@frak-labs/core-sdk 0.0.11 → 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cdn/bundle.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*! For license information please see bundle.js.LICENSE.txt */
2
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.FrakSDK=t():e.FrakSDK=t()}(globalThis,()=>(()=>{"use strict";var e={"../../node_modules/@jsonjoy.com/json-pack/lib/JsonPackExtension.js":function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.JsonPackExtension=void 0,t.JsonPackExtension=class{constructor(e,t){this.tag=e,this.val=t}}},"../../node_modules/@jsonjoy.com/json-pack/lib/JsonPackValue.js":function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.JsonPackValue=void 0,t.JsonPackValue=class{constructor(e){this.val=e}}},"../../node_modules/@jsonjoy.com/json-pack/lib/cbor/CborDecoder.js":function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.CborDecoder=void 0;let n=r("../../node_modules/@jsonjoy.com/json-pack/lib/cbor/CborDecoderBase.js"),i=r("../../node_modules/@jsonjoy.com/json-pack/lib/JsonPackValue.js");class s extends n.CborDecoderBase{readAsMap(){let e=this.reader.u8();if(e>>5==5)return this.readMap(31&e);throw 0}readMap(e){let t=this.readMinorLen(e);return t>=0?this.readMapRaw(t):this.readMapIndef()}readMapRaw(e){let t=new Map;for(let r=0;r<e;r++){let e=this.val(),r=this.val();t.set(e,r)}return t}readMapIndef(){let e=new Map;for(;255!==this.reader.peak();){let t=this.val();if(255===this.reader.peak())throw 7;let r=this.val();e.set(t,r)}return this.reader.x++,e}skipN(e){for(let t=0;t<e;t++)this.skipAny()}skipAny(){this.skipAnyRaw(this.reader.u8())}skipAnyRaw(e){let t=31&e;switch(e>>5){case 0:case 1:this.skipUNint(t);break;case 2:this.skipBin(t);break;case 3:this.skipStr(t);break;case 4:this.skipArr(t);break;case 5:this.skipObj(t);break;case 7:this.skipTkn(t);break;case 6:this.skipTag(t)}}skipMinorLen(e){if(e<=23)return e;switch(e){case 24:return this.reader.u8();case 25:return this.reader.u16();case 26:return this.reader.u32();case 27:return Number(this.reader.u64());case 31:return -1;default:throw 1}}skipUNint(e){if(!(e<=23))switch(e){case 24:return this.reader.skip(1);case 25:return this.reader.skip(2);case 26:return this.reader.skip(4);case 27:return this.reader.skip(8);default:throw 1}}skipBin(e){let t=this.skipMinorLen(e);if(t>=0)this.reader.skip(t);else{for(;255!==this.reader.peak();)this.skipBinChunk();this.reader.x++}}skipBinChunk(){let e=this.reader.u8(),t=31&e;if(2!=e>>5)throw 2;if(t>27)throw 3;this.skipBin(t)}skipStr(e){let t=this.skipMinorLen(e);if(t>=0)this.reader.skip(t);else{for(;255!==this.reader.peak();)this.skipStrChunk();this.reader.x++}}skipStrChunk(){let e=this.reader.u8(),t=31&e;if(3!=e>>5)throw 4;if(t>27)throw 5;this.skipStr(t)}skipArr(e){let t=this.skipMinorLen(e);if(t>=0)this.skipN(t);else{for(;255!==this.reader.peak();)this.skipAny();this.reader.x++}}skipObj(e){let t=this.readMinorLen(e);if(t>=0)return this.skipN(2*t);for(;255!==this.reader.peak();){if(this.skipAny(),255===this.reader.peak())throw 7;this.skipAny()}this.reader.x++}skipTag(e){if(0>this.skipMinorLen(e))throw 1;this.skipAny()}skipTkn(e){switch(e){case 24:this.reader.skip(1);return;case 25:this.reader.skip(2);return;case 26:this.reader.skip(4);return;case 27:this.reader.skip(8);return}if(!(e<=23))throw 1}validate(e,t=0,r=e.length){if(this.reader.reset(e),this.reader.x=t,this.skipAny(),this.reader.x-t!==r)throw 8}decodeLevel(e){return this.reader.reset(e),this.readLevel()}readLevel(){let e=this.reader.u8(),t=e>>5,r=31&e;switch(t){case 4:return this.readArrLevel(r);case 5:return this.readObjLevel(r);default:return super.readAnyRaw(e)}}readPrimitiveOrVal(){switch(this.reader.peak()>>5){case 4:case 5:return this.readAsValue();default:return this.val()}}readAsValue(){let e=this.reader,t=e.x;this.skipAny();let r=e.x;return new i.JsonPackValue(e.uint8.subarray(t,r))}readObjLevel(e){let t=this.readMinorLen(e);return t>=0?this.readObjRawLevel(t):this.readObjIndefLevel()}readObjRawLevel(e){let t={};for(let r=0;r<e;r++){let e=this.key(),r=this.readPrimitiveOrVal();t[e]=r}return t}readObjIndefLevel(){let e={};for(;255!==this.reader.peak();){let t=this.key();if(255===this.reader.peak())throw 7;let r=this.readPrimitiveOrVal();e[t]=r}return this.reader.x++,e}readArrLevel(e){let t=this.readMinorLen(e);return t>=0?this.readArrRawLevel(t):this.readArrIndefLevel()}readArrRawLevel(e){let t=[];for(let r=0;r<e;r++)t.push(this.readPrimitiveOrVal());return t}readArrIndefLevel(){let e=[];for(;255!==this.reader.peak();)e.push(this.readPrimitiveOrVal());return this.reader.x++,e}readHdr(e){let t=this.reader.u8();if(t>>5!==e)throw 0;let r=31&t;if(r<24)return r;switch(r){case 24:return this.reader.u8();case 25:return this.reader.u16();case 26:return this.reader.u32();case 27:return Number(this.reader.u64());case 31:return -1}throw 1}readStrHdr(){return this.readHdr(3)}readObjHdr(){return this.readHdr(5)}readArrHdr(){return this.readHdr(4)}findKey(e){let t=this.readObjHdr();for(let r=0;r<t;r++){if(this.key()===e)return this;this.skipAny()}throw 9}findIndex(e){if(e>=this.readArrHdr())throw 10;for(let t=0;t<e;t++)this.skipAny();return this}find(e){for(let t=0;t<e.length;t++){let r=e[t];"string"==typeof r?this.findKey(r):this.findIndex(r)}return this}}t.CborDecoder=s},"../../node_modules/@jsonjoy.com/json-pack/lib/cbor/CborDecoderBase.js":function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.CborDecoderBase=void 0;let n=r("../../node_modules/tslib/tslib.es6.mjs"),i=r("../../node_modules/@jsonjoy.com/util/lib/buffers/f16.js"),s=r("../../node_modules/@jsonjoy.com/json-pack/lib/JsonPackExtension.js"),o=r("../../node_modules/@jsonjoy.com/json-pack/lib/JsonPackValue.js"),a=r("../../node_modules/@jsonjoy.com/util/lib/buffers/Reader.js"),u=n.__importDefault(r("../../node_modules/@jsonjoy.com/util/lib/buffers/utf8/sharedCachedUtf8Decoder.js"));t.CborDecoderBase=class{constructor(e=new a.Reader,t=u.default){this.reader=e,this.keyDecoder=t}read(e){return this.reader.reset(e),this.val()}decode(e){return this.reader.reset(e),this.val()}val(){let e=this.reader.u8(),t=e>>5,r=31&e;return t<4?t<2?0===t?this.readUint(r):this.readNint(r):2===t?this.readBin(r):this.readStr(r):t<6?4===t?this.readArr(r):this.readObj(r):6===t?this.readTag(r):this.readTkn(r)}readAnyRaw(e){let t=e>>5,r=31&e;return t<4?t<2?0===t?this.readUint(r):this.readNint(r):2===t?this.readBin(r):this.readStr(r):t<6?4===t?this.readArr(r):this.readObj(r):6===t?this.readTag(r):this.readTkn(r)}readMinorLen(e){if(e<24)return e;switch(e){case 24:return this.reader.u8();case 25:return this.reader.u16();case 26:return this.reader.u32();case 27:return Number(this.reader.u64());case 31:return -1;default:throw 1}}readUint(e){if(e<25)return 24===e?this.reader.u8():e;if(e<27)return 25===e?this.reader.u16():this.reader.u32();{let e=this.reader.u64();return e>0x1fffffffffffff?e:Number(e)}}readNint(e){if(e<25)return 24===e?-this.reader.u8()-1:-e-1;if(e<27)return 25===e?-this.reader.u16()-1:-this.reader.u32()-1;{let e=this.reader.u64();return e>0x1ffffffffffffe?-e-BigInt(1):-Number(e)-1}}readBin(e){let t=this.reader;if(e<=23)return t.buf(e);switch(e){case 24:return t.buf(t.u8());case 25:return t.buf(t.u16());case 26:return t.buf(t.u32());case 27:return t.buf(Number(t.u64()));case 31:{let e=0,t=[];for(;255!==this.reader.peak();){let r=this.readBinChunk();e+=r.length,t.push(r)}this.reader.x++;let r=new Uint8Array(e),n=0,i=t.length;for(let e=0;e<i;e++){let i=t[e];r.set(i,n),n+=i.length}return r}default:throw 1}}readBinChunk(){let e=this.reader.u8(),t=31&e;if(2!=e>>5)throw 2;if(t>27)throw 3;return this.readBin(t)}readAsStr(){let e=this.reader.u8();if(3!=e>>5)throw 11;return this.readStr(31&e)}readStr(e){let t=this.reader;if(e<=23)return t.utf8(e);switch(e){case 24:return t.utf8(t.u8());case 25:return t.utf8(t.u16());case 26:return t.utf8(t.u32());case 27:return t.utf8(Number(t.u64()));case 31:{let e="";for(;255!==t.peak();)e+=this.readStrChunk();return this.reader.x++,e}default:throw 1}}readStrLen(e){if(e<=23)return e;switch(e){case 24:return this.reader.u8();case 25:return this.reader.u16();case 26:return this.reader.u32();case 27:return Number(this.reader.u64());default:throw 1}}readStrChunk(){let e=this.reader.u8(),t=31&e;if(3!=e>>5)throw 4;if(t>27)throw 5;return this.readStr(t)}readArr(e){let t=this.readMinorLen(e);return t>=0?this.readArrRaw(t):this.readArrIndef()}readArrRaw(e){let t=[];for(let r=0;r<e;r++)t.push(this.val());return t}readArrIndef(){let e=[];for(;255!==this.reader.peak();)e.push(this.val());return this.reader.x++,e}readObj(e){if(e<28){let t=e;switch(e){case 24:t=this.reader.u8();break;case 25:t=this.reader.u16();break;case 26:t=this.reader.u32();break;case 27:t=Number(this.reader.u64())}let r={};for(let e=0;e<t;e++){let e=this.key();if("__proto__"===e)throw 6;let t=this.val();r[e]=t}return r}if(31===e)return this.readObjIndef();throw 1}readObjRaw(e){let t={};for(let r=0;r<e;r++){let e=this.key(),r=this.val();t[e]=r}return t}readObjIndef(){let e={};for(;255!==this.reader.peak();){let t=this.key();if(255===this.reader.peak())throw 7;let r=this.val();e[t]=r}return this.reader.x++,e}key(){let e=this.reader.u8();if(3!=e>>5)return String(this.readAnyRaw(e));let t=this.readStrLen(31&e);if(t>31)return this.reader.utf8(t);let r=this.keyDecoder.decode(this.reader.uint8,this.reader.x,t);return this.reader.skip(t),r}readTag(e){if(e<=23)return this.readTagRaw(e);switch(e){case 24:return this.readTagRaw(this.reader.u8());case 25:return this.readTagRaw(this.reader.u16());case 26:return this.readTagRaw(this.reader.u32());case 27:return this.readTagRaw(Number(this.reader.u64()));default:throw 1}}readTagRaw(e){return new s.JsonPackExtension(e,this.val())}readTkn(e){switch(e){case 20:return!1;case 21:return!0;case 22:return null;case 23:return;case 24:return new o.JsonPackValue(this.reader.u8());case 25:return this.f16();case 26:return this.reader.f32();case 27:return this.reader.f64()}if(e<=23)return new o.JsonPackValue(e);throw 1}f16(){return(0,i.decodeF16)(this.reader.u16())}}},"../../node_modules/@jsonjoy.com/json-pack/lib/cbor/CborDecoderDag.js":function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.CborDecoderDag=void 0;let n=r("../../node_modules/@jsonjoy.com/json-pack/lib/JsonPackExtension.js"),i=r("../../node_modules/@jsonjoy.com/json-pack/lib/cbor/CborDecoder.js");class s extends i.CborDecoder{readTagRaw(e){let t=this.val();return 42===e?new n.JsonPackExtension(e,t):t}}t.CborDecoderDag=s},"../../node_modules/@jsonjoy.com/json-pack/lib/cbor/CborEncoder.js":function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.CborEncoder=void 0;let n=r("../../node_modules/@jsonjoy.com/util/lib/buffers/isFloat32.js"),i=r("../../node_modules/@jsonjoy.com/json-pack/lib/JsonPackExtension.js"),s=r("../../node_modules/@jsonjoy.com/json-pack/lib/cbor/CborEncoderFast.js"),o=r("../../node_modules/@jsonjoy.com/json-pack/lib/JsonPackValue.js");class a extends s.CborEncoderFast{writeUnknown(e){this.writeNull()}writeAny(e){switch(typeof e){case"number":return this.writeNumber(e);case"string":return this.writeStr(e);case"boolean":return this.writer.u8(244+ +e);case"object":if(!e)return this.writer.u8(246);switch(e.constructor){case Object:return this.writeObj(e);case Array:return this.writeArr(e);case Uint8Array:return this.writeBin(e);case Map:return this.writeMap(e);case i.JsonPackExtension:return this.writeTag(e.tag,e.val);case o.JsonPackValue:let t=e.val;return this.writer.buf(t,t.length);default:if(e instanceof Uint8Array)return this.writeBin(e);if(Array.isArray(e))return this.writeArr(e);if(e instanceof Map)return this.writeMap(e);return this.writeUnknown(e)}case"undefined":return this.writeUndef();case"bigint":return this.writeBigInt(e);default:return this.writeUnknown(e)}}writeFloat(e){(0,n.isFloat32)(e)?this.writer.u8f32(250,e):this.writer.u8f64(251,e)}writeMap(e){this.writeMapHdr(e.size),e.forEach((e,t)=>{this.writeAny(t),this.writeAny(e)})}writeUndef(){this.writer.u8(247)}}t.CborEncoder=a},"../../node_modules/@jsonjoy.com/json-pack/lib/cbor/CborEncoderDag.js":function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.CborEncoderDag=void 0;let n=r("../../node_modules/@jsonjoy.com/json-pack/lib/cbor/CborEncoderStable.js");class i extends n.CborEncoderStable{writeUndef(){this.writeNull()}writeFloat(e){if(e!=e||!Number.isFinite(e))return this.writeNull();this.writer.u8f64(251,e)}writeTag(e,t){42===e&&this.writeTagHdr(e),this.writeAny(t)}}t.CborEncoderDag=i},"../../node_modules/@jsonjoy.com/json-pack/lib/cbor/CborEncoderFast.js":function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.CborEncoderFast=void 0;let n=r("../../node_modules/@jsonjoy.com/util/lib/buffers/Writer.js"),i=Number.isSafeInteger;t.CborEncoderFast=class{constructor(e=new n.Writer){this.writer=e}encode(e){return this.writeAny(e),this.writer.flush()}encodeToSlice(e){return this.writeAny(e),this.writer.flushSlice()}writeAny(e){switch(typeof e){case"number":return this.writeNumber(e);case"string":return this.writeStr(e);case"boolean":return this.writer.u8(244+ +e);case"object":if(!e)return this.writer.u8(246);if(e.constructor===Array)return this.writeArr(e);return this.writeObj(e)}}writeCbor(){this.writer.u8u16(217,55799)}writeEnd(){this.writer.u8(255)}writeNull(){this.writer.u8(246)}writeBoolean(e){e?this.writer.u8(245):this.writer.u8(244)}writeNumber(e){i(e)?this.writeInteger(e):"bigint"==typeof e?this.writeBigInt(e):this.writeFloat(e)}writeBigInt(e){e>=0?this.writeBigUint(e):this.writeBigSint(e)}writeBigUint(e){if(e<=Number.MAX_SAFE_INTEGER)return this.writeUInteger(Number(e));this.writer.u8u64(27,e)}writeBigSint(e){if(e>=Number.MIN_SAFE_INTEGER)return this.encodeNint(Number(e));let t=-BigInt(1)-e;this.writer.u8u64(59,t)}writeInteger(e){e>=0?this.writeUInteger(e):this.encodeNint(e)}writeUInteger(e){let t=this.writer;t.ensureCapacity(9);let r=t.uint8,n=t.x;e<=23?r[n++]=0+e:e<=255?(r[n++]=24,r[n++]=e):e<=65535?(r[n++]=25,t.view.setUint16(n,e),n+=2):e<=0xffffffff?(r[n++]=26,t.view.setUint32(n,e),n+=4):(r[n++]=27,t.view.setBigUint64(n,BigInt(e)),n+=8),t.x=n}encodeNumber(e){this.writeNumber(e)}encodeInteger(e){this.writeInteger(e)}encodeUint(e){this.writeUInteger(e)}encodeNint(e){let t=-1-e,r=this.writer;r.ensureCapacity(9);let n=r.uint8,i=r.x;t<24?n[i++]=32+t:t<=255?(n[i++]=56,n[i++]=t):t<=65535?(n[i++]=57,r.view.setUint16(i,t),i+=2):t<=0xffffffff?(n[i++]=58,r.view.setUint32(i,t),i+=4):(n[i++]=59,r.view.setBigUint64(i,BigInt(t)),i+=8),r.x=i}writeFloat(e){this.writer.u8f64(251,e)}writeBin(e){let t=e.length;this.writeBinHdr(t),this.writer.buf(e,t)}writeBinHdr(e){let t=this.writer;e<=23?t.u8(64+e):e<=255?t.u16(22528+e):e<=65535?t.u8u16(89,e):e<=0xffffffff?t.u8u32(90,e):t.u8u64(91,e)}writeStr(e){let t=this.writer,r=4*e.length;t.ensureCapacity(5+r);let n=t.uint8,i=t.x;r<=23?t.x++:r<=255?(n[t.x++]=120,i=t.x,t.x++):r<=65535?(n[t.x++]=121,i=t.x,t.x+=2):(n[t.x++]=122,i=t.x,t.x+=4);let s=t.utf8(e);r<=23?n[i]=96+s:r<=255?n[i]=s:r<=65535?t.view.setUint16(i,s):t.view.setUint32(i,s)}writeStrHdr(e){let t=this.writer;e<=23?t.u8(96+e):e<=255?t.u16(30720+e):e<=65535?t.u8u16(121,e):t.u8u32(122,e)}writeAsciiStr(e){this.writeStrHdr(e.length),this.writer.ascii(e)}writeArr(e){let t=e.length;this.writeArrHdr(t);for(let r=0;r<t;r++)this.writeAny(e[r])}writeArrHdr(e){let t=this.writer;e<=23?t.u8(128+e):e<=255?t.u16(38912+e):e<=65535?t.u8u16(153,e):e<=0xffffffff?t.u8u32(154,e):t.u8u64(155,e)}writeObj(e){let t=Object.keys(e),r=t.length;this.writeObjHdr(r);for(let n=0;n<r;n++){let r=t[n];this.writeStr(r),this.writeAny(e[r])}}writeObjHdr(e){let t=this.writer;e<=23?t.u8(160+e):e<=255?t.u16(47104+e):e<=65535?t.u8u16(185,e):e<=0xffffffff?t.u8u32(186,e):t.u8u64(187,e)}writeMapHdr(e){this.writeObjHdr(e)}writeStartMap(){this.writer.u8(191)}writeTag(e,t){this.writeTagHdr(e),this.writeAny(t)}writeTagHdr(e){let t=this.writer;e<=23?t.u8(192+e):e<=255?t.u16(55296+e):e<=65535?t.u8u16(217,e):e<=0xffffffff?t.u8u32(218,e):t.u8u64(219,e)}writeTkn(e){let t=this.writer;e<=23?t.u8(224+e):e<=255&&t.u16(63488+e)}writeStartStr(){this.writer.u8(127)}writeStrChunk(e){throw Error("Not implemented")}writeEndStr(){throw Error("Not implemented")}writeStartBin(){this.writer.u8(95)}writeBinChunk(e){throw Error("Not implemented")}writeEndBin(){throw Error("Not implemented")}writeStartArr(){this.writer.u8(159)}writeArrChunk(e){throw Error("Not implemented")}writeEndArr(){this.writer.u8(255)}writeStartObj(){this.writer.u8(191)}writeObjChunk(e,t){throw Error("Not implemented")}writeEndObj(){this.writer.u8(255)}}},"../../node_modules/@jsonjoy.com/json-pack/lib/cbor/CborEncoderStable.js":function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.CborEncoderStable=void 0;let n=r("../../node_modules/@jsonjoy.com/json-pack/lib/cbor/CborEncoder.js"),i=r("../../node_modules/@jsonjoy.com/util/lib/sort/insertion2.js"),s=r("../../node_modules/@jsonjoy.com/util/lib/objKeyCmp.js"),o=e=>e<=23?1:e<=255?2:e<=65535?3:5;class a extends n.CborEncoder{writeObj(e){let t=Object.keys(e);(0,i.sort)(t,s.objKeyCmp);let r=t.length;this.writeObjHdr(r);for(let n=0;n<r;n++){let r=t[n];this.writeStr(r),this.writeAny(e[r])}}writeStr(e){let t=this.writer,r=e.length,n=4*r;t.ensureCapacity(5+n);let i=o(r),s=t.x,a=s+i;t.x=a;let u=t.utf8(e),l=t.uint8,c=o(u);switch(c!==i&&l.copyWithin(a+(c-i),a,a+u),c){case 1:l[s]=96+u;break;case 2:l[s]=120,l[s+1]=u;break;case 3:l[s]=121,t.view.setUint16(s+1,u);break;case 5:l[s]=122,t.view.setUint32(s+1,u)}t.x=s+c+u}writeUndef(){this.writeNull()}}t.CborEncoderStable=a},"../../node_modules/@jsonjoy.com/json-pack/lib/cbor/index.js":function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});let n=r("../../node_modules/tslib/tslib.es6.mjs");n.__exportStar(r("../../node_modules/@jsonjoy.com/json-pack/lib/cbor/types.js"),t),n.__exportStar(r("../../node_modules/@jsonjoy.com/json-pack/lib/cbor/CborEncoderFast.js"),t),n.__exportStar(r("../../node_modules/@jsonjoy.com/json-pack/lib/cbor/CborEncoder.js"),t),n.__exportStar(r("../../node_modules/@jsonjoy.com/json-pack/lib/cbor/CborEncoderStable.js"),t),n.__exportStar(r("../../node_modules/@jsonjoy.com/json-pack/lib/cbor/CborEncoderDag.js"),t),n.__exportStar(r("../../node_modules/@jsonjoy.com/json-pack/lib/cbor/CborDecoderBase.js"),t),n.__exportStar(r("../../node_modules/@jsonjoy.com/json-pack/lib/cbor/CborDecoder.js"),t),n.__exportStar(r("../../node_modules/@jsonjoy.com/json-pack/lib/cbor/CborDecoderDag.js"),t)},"../../node_modules/@jsonjoy.com/json-pack/lib/cbor/types.js":function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},"../../node_modules/@jsonjoy.com/util/lib/buffers/Reader.js":function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.Reader=void 0;let n=r("../../node_modules/@jsonjoy.com/util/lib/buffers/utf8/decodeUtf8/index.js");t.Reader=class{constructor(){this.uint8=new Uint8Array([]),this.view=new DataView(this.uint8.buffer),this.x=0}reset(e){this.x=0,this.uint8=e,this.view=new DataView(e.buffer,e.byteOffset,e.length)}peak(){return this.view.getUint8(this.x)}skip(e){this.x+=e}buf(e){let t=this.x+e,r=this.uint8.subarray(this.x,t);return this.x=t,r}u8(){return this.uint8[this.x++]}i8(){return this.view.getInt8(this.x++)}u16(){let e=this.x,t=(this.uint8[e++]<<8)+this.uint8[e++];return this.x=e,t}i16(){let e=this.view.getInt16(this.x);return this.x+=2,e}u32(){let e=this.view.getUint32(this.x);return this.x+=4,e}i32(){let e=this.view.getInt32(this.x);return this.x+=4,e}u64(){let e=this.view.getBigUint64(this.x);return this.x+=8,e}i64(){let e=this.view.getBigInt64(this.x);return this.x+=8,e}f32(){let e=this.x;return this.x+=4,this.view.getFloat32(e)}f64(){let e=this.x;return this.x+=8,this.view.getFloat64(e)}utf8(e){let t=this.x;return this.x+=e,(0,n.decodeUtf8)(this.uint8,t,e)}ascii(e){let t=this.uint8,r="",n=this.x+e;for(let e=this.x;e<n;e++)r+=String.fromCharCode(t[e]);return this.x=n,r}}},"../../node_modules/@jsonjoy.com/util/lib/buffers/Slice.js":function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.Slice=void 0,t.Slice=class{constructor(e,t,r,n){this.uint8=e,this.view=t,this.start=r,this.end=n}subarray(){return this.uint8.subarray(this.start,this.end)}}},"../../node_modules/@jsonjoy.com/util/lib/buffers/Writer.js":function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.Writer=void 0;let n=r("../../node_modules/@jsonjoy.com/util/lib/buffers/Slice.js"),i=new DataView(new Uint8Array([]).buffer),s="function"==typeof Buffer,o=s?Buffer.prototype.utf8Write:null,a=s?Buffer.from:null,u="undefined"!=typeof TextEncoder?new TextEncoder:null;t.Writer=class{constructor(e=65536){this.allocSize=e,this.view=i,this.x0=0,this.x=0,this.uint8=new Uint8Array(e),this.size=e,this.view=new DataView(this.uint8.buffer)}grow(e){let t=this.x0,r=this.x,n=this.uint8,i=new Uint8Array(e),s=new DataView(i.buffer),o=n.subarray(t,r);i.set(o,0),this.x=r-t,this.x0=0,this.uint8=i,this.size=e,this.view=s}ensureCapacity(e){let t=this.size,r=t-this.x;if(r<e){let n=t-this.x0+(e-r);this.grow(n<=this.allocSize?this.allocSize:2*n)}}move(e){this.ensureCapacity(e),this.x+=e}reset(){this.x0=this.x}newBuffer(e){let t=this.uint8=new Uint8Array(e);this.size=e,this.view=new DataView(t.buffer),this.x=this.x0=0}flush(){let e=this.uint8.subarray(this.x0,this.x);return this.x0=this.x,e}flushSlice(){let e=new n.Slice(this.uint8,this.view,this.x0,this.x);return this.x0=this.x,e}u8(e){this.ensureCapacity(1),this.uint8[this.x++]=e}u16(e){this.ensureCapacity(2),this.view.setUint16(this.x,e),this.x+=2}u32(e){this.ensureCapacity(4),this.view.setUint32(this.x,e),this.x+=4}i32(e){this.ensureCapacity(4),this.view.setInt32(this.x,e),this.x+=4}u64(e){this.ensureCapacity(8),this.view.setBigUint64(this.x,BigInt(e)),this.x+=8}f64(e){this.ensureCapacity(8),this.view.setFloat64(this.x,e),this.x+=8}u8u16(e,t){this.ensureCapacity(3);let r=this.x;this.uint8[r++]=e,this.uint8[r++]=t>>>8,this.uint8[r++]=255&t,this.x=r}u8u32(e,t){this.ensureCapacity(5);let r=this.x;this.uint8[r++]=e,this.view.setUint32(r,t),this.x=r+4}u8u64(e,t){this.ensureCapacity(9);let r=this.x;this.uint8[r++]=e,this.view.setBigUint64(r,BigInt(t)),this.x=r+8}u8f32(e,t){this.ensureCapacity(5);let r=this.x;this.uint8[r++]=e,this.view.setFloat32(r,t),this.x=r+4}u8f64(e,t){this.ensureCapacity(9);let r=this.x;this.uint8[r++]=e,this.view.setFloat64(r,t),this.x=r+8}buf(e,t){this.ensureCapacity(t);let r=this.x;this.uint8.set(e,r),this.x=r+t}utf8(e){let t=4*e.length;if(t<168)return this.utf8Native(e);if(o){let r=o.call(this.uint8,e,this.x,t);return this.x+=r,r}if(a){let r=this.uint8,n=r.byteOffset+this.x,i=a(r.buffer).subarray(n,n+t).write(e,0,t,"utf8");return this.x+=i,i}if(t>1024&&u){let r=u.encodeInto(e,this.uint8.subarray(this.x,this.x+t)).written;return this.x+=r,r}return this.utf8Native(e)}utf8Native(e){let t=e.length,r=this.uint8,n=this.x,i=0;for(;i<t;){let s=e.charCodeAt(i++);if((0xffffff80&s)==0){r[n++]=s;continue}if((0xfffff800&s)==0)r[n++]=s>>6&31|192;else{if(s>=55296&&s<=56319&&i<t){let t=e.charCodeAt(i);(64512&t)==56320&&(i++,s=((1023&s)<<10)+(1023&t)+65536)}(0xffff0000&s)==0?r[n++]=s>>12&15|224:(r[n++]=s>>18&7|240,r[n++]=s>>12&63|128),r[n++]=s>>6&63|128}r[n++]=63&s|128}let s=n-this.x;return this.x=n,s}ascii(e){let t=e.length;this.ensureCapacity(t);let r=this.uint8,n=this.x,i=0;for(;i<t;)r[n++]=e.charCodeAt(i++);this.x=n}}},"../../node_modules/@jsonjoy.com/util/lib/buffers/f16.js":function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.decodeF16=void 0;let r=Math.pow;t.decodeF16=e=>{let t=(31744&e)>>10,n=1023&e;return(e>>15?-1:1)*(t?31===t?n?NaN:1/0:r(2,t-15)*(1+n/1024):n/1024*6103515625e-14)}},"../../node_modules/@jsonjoy.com/util/lib/buffers/isFloat32.js":function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.isFloat32=void 0;let r=new DataView(new ArrayBuffer(4));t.isFloat32=e=>(r.setFloat32(0,e),e===r.getFloat32(0))},"../../node_modules/@jsonjoy.com/util/lib/buffers/utf8/CachedUtf8Decoder.js":function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.CachedUtf8Decoder=void 0;let n=r("../../node_modules/tslib/tslib.es6.mjs").__importDefault(r("../../node_modules/@jsonjoy.com/util/lib/buffers/utf8/decodeUtf8/v10.js")),i=1+Math.round(0xfffffffe*Math.random());class s{constructor(e,t){this.bytes=e,this.value=t}}t.CachedUtf8Decoder=class{constructor(){this.caches=[];for(let e=0;e<31;e++)this.caches.push([])}get(e,t,r){let n=this.caches[r-1],i=n.length;e:for(let s=0;s<i;s++){let i=n[s],o=i.bytes;for(let n=0;n<r;n++)if(o[n]!==e[t+n])continue e;return i.value}return null}store(e,t){let r=this.caches[e.length-1],n=new s(e,t);if(r.length>=16)r[i^=i<<13,i^=i>>>17,((i^=i<<5)>>>0)%16+0]=n;else r.push(n)}decode(e,t,r){if(!r)return"";let i=this.get(e,t,r);if(null!==i)return i;let s=(0,n.default)(e,t,r),o=Uint8Array.prototype.slice.call(e,t,t+r);return this.store(o,s),s}}},"../../node_modules/@jsonjoy.com/util/lib/buffers/utf8/decodeAscii.js":function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.decodeAsciiMax15=t.decodeAscii=void 0;let r=String.fromCharCode;t.decodeAscii=(e,t,n)=>{let i=[];for(let r=0;r<n;r++){let r=e[t++];if(128&r)return;i.push(r)}return r.apply(String,i)},t.decodeAsciiMax15=(e,t,n)=>{if(n<4){if(n<2){if(0===n)return"";{let n=e[t++];if((128&n)>1){t-=1;return}return r(n)}}{let i=e[t++],s=e[t++];if((128&i)>0||(128&s)>0){t-=2;return}if(n<3)return r(i,s);let o=e[t++];if((128&o)>0){t-=3;return}return r(i,s,o)}}{let i=e[t++],s=e[t++],o=e[t++],a=e[t++];if((128&i)>0||(128&s)>0||(128&o)>0||(128&a)>0){t-=4;return}if(n<6){if(4===n)return r(i,s,o,a);{let n=e[t++];if((128&n)>0){t-=5;return}return r(i,s,o,a,n)}}if(n<8){let u=e[t++],l=e[t++];if((128&u)>0||(128&l)>0){t-=6;return}if(n<7)return r(i,s,o,a,u,l);let c=e[t++];if((128&c)>0){t-=7;return}return r(i,s,o,a,u,l,c)}{let u=e[t++],l=e[t++],c=e[t++],f=e[t++];if((128&u)>0||(128&l)>0||(128&c)>0||(128&f)>0){t-=8;return}if(n<10){if(8===n)return r(i,s,o,a,u,l,c,f);{let n=e[t++];if((128&n)>0){t-=9;return}return r(i,s,o,a,u,l,c,f,n)}}if(n<12){let d=e[t++],h=e[t++];if((128&d)>0||(128&h)>0){t-=10;return}if(n<11)return r(i,s,o,a,u,l,c,f,d,h);let p=e[t++];if((128&p)>0){t-=11;return}return r(i,s,o,a,u,l,c,f,d,h,p)}{let d=e[t++],h=e[t++],p=e[t++],w=e[t++];if((128&d)>0||(128&h)>0||(128&p)>0||(128&w)>0){t-=12;return}if(n<14){if(12===n)return r(i,s,o,a,u,l,c,f,d,h,p,w);{let n=e[t++];if((128&n)>0){t-=13;return}return r(i,s,o,a,u,l,c,f,d,h,p,w,n)}}{let b=e[t++],y=e[t++];if((128&b)>0||(128&y)>0){t-=14;return}if(n<15)return r(i,s,o,a,u,l,c,f,d,h,p,w,b,y);let m=e[t++];if((128&m)>0){t-=15;return}return r(i,s,o,a,u,l,c,f,d,h,p,w,b,y,m)}}}}}},"../../node_modules/@jsonjoy.com/util/lib/buffers/utf8/decodeUtf8/index.js":function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.decodeUtf8=void 0;let n=r("../../node_modules/tslib/tslib.es6.mjs").__importDefault(r("../../node_modules/@jsonjoy.com/util/lib/buffers/utf8/decodeUtf8/v16.js"));t.decodeUtf8=n.default},"../../node_modules/@jsonjoy.com/util/lib/buffers/utf8/decodeUtf8/v10.js":function(e,t){Object.defineProperty(t,"__esModule",{value:!0});let r=String.fromCharCode;t.default=(e,t,n)=>{let i=t,s=i+n,o="";for(;i<s;){let t=e[i++];if((128&t)==0){o+=r(t);continue}let n=63&e[i++];if((224&t)==192){o+=r((31&t)<<6|n);continue}let s=63&e[i++];if((240&t)==224){o+=r((31&t)<<12|n<<6|s);continue}if((248&t)==240){let a=(7&t)<<18|n<<12|s<<6|63&e[i++];a>65535?o+=r((a-=65536)>>>10&1023|55296,a=56320|1023&a):o+=r(a)}else o+=r(t)}return o}},"../../node_modules/@jsonjoy.com/util/lib/buffers/utf8/decodeUtf8/v16.js":function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});let n=r("../../node_modules/tslib/tslib.es6.mjs"),i=r("../../node_modules/@jsonjoy.com/util/lib/buffers/utf8/decodeAscii.js"),s=n.__importDefault(r("../../node_modules/@jsonjoy.com/util/lib/buffers/utf8/decodeUtf8/v18.js")),o="undefined"!=typeof Buffer,a=o?Buffer.prototype.utf8Slice:null,u=o?Buffer.from:null,l=(e,t,r)=>(0,i.decodeAsciiMax15)(e,t,r)??(0,s.default)(e,t,r),c=(e,t,r)=>(0,i.decodeAscii)(e,t,r)??(0,s.default)(e,t,r),f=a?(e,t,r)=>a.call(e,t,t+r):u?(e,t,r)=>u(e).subarray(t,t+r).toString("utf8"):s.default;t.default=(e,t,r)=>r<16?l(e,t,r):r<32?c(e,t,r):f(e,t,r)},"../../node_modules/@jsonjoy.com/util/lib/buffers/utf8/decodeUtf8/v18.js":function(e,t){Object.defineProperty(t,"__esModule",{value:!0});let r=String.fromCharCode;t.default=(e,t,n)=>{let i=t,s=i+n,o=[];for(;i<s;){let t=e[i++];if((128&t)!=0){let r=63&e[i++];if((224&t)==192)t=(31&t)<<6|r;else{let n=63&e[i++];if((240&t)==224)t=(31&t)<<12|r<<6|n;else if((248&t)==240){let s=(7&t)<<18|r<<12|n<<6|63&e[i++];if(s>65535){let e=(s-=65536)>>>10&1023|55296;t=56320|1023&s,o.push(e)}else t=s}}}o.push(t)}return r.apply(String,o)}},"../../node_modules/@jsonjoy.com/util/lib/buffers/utf8/sharedCachedUtf8Decoder.js":function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});let n=r("../../node_modules/@jsonjoy.com/util/lib/buffers/utf8/CachedUtf8Decoder.js");t.default=new n.CachedUtf8Decoder},"../../node_modules/@jsonjoy.com/util/lib/objKeyCmp.js":function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.objKeyCmp=void 0,t.objKeyCmp=(e,t)=>{let r=e.length,n=t.length;return r===n?e>t?1:-1:r-n}},"../../node_modules/@jsonjoy.com/util/lib/sort/insertion2.js":function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.sort=void 0,t.sort=(e,t)=>{let r=e.length;for(let n=1;n<r;n++){let r=e[n],i=n;for(;0!==i&&t(e[i-1],r)>0;)e[i]=e[i-1],i--;e[i]=r}return e}},"../../node_modules/tslib/tslib.es6.mjs":function(e,t,r){r.r(t),r.d(t,{__addDisposableResource:()=>L,__assign:()=>s,__asyncDelegator:()=>S,__asyncGenerator:()=>_,__asyncValues:()=>A,__await:()=>k,__awaiter:()=>p,__classPrivateFieldGet:()=>U,__classPrivateFieldIn:()=>D,__classPrivateFieldSet:()=>M,__createBinding:()=>b,__decorate:()=>a,__disposeResources:()=>$,__esDecorate:()=>l,__exportStar:()=>y,__extends:()=>i,__generator:()=>w,__importDefault:()=>P,__importStar:()=>I,__makeTemplateObject:()=>E,__metadata:()=>h,__param:()=>u,__propKey:()=>f,__read:()=>g,__rest:()=>o,__rewriteRelativeImportExtension:()=>N,__runInitializers:()=>c,__setFunctionName:()=>d,__spread:()=>x,__spreadArray:()=>j,__spreadArrays:()=>v,__values:()=>m,default:()=>T});var n=function(e,t){return(n=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)};function i(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var s=function(){return(s=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};function o(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&0>t.indexOf(n)&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)0>t.indexOf(n[i])&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);return r}function a(e,t,r,n){var i,s=arguments.length,o=s<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(o=(s<3?i(o):s>3?i(t,r,o):i(t,r))||o);return s>3&&o&&Object.defineProperty(t,r,o),o}function u(e,t){return function(r,n){t(r,n,e)}}function l(e,t,r,n,i,s){function o(e){if(void 0!==e&&"function"!=typeof e)throw TypeError("Function expected");return e}for(var a,u=n.kind,l="getter"===u?"get":"setter"===u?"set":"value",c=!t&&e?n.static?e:e.prototype:null,f=t||(c?Object.getOwnPropertyDescriptor(c,n.name):{}),d=!1,h=r.length-1;h>=0;h--){var p={};for(var w in n)p[w]="access"===w?{}:n[w];for(var w in n.access)p.access[w]=n.access[w];p.addInitializer=function(e){if(d)throw TypeError("Cannot add initializers after decoration has completed");s.push(o(e||null))};var b=(0,r[h])("accessor"===u?{get:f.get,set:f.set}:f[l],p);if("accessor"===u){if(void 0===b)continue;if(null===b||"object"!=typeof b)throw TypeError("Object expected");(a=o(b.get))&&(f.get=a),(a=o(b.set))&&(f.set=a),(a=o(b.init))&&i.unshift(a)}else(a=o(b))&&("field"===u?i.unshift(a):f[l]=a)}c&&Object.defineProperty(c,n.name,f),d=!0}function c(e,t,r){for(var n=arguments.length>2,i=0;i<t.length;i++)r=n?t[i].call(e,r):t[i].call(e);return n?r:void 0}function f(e){return"symbol"==typeof e?e:"".concat(e)}function d(e,t,r){return"symbol"==typeof t&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:r?"".concat(r," ",t):t})}function h(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function p(e,t,r,n){return new(r||(r=Promise))(function(i,s){function o(e){try{u(n.next(e))}catch(e){s(e)}}function a(e){try{u(n.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?i(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(o,a)}u((n=n.apply(e,t||[])).next())})}function w(e,t){var r,n,i,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(u){return function(a){if(r)throw TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(i=(i=s.trys).length>0&&i[i.length-1])&&(6===a[0]||2===a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}var b=Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]};function y(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||b(t,e,r)}function m(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function g(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,s=r.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(n=s.next()).done;)o.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(i)throw i.error}}return o}function x(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(g(arguments[t]));return e}function v(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;for(var n=Array(e),i=0,t=0;t<r;t++)for(var s=arguments[t],o=0,a=s.length;o<a;o++,i++)n[i]=s[o];return n}function j(e,t,r){if(r||2==arguments.length)for(var n,i=0,s=t.length;i<s;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}function k(e){return this instanceof k?(this.v=e,this):new k(e)}function _(e,t,r){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var n,i=r.apply(e,t||[]),s=[];return n=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),o("next"),o("throw"),o("return",function(e){return function(t){return Promise.resolve(t).then(e,l)}}),n[Symbol.asyncIterator]=function(){return this},n;function o(e,t){i[e]&&(n[e]=function(t){return new Promise(function(r,n){s.push([e,t,r,n])>1||a(e,t)})},t&&(n[e]=t(n[e])))}function a(e,t){try{var r;(r=i[e](t)).value instanceof k?Promise.resolve(r.value.v).then(u,l):c(s[0][2],r)}catch(e){c(s[0][3],e)}}function u(e){a("next",e)}function l(e){a("throw",e)}function c(e,t){e(t),s.shift(),s.length&&a(s[0][0],s[0][1])}}function S(e){var t,r;return t={},n("next"),n("throw",function(e){throw e}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(n,i){t[n]=e[n]?function(t){return(r=!r)?{value:k(e[n](t)),done:!1}:i?i(t):t}:i}}function A(e){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=m(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise(function(n,i){!function(e,t,r,n){Promise.resolve(n).then(function(t){e({value:t,done:r})},t)}(n,i,(t=e[r](t)).done,t.value)})}}}function E(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var C=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t},O=function(e){return(O=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t})(e)};function I(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=O(e),n=0;n<r.length;n++)"default"!==r[n]&&b(t,e,r[n]);return C(t,e),t}function P(e){return e&&e.__esModule?e:{default:e}}function U(e,t,r,n){if("a"===r&&!n)throw TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)}function M(e,t,r,n,i){if("m"===n)throw TypeError("Private method is not writable");if("a"===n&&!i)throw TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?i.call(e,r):i?i.value=r:t.set(e,r),r}function D(e,t){if(null===t||"object"!=typeof t&&"function"!=typeof t)throw TypeError("Cannot use 'in' operator on non-object");return"function"==typeof e?t===e:e.has(t)}function L(e,t,r){if(null!=t){var n,i;if("object"!=typeof t&&"function"!=typeof t)throw TypeError("Object expected.");if(r){if(!Symbol.asyncDispose)throw TypeError("Symbol.asyncDispose is not defined.");n=t[Symbol.asyncDispose]}if(void 0===n){if(!Symbol.dispose)throw TypeError("Symbol.dispose is not defined.");n=t[Symbol.dispose],r&&(i=n)}if("function"!=typeof n)throw TypeError("Object not disposable.");i&&(n=function(){try{i.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:n,async:r})}else r&&e.stack.push({async:!0});return t}var B="function"==typeof SuppressedError?SuppressedError:function(e,t,r){var n=Error(r);return n.name="SuppressedError",n.error=e,n.suppressed=t,n};function $(e){function t(t){e.error=e.hasError?new B(t,e.error,"An error was suppressed during disposal."):t,e.hasError=!0}var r,n=0;return function i(){for(;r=e.stack.pop();)try{if(!r.async&&1===n)return n=0,e.stack.push(r),Promise.resolve().then(i);if(r.dispose){var s=r.dispose.call(r.value);if(r.async)return n|=2,Promise.resolve(s).then(i,function(e){return t(e),i()})}else n|=1}catch(e){t(e)}if(1===n)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}()}function N(e,t){return"string"==typeof e&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(e,r,n,i,s){return r?t?".jsx":".js":!n||i&&s?n+i+"."+s.toLowerCase()+"js":e}):e}let T={__extends:i,__assign:s,__rest:o,__decorate:a,__param:u,__esDecorate:l,__runInitializers:c,__propKey:f,__setFunctionName:d,__metadata:h,__awaiter:p,__generator:w,__createBinding:b,__exportStar:y,__values:m,__read:g,__spread:x,__spreadArrays:v,__spreadArray:j,__await:k,__asyncGenerator:_,__asyncDelegator:S,__asyncValues:A,__makeTemplateObject:E,__importStar:I,__importDefault:P,__classPrivateFieldGet:U,__classPrivateFieldSet:M,__classPrivateFieldIn:D,__addDisposableResource:L,__disposeResources:$,__rewriteRelativeImportExtension:N}}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var s=t[n]={exports:{}};return e[n](s,s.exports,r),s.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{let e;r.r(n),r.d(n,{base64urlEncode:()=>l,Deferred:()=>a,ReferralInteractionEncoder:()=>tl,getProductInformation:()=>e6,decompressJsonFromB64:()=>ea,getSupportedLocale:()=>eS,openSso:()=>e3,productTypes:()=>eC,PurchaseInteractionEncoder:()=>t_,FrakRpcError:()=>t,base64urlDecode:()=>c,referralInteraction:()=>th,productTypesMask:()=>eO,interactionTypes:()=>eI,processReferral:()=>tc,PressInteractionEncoder:()=>tp,sendTransaction:()=>e9,WebShopInteractionEncoder:()=>tS,decompressJson:()=>eo,displayEmbededWallet:()=>e8,compressJsonToB64:()=>er,hashAndCompressData:()=>ee,trackPurchaseStatus:()=>e5,RpcErrorCodes:()=>o,setupClient:()=>ey,RetailInteractionEncoder:()=>tA,getCurrencyAmountKey:()=>eE,watchWalletStatus:()=>eP,siweAuthenticate:()=>e7,getSupportedCurrency:()=>eb,decompressDataAndCheckHash:()=>es,displayModal:()=>e1,FrakContextManager:()=>e_,locales:()=>ew,ClientNotFound:()=>s,baseIframeProps:()=>ec,createIframe:()=>ef,modalBuilder:()=>te,compressJson:()=>et,sendInteraction:()=>e2,createIFrameFrakClient:()=>eh,DebugInfoGatherer:()=>el,formatAmount:()=>eA});class t extends Error{code;data;constructor(e,t,r){super(t),this.code=e,this.data=r}}class i extends t{constructor(e){super(o.internalError,e)}}class s extends t{constructor(){super(o.clientNotConnected,"Client not found")}}let o={parseError:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internalError:-32603,serverError:-32e3,clientNotConnected:-32001,configError:-32002,corruptedResponse:-32003,clientAborted:-32004,walletNotConnected:-32005,serverErrorForInteractionDelegation:-32006};class a{_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)}}var u=r("../../node_modules/@jsonjoy.com/json-pack/lib/cbor/index.js");function l(e){return btoa(Array.from(e,e=>String.fromCharCode(e)).join("")).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function c(e){let t=e.length%4;return Uint8Array.from(atob(e.replace(/-/g,"+").replace(/_/g,"/").padEnd(e.length+(0===t?0:4-t),"=")),e=>e.charCodeAt(0))}function f(e){if(!Number.isSafeInteger(e)||e<0)throw Error("positive integer expected, got "+e)}function d(e,...t){if(!(e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name))throw Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw Error("Uint8Array expected of length "+t+", got length="+e.length)}function h(e,t=!0){if(e.destroyed)throw Error("Hash instance has been destroyed");if(t&&e.finished)throw Error("Hash#digest() has already been called")}function p(e,t){d(e);let r=t.outputLen;if(e.length<r)throw Error("digestInto() expects output buffer of length at least "+r)}function w(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function b(e,t){return e<<32-t|e>>>t}let y=68===new Uint8Array(new Uint32Array([0x11223344]).buffer)[0];function m(e){for(let r=0;r<e.length;r++){var t;e[r]=(t=e[r])<<24&0xff000000|t<<8&0xff0000|t>>>8&65280|t>>>24&255}}function g(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array(new TextEncoder().encode(e))}(e)),d(e),e}class x{clone(){return this._cloneInto()}}function v(e){let t=t=>e().update(g(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}class j extends x{constructor(e,t,r,n){super(),this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=w(this.buffer)}update(e){h(this);let{view:t,buffer:r,blockLen:n}=this,i=(e=g(e)).length;for(let s=0;s<i;){let o=Math.min(n-this.pos,i-s);if(o===n){let t=w(e);for(;n<=i-s;s+=n)this.process(t,s);continue}r.set(e.subarray(s,s+o),this.pos),this.pos+=o,s+=o,this.pos===n&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){h(this),p(e,this),this.finished=!0;let{buffer:t,view:r,blockLen:n,isLE:i}=this,{pos:s}=this;t[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>n-s&&(this.process(r,0),s=0);for(let e=s;e<n;e++)t[e]=0;(function(e,t,r,n){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,r,n);let i=BigInt(32),s=BigInt(0xffffffff),o=Number(r>>i&s),a=Number(r&s),u=4*!!n,l=4*!n;e.setUint32(t+u,o,n),e.setUint32(t+l,a,n)})(r,n-8,BigInt(8*this.length),i),this.process(r,0);let o=w(e),a=this.outputLen;if(a%4)throw Error("_sha2: outputLen should be aligned to 32bit");let u=a/4,l=this.get();if(u>l.length)throw Error("_sha2: outputLen bigger than state");for(let e=0;e<u;e++)o.setUint32(4*e,l[e],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:t,buffer:r,length:n,finished:i,destroyed:s,pos:o}=this;return e.length=n,e.pos=o,e.finished=i,e.destroyed=s,n%t&&e.buffer.set(r),e}}let k=new Uint32Array([0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5,0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5,0xd807aa98,0x12835b01,0x243185be,0x550c7dc3,0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174,0xe49b69c1,0xefbe4786,0xfc19dc6,0x240ca1cc,0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da,0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7,0xc6e00bf3,0xd5a79147,0x6ca6351,0x14292967,0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13,0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85,0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3,0xd192e819,0xd6990624,0xf40e3585,0x106aa070,0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5,0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3,0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208,0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2]),_=new Uint32Array([0x6a09e667,0xbb67ae85,0x3c6ef372,0xa54ff53a,0x510e527f,0x9b05688c,0x1f83d9ab,0x5be0cd19]),S=new Uint32Array(64);class A extends j{constructor(){super(64,32,8,!1),this.A=0|_[0],this.B=0|_[1],this.C=0|_[2],this.D=0|_[3],this.E=0|_[4],this.F=0|_[5],this.G=0|_[6],this.H=0|_[7]}get(){let{A:e,B:t,C:r,D:n,E:i,F:s,G:o,H:a}=this;return[e,t,r,n,i,s,o,a]}set(e,t,r,n,i,s,o,a){this.A=0|e,this.B=0|t,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|s,this.G=0|o,this.H=0|a}process(e,t){for(let r=0;r<16;r++,t+=4)S[r]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=S[e-15],r=S[e-2],n=b(t,7)^b(t,18)^t>>>3,i=b(r,17)^b(r,19)^r>>>10;S[e]=i+S[e-7]+n+S[e-16]|0}let{A:r,B:n,C:i,D:s,E:o,F:a,G:u,H:l}=this;for(let e=0;e<64;e++){var c,f,d,h;let t=l+(b(o,6)^b(o,11)^b(o,25))+((c=o)&a^~c&u)+k[e]+S[e]|0,p=(b(r,2)^b(r,13)^b(r,22))+((f=r)&(d=n)^f&(h=i)^d&h)|0;l=u,u=a,a=o,o=s+t|0,s=i,i=n,n=r,r=t+p|0}r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,s=s+this.D|0,o=o+this.E|0,a=a+this.F|0,u=u+this.G|0,l=l+this.H|0,this.set(r,n,i,s,o,a,u,l)}roundClean(){S.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}let E=v(()=>new A);function C(e,{strict:t=!0}={}){return!!e&&"string"==typeof e&&(t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x"))}let O="2.23.15",I={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:r})=>t?`${e??"https://viem.sh"}${t}${r?`#${r}`:""}`:void 0,version:`viem@${O}`};class P extends Error{constructor(e,t={}){let r=t.cause instanceof P?t.cause.details:t.cause?.message?t.cause.message:t.details,n=t.cause instanceof P&&t.cause.docsPath||t.docsPath,i=I.getDocsUrl?.({...t,docsPath:n});super([e||"An error occurred.","",...t.metaMessages?[...t.metaMessages,""]:[],...i?[`Docs: ${i}`]:[],...r?[`Details: ${r}`]:[],...I.version?[`Version: ${I.version}`]:[]].join("\n"),t.cause?{cause:t.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=r,this.docsPath=n,this.metaMessages=t.metaMessages,this.name=t.name??this.name,this.shortMessage=e,this.version=O}walk(e){return function e(t,r){return r?.(t)?t:t&&"object"==typeof t&&"cause"in t&&void 0!==t.cause?e(t.cause,r):r?null:t}(this,e)}}class U extends P{constructor({offset:e,position:t,size:r}){super(`Slice ${"start"===t?"starting":"ending"} at offset "${e}" is out-of-bounds (size: ${r}).`,{name:"SliceOffsetOutOfBoundsError"})}}class M extends P{constructor({size:e,targetSize:t,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (${e}) exceeds padding size (${t}).`,{name:"SizeExceedsPaddingSizeError"})}}function D(e,{dir:t,size:r=32}={}){return"string"==typeof e?L(e,{dir:t,size:r}):function(e,{dir:t,size:r=32}={}){if(null===r)return e;if(e.length>r)throw new M({size:e.length,targetSize:r,type:"bytes"});let n=new Uint8Array(r);for(let i=0;i<r;i++){let s="right"===t;n[s?i:r-i-1]=e[s?i:e.length-i-1]}return n}(e,{dir:t,size:r})}function L(e,{dir:t,size:r=32}={}){if(null===r)return e;let n=e.replace("0x","");if(n.length>2*r)throw new M({size:Math.ceil(n.length/2),targetSize:r,type:"hex"});return`0x${n["right"===t?"padEnd":"padStart"](2*r,"0")}`}class B extends P{constructor({max:e,min:t,signed:r,size:n,value:i}){super(`Number "${i}" is not in safe ${n?`${8*n}-bit ${r?"signed":"unsigned"} `:""}integer range ${e?`(${t} to ${e})`:`(above ${t})`}`,{name:"IntegerOutOfRangeError"})}}class $ extends P{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed ${t} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function N(e){return C(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}function T(e,{size:t}){if(N(e)>t)throw new $({givenSize:N(e),maxSize:t})}let R=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function z(e,t={}){return"number"==typeof e||"bigint"==typeof e?V(e,t):"string"==typeof e?J(e,t):"boolean"==typeof e?F(e,t):H(e,t)}function F(e,t={}){let r=`0x${Number(e)}`;return"number"==typeof t.size?(T(r,{size:t.size}),D(r,{size:t.size})):r}function H(e,t={}){let r="";for(let t=0;t<e.length;t++)r+=R[e[t]];let n=`0x${r}`;return"number"==typeof t.size?(T(n,{size:t.size}),D(n,{dir:"right",size:t.size})):n}function V(e,t={}){let r;let{signed:n,size:i}=t,s=BigInt(e);i?r=n?(1n<<8n*BigInt(i)-1n)-1n:2n**(8n*BigInt(i))-1n:"number"==typeof e&&(r=BigInt(Number.MAX_SAFE_INTEGER));let o="bigint"==typeof r&&n?-r-1n:0;if(r&&s>r||s<o){let t="bigint"==typeof e?"n":"";throw new B({max:r?`${r}${t}`:void 0,min:`${o}${t}`,signed:n,size:i,value:`${e}${t}`})}let a=`0x${(n&&s<0?(1n<<BigInt(8*i))+BigInt(s):s).toString(16)}`;return i?D(a,{size:i}):a}let W=new TextEncoder;function J(e,t={}){return H(W.encode(e),t)}let q=new TextEncoder;function G(e,t={}){return"number"==typeof e||"bigint"==typeof e?Q(V(e,t)):"boolean"==typeof e?function(e,t={}){let r=new Uint8Array(1);return(r[0]=Number(e),"number"==typeof t.size)?(T(r,{size:t.size}),D(r,{size:t.size})):r}(e,t):C(e)?Q(e,t):Y(e,t)}let K={zero:48,nine:57,A:65,F:70,a:97,f:102};function X(e){return e>=K.zero&&e<=K.nine?e-K.zero:e>=K.A&&e<=K.F?e-(K.A-10):e>=K.a&&e<=K.f?e-(K.a-10):void 0}function Q(e,t={}){let r=e;t.size&&(T(r,{size:t.size}),r=D(r,{dir:"right",size:t.size}));let n=r.slice(2);n.length%2&&(n=`0${n}`);let i=n.length/2,s=new Uint8Array(i);for(let e=0,t=0;e<i;e++){let r=X(n.charCodeAt(t++)),i=X(n.charCodeAt(t++));if(void 0===r||void 0===i)throw new P(`Invalid byte sequence ("${n[t-2]}${n[t-1]}" in "${n}").`);s[e]=16*r+i}return s}function Y(e,t={}){let r=q.encode(e);return"number"==typeof t.size?(T(r,{size:t.size}),D(r,{dir:"right",size:t.size})):r}let Z=new u.CborEncoder;function ee(e){let t={...e,validationHash:en(e)};return Z.encode(t)}function et(e){return Z.encode(e)}function er(e){return l(et(e))}function en(e){var t,r;return z(E(C(t=Z.encode(e),{strict:!1})?G(t):t))}let ei=new u.CborDecoder;function es(e){if(!e.length)throw new t(o.corruptedResponse,"Missing compressed data");let r=eo(e);if(!r)throw new t(o.corruptedResponse,"Invalid compressed data");if(!r?.validationHash)throw new t(o.corruptedResponse,"Missing validation hash");let{validationHash:n,...i}=r;if(en(i)!==r.validationHash)throw new t(o.corruptedResponse,"Invalid data validation hash");return r}function eo(e){try{return ei.decode(e)}catch(t){return console.error("Invalid compressed data",{e:t,data:e}),null}}function ea(e){return eo(c(e))}let eu="nexus-wallet-backup";class el{config;iframe;isSetupDone=!1;lastResponse=null;lastRequest=null;constructor(e,t){this.config=e,this.iframe=t,this.lastRequest=null,this.lastResponse=null}setLastResponse(e){this.lastResponse={event:e.data,origin:e.origin,timestamp:Date.now()}}setLastRequest(e,t){this.lastRequest={event:e,target:t,timestamp:Date.now()}}updateSetupStatus(e){this.isSetupDone=e}base64Encode(e){try{return btoa(JSON.stringify(e))}catch(e){return console.warn("Failed to encode debug data",e),btoa("Failed to encode data")}}getIframeStatus(){return this.iframe?{loading:this.iframe.hasAttribute("loading"),url:this.iframe.src,readyState:this.iframe.contentDocument?.readyState?+("complete"===this.iframe.contentDocument.readyState):-1,contentWindow:!!this.iframe.contentWindow,isConnected:this.iframe.isConnected}:null}getNavigatorInfo(){return navigator?{userAgent:navigator.userAgent,language:navigator.language,onLine:navigator.onLine,screenWidth:window.screen.width,screenHeight:window.screen.height,pixelRatio:window.devicePixelRatio}:null}gatherDebugInfo(e){let r=this.getIframeStatus(),n=this.getNavigatorInfo(),i="Unknown";return e instanceof t?i=`FrakRpcError: ${e.code} '${e.message}'`:e instanceof Error?i=e.message:"string"==typeof e&&(i=e),{timestamp:new Date().toISOString(),encodedUrl:btoa(window.location.href),encodedConfig:this.config?this.base64Encode(this.config):"no-config",navigatorInfo:n?this.base64Encode(n):"no-navigator",iframeStatus:r?this.base64Encode(r):"not-iframe",lastRequest:this.lastRequest?this.base64Encode(this.lastRequest):"No Frak request logged",lastResponse:this.lastResponse?this.base64Encode(this.lastResponse):"No Frak response logged",clientStatus:this.isSetupDone?"setup":"not-setup",error:i}}static empty(){return new el}formatDebugInfo(e){let t=this.gatherDebugInfo(e);return`
2
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.FrakSDK=t():e.FrakSDK=t()}(globalThis,()=>(()=>{"use strict";var e={"../../node_modules/@jsonjoy.com/json-pack/lib/JsonPackExtension.js":function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.JsonPackExtension=void 0,t.JsonPackExtension=class{constructor(e,t){this.tag=e,this.val=t}}},"../../node_modules/@jsonjoy.com/json-pack/lib/JsonPackValue.js":function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.JsonPackValue=void 0,t.JsonPackValue=class{constructor(e){this.val=e}}},"../../node_modules/@jsonjoy.com/json-pack/lib/cbor/CborDecoder.js":function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.CborDecoder=void 0;let n=r("../../node_modules/@jsonjoy.com/json-pack/lib/cbor/CborDecoderBase.js"),i=r("../../node_modules/@jsonjoy.com/json-pack/lib/JsonPackValue.js");class s extends n.CborDecoderBase{readAsMap(){let e=this.reader.u8();if(e>>5==5)return this.readMap(31&e);throw 0}readMap(e){let t=this.readMinorLen(e);return t>=0?this.readMapRaw(t):this.readMapIndef()}readMapRaw(e){let t=new Map;for(let r=0;r<e;r++){let e=this.val(),r=this.val();t.set(e,r)}return t}readMapIndef(){let e=new Map;for(;255!==this.reader.peak();){let t=this.val();if(255===this.reader.peak())throw 7;let r=this.val();e.set(t,r)}return this.reader.x++,e}skipN(e){for(let t=0;t<e;t++)this.skipAny()}skipAny(){this.skipAnyRaw(this.reader.u8())}skipAnyRaw(e){let t=31&e;switch(e>>5){case 0:case 1:this.skipUNint(t);break;case 2:this.skipBin(t);break;case 3:this.skipStr(t);break;case 4:this.skipArr(t);break;case 5:this.skipObj(t);break;case 7:this.skipTkn(t);break;case 6:this.skipTag(t)}}skipMinorLen(e){if(e<=23)return e;switch(e){case 24:return this.reader.u8();case 25:return this.reader.u16();case 26:return this.reader.u32();case 27:return Number(this.reader.u64());case 31:return -1;default:throw 1}}skipUNint(e){if(!(e<=23))switch(e){case 24:return this.reader.skip(1);case 25:return this.reader.skip(2);case 26:return this.reader.skip(4);case 27:return this.reader.skip(8);default:throw 1}}skipBin(e){let t=this.skipMinorLen(e);if(t>=0)this.reader.skip(t);else{for(;255!==this.reader.peak();)this.skipBinChunk();this.reader.x++}}skipBinChunk(){let e=this.reader.u8(),t=31&e;if(2!=e>>5)throw 2;if(t>27)throw 3;this.skipBin(t)}skipStr(e){let t=this.skipMinorLen(e);if(t>=0)this.reader.skip(t);else{for(;255!==this.reader.peak();)this.skipStrChunk();this.reader.x++}}skipStrChunk(){let e=this.reader.u8(),t=31&e;if(3!=e>>5)throw 4;if(t>27)throw 5;this.skipStr(t)}skipArr(e){let t=this.skipMinorLen(e);if(t>=0)this.skipN(t);else{for(;255!==this.reader.peak();)this.skipAny();this.reader.x++}}skipObj(e){let t=this.readMinorLen(e);if(t>=0)return this.skipN(2*t);for(;255!==this.reader.peak();){if(this.skipAny(),255===this.reader.peak())throw 7;this.skipAny()}this.reader.x++}skipTag(e){if(0>this.skipMinorLen(e))throw 1;this.skipAny()}skipTkn(e){switch(e){case 24:this.reader.skip(1);return;case 25:this.reader.skip(2);return;case 26:this.reader.skip(4);return;case 27:this.reader.skip(8);return}if(!(e<=23))throw 1}validate(e,t=0,r=e.length){if(this.reader.reset(e),this.reader.x=t,this.skipAny(),this.reader.x-t!==r)throw 8}decodeLevel(e){return this.reader.reset(e),this.readLevel()}readLevel(){let e=this.reader.u8(),t=e>>5,r=31&e;switch(t){case 4:return this.readArrLevel(r);case 5:return this.readObjLevel(r);default:return super.readAnyRaw(e)}}readPrimitiveOrVal(){switch(this.reader.peak()>>5){case 4:case 5:return this.readAsValue();default:return this.val()}}readAsValue(){let e=this.reader,t=e.x;this.skipAny();let r=e.x;return new i.JsonPackValue(e.uint8.subarray(t,r))}readObjLevel(e){let t=this.readMinorLen(e);return t>=0?this.readObjRawLevel(t):this.readObjIndefLevel()}readObjRawLevel(e){let t={};for(let r=0;r<e;r++){let e=this.key(),r=this.readPrimitiveOrVal();t[e]=r}return t}readObjIndefLevel(){let e={};for(;255!==this.reader.peak();){let t=this.key();if(255===this.reader.peak())throw 7;let r=this.readPrimitiveOrVal();e[t]=r}return this.reader.x++,e}readArrLevel(e){let t=this.readMinorLen(e);return t>=0?this.readArrRawLevel(t):this.readArrIndefLevel()}readArrRawLevel(e){let t=[];for(let r=0;r<e;r++)t.push(this.readPrimitiveOrVal());return t}readArrIndefLevel(){let e=[];for(;255!==this.reader.peak();)e.push(this.readPrimitiveOrVal());return this.reader.x++,e}readHdr(e){let t=this.reader.u8();if(t>>5!==e)throw 0;let r=31&t;if(r<24)return r;switch(r){case 24:return this.reader.u8();case 25:return this.reader.u16();case 26:return this.reader.u32();case 27:return Number(this.reader.u64());case 31:return -1}throw 1}readStrHdr(){return this.readHdr(3)}readObjHdr(){return this.readHdr(5)}readArrHdr(){return this.readHdr(4)}findKey(e){let t=this.readObjHdr();for(let r=0;r<t;r++){if(this.key()===e)return this;this.skipAny()}throw 9}findIndex(e){if(e>=this.readArrHdr())throw 10;for(let t=0;t<e;t++)this.skipAny();return this}find(e){for(let t=0;t<e.length;t++){let r=e[t];"string"==typeof r?this.findKey(r):this.findIndex(r)}return this}}t.CborDecoder=s},"../../node_modules/@jsonjoy.com/json-pack/lib/cbor/CborDecoderBase.js":function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.CborDecoderBase=void 0;let n=r("../../node_modules/tslib/tslib.es6.mjs"),i=r("../../node_modules/@jsonjoy.com/util/lib/buffers/f16.js"),s=r("../../node_modules/@jsonjoy.com/json-pack/lib/JsonPackExtension.js"),o=r("../../node_modules/@jsonjoy.com/json-pack/lib/JsonPackValue.js"),a=r("../../node_modules/@jsonjoy.com/util/lib/buffers/Reader.js"),u=n.__importDefault(r("../../node_modules/@jsonjoy.com/util/lib/buffers/utf8/sharedCachedUtf8Decoder.js"));t.CborDecoderBase=class{constructor(e=new a.Reader,t=u.default){this.reader=e,this.keyDecoder=t}read(e){return this.reader.reset(e),this.val()}decode(e){return this.reader.reset(e),this.val()}val(){let e=this.reader.u8(),t=e>>5,r=31&e;return t<4?t<2?0===t?this.readUint(r):this.readNint(r):2===t?this.readBin(r):this.readStr(r):t<6?4===t?this.readArr(r):this.readObj(r):6===t?this.readTag(r):this.readTkn(r)}readAnyRaw(e){let t=e>>5,r=31&e;return t<4?t<2?0===t?this.readUint(r):this.readNint(r):2===t?this.readBin(r):this.readStr(r):t<6?4===t?this.readArr(r):this.readObj(r):6===t?this.readTag(r):this.readTkn(r)}readMinorLen(e){if(e<24)return e;switch(e){case 24:return this.reader.u8();case 25:return this.reader.u16();case 26:return this.reader.u32();case 27:return Number(this.reader.u64());case 31:return -1;default:throw 1}}readUint(e){if(e<25)return 24===e?this.reader.u8():e;if(e<27)return 25===e?this.reader.u16():this.reader.u32();{let e=this.reader.u64();return e>0x1fffffffffffff?e:Number(e)}}readNint(e){if(e<25)return 24===e?-this.reader.u8()-1:-e-1;if(e<27)return 25===e?-this.reader.u16()-1:-this.reader.u32()-1;{let e=this.reader.u64();return e>0x1ffffffffffffe?-e-BigInt(1):-Number(e)-1}}readBin(e){let t=this.reader;if(e<=23)return t.buf(e);switch(e){case 24:return t.buf(t.u8());case 25:return t.buf(t.u16());case 26:return t.buf(t.u32());case 27:return t.buf(Number(t.u64()));case 31:{let e=0,t=[];for(;255!==this.reader.peak();){let r=this.readBinChunk();e+=r.length,t.push(r)}this.reader.x++;let r=new Uint8Array(e),n=0,i=t.length;for(let e=0;e<i;e++){let i=t[e];r.set(i,n),n+=i.length}return r}default:throw 1}}readBinChunk(){let e=this.reader.u8(),t=31&e;if(2!=e>>5)throw 2;if(t>27)throw 3;return this.readBin(t)}readAsStr(){let e=this.reader.u8();if(3!=e>>5)throw 11;return this.readStr(31&e)}readStr(e){let t=this.reader;if(e<=23)return t.utf8(e);switch(e){case 24:return t.utf8(t.u8());case 25:return t.utf8(t.u16());case 26:return t.utf8(t.u32());case 27:return t.utf8(Number(t.u64()));case 31:{let e="";for(;255!==t.peak();)e+=this.readStrChunk();return this.reader.x++,e}default:throw 1}}readStrLen(e){if(e<=23)return e;switch(e){case 24:return this.reader.u8();case 25:return this.reader.u16();case 26:return this.reader.u32();case 27:return Number(this.reader.u64());default:throw 1}}readStrChunk(){let e=this.reader.u8(),t=31&e;if(3!=e>>5)throw 4;if(t>27)throw 5;return this.readStr(t)}readArr(e){let t=this.readMinorLen(e);return t>=0?this.readArrRaw(t):this.readArrIndef()}readArrRaw(e){let t=[];for(let r=0;r<e;r++)t.push(this.val());return t}readArrIndef(){let e=[];for(;255!==this.reader.peak();)e.push(this.val());return this.reader.x++,e}readObj(e){if(e<28){let t=e;switch(e){case 24:t=this.reader.u8();break;case 25:t=this.reader.u16();break;case 26:t=this.reader.u32();break;case 27:t=Number(this.reader.u64())}let r={};for(let e=0;e<t;e++){let e=this.key();if("__proto__"===e)throw 6;let t=this.val();r[e]=t}return r}if(31===e)return this.readObjIndef();throw 1}readObjRaw(e){let t={};for(let r=0;r<e;r++){let e=this.key(),r=this.val();t[e]=r}return t}readObjIndef(){let e={};for(;255!==this.reader.peak();){let t=this.key();if(255===this.reader.peak())throw 7;let r=this.val();e[t]=r}return this.reader.x++,e}key(){let e=this.reader.u8();if(3!=e>>5)return String(this.readAnyRaw(e));let t=this.readStrLen(31&e);if(t>31)return this.reader.utf8(t);let r=this.keyDecoder.decode(this.reader.uint8,this.reader.x,t);return this.reader.skip(t),r}readTag(e){if(e<=23)return this.readTagRaw(e);switch(e){case 24:return this.readTagRaw(this.reader.u8());case 25:return this.readTagRaw(this.reader.u16());case 26:return this.readTagRaw(this.reader.u32());case 27:return this.readTagRaw(Number(this.reader.u64()));default:throw 1}}readTagRaw(e){return new s.JsonPackExtension(e,this.val())}readTkn(e){switch(e){case 20:return!1;case 21:return!0;case 22:return null;case 23:return;case 24:return new o.JsonPackValue(this.reader.u8());case 25:return this.f16();case 26:return this.reader.f32();case 27:return this.reader.f64()}if(e<=23)return new o.JsonPackValue(e);throw 1}f16(){return(0,i.decodeF16)(this.reader.u16())}}},"../../node_modules/@jsonjoy.com/json-pack/lib/cbor/CborDecoderDag.js":function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.CborDecoderDag=void 0;let n=r("../../node_modules/@jsonjoy.com/json-pack/lib/JsonPackExtension.js"),i=r("../../node_modules/@jsonjoy.com/json-pack/lib/cbor/CborDecoder.js");class s extends i.CborDecoder{readTagRaw(e){let t=this.val();return 42===e?new n.JsonPackExtension(e,t):t}}t.CborDecoderDag=s},"../../node_modules/@jsonjoy.com/json-pack/lib/cbor/CborEncoder.js":function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.CborEncoder=void 0;let n=r("../../node_modules/@jsonjoy.com/util/lib/buffers/isFloat32.js"),i=r("../../node_modules/@jsonjoy.com/json-pack/lib/JsonPackExtension.js"),s=r("../../node_modules/@jsonjoy.com/json-pack/lib/cbor/CborEncoderFast.js"),o=r("../../node_modules/@jsonjoy.com/json-pack/lib/JsonPackValue.js");class a extends s.CborEncoderFast{writeUnknown(e){this.writeNull()}writeAny(e){switch(typeof e){case"number":return this.writeNumber(e);case"string":return this.writeStr(e);case"boolean":return this.writer.u8(244+ +e);case"object":if(!e)return this.writer.u8(246);switch(e.constructor){case Object:return this.writeObj(e);case Array:return this.writeArr(e);case Uint8Array:return this.writeBin(e);case Map:return this.writeMap(e);case i.JsonPackExtension:return this.writeTag(e.tag,e.val);case o.JsonPackValue:let t=e.val;return this.writer.buf(t,t.length);default:if(e instanceof Uint8Array)return this.writeBin(e);if(Array.isArray(e))return this.writeArr(e);if(e instanceof Map)return this.writeMap(e);return this.writeUnknown(e)}case"undefined":return this.writeUndef();case"bigint":return this.writeBigInt(e);default:return this.writeUnknown(e)}}writeFloat(e){(0,n.isFloat32)(e)?this.writer.u8f32(250,e):this.writer.u8f64(251,e)}writeMap(e){this.writeMapHdr(e.size),e.forEach((e,t)=>{this.writeAny(t),this.writeAny(e)})}writeUndef(){this.writer.u8(247)}}t.CborEncoder=a},"../../node_modules/@jsonjoy.com/json-pack/lib/cbor/CborEncoderDag.js":function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.CborEncoderDag=void 0;let n=r("../../node_modules/@jsonjoy.com/json-pack/lib/cbor/CborEncoderStable.js");class i extends n.CborEncoderStable{writeUndef(){this.writeNull()}writeFloat(e){if(e!=e||!Number.isFinite(e))return this.writeNull();this.writer.u8f64(251,e)}writeTag(e,t){42===e&&this.writeTagHdr(e),this.writeAny(t)}}t.CborEncoderDag=i},"../../node_modules/@jsonjoy.com/json-pack/lib/cbor/CborEncoderFast.js":function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.CborEncoderFast=void 0;let n=r("../../node_modules/@jsonjoy.com/util/lib/buffers/Writer.js"),i=Number.isSafeInteger;t.CborEncoderFast=class{constructor(e=new n.Writer){this.writer=e}encode(e){return this.writeAny(e),this.writer.flush()}encodeToSlice(e){return this.writeAny(e),this.writer.flushSlice()}writeAny(e){switch(typeof e){case"number":return this.writeNumber(e);case"string":return this.writeStr(e);case"boolean":return this.writer.u8(244+ +e);case"object":if(!e)return this.writer.u8(246);if(e.constructor===Array)return this.writeArr(e);return this.writeObj(e)}}writeCbor(){this.writer.u8u16(217,55799)}writeEnd(){this.writer.u8(255)}writeNull(){this.writer.u8(246)}writeBoolean(e){e?this.writer.u8(245):this.writer.u8(244)}writeNumber(e){i(e)?this.writeInteger(e):"bigint"==typeof e?this.writeBigInt(e):this.writeFloat(e)}writeBigInt(e){e>=0?this.writeBigUint(e):this.writeBigSint(e)}writeBigUint(e){if(e<=Number.MAX_SAFE_INTEGER)return this.writeUInteger(Number(e));this.writer.u8u64(27,e)}writeBigSint(e){if(e>=Number.MIN_SAFE_INTEGER)return this.encodeNint(Number(e));let t=-BigInt(1)-e;this.writer.u8u64(59,t)}writeInteger(e){e>=0?this.writeUInteger(e):this.encodeNint(e)}writeUInteger(e){let t=this.writer;t.ensureCapacity(9);let r=t.uint8,n=t.x;e<=23?r[n++]=0+e:e<=255?(r[n++]=24,r[n++]=e):e<=65535?(r[n++]=25,t.view.setUint16(n,e),n+=2):e<=0xffffffff?(r[n++]=26,t.view.setUint32(n,e),n+=4):(r[n++]=27,t.view.setBigUint64(n,BigInt(e)),n+=8),t.x=n}encodeNumber(e){this.writeNumber(e)}encodeInteger(e){this.writeInteger(e)}encodeUint(e){this.writeUInteger(e)}encodeNint(e){let t=-1-e,r=this.writer;r.ensureCapacity(9);let n=r.uint8,i=r.x;t<24?n[i++]=32+t:t<=255?(n[i++]=56,n[i++]=t):t<=65535?(n[i++]=57,r.view.setUint16(i,t),i+=2):t<=0xffffffff?(n[i++]=58,r.view.setUint32(i,t),i+=4):(n[i++]=59,r.view.setBigUint64(i,BigInt(t)),i+=8),r.x=i}writeFloat(e){this.writer.u8f64(251,e)}writeBin(e){let t=e.length;this.writeBinHdr(t),this.writer.buf(e,t)}writeBinHdr(e){let t=this.writer;e<=23?t.u8(64+e):e<=255?t.u16(22528+e):e<=65535?t.u8u16(89,e):e<=0xffffffff?t.u8u32(90,e):t.u8u64(91,e)}writeStr(e){let t=this.writer,r=4*e.length;t.ensureCapacity(5+r);let n=t.uint8,i=t.x;r<=23?t.x++:r<=255?(n[t.x++]=120,i=t.x,t.x++):r<=65535?(n[t.x++]=121,i=t.x,t.x+=2):(n[t.x++]=122,i=t.x,t.x+=4);let s=t.utf8(e);r<=23?n[i]=96+s:r<=255?n[i]=s:r<=65535?t.view.setUint16(i,s):t.view.setUint32(i,s)}writeStrHdr(e){let t=this.writer;e<=23?t.u8(96+e):e<=255?t.u16(30720+e):e<=65535?t.u8u16(121,e):t.u8u32(122,e)}writeAsciiStr(e){this.writeStrHdr(e.length),this.writer.ascii(e)}writeArr(e){let t=e.length;this.writeArrHdr(t);for(let r=0;r<t;r++)this.writeAny(e[r])}writeArrHdr(e){let t=this.writer;e<=23?t.u8(128+e):e<=255?t.u16(38912+e):e<=65535?t.u8u16(153,e):e<=0xffffffff?t.u8u32(154,e):t.u8u64(155,e)}writeObj(e){let t=Object.keys(e),r=t.length;this.writeObjHdr(r);for(let n=0;n<r;n++){let r=t[n];this.writeStr(r),this.writeAny(e[r])}}writeObjHdr(e){let t=this.writer;e<=23?t.u8(160+e):e<=255?t.u16(47104+e):e<=65535?t.u8u16(185,e):e<=0xffffffff?t.u8u32(186,e):t.u8u64(187,e)}writeMapHdr(e){this.writeObjHdr(e)}writeStartMap(){this.writer.u8(191)}writeTag(e,t){this.writeTagHdr(e),this.writeAny(t)}writeTagHdr(e){let t=this.writer;e<=23?t.u8(192+e):e<=255?t.u16(55296+e):e<=65535?t.u8u16(217,e):e<=0xffffffff?t.u8u32(218,e):t.u8u64(219,e)}writeTkn(e){let t=this.writer;e<=23?t.u8(224+e):e<=255&&t.u16(63488+e)}writeStartStr(){this.writer.u8(127)}writeStrChunk(e){throw Error("Not implemented")}writeEndStr(){throw Error("Not implemented")}writeStartBin(){this.writer.u8(95)}writeBinChunk(e){throw Error("Not implemented")}writeEndBin(){throw Error("Not implemented")}writeStartArr(){this.writer.u8(159)}writeArrChunk(e){throw Error("Not implemented")}writeEndArr(){this.writer.u8(255)}writeStartObj(){this.writer.u8(191)}writeObjChunk(e,t){throw Error("Not implemented")}writeEndObj(){this.writer.u8(255)}}},"../../node_modules/@jsonjoy.com/json-pack/lib/cbor/CborEncoderStable.js":function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.CborEncoderStable=void 0;let n=r("../../node_modules/@jsonjoy.com/json-pack/lib/cbor/CborEncoder.js"),i=r("../../node_modules/@jsonjoy.com/util/lib/sort/insertion2.js"),s=r("../../node_modules/@jsonjoy.com/util/lib/objKeyCmp.js"),o=e=>e<=23?1:e<=255?2:e<=65535?3:5;class a extends n.CborEncoder{writeObj(e){let t=Object.keys(e);(0,i.sort)(t,s.objKeyCmp);let r=t.length;this.writeObjHdr(r);for(let n=0;n<r;n++){let r=t[n];this.writeStr(r),this.writeAny(e[r])}}writeStr(e){let t=this.writer,r=e.length,n=4*r;t.ensureCapacity(5+n);let i=o(r),s=t.x,a=s+i;t.x=a;let u=t.utf8(e),l=t.uint8,c=o(u);switch(c!==i&&l.copyWithin(a+(c-i),a,a+u),c){case 1:l[s]=96+u;break;case 2:l[s]=120,l[s+1]=u;break;case 3:l[s]=121,t.view.setUint16(s+1,u);break;case 5:l[s]=122,t.view.setUint32(s+1,u)}t.x=s+c+u}writeUndef(){this.writeNull()}}t.CborEncoderStable=a},"../../node_modules/@jsonjoy.com/json-pack/lib/cbor/index.js":function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});let n=r("../../node_modules/tslib/tslib.es6.mjs");n.__exportStar(r("../../node_modules/@jsonjoy.com/json-pack/lib/cbor/types.js"),t),n.__exportStar(r("../../node_modules/@jsonjoy.com/json-pack/lib/cbor/CborEncoderFast.js"),t),n.__exportStar(r("../../node_modules/@jsonjoy.com/json-pack/lib/cbor/CborEncoder.js"),t),n.__exportStar(r("../../node_modules/@jsonjoy.com/json-pack/lib/cbor/CborEncoderStable.js"),t),n.__exportStar(r("../../node_modules/@jsonjoy.com/json-pack/lib/cbor/CborEncoderDag.js"),t),n.__exportStar(r("../../node_modules/@jsonjoy.com/json-pack/lib/cbor/CborDecoderBase.js"),t),n.__exportStar(r("../../node_modules/@jsonjoy.com/json-pack/lib/cbor/CborDecoder.js"),t),n.__exportStar(r("../../node_modules/@jsonjoy.com/json-pack/lib/cbor/CborDecoderDag.js"),t)},"../../node_modules/@jsonjoy.com/json-pack/lib/cbor/types.js":function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},"../../node_modules/@jsonjoy.com/util/lib/buffers/Reader.js":function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.Reader=void 0;let n=r("../../node_modules/@jsonjoy.com/util/lib/buffers/utf8/decodeUtf8/index.js");t.Reader=class{constructor(){this.uint8=new Uint8Array([]),this.view=new DataView(this.uint8.buffer),this.x=0}reset(e){this.x=0,this.uint8=e,this.view=new DataView(e.buffer,e.byteOffset,e.length)}peak(){return this.view.getUint8(this.x)}skip(e){this.x+=e}buf(e){let t=this.x+e,r=this.uint8.subarray(this.x,t);return this.x=t,r}u8(){return this.uint8[this.x++]}i8(){return this.view.getInt8(this.x++)}u16(){let e=this.x,t=(this.uint8[e++]<<8)+this.uint8[e++];return this.x=e,t}i16(){let e=this.view.getInt16(this.x);return this.x+=2,e}u32(){let e=this.view.getUint32(this.x);return this.x+=4,e}i32(){let e=this.view.getInt32(this.x);return this.x+=4,e}u64(){let e=this.view.getBigUint64(this.x);return this.x+=8,e}i64(){let e=this.view.getBigInt64(this.x);return this.x+=8,e}f32(){let e=this.x;return this.x+=4,this.view.getFloat32(e)}f64(){let e=this.x;return this.x+=8,this.view.getFloat64(e)}utf8(e){let t=this.x;return this.x+=e,(0,n.decodeUtf8)(this.uint8,t,e)}ascii(e){let t=this.uint8,r="",n=this.x+e;for(let e=this.x;e<n;e++)r+=String.fromCharCode(t[e]);return this.x=n,r}}},"../../node_modules/@jsonjoy.com/util/lib/buffers/Slice.js":function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.Slice=void 0,t.Slice=class{constructor(e,t,r,n){this.uint8=e,this.view=t,this.start=r,this.end=n}subarray(){return this.uint8.subarray(this.start,this.end)}}},"../../node_modules/@jsonjoy.com/util/lib/buffers/Writer.js":function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.Writer=void 0;let n=r("../../node_modules/@jsonjoy.com/util/lib/buffers/Slice.js"),i=new DataView(new Uint8Array([]).buffer),s="function"==typeof Buffer,o=s?Buffer.prototype.utf8Write:null,a=s?Buffer.from:null,u="undefined"!=typeof TextEncoder?new TextEncoder:null;t.Writer=class{constructor(e=65536){this.allocSize=e,this.view=i,this.x0=0,this.x=0,this.uint8=new Uint8Array(e),this.size=e,this.view=new DataView(this.uint8.buffer)}grow(e){let t=this.x0,r=this.x,n=this.uint8,i=new Uint8Array(e),s=new DataView(i.buffer),o=n.subarray(t,r);i.set(o,0),this.x=r-t,this.x0=0,this.uint8=i,this.size=e,this.view=s}ensureCapacity(e){let t=this.size,r=t-this.x;if(r<e){let n=t-this.x0+(e-r);this.grow(n<=this.allocSize?this.allocSize:2*n)}}move(e){this.ensureCapacity(e),this.x+=e}reset(){this.x0=this.x}newBuffer(e){let t=this.uint8=new Uint8Array(e);this.size=e,this.view=new DataView(t.buffer),this.x=this.x0=0}flush(){let e=this.uint8.subarray(this.x0,this.x);return this.x0=this.x,e}flushSlice(){let e=new n.Slice(this.uint8,this.view,this.x0,this.x);return this.x0=this.x,e}u8(e){this.ensureCapacity(1),this.uint8[this.x++]=e}u16(e){this.ensureCapacity(2),this.view.setUint16(this.x,e),this.x+=2}u32(e){this.ensureCapacity(4),this.view.setUint32(this.x,e),this.x+=4}i32(e){this.ensureCapacity(4),this.view.setInt32(this.x,e),this.x+=4}u64(e){this.ensureCapacity(8),this.view.setBigUint64(this.x,BigInt(e)),this.x+=8}f64(e){this.ensureCapacity(8),this.view.setFloat64(this.x,e),this.x+=8}u8u16(e,t){this.ensureCapacity(3);let r=this.x;this.uint8[r++]=e,this.uint8[r++]=t>>>8,this.uint8[r++]=255&t,this.x=r}u8u32(e,t){this.ensureCapacity(5);let r=this.x;this.uint8[r++]=e,this.view.setUint32(r,t),this.x=r+4}u8u64(e,t){this.ensureCapacity(9);let r=this.x;this.uint8[r++]=e,this.view.setBigUint64(r,BigInt(t)),this.x=r+8}u8f32(e,t){this.ensureCapacity(5);let r=this.x;this.uint8[r++]=e,this.view.setFloat32(r,t),this.x=r+4}u8f64(e,t){this.ensureCapacity(9);let r=this.x;this.uint8[r++]=e,this.view.setFloat64(r,t),this.x=r+8}buf(e,t){this.ensureCapacity(t);let r=this.x;this.uint8.set(e,r),this.x=r+t}utf8(e){let t=4*e.length;if(t<168)return this.utf8Native(e);if(o){let r=o.call(this.uint8,e,this.x,t);return this.x+=r,r}if(a){let r=this.uint8,n=r.byteOffset+this.x,i=a(r.buffer).subarray(n,n+t).write(e,0,t,"utf8");return this.x+=i,i}if(t>1024&&u){let r=u.encodeInto(e,this.uint8.subarray(this.x,this.x+t)).written;return this.x+=r,r}return this.utf8Native(e)}utf8Native(e){let t=e.length,r=this.uint8,n=this.x,i=0;for(;i<t;){let s=e.charCodeAt(i++);if((0xffffff80&s)==0){r[n++]=s;continue}if((0xfffff800&s)==0)r[n++]=s>>6&31|192;else{if(s>=55296&&s<=56319&&i<t){let t=e.charCodeAt(i);(64512&t)==56320&&(i++,s=((1023&s)<<10)+(1023&t)+65536)}(0xffff0000&s)==0?r[n++]=s>>12&15|224:(r[n++]=s>>18&7|240,r[n++]=s>>12&63|128),r[n++]=s>>6&63|128}r[n++]=63&s|128}let s=n-this.x;return this.x=n,s}ascii(e){let t=e.length;this.ensureCapacity(t);let r=this.uint8,n=this.x,i=0;for(;i<t;)r[n++]=e.charCodeAt(i++);this.x=n}}},"../../node_modules/@jsonjoy.com/util/lib/buffers/f16.js":function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.decodeF16=void 0;let r=Math.pow;t.decodeF16=e=>{let t=(31744&e)>>10,n=1023&e;return(e>>15?-1:1)*(t?31===t?n?NaN:1/0:r(2,t-15)*(1+n/1024):n/1024*6103515625e-14)}},"../../node_modules/@jsonjoy.com/util/lib/buffers/isFloat32.js":function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.isFloat32=void 0;let r=new DataView(new ArrayBuffer(4));t.isFloat32=e=>(r.setFloat32(0,e),e===r.getFloat32(0))},"../../node_modules/@jsonjoy.com/util/lib/buffers/utf8/CachedUtf8Decoder.js":function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.CachedUtf8Decoder=void 0;let n=r("../../node_modules/tslib/tslib.es6.mjs").__importDefault(r("../../node_modules/@jsonjoy.com/util/lib/buffers/utf8/decodeUtf8/v10.js")),i=1+Math.round(0xfffffffe*Math.random());class s{constructor(e,t){this.bytes=e,this.value=t}}t.CachedUtf8Decoder=class{constructor(){this.caches=[];for(let e=0;e<31;e++)this.caches.push([])}get(e,t,r){let n=this.caches[r-1],i=n.length;e:for(let s=0;s<i;s++){let i=n[s],o=i.bytes;for(let n=0;n<r;n++)if(o[n]!==e[t+n])continue e;return i.value}return null}store(e,t){let r=this.caches[e.length-1],n=new s(e,t);if(r.length>=16)r[i^=i<<13,i^=i>>>17,((i^=i<<5)>>>0)%16+0]=n;else r.push(n)}decode(e,t,r){if(!r)return"";let i=this.get(e,t,r);if(null!==i)return i;let s=(0,n.default)(e,t,r),o=Uint8Array.prototype.slice.call(e,t,t+r);return this.store(o,s),s}}},"../../node_modules/@jsonjoy.com/util/lib/buffers/utf8/decodeAscii.js":function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.decodeAsciiMax15=t.decodeAscii=void 0;let r=String.fromCharCode;t.decodeAscii=(e,t,n)=>{let i=[];for(let r=0;r<n;r++){let r=e[t++];if(128&r)return;i.push(r)}return r.apply(String,i)},t.decodeAsciiMax15=(e,t,n)=>{if(n<4){if(n<2){if(0===n)return"";{let n=e[t++];if((128&n)>1){t-=1;return}return r(n)}}{let i=e[t++],s=e[t++];if((128&i)>0||(128&s)>0){t-=2;return}if(n<3)return r(i,s);let o=e[t++];if((128&o)>0){t-=3;return}return r(i,s,o)}}{let i=e[t++],s=e[t++],o=e[t++],a=e[t++];if((128&i)>0||(128&s)>0||(128&o)>0||(128&a)>0){t-=4;return}if(n<6){if(4===n)return r(i,s,o,a);{let n=e[t++];if((128&n)>0){t-=5;return}return r(i,s,o,a,n)}}if(n<8){let u=e[t++],l=e[t++];if((128&u)>0||(128&l)>0){t-=6;return}if(n<7)return r(i,s,o,a,u,l);let c=e[t++];if((128&c)>0){t-=7;return}return r(i,s,o,a,u,l,c)}{let u=e[t++],l=e[t++],c=e[t++],f=e[t++];if((128&u)>0||(128&l)>0||(128&c)>0||(128&f)>0){t-=8;return}if(n<10){if(8===n)return r(i,s,o,a,u,l,c,f);{let n=e[t++];if((128&n)>0){t-=9;return}return r(i,s,o,a,u,l,c,f,n)}}if(n<12){let d=e[t++],h=e[t++];if((128&d)>0||(128&h)>0){t-=10;return}if(n<11)return r(i,s,o,a,u,l,c,f,d,h);let p=e[t++];if((128&p)>0){t-=11;return}return r(i,s,o,a,u,l,c,f,d,h,p)}{let d=e[t++],h=e[t++],p=e[t++],w=e[t++];if((128&d)>0||(128&h)>0||(128&p)>0||(128&w)>0){t-=12;return}if(n<14){if(12===n)return r(i,s,o,a,u,l,c,f,d,h,p,w);{let n=e[t++];if((128&n)>0){t-=13;return}return r(i,s,o,a,u,l,c,f,d,h,p,w,n)}}{let b=e[t++],y=e[t++];if((128&b)>0||(128&y)>0){t-=14;return}if(n<15)return r(i,s,o,a,u,l,c,f,d,h,p,w,b,y);let m=e[t++];if((128&m)>0){t-=15;return}return r(i,s,o,a,u,l,c,f,d,h,p,w,b,y,m)}}}}}},"../../node_modules/@jsonjoy.com/util/lib/buffers/utf8/decodeUtf8/index.js":function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.decodeUtf8=void 0;let n=r("../../node_modules/tslib/tslib.es6.mjs").__importDefault(r("../../node_modules/@jsonjoy.com/util/lib/buffers/utf8/decodeUtf8/v16.js"));t.decodeUtf8=n.default},"../../node_modules/@jsonjoy.com/util/lib/buffers/utf8/decodeUtf8/v10.js":function(e,t){Object.defineProperty(t,"__esModule",{value:!0});let r=String.fromCharCode;t.default=(e,t,n)=>{let i=t,s=i+n,o="";for(;i<s;){let t=e[i++];if((128&t)==0){o+=r(t);continue}let n=63&e[i++];if((224&t)==192){o+=r((31&t)<<6|n);continue}let s=63&e[i++];if((240&t)==224){o+=r((31&t)<<12|n<<6|s);continue}if((248&t)==240){let a=(7&t)<<18|n<<12|s<<6|63&e[i++];a>65535?o+=r((a-=65536)>>>10&1023|55296,a=56320|1023&a):o+=r(a)}else o+=r(t)}return o}},"../../node_modules/@jsonjoy.com/util/lib/buffers/utf8/decodeUtf8/v16.js":function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});let n=r("../../node_modules/tslib/tslib.es6.mjs"),i=r("../../node_modules/@jsonjoy.com/util/lib/buffers/utf8/decodeAscii.js"),s=n.__importDefault(r("../../node_modules/@jsonjoy.com/util/lib/buffers/utf8/decodeUtf8/v18.js")),o="undefined"!=typeof Buffer,a=o?Buffer.prototype.utf8Slice:null,u=o?Buffer.from:null,l=(e,t,r)=>(0,i.decodeAsciiMax15)(e,t,r)??(0,s.default)(e,t,r),c=(e,t,r)=>(0,i.decodeAscii)(e,t,r)??(0,s.default)(e,t,r),f=a?(e,t,r)=>a.call(e,t,t+r):u?(e,t,r)=>u(e).subarray(t,t+r).toString("utf8"):s.default;t.default=(e,t,r)=>r<16?l(e,t,r):r<32?c(e,t,r):f(e,t,r)},"../../node_modules/@jsonjoy.com/util/lib/buffers/utf8/decodeUtf8/v18.js":function(e,t){Object.defineProperty(t,"__esModule",{value:!0});let r=String.fromCharCode;t.default=(e,t,n)=>{let i=t,s=i+n,o=[];for(;i<s;){let t=e[i++];if((128&t)!=0){let r=63&e[i++];if((224&t)==192)t=(31&t)<<6|r;else{let n=63&e[i++];if((240&t)==224)t=(31&t)<<12|r<<6|n;else if((248&t)==240){let s=(7&t)<<18|r<<12|n<<6|63&e[i++];if(s>65535){let e=(s-=65536)>>>10&1023|55296;t=56320|1023&s,o.push(e)}else t=s}}}o.push(t)}return r.apply(String,o)}},"../../node_modules/@jsonjoy.com/util/lib/buffers/utf8/sharedCachedUtf8Decoder.js":function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});let n=r("../../node_modules/@jsonjoy.com/util/lib/buffers/utf8/CachedUtf8Decoder.js");t.default=new n.CachedUtf8Decoder},"../../node_modules/@jsonjoy.com/util/lib/objKeyCmp.js":function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.objKeyCmp=void 0,t.objKeyCmp=(e,t)=>{let r=e.length,n=t.length;return r===n?e>t?1:-1:r-n}},"../../node_modules/@jsonjoy.com/util/lib/sort/insertion2.js":function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.sort=void 0,t.sort=(e,t)=>{let r=e.length;for(let n=1;n<r;n++){let r=e[n],i=n;for(;0!==i&&t(e[i-1],r)>0;)e[i]=e[i-1],i--;e[i]=r}return e}},"../../node_modules/tslib/tslib.es6.mjs":function(e,t,r){r.r(t),r.d(t,{__addDisposableResource:()=>L,__assign:()=>s,__asyncDelegator:()=>S,__asyncGenerator:()=>_,__asyncValues:()=>A,__await:()=>k,__awaiter:()=>p,__classPrivateFieldGet:()=>U,__classPrivateFieldIn:()=>D,__classPrivateFieldSet:()=>M,__createBinding:()=>b,__decorate:()=>a,__disposeResources:()=>$,__esDecorate:()=>l,__exportStar:()=>y,__extends:()=>i,__generator:()=>w,__importDefault:()=>P,__importStar:()=>O,__makeTemplateObject:()=>E,__metadata:()=>h,__param:()=>u,__propKey:()=>f,__read:()=>g,__rest:()=>o,__rewriteRelativeImportExtension:()=>N,__runInitializers:()=>c,__setFunctionName:()=>d,__spread:()=>x,__spreadArray:()=>j,__spreadArrays:()=>v,__values:()=>m,default:()=>T});var n=function(e,t){return(n=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)};function i(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var s=function(){return(s=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};function o(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&0>t.indexOf(n)&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)0>t.indexOf(n[i])&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);return r}function a(e,t,r,n){var i,s=arguments.length,o=s<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(o=(s<3?i(o):s>3?i(t,r,o):i(t,r))||o);return s>3&&o&&Object.defineProperty(t,r,o),o}function u(e,t){return function(r,n){t(r,n,e)}}function l(e,t,r,n,i,s){function o(e){if(void 0!==e&&"function"!=typeof e)throw TypeError("Function expected");return e}for(var a,u=n.kind,l="getter"===u?"get":"setter"===u?"set":"value",c=!t&&e?n.static?e:e.prototype:null,f=t||(c?Object.getOwnPropertyDescriptor(c,n.name):{}),d=!1,h=r.length-1;h>=0;h--){var p={};for(var w in n)p[w]="access"===w?{}:n[w];for(var w in n.access)p.access[w]=n.access[w];p.addInitializer=function(e){if(d)throw TypeError("Cannot add initializers after decoration has completed");s.push(o(e||null))};var b=(0,r[h])("accessor"===u?{get:f.get,set:f.set}:f[l],p);if("accessor"===u){if(void 0===b)continue;if(null===b||"object"!=typeof b)throw TypeError("Object expected");(a=o(b.get))&&(f.get=a),(a=o(b.set))&&(f.set=a),(a=o(b.init))&&i.unshift(a)}else(a=o(b))&&("field"===u?i.unshift(a):f[l]=a)}c&&Object.defineProperty(c,n.name,f),d=!0}function c(e,t,r){for(var n=arguments.length>2,i=0;i<t.length;i++)r=n?t[i].call(e,r):t[i].call(e);return n?r:void 0}function f(e){return"symbol"==typeof e?e:"".concat(e)}function d(e,t,r){return"symbol"==typeof t&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:r?"".concat(r," ",t):t})}function h(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function p(e,t,r,n){return new(r||(r=Promise))(function(i,s){function o(e){try{u(n.next(e))}catch(e){s(e)}}function a(e){try{u(n.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?i(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(o,a)}u((n=n.apply(e,t||[])).next())})}function w(e,t){var r,n,i,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(u){return function(a){if(r)throw TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(i=(i=s.trys).length>0&&i[i.length-1])&&(6===a[0]||2===a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}var b=Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]};function y(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||b(t,e,r)}function m(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function g(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,s=r.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(n=s.next()).done;)o.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(i)throw i.error}}return o}function x(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(g(arguments[t]));return e}function v(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;for(var n=Array(e),i=0,t=0;t<r;t++)for(var s=arguments[t],o=0,a=s.length;o<a;o++,i++)n[i]=s[o];return n}function j(e,t,r){if(r||2==arguments.length)for(var n,i=0,s=t.length;i<s;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}function k(e){return this instanceof k?(this.v=e,this):new k(e)}function _(e,t,r){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var n,i=r.apply(e,t||[]),s=[];return n=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),o("next"),o("throw"),o("return",function(e){return function(t){return Promise.resolve(t).then(e,l)}}),n[Symbol.asyncIterator]=function(){return this},n;function o(e,t){i[e]&&(n[e]=function(t){return new Promise(function(r,n){s.push([e,t,r,n])>1||a(e,t)})},t&&(n[e]=t(n[e])))}function a(e,t){try{var r;(r=i[e](t)).value instanceof k?Promise.resolve(r.value.v).then(u,l):c(s[0][2],r)}catch(e){c(s[0][3],e)}}function u(e){a("next",e)}function l(e){a("throw",e)}function c(e,t){e(t),s.shift(),s.length&&a(s[0][0],s[0][1])}}function S(e){var t,r;return t={},n("next"),n("throw",function(e){throw e}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(n,i){t[n]=e[n]?function(t){return(r=!r)?{value:k(e[n](t)),done:!1}:i?i(t):t}:i}}function A(e){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=m(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise(function(n,i){!function(e,t,r,n){Promise.resolve(n).then(function(t){e({value:t,done:r})},t)}(n,i,(t=e[r](t)).done,t.value)})}}}function E(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var C=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t},I=function(e){return(I=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t})(e)};function O(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=I(e),n=0;n<r.length;n++)"default"!==r[n]&&b(t,e,r[n]);return C(t,e),t}function P(e){return e&&e.__esModule?e:{default:e}}function U(e,t,r,n){if("a"===r&&!n)throw TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)}function M(e,t,r,n,i){if("m"===n)throw TypeError("Private method is not writable");if("a"===n&&!i)throw TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?i.call(e,r):i?i.value=r:t.set(e,r),r}function D(e,t){if(null===t||"object"!=typeof t&&"function"!=typeof t)throw TypeError("Cannot use 'in' operator on non-object");return"function"==typeof e?t===e:e.has(t)}function L(e,t,r){if(null!=t){var n,i;if("object"!=typeof t&&"function"!=typeof t)throw TypeError("Object expected.");if(r){if(!Symbol.asyncDispose)throw TypeError("Symbol.asyncDispose is not defined.");n=t[Symbol.asyncDispose]}if(void 0===n){if(!Symbol.dispose)throw TypeError("Symbol.dispose is not defined.");n=t[Symbol.dispose],r&&(i=n)}if("function"!=typeof n)throw TypeError("Object not disposable.");i&&(n=function(){try{i.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:n,async:r})}else r&&e.stack.push({async:!0});return t}var B="function"==typeof SuppressedError?SuppressedError:function(e,t,r){var n=Error(r);return n.name="SuppressedError",n.error=e,n.suppressed=t,n};function $(e){function t(t){e.error=e.hasError?new B(t,e.error,"An error was suppressed during disposal."):t,e.hasError=!0}var r,n=0;return function i(){for(;r=e.stack.pop();)try{if(!r.async&&1===n)return n=0,e.stack.push(r),Promise.resolve().then(i);if(r.dispose){var s=r.dispose.call(r.value);if(r.async)return n|=2,Promise.resolve(s).then(i,function(e){return t(e),i()})}else n|=1}catch(e){t(e)}if(1===n)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}()}function N(e,t){return"string"==typeof e&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(e,r,n,i,s){return r?t?".jsx":".js":!n||i&&s?n+i+"."+s.toLowerCase()+"js":e}):e}let T={__extends:i,__assign:s,__rest:o,__decorate:a,__param:u,__esDecorate:l,__runInitializers:c,__propKey:f,__setFunctionName:d,__metadata:h,__awaiter:p,__generator:w,__createBinding:b,__exportStar:y,__values:m,__read:g,__spread:x,__spreadArrays:v,__spreadArray:j,__await:k,__asyncGenerator:_,__asyncDelegator:S,__asyncValues:A,__makeTemplateObject:E,__importStar:O,__importDefault:P,__classPrivateFieldGet:U,__classPrivateFieldSet:M,__classPrivateFieldIn:D,__addDisposableResource:L,__disposeResources:$,__rewriteRelativeImportExtension:N}}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var s=t[n]={exports:{}};return e[n](s,s.exports,r),s.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{let e;r.r(n),r.d(n,{base64urlEncode:()=>c,sendInteraction:()=>e2,Deferred:()=>u,ReferralInteractionEncoder:()=>tl,getProductInformation:()=>e6,decompressJsonFromB64:()=>eu,getSupportedLocale:()=>eA,openSso:()=>e3,productTypes:()=>eC,PurchaseInteractionEncoder:()=>t_,FrakRpcError:()=>t,base64urlDecode:()=>f,referralInteraction:()=>th,productTypesMask:()=>eI,interactionTypes:()=>eO,processReferral:()=>tc,PressInteractionEncoder:()=>tp,sendTransaction:()=>e9,WebShopInteractionEncoder:()=>tS,decompressJson:()=>ea,compressJsonToB64:()=>en,hashAndCompressData:()=>et,trackPurchaseStatus:()=>e5,watchWalletStatus:()=>eP,RpcErrorCodes:()=>o,setupClient:()=>ey,RetailInteractionEncoder:()=>tA,getCurrencyAmountKey:()=>em,siweAuthenticate:()=>e7,getSupportedCurrency:()=>eb,decompressDataAndCheckHash:()=>eo,displayModal:()=>e1,FrakContextManager:()=>eS,locales:()=>ew,ClientNotFound:()=>s,baseIframeProps:()=>ec,createIframe:()=>ef,modalBuilder:()=>te,compressJson:()=>er,displayEmbeddedWallet:()=>e8,createIFrameFrakClient:()=>eh,DebugInfoGatherer:()=>a,formatAmount:()=>eE});class t extends Error{code;data;constructor(e,t,r){super(t),this.code=e,this.data=r}}class i extends t{constructor(e){super(o.internalError,e)}}class s extends t{constructor(){super(o.clientNotConnected,"Client not found")}}let o={parseError:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internalError:-32603,serverError:-32e3,clientNotConnected:-32001,configError:-32002,corruptedResponse:-32003,clientAborted:-32004,walletNotConnected:-32005,serverErrorForInteractionDelegation:-32006};class a{config;iframe;isSetupDone=!1;lastResponse=null;lastRequest=null;constructor(e,t){this.config=e,this.iframe=t,this.lastRequest=null,this.lastResponse=null}setLastResponse(e){this.lastResponse={event:e.data,origin:e.origin,timestamp:Date.now()}}setLastRequest(e,t){this.lastRequest={event:e,target:t,timestamp:Date.now()}}updateSetupStatus(e){this.isSetupDone=e}base64Encode(e){try{return btoa(JSON.stringify(e))}catch(e){return console.warn("Failed to encode debug data",e),btoa("Failed to encode data")}}getIframeStatus(){return this.iframe?{loading:this.iframe.hasAttribute("loading"),url:this.iframe.src,readyState:this.iframe.contentDocument?.readyState?+("complete"===this.iframe.contentDocument.readyState):-1,contentWindow:!!this.iframe.contentWindow,isConnected:this.iframe.isConnected}:null}getNavigatorInfo(){return navigator?{userAgent:navigator.userAgent,language:navigator.language,onLine:navigator.onLine,screenWidth:window.screen.width,screenHeight:window.screen.height,pixelRatio:window.devicePixelRatio}:null}gatherDebugInfo(e){let r=this.getIframeStatus(),n=this.getNavigatorInfo(),i="Unknown";return e instanceof t?i=`FrakRpcError: ${e.code} '${e.message}'`:e instanceof Error?i=e.message:"string"==typeof e&&(i=e),{timestamp:new Date().toISOString(),encodedUrl:btoa(window.location.href),encodedConfig:this.config?this.base64Encode(this.config):"no-config",navigatorInfo:n?this.base64Encode(n):"no-navigator",iframeStatus:r?this.base64Encode(r):"not-iframe",lastRequest:this.lastRequest?this.base64Encode(this.lastRequest):"No Frak request logged",lastResponse:this.lastResponse?this.base64Encode(this.lastResponse):"No Frak response logged",clientStatus:this.isSetupDone?"setup":"not-setup",error:i}}static empty(){return new a}formatDebugInfo(e){let t=this.gatherDebugInfo(e);return`
3
3
  Debug Information:
4
4
  -----------------
5
5
  Timestamp: ${t.timestamp}
@@ -11,9 +11,9 @@
11
11
  Last Response: ${t.lastResponse}
12
12
  Client Status: ${t.clientStatus}
13
13
  Error: ${t.error}
14
- `.trim()}}let ec={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"}};function ef({walletBaseUrl:e,config:t}){let r=document.querySelector("#frak-wallet");r&&r.remove();let n=document.createElement("iframe");return n.id=ec.id,n.name=ec.name,n.allow=ec.allow,n.style.zIndex=ec.style.zIndex.toString(),ed({iframe:n,isVisible:!1}),document.body.appendChild(n),new Promise(r=>{n?.addEventListener("load",()=>r(n)),n.src=`${t?.walletUrl??e??"https://wallet.frak.id"}/listener`})}function ed({iframe:e,isVisible:t}){if(!t){e.style.width="0",e.style.height="0",e.style.border="0",e.style.position="fixed",e.style.top="-1000px",e.style.left="-1000px";return}e.style.position="fixed",e.style.top="0",e.style.left="0",e.style.width="100%",e.style.height="100%",e.style.pointerEvents="auto"}function eh({config:e,iframe:r}){let n=function(){let e=new Map;return{createChannel:t=>{let r=Math.random().toString(36).substring(7);return e.set(r,t),r},getRpcResolver:t=>e.get(t),removeChannel:t=>e.delete(t),destroy:()=>e.clear()}}(),s=function({iframe:e}){let t=new a;return{handleEvent:async r=>{switch(r.iframeLifecycle){case"connected":t.resolve(!0);break;case"do-backup":r.data.backup?localStorage.setItem(eu,r.data.backup):localStorage.removeItem(eu);break;case"remove-backup":localStorage.removeItem(eu);break;case"show":case"hide":ed({iframe:e,isVisible:"show"===r.iframeLifecycle});break;case"handshake":e.contentWindow?.postMessage({clientLifecycle:"handshake-response",data:{token:r.data.token,currentUrl:window.location.href}},"*")}},isConnected:t.promise}}({iframe:r}),u=new el(e,r),l=function({frakWalletUrl:e,iframe:r,channelManager:n,iframeLifecycleManager:i,debugInfo:s}){if("undefined"==typeof window)throw new t(o.configError,"iframe client should be used in the browser");if(!r.contentWindow)throw new t(o.configError,"The iframe does not have a product window");let a=r.contentWindow;async function u(t){if(!t.origin)return;try{if(new URL(t.origin).origin.toLowerCase()!==new URL(e).origin.toLowerCase())return}catch(e){console.log("Unable to check frak msg origin",e);return}if("object"!=typeof t.data)return;if(s.setLastResponse(t),"iframeLifecycle"in t.data){await i.handleEvent(t.data);return}if("clientLifecycle"in t.data){console.error("Client lifecycle event received on the client side, dismissing it");return}let r=t.data.id,o=n.getRpcResolver(r);o&&o(t.data)}return window.addEventListener("message",u),{sendEvent:function(t){a.postMessage(t,{targetOrigin:e}),s.setLastRequest(t,e)},cleanup:function(){window.removeEventListener("message",u)}}}({frakWalletUrl:e?.walletUrl??"https://wallet.frak.id",iframe:r,channelManager:n,iframeLifecycleManager:s,debugInfo:u}),c=async e=>{if(!await s.isConnected)throw new t(o.clientNotConnected,"The iframe provider isn't connected yet");let r=new a,i=n.createChannel(e=>{let s=es(e.data);s.error?r.reject(new t(s.error.code,s.error.message,s.error?.data)):r.resolve(s.result),n.removeChannel(i)}),u=ee(e);return l.sendEvent({id:i,topic:e.method,data:u}),r.promise},f=async(e,r)=>{if(!await s.isConnected)throw new t(o.clientNotConnected,"The iframe provider isn't connected yet");let a=n.createChannel(e=>{let t=es(e.data);if(t.result)r(t.result);else throw new i("No valid result in the response")}),u=ee(e);l.sendEvent({id:a,topic:e.method,data:u})},d=function(e,t){let r,n;let i=()=>e.sendEvent({clientLifecycle:"heartbeat"});function s(){r&&clearInterval(r),n&&clearTimeout(n)}return async function(){i(),r=setInterval(i,100),n=setTimeout(()=>{s(),console.log("Heartbeat timeout: connection failed")},3e4),await t.isConnected,s()}(),s}(l,s),h=async()=>{d(),n.destroy(),l.cleanup(),r.remove()},p=ep({config:e,messageHandler:l,lifecycleManager:s}).then(()=>u.updateSetupStatus(!0));return{config:e,debugInfo:u,waitForConnection:s.isConnected,waitForSetup:p,request:c,listenerRequest:f,destroy:h}}async function ep({config:e,messageHandler:t,lifecycleManager:r}){async function n(){let r=e.customizations?.css;r&&t.sendEvent({clientLifecycle:"modal-css",data:{cssLink:r}})}async function i(){let r=e.customizations?.i18n;r&&t.sendEvent({clientLifecycle:"modal-i18n",data:{i18n:r}})}async function s(){if("undefined"==typeof window)return;let e=window.localStorage.getItem(eu);e&&t.sendEvent({clientLifecycle:"restore-backup",data:{backup:e}})}await r.isConnected,await Promise.all([n(),i(),s()])}let ew={eur:"fr-FR",usd:"en-US",gbp:"en-GB"};function eb(e){return e&&e in ew?e:"eur"}async function ey({config:e}){let t=function(e){let t=eb(e.metadata?.currency);return{...e,metadata:{...e.metadata,currency:t}}}(e),r=await ef({config:t});if(!r){console.error("Failed to create iframe");return}let n=eh({config:t,iframe:r});if(await n.waitForSetup,!await n.waitForConnection){console.error("Failed to connect to client");return}return n}let em="fCtx";function eg(e){if(e?.r)try{let t=Q(e.r);return l(t)}catch(t){console.error("Error compressing Frak context",{e:t,context:e})}}function ex(e){if(e&&0!==e.length)try{let t=c(e);return{r:H(t,{size:20})}}catch(t){console.error("Error decompressing Frak context",{e:t,context:e})}}function ev({url:e}){if(!e)return null;let t=new URL(e).searchParams.get(em);return t?ex(t):null}function ej({url:e,context:t}){if(!e)return null;let r=ev({url:e}),n=r?{...r,...t}:t;if(!n.r)return null;let i=eg(n);if(!i)return null;let s=new URL(e);return s.searchParams.set(em,i),s.toString()}function ek(e){let t=new URL(e);return t.searchParams.delete(em),t.toString()}let e_={compress:eg,decompress:ex,parse:ev,update:ej,remove:ek,replaceUrl:function({url:e,context:t}){let r;if(!window.location?.href||"undefined"==typeof window){console.error("No window found, can't update context");return}let n=e??window.location.href;(r=null!==t?ej({url:n,context:t}):ek(n))&&window.history.replaceState(null,"",r.toString())}};function eS(e){return e?ew[e]??ew.eur:ew.eur}function eA(e,t){let r=eS(t),n=eb(t);return e.toLocaleString(r,{style:"currency",currency:n,minimumFractionDigits:0,maximumFractionDigits:2})}function eE(e){return e?`${e}Amount`:"eurAmount"}let eC={dapp:1,press:2,webshop:3,retail:4,referral:30,purchase:31},eO=Object.entries(eC).reduce((e,[t,r])=>(e[t]=BigInt(1)<<BigInt(r),e),{}),eI={press:{openArticle:"0xc0a24ffb",readArticle:"0xd5bd0fbe"},dapp:{proofVerifiableStorageUpdate:"0x2ab2aeef",callableVerifiableStorageUpdate:"0xa07da986"},webshop:{open:"0xb311798f"},referral:{referred:"0x010cc3b9",createLink:"0xb2c0f17c"},purchase:{started:"0xd87e90c3",completed:"0x8403aeb4",unsafeCompleted:"0x4d5b14e0"},retail:{customerMeeting:"0x74489004"}};function eP(e,t){if(!t)return e.request({method:"frak_listenToWalletStatus"}).then(e=>(eU(e.interactionToken),e));let r=new a,n=!1;return e.listenerRequest({method:"frak_listenToWalletStatus"},e=>{t(e),eU(e.interactionToken),n||(r.resolve(e),n=!0)}).then(()=>r.promise)}function eU(e){"undefined"!=typeof window&&(e?window.sessionStorage.setItem("frak-wallet-interaction-token",e):window.sessionStorage.removeItem("frak.interaction-token"))}let eM=BigInt(0x100000000-1),eD=BigInt(32),eL=(e,t,r)=>e<<r|t>>>32-r,eB=(e,t,r)=>t<<r|e>>>32-r,e$=(e,t,r)=>t<<r-32|e>>>64-r,eN=(e,t,r)=>e<<r-32|t>>>64-r,eT=[],eR=[],ez=[],eF=BigInt(0),eH=BigInt(1),eV=BigInt(2),eW=BigInt(7),eJ=BigInt(256),eq=BigInt(113);for(let e=0,t=eH,r=1,n=0;e<24;e++){[r,n]=[n,(2*r+3*n)%5],eT.push(2*(5*n+r)),eR.push((e+1)*(e+2)/2%64);let i=eF;for(let e=0;e<7;e++)(t=(t<<eH^(t>>eW)*eq)%eJ)&eV&&(i^=eH<<(eH<<BigInt(e))-eH);ez.push(i)}let[eG,eK]=function(e,t=!1){let r=new Uint32Array(e.length),n=new Uint32Array(e.length);for(let i=0;i<e.length;i++){let{h:s,l:o}=function(e,t=!1){return t?{h:Number(e&eM),l:Number(e>>eD&eM)}:{h:0|Number(e>>eD&eM),l:0|Number(e&eM)}}(e[i],t);[r[i],n[i]]=[s,o]}return[r,n]}(ez,!0),eX=(e,t,r)=>r>32?e$(e,t,r):eL(e,t,r),eQ=(e,t,r)=>r>32?eN(e,t,r):eB(e,t,r);class eY extends x{constructor(e,t,r,n=!1,i=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=n,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,f(r),0>=this.blockLen||this.blockLen>=200)throw Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=function(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}(this.state)}keccak(){y||m(this.state32),function(e,t=24){let r=new Uint32Array(10);for(let n=24-t;n<24;n++){for(let t=0;t<10;t++)r[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){let n=(t+8)%10,i=(t+2)%10,s=r[i],o=r[i+1],a=eX(s,o,1)^r[n],u=eQ(s,o,1)^r[n+1];for(let r=0;r<50;r+=10)e[t+r]^=a,e[t+r+1]^=u}let t=e[2],i=e[3];for(let r=0;r<24;r++){let n=eR[r],s=eX(t,i,n),o=eQ(t,i,n),a=eT[r];t=e[a],i=e[a+1],e[a]=s,e[a+1]=o}for(let t=0;t<50;t+=10){for(let n=0;n<10;n++)r[n]=e[t+n];for(let n=0;n<10;n++)e[t+n]^=~r[(n+2)%10]&r[(n+4)%10]}e[0]^=eG[n],e[1]^=eK[n]}r.fill(0)}(this.state32,this.rounds),y||m(this.state32),this.posOut=0,this.pos=0}update(e){h(this);let{blockLen:t,state:r}=this,n=(e=g(e)).length;for(let i=0;i<n;){let s=Math.min(t-this.pos,n-i);for(let t=0;t<s;t++)r[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:r,blockLen:n}=this;e[r]^=t,(128&t)!=0&&r===n-1&&this.keccak(),e[n-1]^=128,this.keccak()}writeInto(e){h(this,!1),d(e),this.finish();let t=this.state,{blockLen:r}=this;for(let n=0,i=e.length;n<i;){this.posOut>=r&&this.keccak();let s=Math.min(r-this.posOut,i-n);e.set(t.subarray(this.posOut,this.posOut+s),n),this.posOut+=s,n+=s}return e}xofInto(e){if(!this.enableXOF)throw Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return f(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(p(e,this),this.finished)throw Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){let{blockLen:t,suffix:r,outputLen:n,rounds:i,enableXOF:s}=this;return e||(e=new eY(t,r,n,s,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=r,e.outputLen=n,e.enableXOF=s,e.destroyed=this.destroyed,e}}let eZ=v(()=>new eY(136,1,32));function e0(e,t){let r=eZ(C(e,{strict:!1})?G(e):e);return"bytes"===(t||"hex")?r:z(r)}async function e2(e,{productId:t,interaction:r,validation:n}){let i=t??function({domain:e}){return e0(z(e??window.location.host))}(e.config);return await e.request({method:"frak_sendInteraction",params:[i,r,n]})}async function e1(e,{steps:t,metadata:r}){return await e.request({method:"frak_displayModal",params:[t,r,e.config.metadata]})}async function e8(e,t){await e.request({method:"frak_displayEmbededWallet",params:[t,e.config.metadata]})}async function e3(e,t){let{metadata:r,customizations:n}=e.config;await e.request({method:"frak_sso",params:[t,r.name,n?.css]})}async function e6(e){return await e.request({method:"frak_getProductInformation"})}async function e5(e){if("undefined"==typeof window){console.warn("[Frak] No window found, can't track purchase");return}let t=window.sessionStorage.getItem("frak-wallet-interaction-token");if(!t){console.warn("[Frak] No frak session found, skipping purchase check");return}await fetch("https://backend.frak.id/interactions/listenForPurchase",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json","x-wallet-sdk-auth":t},body:JSON.stringify(e)})}let e4=256;async function e7(t,{siwe:r,metadata:n}){let i=t.config?.domain??window.location.host,s=r?.statement??`I confirm that I want to use my Frak wallet on: ${t.config.metadata.name}`,o={...r,statement:s,nonce:r?.nonce??function(t=11){if(!e||e4+t>512){e="",e4=0;for(let t=0;t<256;t++)e+=(256+256*Math.random()|0).toString(16).substring(1)}return e.substring(e4,e4+++t)}(96),uri:r?.uri??`https://${i}`,version:r?.version??"1",domain:i};return(await e1(t,{metadata:n,steps:{login:{},siweAuthenticate:{siwe:o}}})).siweAuthenticate}async function e9(e,{tx:t,metadata:r}){return(await e1(e,{metadata:r,steps:{login:{},sendTransaction:{tx:t}}})).sendTransaction}function te(e,{metadata:t,login:r,openSession:n}){return function e(t,r){async function n(e){return e&&(r.metadata=e(r.metadata??{})),await e1(t,r)}return{params:r,sendTx:function(n){return e(t,{...r,steps:{...r.steps,sendTransaction:n}})},reward:function(n){return e(t,{...r,steps:{...r.steps,final:{...n,action:{key:"reward"}}}})},sharing:function(n,i){return e(t,{...r,steps:{...r.steps,final:{...i,action:{key:"sharing",options:n}}}})},display:n}}(e,{steps:{login:r??{},openSession:n??{}},metadata:t})}class tt extends P{constructor({address:e}){super(`Address "${e}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}}class tr extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){let t=super.get(e);return super.has(e)&&void 0!==t&&(this.delete(e),super.set(e,t)),t}set(e,t){if(super.set(e,t),this.maxSize&&this.size>this.maxSize){let e=this.keys().next().value;e&&this.delete(e)}return this}}let tn=new tr(8192),ti=/^0x[a-fA-F0-9]{40}$/,ts=new tr(8192);function to(e,t){let{strict:r=!0}=t??{},n=`${e}.${r}`;if(ts.has(n))return ts.get(n);let i=!!ti.test(e)&&(e.toLowerCase()===e||!r||function(e,t){if(tn.has(`${e}.${void 0}`))return tn.get(`${e}.${t}`);let r=t?`${t}${e.toLowerCase()}`:e.substring(2).toLowerCase(),n=e0(Y(r),"bytes"),i=(t?r.substring(`${t}0x`.length):r).split("");for(let e=0;e<40;e+=2)n[e>>1]>>4>=8&&i[e]&&(i[e]=i[e].toUpperCase()),(15&n[e>>1])>=8&&i[e+1]&&(i[e+1]=i[e+1].toUpperCase());let s=`0x${i.join("")}`;return tn.set(`${e}.${t}`,s),s}(e)===e);return ts.set(n,i),i}function ta(e){return"string"==typeof e[0]?tu(e):function(e){let t=0;for(let r of e)t+=r.length;let r=new Uint8Array(t),n=0;for(let t of e)r.set(t,n),n+=t.length;return r}(e)}function tu(e){return`0x${e.reduce((e,t)=>e+t.replace("0x",""),"")}`}let tl={createLink:()=>({handlerTypeDenominator:z(eC.referral),interactionData:eI.referral.createLink}),referred({referrer:e}){let t=tu([eI.referral.referred,D(e,{size:32})]);return{handlerTypeDenominator:z(eC.referral),interactionData:t}}};async function tc(e,{walletStatus:r,frakContext:n,modalConfig:i,productId:s,options:a}){let u=!1;async function l(){if(!u)return u=!0,td(e,{modalConfig:i,walletStatus:r})}async function c(t){let r=tl.referred({referrer:t});await e2(e,{productId:s,interaction:r})}try{let{status:e,currentWallet:t}=await tf({initialWalletStatus:r,getFreshWalletStatus:l,pushReferralInteraction:c,frakContext:n});return e_.replaceUrl({url:window.location?.href,context:a?.alwaysAppendUrl?{r:t}:null}),e}catch(e){return console.log("Error processing referral",{error:e}),e_.replaceUrl({url:window.location?.href,context:a?.alwaysAppendUrl?{r:r?.wallet}:null}),function(e){if(e instanceof t)switch(e.code){case o.walletNotConnected:return"no-wallet";case o.serverErrorForInteractionDelegation:return"no-session"}return"error"}(e)}}async function tf({initialWalletStatus:e,getFreshWalletStatus:t,pushReferralInteraction:r,frakContext:n}){let i=e?.wallet;return n?.r?(i||(i=await t()),i&&function(e,t){if(!to(e,{strict:!1}))throw new tt({address:e});if(!to(t,{strict:!1}))throw new tt({address:t});return e.toLowerCase()===t.toLowerCase()}(n.r,i))?{status:"self-referral",currentWallet:i}:(e?.interactionSession||(i=await t()),await r(n.r),{status:"success",currentWallet:i}):{status:"no-referrer",currentWallet:i}}async function td(e,{modalConfig:t,walletStatus:r}){if(!r?.interactionSession){if(!t)return;let r=await e1(e,t);return r?.login?.wallet??void 0}return r.wallet??void 0}async function th(e,{productId:t,modalConfig:r,options:n}={}){let i=e_.parse({url:window.location.href}),s=await eP(e);try{return await tc(e,{walletStatus:s,frakContext:i,modalConfig:r,productId:t,options:n})}catch(e){console.warn("Error processing referral",{error:e})}}let tp={openArticle({articleId:e}){let t=tu([eI.press.openArticle,D(e,{size:32})]);return{handlerTypeDenominator:z(eC.press),interactionData:t}},readArticle({articleId:e}){let t=tu([eI.press.readArticle,D(e,{size:32})]);return{handlerTypeDenominator:z(eC.press),interactionData:t}}};class tw extends P{constructor({expectedLength:e,givenLength:t,type:r}){super(`ABI encoding array length mismatch for type ${r}.
14
+ `.trim()}}class u{_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)}}var l=r("../../node_modules/@jsonjoy.com/json-pack/lib/cbor/index.js");function c(e){return btoa(Array.from(e,e=>String.fromCharCode(e)).join("")).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function f(e){let t=e.length%4;return Uint8Array.from(atob(e.replace(/-/g,"+").replace(/_/g,"/").padEnd(e.length+(0===t?0:4-t),"=")),e=>e.charCodeAt(0))}function d(e){if(!Number.isSafeInteger(e)||e<0)throw Error("positive integer expected, got "+e)}function h(e,...t){if(!(e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name))throw Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw Error("Uint8Array expected of length "+t+", got length="+e.length)}function p(e,t=!0){if(e.destroyed)throw Error("Hash instance has been destroyed");if(t&&e.finished)throw Error("Hash#digest() has already been called")}function w(e,t){h(e);let r=t.outputLen;if(e.length<r)throw Error("digestInto() expects output buffer of length at least "+r)}function b(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function y(e,t){return e<<32-t|e>>>t}let m=68===new Uint8Array(new Uint32Array([0x11223344]).buffer)[0];function g(e){for(let r=0;r<e.length;r++){var t;e[r]=(t=e[r])<<24&0xff000000|t<<8&0xff0000|t>>>8&65280|t>>>24&255}}function x(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array(new TextEncoder().encode(e))}(e)),h(e),e}class v{clone(){return this._cloneInto()}}function j(e){let t=t=>e().update(x(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}class k extends v{constructor(e,t,r,n){super(),this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=b(this.buffer)}update(e){p(this);let{view:t,buffer:r,blockLen:n}=this,i=(e=x(e)).length;for(let s=0;s<i;){let o=Math.min(n-this.pos,i-s);if(o===n){let t=b(e);for(;n<=i-s;s+=n)this.process(t,s);continue}r.set(e.subarray(s,s+o),this.pos),this.pos+=o,s+=o,this.pos===n&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){p(this),w(e,this),this.finished=!0;let{buffer:t,view:r,blockLen:n,isLE:i}=this,{pos:s}=this;t[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>n-s&&(this.process(r,0),s=0);for(let e=s;e<n;e++)t[e]=0;(function(e,t,r,n){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,r,n);let i=BigInt(32),s=BigInt(0xffffffff),o=Number(r>>i&s),a=Number(r&s),u=4*!!n,l=4*!n;e.setUint32(t+u,o,n),e.setUint32(t+l,a,n)})(r,n-8,BigInt(8*this.length),i),this.process(r,0);let o=b(e),a=this.outputLen;if(a%4)throw Error("_sha2: outputLen should be aligned to 32bit");let u=a/4,l=this.get();if(u>l.length)throw Error("_sha2: outputLen bigger than state");for(let e=0;e<u;e++)o.setUint32(4*e,l[e],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:t,buffer:r,length:n,finished:i,destroyed:s,pos:o}=this;return e.length=n,e.pos=o,e.finished=i,e.destroyed=s,n%t&&e.buffer.set(r),e}}let _=new Uint32Array([0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5,0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5,0xd807aa98,0x12835b01,0x243185be,0x550c7dc3,0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174,0xe49b69c1,0xefbe4786,0xfc19dc6,0x240ca1cc,0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da,0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7,0xc6e00bf3,0xd5a79147,0x6ca6351,0x14292967,0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13,0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85,0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3,0xd192e819,0xd6990624,0xf40e3585,0x106aa070,0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5,0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3,0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208,0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2]),S=new Uint32Array([0x6a09e667,0xbb67ae85,0x3c6ef372,0xa54ff53a,0x510e527f,0x9b05688c,0x1f83d9ab,0x5be0cd19]),A=new Uint32Array(64);class E extends k{constructor(){super(64,32,8,!1),this.A=0|S[0],this.B=0|S[1],this.C=0|S[2],this.D=0|S[3],this.E=0|S[4],this.F=0|S[5],this.G=0|S[6],this.H=0|S[7]}get(){let{A:e,B:t,C:r,D:n,E:i,F:s,G:o,H:a}=this;return[e,t,r,n,i,s,o,a]}set(e,t,r,n,i,s,o,a){this.A=0|e,this.B=0|t,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|s,this.G=0|o,this.H=0|a}process(e,t){for(let r=0;r<16;r++,t+=4)A[r]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=A[e-15],r=A[e-2],n=y(t,7)^y(t,18)^t>>>3,i=y(r,17)^y(r,19)^r>>>10;A[e]=i+A[e-7]+n+A[e-16]|0}let{A:r,B:n,C:i,D:s,E:o,F:a,G:u,H:l}=this;for(let e=0;e<64;e++){var c,f,d,h;let t=l+(y(o,6)^y(o,11)^y(o,25))+((c=o)&a^~c&u)+_[e]+A[e]|0,p=(y(r,2)^y(r,13)^y(r,22))+((f=r)&(d=n)^f&(h=i)^d&h)|0;l=u,u=a,a=o,o=s+t|0,s=i,i=n,n=r,r=t+p|0}r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,s=s+this.D|0,o=o+this.E|0,a=a+this.F|0,u=u+this.G|0,l=l+this.H|0,this.set(r,n,i,s,o,a,u,l)}roundClean(){A.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}let C=j(()=>new E);function I(e,{strict:t=!0}={}){return!!e&&"string"==typeof e&&(t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x"))}let O="2.24.3",P={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:r})=>t?`${e??"https://viem.sh"}${t}${r?`#${r}`:""}`:void 0,version:`viem@${O}`};class U extends Error{constructor(e,t={}){let r=t.cause instanceof U?t.cause.details:t.cause?.message?t.cause.message:t.details,n=t.cause instanceof U&&t.cause.docsPath||t.docsPath,i=P.getDocsUrl?.({...t,docsPath:n});super([e||"An error occurred.","",...t.metaMessages?[...t.metaMessages,""]:[],...i?[`Docs: ${i}`]:[],...r?[`Details: ${r}`]:[],...P.version?[`Version: ${P.version}`]:[]].join("\n"),t.cause?{cause:t.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=r,this.docsPath=n,this.metaMessages=t.metaMessages,this.name=t.name??this.name,this.shortMessage=e,this.version=O}walk(e){return function e(t,r){return r?.(t)?t:t&&"object"==typeof t&&"cause"in t&&void 0!==t.cause?e(t.cause,r):r?null:t}(this,e)}}class M extends U{constructor({offset:e,position:t,size:r}){super(`Slice ${"start"===t?"starting":"ending"} at offset "${e}" is out-of-bounds (size: ${r}).`,{name:"SliceOffsetOutOfBoundsError"})}}class D extends U{constructor({size:e,targetSize:t,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (${e}) exceeds padding size (${t}).`,{name:"SizeExceedsPaddingSizeError"})}}function L(e,{dir:t,size:r=32}={}){return"string"==typeof e?B(e,{dir:t,size:r}):function(e,{dir:t,size:r=32}={}){if(null===r)return e;if(e.length>r)throw new D({size:e.length,targetSize:r,type:"bytes"});let n=new Uint8Array(r);for(let i=0;i<r;i++){let s="right"===t;n[s?i:r-i-1]=e[s?i:e.length-i-1]}return n}(e,{dir:t,size:r})}function B(e,{dir:t,size:r=32}={}){if(null===r)return e;let n=e.replace("0x","");if(n.length>2*r)throw new D({size:Math.ceil(n.length/2),targetSize:r,type:"hex"});return`0x${n["right"===t?"padEnd":"padStart"](2*r,"0")}`}class $ extends U{constructor({max:e,min:t,signed:r,size:n,value:i}){super(`Number "${i}" is not in safe ${n?`${8*n}-bit ${r?"signed":"unsigned"} `:""}integer range ${e?`(${t} to ${e})`:`(above ${t})`}`,{name:"IntegerOutOfRangeError"})}}class N extends U{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed ${t} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function T(e){return I(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}function R(e,{size:t}){if(T(e)>t)throw new N({givenSize:T(e),maxSize:t})}let z=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function F(e,t={}){return"number"==typeof e||"bigint"==typeof e?W(e,t):"string"==typeof e?q(e,t):"boolean"==typeof e?H(e,t):V(e,t)}function H(e,t={}){let r=`0x${Number(e)}`;return"number"==typeof t.size?(R(r,{size:t.size}),L(r,{size:t.size})):r}function V(e,t={}){let r="";for(let t=0;t<e.length;t++)r+=z[e[t]];let n=`0x${r}`;return"number"==typeof t.size?(R(n,{size:t.size}),L(n,{dir:"right",size:t.size})):n}function W(e,t={}){let r;let{signed:n,size:i}=t,s=BigInt(e);i?r=n?(1n<<8n*BigInt(i)-1n)-1n:2n**(8n*BigInt(i))-1n:"number"==typeof e&&(r=BigInt(Number.MAX_SAFE_INTEGER));let o="bigint"==typeof r&&n?-r-1n:0;if(r&&s>r||s<o){let t="bigint"==typeof e?"n":"";throw new $({max:r?`${r}${t}`:void 0,min:`${o}${t}`,signed:n,size:i,value:`${e}${t}`})}let a=`0x${(n&&s<0?(1n<<BigInt(8*i))+BigInt(s):s).toString(16)}`;return i?L(a,{size:i}):a}let J=new TextEncoder;function q(e,t={}){return V(J.encode(e),t)}let G=new TextEncoder;function K(e,t={}){return"number"==typeof e||"bigint"==typeof e?Y(W(e,t)):"boolean"==typeof e?function(e,t={}){let r=new Uint8Array(1);return(r[0]=Number(e),"number"==typeof t.size)?(R(r,{size:t.size}),L(r,{size:t.size})):r}(e,t):I(e)?Y(e,t):Z(e,t)}let X={zero:48,nine:57,A:65,F:70,a:97,f:102};function Q(e){return e>=X.zero&&e<=X.nine?e-X.zero:e>=X.A&&e<=X.F?e-(X.A-10):e>=X.a&&e<=X.f?e-(X.a-10):void 0}function Y(e,t={}){let r=e;t.size&&(R(r,{size:t.size}),r=L(r,{dir:"right",size:t.size}));let n=r.slice(2);n.length%2&&(n=`0${n}`);let i=n.length/2,s=new Uint8Array(i);for(let e=0,t=0;e<i;e++){let r=Q(n.charCodeAt(t++)),i=Q(n.charCodeAt(t++));if(void 0===r||void 0===i)throw new U(`Invalid byte sequence ("${n[t-2]}${n[t-1]}" in "${n}").`);s[e]=16*r+i}return s}function Z(e,t={}){let r=G.encode(e);return"number"==typeof t.size?(R(r,{size:t.size}),L(r,{dir:"right",size:t.size})):r}let ee=new l.CborEncoder;function et(e){let t={...e,validationHash:ei(e)};return ee.encode(t)}function er(e){return ee.encode(e)}function en(e){return c(er(e))}function ei(e){var t,r;return F(C(I(t=ee.encode(e),{strict:!1})?K(t):t))}let es=new l.CborDecoder;function eo(e){if(!e.length)throw new t(o.corruptedResponse,"Missing compressed data");let r=ea(e);if(!r)throw new t(o.corruptedResponse,"Invalid compressed data");if(!r?.validationHash)throw new t(o.corruptedResponse,"Missing validation hash");let{validationHash:n,...i}=r;if(ei(i)!==r.validationHash)throw new t(o.corruptedResponse,"Invalid data validation hash");return r}function ea(e){try{return es.decode(e)}catch(t){return console.error("Invalid compressed data",{e:t,data:e}),null}}function eu(e){return ea(f(e))}let el="nexus-wallet-backup",ec={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"}};function ef({walletBaseUrl:e,config:t}){let r=document.querySelector("#frak-wallet");r&&r.remove();let n=document.createElement("iframe");return n.id=ec.id,n.name=ec.name,n.allow=ec.allow,n.style.zIndex=ec.style.zIndex.toString(),ed({iframe:n,isVisible:!1}),document.body.appendChild(n),new Promise(r=>{n?.addEventListener("load",()=>r(n)),n.src=`${t?.walletUrl??e??"https://wallet.frak.id"}/listener`})}function ed({iframe:e,isVisible:t}){if(!t){e.style.width="0",e.style.height="0",e.style.border="0",e.style.position="fixed",e.style.top="-1000px",e.style.left="-1000px";return}e.style.position="fixed",e.style.top="0",e.style.left="0",e.style.width="100%",e.style.height="100%",e.style.pointerEvents="auto"}function eh({config:e,iframe:r}){let n=function(){let e=new Map;return{createChannel:t=>{let r=Math.random().toString(36).substring(7);return e.set(r,t),r},getRpcResolver:t=>e.get(t),removeChannel:t=>e.delete(t),destroy:()=>e.clear()}}(),s=function({iframe:e}){let t=new u;return{handleEvent:async r=>{switch(r.iframeLifecycle){case"connected":t.resolve(!0);break;case"do-backup":r.data.backup?localStorage.setItem(el,r.data.backup):localStorage.removeItem(el);break;case"remove-backup":localStorage.removeItem(el);break;case"show":case"hide":ed({iframe:e,isVisible:"show"===r.iframeLifecycle});break;case"handshake":e.contentWindow?.postMessage({clientLifecycle:"handshake-response",data:{token:r.data.token,currentUrl:window.location.href}},"*")}},isConnected:t.promise}}({iframe:r}),l=new a(e,r),c=function({frakWalletUrl:e,iframe:r,channelManager:n,iframeLifecycleManager:i,debugInfo:s}){if("undefined"==typeof window)throw new t(o.configError,"iframe client should be used in the browser");if(!r.contentWindow)throw new t(o.configError,"The iframe does not have a product window");let a=r.contentWindow;async function u(t){if(!t.origin)return;try{if(new URL(t.origin).origin.toLowerCase()!==new URL(e).origin.toLowerCase())return}catch(e){console.log("Unable to check frak msg origin",e);return}if("object"!=typeof t.data)return;if(s.setLastResponse(t),"iframeLifecycle"in t.data){await i.handleEvent(t.data);return}if("clientLifecycle"in t.data){console.error("Client lifecycle event received on the client side, dismissing it");return}let r=t.data.id,o=n.getRpcResolver(r);o&&o(t.data)}return window.addEventListener("message",u),{sendEvent:function(t){a.postMessage(t,{targetOrigin:e}),s.setLastRequest(t,e)},cleanup:function(){window.removeEventListener("message",u)}}}({frakWalletUrl:e?.walletUrl??"https://wallet.frak.id",iframe:r,channelManager:n,iframeLifecycleManager:s,debugInfo:l}),f=async e=>{if(!await s.isConnected)throw new t(o.clientNotConnected,"The iframe provider isn't connected yet");let r=new u,i=n.createChannel(e=>{let s=eo(e.data);s.error?r.reject(new t(s.error.code,s.error.message,s.error?.data)):r.resolve(s.result),n.removeChannel(i)}),a=et(e);return c.sendEvent({id:i,topic:e.method,data:a}),r.promise},d=async(e,r)=>{if(!await s.isConnected)throw new t(o.clientNotConnected,"The iframe provider isn't connected yet");let a=n.createChannel(e=>{let t=eo(e.data);if(t.result)r(t.result);else throw new i("No valid result in the response")}),u=et(e);c.sendEvent({id:a,topic:e.method,data:u})},h=function(e,t){let r,n;let i=()=>e.sendEvent({clientLifecycle:"heartbeat"});function s(){r&&clearInterval(r),n&&clearTimeout(n)}return async function(){i(),r=setInterval(i,100),n=setTimeout(()=>{s(),console.log("Heartbeat timeout: connection failed")},3e4),await t.isConnected,s()}(),s}(c,s),p=async()=>{h(),n.destroy(),c.cleanup(),r.remove()},w=ep({config:e,messageHandler:c,lifecycleManager:s}).then(()=>l.updateSetupStatus(!0));return{config:e,debugInfo:l,waitForConnection:s.isConnected,waitForSetup:w,request:f,listenerRequest:d,destroy:p}}async function ep({config:e,messageHandler:t,lifecycleManager:r}){async function n(){let r=e.customizations?.css;r&&t.sendEvent({clientLifecycle:"modal-css",data:{cssLink:r}})}async function i(){let r=e.customizations?.i18n;r&&t.sendEvent({clientLifecycle:"modal-i18n",data:{i18n:r}})}async function s(){if("undefined"==typeof window)return;let e=window.localStorage.getItem(el);e&&t.sendEvent({clientLifecycle:"restore-backup",data:{backup:e}})}await r.isConnected,await Promise.all([n(),i(),s()])}let ew={eur:"fr-FR",usd:"en-US",gbp:"en-GB"};function eb(e){return e&&e in ew?e:"eur"}async function ey({config:e}){let t=function(e){let t=eb(e.metadata?.currency);return{...e,metadata:{...e.metadata,currency:t}}}(e),r=await ef({config:t});if(!r){console.error("Failed to create iframe");return}let n=eh({config:t,iframe:r});if(await n.waitForSetup,!await n.waitForConnection){console.error("Failed to connect to client");return}return n}function em(e){return e?`${e}Amount`:"eurAmount"}let eg="fCtx";function ex(e){if(e?.r)try{let t=Y(e.r);return c(t)}catch(t){console.error("Error compressing Frak context",{e:t,context:e})}}function ev(e){if(e&&0!==e.length)try{let t=f(e);return{r:V(t,{size:20})}}catch(t){console.error("Error decompressing Frak context",{e:t,context:e})}}function ej({url:e}){if(!e)return null;let t=new URL(e).searchParams.get(eg);return t?ev(t):null}function ek({url:e,context:t}){if(!e)return null;let r=ej({url:e}),n=r?{...r,...t}:t;if(!n.r)return null;let i=ex(n);if(!i)return null;let s=new URL(e);return s.searchParams.set(eg,i),s.toString()}function e_(e){let t=new URL(e);return t.searchParams.delete(eg),t.toString()}let eS={compress:ex,decompress:ev,parse:ej,update:ek,remove:e_,replaceUrl:function({url:e,context:t}){let r;if(!window.location?.href||"undefined"==typeof window){console.error("No window found, can't update context");return}let n=e??window.location.href;(r=null!==t?ek({url:n,context:t}):e_(n))&&window.history.replaceState(null,"",r.toString())}};function eA(e){return e?ew[e]??ew.eur:ew.eur}function eE(e,t){let r=eA(t),n=eb(t);return e.toLocaleString(r,{style:"currency",currency:n,minimumFractionDigits:0,maximumFractionDigits:2})}let eC={dapp:1,press:2,webshop:3,retail:4,referral:30,purchase:31},eI=Object.entries(eC).reduce((e,[t,r])=>(e[t]=BigInt(1)<<BigInt(r),e),{}),eO={press:{openArticle:"0xc0a24ffb",readArticle:"0xd5bd0fbe"},dapp:{proofVerifiableStorageUpdate:"0x2ab2aeef",callableVerifiableStorageUpdate:"0xa07da986"},webshop:{open:"0xb311798f"},referral:{referred:"0x010cc3b9",createLink:"0xb2c0f17c"},purchase:{started:"0xd87e90c3",completed:"0x8403aeb4",unsafeCompleted:"0x4d5b14e0"},retail:{customerMeeting:"0x74489004"}};function eP(e,t){if(!t)return e.request({method:"frak_listenToWalletStatus"}).then(e=>(eU(e.interactionToken),e));let r=new u,n=!1;return e.listenerRequest({method:"frak_listenToWalletStatus"},e=>{t(e),eU(e.interactionToken),n||(r.resolve(e),n=!0)}).then(()=>r.promise)}function eU(e){"undefined"!=typeof window&&(e?window.sessionStorage.setItem("frak-wallet-interaction-token",e):window.sessionStorage.removeItem("frak.interaction-token"))}let eM=BigInt(0x100000000-1),eD=BigInt(32),eL=(e,t,r)=>e<<r|t>>>32-r,eB=(e,t,r)=>t<<r|e>>>32-r,e$=(e,t,r)=>t<<r-32|e>>>64-r,eN=(e,t,r)=>e<<r-32|t>>>64-r,eT=[],eR=[],ez=[],eF=BigInt(0),eH=BigInt(1),eV=BigInt(2),eW=BigInt(7),eJ=BigInt(256),eq=BigInt(113);for(let e=0,t=eH,r=1,n=0;e<24;e++){[r,n]=[n,(2*r+3*n)%5],eT.push(2*(5*n+r)),eR.push((e+1)*(e+2)/2%64);let i=eF;for(let e=0;e<7;e++)(t=(t<<eH^(t>>eW)*eq)%eJ)&eV&&(i^=eH<<(eH<<BigInt(e))-eH);ez.push(i)}let[eG,eK]=function(e,t=!1){let r=new Uint32Array(e.length),n=new Uint32Array(e.length);for(let i=0;i<e.length;i++){let{h:s,l:o}=function(e,t=!1){return t?{h:Number(e&eM),l:Number(e>>eD&eM)}:{h:0|Number(e>>eD&eM),l:0|Number(e&eM)}}(e[i],t);[r[i],n[i]]=[s,o]}return[r,n]}(ez,!0),eX=(e,t,r)=>r>32?e$(e,t,r):eL(e,t,r),eQ=(e,t,r)=>r>32?eN(e,t,r):eB(e,t,r);class eY extends v{constructor(e,t,r,n=!1,i=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=n,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,d(r),0>=this.blockLen||this.blockLen>=200)throw Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=function(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}(this.state)}keccak(){m||g(this.state32),function(e,t=24){let r=new Uint32Array(10);for(let n=24-t;n<24;n++){for(let t=0;t<10;t++)r[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){let n=(t+8)%10,i=(t+2)%10,s=r[i],o=r[i+1],a=eX(s,o,1)^r[n],u=eQ(s,o,1)^r[n+1];for(let r=0;r<50;r+=10)e[t+r]^=a,e[t+r+1]^=u}let t=e[2],i=e[3];for(let r=0;r<24;r++){let n=eR[r],s=eX(t,i,n),o=eQ(t,i,n),a=eT[r];t=e[a],i=e[a+1],e[a]=s,e[a+1]=o}for(let t=0;t<50;t+=10){for(let n=0;n<10;n++)r[n]=e[t+n];for(let n=0;n<10;n++)e[t+n]^=~r[(n+2)%10]&r[(n+4)%10]}e[0]^=eG[n],e[1]^=eK[n]}r.fill(0)}(this.state32,this.rounds),m||g(this.state32),this.posOut=0,this.pos=0}update(e){p(this);let{blockLen:t,state:r}=this,n=(e=x(e)).length;for(let i=0;i<n;){let s=Math.min(t-this.pos,n-i);for(let t=0;t<s;t++)r[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:r,blockLen:n}=this;e[r]^=t,(128&t)!=0&&r===n-1&&this.keccak(),e[n-1]^=128,this.keccak()}writeInto(e){p(this,!1),h(e),this.finish();let t=this.state,{blockLen:r}=this;for(let n=0,i=e.length;n<i;){this.posOut>=r&&this.keccak();let s=Math.min(r-this.posOut,i-n);e.set(t.subarray(this.posOut,this.posOut+s),n),this.posOut+=s,n+=s}return e}xofInto(e){if(!this.enableXOF)throw Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return d(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(w(e,this),this.finished)throw Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){let{blockLen:t,suffix:r,outputLen:n,rounds:i,enableXOF:s}=this;return e||(e=new eY(t,r,n,s,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=r,e.outputLen=n,e.enableXOF=s,e.destroyed=this.destroyed,e}}let eZ=j(()=>new eY(136,1,32));function e0(e,t){let r=eZ(I(e,{strict:!1})?K(e):e);return"bytes"===(t||"hex")?r:F(r)}async function e2(e,{productId:t,interaction:r,validation:n}){let i=t??function({domain:e}){return e0(F((e??window.location.host).replace("www.","")))}(e.config);return await e.request({method:"frak_sendInteraction",params:[i,r,n]})}async function e1(e,{steps:t,metadata:r}){return await e.request({method:"frak_displayModal",params:[t,r,e.config.metadata]})}async function e8(e,t){return await e.request({method:"frak_displayEmbeddedWallet",params:[t,e.config.metadata]})}async function e3(e,t){let{metadata:r,customizations:n}=e.config;await e.request({method:"frak_sso",params:[t,r.name,n?.css]})}async function e6(e){return await e.request({method:"frak_getProductInformation"})}async function e5(e){if("undefined"==typeof window){console.warn("[Frak] No window found, can't track purchase");return}let t=window.sessionStorage.getItem("frak-wallet-interaction-token");if(!t){console.warn("[Frak] No frak session found, skipping purchase check");return}await fetch("https://backend.frak.id/interactions/listenForPurchase",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json","x-wallet-sdk-auth":t},body:JSON.stringify(e)})}let e4=256;async function e7(t,{siwe:r,metadata:n}){let i=t.config?.domain??window.location.host,s=r?.statement??`I confirm that I want to use my Frak wallet on: ${t.config.metadata.name}`,o={...r,statement:s,nonce:r?.nonce??function(t=11){if(!e||e4+t>512){e="",e4=0;for(let t=0;t<256;t++)e+=(256+256*Math.random()|0).toString(16).substring(1)}return e.substring(e4,e4+++t)}(96),uri:r?.uri??`https://${i}`,version:r?.version??"1",domain:i};return(await e1(t,{metadata:n,steps:{login:{},siweAuthenticate:{siwe:o}}})).siweAuthenticate}async function e9(e,{tx:t,metadata:r}){return(await e1(e,{metadata:r,steps:{login:{},sendTransaction:{tx:t}}})).sendTransaction}function te(e,{metadata:t,login:r,openSession:n}){return function e(t,r){async function n(e){return e&&(r.metadata=e(r.metadata??{})),await e1(t,r)}return{params:r,sendTx:function(n){return e(t,{...r,steps:{...r.steps,sendTransaction:n}})},reward:function(n){return e(t,{...r,steps:{...r.steps,final:{...n,action:{key:"reward"}}}})},sharing:function(n,i){return e(t,{...r,steps:{...r.steps,final:{...i,action:{key:"sharing",options:n}}}})},display:n}}(e,{steps:{login:r??{},openSession:n??{}},metadata:t})}class tt extends U{constructor({address:e}){super(`Address "${e}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}}class tr extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){let t=super.get(e);return super.has(e)&&void 0!==t&&(this.delete(e),super.set(e,t)),t}set(e,t){if(super.set(e,t),this.maxSize&&this.size>this.maxSize){let e=this.keys().next().value;e&&this.delete(e)}return this}}let tn=new tr(8192),ti=/^0x[a-fA-F0-9]{40}$/,ts=new tr(8192);function to(e,t){let{strict:r=!0}=t??{},n=`${e}.${r}`;if(ts.has(n))return ts.get(n);let i=!!ti.test(e)&&(e.toLowerCase()===e||!r||function(e,t){if(tn.has(`${e}.${void 0}`))return tn.get(`${e}.${t}`);let r=t?`${t}${e.toLowerCase()}`:e.substring(2).toLowerCase(),n=e0(Z(r),"bytes"),i=(t?r.substring(`${t}0x`.length):r).split("");for(let e=0;e<40;e+=2)n[e>>1]>>4>=8&&i[e]&&(i[e]=i[e].toUpperCase()),(15&n[e>>1])>=8&&i[e+1]&&(i[e+1]=i[e+1].toUpperCase());let s=`0x${i.join("")}`;return tn.set(`${e}.${t}`,s),s}(e)===e);return ts.set(n,i),i}function ta(e){return"string"==typeof e[0]?tu(e):function(e){let t=0;for(let r of e)t+=r.length;let r=new Uint8Array(t),n=0;for(let t of e)r.set(t,n),n+=t.length;return r}(e)}function tu(e){return`0x${e.reduce((e,t)=>e+t.replace("0x",""),"")}`}let tl={createLink:()=>({handlerTypeDenominator:F(eC.referral),interactionData:eO.referral.createLink}),referred({referrer:e}){let t=tu([eO.referral.referred,L(e,{size:32})]);return{handlerTypeDenominator:F(eC.referral),interactionData:t}}};async function tc(e,{walletStatus:r,frakContext:n,modalConfig:i,productId:s,options:a}){let u=!1;async function l(){if(!u)return u=!0,td(e,{modalConfig:{...i,loggedIn:{action:{key:"referred"}}},walletStatus:r})}async function c(t){let r=tl.referred({referrer:t});await e2(e,{productId:s,interaction:r})}try{let{status:e,currentWallet:t}=await tf({initialWalletStatus:r,getFreshWalletStatus:l,pushReferralInteraction:c,frakContext:n});return eS.replaceUrl({url:window.location?.href,context:a?.alwaysAppendUrl?{r:t}:null}),e}catch(e){return console.log("Error processing referral",{error:e}),eS.replaceUrl({url:window.location?.href,context:a?.alwaysAppendUrl?{r:r?.wallet}:null}),function(e){if(e instanceof t)switch(e.code){case o.walletNotConnected:return"no-wallet";case o.serverErrorForInteractionDelegation:return"no-session"}return"error"}(e)}}async function tf({initialWalletStatus:e,getFreshWalletStatus:t,pushReferralInteraction:r,frakContext:n}){let i=e?.wallet;return n?.r?(i||(i=await t()),i&&function(e,t){if(!to(e,{strict:!1}))throw new tt({address:e});if(!to(t,{strict:!1}))throw new tt({address:t});return e.toLowerCase()===t.toLowerCase()}(n.r,i))?{status:"self-referral",currentWallet:i}:(e?.interactionSession||(i=await t()),await r(n.r),{status:"success",currentWallet:i}):{status:"no-referrer",currentWallet:i}}async function td(e,{modalConfig:t,walletStatus:r}){if(!r?.interactionSession){let r=await e8(e,t??{});return r?.wallet??void 0}return r.wallet??void 0}async function th(e,{productId:t,modalConfig:r,options:n}={}){let i=eS.parse({url:window.location.href}),s=await eP(e);try{return await tc(e,{walletStatus:s,frakContext:i,modalConfig:r,productId:t,options:n})}catch(e){console.warn("Error processing referral",{error:e})}}let tp={openArticle({articleId:e}){let t=tu([eO.press.openArticle,L(e,{size:32})]);return{handlerTypeDenominator:F(eC.press),interactionData:t}},readArticle({articleId:e}){let t=tu([eO.press.readArticle,L(e,{size:32})]);return{handlerTypeDenominator:F(eC.press),interactionData:t}}};class tw extends U{constructor({expectedLength:e,givenLength:t,type:r}){super(`ABI encoding array length mismatch for type ${r}.
15
15
  Expected length: ${e}
16
- Given length: ${t}`,{name:"AbiEncodingArrayLengthMismatchError"})}}class tb extends P{constructor({expectedSize:e,value:t}){super(`Size of bytes "${t}" (bytes${N(t)}) does not match expected size (bytes${e}).`,{name:"AbiEncodingBytesSizeMismatchError"})}}class ty extends P{constructor({expectedLength:e,givenLength:t}){super(`ABI encoding params/values length mismatch.
16
+ Given length: ${t}`,{name:"AbiEncodingArrayLengthMismatchError"})}}class tb extends U{constructor({expectedSize:e,value:t}){super(`Size of bytes "${t}" (bytes${T(t)}) does not match expected size (bytes${e}).`,{name:"AbiEncodingBytesSizeMismatchError"})}}class ty extends U{constructor({expectedLength:e,givenLength:t}){super(`ABI encoding params/values length mismatch.
17
17
  Expected length (params): ${e}
18
- Given length (values): ${t}`,{name:"AbiEncodingLengthMismatchError"})}}class tm extends P{constructor(e,{docsPath:t}){super(`Type "${e}" is not a valid encoding type.
19
- Please provide a valid ABI type.`,{docsPath:t,name:"InvalidAbiEncodingType"})}}class tg extends P{constructor(e){super(`Value "${e}" is not a valid array.`,{name:"InvalidArrayError"})}}function tx(e,t){if("number"==typeof t&&t>0&&t>N(e)-1)throw new U({offset:t,position:"start",size:N(e)})}function tv(e,t,r){if("number"==typeof t&&"number"==typeof r&&N(e)!==r-t)throw new U({offset:r,position:"end",size:N(e)})}let tj=/^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;function tk(e){let t=0;for(let r=0;r<e.length;r++){let{dynamic:n,encoded:i}=e[r];n?t+=32:t+=N(i)}let r=[],n=[],i=0;for(let s=0;s<e.length;s++){let{dynamic:o,encoded:a}=e[s];o?(r.push(V(t+i,{size:32})),n.push(a),i+=N(a)):r.push(a)}return ta([...r,...n])}let t_={startPurchase({purchaseId:e}){let t=tu([eI.purchase.started,D(e,{size:32})]);return{handlerTypeDenominator:z(eC.purchase),interactionData:t}},completedPurchase({purchaseId:e,proof:t}){let r=function(e,t){if(e.length!==t.length)throw new ty({expectedLength:e.length,givenLength:t.length});let r=tk(function({params:e,values:t}){let r=[];for(let n=0;n<e.length;n++)r.push(function e({param:t,value:r}){let n=function(e){let t=e.match(/^(.*)\[(\d+)?\]$/);return t?[t[2]?Number(t[2]):null,t[1]]:void 0}(t.type);if(n){let[i,s]=n;return function(t,{length:r,param:n}){let i=null===r;if(!Array.isArray(t))throw new tg(t);if(!i&&t.length!==r)throw new tw({expectedLength:r,givenLength:t.length,type:`${n.type}[${r}]`});let s=!1,o=[];for(let r=0;r<t.length;r++){let i=e({param:n,value:t[r]});i.dynamic&&(s=!0),o.push(i)}if(i||s){let e=tk(o);if(i){let t=V(o.length,{size:32});return{dynamic:!0,encoded:o.length>0?ta([t,e]):t}}if(s)return{dynamic:!0,encoded:e}}return{dynamic:!1,encoded:ta(o.map(({encoded:e})=>e))}}(r,{length:i,param:{...t,type:s}})}if("tuple"===t.type)return function(t,{param:r}){let n=!1,i=[];for(let s=0;s<r.components.length;s++){let o=r.components[s],a=Array.isArray(t)?s:o.name,u=e({param:o,value:t[a]});i.push(u),u.dynamic&&(n=!0)}return{dynamic:n,encoded:n?tk(i):ta(i.map(({encoded:e})=>e))}}(r,{param:t});if("address"===t.type)return function(e){if(!to(e))throw new tt({address:e});return{dynamic:!1,encoded:L(e.toLowerCase())}}(r);if("bool"===t.type)return function(e){if("boolean"!=typeof e)throw new P(`Invalid boolean value: "${e}" (type: ${typeof e}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:L(F(e))}}(r);if(t.type.startsWith("uint")||t.type.startsWith("int")){let e=t.type.startsWith("int"),[,,n="256"]=tj.exec(t.type)??[];return function(e,{signed:t,size:r=256}){if("number"==typeof r){let n=2n**(BigInt(r)-(t?1n:0n))-1n,i=t?-n-1n:0n;if(e>n||e<i)throw new B({max:n.toString(),min:i.toString(),signed:t,size:r/8,value:e.toString()})}return{dynamic:!1,encoded:V(e,{size:32,signed:t})}}(r,{signed:e,size:Number(n)})}if(t.type.startsWith("bytes"))return function(e,{param:t}){let[,r]=t.type.split("bytes"),n=N(e);if(!r){let t=e;return n%32!=0&&(t=L(t,{dir:"right",size:32*Math.ceil((e.length-2)/2/32)})),{dynamic:!0,encoded:ta([L(V(n,{size:32})),t])}}if(n!==Number.parseInt(r))throw new tb({expectedSize:Number.parseInt(r),value:e});return{dynamic:!1,encoded:L(e,{dir:"right"})}}(r,{param:t});if("string"===t.type)return function(e){let t=J(e),r=Math.ceil(N(t)/32),n=[];for(let e=0;e<r;e++)n.push(L(function(e,t,r,{strict:n}={}){return C(e,{strict:!1})?function(e,t,r,{strict:n}={}){tx(e,t);let i=`0x${e.replace("0x","").slice((t??0)*2,(r??e.length)*2)}`;return n&&tv(i,t,r),i}(e,t,r,{strict:n}):function(e,t,r,{strict:n}={}){tx(e,t);let i=e.slice(t,r);return n&&tv(i,t,r),i}(e,t,r,{strict:n})}(t,32*e,(e+1)*32),{dir:"right"}));return{dynamic:!0,encoded:ta([L(V(N(t),{size:32})),...n])}}(r);throw new tm(t.type,{docsPath:"/docs/contract/encodeAbiParameters"})}({param:e[n],value:t[n]}));return r}({params:e,values:t}));return 0===r.length?"0x":r}([{type:"uint256"},{type:"bytes32[]"}],[BigInt(e),t]),n=tu([eI.purchase.completed,r]);return{handlerTypeDenominator:z(eC.purchase),interactionData:n}},unsafeCompletedPurchase({purchaseId:e}){let t=tu([eI.purchase.unsafeCompleted,D(e,{size:32})]);return{handlerTypeDenominator:z(eC.purchase),interactionData:t}}},tS={open:()=>({handlerTypeDenominator:z(eC.webshop),interactionData:eI.webshop.open})},tA={customerMeeting({agencyId:e}){let t=tu([eI.retail.customerMeeting,D(e,{size:32})]);return{handlerTypeDenominator:z(eC.retail),interactionData:t}}}})(),n})());
18
+ Given length (values): ${t}`,{name:"AbiEncodingLengthMismatchError"})}}class tm extends U{constructor(e,{docsPath:t}){super(`Type "${e}" is not a valid encoding type.
19
+ Please provide a valid ABI type.`,{docsPath:t,name:"InvalidAbiEncodingType"})}}class tg extends U{constructor(e){super(`Value "${e}" is not a valid array.`,{name:"InvalidArrayError"})}}function tx(e,t){if("number"==typeof t&&t>0&&t>T(e)-1)throw new M({offset:t,position:"start",size:T(e)})}function tv(e,t,r){if("number"==typeof t&&"number"==typeof r&&T(e)!==r-t)throw new M({offset:r,position:"end",size:T(e)})}let tj=/^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;function tk(e){let t=0;for(let r=0;r<e.length;r++){let{dynamic:n,encoded:i}=e[r];n?t+=32:t+=T(i)}let r=[],n=[],i=0;for(let s=0;s<e.length;s++){let{dynamic:o,encoded:a}=e[s];o?(r.push(W(t+i,{size:32})),n.push(a),i+=T(a)):r.push(a)}return ta([...r,...n])}let t_={startPurchase({purchaseId:e}){let t=tu([eO.purchase.started,L(e,{size:32})]);return{handlerTypeDenominator:F(eC.purchase),interactionData:t}},completedPurchase({purchaseId:e,proof:t}){let r=function(e,t){if(e.length!==t.length)throw new ty({expectedLength:e.length,givenLength:t.length});let r=tk(function({params:e,values:t}){let r=[];for(let n=0;n<e.length;n++)r.push(function e({param:t,value:r}){let n=function(e){let t=e.match(/^(.*)\[(\d+)?\]$/);return t?[t[2]?Number(t[2]):null,t[1]]:void 0}(t.type);if(n){let[i,s]=n;return function(t,{length:r,param:n}){let i=null===r;if(!Array.isArray(t))throw new tg(t);if(!i&&t.length!==r)throw new tw({expectedLength:r,givenLength:t.length,type:`${n.type}[${r}]`});let s=!1,o=[];for(let r=0;r<t.length;r++){let i=e({param:n,value:t[r]});i.dynamic&&(s=!0),o.push(i)}if(i||s){let e=tk(o);if(i){let t=W(o.length,{size:32});return{dynamic:!0,encoded:o.length>0?ta([t,e]):t}}if(s)return{dynamic:!0,encoded:e}}return{dynamic:!1,encoded:ta(o.map(({encoded:e})=>e))}}(r,{length:i,param:{...t,type:s}})}if("tuple"===t.type)return function(t,{param:r}){let n=!1,i=[];for(let s=0;s<r.components.length;s++){let o=r.components[s],a=Array.isArray(t)?s:o.name,u=e({param:o,value:t[a]});i.push(u),u.dynamic&&(n=!0)}return{dynamic:n,encoded:n?tk(i):ta(i.map(({encoded:e})=>e))}}(r,{param:t});if("address"===t.type)return function(e){if(!to(e))throw new tt({address:e});return{dynamic:!1,encoded:B(e.toLowerCase())}}(r);if("bool"===t.type)return function(e){if("boolean"!=typeof e)throw new U(`Invalid boolean value: "${e}" (type: ${typeof e}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:B(H(e))}}(r);if(t.type.startsWith("uint")||t.type.startsWith("int")){let e=t.type.startsWith("int"),[,,n="256"]=tj.exec(t.type)??[];return function(e,{signed:t,size:r=256}){if("number"==typeof r){let n=2n**(BigInt(r)-(t?1n:0n))-1n,i=t?-n-1n:0n;if(e>n||e<i)throw new $({max:n.toString(),min:i.toString(),signed:t,size:r/8,value:e.toString()})}return{dynamic:!1,encoded:W(e,{size:32,signed:t})}}(r,{signed:e,size:Number(n)})}if(t.type.startsWith("bytes"))return function(e,{param:t}){let[,r]=t.type.split("bytes"),n=T(e);if(!r){let t=e;return n%32!=0&&(t=B(t,{dir:"right",size:32*Math.ceil((e.length-2)/2/32)})),{dynamic:!0,encoded:ta([B(W(n,{size:32})),t])}}if(n!==Number.parseInt(r))throw new tb({expectedSize:Number.parseInt(r),value:e});return{dynamic:!1,encoded:B(e,{dir:"right"})}}(r,{param:t});if("string"===t.type)return function(e){let t=q(e),r=Math.ceil(T(t)/32),n=[];for(let e=0;e<r;e++)n.push(B(function(e,t,r,{strict:n}={}){return I(e,{strict:!1})?function(e,t,r,{strict:n}={}){tx(e,t);let i=`0x${e.replace("0x","").slice((t??0)*2,(r??e.length)*2)}`;return n&&tv(i,t,r),i}(e,t,r,{strict:n}):function(e,t,r,{strict:n}={}){tx(e,t);let i=e.slice(t,r);return n&&tv(i,t,r),i}(e,t,r,{strict:n})}(t,32*e,(e+1)*32),{dir:"right"}));return{dynamic:!0,encoded:ta([B(W(T(t),{size:32})),...n])}}(r);throw new tm(t.type,{docsPath:"/docs/contract/encodeAbiParameters"})}({param:e[n],value:t[n]}));return r}({params:e,values:t}));return 0===r.length?"0x":r}([{type:"uint256"},{type:"bytes32[]"}],[BigInt(e),t]),n=tu([eO.purchase.completed,r]);return{handlerTypeDenominator:F(eC.purchase),interactionData:n}},unsafeCompletedPurchase({purchaseId:e}){let t=tu([eO.purchase.unsafeCompleted,L(e,{size:32})]);return{handlerTypeDenominator:F(eC.purchase),interactionData:t}}},tS={open:()=>({handlerTypeDenominator:F(eC.webshop),interactionData:eO.webshop.open})},tA={customerMeeting({agencyId:e}){let t=tu([eO.retail.customerMeeting,L(e,{size:32})]);return{handlerTypeDenominator:F(eC.retail),interactionData:t}}}})(),n})());
package/dist/actions.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";let __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(e,r)=>{for(var t in r)__webpack_require__.o(r,t)&&!__webpack_require__.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},__webpack_require__.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{openSso:()=>openSso,referralInteraction:()=>referralInteraction,trackPurchaseStatus:()=>trackPurchaseStatus,modalBuilder:()=>modalBuilder,processReferral:()=>processReferral,sendTransaction:()=>sendTransaction,displayModal:()=>displayModal,getProductInformation:()=>getProductInformation,displayEmbededWallet:()=>displayEmbededWallet,sendInteraction:()=>sendInteraction,siweAuthenticate:()=>siweAuthenticate,watchWalletStatus:()=>watchWalletStatus});class Deferred{_promise;_resolve;_reject;constructor(){this._promise=new Promise((e,r)=>{this._resolve=e,this._reject=r})}get promise(){return this._promise}resolve=e=>{this._resolve?.(e)};reject=e=>{this._reject?.(e)}}function watchWalletStatus(e,r){if(!r)return e.request({method:"frak_listenToWalletStatus"}).then(e=>(savePotentialToken(e.interactionToken),e));let t=new Deferred,n=!1;return e.listenerRequest({method:"frak_listenToWalletStatus"},e=>{r(e),savePotentialToken(e.interactionToken),n||(t.resolve(e),n=!0)}).then(()=>t.promise)}function savePotentialToken(e){"undefined"!=typeof window&&(e?window.sessionStorage.setItem("frak-wallet-interaction-token",e):window.sessionStorage.removeItem("frak.interaction-token"))}let external_viem_namespaceObject=require("viem");function computeProductId({domain:e}){let r=e??window.location.host;return(0,external_viem_namespaceObject.keccak256)((0,external_viem_namespaceObject.toHex)(r))}async function sendInteraction(e,{productId:r,interaction:t,validation:n}){let a=r??computeProductId(e.config);return await e.request({method:"frak_sendInteraction",params:[a,t,n]})}async function displayModal(e,{steps:r,metadata:t}){return await e.request({method:"frak_displayModal",params:[r,t,e.config.metadata]})}async function displayEmbededWallet(e,r){await e.request({method:"frak_displayEmbededWallet",params:[r,e.config.metadata]})}async function openSso(e,r){let{metadata:t,customizations:n}=e.config;await e.request({method:"frak_sso",params:[r,t.name,n?.css]})}async function getProductInformation(e){return await e.request({method:"frak_getProductInformation"})}async function trackPurchaseStatus(e){if("undefined"==typeof window){console.warn("[Frak] No window found, can't track purchase");return}let r=window.sessionStorage.getItem("frak-wallet-interaction-token");if(!r){console.warn("[Frak] No frak session found, skipping purchase check");return}await fetch("https://backend.frak.id/interactions/listenForPurchase",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json","x-wallet-sdk-auth":r},body:JSON.stringify(e)})}let siwe_namespaceObject=require("viem/siwe");async function siweAuthenticate(e,{siwe:r,metadata:t}){let n=e.config?.domain??window.location.host,a=r?.statement??`I confirm that I want to use my Frak wallet on: ${e.config.metadata.name}`,o={...r,statement:a,nonce:r?.nonce??(0,siwe_namespaceObject.generateSiweNonce)(),uri:r?.uri??`https://${n}`,version:r?.version??"1",domain:n};return(await displayModal(e,{metadata:t,steps:{login:{},siweAuthenticate:{siwe:o}}})).siweAuthenticate}async function sendTransaction(e,{tx:r,metadata:t}){return(await displayModal(e,{metadata:t,steps:{login:{},sendTransaction:{tx:r}}})).sendTransaction}function modalBuilder(e,{metadata:r,login:t,openSession:n}){return modalStepsBuilder(e,{steps:{login:t??{},openSession:n??{}},metadata:r})}function modalStepsBuilder(e,r){async function t(t){return t&&(r.metadata=t(r.metadata??{})),await displayModal(e,r)}return{params:r,sendTx:function(t){return modalStepsBuilder(e,{...r,steps:{...r.steps,sendTransaction:t}})},reward:function(t){return modalStepsBuilder(e,{...r,steps:{...r.steps,final:{...t,action:{key:"reward"}}}})},sharing:function(t,n){return modalStepsBuilder(e,{...r,steps:{...r.steps,final:{...n,action:{key:"sharing",options:t}}}})},display:t}}function base64urlEncode(e){return btoa(Array.from(e,e=>String.fromCharCode(e)).join("")).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function base64urlDecode(e){let r=e.length%4;return Uint8Array.from(atob(e.replace(/-/g,"+").replace(/_/g,"/").padEnd(e.length+(0===r?0:4-r),"=")),e=>e.charCodeAt(0))}let contextKey="fCtx";function compress(e){if(e?.r)try{let r=(0,external_viem_namespaceObject.hexToBytes)(e.r);return base64urlEncode(r)}catch(r){console.error("Error compressing Frak context",{e:r,context:e})}}function decompress(e){if(e&&0!==e.length)try{let r=base64urlDecode(e);return{r:(0,external_viem_namespaceObject.bytesToHex)(r,{size:20})}}catch(r){console.error("Error decompressing Frak context",{e:r,context:e})}}function parse({url:e}){if(!e)return null;let r=new URL(e).searchParams.get(contextKey);return r?decompress(r):null}function update({url:e,context:r}){if(!e)return null;let t=parse({url:e}),n=t?{...t,...r}:r;if(!n.r)return null;let a=compress(n);if(!a)return null;let o=new URL(e);return o.searchParams.set(contextKey,a),o.toString()}function remove(e){let r=new URL(e);return r.searchParams.delete(contextKey),r.toString()}function replaceUrl({url:e,context:r}){let t;if(!window.location?.href||"undefined"==typeof window){console.error("No window found, can't update context");return}let n=e??window.location.href;(t=null!==r?update({url:n,context:r}):remove(n))&&window.history.replaceState(null,"",t.toString())}let FrakContextManager={compress,decompress,parse,update,remove,replaceUrl},interactionTypes={press:{openArticle:"0xc0a24ffb",readArticle:"0xd5bd0fbe"},dapp:{proofVerifiableStorageUpdate:"0x2ab2aeef",callableVerifiableStorageUpdate:"0xa07da986"},webshop:{open:"0xb311798f"},referral:{referred:"0x010cc3b9",createLink:"0xb2c0f17c"},purchase:{started:"0xd87e90c3",completed:"0x8403aeb4",unsafeCompleted:"0x4d5b14e0"},retail:{customerMeeting:"0x74489004"}},productTypes={dapp:1,press:2,webshop:3,retail:4,referral:30,purchase:31},productTypesMask=Object.entries(productTypes).reduce((e,[r,t])=>(e[r]=BigInt(1)<<BigInt(t),e),{}),ReferralInteractionEncoder={createLink:()=>({handlerTypeDenominator:(0,external_viem_namespaceObject.toHex)(productTypes.referral),interactionData:interactionTypes.referral.createLink}),referred({referrer:e}){let r=(0,external_viem_namespaceObject.concatHex)([interactionTypes.referral.referred,(0,external_viem_namespaceObject.pad)(e,{size:32})]);return{handlerTypeDenominator:(0,external_viem_namespaceObject.toHex)(productTypes.referral),interactionData:r}}};class FrakRpcError extends Error{code;data;constructor(e,r,t){super(r),this.code=e,this.data=t}}class MethodNotFoundError extends FrakRpcError{constructor(e,r){super(RpcErrorCodes.methodNotFound,e,{method:r})}}class InternalError extends FrakRpcError{constructor(e){super(RpcErrorCodes.internalError,e)}}class ClientNotFound extends FrakRpcError{constructor(){super(RpcErrorCodes.clientNotConnected,"Client not found")}}let RpcErrorCodes={parseError:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internalError:-32603,serverError:-32e3,clientNotConnected:-32001,configError:-32002,corruptedResponse:-32003,clientAborted:-32004,walletNotConnected:-32005,serverErrorForInteractionDelegation:-32006};async function processReferral(e,{walletStatus:r,frakContext:t,modalConfig:n,productId:a,options:o}){let s=!1;async function c(){if(!s)return s=!0,ensureWalletConnected(e,{modalConfig:n,walletStatus:r})}async function i(r){let t=ReferralInteractionEncoder.referred({referrer:r});await sendInteraction(e,{productId:a,interaction:t})}try{let{status:e,currentWallet:n}=await processReferralLogic({initialWalletStatus:r,getFreshWalletStatus:c,pushReferralInteraction:i,frakContext:t});return FrakContextManager.replaceUrl({url:window.location?.href,context:o?.alwaysAppendUrl?{r:n}:null}),e}catch(e){return console.log("Error processing referral",{error:e}),FrakContextManager.replaceUrl({url:window.location?.href,context:o?.alwaysAppendUrl?{r:r?.wallet}:null}),mapErrorToState(e)}}async function processReferralLogic({initialWalletStatus:e,getFreshWalletStatus:r,pushReferralInteraction:t,frakContext:n}){let a=e?.wallet;return n?.r?(a||(a=await r()),a&&(0,external_viem_namespaceObject.isAddressEqual)(n.r,a))?{status:"self-referral",currentWallet:a}:(e?.interactionSession||(a=await r()),await t(n.r),{status:"success",currentWallet:a}):{status:"no-referrer",currentWallet:a}}async function ensureWalletConnected(e,{modalConfig:r,walletStatus:t}){if(!t?.interactionSession){if(!r)return;let t=await displayModal(e,r);return t?.login?.wallet??void 0}return t.wallet??void 0}function mapErrorToState(e){if(e instanceof FrakRpcError)switch(e.code){case RpcErrorCodes.walletNotConnected:return"no-wallet";case RpcErrorCodes.serverErrorForInteractionDelegation:return"no-session"}return"error"}async function referralInteraction(e,{productId:r,modalConfig:t,options:n}={}){let a=FrakContextManager.parse({url:window.location.href}),o=await watchWalletStatus(e);try{return await processReferral(e,{walletStatus:o,frakContext:a,modalConfig:t,productId:r,options:n})}catch(e){console.warn("Error processing referral",{error:e})}}var __webpack_export_target__=exports;for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__]=__webpack_exports__[__webpack_i__];__webpack_exports__.__esModule&&Object.defineProperty(__webpack_export_target__,"__esModule",{value:!0});
1
+ "use strict";let __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(e,r)=>{for(var t in r)__webpack_require__.o(r,t)&&!__webpack_require__.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},__webpack_require__.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{openSso:()=>openSso,referralInteraction:()=>referralInteraction,trackPurchaseStatus:()=>trackPurchaseStatus,modalBuilder:()=>modalBuilder,processReferral:()=>processReferral,sendTransaction:()=>sendTransaction,displayModal:()=>displayModal,getProductInformation:()=>getProductInformation,displayEmbeddedWallet:()=>displayEmbeddedWallet,sendInteraction:()=>sendInteraction,siweAuthenticate:()=>siweAuthenticate,watchWalletStatus:()=>watchWalletStatus});class Deferred{_promise;_resolve;_reject;constructor(){this._promise=new Promise((e,r)=>{this._resolve=e,this._reject=r})}get promise(){return this._promise}resolve=e=>{this._resolve?.(e)};reject=e=>{this._reject?.(e)}}function watchWalletStatus(e,r){if(!r)return e.request({method:"frak_listenToWalletStatus"}).then(e=>(savePotentialToken(e.interactionToken),e));let t=new Deferred,n=!1;return e.listenerRequest({method:"frak_listenToWalletStatus"},e=>{r(e),savePotentialToken(e.interactionToken),n||(t.resolve(e),n=!0)}).then(()=>t.promise)}function savePotentialToken(e){"undefined"!=typeof window&&(e?window.sessionStorage.setItem("frak-wallet-interaction-token",e):window.sessionStorage.removeItem("frak.interaction-token"))}let external_viem_namespaceObject=require("viem");function computeProductId({domain:e}){let r=(e??window.location.host).replace("www.","");return(0,external_viem_namespaceObject.keccak256)((0,external_viem_namespaceObject.toHex)(r))}async function sendInteraction(e,{productId:r,interaction:t,validation:n}){let a=r??computeProductId(e.config);return await e.request({method:"frak_sendInteraction",params:[a,t,n]})}async function displayModal(e,{steps:r,metadata:t}){return await e.request({method:"frak_displayModal",params:[r,t,e.config.metadata]})}async function displayEmbeddedWallet(e,r){return await e.request({method:"frak_displayEmbeddedWallet",params:[r,e.config.metadata]})}async function openSso(e,r){let{metadata:t,customizations:n}=e.config;await e.request({method:"frak_sso",params:[r,t.name,n?.css]})}async function getProductInformation(e){return await e.request({method:"frak_getProductInformation"})}async function trackPurchaseStatus(e){if("undefined"==typeof window){console.warn("[Frak] No window found, can't track purchase");return}let r=window.sessionStorage.getItem("frak-wallet-interaction-token");if(!r){console.warn("[Frak] No frak session found, skipping purchase check");return}await fetch("https://backend.frak.id/interactions/listenForPurchase",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json","x-wallet-sdk-auth":r},body:JSON.stringify(e)})}let siwe_namespaceObject=require("viem/siwe");async function siweAuthenticate(e,{siwe:r,metadata:t}){let n=e.config?.domain??window.location.host,a=r?.statement??`I confirm that I want to use my Frak wallet on: ${e.config.metadata.name}`,o={...r,statement:a,nonce:r?.nonce??(0,siwe_namespaceObject.generateSiweNonce)(),uri:r?.uri??`https://${n}`,version:r?.version??"1",domain:n};return(await displayModal(e,{metadata:t,steps:{login:{},siweAuthenticate:{siwe:o}}})).siweAuthenticate}async function sendTransaction(e,{tx:r,metadata:t}){return(await displayModal(e,{metadata:t,steps:{login:{},sendTransaction:{tx:r}}})).sendTransaction}function modalBuilder(e,{metadata:r,login:t,openSession:n}){return modalStepsBuilder(e,{steps:{login:t??{},openSession:n??{}},metadata:r})}function modalStepsBuilder(e,r){async function t(t){return t&&(r.metadata=t(r.metadata??{})),await displayModal(e,r)}return{params:r,sendTx:function(t){return modalStepsBuilder(e,{...r,steps:{...r.steps,sendTransaction:t}})},reward:function(t){return modalStepsBuilder(e,{...r,steps:{...r.steps,final:{...t,action:{key:"reward"}}}})},sharing:function(t,n){return modalStepsBuilder(e,{...r,steps:{...r.steps,final:{...n,action:{key:"sharing",options:t}}}})},display:t}}function base64urlEncode(e){return btoa(Array.from(e,e=>String.fromCharCode(e)).join("")).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function base64urlDecode(e){let r=e.length%4;return Uint8Array.from(atob(e.replace(/-/g,"+").replace(/_/g,"/").padEnd(e.length+(0===r?0:4-r),"=")),e=>e.charCodeAt(0))}let contextKey="fCtx";function compress(e){if(e?.r)try{let r=(0,external_viem_namespaceObject.hexToBytes)(e.r);return base64urlEncode(r)}catch(r){console.error("Error compressing Frak context",{e:r,context:e})}}function decompress(e){if(e&&0!==e.length)try{let r=base64urlDecode(e);return{r:(0,external_viem_namespaceObject.bytesToHex)(r,{size:20})}}catch(r){console.error("Error decompressing Frak context",{e:r,context:e})}}function parse({url:e}){if(!e)return null;let r=new URL(e).searchParams.get(contextKey);return r?decompress(r):null}function update({url:e,context:r}){if(!e)return null;let t=parse({url:e}),n=t?{...t,...r}:r;if(!n.r)return null;let a=compress(n);if(!a)return null;let o=new URL(e);return o.searchParams.set(contextKey,a),o.toString()}function remove(e){let r=new URL(e);return r.searchParams.delete(contextKey),r.toString()}function replaceUrl({url:e,context:r}){let t;if(!window.location?.href||"undefined"==typeof window){console.error("No window found, can't update context");return}let n=e??window.location.href;(t=null!==r?update({url:n,context:r}):remove(n))&&window.history.replaceState(null,"",t.toString())}let FrakContextManager={compress,decompress,parse,update,remove,replaceUrl},interactionTypes={press:{openArticle:"0xc0a24ffb",readArticle:"0xd5bd0fbe"},dapp:{proofVerifiableStorageUpdate:"0x2ab2aeef",callableVerifiableStorageUpdate:"0xa07da986"},webshop:{open:"0xb311798f"},referral:{referred:"0x010cc3b9",createLink:"0xb2c0f17c"},purchase:{started:"0xd87e90c3",completed:"0x8403aeb4",unsafeCompleted:"0x4d5b14e0"},retail:{customerMeeting:"0x74489004"}},productTypes={dapp:1,press:2,webshop:3,retail:4,referral:30,purchase:31},productTypesMask=Object.entries(productTypes).reduce((e,[r,t])=>(e[r]=BigInt(1)<<BigInt(t),e),{}),ReferralInteractionEncoder={createLink:()=>({handlerTypeDenominator:(0,external_viem_namespaceObject.toHex)(productTypes.referral),interactionData:interactionTypes.referral.createLink}),referred({referrer:e}){let r=(0,external_viem_namespaceObject.concatHex)([interactionTypes.referral.referred,(0,external_viem_namespaceObject.pad)(e,{size:32})]);return{handlerTypeDenominator:(0,external_viem_namespaceObject.toHex)(productTypes.referral),interactionData:r}}};class FrakRpcError extends Error{code;data;constructor(e,r,t){super(r),this.code=e,this.data=t}}class MethodNotFoundError extends FrakRpcError{constructor(e,r){super(RpcErrorCodes.methodNotFound,e,{method:r})}}class InternalError extends FrakRpcError{constructor(e){super(RpcErrorCodes.internalError,e)}}class ClientNotFound extends FrakRpcError{constructor(){super(RpcErrorCodes.clientNotConnected,"Client not found")}}let RpcErrorCodes={parseError:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internalError:-32603,serverError:-32e3,clientNotConnected:-32001,configError:-32002,corruptedResponse:-32003,clientAborted:-32004,walletNotConnected:-32005,serverErrorForInteractionDelegation:-32006};async function processReferral(e,{walletStatus:r,frakContext:t,modalConfig:n,productId:a,options:o}){let s=!1;async function c(){if(!s)return s=!0,ensureWalletConnected(e,{modalConfig:{...n,loggedIn:{action:{key:"referred"}}},walletStatus:r})}async function i(r){let t=ReferralInteractionEncoder.referred({referrer:r});await sendInteraction(e,{productId:a,interaction:t})}try{let{status:e,currentWallet:n}=await processReferralLogic({initialWalletStatus:r,getFreshWalletStatus:c,pushReferralInteraction:i,frakContext:t});return FrakContextManager.replaceUrl({url:window.location?.href,context:o?.alwaysAppendUrl?{r:n}:null}),e}catch(e){return console.log("Error processing referral",{error:e}),FrakContextManager.replaceUrl({url:window.location?.href,context:o?.alwaysAppendUrl?{r:r?.wallet}:null}),mapErrorToState(e)}}async function processReferralLogic({initialWalletStatus:e,getFreshWalletStatus:r,pushReferralInteraction:t,frakContext:n}){let a=e?.wallet;return n?.r?(a||(a=await r()),a&&(0,external_viem_namespaceObject.isAddressEqual)(n.r,a))?{status:"self-referral",currentWallet:a}:(e?.interactionSession||(a=await r()),await t(n.r),{status:"success",currentWallet:a}):{status:"no-referrer",currentWallet:a}}async function ensureWalletConnected(e,{modalConfig:r,walletStatus:t}){if(!t?.interactionSession){let t=await displayEmbeddedWallet(e,r??{});return t?.wallet??void 0}return t.wallet??void 0}function mapErrorToState(e){if(e instanceof FrakRpcError)switch(e.code){case RpcErrorCodes.walletNotConnected:return"no-wallet";case RpcErrorCodes.serverErrorForInteractionDelegation:return"no-session"}return"error"}async function referralInteraction(e,{productId:r,modalConfig:t,options:n}={}){let a=FrakContextManager.parse({url:window.location.href}),o=await watchWalletStatus(e);try{return await processReferral(e,{walletStatus:o,frakContext:a,modalConfig:t,productId:r,options:n})}catch(e){console.warn("Error processing referral",{error:e})}}var __webpack_export_target__=exports;for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__]=__webpack_exports__[__webpack_i__];__webpack_exports__.__esModule&&Object.defineProperty(__webpack_export_target__,"__esModule",{value:!0});
@@ -11,26 +11,26 @@ import type { SiweMessage } from 'viem/siwe';
11
11
  declare type Currency = "eur" | "usd" | "gbp";
12
12
 
13
13
  /**
14
- * Function used to display the Frak embeded wallet popup
14
+ * Function used to display the Frak embedded wallet popup
15
15
  * @param client - The current Frak Client
16
- * @param params - The parameter used to customise the embeded wallet
16
+ * @param params - The parameter used to customise the embedded wallet
17
17
  */
18
- export declare function displayEmbededWallet(client: FrakClient, params: DisplayEmbededWalletParamsType): Promise<void>;
18
+ export declare function displayEmbeddedWallet(client: FrakClient, params: DisplayEmbeddedWalletParamsType): Promise<DisplayEmbeddedWalletResultType>;
19
19
 
20
20
  /**
21
21
  * The params used to display the embedded wallet
22
22
  *
23
23
  * @group Embedded wallet
24
24
  */
25
- declare type DisplayEmbededWalletParamsType = {
25
+ declare type DisplayEmbeddedWalletParamsType = {
26
26
  /**
27
27
  * The embedded view to display once the user is logged in
28
28
  */
29
- loggedIn?: LoggedInEmbededView;
29
+ loggedIn?: LoggedInEmbeddedView;
30
30
  /**
31
31
  * The embedded view to display once the user is logged out
32
32
  */
33
- loggedOut?: LoggedOutEmbededView;
33
+ loggedOut?: LoggedOutEmbeddedView;
34
34
  /**
35
35
  * Some metadata to customize the embedded view
36
36
  */
@@ -60,6 +60,15 @@ declare type DisplayEmbededWalletParamsType = {
60
60
  };
61
61
  };
62
62
 
63
+ /**
64
+ * The result of the display embedded wallet rpc request
65
+ *
66
+ * @group Embedded wallet
67
+ */
68
+ declare type DisplayEmbeddedWalletResultType = {
69
+ wallet: Address;
70
+ };
71
+
63
72
  /**
64
73
  * Function used to display a modal
65
74
  * @param client - The current Frak Client
@@ -185,12 +194,25 @@ declare type DisplayModalParamsType<T extends ModalStepTypes[]> = {
185
194
  metadata?: ModalRpcMetadata;
186
195
  };
187
196
 
197
+ /**
198
+ * The action to display on the logged out embedded view when the user is referred
199
+ *
200
+ * @group Embedded wallet
201
+ */
202
+ declare type EmbeddedViewActionReferred = {
203
+ key: "referred";
204
+ /**
205
+ * No options for a referred action
206
+ */
207
+ options?: never;
208
+ };
209
+
188
210
  /**
189
211
  * The different type of action we can have on the embedded view (once the user is logged in)
190
212
  *
191
213
  * @group Embedded wallet
192
214
  */
193
- declare type EmbededViewAction = {
215
+ declare type EmbeddedViewActionSharing = {
194
216
  key: "sharing";
195
217
  /**
196
218
  * Some sharing options
@@ -493,9 +515,9 @@ declare type I18nConfig = Record<Language, LocalizedI18nConfig> | LocalizedI18nC
493
515
  * - Params: None
494
516
  * - Returns: {@link GetProductInformationReturnType}
495
517
  *
496
- * ### frak_displayEmbededWallet
497
- * - Params: [{@link DisplayEmbededWalletParamsType}]
498
- * - Returns: undefined
518
+ * ### frak_displayEmbeddedWallet
519
+ * - Params: [{@link DisplayEmbeddedWalletParamsType}]
520
+ * - Returns: {@link DisplayEmbeddedWalletResultType}
499
521
  */
500
522
  declare type IFrameRpcSchema = [
501
523
  /**
@@ -558,12 +580,12 @@ declare type IFrameRpcSchema = [
558
580
  * Method to show the embedded wallet, with potential customization
559
581
  */
560
582
  {
561
- Method: "frak_displayEmbededWallet";
583
+ Method: "frak_displayEmbeddedWallet";
562
584
  Parameters: [
563
- request: DisplayEmbededWalletParamsType,
585
+ request: DisplayEmbeddedWalletParamsType,
564
586
  metadata: FrakWalletSdkConfig["metadata"]
565
587
  ];
566
- ReturnType: undefined;
588
+ ReturnType: DisplayEmbeddedWalletResultType;
567
589
  }
568
590
  ];
569
591
 
@@ -647,19 +669,18 @@ declare type LocalizedI18nConfig = `${string}.css` | {
647
669
  *
648
670
  * @group Embedded wallet
649
671
  */
650
- declare type LoggedInEmbededView = {
672
+ declare type LoggedInEmbeddedView = {
651
673
  /**
652
674
  * The main action to display on the logged in embedded view
653
- * If none specified, the user will see his wallet with the activation button
654
675
  */
655
- action?: EmbededViewAction;
676
+ action?: EmbeddedViewActionSharing | EmbeddedViewActionReferred;
656
677
  };
657
678
 
658
679
  /**
659
680
  * The view when a user is logged out
660
681
  * @group Embedded wallet
661
682
  */
662
- declare type LoggedOutEmbededView = {
683
+ declare type LoggedOutEmbeddedView = {
663
684
  /**
664
685
  * Metadata option when displaying the embedded view
665
686
  */
@@ -999,7 +1020,7 @@ declare type PreparedInteraction = {
999
1020
  export declare function processReferral(client: FrakClient, { walletStatus, frakContext, modalConfig, productId, options, }: {
1000
1021
  walletStatus?: WalletStatusReturnType;
1001
1022
  frakContext?: Partial<FrakContext> | null;
1002
- modalConfig?: DisplayModalParamsType<ModalStepTypes[]>;
1023
+ modalConfig?: DisplayEmbeddedWalletParamsType;
1003
1024
  productId?: Hex;
1004
1025
  options?: ProcessReferralOptions;
1005
1026
  }): Promise<ReferralState>;
@@ -1050,7 +1071,7 @@ declare type ProductTypesKey = keyof typeof productTypes;
1050
1071
  */
1051
1072
  export declare function referralInteraction(client: FrakClient, { productId, modalConfig, options, }?: {
1052
1073
  productId?: Hex;
1053
- modalConfig?: DisplayModalParamsType<ModalStepTypes[]>;
1074
+ modalConfig?: DisplayEmbeddedWalletParamsType;
1054
1075
  options?: ProcessReferralOptions;
1055
1076
  }): Promise<("error" | "idle" | "processing" | "success" | "no-wallet" | "no-session" | "no-referrer" | "self-referral") | undefined>;
1056
1077
 
package/dist/actions.d.ts CHANGED
@@ -11,26 +11,26 @@ import type { SiweMessage } from 'viem/siwe';
11
11
  declare type Currency = "eur" | "usd" | "gbp";
12
12
 
13
13
  /**
14
- * Function used to display the Frak embeded wallet popup
14
+ * Function used to display the Frak embedded wallet popup
15
15
  * @param client - The current Frak Client
16
- * @param params - The parameter used to customise the embeded wallet
16
+ * @param params - The parameter used to customise the embedded wallet
17
17
  */
18
- export declare function displayEmbededWallet(client: FrakClient, params: DisplayEmbededWalletParamsType): Promise<void>;
18
+ export declare function displayEmbeddedWallet(client: FrakClient, params: DisplayEmbeddedWalletParamsType): Promise<DisplayEmbeddedWalletResultType>;
19
19
 
20
20
  /**
21
21
  * The params used to display the embedded wallet
22
22
  *
23
23
  * @group Embedded wallet
24
24
  */
25
- declare type DisplayEmbededWalletParamsType = {
25
+ declare type DisplayEmbeddedWalletParamsType = {
26
26
  /**
27
27
  * The embedded view to display once the user is logged in
28
28
  */
29
- loggedIn?: LoggedInEmbededView;
29
+ loggedIn?: LoggedInEmbeddedView;
30
30
  /**
31
31
  * The embedded view to display once the user is logged out
32
32
  */
33
- loggedOut?: LoggedOutEmbededView;
33
+ loggedOut?: LoggedOutEmbeddedView;
34
34
  /**
35
35
  * Some metadata to customize the embedded view
36
36
  */
@@ -60,6 +60,15 @@ declare type DisplayEmbededWalletParamsType = {
60
60
  };
61
61
  };
62
62
 
63
+ /**
64
+ * The result of the display embedded wallet rpc request
65
+ *
66
+ * @group Embedded wallet
67
+ */
68
+ declare type DisplayEmbeddedWalletResultType = {
69
+ wallet: Address;
70
+ };
71
+
63
72
  /**
64
73
  * Function used to display a modal
65
74
  * @param client - The current Frak Client
@@ -185,12 +194,25 @@ declare type DisplayModalParamsType<T extends ModalStepTypes[]> = {
185
194
  metadata?: ModalRpcMetadata;
186
195
  };
187
196
 
197
+ /**
198
+ * The action to display on the logged out embedded view when the user is referred
199
+ *
200
+ * @group Embedded wallet
201
+ */
202
+ declare type EmbeddedViewActionReferred = {
203
+ key: "referred";
204
+ /**
205
+ * No options for a referred action
206
+ */
207
+ options?: never;
208
+ };
209
+
188
210
  /**
189
211
  * The different type of action we can have on the embedded view (once the user is logged in)
190
212
  *
191
213
  * @group Embedded wallet
192
214
  */
193
- declare type EmbededViewAction = {
215
+ declare type EmbeddedViewActionSharing = {
194
216
  key: "sharing";
195
217
  /**
196
218
  * Some sharing options
@@ -493,9 +515,9 @@ declare type I18nConfig = Record<Language, LocalizedI18nConfig> | LocalizedI18nC
493
515
  * - Params: None
494
516
  * - Returns: {@link GetProductInformationReturnType}
495
517
  *
496
- * ### frak_displayEmbededWallet
497
- * - Params: [{@link DisplayEmbededWalletParamsType}]
498
- * - Returns: undefined
518
+ * ### frak_displayEmbeddedWallet
519
+ * - Params: [{@link DisplayEmbeddedWalletParamsType}]
520
+ * - Returns: {@link DisplayEmbeddedWalletResultType}
499
521
  */
500
522
  declare type IFrameRpcSchema = [
501
523
  /**
@@ -558,12 +580,12 @@ declare type IFrameRpcSchema = [
558
580
  * Method to show the embedded wallet, with potential customization
559
581
  */
560
582
  {
561
- Method: "frak_displayEmbededWallet";
583
+ Method: "frak_displayEmbeddedWallet";
562
584
  Parameters: [
563
- request: DisplayEmbededWalletParamsType,
585
+ request: DisplayEmbeddedWalletParamsType,
564
586
  metadata: FrakWalletSdkConfig["metadata"]
565
587
  ];
566
- ReturnType: undefined;
588
+ ReturnType: DisplayEmbeddedWalletResultType;
567
589
  }
568
590
  ];
569
591
 
@@ -647,19 +669,18 @@ declare type LocalizedI18nConfig = `${string}.css` | {
647
669
  *
648
670
  * @group Embedded wallet
649
671
  */
650
- declare type LoggedInEmbededView = {
672
+ declare type LoggedInEmbeddedView = {
651
673
  /**
652
674
  * The main action to display on the logged in embedded view
653
- * If none specified, the user will see his wallet with the activation button
654
675
  */
655
- action?: EmbededViewAction;
676
+ action?: EmbeddedViewActionSharing | EmbeddedViewActionReferred;
656
677
  };
657
678
 
658
679
  /**
659
680
  * The view when a user is logged out
660
681
  * @group Embedded wallet
661
682
  */
662
- declare type LoggedOutEmbededView = {
683
+ declare type LoggedOutEmbeddedView = {
663
684
  /**
664
685
  * Metadata option when displaying the embedded view
665
686
  */
@@ -999,7 +1020,7 @@ declare type PreparedInteraction = {
999
1020
  export declare function processReferral(client: FrakClient, { walletStatus, frakContext, modalConfig, productId, options, }: {
1000
1021
  walletStatus?: WalletStatusReturnType;
1001
1022
  frakContext?: Partial<FrakContext> | null;
1002
- modalConfig?: DisplayModalParamsType<ModalStepTypes[]>;
1023
+ modalConfig?: DisplayEmbeddedWalletParamsType;
1003
1024
  productId?: Hex;
1004
1025
  options?: ProcessReferralOptions;
1005
1026
  }): Promise<ReferralState>;
@@ -1050,7 +1071,7 @@ declare type ProductTypesKey = keyof typeof productTypes;
1050
1071
  */
1051
1072
  export declare function referralInteraction(client: FrakClient, { productId, modalConfig, options, }?: {
1052
1073
  productId?: Hex;
1053
- modalConfig?: DisplayModalParamsType<ModalStepTypes[]>;
1074
+ modalConfig?: DisplayEmbeddedWalletParamsType;
1054
1075
  options?: ProcessReferralOptions;
1055
1076
  }): Promise<("error" | "idle" | "processing" | "success" | "no-wallet" | "no-session" | "no-referrer" | "self-referral") | undefined>;
1056
1077
 
package/dist/actions.js CHANGED
@@ -1 +1 @@
1
- import*as e from"viem";import*as t from"viem/siwe";class n{_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 r(e,t){if(!t)return e.request({method:"frak_listenToWalletStatus"}).then(e=>(a(e.interactionToken),e));let r=new n,o=!1;return e.listenerRequest({method:"frak_listenToWalletStatus"},e=>{t(e),a(e.interactionToken),o||(r.resolve(e),o=!0)}).then(()=>r.promise)}function a(e){"undefined"!=typeof window&&(e?window.sessionStorage.setItem("frak-wallet-interaction-token",e):window.sessionStorage.removeItem("frak.interaction-token"))}async function o(t,{productId:n,interaction:r,validation:a}){let o=n??function({domain:t}){let n=t??window.location.host;return(0,e.keccak256)((0,e.toHex)(n))}(t.config);return await t.request({method:"frak_sendInteraction",params:[o,r,a]})}async function i(e,{steps:t,metadata:n}){return await e.request({method:"frak_displayModal",params:[t,n,e.config.metadata]})}async function s(e,t){await e.request({method:"frak_displayEmbededWallet",params:[t,e.config.metadata]})}async function c(e,t){let{metadata:n,customizations:r}=e.config;await e.request({method:"frak_sso",params:[t,n.name,r?.css]})}async function l(e){return await e.request({method:"frak_getProductInformation"})}async function u(e){if("undefined"==typeof window){console.warn("[Frak] No window found, can't track purchase");return}let t=window.sessionStorage.getItem("frak-wallet-interaction-token");if(!t){console.warn("[Frak] No frak session found, skipping purchase check");return}await fetch("https://backend.frak.id/interactions/listenForPurchase",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json","x-wallet-sdk-auth":t},body:JSON.stringify(e)})}async function f(e,{siwe:n,metadata:r}){let a=e.config?.domain??window.location.host,o=n?.statement??`I confirm that I want to use my Frak wallet on: ${e.config.metadata.name}`,s={...n,statement:o,nonce:n?.nonce??(0,t.generateSiweNonce)(),uri:n?.uri??`https://${a}`,version:n?.version??"1",domain:a};return(await i(e,{metadata:r,steps:{login:{},siweAuthenticate:{siwe:s}}})).siweAuthenticate}async function d(e,{tx:t,metadata:n}){return(await i(e,{metadata:n,steps:{login:{},sendTransaction:{tx:t}}})).sendTransaction}function w(e,{metadata:t,login:n,openSession:r}){return function e(t,n){async function r(e){return e&&(n.metadata=e(n.metadata??{})),await i(t,n)}return{params:n,sendTx:function(r){return e(t,{...n,steps:{...n.steps,sendTransaction:r}})},reward:function(r){return e(t,{...n,steps:{...n.steps,final:{...r,action:{key:"reward"}}}})},sharing:function(r,a){return e(t,{...n,steps:{...n.steps,final:{...a,action:{key:"sharing",options:r}}}})},display:r}}(e,{steps:{login:n??{},openSession:r??{}},metadata:t})}let p="fCtx";function h({url:t}){if(!t)return null;let n=new URL(t).searchParams.get(p);return n?function(t){if(t&&0!==t.length)try{let n=function(e){let t=e.length%4;return Uint8Array.from(atob(e.replace(/-/g,"+").replace(/_/g,"/").padEnd(e.length+(0===t?0:4-t),"=")),e=>e.charCodeAt(0))}(t);return{r:(0,e.bytesToHex)(n,{size:20})}}catch(e){console.error("Error decompressing Frak context",{e,context:t})}}(n):null}let m={parse:h,replaceUrl:function({url:t,context:n}){let r;if(!window.location?.href||"undefined"==typeof window){console.error("No window found, can't update context");return}let a=t??window.location.href;(r=null!==n?function({url:t,context:n}){if(!t)return null;let r=h({url:t}),a=r?{...r,...n}:n;if(!a.r)return null;let o=function(t){if(t?.r)try{var n;return n=(0,e.hexToBytes)(t.r),btoa(Array.from(n,e=>String.fromCharCode(e)).join("")).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}catch(e){console.error("Error compressing Frak context",{e,context:t})}}(a);if(!o)return null;let i=new URL(t);return i.searchParams.set(p,o),i.toString()}({url:a,context:n}):function(e){let t=new URL(e);return t.searchParams.delete(p),t.toString()}(a))&&window.history.replaceState(null,"",r.toString())}},g="0x010cc3b9",y="0xb2c0f17c",k={dapp:1,press:2,webshop:3,retail:4,referral:30,purchase:31};Object.entries(k).reduce((e,[t,n])=>(e[t]=BigInt(1)<<BigInt(n),e),{});let S={createLink:()=>({handlerTypeDenominator:(0,e.toHex)(k.referral),interactionData:y}),referred({referrer:t}){let n=(0,e.concatHex)([g,(0,e.pad)(t,{size:32})]);return{handlerTypeDenominator:(0,e.toHex)(k.referral),interactionData:n}}};class x extends Error{code;data;constructor(e,t,n){super(t),this.code=e,this.data=n}}let _={walletNotConnected:-32005,serverErrorForInteractionDelegation:-32006};async function v(e,{walletStatus:t,frakContext:n,modalConfig:r,productId:a,options:i}){let s=!1;async function c(){if(!s)return s=!0,I(e,{modalConfig:r,walletStatus:t})}async function l(t){let n=S.referred({referrer:t});await o(e,{productId:a,interaction:n})}try{let{status:e,currentWallet:r}=await T({initialWalletStatus:t,getFreshWalletStatus:c,pushReferralInteraction:l,frakContext:n});return m.replaceUrl({url:window.location?.href,context:i?.alwaysAppendUrl?{r:r}:null}),e}catch(e){return console.log("Error processing referral",{error:e}),m.replaceUrl({url:window.location?.href,context:i?.alwaysAppendUrl?{r:t?.wallet}:null}),function(e){if(e instanceof x)switch(e.code){case _.walletNotConnected:return"no-wallet";case _.serverErrorForInteractionDelegation:return"no-session"}return"error"}(e)}}async function T({initialWalletStatus:t,getFreshWalletStatus:n,pushReferralInteraction:r,frakContext:a}){let o=t?.wallet;return a?.r?(o||(o=await n()),o&&(0,e.isAddressEqual)(a.r,o))?{status:"self-referral",currentWallet:o}:(t?.interactionSession||(o=await n()),await r(a.r),{status:"success",currentWallet:o}):{status:"no-referrer",currentWallet:o}}async function I(e,{modalConfig:t,walletStatus:n}){if(!n?.interactionSession){if(!t)return;let n=await i(e,t);return n?.login?.wallet??void 0}return n.wallet??void 0}async function b(e,{productId:t,modalConfig:n,options:a}={}){let o=m.parse({url:window.location.href}),i=await r(e);try{return await v(e,{walletStatus:i,frakContext:o,modalConfig:n,productId:t,options:a})}catch(e){console.warn("Error processing referral",{error:e})}}export{s as displayEmbededWallet,i as displayModal,l as getProductInformation,w as modalBuilder,c as openSso,v as processReferral,b as referralInteraction,o as sendInteraction,d as sendTransaction,f as siweAuthenticate,u as trackPurchaseStatus,r as watchWalletStatus};
1
+ import*as e from"viem";import*as t from"viem/siwe";class n{_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 r(e,t){if(!t)return e.request({method:"frak_listenToWalletStatus"}).then(e=>(a(e.interactionToken),e));let r=new n,o=!1;return e.listenerRequest({method:"frak_listenToWalletStatus"},e=>{t(e),a(e.interactionToken),o||(r.resolve(e),o=!0)}).then(()=>r.promise)}function a(e){"undefined"!=typeof window&&(e?window.sessionStorage.setItem("frak-wallet-interaction-token",e):window.sessionStorage.removeItem("frak.interaction-token"))}async function o(t,{productId:n,interaction:r,validation:a}){let o=n??function({domain:t}){let n=(t??window.location.host).replace("www.","");return(0,e.keccak256)((0,e.toHex)(n))}(t.config);return await t.request({method:"frak_sendInteraction",params:[o,r,a]})}async function i(e,{steps:t,metadata:n}){return await e.request({method:"frak_displayModal",params:[t,n,e.config.metadata]})}async function s(e,t){return await e.request({method:"frak_displayEmbeddedWallet",params:[t,e.config.metadata]})}async function c(e,t){let{metadata:n,customizations:r}=e.config;await e.request({method:"frak_sso",params:[t,n.name,r?.css]})}async function l(e){return await e.request({method:"frak_getProductInformation"})}async function u(e){if("undefined"==typeof window){console.warn("[Frak] No window found, can't track purchase");return}let t=window.sessionStorage.getItem("frak-wallet-interaction-token");if(!t){console.warn("[Frak] No frak session found, skipping purchase check");return}await fetch("https://backend.frak.id/interactions/listenForPurchase",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json","x-wallet-sdk-auth":t},body:JSON.stringify(e)})}async function f(e,{siwe:n,metadata:r}){let a=e.config?.domain??window.location.host,o=n?.statement??`I confirm that I want to use my Frak wallet on: ${e.config.metadata.name}`,s={...n,statement:o,nonce:n?.nonce??(0,t.generateSiweNonce)(),uri:n?.uri??`https://${a}`,version:n?.version??"1",domain:a};return(await i(e,{metadata:r,steps:{login:{},siweAuthenticate:{siwe:s}}})).siweAuthenticate}async function d(e,{tx:t,metadata:n}){return(await i(e,{metadata:n,steps:{login:{},sendTransaction:{tx:t}}})).sendTransaction}function w(e,{metadata:t,login:n,openSession:r}){return function e(t,n){async function r(e){return e&&(n.metadata=e(n.metadata??{})),await i(t,n)}return{params:n,sendTx:function(r){return e(t,{...n,steps:{...n.steps,sendTransaction:r}})},reward:function(r){return e(t,{...n,steps:{...n.steps,final:{...r,action:{key:"reward"}}}})},sharing:function(r,a){return e(t,{...n,steps:{...n.steps,final:{...a,action:{key:"sharing",options:r}}}})},display:r}}(e,{steps:{login:n??{},openSession:r??{}},metadata:t})}let p="fCtx";function h({url:t}){if(!t)return null;let n=new URL(t).searchParams.get(p);return n?function(t){if(t&&0!==t.length)try{let n=function(e){let t=e.length%4;return Uint8Array.from(atob(e.replace(/-/g,"+").replace(/_/g,"/").padEnd(e.length+(0===t?0:4-t),"=")),e=>e.charCodeAt(0))}(t);return{r:(0,e.bytesToHex)(n,{size:20})}}catch(e){console.error("Error decompressing Frak context",{e,context:t})}}(n):null}let m={parse:h,replaceUrl:function({url:t,context:n}){let r;if(!window.location?.href||"undefined"==typeof window){console.error("No window found, can't update context");return}let a=t??window.location.href;(r=null!==n?function({url:t,context:n}){if(!t)return null;let r=h({url:t}),a=r?{...r,...n}:n;if(!a.r)return null;let o=function(t){if(t?.r)try{var n;return n=(0,e.hexToBytes)(t.r),btoa(Array.from(n,e=>String.fromCharCode(e)).join("")).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}catch(e){console.error("Error compressing Frak context",{e,context:t})}}(a);if(!o)return null;let i=new URL(t);return i.searchParams.set(p,o),i.toString()}({url:a,context:n}):function(e){let t=new URL(e);return t.searchParams.delete(p),t.toString()}(a))&&window.history.replaceState(null,"",r.toString())}},g="0x010cc3b9",y="0xb2c0f17c",k={dapp:1,press:2,webshop:3,retail:4,referral:30,purchase:31};Object.entries(k).reduce((e,[t,n])=>(e[t]=BigInt(1)<<BigInt(n),e),{});let S={createLink:()=>({handlerTypeDenominator:(0,e.toHex)(k.referral),interactionData:y}),referred({referrer:t}){let n=(0,e.concatHex)([g,(0,e.pad)(t,{size:32})]);return{handlerTypeDenominator:(0,e.toHex)(k.referral),interactionData:n}}};class x extends Error{code;data;constructor(e,t,n){super(t),this.code=e,this.data=n}}let _={walletNotConnected:-32005,serverErrorForInteractionDelegation:-32006};async function v(e,{walletStatus:t,frakContext:n,modalConfig:r,productId:a,options:i}){let s=!1;async function c(){if(!s)return s=!0,T(e,{modalConfig:{...r,loggedIn:{action:{key:"referred"}}},walletStatus:t})}async function l(t){let n=S.referred({referrer:t});await o(e,{productId:a,interaction:n})}try{let{status:e,currentWallet:r}=await I({initialWalletStatus:t,getFreshWalletStatus:c,pushReferralInteraction:l,frakContext:n});return m.replaceUrl({url:window.location?.href,context:i?.alwaysAppendUrl?{r:r}:null}),e}catch(e){return console.log("Error processing referral",{error:e}),m.replaceUrl({url:window.location?.href,context:i?.alwaysAppendUrl?{r:t?.wallet}:null}),function(e){if(e instanceof x)switch(e.code){case _.walletNotConnected:return"no-wallet";case _.serverErrorForInteractionDelegation:return"no-session"}return"error"}(e)}}async function I({initialWalletStatus:t,getFreshWalletStatus:n,pushReferralInteraction:r,frakContext:a}){let o=t?.wallet;return a?.r?(o||(o=await n()),o&&(0,e.isAddressEqual)(a.r,o))?{status:"self-referral",currentWallet:o}:(t?.interactionSession||(o=await n()),await r(a.r),{status:"success",currentWallet:o}):{status:"no-referrer",currentWallet:o}}async function T(e,{modalConfig:t,walletStatus:n}){if(!n?.interactionSession){let n=await s(e,t??{});return n?.wallet??void 0}return n.wallet??void 0}async function b(e,{productId:t,modalConfig:n,options:a}={}){let o=m.parse({url:window.location.href}),i=await r(e);try{return await v(e,{walletStatus:i,frakContext:o,modalConfig:n,productId:t,options:a})}catch(e){console.warn("Error processing referral",{error:e})}}export{s as displayEmbeddedWallet,i as displayModal,l as getProductInformation,w as modalBuilder,c as openSso,v as processReferral,b as referralInteraction,o as sendInteraction,d as sendTransaction,f as siweAuthenticate,u as trackPurchaseStatus,r as watchWalletStatus};
package/dist/index.cjs CHANGED
@@ -10,4 +10,4 @@
10
10
  Last Response: ${r.lastResponse}
11
11
  Client Status: ${r.clientStatus}
12
12
  Error: ${r.error}
13
- `.trim()}}function createIFrameChannelManager(){let e=new Map;return{createChannel:r=>{let t=Math.random().toString(36).substring(7);return e.set(t,r),t},getRpcResolver:r=>e.get(r),removeChannel:r=>e.delete(r),destroy:()=>e.clear()}}let baseIframeProps={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"}};function createIframe({walletBaseUrl:e,config:r}){let t=document.querySelector("#frak-wallet");t&&t.remove();let n=document.createElement("iframe");return n.id=baseIframeProps.id,n.name=baseIframeProps.name,n.allow=baseIframeProps.allow,n.style.zIndex=baseIframeProps.style.zIndex.toString(),changeIframeVisibility({iframe:n,isVisible:!1}),document.body.appendChild(n),new Promise(t=>{n?.addEventListener("load",()=>t(n)),n.src=`${r?.walletUrl??e??"https://wallet.frak.id"}/listener`})}function changeIframeVisibility({iframe:e,isVisible:r}){if(!r){e.style.width="0",e.style.height="0",e.style.border="0",e.style.position="fixed",e.style.top="-1000px",e.style.left="-1000px";return}e.style.position="fixed",e.style.top="0",e.style.left="0",e.style.width="100%",e.style.height="100%",e.style.pointerEvents="auto"}function createIFrameLifecycleManager({iframe:e}){let r=new Deferred;return{handleEvent:async t=>{switch(t.iframeLifecycle){case"connected":r.resolve(!0);break;case"do-backup":t.data.backup?localStorage.setItem(BACKUP_KEY,t.data.backup):localStorage.removeItem(BACKUP_KEY);break;case"remove-backup":localStorage.removeItem(BACKUP_KEY);break;case"show":case"hide":changeIframeVisibility({iframe:e,isVisible:"show"===t.iframeLifecycle});break;case"handshake":e.contentWindow?.postMessage({clientLifecycle:"handshake-response",data:{token:t.data.token,currentUrl:window.location.href}},"*")}},isConnected:r.promise}}function createIFrameMessageHandler({frakWalletUrl:e,iframe:r,channelManager:t,iframeLifecycleManager:n,debugInfo:o}){if("undefined"==typeof window)throw new FrakRpcError(RpcErrorCodes.configError,"iframe client should be used in the browser");if(!r.contentWindow)throw new FrakRpcError(RpcErrorCodes.configError,"The iframe does not have a product window");let a=r.contentWindow;async function s(r){if(!r.origin)return;try{if(new URL(r.origin).origin.toLowerCase()!==new URL(e).origin.toLowerCase())return}catch(e){console.log("Unable to check frak msg origin",e);return}if("object"!=typeof r.data)return;if(o.setLastResponse(r),"iframeLifecycle"in r.data){await n.handleEvent(r.data);return}if("clientLifecycle"in r.data){console.error("Client lifecycle event received on the client side, dismissing it");return}let a=r.data.id,s=t.getRpcResolver(a);s&&s(r.data)}return window.addEventListener("message",s),{sendEvent:function(r){a.postMessage(r,{targetOrigin:e}),o.setLastRequest(r,e)},cleanup:function(){window.removeEventListener("message",s)}}}function createIFrameFrakClient({config:e,iframe:r}){let t=createIFrameChannelManager(),n=createIFrameLifecycleManager({iframe:r}),o=new DebugInfoGatherer(e,r),a=createIFrameMessageHandler({frakWalletUrl:e?.walletUrl??"https://wallet.frak.id",iframe:r,channelManager:t,iframeLifecycleManager:n,debugInfo:o}),s=async e=>{if(!await n.isConnected)throw new FrakRpcError(RpcErrorCodes.clientNotConnected,"The iframe provider isn't connected yet");let r=new Deferred,o=t.createChannel(e=>{let n=decompressDataAndCheckHash(e.data);n.error?r.reject(new FrakRpcError(n.error.code,n.error.message,n.error?.data)):r.resolve(n.result),t.removeChannel(o)}),s=hashAndCompressData(e);return a.sendEvent({id:o,topic:e.method,data:s}),r.promise},c=async(e,r)=>{if(!await n.isConnected)throw new FrakRpcError(RpcErrorCodes.clientNotConnected,"The iframe provider isn't connected yet");let o=t.createChannel(e=>{let t=decompressDataAndCheckHash(e.data);if(t.result)r(t.result);else throw new InternalError("No valid result in the response")}),s=hashAndCompressData(e);a.sendEvent({id:o,topic:e.method,data:s})},i=setupHeartbeat(a,n),l=async()=>{i(),t.destroy(),a.cleanup(),r.remove()},d=postConnectionSetup({config:e,messageHandler:a,lifecycleManager:n}).then(()=>o.updateSetupStatus(!0));return{config:e,debugInfo:o,waitForConnection:n.isConnected,waitForSetup:d,request:s,listenerRequest:c,destroy:l}}function setupHeartbeat(e,r){let t,n;let o=()=>e.sendEvent({clientLifecycle:"heartbeat"});function a(){t&&clearInterval(t),n&&clearTimeout(n)}return async function(){o(),t=setInterval(o,100),n=setTimeout(()=>{a(),console.log("Heartbeat timeout: connection failed")},3e4),await r.isConnected,a()}(),a}async function postConnectionSetup({config:e,messageHandler:r,lifecycleManager:t}){async function n(){let t=e.customizations?.css;t&&r.sendEvent({clientLifecycle:"modal-css",data:{cssLink:t}})}async function o(){let t=e.customizations?.i18n;t&&r.sendEvent({clientLifecycle:"modal-i18n",data:{i18n:t}})}async function a(){if("undefined"==typeof window)return;let e=window.localStorage.getItem(BACKUP_KEY);e&&r.sendEvent({clientLifecycle:"restore-backup",data:{backup:e}})}await t.isConnected,await Promise.all([n(),o(),a()])}let locales={eur:"fr-FR",usd:"en-US",gbp:"en-GB"};function getSupportedCurrency(e){return e&&e in locales?e:"eur"}async function setupClient({config:e}){let r=prepareConfig(e),t=await createIframe({config:r});if(!t){console.error("Failed to create iframe");return}let n=createIFrameFrakClient({config:r,iframe:t});if(await n.waitForSetup,!await n.waitForConnection){console.error("Failed to connect to client");return}return n}function prepareConfig(e){let r=getSupportedCurrency(e.metadata?.currency);return{...e,metadata:{...e.metadata,currency:r}}}function getSupportedLocale(e){return e?locales[e]??locales.eur:locales.eur}function getCurrencyAmountKey(e){return e?`${e}Amount`:"eurAmount"}let contextKey="fCtx";function compress(e){if(e?.r)try{let r=(0,external_viem_namespaceObject.hexToBytes)(e.r);return base64urlEncode(r)}catch(r){console.error("Error compressing Frak context",{e:r,context:e})}}function decompress(e){if(e&&0!==e.length)try{let r=base64urlDecode(e);return{r:(0,external_viem_namespaceObject.bytesToHex)(r,{size:20})}}catch(r){console.error("Error decompressing Frak context",{e:r,context:e})}}function parse({url:e}){if(!e)return null;let r=new URL(e).searchParams.get(contextKey);return r?decompress(r):null}function update({url:e,context:r}){if(!e)return null;let t=parse({url:e}),n=t?{...t,...r}:r;if(!n.r)return null;let o=compress(n);if(!o)return null;let a=new URL(e);return a.searchParams.set(contextKey,o),a.toString()}function remove(e){let r=new URL(e);return r.searchParams.delete(contextKey),r.toString()}function replaceUrl({url:e,context:r}){let t;if(!window.location?.href||"undefined"==typeof window){console.error("No window found, can't update context");return}let n=e??window.location.href;(t=null!==r?update({url:n,context:r}):remove(n))&&window.history.replaceState(null,"",t.toString())}let FrakContextManager={compress,decompress,parse,update,remove,replaceUrl};function formatAmount(e,r){let t=getSupportedLocale(r),n=getSupportedCurrency(r);return e.toLocaleString(t,{style:"currency",currency:n,minimumFractionDigits:0,maximumFractionDigits:2})}let productTypes={dapp:1,press:2,webshop:3,retail:4,referral:30,purchase:31},productTypesMask=Object.entries(productTypes).reduce((e,[r,t])=>(e[r]=BigInt(1)<<BigInt(t),e),{}),interactionTypes={press:{openArticle:"0xc0a24ffb",readArticle:"0xd5bd0fbe"},dapp:{proofVerifiableStorageUpdate:"0x2ab2aeef",callableVerifiableStorageUpdate:"0xa07da986"},webshop:{open:"0xb311798f"},referral:{referred:"0x010cc3b9",createLink:"0xb2c0f17c"},purchase:{started:"0xd87e90c3",completed:"0x8403aeb4",unsafeCompleted:"0x4d5b14e0"},retail:{customerMeeting:"0x74489004"}};var __webpack_export_target__=exports;for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__]=__webpack_exports__[__webpack_i__];__webpack_exports__.__esModule&&Object.defineProperty(__webpack_export_target__,"__esModule",{value:!0});
13
+ `.trim()}}function createIFrameChannelManager(){let e=new Map;return{createChannel:r=>{let t=Math.random().toString(36).substring(7);return e.set(t,r),t},getRpcResolver:r=>e.get(r),removeChannel:r=>e.delete(r),destroy:()=>e.clear()}}let baseIframeProps={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"}};function createIframe({walletBaseUrl:e,config:r}){let t=document.querySelector("#frak-wallet");t&&t.remove();let n=document.createElement("iframe");return n.id=baseIframeProps.id,n.name=baseIframeProps.name,n.allow=baseIframeProps.allow,n.style.zIndex=baseIframeProps.style.zIndex.toString(),changeIframeVisibility({iframe:n,isVisible:!1}),document.body.appendChild(n),new Promise(t=>{n?.addEventListener("load",()=>t(n)),n.src=`${r?.walletUrl??e??"https://wallet.frak.id"}/listener`})}function changeIframeVisibility({iframe:e,isVisible:r}){if(!r){e.style.width="0",e.style.height="0",e.style.border="0",e.style.position="fixed",e.style.top="-1000px",e.style.left="-1000px";return}e.style.position="fixed",e.style.top="0",e.style.left="0",e.style.width="100%",e.style.height="100%",e.style.pointerEvents="auto"}function createIFrameLifecycleManager({iframe:e}){let r=new Deferred;return{handleEvent:async t=>{switch(t.iframeLifecycle){case"connected":r.resolve(!0);break;case"do-backup":t.data.backup?localStorage.setItem(BACKUP_KEY,t.data.backup):localStorage.removeItem(BACKUP_KEY);break;case"remove-backup":localStorage.removeItem(BACKUP_KEY);break;case"show":case"hide":changeIframeVisibility({iframe:e,isVisible:"show"===t.iframeLifecycle});break;case"handshake":e.contentWindow?.postMessage({clientLifecycle:"handshake-response",data:{token:t.data.token,currentUrl:window.location.href}},"*")}},isConnected:r.promise}}function createIFrameMessageHandler({frakWalletUrl:e,iframe:r,channelManager:t,iframeLifecycleManager:n,debugInfo:o}){if("undefined"==typeof window)throw new FrakRpcError(RpcErrorCodes.configError,"iframe client should be used in the browser");if(!r.contentWindow)throw new FrakRpcError(RpcErrorCodes.configError,"The iframe does not have a product window");let a=r.contentWindow;async function s(r){if(!r.origin)return;try{if(new URL(r.origin).origin.toLowerCase()!==new URL(e).origin.toLowerCase())return}catch(e){console.log("Unable to check frak msg origin",e);return}if("object"!=typeof r.data)return;if(o.setLastResponse(r),"iframeLifecycle"in r.data){await n.handleEvent(r.data);return}if("clientLifecycle"in r.data){console.error("Client lifecycle event received on the client side, dismissing it");return}let a=r.data.id,s=t.getRpcResolver(a);s&&s(r.data)}return window.addEventListener("message",s),{sendEvent:function(r){a.postMessage(r,{targetOrigin:e}),o.setLastRequest(r,e)},cleanup:function(){window.removeEventListener("message",s)}}}function createIFrameFrakClient({config:e,iframe:r}){let t=createIFrameChannelManager(),n=createIFrameLifecycleManager({iframe:r}),o=new DebugInfoGatherer(e,r),a=createIFrameMessageHandler({frakWalletUrl:e?.walletUrl??"https://wallet.frak.id",iframe:r,channelManager:t,iframeLifecycleManager:n,debugInfo:o}),s=async e=>{if(!await n.isConnected)throw new FrakRpcError(RpcErrorCodes.clientNotConnected,"The iframe provider isn't connected yet");let r=new Deferred,o=t.createChannel(e=>{let n=decompressDataAndCheckHash(e.data);n.error?r.reject(new FrakRpcError(n.error.code,n.error.message,n.error?.data)):r.resolve(n.result),t.removeChannel(o)}),s=hashAndCompressData(e);return a.sendEvent({id:o,topic:e.method,data:s}),r.promise},c=async(e,r)=>{if(!await n.isConnected)throw new FrakRpcError(RpcErrorCodes.clientNotConnected,"The iframe provider isn't connected yet");let o=t.createChannel(e=>{let t=decompressDataAndCheckHash(e.data);if(t.result)r(t.result);else throw new InternalError("No valid result in the response")}),s=hashAndCompressData(e);a.sendEvent({id:o,topic:e.method,data:s})},i=setupHeartbeat(a,n),l=async()=>{i(),t.destroy(),a.cleanup(),r.remove()},d=postConnectionSetup({config:e,messageHandler:a,lifecycleManager:n}).then(()=>o.updateSetupStatus(!0));return{config:e,debugInfo:o,waitForConnection:n.isConnected,waitForSetup:d,request:s,listenerRequest:c,destroy:l}}function setupHeartbeat(e,r){let t,n;let o=()=>e.sendEvent({clientLifecycle:"heartbeat"});function a(){t&&clearInterval(t),n&&clearTimeout(n)}return async function(){o(),t=setInterval(o,100),n=setTimeout(()=>{a(),console.log("Heartbeat timeout: connection failed")},3e4),await r.isConnected,a()}(),a}async function postConnectionSetup({config:e,messageHandler:r,lifecycleManager:t}){async function n(){let t=e.customizations?.css;t&&r.sendEvent({clientLifecycle:"modal-css",data:{cssLink:t}})}async function o(){let t=e.customizations?.i18n;t&&r.sendEvent({clientLifecycle:"modal-i18n",data:{i18n:t}})}async function a(){if("undefined"==typeof window)return;let e=window.localStorage.getItem(BACKUP_KEY);e&&r.sendEvent({clientLifecycle:"restore-backup",data:{backup:e}})}await t.isConnected,await Promise.all([n(),o(),a()])}let locales={eur:"fr-FR",usd:"en-US",gbp:"en-GB"};function getSupportedCurrency(e){return e&&e in locales?e:"eur"}async function setupClient({config:e}){let r=prepareConfig(e),t=await createIframe({config:r});if(!t){console.error("Failed to create iframe");return}let n=createIFrameFrakClient({config:r,iframe:t});if(await n.waitForSetup,!await n.waitForConnection){console.error("Failed to connect to client");return}return n}function prepareConfig(e){let r=getSupportedCurrency(e.metadata?.currency);return{...e,metadata:{...e.metadata,currency:r}}}let contextKey="fCtx";function compress(e){if(e?.r)try{let r=(0,external_viem_namespaceObject.hexToBytes)(e.r);return base64urlEncode(r)}catch(r){console.error("Error compressing Frak context",{e:r,context:e})}}function decompress(e){if(e&&0!==e.length)try{let r=base64urlDecode(e);return{r:(0,external_viem_namespaceObject.bytesToHex)(r,{size:20})}}catch(r){console.error("Error decompressing Frak context",{e:r,context:e})}}function parse({url:e}){if(!e)return null;let r=new URL(e).searchParams.get(contextKey);return r?decompress(r):null}function update({url:e,context:r}){if(!e)return null;let t=parse({url:e}),n=t?{...t,...r}:r;if(!n.r)return null;let o=compress(n);if(!o)return null;let a=new URL(e);return a.searchParams.set(contextKey,o),a.toString()}function remove(e){let r=new URL(e);return r.searchParams.delete(contextKey),r.toString()}function replaceUrl({url:e,context:r}){let t;if(!window.location?.href||"undefined"==typeof window){console.error("No window found, can't update context");return}let n=e??window.location.href;(t=null!==r?update({url:n,context:r}):remove(n))&&window.history.replaceState(null,"",t.toString())}let FrakContextManager={compress,decompress,parse,update,remove,replaceUrl};function getSupportedLocale(e){return e?locales[e]??locales.eur:locales.eur}function formatAmount(e,r){let t=getSupportedLocale(r),n=getSupportedCurrency(r);return e.toLocaleString(t,{style:"currency",currency:n,minimumFractionDigits:0,maximumFractionDigits:2})}function getCurrencyAmountKey(e){return e?`${e}Amount`:"eurAmount"}let productTypes={dapp:1,press:2,webshop:3,retail:4,referral:30,purchase:31},productTypesMask=Object.entries(productTypes).reduce((e,[r,t])=>(e[r]=BigInt(1)<<BigInt(t),e),{}),interactionTypes={press:{openArticle:"0xc0a24ffb",readArticle:"0xd5bd0fbe"},dapp:{proofVerifiableStorageUpdate:"0x2ab2aeef",callableVerifiableStorageUpdate:"0xa07da986"},webshop:{open:"0xb311798f"},referral:{referred:"0x010cc3b9",createLink:"0xb2c0f17c"},purchase:{started:"0xd87e90c3",completed:"0x8403aeb4",unsafeCompleted:"0x4d5b14e0"},retail:{customerMeeting:"0x74489004"}};var __webpack_export_target__=exports;for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__]=__webpack_exports__[__webpack_i__];__webpack_exports__.__esModule&&Object.defineProperty(__webpack_export_target__,"__esModule",{value:!0});
package/dist/index.d.cts CHANGED
@@ -35,6 +35,7 @@ export declare const baseIframeProps: {
35
35
  zIndex: number;
36
36
  top: string;
37
37
  left: string;
38
+ colorScheme: string;
38
39
  };
39
40
  };
40
41
 
@@ -201,15 +202,15 @@ export declare class Deferred<T> {
201
202
  *
202
203
  * @group Embedded wallet
203
204
  */
204
- export declare type DisplayEmbededWalletParamsType = {
205
+ export declare type DisplayEmbeddedWalletParamsType = {
205
206
  /**
206
207
  * The embedded view to display once the user is logged in
207
208
  */
208
- loggedIn?: LoggedInEmbededView;
209
+ loggedIn?: LoggedInEmbeddedView;
209
210
  /**
210
211
  * The embedded view to display once the user is logged out
211
212
  */
212
- loggedOut?: LoggedOutEmbededView;
213
+ loggedOut?: LoggedOutEmbeddedView;
213
214
  /**
214
215
  * Some metadata to customize the embedded view
215
216
  */
@@ -239,6 +240,15 @@ export declare type DisplayEmbededWalletParamsType = {
239
240
  };
240
241
  };
241
242
 
243
+ /**
244
+ * The result of the display embedded wallet rpc request
245
+ *
246
+ * @group Embedded wallet
247
+ */
248
+ export declare type DisplayEmbeddedWalletResultType = {
249
+ wallet: Address;
250
+ };
251
+
242
252
  /**
243
253
  * Params used to display a modal
244
254
  * @typeParam T - The list of modal steps we expect to have in the modal
@@ -256,12 +266,25 @@ declare type DoBackupEvent = {
256
266
  };
257
267
  };
258
268
 
269
+ /**
270
+ * The action to display on the logged out embedded view when the user is referred
271
+ *
272
+ * @group Embedded wallet
273
+ */
274
+ export declare type EmbeddedViewActionReferred = {
275
+ key: "referred";
276
+ /**
277
+ * No options for a referred action
278
+ */
279
+ options?: never;
280
+ };
281
+
259
282
  /**
260
283
  * The different type of action we can have on the embedded view (once the user is logged in)
261
284
  *
262
285
  * @group Embedded wallet
263
286
  */
264
- export declare type EmbededViewAction = {
287
+ export declare type EmbeddedViewActionSharing = {
265
288
  key: "sharing";
266
289
  /**
267
290
  * Some sharing options
@@ -659,9 +682,9 @@ export declare type IFrameRpcEvent = {
659
682
  * - Params: None
660
683
  * - Returns: {@link GetProductInformationReturnType}
661
684
  *
662
- * ### frak_displayEmbededWallet
663
- * - Params: [{@link DisplayEmbededWalletParamsType}]
664
- * - Returns: undefined
685
+ * ### frak_displayEmbeddedWallet
686
+ * - Params: [{@link DisplayEmbeddedWalletParamsType}]
687
+ * - Returns: {@link DisplayEmbeddedWalletResultType}
665
688
  */
666
689
  export declare type IFrameRpcSchema = [
667
690
  /**
@@ -724,12 +747,12 @@ export declare type IFrameRpcSchema = [
724
747
  * Method to show the embedded wallet, with potential customization
725
748
  */
726
749
  {
727
- Method: "frak_displayEmbededWallet";
750
+ Method: "frak_displayEmbeddedWallet";
728
751
  Parameters: [
729
- request: DisplayEmbededWalletParamsType,
752
+ request: DisplayEmbeddedWalletParamsType,
730
753
  metadata: FrakWalletSdkConfig["metadata"]
731
754
  ];
732
- ReturnType: undefined;
755
+ ReturnType: DisplayEmbeddedWalletResultType;
733
756
  }
734
757
  ];
735
758
 
@@ -842,19 +865,18 @@ export declare type LocalizedI18nConfig = `${string}.css` | {
842
865
  *
843
866
  * @group Embedded wallet
844
867
  */
845
- export declare type LoggedInEmbededView = {
868
+ export declare type LoggedInEmbeddedView = {
846
869
  /**
847
870
  * The main action to display on the logged in embedded view
848
- * If none specified, the user will see his wallet with the activation button
849
871
  */
850
- action?: EmbededViewAction;
872
+ action?: EmbeddedViewActionSharing | EmbeddedViewActionReferred;
851
873
  };
852
874
 
853
875
  /**
854
876
  * The view when a user is logged out
855
877
  * @group Embedded wallet
856
878
  */
857
- export declare type LoggedOutEmbededView = {
879
+ export declare type LoggedOutEmbeddedView = {
858
880
  /**
859
881
  * Metadata option when displaying the embedded view
860
882
  */
package/dist/index.d.ts CHANGED
@@ -35,6 +35,7 @@ export declare const baseIframeProps: {
35
35
  zIndex: number;
36
36
  top: string;
37
37
  left: string;
38
+ colorScheme: string;
38
39
  };
39
40
  };
40
41
 
@@ -201,15 +202,15 @@ export declare class Deferred<T> {
201
202
  *
202
203
  * @group Embedded wallet
203
204
  */
204
- export declare type DisplayEmbededWalletParamsType = {
205
+ export declare type DisplayEmbeddedWalletParamsType = {
205
206
  /**
206
207
  * The embedded view to display once the user is logged in
207
208
  */
208
- loggedIn?: LoggedInEmbededView;
209
+ loggedIn?: LoggedInEmbeddedView;
209
210
  /**
210
211
  * The embedded view to display once the user is logged out
211
212
  */
212
- loggedOut?: LoggedOutEmbededView;
213
+ loggedOut?: LoggedOutEmbeddedView;
213
214
  /**
214
215
  * Some metadata to customize the embedded view
215
216
  */
@@ -239,6 +240,15 @@ export declare type DisplayEmbededWalletParamsType = {
239
240
  };
240
241
  };
241
242
 
243
+ /**
244
+ * The result of the display embedded wallet rpc request
245
+ *
246
+ * @group Embedded wallet
247
+ */
248
+ export declare type DisplayEmbeddedWalletResultType = {
249
+ wallet: Address;
250
+ };
251
+
242
252
  /**
243
253
  * Params used to display a modal
244
254
  * @typeParam T - The list of modal steps we expect to have in the modal
@@ -256,12 +266,25 @@ declare type DoBackupEvent = {
256
266
  };
257
267
  };
258
268
 
269
+ /**
270
+ * The action to display on the logged out embedded view when the user is referred
271
+ *
272
+ * @group Embedded wallet
273
+ */
274
+ export declare type EmbeddedViewActionReferred = {
275
+ key: "referred";
276
+ /**
277
+ * No options for a referred action
278
+ */
279
+ options?: never;
280
+ };
281
+
259
282
  /**
260
283
  * The different type of action we can have on the embedded view (once the user is logged in)
261
284
  *
262
285
  * @group Embedded wallet
263
286
  */
264
- export declare type EmbededViewAction = {
287
+ export declare type EmbeddedViewActionSharing = {
265
288
  key: "sharing";
266
289
  /**
267
290
  * Some sharing options
@@ -659,9 +682,9 @@ export declare type IFrameRpcEvent = {
659
682
  * - Params: None
660
683
  * - Returns: {@link GetProductInformationReturnType}
661
684
  *
662
- * ### frak_displayEmbededWallet
663
- * - Params: [{@link DisplayEmbededWalletParamsType}]
664
- * - Returns: undefined
685
+ * ### frak_displayEmbeddedWallet
686
+ * - Params: [{@link DisplayEmbeddedWalletParamsType}]
687
+ * - Returns: {@link DisplayEmbeddedWalletResultType}
665
688
  */
666
689
  export declare type IFrameRpcSchema = [
667
690
  /**
@@ -724,12 +747,12 @@ export declare type IFrameRpcSchema = [
724
747
  * Method to show the embedded wallet, with potential customization
725
748
  */
726
749
  {
727
- Method: "frak_displayEmbededWallet";
750
+ Method: "frak_displayEmbeddedWallet";
728
751
  Parameters: [
729
- request: DisplayEmbededWalletParamsType,
752
+ request: DisplayEmbeddedWalletParamsType,
730
753
  metadata: FrakWalletSdkConfig["metadata"]
731
754
  ];
732
- ReturnType: undefined;
755
+ ReturnType: DisplayEmbeddedWalletResultType;
733
756
  }
734
757
  ];
735
758
 
@@ -842,19 +865,18 @@ export declare type LocalizedI18nConfig = `${string}.css` | {
842
865
  *
843
866
  * @group Embedded wallet
844
867
  */
845
- export declare type LoggedInEmbededView = {
868
+ export declare type LoggedInEmbeddedView = {
846
869
  /**
847
870
  * The main action to display on the logged in embedded view
848
- * If none specified, the user will see his wallet with the activation button
849
871
  */
850
- action?: EmbededViewAction;
872
+ action?: EmbeddedViewActionSharing | EmbeddedViewActionReferred;
851
873
  };
852
874
 
853
875
  /**
854
876
  * The view when a user is logged out
855
877
  * @group Embedded wallet
856
878
  */
857
- export declare type LoggedOutEmbededView = {
879
+ export declare type LoggedOutEmbeddedView = {
858
880
  /**
859
881
  * Metadata option when displaying the embedded view
860
882
  */
package/dist/index.js CHANGED
@@ -10,4 +10,4 @@ import*as e from"@jsonjoy.com/json-pack/lib/cbor";import*as t from"viem";class n
10
10
  Last Response: ${t.lastResponse}
11
11
  Client Status: ${t.clientStatus}
12
12
  Error: ${t.error}
13
- `.trim()}}let v={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"}};function C({walletBaseUrl:e,config:t}){let n=document.querySelector("#frak-wallet");n&&n.remove();let r=document.createElement("iframe");return r.id=v.id,r.name=v.name,r.allow=v.allow,r.style.zIndex=v.style.zIndex.toString(),R({iframe:r,isVisible:!1}),document.body.appendChild(r),new Promise(n=>{r?.addEventListener("load",()=>n(r)),r.src=`${t?.walletUrl??e??"https://wallet.frak.id"}/listener`})}function R({iframe:e,isVisible:t}){if(!t){e.style.width="0",e.style.height="0",e.style.border="0",e.style.position="fixed",e.style.top="-1000px",e.style.left="-1000px";return}e.style.position="fixed",e.style.top="0",e.style.left="0",e.style.width="100%",e.style.height="100%",e.style.pointerEvents="auto"}function S({config:e,iframe:t}){let o=function(){let e=new Map;return{createChannel:t=>{let n=Math.random().toString(36).substring(7);return e.set(n,t),n},getRpcResolver:t=>e.get(t),removeChannel:t=>e.delete(t),destroy:()=>e.clear()}}(),s=function({iframe:e}){let t=new i;return{handleEvent:async n=>{switch(n.iframeLifecycle){case"connected":t.resolve(!0);break;case"do-backup":n.data.backup?localStorage.setItem(y,n.data.backup):localStorage.removeItem(y);break;case"remove-backup":localStorage.removeItem(y);break;case"show":case"hide":R({iframe:e,isVisible:"show"===n.iframeLifecycle});break;case"handshake":e.contentWindow?.postMessage({clientLifecycle:"handshake-response",data:{token:n.data.token,currentUrl:window.location.href}},"*")}},isConnected:t.promise}}({iframe:t}),c=new b(e,t),l=function({frakWalletUrl:e,iframe:t,channelManager:r,iframeLifecycleManager:o,debugInfo:i}){if("undefined"==typeof window)throw new n(a.configError,"iframe client should be used in the browser");if(!t.contentWindow)throw new n(a.configError,"The iframe does not have a product window");let s=t.contentWindow;async function c(t){if(!t.origin)return;try{if(new URL(t.origin).origin.toLowerCase()!==new URL(e).origin.toLowerCase())return}catch(e){console.log("Unable to check frak msg origin",e);return}if("object"!=typeof t.data)return;if(i.setLastResponse(t),"iframeLifecycle"in t.data){await o.handleEvent(t.data);return}if("clientLifecycle"in t.data){console.error("Client lifecycle event received on the client side, dismissing it");return}let n=t.data.id,a=r.getRpcResolver(n);a&&a(t.data)}return window.addEventListener("message",c),{sendEvent:function(t){s.postMessage(t,{targetOrigin:e}),i.setLastRequest(t,e)},cleanup:function(){window.removeEventListener("message",c)}}}({frakWalletUrl:e?.walletUrl??"https://wallet.frak.id",iframe:t,channelManager:o,iframeLifecycleManager:s,debugInfo:c}),u=async e=>{if(!await s.isConnected)throw new n(a.clientNotConnected,"The iframe provider isn't connected yet");let t=new i,r=o.createChannel(e=>{let a=m(e.data);a.error?t.reject(new n(a.error.code,a.error.message,a.error?.data)):t.resolve(a.result),o.removeChannel(r)}),c=d(e);return l.sendEvent({id:r,topic:e.method,data:c}),t.promise},f=async(e,t)=>{if(!await s.isConnected)throw new n(a.clientNotConnected,"The iframe provider isn't connected yet");let i=o.createChannel(e=>{let n=m(e.data);if(n.result)t(n.result);else throw new r("No valid result in the response")}),c=d(e);l.sendEvent({id:i,topic:e.method,data:c})},p=function(e,t){let n,r;let o=()=>e.sendEvent({clientLifecycle:"heartbeat"});function a(){n&&clearInterval(n),r&&clearTimeout(r)}return async function(){o(),n=setInterval(o,100),r=setTimeout(()=>{a(),console.log("Heartbeat timeout: connection failed")},3e4),await t.isConnected,a()}(),a}(l,s),h=async()=>{p(),o.destroy(),l.cleanup(),t.remove()},g=E({config:e,messageHandler:l,lifecycleManager:s}).then(()=>c.updateSetupStatus(!0));return{config:e,debugInfo:c,waitForConnection:s.isConnected,waitForSetup:g,request:u,listenerRequest:f,destroy:h}}async function E({config:e,messageHandler:t,lifecycleManager:n}){async function r(){let n=e.customizations?.css;n&&t.sendEvent({clientLifecycle:"modal-css",data:{cssLink:n}})}async function o(){let n=e.customizations?.i18n;n&&t.sendEvent({clientLifecycle:"modal-i18n",data:{i18n:n}})}async function a(){if("undefined"==typeof window)return;let e=window.localStorage.getItem(y);e&&t.sendEvent({clientLifecycle:"restore-backup",data:{backup:e}})}await n.isConnected,await Promise.all([r(),o(),a()])}let k={eur:"fr-FR",usd:"en-US",gbp:"en-GB"};function x(e){return e&&e in k?e:"eur"}async function I({config:e}){let t=function(e){let t=x(e.metadata?.currency);return{...e,metadata:{...e.metadata,currency:t}}}(e),n=await C({config:t});if(!n){console.error("Failed to create iframe");return}let r=S({config:t,iframe:n});if(await r.waitForSetup,!await r.waitForConnection){console.error("Failed to connect to client");return}return r}function L(e){return e?`${e}Amount`:"eurAmount"}let F="fCtx";function D(e){if(e?.r)try{let n=(0,t.hexToBytes)(e.r);return s(n)}catch(t){console.error("Error compressing Frak context",{e:t,context:e})}}function U(e){if(e&&0!==e.length)try{let n=c(e);return{r:(0,t.bytesToHex)(n,{size:20})}}catch(t){console.error("Error decompressing Frak context",{e:t,context:e})}}function A({url:e}){if(!e)return null;let t=new URL(e).searchParams.get(F);return t?U(t):null}function N({url:e,context:t}){if(!e)return null;let n=A({url:e}),r=n?{...n,...t}:t;if(!r.r)return null;let o=D(r);if(!o)return null;let a=new URL(e);return a.searchParams.set(F,o),a.toString()}function $(e){let t=new URL(e);return t.searchParams.delete(F),t.toString()}let q={compress:D,decompress:U,parse:A,update:N,remove:$,replaceUrl:function({url:e,context:t}){let n;if(!window.location?.href||"undefined"==typeof window){console.error("No window found, can't update context");return}let r=e??window.location.href;(n=null!==t?N({url:r,context:t}):$(r))&&window.history.replaceState(null,"",n.toString())}};function T(e){return e?k[e]??k.eur:k.eur}function j(e,t){let n=T(t),r=x(t);return e.toLocaleString(n,{style:"currency",currency:r,minimumFractionDigits:0,maximumFractionDigits:2})}let _={dapp:1,press:2,webshop:3,retail:4,referral:30,purchase:31},M=Object.entries(_).reduce((e,[t,n])=>(e[t]=BigInt(1)<<BigInt(n),e),{}),P={press:{openArticle:"0xc0a24ffb",readArticle:"0xd5bd0fbe"},dapp:{proofVerifiableStorageUpdate:"0x2ab2aeef",callableVerifiableStorageUpdate:"0xa07da986"},webshop:{open:"0xb311798f"},referral:{referred:"0x010cc3b9",createLink:"0xb2c0f17c"},purchase:{started:"0xd87e90c3",completed:"0x8403aeb4",unsafeCompleted:"0x4d5b14e0"},retail:{customerMeeting:"0x74489004"}};export{o as ClientNotFound,b as DebugInfoGatherer,i as Deferred,q as FrakContextManager,n as FrakRpcError,a as RpcErrorCodes,c as base64urlDecode,s as base64urlEncode,v as baseIframeProps,u as compressJson,f as compressJsonToB64,S as createIFrameFrakClient,C as createIframe,m as decompressDataAndCheckHash,g as decompressJson,w as decompressJsonFromB64,j as formatAmount,L as getCurrencyAmountKey,x as getSupportedCurrency,T as getSupportedLocale,d as hashAndCompressData,P as interactionTypes,k as locales,_ as productTypes,M as productTypesMask,I as setupClient};
13
+ `.trim()}}let v={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"}};function C({walletBaseUrl:e,config:t}){let n=document.querySelector("#frak-wallet");n&&n.remove();let r=document.createElement("iframe");return r.id=v.id,r.name=v.name,r.allow=v.allow,r.style.zIndex=v.style.zIndex.toString(),R({iframe:r,isVisible:!1}),document.body.appendChild(r),new Promise(n=>{r?.addEventListener("load",()=>n(r)),r.src=`${t?.walletUrl??e??"https://wallet.frak.id"}/listener`})}function R({iframe:e,isVisible:t}){if(!t){e.style.width="0",e.style.height="0",e.style.border="0",e.style.position="fixed",e.style.top="-1000px",e.style.left="-1000px";return}e.style.position="fixed",e.style.top="0",e.style.left="0",e.style.width="100%",e.style.height="100%",e.style.pointerEvents="auto"}function S({config:e,iframe:t}){let o=function(){let e=new Map;return{createChannel:t=>{let n=Math.random().toString(36).substring(7);return e.set(n,t),n},getRpcResolver:t=>e.get(t),removeChannel:t=>e.delete(t),destroy:()=>e.clear()}}(),s=function({iframe:e}){let t=new i;return{handleEvent:async n=>{switch(n.iframeLifecycle){case"connected":t.resolve(!0);break;case"do-backup":n.data.backup?localStorage.setItem(y,n.data.backup):localStorage.removeItem(y);break;case"remove-backup":localStorage.removeItem(y);break;case"show":case"hide":R({iframe:e,isVisible:"show"===n.iframeLifecycle});break;case"handshake":e.contentWindow?.postMessage({clientLifecycle:"handshake-response",data:{token:n.data.token,currentUrl:window.location.href}},"*")}},isConnected:t.promise}}({iframe:t}),c=new b(e,t),l=function({frakWalletUrl:e,iframe:t,channelManager:r,iframeLifecycleManager:o,debugInfo:i}){if("undefined"==typeof window)throw new n(a.configError,"iframe client should be used in the browser");if(!t.contentWindow)throw new n(a.configError,"The iframe does not have a product window");let s=t.contentWindow;async function c(t){if(!t.origin)return;try{if(new URL(t.origin).origin.toLowerCase()!==new URL(e).origin.toLowerCase())return}catch(e){console.log("Unable to check frak msg origin",e);return}if("object"!=typeof t.data)return;if(i.setLastResponse(t),"iframeLifecycle"in t.data){await o.handleEvent(t.data);return}if("clientLifecycle"in t.data){console.error("Client lifecycle event received on the client side, dismissing it");return}let n=t.data.id,a=r.getRpcResolver(n);a&&a(t.data)}return window.addEventListener("message",c),{sendEvent:function(t){s.postMessage(t,{targetOrigin:e}),i.setLastRequest(t,e)},cleanup:function(){window.removeEventListener("message",c)}}}({frakWalletUrl:e?.walletUrl??"https://wallet.frak.id",iframe:t,channelManager:o,iframeLifecycleManager:s,debugInfo:c}),u=async e=>{if(!await s.isConnected)throw new n(a.clientNotConnected,"The iframe provider isn't connected yet");let t=new i,r=o.createChannel(e=>{let a=m(e.data);a.error?t.reject(new n(a.error.code,a.error.message,a.error?.data)):t.resolve(a.result),o.removeChannel(r)}),c=d(e);return l.sendEvent({id:r,topic:e.method,data:c}),t.promise},f=async(e,t)=>{if(!await s.isConnected)throw new n(a.clientNotConnected,"The iframe provider isn't connected yet");let i=o.createChannel(e=>{let n=m(e.data);if(n.result)t(n.result);else throw new r("No valid result in the response")}),c=d(e);l.sendEvent({id:i,topic:e.method,data:c})},p=function(e,t){let n,r;let o=()=>e.sendEvent({clientLifecycle:"heartbeat"});function a(){n&&clearInterval(n),r&&clearTimeout(r)}return async function(){o(),n=setInterval(o,100),r=setTimeout(()=>{a(),console.log("Heartbeat timeout: connection failed")},3e4),await t.isConnected,a()}(),a}(l,s),h=async()=>{p(),o.destroy(),l.cleanup(),t.remove()},g=E({config:e,messageHandler:l,lifecycleManager:s}).then(()=>c.updateSetupStatus(!0));return{config:e,debugInfo:c,waitForConnection:s.isConnected,waitForSetup:g,request:u,listenerRequest:f,destroy:h}}async function E({config:e,messageHandler:t,lifecycleManager:n}){async function r(){let n=e.customizations?.css;n&&t.sendEvent({clientLifecycle:"modal-css",data:{cssLink:n}})}async function o(){let n=e.customizations?.i18n;n&&t.sendEvent({clientLifecycle:"modal-i18n",data:{i18n:n}})}async function a(){if("undefined"==typeof window)return;let e=window.localStorage.getItem(y);e&&t.sendEvent({clientLifecycle:"restore-backup",data:{backup:e}})}await n.isConnected,await Promise.all([r(),o(),a()])}let k={eur:"fr-FR",usd:"en-US",gbp:"en-GB"};function x(e){return e&&e in k?e:"eur"}async function I({config:e}){let t=function(e){let t=x(e.metadata?.currency);return{...e,metadata:{...e.metadata,currency:t}}}(e),n=await C({config:t});if(!n){console.error("Failed to create iframe");return}let r=S({config:t,iframe:n});if(await r.waitForSetup,!await r.waitForConnection){console.error("Failed to connect to client");return}return r}function L(e){return e?`${e}Amount`:"eurAmount"}let F="fCtx";function D(e){if(e?.r)try{let n=(0,t.hexToBytes)(e.r);return s(n)}catch(t){console.error("Error compressing Frak context",{e:t,context:e})}}function U(e){if(e&&0!==e.length)try{let n=c(e);return{r:(0,t.bytesToHex)(n,{size:20})}}catch(t){console.error("Error decompressing Frak context",{e:t,context:e})}}function A({url:e}){if(!e)return null;let t=new URL(e).searchParams.get(F);return t?U(t):null}function N({url:e,context:t}){if(!e)return null;let n=A({url:e}),r=n?{...n,...t}:t;if(!r.r)return null;let o=D(r);if(!o)return null;let a=new URL(e);return a.searchParams.set(F,o),a.toString()}function $(e){let t=new URL(e);return t.searchParams.delete(F),t.toString()}let q={compress:D,decompress:U,parse:A,update:N,remove:$,replaceUrl:function({url:e,context:t}){let n;if(!window.location?.href||"undefined"==typeof window){console.error("No window found, can't update context");return}let r=e??window.location.href;(n=null!==t?N({url:r,context:t}):$(r))&&window.history.replaceState(null,"",n.toString())}};function T(e){return e?k[e]??k.eur:k.eur}function j(e,t){let n=T(t),r=x(t);return e.toLocaleString(n,{style:"currency",currency:r,minimumFractionDigits:0,maximumFractionDigits:2})}let _={dapp:1,press:2,webshop:3,retail:4,referral:30,purchase:31},M=Object.entries(_).reduce((e,[t,n])=>(e[t]=BigInt(1)<<BigInt(n),e),{}),P={press:{openArticle:"0xc0a24ffb",readArticle:"0xd5bd0fbe"},dapp:{proofVerifiableStorageUpdate:"0x2ab2aeef",callableVerifiableStorageUpdate:"0xa07da986"},webshop:{open:"0xb311798f"},referral:{referred:"0x010cc3b9",createLink:"0xb2c0f17c"},purchase:{started:"0xd87e90c3",completed:"0x8403aeb4",unsafeCompleted:"0x4d5b14e0"},retail:{customerMeeting:"0x74489004"}};export{o as ClientNotFound,b as DebugInfoGatherer,i as Deferred,q as FrakContextManager,n as FrakRpcError,a as RpcErrorCodes,c as base64urlDecode,s as base64urlEncode,v as baseIframeProps,u as compressJson,f as compressJsonToB64,S as createIFrameFrakClient,C as createIframe,m as decompressDataAndCheckHash,g as decompressJson,w as decompressJsonFromB64,j as formatAmount,L as getCurrencyAmountKey,x as getSupportedCurrency,T as getSupportedLocale,d as hashAndCompressData,P as interactionTypes,k as locales,_ as productTypes,M as productTypesMask,I as setupClient};
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "url": "https://twitter.com/QNivelais"
12
12
  }
13
13
  ],
14
- "version": "0.0.11",
14
+ "version": "0.0.13",
15
15
  "description": "Core SDK of the Frak wallet, low level library to interact directly with the frak ecosystem.",
16
16
  "repository": {
17
17
  "url": "https://github.com/frak-id/wallet",
@@ -74,7 +74,7 @@
74
74
  "format:check": "biome check .",
75
75
  "format": "biome check --write .",
76
76
  "clean": "rimraf dist",
77
- "build": "rslib build && bun run check-exports",
77
+ "build": "rslib build",
78
78
  "build:watch": "rslib build --watch",
79
79
  "check-exports": "attw --pack --profile node16 .",
80
80
  "typecheck": "tsc --noEmit",