@tinycloud/web-sdk 3.12.0-beta.34 → 3.12.0-beta.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/delegations-issued.cjs +1 -1
- package/dist/delegations-issued.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +1 -1
- package/dist/modules/Storage/tinycloud/types.schema.d.ts +8 -8
- package/dist/modules/tcw.d.ts +2 -0
- package/dist/share-placement-core-bridge.d.ts +2 -0
- package/dist/share-placement-core.d.ts +13 -0
- package/dist/share-placement-entry.d.ts +2 -0
- package/dist/share-placement.cjs +2 -0
- package/dist/share-placement.cjs.LICENSE.txt +3 -0
- package/dist/share-placement.mjs +2 -0
- package/dist/share-placement.mjs.LICENSE.txt +3 -0
- package/package.json +4 -4
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see share-placement.mjs.LICENSE.txt */
|
|
2
|
+
import{__sharePlacementCore as e}from"./index.mjs";var t={964(e,t,n){n.d(t,{B4:()=>p,CQ:()=>b,CW:()=>_,Ei:()=>h,F8:()=>x,P5:()=>f,TH:()=>k,Vl:()=>v,Vr:()=>w,WM:()=>m,WQ:()=>y,im:()=>g,jm:()=>d,lD:()=>a,qh:()=>l,rE:()=>u,ry:()=>c,xn:()=>o});const r=BigInt(2**32-1),s=BigInt(32);function i(e,t=!1){return t?{h:Number(e&r),l:Number(e>>s&r)}:{h:0|Number(e>>s&r),l:0|Number(e&r)}}function a(e,t=!1){const n=e.length;let r=new Uint32Array(n),s=new Uint32Array(n);for(let a=0;a<n;a++){const{h:n,l:o}=i(e[a],t);[r[a],s[a]]=[n,o]}return[r,s]}const o=(e,t,n)=>e>>>n,d=(e,t,n)=>e<<32-n|t>>>n,u=(e,t,n)=>e>>>n|t<<32-n,c=(e,t,n)=>e<<32-n|t>>>n,l=(e,t,n)=>e<<64-n|t>>>n-32,h=(e,t,n)=>e>>>n-32|t<<64-n,f=(e,t,n)=>e<<n|t>>>32-n,p=(e,t,n)=>t<<n|e>>>32-n,m=(e,t,n)=>t<<n-32|e>>>64-n,g=(e,t,n)=>e<<n-32|t>>>64-n;function y(e,t,n,r){const s=(t>>>0)+(r>>>0);return{h:e+n+(s/2**32|0)|0,l:0|s}}const v=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),w=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,_=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),b=(e,t,n,r,s)=>t+n+r+s+(e/2**32|0)|0,x=(e,t,n,r,s)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(s>>>0),k=(e,t,n,r,s,i)=>t+n+r+s+i+(e/2**32|0)|0},657(e,t,n){n.d(t,{Vw:()=>v,DO:()=>a,CC:()=>d,sd:()=>o,Fe:()=>i,Ht:()=>u,uH:()=>l,Id:()=>y,qj:()=>w,O8:()=>h,po:()=>_,Ow:()=>f,fd:()=>m,ZJ:()=>g,DH:()=>c});const r=()=>"undefined"!=typeof globalThis&&globalThis.crypto?globalThis.crypto:"undefined"!=typeof window&&window.crypto?window.crypto:"undefined"!=typeof self&&self.crypto?self.crypto:void 0,s={web:r(),node:void 0,getRandomValues:function(e){const t=r();if(t&&t.getRandomValues)return t.getRandomValues(e);throw new Error("crypto.getRandomValues is unavailable")}};function i(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function a(e,...t){if(!((n=e)instanceof Uint8Array||ArrayBuffer.isView(n)&&"Uint8Array"===n.constructor.name))throw new Error("Uint8Array expected");var n;if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function o(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.createHasher");i(e.outputLen),i(e.blockLen)}function d(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function u(e,t){a(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function c(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function l(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function h(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function f(e,t){return e<<32-t|e>>>t}function p(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const m=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])()?e=>e:function(e){for(let t=0;t<e.length;t++)e[t]=p(e[t]);return e};function g(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}(e)),a(e),e}function y(...e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];a(r),t+=r.length}const n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){const s=e[t];n.set(s,r),r+=s.length}return n}class v{}function w(e){const t=t=>e().update(g(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function _(e=32){if(s&&"function"==typeof s.getRandomValues)return s.getRandomValues(new Uint8Array(e));if(s&&"function"==typeof s.randomBytes)return Uint8Array.from(s.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}},329(e,t,n){n.d(t,{secp256k1:()=>Re});var r=n(657);function s(e,t,n){return e&t^~e&n}function i(e,t,n){return e&t^e&n^t&n}class a extends r.Vw{constructor(e,t,n,s){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=s,this.buffer=new Uint8Array(e),this.view=(0,r.O8)(this.buffer)}update(e){(0,r.CC)(this),e=(0,r.ZJ)(e),(0,r.DO)(e);const{view:t,buffer:n,blockLen:s}=this,i=e.length;for(let a=0;a<i;){const o=Math.min(s-this.pos,i-a);if(o===s){const t=(0,r.O8)(e);for(;s<=i-a;a+=s)this.process(t,a);continue}n.set(e.subarray(a,a+o),this.pos),this.pos+=o,a+=o,this.pos===s&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){(0,r.CC)(this),(0,r.Ht)(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:s,isLE:i}=this;let{pos:a}=this;t[a++]=128,(0,r.uH)(this.buffer.subarray(a)),this.padOffset>s-a&&(this.process(n,0),a=0);for(let e=a;e<s;e++)t[e]=0;!function(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const s=BigInt(32),i=BigInt(4294967295),a=Number(n>>s&i),o=Number(n&i),d=r?4:0,u=r?0:4;e.setUint32(t+d,a,r),e.setUint32(t+u,o,r)}(n,s-8,BigInt(8*this.length),i),this.process(n,0);const o=(0,r.O8)(e),d=this.outputLen;if(d%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=d/4,c=this.get();if(u>c.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<u;e++)o.setUint32(4*e,c[e],i)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:r,finished:s,destroyed:i,pos:a}=this;return e.destroyed=i,e.finished=s,e.length=r,e.pos=a,r%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}}const o=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);n(964);const d=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),u=new Uint32Array(64);class c extends a{constructor(e=32){super(64,e,8,!1),this.A=0|o[0],this.B=0|o[1],this.C=0|o[2],this.D=0|o[3],this.E=0|o[4],this.F=0|o[5],this.G=0|o[6],this.H=0|o[7]}get(){const{A:e,B:t,C:n,D:r,E:s,F:i,G:a,H:o}=this;return[e,t,n,r,s,i,a,o]}set(e,t,n,r,s,i,a,o){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|s,this.F=0|i,this.G=0|a,this.H=0|o}process(e,t){for(let n=0;n<16;n++,t+=4)u[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=u[e-15],n=u[e-2],s=(0,r.Ow)(t,7)^(0,r.Ow)(t,18)^t>>>3,i=(0,r.Ow)(n,17)^(0,r.Ow)(n,19)^n>>>10;u[e]=i+u[e-7]+s+u[e-16]|0}let{A:n,B:a,C:o,D:c,E:l,F:h,G:f,H:p}=this;for(let e=0;e<64;e++){const t=p+((0,r.Ow)(l,6)^(0,r.Ow)(l,11)^(0,r.Ow)(l,25))+s(l,h,f)+d[e]+u[e]|0,m=((0,r.Ow)(n,2)^(0,r.Ow)(n,13)^(0,r.Ow)(n,22))+i(n,a,o)|0;p=f,f=h,h=l,l=c+t|0,c=o,o=a,a=n,n=t+m|0}n=n+this.A|0,a=a+this.B|0,o=o+this.C|0,c=c+this.D|0,l=l+this.E|0,h=h+this.F|0,f=f+this.G|0,p=p+this.H|0,this.set(n,a,o,c,l,h,f,p)}roundClean(){(0,r.uH)(u)}destroy(){this.set(0,0,0,0,0,0,0,0),(0,r.uH)(this.buffer)}}const l=(0,r.qj)(()=>new c);class h extends r.Vw{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,(0,r.sd)(e);const n=(0,r.ZJ)(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,i=new Uint8Array(s);i.set(n.length>s?e.create().update(n).digest():n);for(let e=0;e<i.length;e++)i[e]^=54;this.iHash.update(i),this.oHash=e.create();for(let e=0;e<i.length;e++)i[e]^=106;this.oHash.update(i),(0,r.uH)(i)}update(e){return(0,r.CC)(this),this.iHash.update(e),this}digestInto(e){(0,r.CC)(this),(0,r.DO)(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:n,finished:r,destroyed:s,blockLen:i,outputLen:a}=this;return e.finished=r,e.destroyed=s,e.blockLen=i,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const f=(e,t,n)=>new h(e,t).update(n).digest();f.create=(e,t)=>new h(e,t);const p=BigInt(0),m=BigInt(1);function g(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function y(e){if(!g(e))throw new Error("Uint8Array expected")}function v(e,t){if("boolean"!=typeof t)throw new Error(e+" boolean expected, got "+t)}function w(e){const t=e.toString(16);return 1&t.length?"0"+t:t}function _(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return""===e?p:BigInt("0x"+e)}const b="function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex,x=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function k(e){if(y(e),b)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=x[e[n]];return t}function E(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:void 0}function O(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(b)return Uint8Array.fromHex(e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let t=0,s=0;t<n;t++,s+=2){const n=E(e.charCodeAt(s)),i=E(e.charCodeAt(s+1));if(void 0===n||void 0===i){const t=e[s]+e[s+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+s)}r[t]=16*n+i}return r}function A(e){return _(k(e))}function S(e){return y(e),_(k(Uint8Array.from(e).reverse()))}function I(e,t){return O(e.toString(16).padStart(2*t,"0"))}function C(e,t){return I(e,t).reverse()}function N(e,t,n){let r;if("string"==typeof t)try{r=O(t)}catch(t){throw new Error(e+" must be hex string or Uint8Array, cause: "+t)}else{if(!g(t))throw new Error(e+" must be hex string or Uint8Array");r=Uint8Array.from(t)}const s=r.length;if("number"==typeof n&&s!==n)throw new Error(e+" of length "+n+" expected, got "+s);return r}function B(...e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];y(r),t+=r.length}const n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){const s=e[t];n.set(s,r),r+=s.length}return n}const Z=e=>"bigint"==typeof e&&p<=e;function T(e,t,n){return Z(e)&&Z(t)&&Z(n)&&t<=e&&e<n}function R(e,t,n,r){if(!T(t,n,r))throw new Error("expected valid "+e+": "+n+" <= n < "+r+", got "+t)}const z=e=>(m<<BigInt(e))-m,j=e=>new Uint8Array(e),$=e=>Uint8Array.from(e),P={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,stringOrUint8Array:e=>"string"==typeof e||g(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)};function L(e,t,n={}){const r=(t,n,r)=>{const s=P[n];if("function"!=typeof s)throw new Error("invalid validator function");const i=e[t];if(!(r&&void 0===i||s(i,e)))throw new Error("param "+String(t)+" is invalid. Expected "+n+", got "+i)};for(const[e,n]of Object.entries(t))r(e,n,!1);for(const[e,t]of Object.entries(n))r(e,t,!0);return e}function F(e){const t=new WeakMap;return(n,...r)=>{const s=t.get(n);if(void 0!==s)return s;const i=e(n,...r);return t.set(n,i),i}}const U=BigInt(0),D=BigInt(1),q=BigInt(2),H=BigInt(3),M=BigInt(4),V=BigInt(5),K=BigInt(8);function W(e,t){const n=e%t;return n>=U?n:t+n}function G(e,t,n){let r=e;for(;t-- >U;)r*=r,r%=n;return r}function Y(e,t){if(e===U)throw new Error("invert: expected non-zero number");if(t<=U)throw new Error("invert: expected positive modulus, got "+t);let n=W(e,t),r=t,s=U,i=D,a=D,o=U;for(;n!==U;){const e=r/n,t=r%n,d=s-a*e,u=i-o*e;r=n,n=t,s=a,i=o,a=d,o=u}if(r!==D)throw new Error("invert: does not exist");return W(s,t)}function J(e,t){const n=(e.ORDER+D)/M,r=e.pow(t,n);if(!e.eql(e.sqr(r),t))throw new Error("Cannot find square root");return r}function X(e,t){const n=(e.ORDER-V)/K,r=e.mul(t,q),s=e.pow(r,n),i=e.mul(t,s),a=e.mul(e.mul(i,q),s),o=e.mul(i,e.sub(a,e.ONE));if(!e.eql(e.sqr(o),t))throw new Error("Cannot find square root");return o}const Q=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function ee(e,t,n=!1){const r=new Array(t.length).fill(n?e.ZERO:void 0),s=t.reduce((t,n,s)=>e.is0(n)?t:(r[s]=t,e.mul(t,n)),e.ONE),i=e.inv(s);return t.reduceRight((t,n,s)=>e.is0(n)?t:(r[s]=e.mul(t,r[s]),e.mul(t,n)),i),r}function te(e,t){const n=(e.ORDER-D)/q,r=e.pow(t,n),s=e.eql(r,e.ONE),i=e.eql(r,e.ZERO),a=e.eql(r,e.neg(e.ONE));if(!s&&!i&&!a)throw new Error("invalid Legendre symbol result");return s?1:i?0:-1}function ne(e,t){void 0!==t&&(0,r.Fe)(t);const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function re(e,t,n=!1,r={}){if(e<=U)throw new Error("invalid field: expected ORDER > 0, got "+e);const{nBitLength:s,nByteLength:i}=ne(e,t);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let a;const o=Object.freeze({ORDER:e,isLE:n,BITS:s,BYTES:i,MASK:z(s),ZERO:U,ONE:D,create:t=>W(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("invalid field element: expected bigint, got "+typeof t);return U<=t&&t<e},is0:e=>e===U,isOdd:e=>(e&D)===D,neg:t=>W(-t,e),eql:(e,t)=>e===t,sqr:t=>W(t*t,e),add:(t,n)=>W(t+n,e),sub:(t,n)=>W(t-n,e),mul:(t,n)=>W(t*n,e),pow:(e,t)=>function(e,t,n){if(n<U)throw new Error("invalid exponent, negatives unsupported");if(n===U)return e.ONE;if(n===D)return t;let r=e.ONE,s=t;for(;n>U;)n&D&&(r=e.mul(r,s)),s=e.sqr(s),n>>=D;return r}(o,e,t),div:(t,n)=>W(t*Y(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>Y(t,e),sqrt:r.sqrt||(t=>{return a||(a=(n=e)%M===H?J:n%K===V?X:function(e){if(e<BigInt(3))throw new Error("sqrt is not defined for small field");let t=e-D,n=0;for(;t%q===U;)t/=q,n++;let r=q;const s=re(e);for(;1===te(s,r);)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===n)return J;let i=s.pow(r,t);const a=(t+D)/q;return function(e,r){if(e.is0(r))return r;if(1!==te(e,r))throw new Error("Cannot find square root");let s=n,o=e.mul(e.ONE,i),d=e.pow(r,t),u=e.pow(r,a);for(;!e.eql(d,e.ONE);){if(e.is0(d))return e.ZERO;let t=1,n=e.sqr(d);for(;!e.eql(n,e.ONE);)if(t++,n=e.sqr(n),t===s)throw new Error("Cannot find square root");const r=D<<BigInt(s-t-1),i=e.pow(o,r);s=t,o=e.sqr(i),d=e.mul(d,o),u=e.mul(u,i)}return u}}(n)),a(o,t);var n}),toBytes:e=>n?C(e,i):I(e,i),fromBytes:e=>{if(e.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+e.length);return n?S(e):A(e)},invertBatch:e=>ee(o,e),cmov:(e,t,n)=>n?t:e});return Object.freeze(o)}function se(e){if("bigint"!=typeof e)throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function ie(e){const t=se(e);return t+Math.ceil(t/2)}const ae=BigInt(0),oe=BigInt(1);function de(e,t){const n=t.negate();return e?n:t}function ue(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function ce(e,t){ue(e,t);const n=2**e;return{windows:Math.ceil(t/e)+1,windowSize:2**(e-1),mask:z(e),maxNumber:n,shiftBy:BigInt(e)}}function le(e,t,n){const{windowSize:r,mask:s,maxNumber:i,shiftBy:a}=n;let o=Number(e&s),d=e>>a;o>r&&(o-=i,d+=oe);const u=t*r;return{nextN:d,offset:u+Math.abs(o)-1,isZero:0===o,isNeg:o<0,isNegF:t%2!=0,offsetF:u}}const he=new WeakMap,fe=new WeakMap;function pe(e){return fe.get(e)||1}function me(e,t,n,r){(function(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach((e,n)=>{if(!(e instanceof t))throw new Error("invalid point at index "+n)})})(n,e),function(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)})}(r,t);const s=n.length,i=r.length;if(s!==i)throw new Error("arrays of points and scalars must have equal length");const a=e.ZERO,o=function(e){let t;for(t=0;e>p;e>>=m,t+=1);return t}(BigInt(s));let d=1;o>12?d=o-3:o>4?d=o-2:o>0&&(d=2);const u=z(d),c=new Array(Number(u)+1).fill(a);let l=a;for(let e=Math.floor((t.BITS-1)/d)*d;e>=0;e-=d){c.fill(a);for(let t=0;t<i;t++){const s=r[t],i=Number(s>>BigInt(e)&u);c[i]=c[i].add(n[t])}let t=a;for(let e=c.length-1,n=a;e>0;e--)n=n.add(c[e]),t=t.add(n);if(l=l.add(t),0!==e)for(let e=0;e<d;e++)l=l.double()}return l}function ge(e){return L(e.Fp,Q.reduce((e,t)=>(e[t]="function",e),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"})),L(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...ne(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}function ye(e){void 0!==e.lowS&&v("lowS",e.lowS),void 0!==e.prehash&&v("prehash",e.prehash)}class ve extends Error{constructor(e=""){super(e)}}const we={Err:ve,_tlv:{encode:(e,t)=>{const{Err:n}=we;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(1&t.length)throw new n("tlv.encode: unpadded data");const r=t.length/2,s=w(r);if(s.length/2&128)throw new n("tlv.encode: long form length too big");const i=r>127?w(s.length/2|128):"";return w(e)+i+s+t},decode(e,t){const{Err:n}=we;let r=0;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length<2||t[r++]!==e)throw new n("tlv.decode: wrong tlv");const s=t[r++];let i=0;if(128&s){const e=127&s;if(!e)throw new n("tlv.decode(long): indefinite length not supported");if(e>4)throw new n("tlv.decode(long): byte length is too big");const a=t.subarray(r,r+e);if(a.length!==e)throw new n("tlv.decode: length bytes not complete");if(0===a[0])throw new n("tlv.decode(long): zero leftmost byte");for(const e of a)i=i<<8|e;if(r+=e,i<128)throw new n("tlv.decode(long): not minimal encoding")}else i=s;const a=t.subarray(r,r+i);if(a.length!==i)throw new n("tlv.decode: wrong value length");return{v:a,l:t.subarray(r+i)}}},_int:{encode(e){const{Err:t}=we;if(e<be)throw new t("integer: negative integers are not allowed");let n=w(e);if(8&Number.parseInt(n[0],16)&&(n="00"+n),1&n.length)throw new t("unexpected DER parsing assertion: unpadded hex");return n},decode(e){const{Err:t}=we;if(128&e[0])throw new t("invalid signature integer: negative");if(0===e[0]&&!(128&e[1]))throw new t("invalid signature integer: unnecessary leading zero");return A(e)}},toSig(e){const{Err:t,_int:n,_tlv:r}=we,s=N("signature",e),{v:i,l:a}=r.decode(48,s);if(a.length)throw new t("invalid signature: left bytes after parsing");const{v:o,l:d}=r.decode(2,i),{v:u,l:c}=r.decode(2,d);if(c.length)throw new t("invalid signature: left bytes after parsing");return{r:n.decode(o),s:n.decode(u)}},hexFromSig(e){const{_tlv:t,_int:n}=we,r=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,r)}};function _e(e,t){return k(I(e,t))}const be=BigInt(0),xe=BigInt(1),ke=(BigInt(2),BigInt(3)),Ee=BigInt(4);function Oe(e){const t=function(e){const t=ge(e);return L(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}(e),{Fp:n,n:r,nByteLength:s,nBitLength:i}=t,a=n.BYTES+1,o=2*n.BYTES+1;function d(e){return W(e,r)}function u(e){return Y(e,r)}const{ProjectivePoint:c,normPrivateKeyToScalar:l,weierstrassEquation:h,isWithinCurveOrder:f}=function(e){const t=function(e){const t=ge(e);L(t,{a:"field",b:"field"},{allowInfinityPoint:"boolean",allowedPrivateKeyLengths:"array",clearCofactor:"function",fromBytes:"function",isTorsionFree:"function",toBytes:"function",wrapPrivateKey:"boolean"});const{endo:n,Fp:r,a:s}=t;if(n){if(!r.eql(s,r.ZERO))throw new Error("invalid endo: CURVE.a must be 0");if("object"!=typeof n||"bigint"!=typeof n.beta||"function"!=typeof n.splitScalar)throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function')}return Object.freeze({...t})}(e),{Fp:n}=t,r=re(t.n,t.nBitLength),s=t.toBytes||((e,t,r)=>{const s=t.toAffine();return B(Uint8Array.from([4]),n.toBytes(s.x),n.toBytes(s.y))}),i=t.fromBytes||(e=>{const t=e.subarray(1);return{x:n.fromBytes(t.subarray(0,n.BYTES)),y:n.fromBytes(t.subarray(n.BYTES,2*n.BYTES))}});function a(e){const{a:r,b:s}=t,i=n.sqr(e),a=n.mul(i,e);return n.add(n.add(a,n.mul(e,r)),s)}function o(e,t){const r=n.sqr(t),s=a(e);return n.eql(r,s)}if(!o(t.Gx,t.Gy))throw new Error("bad curve params: generator point");const d=n.mul(n.pow(t.a,ke),Ee),u=n.mul(n.sqr(t.b),BigInt(27));if(n.is0(n.add(d,u)))throw new Error("bad curve params: a or b");function c(e){const{allowedPrivateKeyLengths:n,nByteLength:r,wrapPrivateKey:s,n:i}=t;if(n&&"bigint"!=typeof e){if(g(e)&&(e=k(e)),"string"!=typeof e||!n.includes(e.length))throw new Error("invalid private key");e=e.padStart(2*r,"0")}let a;try{a="bigint"==typeof e?e:A(N("private key",e,r))}catch(t){throw new Error("invalid private key, expected hex or "+r+" bytes, got "+typeof e)}return s&&(a=W(a,i)),R("private key",a,xe,i),a}function l(e){if(!(e instanceof p))throw new Error("ProjectivePoint expected")}const h=F((e,t)=>{const{px:r,py:s,pz:i}=e;if(n.eql(i,n.ONE))return{x:r,y:s};const a=e.is0();null==t&&(t=a?n.ONE:n.inv(i));const o=n.mul(r,t),d=n.mul(s,t),u=n.mul(i,t);if(a)return{x:n.ZERO,y:n.ZERO};if(!n.eql(u,n.ONE))throw new Error("invZ was invalid");return{x:o,y:d}}),f=F(e=>{if(e.is0()){if(t.allowInfinityPoint&&!n.is0(e.py))return;throw new Error("bad point: ZERO")}const{x:r,y:s}=e.toAffine();if(!n.isValid(r)||!n.isValid(s))throw new Error("bad point: x or y not FE");if(!o(r,s))throw new Error("bad point: equation left != right");if(!e.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class p{constructor(e,t,r){if(null==e||!n.isValid(e))throw new Error("x required");if(null==t||!n.isValid(t)||n.is0(t))throw new Error("y required");if(null==r||!n.isValid(r))throw new Error("z required");this.px=e,this.py=t,this.pz=r,Object.freeze(this)}static fromAffine(e){const{x:t,y:r}=e||{};if(!e||!n.isValid(t)||!n.isValid(r))throw new Error("invalid affine point");if(e instanceof p)throw new Error("projective point not allowed");const s=e=>n.eql(e,n.ZERO);return s(t)&&s(r)?p.ZERO:new p(t,r,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){const t=ee(n,e.map(e=>e.pz));return e.map((e,n)=>e.toAffine(t[n])).map(p.fromAffine)}static fromHex(e){const t=p.fromAffine(i(N("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return p.BASE.multiply(c(e))}static msm(e,t){return me(p,r,e,t)}_setWindowSize(e){w.setWindowSize(this,e)}assertValidity(){f(this)}hasEvenY(){const{y:e}=this.toAffine();if(n.isOdd)return!n.isOdd(e);throw new Error("Field doesn't support isOdd")}equals(e){l(e);const{px:t,py:r,pz:s}=this,{px:i,py:a,pz:o}=e,d=n.eql(n.mul(t,o),n.mul(i,s)),u=n.eql(n.mul(r,o),n.mul(a,s));return d&&u}negate(){return new p(this.px,n.neg(this.py),this.pz)}double(){const{a:e,b:r}=t,s=n.mul(r,ke),{px:i,py:a,pz:o}=this;let d=n.ZERO,u=n.ZERO,c=n.ZERO,l=n.mul(i,i),h=n.mul(a,a),f=n.mul(o,o),m=n.mul(i,a);return m=n.add(m,m),c=n.mul(i,o),c=n.add(c,c),d=n.mul(e,c),u=n.mul(s,f),u=n.add(d,u),d=n.sub(h,u),u=n.add(h,u),u=n.mul(d,u),d=n.mul(m,d),c=n.mul(s,c),f=n.mul(e,f),m=n.sub(l,f),m=n.mul(e,m),m=n.add(m,c),c=n.add(l,l),l=n.add(c,l),l=n.add(l,f),l=n.mul(l,m),u=n.add(u,l),f=n.mul(a,o),f=n.add(f,f),l=n.mul(f,m),d=n.sub(d,l),c=n.mul(f,h),c=n.add(c,c),c=n.add(c,c),new p(d,u,c)}add(e){l(e);const{px:r,py:s,pz:i}=this,{px:a,py:o,pz:d}=e;let u=n.ZERO,c=n.ZERO,h=n.ZERO;const f=t.a,m=n.mul(t.b,ke);let g=n.mul(r,a),y=n.mul(s,o),v=n.mul(i,d),w=n.add(r,s),_=n.add(a,o);w=n.mul(w,_),_=n.add(g,y),w=n.sub(w,_),_=n.add(r,i);let b=n.add(a,d);return _=n.mul(_,b),b=n.add(g,v),_=n.sub(_,b),b=n.add(s,i),u=n.add(o,d),b=n.mul(b,u),u=n.add(y,v),b=n.sub(b,u),h=n.mul(f,_),u=n.mul(m,v),h=n.add(u,h),u=n.sub(y,h),h=n.add(y,h),c=n.mul(u,h),y=n.add(g,g),y=n.add(y,g),v=n.mul(f,v),_=n.mul(m,_),y=n.add(y,v),v=n.sub(g,v),v=n.mul(f,v),_=n.add(_,v),g=n.mul(y,_),c=n.add(c,g),g=n.mul(b,_),u=n.mul(w,u),u=n.sub(u,g),g=n.mul(w,y),h=n.mul(b,h),h=n.add(h,g),new p(u,c,h)}subtract(e){return this.add(e.negate())}is0(){return this.equals(p.ZERO)}wNAF(e){return w.wNAFCached(this,e,p.normalizeZ)}multiplyUnsafe(e){const{endo:r,n:s}=t;R("scalar",e,be,s);const i=p.ZERO;if(e===be)return i;if(this.is0()||e===xe)return this;if(!r||w.hasPrecomputes(this))return w.wNAFCachedUnsafe(this,e,p.normalizeZ);let{k1neg:a,k1:o,k2neg:d,k2:u}=r.splitScalar(e),c=i,l=i,h=this;for(;o>be||u>be;)o&xe&&(c=c.add(h)),u&xe&&(l=l.add(h)),h=h.double(),o>>=xe,u>>=xe;return a&&(c=c.negate()),d&&(l=l.negate()),l=new p(n.mul(l.px,r.beta),l.py,l.pz),c.add(l)}multiply(e){const{endo:r,n:s}=t;let i,a;if(R("scalar",e,xe,s),r){const{k1neg:t,k1:s,k2neg:o,k2:d}=r.splitScalar(e);let{p:u,f:c}=this.wNAF(s),{p:l,f:h}=this.wNAF(d);u=w.constTimeNegate(t,u),l=w.constTimeNegate(o,l),l=new p(n.mul(l.px,r.beta),l.py,l.pz),i=u.add(l),a=c.add(h)}else{const{p:t,f:n}=this.wNAF(e);i=t,a=n}return p.normalizeZ([i,a])[0]}multiplyAndAddUnsafe(e,t,n){const r=p.BASE,s=(e,t)=>t!==be&&t!==xe&&e.equals(r)?e.multiply(t):e.multiplyUnsafe(t),i=s(this,t).add(s(e,n));return i.is0()?void 0:i}toAffine(e){return h(this,e)}isTorsionFree(){const{h:e,isTorsionFree:n}=t;if(e===xe)return!0;if(n)return n(p,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:e,clearCofactor:n}=t;return e===xe?this:n?n(p,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return v("isCompressed",e),this.assertValidity(),s(p,this,e)}toHex(e=!0){return v("isCompressed",e),k(this.toRawBytes(e))}}p.BASE=new p(t.Gx,t.Gy,n.ONE),p.ZERO=new p(n.ZERO,n.ONE,n.ZERO);const{endo:m,nBitLength:y}=t,w=(_=p,b=m?Math.ceil(y/2):y,{constTimeNegate:de,hasPrecomputes:e=>1!==pe(e),unsafeLadder(e,t,n=_.ZERO){let r=e;for(;t>ae;)t&oe&&(n=n.add(r)),r=r.double(),t>>=oe;return n},precomputeWindow(e,t){const{windows:n,windowSize:r}=ce(t,b),s=[];let i=e,a=i;for(let e=0;e<n;e++){a=i,s.push(a);for(let e=1;e<r;e++)a=a.add(i),s.push(a);i=a.double()}return s},wNAF(e,t,n){let r=_.ZERO,s=_.BASE;const i=ce(e,b);for(let e=0;e<i.windows;e++){const{nextN:a,offset:o,isZero:d,isNeg:u,isNegF:c,offsetF:l}=le(n,e,i);n=a,d?s=s.add(de(c,t[l])):r=r.add(de(u,t[o]))}return{p:r,f:s}},wNAFUnsafe(e,t,n,r=_.ZERO){const s=ce(e,b);for(let e=0;e<s.windows&&n!==ae;e++){const{nextN:i,offset:a,isZero:o,isNeg:d}=le(n,e,s);if(n=i,!o){const e=t[a];r=r.add(d?e.negate():e)}}return r},getPrecomputes(e,t,n){let r=he.get(t);return r||(r=this.precomputeWindow(t,e),1!==e&&he.set(t,n(r))),r},wNAFCached(e,t,n){const r=pe(e);return this.wNAF(r,this.getPrecomputes(r,e,n),t)},wNAFCachedUnsafe(e,t,n,r){const s=pe(e);return 1===s?this.unsafeLadder(e,t,r):this.wNAFUnsafe(s,this.getPrecomputes(s,e,n),t,r)},setWindowSize(e,t){ue(t,b),fe.set(e,t),he.delete(e)}});var _,b;return{CURVE:t,ProjectivePoint:p,normPrivateKeyToScalar:c,weierstrassEquation:a,isWithinCurveOrder:function(e){return T(e,xe,t.n)}}}({...t,toBytes(e,t,r){const s=t.toAffine(),i=n.toBytes(s.x),a=B;return v("isCompressed",r),r?a(Uint8Array.from([t.hasEvenY()?2:3]),i):a(Uint8Array.from([4]),i,n.toBytes(s.y))},fromBytes(e){const t=e.length,r=e[0],s=e.subarray(1);if(t!==a||2!==r&&3!==r){if(t===o&&4===r)return{x:n.fromBytes(s.subarray(0,n.BYTES)),y:n.fromBytes(s.subarray(n.BYTES,2*n.BYTES))};throw new Error("invalid Point, expected length of "+a+", or uncompressed "+o+", got "+t)}{const e=A(s);if(!T(e,xe,n.ORDER))throw new Error("Point is not on curve");const t=h(e);let i;try{i=n.sqrt(t)}catch(e){const t=e instanceof Error?": "+e.message:"";throw new Error("Point is not on curve"+t)}return!(1&~r)!=((i&xe)===xe)&&(i=n.neg(i)),{x:e,y:i}}}});function p(e){return e>r>>xe}const m=(e,t,n)=>A(e.slice(t,n));class y{constructor(e,t,n){R("r",e,xe,r),R("s",t,xe,r),this.r=e,this.s=t,null!=n&&(this.recovery=n),Object.freeze(this)}static fromCompact(e){const t=s;return e=N("compactSignature",e,2*t),new y(m(e,0,t),m(e,t,2*t))}static fromDER(e){const{r:t,s:n}=we.toSig(N("DER",e));return new y(t,n)}assertValidity(){}addRecoveryBit(e){return new y(this.r,this.s,e)}recoverPublicKey(e){const{r,s,recovery:i}=this,a=x(N("msgHash",e));if(null==i||![0,1,2,3].includes(i))throw new Error("recovery id invalid");const o=2===i||3===i?r+t.n:r;if(o>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const l=1&i?"03":"02",h=c.fromHex(l+_e(o,n.BYTES)),f=u(o),p=d(-a*f),m=d(s*f),g=c.BASE.multiplyAndAddUnsafe(h,p,m);if(!g)throw new Error("point at infinify");return g.assertValidity(),g}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new y(this.r,d(-this.s),this.recovery):this}toDERRawBytes(){return O(this.toDERHex())}toDERHex(){return we.hexFromSig(this)}toCompactRawBytes(){return O(this.toCompactHex())}toCompactHex(){const e=s;return _e(this.r,e)+_e(this.s,e)}}const w={isValidPrivateKey(e){try{return l(e),!0}catch(e){return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{const e=ie(t.n);return function(e,t,n=!1){const r=e.length,s=se(t),i=ie(t);if(r<16||r<i||r>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+r);const a=W(n?S(e):A(e),t-D)+D;return n?C(a,s):I(a,s)}(t.randomBytes(e),t.n)},precompute:(e=8,t=c.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)};function _(e){if("bigint"==typeof e)return!1;if(e instanceof c)return!0;const r=N("key",e).length,i=n.BYTES,a=i+1,o=2*i+1;return t.allowedPrivateKeyLengths||s===a?void 0:r===a||r===o}const b=t.bits2int||function(e){if(e.length>8192)throw new Error("input is too large");const t=A(e),n=8*e.length-i;return n>0?t>>BigInt(n):t},x=t.bits2int_modN||function(e){return d(b(e))},E=z(i);function Z(e){return R("num < 2^"+i,e,be,E),I(e,s)}const P={lowS:t.lowS,prehash:!1},U={lowS:t.lowS,prehash:!1};return c.BASE._setWindowSize(8),{CURVE:t,getPublicKey:function(e,t=!0){return c.fromPrivateKey(e).toRawBytes(t)},getSharedSecret:function(e,t,n=!0){if(!0===_(e))throw new Error("first arg must be private key");if(!1===_(t))throw new Error("second arg must be public key");return c.fromHex(t).multiply(l(e)).toRawBytes(n)},sign:function(e,r,s=P){const{seed:i,k2sig:a}=function(e,r,s=P){if(["recovered","canonical"].some(e=>e in s))throw new Error("sign() legacy options not supported");const{hash:i,randomBytes:a}=t;let{lowS:o,prehash:h,extraEntropy:m}=s;null==o&&(o=!0),e=N("msgHash",e),ye(s),h&&(e=N("prehashed msgHash",i(e)));const g=x(e),v=l(r),w=[Z(v),Z(g)];if(null!=m&&!1!==m){const e=!0===m?a(n.BYTES):m;w.push(N("extraEntropy",e))}const _=B(...w),k=g;return{seed:_,k2sig:function(e){const t=b(e);if(!f(t))return;const n=u(t),r=c.BASE.multiply(t).toAffine(),s=d(r.x);if(s===be)return;const i=d(n*d(k+s*v));if(i===be)return;let a=(r.x===s?0:2)|Number(r.y&xe),l=i;return o&&p(i)&&(l=function(e){return p(e)?d(-e):e}(i),a^=1),new y(s,l,a)}}}(e,r,s),o=t,h=function(e,t,n){if("number"!=typeof e||e<2)throw new Error("hashLen must be a number");if("number"!=typeof t||t<2)throw new Error("qByteLen must be a number");if("function"!=typeof n)throw new Error("hmacFn must be a function");let r=j(e),s=j(e),i=0;const a=()=>{r.fill(1),s.fill(0),i=0},o=(...e)=>n(s,r,...e),d=(e=j(0))=>{s=o($([0]),e),r=o(),0!==e.length&&(s=o($([1]),e),r=o())},u=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const n=[];for(;e<t;){r=o();const t=r.slice();n.push(t),e+=r.length}return B(...n)};return(e,t)=>{let n;for(a(),d(e);!(n=t(u()));)d();return a(),n}}(o.hash.outputLen,o.nByteLength,o.hmac);return h(i,a)},verify:function(e,n,r,s=U){const i=e;n=N("msgHash",n),r=N("publicKey",r);const{lowS:a,prehash:o,format:l}=s;if(ye(s),"strict"in s)throw new Error("options.strict was renamed to lowS");if(void 0!==l&&"compact"!==l&&"der"!==l)throw new Error("format must be compact or der");const h="string"==typeof i||g(i),f=!h&&!l&&"object"==typeof i&&null!==i&&"bigint"==typeof i.r&&"bigint"==typeof i.s;if(!h&&!f)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let p,m;try{if(f&&(p=new y(i.r,i.s)),h){try{"compact"!==l&&(p=y.fromDER(i))}catch(e){if(!(e instanceof we.Err))throw e}p||"der"===l||(p=y.fromCompact(i))}m=c.fromHex(r)}catch(e){return!1}if(!p)return!1;if(a&&p.hasHighS())return!1;o&&(n=t.hash(n));const{r:v,s:w}=p,_=x(n),b=u(w),k=d(_*b),E=d(v*b),O=c.BASE.multiplyAndAddUnsafe(m,k,E)?.toAffine();return!!O&&d(O.x)===v},ProjectivePoint:c,Signature:y,utils:w}}function Ae(e){return{hash:e,hmac:(t,...n)=>f(e,t,(0,r.Id)(...n)),randomBytes:r.po}}const Se=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Ie=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Ce=BigInt(0),Ne=BigInt(1),Be=BigInt(2),Ze=(e,t)=>(e+t/Be)/t;const Te=re(Se,void 0,void 0,{sqrt:function(e){const t=Se,n=BigInt(3),r=BigInt(6),s=BigInt(11),i=BigInt(22),a=BigInt(23),o=BigInt(44),d=BigInt(88),u=e*e*e%t,c=u*u*e%t,l=G(c,n,t)*c%t,h=G(l,n,t)*c%t,f=G(h,Be,t)*u%t,p=G(f,s,t)*f%t,m=G(p,i,t)*p%t,g=G(m,o,t)*m%t,y=G(g,d,t)*g%t,v=G(y,o,t)*m%t,w=G(v,n,t)*c%t,_=G(w,a,t)*p%t,b=G(_,r,t)*u%t,x=G(b,Be,t);if(!Te.eql(Te.sqr(x),e))throw new Error("Cannot find square root");return x}}),Re=function(e,t){const n=t=>Oe({...e,...Ae(t)});return{...n(t),create:n}}({a:Ce,b:BigInt(7),Fp:Te,n:Ie,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=Ie,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-Ne*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=n,a=BigInt("0x100000000000000000000000000000000"),o=Ze(i*e,t),d=Ze(-r*e,t);let u=W(e-o*n-d*s,t),c=W(-o*r-d*i,t);const l=u>a,h=c>a;if(l&&(u=t-u),h&&(c=t-c),u>a||c>a)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:l,k1:u,k2neg:h,k2:c}}}},l)}},n={};function r(e){var s=n[e];if(void 0!==s)return s.exports;var i=n[e]={exports:{}};return t[e](i,i.exports,r),i.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);const s="2.45.1";let i=({docsBaseUrl:e,docsPath:t="",docsSlug:n})=>t?`${e??"https://viem.sh"}${t}${n?`#${n}`:""}`:void 0,a=`viem@${s}`;class o extends Error{constructor(e,t={}){const n=t.cause instanceof o?t.cause.details:t.cause?.message?t.cause.message:t.details,r=t.cause instanceof o&&t.cause.docsPath||t.docsPath,d=i?.({...t,docsPath:r});super([e||"An error occurred.","",...t.metaMessages?[...t.metaMessages,""]:[],...d?[`Docs: ${d}`]:[],...n?[`Details: ${n}`]:[],...a?[`Version: ${a}`]:[]].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=n,this.docsPath=r,this.metaMessages=t.metaMessages,this.name=t.name??this.name,this.shortMessage=e,this.version=s}walk(e){return d(this,e)}}function d(e,t){return t?.(e)?e:e&&"object"==typeof e&&"cause"in e&&void 0!==e.cause?d(e.cause,t):t?null:e}class u extends o{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"})}}function c(e,{strict:t=!0}={}){return!!e&&"string"==typeof e&&(t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x"))}class l extends o{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${e}) exceeds padding size (${t}).`,{name:"SizeExceedsPaddingSizeError"})}}function h(e,{dir:t,size:n=32}={}){return"string"==typeof e?function(e,{dir:t,size:n=32}={}){if(null===n)return e;const r=e.replace("0x","");if(r.length>2*n)throw new l({size:Math.ceil(r.length/2),targetSize:n,type:"hex"});return`0x${r["right"===t?"padEnd":"padStart"](2*n,"0")}`}(e,{dir:t,size:n}):function(e,{dir:t,size:n=32}={}){if(null===n)return e;if(e.length>n)throw new l({size:e.length,targetSize:n,type:"bytes"});const r=new Uint8Array(n);for(let s=0;s<n;s++){const i="right"===t;r[i?s:n-s-1]=e[i?s:e.length-s-1]}return r}(e,{dir:t,size:n})}class f extends o{constructor({max:e,min:t,signed:n,size:r,value:s}){super(`Number "${s}" is not in safe ${r?`${8*r}-bit ${n?"signed":"unsigned"} `:""}integer range ${e?`(${t} to ${e})`:`(above ${t})`}`,{name:"IntegerOutOfRangeError"})}}class p extends o{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed ${t} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function m(e){return c(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}function g(e,{size:t}){if(m(e)>t)throw new p({givenSize:m(e),maxSize:t})}function y(e,t={}){const{signed:n}=t;t.size&&g(e,{size:t.size});const r=BigInt(e);if(!n)return r;const s=(e.length-2)/2;return r<=(1n<<8n*BigInt(s)-1n)-1n?r:r-BigInt(`0x${"f".padStart(2*s,"f")}`)-1n}const v=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function w(e,t={}){return"number"==typeof e||"bigint"==typeof e?b(e,t):"string"==typeof e?k(e,t):"boolean"==typeof e?function(e,t={}){const n=`0x${Number(e)}`;return"number"==typeof t.size?(g(n,{size:t.size}),h(n,{size:t.size})):n}(e,t):_(e,t)}function _(e,t={}){let n="";for(let t=0;t<e.length;t++)n+=v[e[t]];const r=`0x${n}`;return"number"==typeof t.size?(g(r,{size:t.size}),h(r,{dir:"right",size:t.size})):r}function b(e,t={}){const{signed:n,size:r}=t,s=BigInt(e);let i;r?i=n?(1n<<8n*BigInt(r)-1n)-1n:2n**(8n*BigInt(r))-1n:"number"==typeof e&&(i=BigInt(Number.MAX_SAFE_INTEGER));const a="bigint"==typeof i&&n?-i-1n:0;if(i&&s>i||s<a){const t="bigint"==typeof e?"n":"";throw new f({max:i?`${i}${t}`:void 0,min:`${a}${t}`,signed:n,size:r,value:`${e}${t}`})}const o=`0x${(n&&s<0?(1n<<BigInt(8*r))+BigInt(s):s).toString(16)}`;return r?h(o,{size:r}):o}const x=new TextEncoder;function k(e,t={}){return _(x.encode(e),t)}const E=new TextEncoder;const O={zero:48,nine:57,A:65,F:70,a:97,f:102};function A(e){return e>=O.zero&&e<=O.nine?e-O.zero:e>=O.A&&e<=O.F?e-(O.A-10):e>=O.a&&e<=O.f?e-(O.a-10):void 0}function S(e,t={}){let n=e;t.size&&(g(n,{size:t.size}),n=h(n,{dir:"right",size:t.size}));let r=n.slice(2);r.length%2&&(r=`0${r}`);const s=r.length/2,i=new Uint8Array(s);for(let e=0,t=0;e<s;e++){const n=A(r.charCodeAt(t++)),s=A(r.charCodeAt(t++));if(void 0===n||void 0===s)throw new o(`Invalid byte sequence ("${r[t-2]}${r[t-1]}" in "${r}").`);i[e]=16*n+s}return i}function I(e,t={}){const n=E.encode(e);return"number"==typeof t.size?(g(n,{size:t.size}),h(n,{dir:"right",size:t.size})):n}var C=r(964),N=r(657);const B=BigInt(0),Z=BigInt(1),T=BigInt(2),R=BigInt(7),z=BigInt(256),j=BigInt(113),$=[],P=[],L=[];for(let e=0,t=Z,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],$.push(2*(5*r+n)),P.push((e+1)*(e+2)/2%64);let s=B;for(let e=0;e<7;e++)t=(t<<Z^(t>>R)*j)%z,t&T&&(s^=Z<<(Z<<BigInt(e))-Z);L.push(s)}const F=(0,C.lD)(L,!0),U=F[0],D=F[1],q=(e,t,n)=>n>32?(0,C.WM)(e,t,n):(0,C.P5)(e,t,n),H=(e,t,n)=>n>32?(0,C.im)(e,t,n):(0,C.B4)(e,t,n);class M extends N.Vw{constructor(e,t,n,r=!1,s=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=r,this.rounds=s,(0,N.Fe)(n),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=(0,N.DH)(this.state)}clone(){return this._cloneInto()}keccak(){(0,N.fd)(this.state32),function(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let t=0;t<10;t++)n[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){const r=(t+8)%10,s=(t+2)%10,i=n[s],a=n[s+1],o=q(i,a,1)^n[r],d=H(i,a,1)^n[r+1];for(let n=0;n<50;n+=10)e[t+n]^=o,e[t+n+1]^=d}let t=e[2],s=e[3];for(let n=0;n<24;n++){const r=P[n],i=q(t,s,r),a=H(t,s,r),o=$[n];t=e[o],s=e[o+1],e[o]=i,e[o+1]=a}for(let t=0;t<50;t+=10){for(let r=0;r<10;r++)n[r]=e[t+r];for(let r=0;r<10;r++)e[t+r]^=~n[(r+2)%10]&n[(r+4)%10]}e[0]^=U[r],e[1]^=D[r]}(0,N.uH)(n)}(this.state32,this.rounds),(0,N.fd)(this.state32),this.posOut=0,this.pos=0}update(e){(0,N.CC)(this),e=(0,N.ZJ)(e),(0,N.DO)(e);const{blockLen:t,state:n}=this,r=e.length;for(let s=0;s<r;){const i=Math.min(t-this.pos,r-s);for(let t=0;t<i;t++)n[this.pos++]^=e[s++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:n,blockLen:r}=this;e[n]^=t,128&t&&n===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){(0,N.CC)(this,!1),(0,N.DO)(e),this.finish();const t=this.state,{blockLen:n}=this;for(let r=0,s=e.length;r<s;){this.posOut>=n&&this.keccak();const i=Math.min(n-this.posOut,s-r);e.set(t.subarray(this.posOut,this.posOut+i),r),this.posOut+=i,r+=i}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return(0,N.Fe)(e),this.xofInto(new Uint8Array(e))}digestInto(e){if((0,N.Ht)(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,(0,N.uH)(this.state)}_cloneInto(e){const{blockLen:t,suffix:n,outputLen:r,rounds:s,enableXOF:i}=this;return e||(e=new M(t,n,r,i,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=n,e.outputLen=r,e.enableXOF=i,e.destroyed=this.destroyed,e}}const V=(()=>{return e=1,t=136,n=32,(0,N.qj)(()=>new M(t,e,n));var e,t,n})();function K(e,t){const n=t||"hex",r=V(c(e,{strict:!1})?function(e,t={}){return"number"==typeof e||"bigint"==typeof e?function(e,t){return S(b(e,t))}(e,t):"boolean"==typeof e?function(e,t={}){const n=new Uint8Array(1);return n[0]=Number(e),"number"==typeof t.size?(g(n,{size:t.size}),h(n,{size:t.size})):n}(e,t):c(e)?S(e,t):I(e,t)}(e):e);return"bytes"===n?r:w(r)}class W extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const 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){const e=this.keys().next().value;e&&this.delete(e)}return this}}const G=/^0x[a-fA-F0-9]{40}$/,Y=new W(8192);function J(e,t){const{strict:n=!0}=t??{},r=`${e}.${n}`;if(Y.has(r))return Y.get(r);const s=!(!G.test(e)||e.toLowerCase()!==e&&n&&Q(e)!==e);return Y.set(r,s),s}const X=new W(8192);function Q(e,t){if(X.has(`${e}.${t}`))return X.get(`${e}.${t}`);const n=t?`${t}${e.toLowerCase()}`:e.substring(2).toLowerCase(),r=K(I(n),"bytes"),s=(t?n.substring(`${t}0x`.length):n).split("");for(let e=0;e<40;e+=2)r[e>>1]>>4>=8&&s[e]&&(s[e]=s[e].toUpperCase()),(15&r[e>>1])>=8&&s[e+1]&&(s[e+1]=s[e+1].toUpperCase());const i=`0x${s.join("")}`;return X.set(`${e}.${t}`,i),i}function ee(e,t){return K(function(e){const t="string"==typeof e?k(e):"string"==typeof e.raw?e.raw:_(e.raw);return"string"==typeof(n=[k(`Ethereum Signed Message:\n${m(t)}`),t])[0]?function(e){return`0x${e.reduce((e,t)=>e+t.replace("0x",""),"")}`}(n):function(e){let t=0;for(const n of e)t+=n.length;const n=new Uint8Array(t);let r=0;for(const t of e)n.set(t,r),r+=t.length;return n}(n);var n}(e),t)}function te(e){if(0===e||1===e)return e;if(27===e)return 0;if(28===e)return 1;throw new Error("Invalid yParityOrV value")}async function ne({hash:e,signature:t}){return n=await async function({hash:e,signature:t}){const n=c(e)?e:w(e),{secp256k1:s}=await Promise.resolve().then(r.bind(r,329));return`0x${(()=>{if("object"==typeof t&&"r"in t&&"s"in t){const{r:e,s:n,v:r,yParity:i}=t,a=te(Number(i??r));return new s.Signature(y(e),y(n)).addRecoveryBit(a)}const e=c(t)?t:w(t);if(65!==m(e))throw new Error("invalid signature length");const n=te(function(e,t={}){const n=y(e,t),r=Number(n);if(!Number.isSafeInteger(r))throw new f({max:`${Number.MAX_SAFE_INTEGER}`,min:`${Number.MIN_SAFE_INTEGER}`,signed:t.signed,size:t.size,value:`${n}n`});return r}(`0x${e.slice(130)}`));return s.Signature.fromCompact(e.substring(2,130)).addRecoveryBit(n)})().recoverPublicKey(n.substring(2)).toHex(!1)}`}({hash:e,signature:t}),Q(`0x${K(`0x${n.substring(4)}`).substring(26)}`);var n}var re,se;!function(e){e.assertEqual=e=>{},e.assertIs=function(e){},e.assertNever=function(e){throw new Error},e.arrayToEnum=e=>{const t={};for(const n of e)t[n]=n;return t},e.getValidEnumValues=t=>{const n=e.objectKeys(t).filter(e=>"number"!=typeof t[t[e]]),r={};for(const e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{const t=[];for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(const n of e)if(t(n))return n},e.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&Number.isFinite(e)&&Math.floor(e)===e,e.joinValues=function(e,t=" | "){return e.map(e=>"string"==typeof e?`'${e}'`:e).join(t)},e.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t}(re||(re={})),function(e){e.mergeShapes=(e,t)=>({...e,...t})}(se||(se={}));const ie=re.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ae=e=>{switch(typeof e){case"undefined":return ie.undefined;case"string":return ie.string;case"number":return Number.isNaN(e)?ie.nan:ie.number;case"boolean":return ie.boolean;case"function":return ie.function;case"bigint":return ie.bigint;case"symbol":return ie.symbol;case"object":return Array.isArray(e)?ie.array:null===e?ie.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?ie.promise:"undefined"!=typeof Map&&e instanceof Map?ie.map:"undefined"!=typeof Set&&e instanceof Set?ie.set:"undefined"!=typeof Date&&e instanceof Date?ie.date:ie.object;default:return ie.unknown}},oe=re.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class de extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(const s of e.issues)if("invalid_union"===s.code)s.unionErrors.map(r);else if("invalid_return_type"===s.code)r(s.returnTypeError);else if("invalid_arguments"===s.code)r(s.argumentsError);else if(0===s.path.length)n._errors.push(t(s));else{let e=n,r=0;for(;r<s.path.length;){const n=s.path[r];r===s.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(s))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}static assert(e){if(!(e instanceof de))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,re.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){const t={},n=[];for(const r of this.issues)if(r.path.length>0){const n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}de.create=e=>new de(e);const ue=(e,t)=>{let n;switch(e.code){case oe.invalid_type:n=e.received===ie.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case oe.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,re.jsonStringifyReplacer)}`;break;case oe.unrecognized_keys:n=`Unrecognized key(s) in object: ${re.joinValues(e.keys,", ")}`;break;case oe.invalid_union:n="Invalid input";break;case oe.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${re.joinValues(e.options)}`;break;case oe.invalid_enum_value:n=`Invalid enum value. Expected ${re.joinValues(e.options)}, received '${e.received}'`;break;case oe.invalid_arguments:n="Invalid function arguments";break;case oe.invalid_return_type:n="Invalid function return type";break;case oe.invalid_date:n="Invalid date";break;case oe.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:re.assertNever(e.validation):n="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case oe.too_small:n="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:"number"===e.type||"bigint"===e.type?`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:"date"===e.type?`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:"Invalid input";break;case oe.too_big:n="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"bigint"===e.type?`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"date"===e.type?`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:"Invalid input";break;case oe.custom:n="Invalid input";break;case oe.invalid_intersection_types:n="Intersection results could not be merged";break;case oe.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case oe.not_finite:n="Number must be finite";break;default:n=t.defaultError,re.assertNever(e)}return{message:n}};let ce=ue;var le;!function(e){e.errToObj=e=>"string"==typeof e?{message:e}:e||{},e.toString=e=>"string"==typeof e?e:e?.message}(le||(le={}));function he(e,t){const n=ce,r=(e=>{const{data:t,path:n,errorMaps:r,issueData:s}=e,i=[...n,...s.path||[]],a={...s,path:i};if(void 0!==s.message)return{...s,path:i,message:s.message};let o="";const d=r.filter(e=>!!e).slice().reverse();for(const e of d)o=e(a,{data:t,defaultError:o}).message;return{...s,path:i,message:o}})({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===ue?void 0:ue].filter(e=>!!e)});e.common.issues.push(r)}class fe{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const r of t){if("aborted"===r.status)return pe;"dirty"===r.status&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const e of t){const t=await e.key,r=await e.value;n.push({key:t,value:r})}return fe.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const r of t){const{key:t,value:s}=r;if("aborted"===t.status)return pe;if("aborted"===s.status)return pe;"dirty"===t.status&&e.dirty(),"dirty"===s.status&&e.dirty(),"__proto__"===t.value||void 0===s.value&&!r.alwaysSet||(n[t.value]=s.value)}return{status:e.value,value:n}}}const pe=Object.freeze({status:"aborted"}),me=e=>({status:"dirty",value:e}),ge=e=>({status:"valid",value:e}),ye=e=>"aborted"===e.status,ve=e=>"dirty"===e.status,we=e=>"valid"===e.status,_e=e=>"undefined"!=typeof Promise&&e instanceof Promise;class be{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const xe=(e,t)=>{if(we(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new de(e.common.issues);return this._error=t,this._error}}};function ke(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:r,description:s}=e;if(t&&(n||r))throw new Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');return t?{errorMap:t,description:s}:{errorMap:(t,s)=>{const{message:i}=e;return"invalid_enum_value"===t.code?{message:i??s.defaultError}:void 0===s.data?{message:i??r??s.defaultError}:"invalid_type"!==t.code?{message:s.defaultError}:{message:i??n??s.defaultError}},description:s}}class Ee{get description(){return this._def.description}_getType(e){return ae(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:ae(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new fe,ctx:{common:e.parent.common,data:e.data,parsedType:ae(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(_e(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){const n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ae(e)},r=this._parseSync({data:e,path:n.path,parent:n});return xe(n,r)}"~validate"(e){const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ae(e)};if(!this["~standard"].async)try{const n=this._parseSync({data:e,path:[],parent:t});return we(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>we(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ae(e)},r=this._parse({data:e,path:n.path,parent:n}),s=await(_e(r)?r:Promise.resolve(r));return xe(n,s)}refine(e,t){const n=e=>"string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(e):t;return this._refinement((t,r)=>{const s=e(t),i=()=>r.addIssue({code:oe.custom,...n(t)});return"undefined"!=typeof Promise&&s instanceof Promise?s.then(e=>!!e||(i(),!1)):!!s||(i(),!1)})}refinement(e,t){return this._refinement((n,r)=>!!e(n)||(r.addIssue("function"==typeof t?t(n,r):t),!1))}_refinement(e){return new xt({schema:this,typeName:Bt.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return kt.create(this,this._def)}nullable(){return Et.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ot.create(this)}promise(){return bt.create(this,this._def)}or(e){return ct.create([this,e],this._def)}and(e){return ht.create(this,e,this._def)}transform(e){return new xt({...ke(this._def),schema:this,typeName:Bt.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t="function"==typeof e?e:()=>e;return new Ot({...ke(this._def),innerType:this,defaultValue:t,typeName:Bt.ZodDefault})}brand(){return new It({typeName:Bt.ZodBranded,type:this,...ke(this._def)})}catch(e){const t="function"==typeof e?e:()=>e;return new At({...ke(this._def),innerType:this,catchValue:t,typeName:Bt.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return Ct.create(this,e)}readonly(){return Nt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Oe=/^c[^\s-]{8,}$/i,Ae=/^[0-9a-z]+$/,Se=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Ie=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Ce=/^[a-z0-9_-]{21}$/i,Ne=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Be=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Ze=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let Te;const Re=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ze=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,je=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,$e=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Pe=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Le=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Fe="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Ue=new RegExp(`^${Fe}$`);function De(e){let t="[0-5]\\d";return e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`),`([01]\\d|2[0-3]):[0-5]\\d(:${t})${e.precision?"+":"?"}`}function qe(e){return new RegExp(`^${De(e)}$`)}function He(e){let t=`${Fe}T${De(e)}`;const n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function Me(e,t){return!("v4"!==t&&t||!Re.test(e))||!("v6"!==t&&t||!je.test(e))}function Ve(e,t){if(!Ne.test(e))return!1;try{const[n]=e.split(".");if(!n)return!1;const r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),s=JSON.parse(atob(r));return!("object"!=typeof s||null===s||"typ"in s&&"JWT"!==s?.typ||!s.alg||t&&s.alg!==t)}catch{return!1}}function Ke(e,t){return!("v4"!==t&&t||!ze.test(e))||!("v6"!==t&&t||!$e.test(e))}class We extends Ee{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==ie.string){const t=this._getOrReturnCtx(e);return he(t,{code:oe.invalid_type,expected:ie.string,received:t.parsedType}),pe}const t=new fe;let n;for(const r of this._def.checks)if("min"===r.kind)e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),he(n,{code:oe.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),t.dirty());else if("max"===r.kind)e.data.length>r.value&&(n=this._getOrReturnCtx(e,n),he(n,{code:oe.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),t.dirty());else if("length"===r.kind){const s=e.data.length>r.value,i=e.data.length<r.value;(s||i)&&(n=this._getOrReturnCtx(e,n),s?he(n,{code:oe.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}):i&&he(n,{code:oe.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if("email"===r.kind)Ze.test(e.data)||(n=this._getOrReturnCtx(e,n),he(n,{validation:"email",code:oe.invalid_string,message:r.message}),t.dirty());else if("emoji"===r.kind)Te||(Te=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Te.test(e.data)||(n=this._getOrReturnCtx(e,n),he(n,{validation:"emoji",code:oe.invalid_string,message:r.message}),t.dirty());else if("uuid"===r.kind)Ie.test(e.data)||(n=this._getOrReturnCtx(e,n),he(n,{validation:"uuid",code:oe.invalid_string,message:r.message}),t.dirty());else if("nanoid"===r.kind)Ce.test(e.data)||(n=this._getOrReturnCtx(e,n),he(n,{validation:"nanoid",code:oe.invalid_string,message:r.message}),t.dirty());else if("cuid"===r.kind)Oe.test(e.data)||(n=this._getOrReturnCtx(e,n),he(n,{validation:"cuid",code:oe.invalid_string,message:r.message}),t.dirty());else if("cuid2"===r.kind)Ae.test(e.data)||(n=this._getOrReturnCtx(e,n),he(n,{validation:"cuid2",code:oe.invalid_string,message:r.message}),t.dirty());else if("ulid"===r.kind)Se.test(e.data)||(n=this._getOrReturnCtx(e,n),he(n,{validation:"ulid",code:oe.invalid_string,message:r.message}),t.dirty());else if("url"===r.kind)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),he(n,{validation:"url",code:oe.invalid_string,message:r.message}),t.dirty()}else"regex"===r.kind?(r.regex.lastIndex=0,r.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),he(n,{validation:"regex",code:oe.invalid_string,message:r.message}),t.dirty())):"trim"===r.kind?e.data=e.data.trim():"includes"===r.kind?e.data.includes(r.value,r.position)||(n=this._getOrReturnCtx(e,n),he(n,{code:oe.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()):"toLowerCase"===r.kind?e.data=e.data.toLowerCase():"toUpperCase"===r.kind?e.data=e.data.toUpperCase():"startsWith"===r.kind?e.data.startsWith(r.value)||(n=this._getOrReturnCtx(e,n),he(n,{code:oe.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):"endsWith"===r.kind?e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),he(n,{code:oe.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):"datetime"===r.kind?He(r).test(e.data)||(n=this._getOrReturnCtx(e,n),he(n,{code:oe.invalid_string,validation:"datetime",message:r.message}),t.dirty()):"date"===r.kind?Ue.test(e.data)||(n=this._getOrReturnCtx(e,n),he(n,{code:oe.invalid_string,validation:"date",message:r.message}),t.dirty()):"time"===r.kind?qe(r).test(e.data)||(n=this._getOrReturnCtx(e,n),he(n,{code:oe.invalid_string,validation:"time",message:r.message}),t.dirty()):"duration"===r.kind?Be.test(e.data)||(n=this._getOrReturnCtx(e,n),he(n,{validation:"duration",code:oe.invalid_string,message:r.message}),t.dirty()):"ip"===r.kind?Me(e.data,r.version)||(n=this._getOrReturnCtx(e,n),he(n,{validation:"ip",code:oe.invalid_string,message:r.message}),t.dirty()):"jwt"===r.kind?Ve(e.data,r.alg)||(n=this._getOrReturnCtx(e,n),he(n,{validation:"jwt",code:oe.invalid_string,message:r.message}),t.dirty()):"cidr"===r.kind?Ke(e.data,r.version)||(n=this._getOrReturnCtx(e,n),he(n,{validation:"cidr",code:oe.invalid_string,message:r.message}),t.dirty()):"base64"===r.kind?Pe.test(e.data)||(n=this._getOrReturnCtx(e,n),he(n,{validation:"base64",code:oe.invalid_string,message:r.message}),t.dirty()):"base64url"===r.kind?Le.test(e.data)||(n=this._getOrReturnCtx(e,n),he(n,{validation:"base64url",code:oe.invalid_string,message:r.message}),t.dirty()):re.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:oe.invalid_string,...le.errToObj(n)})}_addCheck(e){return new We({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...le.errToObj(e)})}url(e){return this._addCheck({kind:"url",...le.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...le.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...le.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...le.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...le.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...le.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...le.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...le.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...le.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...le.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...le.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...le.errToObj(e)})}datetime(e){return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===e?.precision?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...le.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:void 0===e?.precision?null:e?.precision,...le.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...le.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...le.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...le.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...le.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...le.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...le.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...le.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...le.errToObj(t)})}nonempty(e){return this.min(1,le.errToObj(e))}trim(){return new We({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new We({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new We({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>"datetime"===e.kind)}get isDate(){return!!this._def.checks.find(e=>"date"===e.kind)}get isTime(){return!!this._def.checks.find(e=>"time"===e.kind)}get isDuration(){return!!this._def.checks.find(e=>"duration"===e.kind)}get isEmail(){return!!this._def.checks.find(e=>"email"===e.kind)}get isURL(){return!!this._def.checks.find(e=>"url"===e.kind)}get isEmoji(){return!!this._def.checks.find(e=>"emoji"===e.kind)}get isUUID(){return!!this._def.checks.find(e=>"uuid"===e.kind)}get isNANOID(){return!!this._def.checks.find(e=>"nanoid"===e.kind)}get isCUID(){return!!this._def.checks.find(e=>"cuid"===e.kind)}get isCUID2(){return!!this._def.checks.find(e=>"cuid2"===e.kind)}get isULID(){return!!this._def.checks.find(e=>"ulid"===e.kind)}get isIP(){return!!this._def.checks.find(e=>"ip"===e.kind)}get isCIDR(){return!!this._def.checks.find(e=>"cidr"===e.kind)}get isBase64(){return!!this._def.checks.find(e=>"base64"===e.kind)}get isBase64url(){return!!this._def.checks.find(e=>"base64url"===e.kind)}get minLength(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}function Ge(e,t){const n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,s=n>r?n:r;return Number.parseInt(e.toFixed(s).replace(".",""))%Number.parseInt(t.toFixed(s).replace(".",""))/10**s}We.create=e=>new We({checks:[],typeName:Bt.ZodString,coerce:e?.coerce??!1,...ke(e)});class Ye extends Ee{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==ie.number){const t=this._getOrReturnCtx(e);return he(t,{code:oe.invalid_type,expected:ie.number,received:t.parsedType}),pe}let t;const n=new fe;for(const r of this._def.checks)"int"===r.kind?re.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),he(t,{code:oe.invalid_type,expected:"integer",received:"float",message:r.message}),n.dirty()):"min"===r.kind?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),he(t,{code:oe.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):"max"===r.kind?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),he(t,{code:oe.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):"multipleOf"===r.kind?0!==Ge(e.data,r.value)&&(t=this._getOrReturnCtx(e,t),he(t,{code:oe.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):"finite"===r.kind?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),he(t,{code:oe.not_finite,message:r.message}),n.dirty()):re.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,le.toString(t))}gt(e,t){return this.setLimit("min",e,!1,le.toString(t))}lte(e,t){return this.setLimit("max",e,!0,le.toString(t))}lt(e,t){return this.setLimit("max",e,!1,le.toString(t))}setLimit(e,t,n,r){return new Ye({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:le.toString(r)}]})}_addCheck(e){return new Ye({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:le.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:le.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:le.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:le.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:le.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:le.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:le.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:le.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:le.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>"int"===e.kind||"multipleOf"===e.kind&&re.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if("finite"===n.kind||"int"===n.kind||"multipleOf"===n.kind)return!0;"min"===n.kind?(null===t||n.value>t)&&(t=n.value):"max"===n.kind&&(null===e||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Ye.create=e=>new Ye({checks:[],typeName:Bt.ZodNumber,coerce:e?.coerce||!1,...ke(e)});class Je extends Ee{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==ie.bigint)return this._getInvalidInput(e);let t;const n=new fe;for(const r of this._def.checks)"min"===r.kind?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),he(t,{code:oe.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):"max"===r.kind?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),he(t,{code:oe.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):"multipleOf"===r.kind?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),he(t,{code:oe.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):re.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return he(t,{code:oe.invalid_type,expected:ie.bigint,received:t.parsedType}),pe}gte(e,t){return this.setLimit("min",e,!0,le.toString(t))}gt(e,t){return this.setLimit("min",e,!1,le.toString(t))}lte(e,t){return this.setLimit("max",e,!0,le.toString(t))}lt(e,t){return this.setLimit("max",e,!1,le.toString(t))}setLimit(e,t,n,r){return new Je({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:le.toString(r)}]})}_addCheck(e){return new Je({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:le.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:le.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:le.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:le.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:le.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}Je.create=e=>new Je({checks:[],typeName:Bt.ZodBigInt,coerce:e?.coerce??!1,...ke(e)});class Xe extends Ee{_parse(e){if(this._def.coerce&&(e.data=Boolean(e.data)),this._getType(e)!==ie.boolean){const t=this._getOrReturnCtx(e);return he(t,{code:oe.invalid_type,expected:ie.boolean,received:t.parsedType}),pe}return ge(e.data)}}Xe.create=e=>new Xe({typeName:Bt.ZodBoolean,coerce:e?.coerce||!1,...ke(e)});class Qe extends Ee{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==ie.date){const t=this._getOrReturnCtx(e);return he(t,{code:oe.invalid_type,expected:ie.date,received:t.parsedType}),pe}if(Number.isNaN(e.data.getTime()))return he(this._getOrReturnCtx(e),{code:oe.invalid_date}),pe;const t=new fe;let n;for(const r of this._def.checks)"min"===r.kind?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),he(n,{code:oe.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),t.dirty()):"max"===r.kind?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),he(n,{code:oe.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),t.dirty()):re.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Qe({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:le.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:le.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return null!=e?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return null!=e?new Date(e):null}}Qe.create=e=>new Qe({checks:[],coerce:e?.coerce||!1,typeName:Bt.ZodDate,...ke(e)});class et extends Ee{_parse(e){if(this._getType(e)!==ie.symbol){const t=this._getOrReturnCtx(e);return he(t,{code:oe.invalid_type,expected:ie.symbol,received:t.parsedType}),pe}return ge(e.data)}}et.create=e=>new et({typeName:Bt.ZodSymbol,...ke(e)});class tt extends Ee{_parse(e){if(this._getType(e)!==ie.undefined){const t=this._getOrReturnCtx(e);return he(t,{code:oe.invalid_type,expected:ie.undefined,received:t.parsedType}),pe}return ge(e.data)}}tt.create=e=>new tt({typeName:Bt.ZodUndefined,...ke(e)});class nt extends Ee{_parse(e){if(this._getType(e)!==ie.null){const t=this._getOrReturnCtx(e);return he(t,{code:oe.invalid_type,expected:ie.null,received:t.parsedType}),pe}return ge(e.data)}}nt.create=e=>new nt({typeName:Bt.ZodNull,...ke(e)});class rt extends Ee{constructor(){super(...arguments),this._any=!0}_parse(e){return ge(e.data)}}rt.create=e=>new rt({typeName:Bt.ZodAny,...ke(e)});class st extends Ee{constructor(){super(...arguments),this._unknown=!0}_parse(e){return ge(e.data)}}st.create=e=>new st({typeName:Bt.ZodUnknown,...ke(e)});class it extends Ee{_parse(e){const t=this._getOrReturnCtx(e);return he(t,{code:oe.invalid_type,expected:ie.never,received:t.parsedType}),pe}}it.create=e=>new it({typeName:Bt.ZodNever,...ke(e)});class at extends Ee{_parse(e){if(this._getType(e)!==ie.undefined){const t=this._getOrReturnCtx(e);return he(t,{code:oe.invalid_type,expected:ie.void,received:t.parsedType}),pe}return ge(e.data)}}at.create=e=>new at({typeName:Bt.ZodVoid,...ke(e)});class ot extends Ee{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==ie.array)return he(t,{code:oe.invalid_type,expected:ie.array,received:t.parsedType}),pe;if(null!==r.exactLength){const e=t.data.length>r.exactLength.value,s=t.data.length<r.exactLength.value;(e||s)&&(he(t,{code:e?oe.too_big:oe.too_small,minimum:s?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(null!==r.minLength&&t.data.length<r.minLength.value&&(he(t,{code:oe.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),null!==r.maxLength&&t.data.length>r.maxLength.value&&(he(t,{code:oe.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>r.type._parseAsync(new be(t,e,t.path,n)))).then(e=>fe.mergeArray(n,e));const s=[...t.data].map((e,n)=>r.type._parseSync(new be(t,e,t.path,n)));return fe.mergeArray(n,s)}get element(){return this._def.type}min(e,t){return new ot({...this._def,minLength:{value:e,message:le.toString(t)}})}max(e,t){return new ot({...this._def,maxLength:{value:e,message:le.toString(t)}})}length(e,t){return new ot({...this._def,exactLength:{value:e,message:le.toString(t)}})}nonempty(e){return this.min(1,e)}}function dt(e){if(e instanceof ut){const t={};for(const n in e.shape){const r=e.shape[n];t[n]=kt.create(dt(r))}return new ut({...e._def,shape:()=>t})}return e instanceof ot?new ot({...e._def,type:dt(e.element)}):e instanceof kt?kt.create(dt(e.unwrap())):e instanceof Et?Et.create(dt(e.unwrap())):e instanceof ft?ft.create(e.items.map(e=>dt(e))):e}ot.create=(e,t)=>new ot({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Bt.ZodArray,...ke(t)});class ut extends Ee{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;const e=this._def.shape(),t=re.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==ie.object){const t=this._getOrReturnCtx(e);return he(t,{code:oe.invalid_type,expected:ie.object,received:t.parsedType}),pe}const{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:s}=this._getCached(),i=[];if(!(this._def.catchall instanceof it&&"strip"===this._def.unknownKeys))for(const e in n.data)s.includes(e)||i.push(e);const a=[];for(const e of s){const t=r[e],s=n.data[e];a.push({key:{status:"valid",value:e},value:t._parse(new be(n,s,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof it){const e=this._def.unknownKeys;if("passthrough"===e)for(const e of i)a.push({key:{status:"valid",value:e},value:{status:"valid",value:n.data[e]}});else if("strict"===e)i.length>0&&(he(n,{code:oe.unrecognized_keys,keys:i}),t.dirty());else if("strip"!==e)throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const e=this._def.catchall;for(const t of i){const r=n.data[t];a.push({key:{status:"valid",value:t},value:e._parse(new be(n,r,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const e=[];for(const t of a){const n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>fe.mergeObjectSync(t,e)):fe.mergeObjectSync(t,a)}get shape(){return this._def.shape()}strict(e){return le.errToObj,new ut({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,n)=>{const r=this._def.errorMap?.(t,n).message??n.defaultError;return"unrecognized_keys"===t.code?{message:le.errToObj(e).message??r}:{message:r}}}:{}})}strip(){return new ut({...this._def,unknownKeys:"strip"})}passthrough(){return new ut({...this._def,unknownKeys:"passthrough"})}extend(e){return new ut({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new ut({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Bt.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new ut({...this._def,catchall:e})}pick(e){const t={};for(const n of re.objectKeys(e))e[n]&&this.shape[n]&&(t[n]=this.shape[n]);return new ut({...this._def,shape:()=>t})}omit(e){const t={};for(const n of re.objectKeys(this.shape))e[n]||(t[n]=this.shape[n]);return new ut({...this._def,shape:()=>t})}deepPartial(){return dt(this)}partial(e){const t={};for(const n of re.objectKeys(this.shape)){const r=this.shape[n];e&&!e[n]?t[n]=r:t[n]=r.optional()}return new ut({...this._def,shape:()=>t})}required(e){const t={};for(const n of re.objectKeys(this.shape))if(e&&!e[n])t[n]=this.shape[n];else{let e=this.shape[n];for(;e instanceof kt;)e=e._def.innerType;t[n]=e}return new ut({...this._def,shape:()=>t})}keyof(){return vt(re.objectKeys(this.shape))}}ut.create=(e,t)=>new ut({shape:()=>e,unknownKeys:"strip",catchall:it.create(),typeName:Bt.ZodObject,...ke(t)}),ut.strictCreate=(e,t)=>new ut({shape:()=>e,unknownKeys:"strict",catchall:it.create(),typeName:Bt.ZodObject,...ke(t)}),ut.lazycreate=(e,t)=>new ut({shape:e,unknownKeys:"strip",catchall:it.create(),typeName:Bt.ZodObject,...ke(t)});class ct extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;if(t.common.async)return Promise.all(n.map(async e=>{const n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(function(e){for(const t of e)if("valid"===t.result.status)return t.result;for(const n of e)if("dirty"===n.result.status)return t.common.issues.push(...n.ctx.common.issues),n.result;const n=e.map(e=>new de(e.ctx.common.issues));return he(t,{code:oe.invalid_union,unionErrors:n}),pe});{let e;const r=[];for(const s of n){const n={...t,common:{...t.common,issues:[]},parent:null},i=s._parseSync({data:t.data,path:t.path,parent:n});if("valid"===i.status)return i;"dirty"!==i.status||e||(e={result:i,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;const s=r.map(e=>new de(e));return he(t,{code:oe.invalid_union,unionErrors:s}),pe}}get options(){return this._def.options}}function lt(e,t){const n=ae(e),r=ae(t);if(e===t)return{valid:!0,data:e};if(n===ie.object&&r===ie.object){const n=re.objectKeys(t),r=re.objectKeys(e).filter(e=>-1!==n.indexOf(e)),s={...e,...t};for(const n of r){const r=lt(e[n],t[n]);if(!r.valid)return{valid:!1};s[n]=r.data}return{valid:!0,data:s}}if(n===ie.array&&r===ie.array){if(e.length!==t.length)return{valid:!1};const n=[];for(let r=0;r<e.length;r++){const s=lt(e[r],t[r]);if(!s.valid)return{valid:!1};n.push(s.data)}return{valid:!0,data:n}}return n===ie.date&&r===ie.date&&+e===+t?{valid:!0,data:e}:{valid:!1}}ct.create=(e,t)=>new ct({options:e,typeName:Bt.ZodUnion,...ke(t)});class ht extends Ee{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(ye(e)||ye(r))return pe;const s=lt(e.value,r.value);return s.valid?((ve(e)||ve(r))&&t.dirty(),{status:t.value,value:s.data}):(he(n,{code:oe.invalid_intersection_types}),pe)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}ht.create=(e,t,n)=>new ht({left:e,right:t,typeName:Bt.ZodIntersection,...ke(n)});class ft extends Ee{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ie.array)return he(n,{code:oe.invalid_type,expected:ie.array,received:n.parsedType}),pe;if(n.data.length<this._def.items.length)return he(n,{code:oe.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),pe;!this._def.rest&&n.data.length>this._def.items.length&&(he(n,{code:oe.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const r=[...n.data].map((e,t)=>{const r=this._def.items[t]||this._def.rest;return r?r._parse(new be(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>fe.mergeArray(t,e)):fe.mergeArray(t,r)}get items(){return this._def.items}rest(e){return new ft({...this._def,rest:e})}}ft.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ft({items:e,typeName:Bt.ZodTuple,rest:null,...ke(t)})};class pt extends Ee{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ie.map)return he(n,{code:oe.invalid_type,expected:ie.map,received:n.parsedType}),pe;const r=this._def.keyType,s=this._def.valueType,i=[...n.data.entries()].map(([e,t],i)=>({key:r._parse(new be(n,e,n.path,[i,"key"])),value:s._parse(new be(n,t,n.path,[i,"value"]))}));if(n.common.async){const e=new Map;return Promise.resolve().then(async()=>{for(const n of i){const r=await n.key,s=await n.value;if("aborted"===r.status||"aborted"===s.status)return pe;"dirty"!==r.status&&"dirty"!==s.status||t.dirty(),e.set(r.value,s.value)}return{status:t.value,value:e}})}{const e=new Map;for(const n of i){const r=n.key,s=n.value;if("aborted"===r.status||"aborted"===s.status)return pe;"dirty"!==r.status&&"dirty"!==s.status||t.dirty(),e.set(r.value,s.value)}return{status:t.value,value:e}}}}pt.create=(e,t,n)=>new pt({valueType:t,keyType:e,typeName:Bt.ZodMap,...ke(n)});class mt extends Ee{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ie.set)return he(n,{code:oe.invalid_type,expected:ie.set,received:n.parsedType}),pe;const r=this._def;null!==r.minSize&&n.data.size<r.minSize.value&&(he(n,{code:oe.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),null!==r.maxSize&&n.data.size>r.maxSize.value&&(he(n,{code:oe.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());const s=this._def.valueType;function i(e){const n=new Set;for(const r of e){if("aborted"===r.status)return pe;"dirty"===r.status&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}const a=[...n.data.values()].map((e,t)=>s._parse(new be(n,e,n.path,t)));return n.common.async?Promise.all(a).then(e=>i(e)):i(a)}min(e,t){return new mt({...this._def,minSize:{value:e,message:le.toString(t)}})}max(e,t){return new mt({...this._def,maxSize:{value:e,message:le.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}mt.create=(e,t)=>new mt({valueType:e,minSize:null,maxSize:null,typeName:Bt.ZodSet,...ke(t)});class gt extends Ee{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}gt.create=(e,t)=>new gt({getter:e,typeName:Bt.ZodLazy,...ke(t)});class yt extends Ee{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return he(t,{received:t.data,code:oe.invalid_literal,expected:this._def.value}),pe}return{status:"valid",value:e.data}}get value(){return this._def.value}}function vt(e,t){return new wt({values:e,typeName:Bt.ZodEnum,...ke(t)})}yt.create=(e,t)=>new yt({value:e,typeName:Bt.ZodLiteral,...ke(t)});class wt extends Ee{_parse(e){if("string"!=typeof e.data){const t=this._getOrReturnCtx(e),n=this._def.values;return he(t,{expected:re.joinValues(n),received:t.parsedType,code:oe.invalid_type}),pe}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return he(t,{received:t.data,code:oe.invalid_enum_value,options:n}),pe}return ge(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return wt.create(e,{...this._def,...t})}exclude(e,t=this._def){return wt.create(this.options.filter(t=>!e.includes(t)),{...this._def,...t})}}wt.create=vt;class _t extends Ee{_parse(e){const t=re.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==ie.string&&n.parsedType!==ie.number){const e=re.objectValues(t);return he(n,{expected:re.joinValues(e),received:n.parsedType,code:oe.invalid_type}),pe}if(this._cache||(this._cache=new Set(re.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const e=re.objectValues(t);return he(n,{received:n.data,code:oe.invalid_enum_value,options:e}),pe}return ge(e.data)}get enum(){return this._def.values}}_t.create=(e,t)=>new _t({values:e,typeName:Bt.ZodNativeEnum,...ke(t)});class bt extends Ee{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ie.promise&&!1===t.common.async)return he(t,{code:oe.invalid_type,expected:ie.promise,received:t.parsedType}),pe;const n=t.parsedType===ie.promise?t.data:Promise.resolve(t.data);return ge(n.then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}}bt.create=(e,t)=>new bt({type:e,typeName:Bt.ZodPromise,...ke(t)});class xt extends Ee{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Bt.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,s={addIssue:e=>{he(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),"preprocess"===r.type){const e=r.transform(n.data,s);if(n.common.async)return Promise.resolve(e).then(async e=>{if("aborted"===t.value)return pe;const r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return"aborted"===r.status?pe:"dirty"===r.status||"dirty"===t.value?me(r.value):r});{if("aborted"===t.value)return pe;const r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return"aborted"===r.status?pe:"dirty"===r.status||"dirty"===t.value?me(r.value):r}}if("refinement"===r.type){const e=e=>{const t=r.refinement(e,s);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return e};if(!1===n.common.async){const r=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return"aborted"===r.status?pe:("dirty"===r.status&&t.dirty(),e(r.value),{status:t.value,value:r.value})}return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(n=>"aborted"===n.status?pe:("dirty"===n.status&&t.dirty(),e(n.value).then(()=>({status:t.value,value:n.value}))))}if("transform"===r.type){if(!1===n.common.async){const e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!we(e))return pe;const i=r.transform(e.value,s);if(i instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:i}}return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(e=>we(e)?Promise.resolve(r.transform(e.value,s)).then(e=>({status:t.value,value:e})):pe)}re.assertNever(r)}}xt.create=(e,t,n)=>new xt({schema:e,typeName:Bt.ZodEffects,effect:t,...ke(n)}),xt.createWithPreprocess=(e,t,n)=>new xt({schema:t,effect:{type:"preprocess",transform:e},typeName:Bt.ZodEffects,...ke(n)});class kt extends Ee{_parse(e){return this._getType(e)===ie.undefined?ge(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}kt.create=(e,t)=>new kt({innerType:e,typeName:Bt.ZodOptional,...ke(t)});class Et extends Ee{_parse(e){return this._getType(e)===ie.null?ge(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Et.create=(e,t)=>new Et({innerType:e,typeName:Bt.ZodNullable,...ke(t)});class Ot extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===ie.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Ot.create=(e,t)=>new Ot({innerType:e,typeName:Bt.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...ke(t)});class At extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return _e(r)?r.then(e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new de(n.common.issues)},input:n.data})})):{status:"valid",value:"valid"===r.status?r.value:this._def.catchValue({get error(){return new de(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}At.create=(e,t)=>new At({innerType:e,typeName:Bt.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...ke(t)});class St extends Ee{_parse(e){if(this._getType(e)!==ie.nan){const t=this._getOrReturnCtx(e);return he(t,{code:oe.invalid_type,expected:ie.nan,received:t.parsedType}),pe}return{status:"valid",value:e.data}}}St.create=e=>new St({typeName:Bt.ZodNaN,...ke(e)}),Symbol("zod_brand");class It extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class Ct extends Ee{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return"aborted"===e.status?pe:"dirty"===e.status?(t.dirty(),me(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{const e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return"aborted"===e.status?pe:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(e,t){return new Ct({in:e,out:t,typeName:Bt.ZodPipeline})}}class Nt extends Ee{_parse(e){const t=this._def.innerType._parse(e),n=e=>(we(e)&&(e.value=Object.freeze(e.value)),e);return _e(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}}var Bt;Nt.create=(e,t)=>new Nt({innerType:e,typeName:Bt.ZodReadonly,...ke(t)}),ut.lazycreate,function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"}(Bt||(Bt={}));const Zt=We.create,Tt=(Ye.create,St.create,Je.create,Xe.create,Qe.create,et.create,tt.create,nt.create,rt.create,st.create,it.create,at.create,ot.create,ut.create),Rt=(ut.strictCreate,ct.create,ht.create,ft.create,pt.create,mt.create,gt.create,yt.create),{parseSpaceUri:zt,exactHttpOrigin:jt,validateLocationRecordV2Payload:$t,decodeBase64Url:Pt,parseSignedSiweCacao:Lt,verifiedDelegationRouting:Ft,spaceIdsEqual:Ut,resolveOwnerHosts:Dt,RegistryUnavailableError:qt}=(wt.create,_t.create,bt.create,xt.create,kt.create,Et.create,xt.createWithPreprocess,Ct.create,e);var Ht="tinycloud/share-placement/v1",Mt=Tt({type:Rt(Ht),ownerDid:Zt(),parentCid:Zt().min(1),spaceId:Zt().min(1),nodeDid:Zt(),nodeUrl:Zt(),issuedAt:Zt().datetime(),notAfter:Zt().datetime(),signature:Zt().regex(/^0x[0-9a-fA-F]{130}$/)}).strict();function Vt(e){return Ht+"\n"+JSON.stringify({type:e.type,ownerDid:e.ownerDid,parentCid:e.parentCid,spaceId:e.spaceId,nodeDid:e.nodeDid,nodeUrl:e.nodeUrl,issuedAt:e.issuedAt,notAfter:e.notAfter})}function Kt(e){if(jt(e.nodeUrl,"share node")!==e.nodeUrl)throw new Error("Share node URL must be exact");$t({version:2,subject:e.ownerDid,nodes:[{did:e.nodeDid,url:e.nodeUrl}],spaces:[{space:e.spaceId,nodes:[{did:e.nodeDid,mode:"read-only"}]}],encryptionNode:null,updated_at:e.issuedAt,sequence:0})}async function Wt(e){if(!e.authHeader)throw new Error("Share placement requires signed parent bytes");if(!(await Ft(e.authHeader,e.cid)).resources.some(({resource:t})=>Ut(t,e.spaceId)))throw new Error("Share placement space is not in the signed parent");const t=zt(e.spaceId)?.owner;if(!t?.startsWith("did:pkh:eip155:"))throw new Error("Share placement requires the wallet owner");const n=e.authHeader.includes(".")?new Date(1e3*JSON.parse((new TextDecoder).decode(Pt(e.authHeader.split(".")[1]))).exp):new Date((await Lt(e.authHeader,e.cid)).expiresAt);if(!Number.isFinite(n.getTime()))throw new Error("Share placement parent has no finite expiry");return{ownerDid:t,expiry:n}}async function Gt(e,t,n=Date.now()){try{const r=Mt.parse(e),s=await Wt(t);if(r.ownerDid.toLowerCase()!==s.ownerDid.toLowerCase()||r.parentCid!==t.cid||r.spaceId!==t.spaceId||Date.parse(r.notAfter)!==s.expiry.getTime()||Date.parse(r.issuedAt)>n||Date.parse(r.issuedAt)>=Date.parse(r.notAfter)||n>=Date.parse(r.notAfter))throw new Error("Share placement binding or validity is invalid");if(Kt(r),!await async function({address:e,message:t,signature:n}){return function(e,t){if(!J(e,{strict:!1}))throw new u({address:e});if(!J(t,{strict:!1}))throw new u({address:t});return e.toLowerCase()===t.toLowerCase()}(function(e){if(!J(e,{strict:!1}))throw new u({address:e});return Q(e,void 0)}(e),await async function({message:e,signature:t}){return ne({hash:ee(e),signature:t})}({message:t,signature:n}))}({address:r.ownerDid.slice(r.ownerDid.lastIndexOf(":")+1),message:Vt(r),signature:r.signature}))throw new Error("Share placement owner signature is invalid");return r}catch{throw new Error("Invalid share placement")}}async function Yt(e,t,n,r=Date.now()){const{ownerDid:s,expiry:i}=await Wt(e),a={type:Ht,ownerDid:s,parentCid:e.cid,spaceId:e.spaceId,nodeDid:t.did,nodeUrl:t.url,issuedAt:new Date(r).toISOString(),notAfter:i.toISOString()};if(Kt(a),r>=i.getTime())throw new Error("Share placement parent is expired");const o=await n(Vt(a));return Gt({...a,signature:o},e,r)}async function Jt(e,t,n={}){const r=await Gt(e,t),s=n.fetch??globalThis.fetch;let i;const a=Object.assign(async(e,t)=>{const n=await s(e,t);return 200!==n.status&&404!==n.status&&(i=n.status),n},{preconnect:s.preconnect}),o=await Dt(r.ownerDid,{...n,fetch:a});if(void 0!==i&&(i<500||i>599))throw new Error("Share placement registry lookup refused");if("registered"===o.status){if(!o.record)throw new qt(r.ownerDid,void 0);const e=o.record.spaces.find(({space:e})=>Ut(e,r.spaceId));if(!e||0===e.nodes.length)throw new Error("Current owner placement does not serve this share");return e.nodes.map(({did:e})=>{const t=o.record.nodes.find(t=>t.did===e);if(!t)throw new Error("Current owner placement has no destination identity");return{nodeDid:t.did,url:t.url}})}if("unavailable"===o.status&&!("network-error"===o.reason||"timeout"===o.reason||"http-status"===o.reason&&void 0!==i&&i>=500&&i<=599))throw new qt(r.ownerDid,o);return[{nodeDid:r.nodeDid,url:r.nodeUrl}]}export{Ht as SHARE_PLACEMENT_TYPE,Jt as sharePlacementDestinations,Vt as sharePlacementMessage,Yt as signSharePlacement,Gt as verifySharePlacement};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinycloud/web-sdk",
|
|
3
|
-
"version": "3.12.0-beta.
|
|
3
|
+
"version": "3.12.0-beta.36",
|
|
4
4
|
"description": "A set of tools and utilities to help you build your app with TinyCloud.",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -67,11 +67,11 @@
|
|
|
67
67
|
"@multiformats/multiaddr": "^13.0.1",
|
|
68
68
|
"@multiformats/multiaddr-to-uri": "^12.0.0",
|
|
69
69
|
"@noble/curves": "^1.9.7",
|
|
70
|
-
"@tinycloud/node-sdk": "3.12.0-beta.
|
|
70
|
+
"@tinycloud/node-sdk": "3.12.0-beta.36",
|
|
71
71
|
"@tinycloud/replica": "0.4.5-beta.10",
|
|
72
|
-
"@tinycloud/sdk-core": "3.12.0-beta.
|
|
72
|
+
"@tinycloud/sdk-core": "3.12.0-beta.36",
|
|
73
73
|
"@tinycloud/share-envelope": "1.6.0-beta.1",
|
|
74
|
-
"@tinycloud/share-sdk": "1.5.0-beta.
|
|
74
|
+
"@tinycloud/share-sdk": "1.5.0-beta.5",
|
|
75
75
|
"@tinycloud/web-sdk-wasm": "1.7.8-beta.0",
|
|
76
76
|
"axios": "^1.7.9",
|
|
77
77
|
"viem": "^2.45.0",
|