@permaweb/libs 0.0.16 → 0.0.18

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.
@@ -0,0 +1 @@
1
+ var e={204:(e,t,r)=>{r.r(t),r.d(t,{default:()=>n});const n={}},566:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=r(594);t.default=class{BigNum;constructor(){this.BigNum=(e,t)=>new(n.BigNumber.clone({DECIMAL_PLACES:t}))(e)}winstonToAr(e,{formatted:t=!1,decimals:r=12,trim:n=!0}={}){let a=this.stringToBigNum(e,r).shiftedBy(-12);return t?a.toFormat(r):a.toFixed(r)}arToWinston(e,{formatted:t=!1}={}){let r=this.stringToBigNum(e).shiftedBy(12);return t?r.toFormat():r.toFixed(0)}compare(e,t){let r=this.stringToBigNum(e),n=this.stringToBigNum(t);return r.comparedTo(n)}isEqual(e,t){return 0===this.compare(e,t)}isLessThan(e,t){let r=this.stringToBigNum(e),n=this.stringToBigNum(t);return r.isLessThan(n)}isGreaterThan(e,t){let r=this.stringToBigNum(e),n=this.stringToBigNum(t);return r.isGreaterThan(n)}add(e,t){let r=this.stringToBigNum(e);return this.stringToBigNum(t),r.plus(t).toFixed(0)}sub(e,t){let r=this.stringToBigNum(e);return this.stringToBigNum(t),r.minus(t).toFixed(0)}stringToBigNum(e,t=12){return this.BigNum(e,t)}}},143:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=r(911);r(204);class a{api;network;static HASH_ENDPOINT="block/hash/";static HEIGHT_ENDPOINT="block/height/";constructor(e,t){this.api=e,this.network=t}async get(e){const t=await this.api.get(`${a.HASH_ENDPOINT}${e}`);if(200===t.status)return t.data;throw 404===t.status?new n.default("BLOCK_NOT_FOUND"):new Error(`Error while loading block data: ${t}`)}async getByHeight(e){const t=await this.api.get(`${a.HEIGHT_ENDPOINT}${e}`);if(200===t.status)return t.data;throw 404===t.status?new n.default("BLOCK_NOT_FOUND"):new Error(`Error while loading block data: ${t}`)}async getCurrent(){const{current:e}=await this.network.getInfo();return await this.get(e)}}t.default=a},855:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=r(911),a=r(848);t.default=class{api;constructor(e){this.api=e}async getTransactionOffset(e){const t=await this.api.get(`tx/${e}/offset`);if(200===t.status)return t.data;throw new Error(`Unable to get transaction offset: ${(0,n.getError)(t)}`)}async getChunk(e){const t=await this.api.get(`chunk/${e}`);if(200===t.status)return t.data;throw new Error(`Unable to get chunk: ${(0,n.getError)(t)}`)}async getChunkData(e){const t=await this.getChunk(e);return a.b64UrlToBuffer(t.chunk)}firstChunkOffset(e){return parseInt(e.offset)-parseInt(e.size)+1}async downloadChunkedData(e){const t=await this.getTransactionOffset(e),r=parseInt(t.size),n=parseInt(t.offset)-r+1,a=new Uint8Array(r);let i=0;for(;i<r;){let e;this.api.config.logging&&console.log(`[chunk] ${i}/${r}`);try{e=await this.getChunkData(n+i)}catch(e){console.error(`[chunk] Failed to fetch chunk at offset ${n+i}`),console.error("[chunk] This could indicate that the chunk wasn't uploaded or hasn't yet seeded properly to a particular gateway/node")}if(!e)throw new Error(`Couldn't complete data download at ${i}/${r}`);a.set(e,i),i+=e.length}return a}}},908:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=r(566),a=r(965),i=r(311),s=r(779),o=r(320),u=r(115),c=r(813),l=r(848),h=r(716),d=r(855),f=r(143);class p{api;wallets;transactions;network;blocks;ar;silo;chunks;static init;static crypto=new i.default;static utils=l;constructor(e){this.api=new a.default(e),this.wallets=new u.default(this.api,p.crypto),this.chunks=new d.default(this.api),this.transactions=new o.default(this.api,p.crypto,this.chunks),this.silo=new h.default(this.api,this.crypto,this.transactions),this.network=new s.default(this.api),this.blocks=new f.default(this.api,this.network),this.ar=new n.default}get crypto(){return p.crypto}get utils(){return p.utils}getConfig(){return{api:this.api.getConfig(),crypto:null}}async createTransaction(e,t){const r={};if(Object.assign(r,e),!(e.data||e.target&&e.quantity))throw new Error("A new Arweave transaction must have a 'data' value, or 'target' and 'quantity' values.");if(null==e.owner&&t&&"use_wallet"!==t&&(r.owner=t.n),null==e.last_tx&&(r.last_tx=await this.transactions.getTransactionAnchor()),"string"==typeof e.data&&(e.data=l.stringToBuffer(e.data)),e.data instanceof ArrayBuffer&&(e.data=new Uint8Array(e.data)),e.data&&!(e.data instanceof Uint8Array))throw new Error("Expected data to be a string, Uint8Array or ArrayBuffer");if(null==e.reward){const t=e.data?e.data.byteLength:0;r.reward=await this.transactions.getPrice(t,r.target)}r.data_root="",r.data_size=e.data?e.data.byteLength.toString():"0",r.data=e.data||new Uint8Array(0);const n=new c.default(r);return await n.getSignatureData(),n}async createSiloTransaction(e,t,r){const n={};if(Object.assign(n,e),!e.data)throw new Error("Silo transactions must have a 'data' value");if(!r)throw new Error("No Silo URI specified.");if(e.target||e.quantity)throw new Error("Silo transactions can only be used for storing data, sending AR to other wallets isn't supported.");if(null==e.owner){if(!t||!t.n)throw new Error("A new Arweave transaction must either have an 'owner' attribute, or you must provide the jwk parameter.");n.owner=t.n}null==e.last_tx&&(n.last_tx=await this.transactions.getTransactionAnchor());const a=await this.silo.parseUri(r);if("string"==typeof e.data){const t=await this.crypto.encrypt(l.stringToBuffer(e.data),a.getEncryptionKey());n.reward=await this.transactions.getPrice(t.byteLength),n.data=l.bufferTob64Url(t)}if(e.data instanceof Uint8Array){const t=await this.crypto.encrypt(e.data,a.getEncryptionKey());n.reward=await this.transactions.getPrice(t.byteLength),n.data=l.bufferTob64Url(t)}const i=new c.default(n);return i.addTag("Silo-Name",a.getAccessKey()),i.addTag("Silo-Version","0.1.0"),i}arql(e){return this.api.post("/arql",e).then((e=>e.data||[]))}}t.default=p},69:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var a=Object.getOwnPropertyDescriptor(t,r);a&&!("get"in a?!t.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,a)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),a=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0});const i=r(908),s=r(525);i.default.init=function(e={}){if("object"!=typeof location||!location.protocol||!location.hostname)return new i.default({...e,host:"arweave.net",port:443,protocol:"https"});const t=location.protocol.replace(":",""),r=location.hostname,n=location.port?parseInt(location.port):"https"==t?443:80,a=(0,s.getDefaultConfig)(t,r),o=e.protocol||a.protocol,u=e.host||a.host,c=e.port||a.port||n;return new i.default({...e,host:u,protocol:o,port:c})},"object"==typeof globalThis?globalThis.Arweave=i.default:"object"==typeof self&&(self.Arweave=i.default),a(r(908),t),t.default=i.default},965:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{METHOD_GET="GET";METHOD_POST="POST";config;constructor(e){this.applyConfig(e)}applyConfig(e){this.config=this.mergeDefaults(e)}getConfig(){return this.config}mergeDefaults(e){const t=e.protocol||"http",r=e.port||("https"===t?443:80);return{host:e.host||"127.0.0.1",protocol:t,port:r,timeout:e.timeout||2e4,logging:e.logging||!1,logger:e.logger||console.log,network:e.network}}async get(e,t){return await this.request(e,{...t,method:this.METHOD_GET})}async post(e,t,r){const n=new Headers(r?.headers||{});return n.get("content-type")?.includes("application/json")||n.append("content-type","application/json"),n.append("accept","application/json, text/plain, */*"),await this.request(e,{...r,method:this.METHOD_POST,body:"string"!=typeof t?JSON.stringify(t):t,headers:n})}async request(e,t){const n=new Headers(t?.headers||{}),a=`${this.config.protocol}://${this.config.host}:${this.config.port}`,i=t?.responseType;delete t?.responseType,e.startsWith("/")&&(e=e.slice(1)),this.config.network&&n.append("x-network",this.config.network),this.config.logging&&this.config.logger(`Requesting: ${a}/${e}`);let s=await fetch(`${a}/${e}`,{...t||{},headers:n});this.config.logging&&this.config.logger(`Response: ${s.url} - ${s.status}`);const o=s.headers.get("content-type"),u=o?.match(/charset=([^()<>@,;:\"/[\]?.=\s]*)/i)?.[1],c=s,l=async()=>{if(u)try{c.data=new TextDecoder(u).decode(await s.arrayBuffer())}catch(e){c.data=await s.text()}else c.data=await s.text()};if("arraybuffer"===i)c.data=await s.arrayBuffer();else if("text"===i)await l();else if("webstream"===i)c.data=r(s.body);else try{let e=await s.clone().json();"object"!=typeof e?await l():c.data=await s.json(),e=null}catch{await l()}return c}};const r=e=>{const t=e;return void 0===t[Symbol.asyncIterator]?(t[Symbol.asyncIterator]=n(e),t):e},n=function(e){return async function*(){const t=e.getReader();try{for(;;){const{done:e,value:r}=await t.read();if(e)return;yield r}}finally{t.releaseLock()}}}},311:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=r(848);t.default=class{keyLength=4096;publicExponent=65537;hashAlgorithm="sha256";driver;constructor(){if(!this.detectWebCrypto())throw new Error("SubtleCrypto not available!");this.driver=crypto.subtle}async generateJWK(){let e=await this.driver.generateKey({name:"RSA-PSS",modulusLength:4096,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign"]),t=await this.driver.exportKey("jwk",e.privateKey);return{kty:t.kty,e:t.e,n:t.n,d:t.d,p:t.p,q:t.q,dp:t.dp,dq:t.dq,qi:t.qi}}async sign(e,t,{saltLength:r}={}){let n=await this.driver.sign({name:"RSA-PSS",saltLength:32},await this.jwkToCryptoKey(e),t);return new Uint8Array(n)}async hash(e,t="SHA-256"){let r=await this.driver.digest(t,e);return new Uint8Array(r)}async verify(e,t,r){const n={kty:"RSA",e:"AQAB",n:e},a=await this.jwkToPublicCryptoKey(n),i=await this.driver.digest("SHA-256",t),s=await this.driver.verify({name:"RSA-PSS",saltLength:0},a,r,t),o=await this.driver.verify({name:"RSA-PSS",saltLength:32},a,r,t),u=await this.driver.verify({name:"RSA-PSS",saltLength:Math.ceil((a.algorithm.modulusLength-1)/8)-i.byteLength-2},a,r,t);return s||o||u}async jwkToCryptoKey(e){return this.driver.importKey("jwk",e,{name:"RSA-PSS",hash:{name:"SHA-256"}},!1,["sign"])}async jwkToPublicCryptoKey(e){return this.driver.importKey("jwk",e,{name:"RSA-PSS",hash:{name:"SHA-256"}},!1,["verify"])}detectWebCrypto(){if("undefined"==typeof crypto)return!1;const e=crypto?.subtle;return void 0!==e&&["generateKey","importKey","exportKey","digest","sign"].every((t=>"function"==typeof e[t]))}async encrypt(e,t,r){const a=await this.driver.importKey("raw","string"==typeof t?n.stringToBuffer(t):t,{name:"PBKDF2",length:32},!1,["deriveKey"]),i=await this.driver.deriveKey({name:"PBKDF2",salt:r?n.stringToBuffer(r):n.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},a,{name:"AES-CBC",length:256},!1,["encrypt","decrypt"]),s=new Uint8Array(16);crypto.getRandomValues(s);const o=await this.driver.encrypt({name:"AES-CBC",iv:s},i,e);return n.concatBuffers([s,o])}async decrypt(e,t,r){const a=await this.driver.importKey("raw","string"==typeof t?n.stringToBuffer(t):t,{name:"PBKDF2",length:32},!1,["deriveKey"]),i=await this.driver.deriveKey({name:"PBKDF2",salt:r?n.stringToBuffer(r):n.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},a,{name:"AES-CBC",length:256},!1,["encrypt","decrypt"]),s=e.slice(0,16),o=await this.driver.decrypt({name:"AES-CBC",iv:s},i,e.slice(16));return n.concatBuffers([o])}}},475:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=r(908);async function a(e){if(Array.isArray(e)){const t=n.default.utils.concatBuffers([n.default.utils.stringToBuffer("list"),n.default.utils.stringToBuffer(e.length.toString())]);return await i(e,await n.default.crypto.hash(t,"SHA-384"))}const t=n.default.utils.concatBuffers([n.default.utils.stringToBuffer("blob"),n.default.utils.stringToBuffer(e.byteLength.toString())]),r=n.default.utils.concatBuffers([await n.default.crypto.hash(t,"SHA-384"),await n.default.crypto.hash(e,"SHA-384")]);return await n.default.crypto.hash(r,"SHA-384")}async function i(e,t){if(e.length<1)return t;const r=n.default.utils.concatBuffers([t,await a(e[0])]),s=await n.default.crypto.hash(r,"SHA-384");return await i(e.slice(1),s)}t.default=a},911:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getError=void 0;class r extends Error{type;response;constructor(e,t={}){t.message?super(t.message):super(),this.type=e,this.response=t.response}getType(){return this.type}}t.default=r,t.getError=function(e){let t=e.data;if("string"==typeof e.data)try{t=JSON.parse(e.data)}catch(e){}if(e.data instanceof ArrayBuffer||e.data instanceof Uint8Array)try{t=JSON.parse(t.toString())}catch(e){}return t?t.error||t:e.statusText||"unknown"}},647:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.debug=t.validatePath=t.arrayCompare=t.bufferToInt=t.intToBuffer=t.arrayFlatten=t.generateProofs=t.buildLayers=t.generateTransactionChunks=t.generateTree=t.computeRootHash=t.generateLeaves=t.chunkData=t.MIN_CHUNK_SIZE=t.MAX_CHUNK_SIZE=void 0;const n=r(908),a=r(848);t.MAX_CHUNK_SIZE=262144,t.MIN_CHUNK_SIZE=32768;async function i(e){let r=[],a=e,i=0;for(;a.byteLength>=t.MAX_CHUNK_SIZE;){let e=t.MAX_CHUNK_SIZE,s=a.byteLength-t.MAX_CHUNK_SIZE;s>0&&s<t.MIN_CHUNK_SIZE&&(e=Math.ceil(a.byteLength/2));const o=a.slice(0,e),u=await n.default.crypto.hash(o);i+=o.byteLength,r.push({dataHash:u,minByteRange:i-o.byteLength,maxByteRange:i}),a=a.slice(e)}return r.push({dataHash:await n.default.crypto.hash(a),minByteRange:i,maxByteRange:i+a.byteLength}),r}async function s(e){return Promise.all(e.map((async({dataHash:e,minByteRange:t,maxByteRange:r})=>({type:"leaf",id:await f(await Promise.all([f(e),f(p(r))])),dataHash:e,minByteRange:t,maxByteRange:r}))))}async function o(e){return await u(await s(await i(e)))}async function u(e,t=0){if(e.length<2)return e[0];const r=[];for(let t=0;t<e.length;t+=2)r.push(await d(e[t],e[t+1]));return u(r,t+1)}function c(e){const t=l(e);return Array.isArray(t)?h(t):[t]}function l(e,t=new Uint8Array,r=0){if("leaf"==e.type)return{offset:e.maxByteRange-1,proof:(0,a.concatBuffers)([t,e.dataHash,p(e.maxByteRange)])};if("branch"==e.type){const n=(0,a.concatBuffers)([t,e.leftChild.id,e.rightChild.id,p(e.byteRange)]);return[l(e.leftChild,n,r+1),l(e.rightChild,n,r+1)]}throw new Error("Unexpected node type")}function h(e){const t=[];return e.forEach((e=>{Array.isArray(e)?t.push(...h(e)):t.push(e)})),t}async function d(e,t){return t?{type:"branch",id:await f([await f(e.id),await f(t.id),await f(p(e.maxByteRange))]),byteRange:e.maxByteRange,maxByteRange:t.maxByteRange,leftChild:e,rightChild:t}:e}async function f(e){return Array.isArray(e)&&(e=n.default.utils.concatBuffers(e)),new Uint8Array(await n.default.crypto.hash(e))}function p(e){const t=new Uint8Array(32);for(var r=t.length-1;r>=0;r--){var n=e%256;t[r]=n,e=(e-n)/256}return t}function g(e){let t=0;for(var r=0;r<e.length;r++)t*=256,t+=e[r];return t}t.chunkData=i,t.generateLeaves=s,t.computeRootHash=async function(e){return(await o(e)).id},t.generateTree=o,t.generateTransactionChunks=async function(e){const t=await i(e),r=await s(t),n=await u(r),a=await c(n),o=t.slice(-1)[0];return o.maxByteRange-o.minByteRange==0&&(t.splice(t.length-1,1),a.splice(a.length-1,1)),{data_root:n.id,chunks:t,proofs:a}},t.buildLayers=u,t.generateProofs=c,t.arrayFlatten=h,t.intToBuffer=p,t.bufferToInt=g,t.arrayCompare=(e,t)=>e.every(((e,r)=>t[r]===e)),t.validatePath=async function e(r,n,a,i,s){if(i<=0)return!1;if(n>=i)return e(r,0,i-1,i,s);if(n<0)return e(r,0,0,i,s);if(64==s.length){const e=s.slice(0,32),n=s.slice(e.length,e.length+32),o=await f([await f(e),await f(n)]);return!!(0,t.arrayCompare)(r,o)&&{offset:i-1,leftBound:a,rightBound:i,chunkSize:i-a}}const o=s.slice(0,32),u=s.slice(o.length,o.length+32),c=s.slice(o.length+u.length,o.length+u.length+32),l=g(c),h=s.slice(o.length+u.length+c.length),d=await f([await f(o),await f(u),await f(c)]);return!!(0,t.arrayCompare)(r,d)&&(n<l?await e(o,n,a,Math.min(i,l),h):await e(u,n,Math.max(a,l),i,h))},t.debug=async function e(t,r=""){if(t.byteLength<1)return r;const n=t.slice(0,32),a=t.slice(n.length,n.length+32),i=t.slice(n.length+a.length,n.length+a.length+32),s=g(i),o=t.slice(n.length+a.length+i.length),u=await f([await f(n),await f(a),await f(i)]);return e(o,`${r}\n${JSON.stringify(Buffer.from(n))},${JSON.stringify(Buffer.from(a))},${s} => ${JSON.stringify(u)}`)}},472:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TransactionUploader=void 0;const n=r(813),a=r(848),i=r(911),s=r(647),o=["invalid_json","chunk_too_big","data_path_too_big","offset_too_big","data_size_too_big","chunk_proof_ratio_not_attractive","invalid_proof"];class u{api;chunkIndex=0;txPosted=!1;transaction;lastRequestTimeEnd=0;totalErrors=0;data;lastResponseStatus=0;lastResponseError="";get isComplete(){return this.txPosted&&this.chunkIndex===this.transaction.chunks.chunks.length}get totalChunks(){return this.transaction.chunks.chunks.length}get uploadedChunks(){return this.chunkIndex}get pctComplete(){return Math.trunc(this.uploadedChunks/this.totalChunks*100)}constructor(e,t){if(this.api=e,!t.id)throw new Error("Transaction is not signed");if(!t.chunks)throw new Error("Transaction chunks not prepared");this.data=t.data,this.transaction=new n.default(Object.assign({},t,{data:new Uint8Array(0)}))}async uploadChunk(e){if(this.isComplete)throw new Error("Upload is already complete");if(""!==this.lastResponseError?this.totalErrors++:this.totalErrors=0,100===this.totalErrors)throw new Error(`Unable to complete upload: ${this.lastResponseStatus}: ${this.lastResponseError}`);let t=""===this.lastResponseError?0:Math.max(this.lastRequestTimeEnd+4e4-Date.now(),4e4);if(t>0&&(t-=t*Math.random()*.3,await new Promise((e=>setTimeout(e,t)))),this.lastResponseError="",!this.txPosted)return void await this.postTransaction();e&&(this.chunkIndex=e);const r=this.transaction.getChunk(e||this.chunkIndex,this.data);if(!await(0,s.validatePath)(this.transaction.chunks.data_root,parseInt(r.offset),0,parseInt(r.data_size),a.b64UrlToBuffer(r.data_path)))throw new Error(`Unable to validate chunk ${this.chunkIndex}`);const n=await this.api.post("chunk",this.transaction.getChunk(this.chunkIndex,this.data)).catch((e=>(console.error(e.message),{status:-1,data:{error:e.message}})));if(this.lastRequestTimeEnd=Date.now(),this.lastResponseStatus=n.status,200==this.lastResponseStatus)this.chunkIndex++;else if(this.lastResponseError=(0,i.getError)(n),o.includes(this.lastResponseError))throw new Error(`Fatal error uploading chunk ${this.chunkIndex}: ${this.lastResponseError}`)}static async fromSerialized(e,t,r){if(!t||"number"!=typeof t.chunkIndex||"object"!=typeof t.transaction)throw new Error("Serialized object does not match expected format.");var a=new n.default(t.transaction);a.chunks||await a.prepareChunks(r);const i=new u(e,a);if(i.chunkIndex=t.chunkIndex,i.lastRequestTimeEnd=t.lastRequestTimeEnd,i.lastResponseError=t.lastResponseError,i.lastResponseStatus=t.lastResponseStatus,i.txPosted=t.txPosted,i.data=r,i.transaction.data_root!==t.transaction.data_root)throw new Error("Data mismatch: Uploader doesn't match provided data.");return i}static async fromTransactionId(e,t){const r=await e.get(`tx/${t}`);if(200!==r.status)throw new Error(`Tx ${t} not found: ${r.status}`);const n=r.data;return n.data=new Uint8Array(0),{txPosted:!0,chunkIndex:0,lastResponseError:"",lastRequestTimeEnd:0,lastResponseStatus:0,transaction:n}}toJSON(){return{chunkIndex:this.chunkIndex,transaction:this.transaction,lastRequestTimeEnd:this.lastRequestTimeEnd,lastResponseStatus:this.lastResponseStatus,lastResponseError:this.lastResponseError,txPosted:this.txPosted}}async postTransaction(){if(this.totalChunks<=1){this.transaction.data=this.data;const e=await this.api.post("tx",this.transaction).catch((e=>(console.error(e),{status:-1,data:{error:e.message}})));if(this.lastRequestTimeEnd=Date.now(),this.lastResponseStatus=e.status,this.transaction.data=new Uint8Array(0),e.status>=200&&e.status<300)return this.txPosted=!0,void(this.chunkIndex=1);throw this.lastResponseError=(0,i.getError)(e),new Error(`Unable to upload transaction: ${e.status}, ${this.lastResponseError}`)}const e=await this.api.post("tx",this.transaction);if(this.lastRequestTimeEnd=Date.now(),this.lastResponseStatus=e.status,!(e.status>=200&&e.status<300))throw this.lastResponseError=(0,i.getError)(e),new Error(`Unable to upload transaction: ${e.status}, ${this.lastResponseError}`);this.txPosted=!0}}t.TransactionUploader=u},813:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Tag=void 0;const n=r(848),a=r(475),i=r(647);class s{get(e,t){if(!Object.getOwnPropertyNames(this).includes(e))throw new Error(`Field "${e}" is not a property of the Arweave Transaction class.`);if(this[e]instanceof Uint8Array)return t&&t.decode&&t.string?n.bufferToString(this[e]):t&&t.decode&&!t.string?this[e]:n.bufferTob64Url(this[e]);if(this[e]instanceof Array){if(void 0!==t?.decode||void 0!==t?.string)throw"tags"===e&&console.warn("Did you mean to use 'transaction[\"tags\"]' ?"),new Error("Cannot decode or stringify an array.");return this[e]}return t&&1==t.decode?t&&t.string?n.b64UrlToString(this[e]):n.b64UrlToBuffer(this[e]):this[e]}}class o extends s{name;value;constructor(e,t,r=!1){super(),this.name=e,this.value=t}}t.Tag=o,t.default=class extends s{format=2;id="";last_tx="";owner="";tags=[];target="";quantity="0";data_size="0";data=new Uint8Array;data_root="";reward="0";signature="";chunks;constructor(e={}){super(),Object.assign(this,e),"string"==typeof this.data&&(this.data=n.b64UrlToBuffer(this.data)),e.tags&&(this.tags=e.tags.map((e=>new o(e.name,e.value))))}addTag(e,t){this.tags.push(new o(n.stringToB64Url(e),n.stringToB64Url(t)))}toJSON(){return{format:this.format,id:this.id,last_tx:this.last_tx,owner:this.owner,tags:this.tags,target:this.target,quantity:this.quantity,data:n.bufferTob64Url(this.data),data_size:this.data_size,data_root:this.data_root,data_tree:this.data_tree,reward:this.reward,signature:this.signature}}setOwner(e){this.owner=e}setSignature({id:e,owner:t,reward:r,tags:n,signature:a}){this.id=e,this.owner=t,r&&(this.reward=r),n&&(this.tags=n),this.signature=a}async prepareChunks(e){!this.chunks&&e.byteLength>0&&(this.chunks=await(0,i.generateTransactionChunks)(e),this.data_root=n.bufferTob64Url(this.chunks.data_root)),this.chunks||0!==e.byteLength||(this.chunks={chunks:[],data_root:new Uint8Array,proofs:[]},this.data_root="")}getChunk(e,t){if(!this.chunks)throw new Error("Chunks have not been prepared");const r=this.chunks.proofs[e],a=this.chunks.chunks[e];return{data_root:this.data_root,data_size:this.data_size,data_path:n.bufferTob64Url(r.proof),offset:r.offset.toString(),chunk:n.bufferTob64Url(t.slice(a.minByteRange,a.maxByteRange))}}async getSignatureData(){switch(this.format){case 1:let e=this.tags.reduce(((e,t)=>n.concatBuffers([e,t.get("name",{decode:!0,string:!1}),t.get("value",{decode:!0,string:!1})])),new Uint8Array);return n.concatBuffers([this.get("owner",{decode:!0,string:!1}),this.get("target",{decode:!0,string:!1}),this.get("data",{decode:!0,string:!1}),n.stringToBuffer(this.quantity),n.stringToBuffer(this.reward),this.get("last_tx",{decode:!0,string:!1}),e]);case 2:this.data_root||await this.prepareChunks(this.data);const t=this.tags.map((e=>[e.get("name",{decode:!0,string:!1}),e.get("value",{decode:!0,string:!1})]));return await(0,a.default)([n.stringToBuffer(this.format.toString()),this.get("owner",{decode:!0,string:!1}),this.get("target",{decode:!0,string:!1}),n.stringToBuffer(this.quantity),n.stringToBuffer(this.reward),this.get("last_tx",{decode:!0,string:!1}),t,n.stringToBuffer(this.data_size),this.get("data_root",{decode:!0,string:!1})]);default:throw new Error(`Unexpected transaction format: ${this.format}`)}}}},848:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.b64UrlDecode=t.b64UrlEncode=t.bufferTob64Url=t.bufferTob64=t.b64UrlToBuffer=t.stringToB64Url=t.stringToBuffer=t.bufferToString=t.b64UrlToString=t.concatBuffers=void 0;const n=r(526);function a(e){return new TextDecoder("utf-8",{fatal:!0}).decode(e)}function i(e){return(new TextEncoder).encode(e)}function s(e){return new Uint8Array(n.toByteArray(l(e)))}function o(e){return n.fromByteArray(new Uint8Array(e))}function u(e){return c(o(e))}function c(e){try{return e.replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}catch(e){throw new Error("Failed to encode string",{cause:e})}}function l(e){try{let t;return t=(e=e.replace(/\-/g,"+").replace(/\_/g,"/")).length%4==0?0:4-e.length%4,e.concat("=".repeat(t))}catch(e){throw new Error("Failed to decode string",{cause:e})}}t.concatBuffers=function(e){let t=0;for(let r=0;r<e.length;r++)t+=e[r].byteLength;let r=new Uint8Array(t),n=0;r.set(new Uint8Array(e[0]),n),n+=e[0].byteLength;for(let t=1;t<e.length;t++)r.set(new Uint8Array(e[t]),n),n+=e[t].byteLength;return r},t.b64UrlToString=function(e){return a(s(e))},t.bufferToString=a,t.stringToBuffer=i,t.stringToB64Url=function(e){return u(i(e))},t.b64UrlToBuffer=s,t.bufferTob64=o,t.bufferTob64Url=u,t.b64UrlEncode=c,t.b64UrlDecode=l},525:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getDefaultConfig=void 0,t.getDefaultConfig=(e,t)=>{if(((e,t)=>{const r=/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/,n=t.split("."),a=n[n.length-1],i=["localhost","[::1]"];return i.includes(t)||"file"==e||i.includes(a)||!!t.match(r)||!!a.match(r)})(e,t))return{protocol:"https",host:"arweave.net",port:443};if(!(e=>{const t="["===e.charAt(0);return!!e.match(/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/)||t})(t)){let r=t.split(".");if(r.length>=3)return r.shift(),{protocol:e,host:r.join(".")}}return{protocol:e,host:t}}},779:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{api;constructor(e){this.api=e}getInfo(){return this.api.get("info").then((e=>e.data))}getPeers(){return this.api.get("peers").then((e=>e.data))}}},716:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SiloResource=void 0;const n=r(848);t.default=class{api;crypto;transactions;constructor(e,t,r){this.api=e,this.crypto=t,this.transactions=r}async get(e){if(!e)throw new Error("No Silo URI specified");const t=await this.parseUri(e),r=await this.transactions.search("Silo-Name",t.getAccessKey());if(0==r.length)throw new Error(`No data could be found for the Silo URI: ${e}`);const n=await this.transactions.get(r[0]);if(!n)throw new Error(`No data could be found for the Silo URI: ${e}`);const a=n.get("data",{decode:!0,string:!1});return this.crypto.decrypt(a,t.getEncryptionKey())}async readTransactionData(e,t){if(!t)throw new Error("No Silo URI specified");const r=await this.parseUri(t),n=e.get("data",{decode:!0,string:!1});return this.crypto.decrypt(n,r.getEncryptionKey())}async parseUri(e){const t=e.match(/^([a-z0-9-_]+)\.([0-9]+)/i);if(!t)throw new Error("Invalid Silo name, must be a name in the format of [a-z0-9]+.[0-9]+, e.g. 'bubble.7'");const r=t[1],i=Math.pow(2,parseInt(t[2])),s=await this.hash(n.stringToBuffer(r),i),o=n.bufferTob64(s.slice(0,15)),u=await this.hash(s.slice(16,31),1);return new a(e,o,u)}async hash(e,t){let r=await this.crypto.hash(e);for(let e=0;e<t-1;e++)r=await this.crypto.hash(r);return r}};class a{uri;accessKey;encryptionKey;constructor(e,t,r){this.uri=e,this.accessKey=t,this.encryptionKey=r}getUri(){return this.uri}getAccessKey(){return this.accessKey}getEncryptionKey(){return this.encryptionKey}}t.SiloResource=a},320:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=r(911),a=r(813),i=r(848),s=r(472);r(204),t.default=class{api;crypto;chunks;constructor(e,t,r){this.api=e,this.crypto=t,this.chunks=r}async getTransactionAnchor(){const e=await this.api.get("tx_anchor");if(!e.data.match(/^[a-z0-9_-]{43,}/i)||!e.ok)throw new Error(`Could not getTransactionAnchor. Received: ${e.data}. Status: ${e.status}, ${e.statusText}`);return e.data}async getPrice(e,t){let r=t?`price/${e}/${t}`:`price/${e}`;const n=await this.api.get(r);if(!/^\d+$/.test(n.data)||!n.ok)throw new Error(`Could not getPrice. Received: ${n.data}. Status: ${n.status}, ${n.statusText}`);return n.data}async get(e){const t=await this.api.get(`tx/${e}`);if(200==t.status){const r=parseInt(t.data.data_size);if(t.data.format>=2&&r>0&&r<=12582912){const r=await this.getData(e);return new a.default({...t.data,data:r})}return new a.default({...t.data,format:t.data.format||1})}if(404==t.status)throw new n.default("TX_NOT_FOUND");if(410==t.status)throw new n.default("TX_FAILED");throw new n.default("TX_INVALID")}fromRaw(e){return new a.default(e)}async search(e,t){return this.api.post("arql",{op:"equals",expr1:e,expr2:t}).then((e=>e.data?e.data:[]))}getStatus(e){return this.api.get(`tx/${e}/status`).then((e=>200==e.status?{status:200,confirmed:e.data}:{status:e.status,confirmed:null}))}async getData(e,t){let r;try{r=await this.chunks.downloadChunkedData(e)}catch(t){console.error(`Error while trying to download chunked data for ${e}`),console.error(t)}if(!r){console.warn(`Falling back to gateway cache for ${e}`);try{const{data:t,ok:n,status:a,statusText:i}=await this.api.get(`/${e}`,{responseType:"arraybuffer"});if(!n)throw new Error("Bad http status code",{cause:{status:a,statusText:i}});r=t}catch(t){console.error(`Error while trying to download contiguous data from gateway cache for ${e}`),console.error(t)}}if(!r)throw new Error(`${e} data was not found!`);return t&&t.decode&&!t.string?r:t&&t.decode&&t.string?i.bufferToString(r):i.bufferTob64Url(r)}async sign(e,t,r){const n="object"==typeof t&&(e=>{let t=!0;return["n","e","d","p","q","dp","dq","qi"].map((r=>!(r in e)&&(t=!1))),t})(t),a="object"==typeof arweaveWallet;if(!n&&!a)throw new Error("No valid JWK or external wallet found to sign transaction.");if(n){e.setOwner(t.n);let n=await e.getSignatureData(),a=await this.crypto.sign(t,n,r),s=await this.crypto.hash(a);e.setSignature({id:i.bufferTob64Url(s),owner:t.n,signature:i.bufferTob64Url(a)})}else{if(!a)throw new Error("An error occurred while signing. Check wallet is valid");{try{(await arweaveWallet.getPermissions()).includes("SIGN_TRANSACTION")||await arweaveWallet.connect(["SIGN_TRANSACTION"])}catch{}const t=await arweaveWallet.sign(e,r);e.setSignature({id:t.id,owner:t.owner,reward:t.reward,tags:t.tags,signature:t.signature})}}}async verify(e){const t=await e.getSignatureData(),r=e.get("signature",{decode:!0,string:!1}),n=i.bufferTob64Url(await this.crypto.hash(r));if(e.id!==n)throw new Error("Invalid transaction signature or ID! The transaction ID doesn't match the expected SHA-256 hash of the signature.");return this.crypto.verify(e.owner,t,r)}async post(e){if("string"==typeof e?e=new a.default(JSON.parse(e)):"function"==typeof e.readInt32BE?e=new a.default(JSON.parse(e.toString())):"object"!=typeof e||e instanceof a.default||(e=new a.default(e)),!(e instanceof a.default))throw new Error("Must be Transaction object");e.chunks||await e.prepareChunks(e.data);const t=await this.getUploader(e,e.data);try{for(;!t.isComplete;)await t.uploadChunk()}catch(e){if(t.lastResponseStatus>0)return{status:t.lastResponseStatus,statusText:t.lastResponseError,data:{error:t.lastResponseError}};throw e}return{status:200,statusText:"OK",data:{}}}async getUploader(e,t){let r;if(t instanceof ArrayBuffer&&(t=new Uint8Array(t)),e instanceof a.default){if(t||(t=e.data),!(t instanceof Uint8Array))throw new Error("Data format is invalid");e.chunks||await e.prepareChunks(t),r=new s.TransactionUploader(this.api,e),r.data&&0!==r.data.length||(r.data=t)}else{if("string"==typeof e&&(e=await s.TransactionUploader.fromTransactionId(this.api,e)),!(t&&t instanceof Uint8Array))throw new Error("Must provide data when resuming upload");r=await s.TransactionUploader.fromSerialized(this.api,e,t)}return r}async*upload(e,t){const r=await this.getUploader(e,t);for(;!r.isComplete;)await r.uploadChunk(),yield r;return r}}},115:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=r(848);r(204),t.default=class{api;crypto;constructor(e,t){this.api=e,this.crypto=t}getBalance(e){return this.api.get(`wallet/${e}/balance`).then((e=>e.data))}getLastTransactionID(e){return this.api.get(`wallet/${e}/last_tx`).then((e=>e.data))}generate(){return this.crypto.generateJWK()}async jwkToAddress(e){return e&&"use_wallet"!==e?this.getAddress(e):this.getAddress()}async getAddress(e){if(e&&"use_wallet"!==e)return this.ownerToAddress(e.n);try{await arweaveWallet.connect(["ACCESS_ADDRESS"])}catch{}return arweaveWallet.getActiveAddress()}async ownerToAddress(e){return n.bufferTob64Url(await this.crypto.hash(n.b64UrlToBuffer(e)))}}},526:(e,t)=>{t.byteLength=function(e){var t=o(e),r=t[0],n=t[1];return 3*(r+n)/4-n},t.toByteArray=function(e){var t,r,i=o(e),s=i[0],u=i[1],c=new a(function(e,t,r){return 3*(t+r)/4-r}(0,s,u)),l=0,h=u>0?s-4:s;for(r=0;r<h;r+=4)t=n[e.charCodeAt(r)]<<18|n[e.charCodeAt(r+1)]<<12|n[e.charCodeAt(r+2)]<<6|n[e.charCodeAt(r+3)],c[l++]=t>>16&255,c[l++]=t>>8&255,c[l++]=255&t;return 2===u&&(t=n[e.charCodeAt(r)]<<2|n[e.charCodeAt(r+1)]>>4,c[l++]=255&t),1===u&&(t=n[e.charCodeAt(r)]<<10|n[e.charCodeAt(r+1)]<<4|n[e.charCodeAt(r+2)]>>2,c[l++]=t>>8&255,c[l++]=255&t),c},t.fromByteArray=function(e){for(var t,n=e.length,a=n%3,i=[],s=16383,o=0,c=n-a;o<c;o+=s)i.push(u(e,o,o+s>c?c:o+s));return 1===a?(t=e[n-1],i.push(r[t>>2]+r[t<<4&63]+"==")):2===a&&(t=(e[n-2]<<8)+e[n-1],i.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"=")),i.join("")};for(var r=[],n=[],a="undefined"!=typeof Uint8Array?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0;s<64;++s)r[s]=i[s],n[i.charCodeAt(s)]=s;function o(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function u(e,t,n){for(var a,i,s=[],o=t;o<n;o+=3)a=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(255&e[o+2]),s.push(r[(i=a)>>18&63]+r[i>>12&63]+r[i>>6&63]+r[63&i]);return s.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},594:function(e,t,r){var n;!function(){var a,i=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,s=Math.ceil,o=Math.floor,u="[BigNumber Error] ",c=u+"Number primitive has more than 15 significant digits: ",l=1e14,h=14,d=9007199254740991,f=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],p=1e7,g=1e9;function y(e){var t=0|e;return e>0||e===t?t:t-1}function m(e){for(var t,r,n=1,a=e.length,i=e[0]+"";n<a;){for(t=e[n++]+"",r=h-t.length;r--;t="0"+t);i+=t}for(a=i.length;48===i.charCodeAt(--a););return i.slice(0,a+1||1)}function v(e,t){var r,n,a=e.c,i=t.c,s=e.s,o=t.s,u=e.e,c=t.e;if(!s||!o)return null;if(r=a&&!a[0],n=i&&!i[0],r||n)return r?n?0:-o:s;if(s!=o)return s;if(r=s<0,n=u==c,!a||!i)return n?0:!a^r?1:-1;if(!n)return u>c^r?1:-1;for(o=(u=a.length)<(c=i.length)?u:c,s=0;s<o;s++)if(a[s]!=i[s])return a[s]>i[s]^r?1:-1;return u==c?0:u>c^r?1:-1}function w(e,t,r,n){if(e<t||e>r||e!==o(e))throw Error(u+(n||"Argument")+("number"==typeof e?e<t||e>r?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function b(e){var t=e.c.length-1;return y(e.e/h)==t&&e.c[t]%2!=0}function _(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function T(e,t,r){var n,a;if(t<0){for(a=r+".";++t;a+=r);e=a+e}else if(++t>(n=e.length)){for(a=r,t-=n;--t;a+=r);e+=a}else t<n&&(e=e.slice(0,t)+"."+e.slice(t));return e}a=function e(t){var r,n,a,E,k,A,x,S,O,C,R=K.prototype={constructor:K,toString:null,valueOf:null},I=new K(1),B=20,U=4,j=-7,N=21,P=-1e7,L=1e7,$=!1,M=1,Z=0,D={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},F="0123456789abcdefghijklmnopqrstuvwxyz",z=!0;function K(e,t){var r,s,u,l,f,p,g,y,m=this;if(!(m instanceof K))return new K(e,t);if(null==t){if(e&&!0===e._isBigNumber)return m.s=e.s,void(!e.c||e.e>L?m.c=m.e=null:e.e<P?m.c=[m.e=0]:(m.e=e.e,m.c=e.c.slice()));if((p="number"==typeof e)&&0*e==0){if(m.s=1/e<0?(e=-e,-1):1,e===~~e){for(l=0,f=e;f>=10;f/=10,l++);return void(l>L?m.c=m.e=null:(m.e=l,m.c=[e]))}y=String(e)}else{if(!i.test(y=String(e)))return a(m,y,p);m.s=45==y.charCodeAt(0)?(y=y.slice(1),-1):1}(l=y.indexOf("."))>-1&&(y=y.replace(".","")),(f=y.search(/e/i))>0?(l<0&&(l=f),l+=+y.slice(f+1),y=y.substring(0,f)):l<0&&(l=y.length)}else{if(w(t,2,F.length,"Base"),10==t&&z)return V(m=new K(e),B+m.e+1,U);if(y=String(e),p="number"==typeof e){if(0*e!=0)return a(m,y,p,t);if(m.s=1/e<0?(y=y.slice(1),-1):1,K.DEBUG&&y.replace(/^0\.0*|\./,"").length>15)throw Error(c+e)}else m.s=45===y.charCodeAt(0)?(y=y.slice(1),-1):1;for(r=F.slice(0,t),l=f=0,g=y.length;f<g;f++)if(r.indexOf(s=y.charAt(f))<0){if("."==s){if(f>l){l=g;continue}}else if(!u&&(y==y.toUpperCase()&&(y=y.toLowerCase())||y==y.toLowerCase()&&(y=y.toUpperCase()))){u=!0,f=-1,l=0;continue}return a(m,String(e),p,t)}p=!1,(l=(y=n(y,t,10,m.s)).indexOf("."))>-1?y=y.replace(".",""):l=y.length}for(f=0;48===y.charCodeAt(f);f++);for(g=y.length;48===y.charCodeAt(--g););if(y=y.slice(f,++g)){if(g-=f,p&&K.DEBUG&&g>15&&(e>d||e!==o(e)))throw Error(c+m.s*e);if((l=l-f-1)>L)m.c=m.e=null;else if(l<P)m.c=[m.e=0];else{if(m.e=l,m.c=[],f=(l+1)%h,l<0&&(f+=h),f<g){for(f&&m.c.push(+y.slice(0,f)),g-=h;f<g;)m.c.push(+y.slice(f,f+=h));f=h-(y=y.slice(f)).length}else f-=g;for(;f--;y+="0");m.c.push(+y)}}else m.c=[m.e=0]}function q(e,t,r,n){var a,i,s,o,u;if(null==r?r=U:w(r,0,8),!e.c)return e.toString();if(a=e.c[0],s=e.e,null==t)u=m(e.c),u=1==n||2==n&&(s<=j||s>=N)?_(u,s):T(u,s,"0");else if(i=(e=V(new K(e),t,r)).e,o=(u=m(e.c)).length,1==n||2==n&&(t<=i||i<=j)){for(;o<t;u+="0",o++);u=_(u,i)}else if(t-=s,u=T(u,i,"0"),i+1>o){if(--t>0)for(u+=".";t--;u+="0");}else if((t+=i-o)>0)for(i+1==o&&(u+=".");t--;u+="0");return e.s<0&&a?"-"+u:u}function H(e,t){for(var r,n,a=1,i=new K(e[0]);a<e.length;a++)(!(n=new K(e[a])).s||(r=v(i,n))===t||0===r&&i.s===t)&&(i=n);return i}function G(e,t,r){for(var n=1,a=t.length;!t[--a];t.pop());for(a=t[0];a>=10;a/=10,n++);return(r=n+r*h-1)>L?e.c=e.e=null:r<P?e.c=[e.e=0]:(e.e=r,e.c=t),e}function V(e,t,r,n){var a,i,u,c,d,p,g,y=e.c,m=f;if(y){e:{for(a=1,c=y[0];c>=10;c/=10,a++);if((i=t-a)<0)i+=h,u=t,d=y[p=0],g=o(d/m[a-u-1]%10);else if((p=s((i+1)/h))>=y.length){if(!n)break e;for(;y.length<=p;y.push(0));d=g=0,a=1,u=(i%=h)-h+1}else{for(d=c=y[p],a=1;c>=10;c/=10,a++);g=(u=(i%=h)-h+a)<0?0:o(d/m[a-u-1]%10)}if(n=n||t<0||null!=y[p+1]||(u<0?d:d%m[a-u-1]),n=r<4?(g||n)&&(0==r||r==(e.s<0?3:2)):g>5||5==g&&(4==r||n||6==r&&(i>0?u>0?d/m[a-u]:0:y[p-1])%10&1||r==(e.s<0?8:7)),t<1||!y[0])return y.length=0,n?(t-=e.e+1,y[0]=m[(h-t%h)%h],e.e=-t||0):y[0]=e.e=0,e;if(0==i?(y.length=p,c=1,p--):(y.length=p+1,c=m[h-i],y[p]=u>0?o(d/m[a-u]%m[u])*c:0),n)for(;;){if(0==p){for(i=1,u=y[0];u>=10;u/=10,i++);for(u=y[0]+=c,c=1;u>=10;u/=10,c++);i!=c&&(e.e++,y[0]==l&&(y[0]=1));break}if(y[p]+=c,y[p]!=l)break;y[p--]=0,c=1}for(i=y.length;0===y[--i];y.pop());}e.e>L?e.c=e.e=null:e.e<P&&(e.c=[e.e=0])}return e}function W(e){var t,r=e.e;return null===r?e.toString():(t=m(e.c),t=r<=j||r>=N?_(t,r):T(t,r,"0"),e.s<0?"-"+t:t)}return K.clone=e,K.ROUND_UP=0,K.ROUND_DOWN=1,K.ROUND_CEIL=2,K.ROUND_FLOOR=3,K.ROUND_HALF_UP=4,K.ROUND_HALF_DOWN=5,K.ROUND_HALF_EVEN=6,K.ROUND_HALF_CEIL=7,K.ROUND_HALF_FLOOR=8,K.EUCLID=9,K.config=K.set=function(e){var t,r;if(null!=e){if("object"!=typeof e)throw Error(u+"Object expected: "+e);if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(w(r=e[t],0,g,t),B=r),e.hasOwnProperty(t="ROUNDING_MODE")&&(w(r=e[t],0,8,t),U=r),e.hasOwnProperty(t="EXPONENTIAL_AT")&&((r=e[t])&&r.pop?(w(r[0],-g,0,t),w(r[1],0,g,t),j=r[0],N=r[1]):(w(r,-g,g,t),j=-(N=r<0?-r:r))),e.hasOwnProperty(t="RANGE"))if((r=e[t])&&r.pop)w(r[0],-g,-1,t),w(r[1],1,g,t),P=r[0],L=r[1];else{if(w(r,-g,g,t),!r)throw Error(u+t+" cannot be zero: "+r);P=-(L=r<0?-r:r)}if(e.hasOwnProperty(t="CRYPTO")){if((r=e[t])!==!!r)throw Error(u+t+" not true or false: "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw $=!r,Error(u+"crypto unavailable");$=r}else $=r}if(e.hasOwnProperty(t="MODULO_MODE")&&(w(r=e[t],0,9,t),M=r),e.hasOwnProperty(t="POW_PRECISION")&&(w(r=e[t],0,g,t),Z=r),e.hasOwnProperty(t="FORMAT")){if("object"!=typeof(r=e[t]))throw Error(u+t+" not an object: "+r);D=r}if(e.hasOwnProperty(t="ALPHABET")){if("string"!=typeof(r=e[t])||/^.?$|[+\-.\s]|(.).*\1/.test(r))throw Error(u+t+" invalid: "+r);z="0123456789"==r.slice(0,10),F=r}}return{DECIMAL_PLACES:B,ROUNDING_MODE:U,EXPONENTIAL_AT:[j,N],RANGE:[P,L],CRYPTO:$,MODULO_MODE:M,POW_PRECISION:Z,FORMAT:D,ALPHABET:F}},K.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!K.DEBUG)return!0;var t,r,n=e.c,a=e.e,i=e.s;e:if("[object Array]"=={}.toString.call(n)){if((1===i||-1===i)&&a>=-g&&a<=g&&a===o(a)){if(0===n[0]){if(0===a&&1===n.length)return!0;break e}if((t=(a+1)%h)<1&&(t+=h),String(n[0]).length==t){for(t=0;t<n.length;t++)if((r=n[t])<0||r>=l||r!==o(r))break e;if(0!==r)return!0}}}else if(null===n&&null===a&&(null===i||1===i||-1===i))return!0;throw Error(u+"Invalid BigNumber: "+e)},K.maximum=K.max=function(){return H(arguments,-1)},K.minimum=K.min=function(){return H(arguments,1)},K.random=(E=9007199254740992,k=Math.random()*E&2097151?function(){return o(Math.random()*E)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var t,r,n,a,i,c=0,l=[],d=new K(I);if(null==e?e=B:w(e,0,g),a=s(e/h),$)if(crypto.getRandomValues){for(t=crypto.getRandomValues(new Uint32Array(a*=2));c<a;)(i=131072*t[c]+(t[c+1]>>>11))>=9e15?(r=crypto.getRandomValues(new Uint32Array(2)),t[c]=r[0],t[c+1]=r[1]):(l.push(i%1e14),c+=2);c=a/2}else{if(!crypto.randomBytes)throw $=!1,Error(u+"crypto unavailable");for(t=crypto.randomBytes(a*=7);c<a;)(i=281474976710656*(31&t[c])+1099511627776*t[c+1]+4294967296*t[c+2]+16777216*t[c+3]+(t[c+4]<<16)+(t[c+5]<<8)+t[c+6])>=9e15?crypto.randomBytes(7).copy(t,c):(l.push(i%1e14),c+=7);c=a/7}if(!$)for(;c<a;)(i=k())<9e15&&(l[c++]=i%1e14);for(a=l[--c],e%=h,a&&e&&(i=f[h-e],l[c]=o(a/i)*i);0===l[c];l.pop(),c--);if(c<0)l=[n=0];else{for(n=-1;0===l[0];l.splice(0,1),n-=h);for(c=1,i=l[0];i>=10;i/=10,c++);c<h&&(n-=h-c)}return d.e=n,d.c=l,d}),K.sum=function(){for(var e=1,t=arguments,r=new K(t[0]);e<t.length;)r=r.plus(t[e++]);return r},n=function(){var e="0123456789";function t(e,t,r,n){for(var a,i,s=[0],o=0,u=e.length;o<u;){for(i=s.length;i--;s[i]*=t);for(s[0]+=n.indexOf(e.charAt(o++)),a=0;a<s.length;a++)s[a]>r-1&&(null==s[a+1]&&(s[a+1]=0),s[a+1]+=s[a]/r|0,s[a]%=r)}return s.reverse()}return function(n,a,i,s,o){var u,c,l,h,d,f,p,g,y=n.indexOf("."),v=B,w=U;for(y>=0&&(h=Z,Z=0,n=n.replace(".",""),f=(g=new K(a)).pow(n.length-y),Z=h,g.c=t(T(m(f.c),f.e,"0"),10,i,e),g.e=g.c.length),l=h=(p=t(n,a,i,o?(u=F,e):(u=e,F))).length;0==p[--h];p.pop());if(!p[0])return u.charAt(0);if(y<0?--l:(f.c=p,f.e=l,f.s=s,p=(f=r(f,g,v,w,i)).c,d=f.r,l=f.e),y=p[c=l+v+1],h=i/2,d=d||c<0||null!=p[c+1],d=w<4?(null!=y||d)&&(0==w||w==(f.s<0?3:2)):y>h||y==h&&(4==w||d||6==w&&1&p[c-1]||w==(f.s<0?8:7)),c<1||!p[0])n=d?T(u.charAt(1),-v,u.charAt(0)):u.charAt(0);else{if(p.length=c,d)for(--i;++p[--c]>i;)p[c]=0,c||(++l,p=[1].concat(p));for(h=p.length;!p[--h];);for(y=0,n="";y<=h;n+=u.charAt(p[y++]));n=T(n,l,u.charAt(0))}return n}}(),r=function(){function e(e,t,r){var n,a,i,s,o=0,u=e.length,c=t%p,l=t/p|0;for(e=e.slice();u--;)o=((a=c*(i=e[u]%p)+(n=l*i+(s=e[u]/p|0)*c)%p*p+o)/r|0)+(n/p|0)+l*s,e[u]=a%r;return o&&(e=[o].concat(e)),e}function t(e,t,r,n){var a,i;if(r!=n)i=r>n?1:-1;else for(a=i=0;a<r;a++)if(e[a]!=t[a]){i=e[a]>t[a]?1:-1;break}return i}function r(e,t,r,n){for(var a=0;r--;)e[r]-=a,a=e[r]<t[r]?1:0,e[r]=a*n+e[r]-t[r];for(;!e[0]&&e.length>1;e.splice(0,1));}return function(n,a,i,s,u){var c,d,f,p,g,m,v,w,b,_,T,E,k,A,x,S,O,C=n.s==a.s?1:-1,R=n.c,I=a.c;if(!(R&&R[0]&&I&&I[0]))return new K(n.s&&a.s&&(R?!I||R[0]!=I[0]:I)?R&&0==R[0]||!I?0*C:C/0:NaN);for(b=(w=new K(C)).c=[],C=i+(d=n.e-a.e)+1,u||(u=l,d=y(n.e/h)-y(a.e/h),C=C/h|0),f=0;I[f]==(R[f]||0);f++);if(I[f]>(R[f]||0)&&d--,C<0)b.push(1),p=!0;else{for(A=R.length,S=I.length,f=0,C+=2,(g=o(u/(I[0]+1)))>1&&(I=e(I,g,u),R=e(R,g,u),S=I.length,A=R.length),k=S,T=(_=R.slice(0,S)).length;T<S;_[T++]=0);O=I.slice(),O=[0].concat(O),x=I[0],I[1]>=u/2&&x++;do{if(g=0,(c=t(I,_,S,T))<0){if(E=_[0],S!=T&&(E=E*u+(_[1]||0)),(g=o(E/x))>1)for(g>=u&&(g=u-1),v=(m=e(I,g,u)).length,T=_.length;1==t(m,_,v,T);)g--,r(m,S<v?O:I,v,u),v=m.length,c=1;else 0==g&&(c=g=1),v=(m=I.slice()).length;if(v<T&&(m=[0].concat(m)),r(_,m,T,u),T=_.length,-1==c)for(;t(I,_,S,T)<1;)g++,r(_,S<T?O:I,T,u),T=_.length}else 0===c&&(g++,_=[0]);b[f++]=g,_[0]?_[T++]=R[k]||0:(_=[R[k]],T=1)}while((k++<A||null!=_[0])&&C--);p=null!=_[0],b[0]||b.splice(0,1)}if(u==l){for(f=1,C=b[0];C>=10;C/=10,f++);V(w,i+(w.e=f+d*h-1)+1,s,p)}else w.e=d,w.r=+p;return w}}(),A=/^(-?)0([xbo])(?=\w[\w.]*$)/i,x=/^([^.]+)\.$/,S=/^\.([^.]+)$/,O=/^-?(Infinity|NaN)$/,C=/^\s*\+(?=[\w.])|^\s+|\s+$/g,a=function(e,t,r,n){var a,i=r?t:t.replace(C,"");if(O.test(i))e.s=isNaN(i)?null:i<0?-1:1;else{if(!r&&(i=i.replace(A,(function(e,t,r){return a="x"==(r=r.toLowerCase())?16:"b"==r?2:8,n&&n!=a?e:t})),n&&(a=n,i=i.replace(x,"$1").replace(S,"0.$1")),t!=i))return new K(i,a);if(K.DEBUG)throw Error(u+"Not a"+(n?" base "+n:"")+" number: "+t);e.s=null}e.c=e.e=null},R.absoluteValue=R.abs=function(){var e=new K(this);return e.s<0&&(e.s=1),e},R.comparedTo=function(e,t){return v(this,new K(e,t))},R.decimalPlaces=R.dp=function(e,t){var r,n,a,i=this;if(null!=e)return w(e,0,g),null==t?t=U:w(t,0,8),V(new K(i),e+i.e+1,t);if(!(r=i.c))return null;if(n=((a=r.length-1)-y(this.e/h))*h,a=r[a])for(;a%10==0;a/=10,n--);return n<0&&(n=0),n},R.dividedBy=R.div=function(e,t){return r(this,new K(e,t),B,U)},R.dividedToIntegerBy=R.idiv=function(e,t){return r(this,new K(e,t),0,1)},R.exponentiatedBy=R.pow=function(e,t){var r,n,a,i,c,l,d,f,p=this;if((e=new K(e)).c&&!e.isInteger())throw Error(u+"Exponent not an integer: "+W(e));if(null!=t&&(t=new K(t)),c=e.e>14,!p.c||!p.c[0]||1==p.c[0]&&!p.e&&1==p.c.length||!e.c||!e.c[0])return f=new K(Math.pow(+W(p),c?e.s*(2-b(e)):+W(e))),t?f.mod(t):f;if(l=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new K(NaN);(n=!l&&p.isInteger()&&t.isInteger())&&(p=p.mod(t))}else{if(e.e>9&&(p.e>0||p.e<-1||(0==p.e?p.c[0]>1||c&&p.c[1]>=24e7:p.c[0]<8e13||c&&p.c[0]<=9999975e7)))return i=p.s<0&&b(e)?-0:0,p.e>-1&&(i=1/i),new K(l?1/i:i);Z&&(i=s(Z/h+2))}for(c?(r=new K(.5),l&&(e.s=1),d=b(e)):d=(a=Math.abs(+W(e)))%2,f=new K(I);;){if(d){if(!(f=f.times(p)).c)break;i?f.c.length>i&&(f.c.length=i):n&&(f=f.mod(t))}if(a){if(0===(a=o(a/2)))break;d=a%2}else if(V(e=e.times(r),e.e+1,1),e.e>14)d=b(e);else{if(0==(a=+W(e)))break;d=a%2}p=p.times(p),i?p.c&&p.c.length>i&&(p.c.length=i):n&&(p=p.mod(t))}return n?f:(l&&(f=I.div(f)),t?f.mod(t):i?V(f,Z,U,void 0):f)},R.integerValue=function(e){var t=new K(this);return null==e?e=U:w(e,0,8),V(t,t.e+1,e)},R.isEqualTo=R.eq=function(e,t){return 0===v(this,new K(e,t))},R.isFinite=function(){return!!this.c},R.isGreaterThan=R.gt=function(e,t){return v(this,new K(e,t))>0},R.isGreaterThanOrEqualTo=R.gte=function(e,t){return 1===(t=v(this,new K(e,t)))||0===t},R.isInteger=function(){return!!this.c&&y(this.e/h)>this.c.length-2},R.isLessThan=R.lt=function(e,t){return v(this,new K(e,t))<0},R.isLessThanOrEqualTo=R.lte=function(e,t){return-1===(t=v(this,new K(e,t)))||0===t},R.isNaN=function(){return!this.s},R.isNegative=function(){return this.s<0},R.isPositive=function(){return this.s>0},R.isZero=function(){return!!this.c&&0==this.c[0]},R.minus=function(e,t){var r,n,a,i,s=this,o=s.s;if(t=(e=new K(e,t)).s,!o||!t)return new K(NaN);if(o!=t)return e.s=-t,s.plus(e);var u=s.e/h,c=e.e/h,d=s.c,f=e.c;if(!u||!c){if(!d||!f)return d?(e.s=-t,e):new K(f?s:NaN);if(!d[0]||!f[0])return f[0]?(e.s=-t,e):new K(d[0]?s:3==U?-0:0)}if(u=y(u),c=y(c),d=d.slice(),o=u-c){for((i=o<0)?(o=-o,a=d):(c=u,a=f),a.reverse(),t=o;t--;a.push(0));a.reverse()}else for(n=(i=(o=d.length)<(t=f.length))?o:t,o=t=0;t<n;t++)if(d[t]!=f[t]){i=d[t]<f[t];break}if(i&&(a=d,d=f,f=a,e.s=-e.s),(t=(n=f.length)-(r=d.length))>0)for(;t--;d[r++]=0);for(t=l-1;n>o;){if(d[--n]<f[n]){for(r=n;r&&!d[--r];d[r]=t);--d[r],d[n]+=l}d[n]-=f[n]}for(;0==d[0];d.splice(0,1),--c);return d[0]?G(e,d,c):(e.s=3==U?-1:1,e.c=[e.e=0],e)},R.modulo=R.mod=function(e,t){var n,a,i=this;return e=new K(e,t),!i.c||!e.s||e.c&&!e.c[0]?new K(NaN):!e.c||i.c&&!i.c[0]?new K(i):(9==M?(a=e.s,e.s=1,n=r(i,e,0,3),e.s=a,n.s*=a):n=r(i,e,0,M),(e=i.minus(n.times(e))).c[0]||1!=M||(e.s=i.s),e)},R.multipliedBy=R.times=function(e,t){var r,n,a,i,s,o,u,c,d,f,g,m,v,w,b,_=this,T=_.c,E=(e=new K(e,t)).c;if(!(T&&E&&T[0]&&E[0]))return!_.s||!e.s||T&&!T[0]&&!E||E&&!E[0]&&!T?e.c=e.e=e.s=null:(e.s*=_.s,T&&E?(e.c=[0],e.e=0):e.c=e.e=null),e;for(n=y(_.e/h)+y(e.e/h),e.s*=_.s,(u=T.length)<(f=E.length)&&(v=T,T=E,E=v,a=u,u=f,f=a),a=u+f,v=[];a--;v.push(0));for(w=l,b=p,a=f;--a>=0;){for(r=0,g=E[a]%b,m=E[a]/b|0,i=a+(s=u);i>a;)r=((c=g*(c=T[--s]%b)+(o=m*c+(d=T[s]/b|0)*g)%b*b+v[i]+r)/w|0)+(o/b|0)+m*d,v[i--]=c%w;v[i]=r}return r?++n:v.splice(0,1),G(e,v,n)},R.negated=function(){var e=new K(this);return e.s=-e.s||null,e},R.plus=function(e,t){var r,n=this,a=n.s;if(t=(e=new K(e,t)).s,!a||!t)return new K(NaN);if(a!=t)return e.s=-t,n.minus(e);var i=n.e/h,s=e.e/h,o=n.c,u=e.c;if(!i||!s){if(!o||!u)return new K(a/0);if(!o[0]||!u[0])return u[0]?e:new K(o[0]?n:0*a)}if(i=y(i),s=y(s),o=o.slice(),a=i-s){for(a>0?(s=i,r=u):(a=-a,r=o),r.reverse();a--;r.push(0));r.reverse()}for((a=o.length)-(t=u.length)<0&&(r=u,u=o,o=r,t=a),a=0;t;)a=(o[--t]=o[t]+u[t]+a)/l|0,o[t]=l===o[t]?0:o[t]%l;return a&&(o=[a].concat(o),++s),G(e,o,s)},R.precision=R.sd=function(e,t){var r,n,a,i=this;if(null!=e&&e!==!!e)return w(e,1,g),null==t?t=U:w(t,0,8),V(new K(i),e,t);if(!(r=i.c))return null;if(n=(a=r.length-1)*h+1,a=r[a]){for(;a%10==0;a/=10,n--);for(a=r[0];a>=10;a/=10,n++);}return e&&i.e+1>n&&(n=i.e+1),n},R.shiftedBy=function(e){return w(e,-9007199254740991,d),this.times("1e"+e)},R.squareRoot=R.sqrt=function(){var e,t,n,a,i,s=this,o=s.c,u=s.s,c=s.e,l=B+4,h=new K("0.5");if(1!==u||!o||!o[0])return new K(!u||u<0&&(!o||o[0])?NaN:o?s:1/0);if(0==(u=Math.sqrt(+W(s)))||u==1/0?(((t=m(o)).length+c)%2==0&&(t+="0"),u=Math.sqrt(+t),c=y((c+1)/2)-(c<0||c%2),n=new K(t=u==1/0?"5e"+c:(t=u.toExponential()).slice(0,t.indexOf("e")+1)+c)):n=new K(u+""),n.c[0])for((u=(c=n.e)+l)<3&&(u=0);;)if(i=n,n=h.times(i.plus(r(s,i,l,1))),m(i.c).slice(0,u)===(t=m(n.c)).slice(0,u)){if(n.e<c&&--u,"9999"!=(t=t.slice(u-3,u+1))&&(a||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(V(n,n.e+B+2,1),e=!n.times(n).eq(s));break}if(!a&&(V(i,i.e+B+2,0),i.times(i).eq(s))){n=i;break}l+=4,u+=4,a=1}return V(n,n.e+B+1,U,e)},R.toExponential=function(e,t){return null!=e&&(w(e,0,g),e++),q(this,e,t,1)},R.toFixed=function(e,t){return null!=e&&(w(e,0,g),e=e+this.e+1),q(this,e,t)},R.toFormat=function(e,t,r){var n,a=this;if(null==r)null!=e&&t&&"object"==typeof t?(r=t,t=null):e&&"object"==typeof e?(r=e,e=t=null):r=D;else if("object"!=typeof r)throw Error(u+"Argument not an object: "+r);if(n=a.toFixed(e,t),a.c){var i,s=n.split("."),o=+r.groupSize,c=+r.secondaryGroupSize,l=r.groupSeparator||"",h=s[0],d=s[1],f=a.s<0,p=f?h.slice(1):h,g=p.length;if(c&&(i=o,o=c,c=i,g-=i),o>0&&g>0){for(i=g%o||o,h=p.substr(0,i);i<g;i+=o)h+=l+p.substr(i,o);c>0&&(h+=l+p.slice(i)),f&&(h="-"+h)}n=d?h+(r.decimalSeparator||"")+((c=+r.fractionGroupSize)?d.replace(new RegExp("\\d{"+c+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):d):h}return(r.prefix||"")+n+(r.suffix||"")},R.toFraction=function(e){var t,n,a,i,s,o,c,l,d,p,g,y,v=this,w=v.c;if(null!=e&&(!(c=new K(e)).isInteger()&&(c.c||1!==c.s)||c.lt(I)))throw Error(u+"Argument "+(c.isInteger()?"out of range: ":"not an integer: ")+W(c));if(!w)return new K(v);for(t=new K(I),d=n=new K(I),a=l=new K(I),y=m(w),s=t.e=y.length-v.e-1,t.c[0]=f[(o=s%h)<0?h+o:o],e=!e||c.comparedTo(t)>0?s>0?t:d:c,o=L,L=1/0,c=new K(y),l.c[0]=0;p=r(c,t,0,1),1!=(i=n.plus(p.times(a))).comparedTo(e);)n=a,a=i,d=l.plus(p.times(i=d)),l=i,t=c.minus(p.times(i=t)),c=i;return i=r(e.minus(n),a,0,1),l=l.plus(i.times(d)),n=n.plus(i.times(a)),l.s=d.s=v.s,g=r(d,a,s*=2,U).minus(v).abs().comparedTo(r(l,n,s,U).minus(v).abs())<1?[d,a]:[l,n],L=o,g},R.toNumber=function(){return+W(this)},R.toPrecision=function(e,t){return null!=e&&w(e,1,g),q(this,e,t,2)},R.toString=function(e){var t,r=this,a=r.s,i=r.e;return null===i?a?(t="Infinity",a<0&&(t="-"+t)):t="NaN":(null==e?t=i<=j||i>=N?_(m(r.c),i):T(m(r.c),i,"0"):10===e&&z?t=T(m((r=V(new K(r),B+i+1,U)).c),r.e,"0"):(w(e,2,F.length,"Base"),t=n(T(m(r.c),i,"0"),10,e,a,!0)),a<0&&r.c[0]&&(t="-"+t)),t},R.valueOf=R.toJSON=function(){return W(this)},R._isBigNumber=!0,null!=t&&K.set(t),K}(),a.default=a.BigNumber=a,void 0===(n=function(){return a}.call(t,r,t,e))||(e.exports=n)}()}},t={};function r(n){var a=t[n];if(void 0!==a)return a.exports;var i=t[n]={exports:{}};return e[n].call(i.exports,i,i.exports,r),i.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},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.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};r.d(n,{AO:()=>jl,yw:()=>Nl,it:()=>Pl,Bw:()=>Ll,gp:()=>$l,oH:()=>Ml,xH:()=>Yh,CH:()=>Nh,FV:()=>Ch,T1:()=>Rh,G3:()=>Ih,P8:()=>Oh,as:()=>Sh,xS:()=>zh,L_:()=>ah,hs:()=>Zl,Dq:()=>rh,YX:()=>Zh,SH:()=>Qh,zS:()=>$h,TW:()=>Vh,Ie:()=>Uh,M0:()=>Dl,B4:()=>zl,Yq:()=>ql,Ee:()=>Kl,pi:()=>Gl,zb:()=>lh,i$:()=>Dh,t$:()=>Fh,WS:()=>Jl,jU:()=>yh,$r:()=>uh,Ok:()=>Ql,UT:()=>Yl,NG:()=>gh,ay:()=>ed,KW:()=>td,PG:()=>Hl,Bq:()=>dh,Xc:()=>nh,dg:()=>Wl,Gb:()=>Fl,IX:()=>Xl,GR:()=>hh,HD:()=>Jh,U1:()=>ih,nG:()=>jh,gm:()=>eh,sY:()=>oh,TT:()=>sh,IF:()=>Mh,CE:()=>th,go:()=>Vl,r7:()=>Xh,G5:()=>Wh,gD:()=>Bh});var a=Object.create,i=Object.defineProperty,s=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,u=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,l=(e,t)=>function(){return t||(0,e[o(e)[0]])((t={exports:{}}).exports,t),t.exports},h=(e,t)=>{for(var r in t)i(e,r,{get:t[r],enumerable:!0})},d=(e,t,r)=>(r=null!=e?a(u(e)):{},((e,t,r,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of o(t))c.call(e,r)||undefined===r||i(e,r,{get:()=>t[r],enumerable:!(n=s(t,r))||n.enumerable});return e})(!t&&e&&e.__esModule?r:i(r,"default",{value:e,enumerable:!0}),e)),f=l({"node_modules/obliterator/iterator.js"(e,t){function r(e){if("function"!=typeof e)throw new Error("obliterator/iterator: expecting a function!");this.next=e}"undefined"!=typeof Symbol&&(r.prototype[Symbol.iterator]=function(){return this}),r.of=function(){var e=arguments,t=e.length,n=0;return new r((function(){return n>=t?{done:!0}:{done:!1,value:e[n++]}}))},r.empty=function(){return new r((function(){return{done:!0}}))},r.fromSequence=function(e){var t=0,n=e.length;return new r((function(){return t>=n?{done:!0}:{done:!1,value:e[t++]}}))},r.is=function(e){return e instanceof r||"object"==typeof e&&null!==e&&"function"==typeof e.next},t.exports=r}}),p=l({"node_modules/obliterator/support.js"(e){e.ARRAY_BUFFER_SUPPORT="undefined"!=typeof ArrayBuffer,e.SYMBOL_SUPPORT="undefined"!=typeof Symbol}}),g=l({"node_modules/obliterator/foreach.js"(e,t){var r=p(),n=r.ARRAY_BUFFER_SUPPORT,a=r.SYMBOL_SUPPORT;t.exports=function(e,t){var r,i,s,o,u;if(!e)throw new Error("obliterator/forEach: invalid iterable.");if("function"!=typeof t)throw new Error("obliterator/forEach: expecting a callback.");if(Array.isArray(e)||n&&ArrayBuffer.isView(e)||"string"==typeof e||"[object Arguments]"===e.toString())for(s=0,o=e.length;s<o;s++)t(e[s],s);else if("function"!=typeof e.forEach)if(a&&Symbol.iterator in e&&"function"!=typeof e.next&&(e=e[Symbol.iterator]()),"function"!=typeof e.next)for(i in e)e.hasOwnProperty(i)&&t(e[i],i);else for(r=e,s=0;!0!==(u=r.next()).done;)t(u.value,s),s++;else e.forEach(t)}}}),y=l({"node_modules/mnemonist/utils/typed-arrays.js"(e){var t=Math.pow(2,8)-1,r=Math.pow(2,16)-1,n=Math.pow(2,32)-1,a=Math.pow(2,7)-1,i=Math.pow(2,15)-1,s=Math.pow(2,31)-1;e.getPointerArray=function(e){var a=e-1;if(a<=t)return Uint8Array;if(a<=r)return Uint16Array;if(a<=n)return Uint32Array;throw new Error("mnemonist: Pointer Array of size > 4294967295 is not supported.")},e.getSignedPointerArray=function(e){var t=e-1;return t<=a?Int8Array:t<=i?Int16Array:t<=s?Int32Array:Float64Array},e.getNumberType=function(e){return e===(0|e)?-1===Math.sign(e)?e<=127&&e>=-128?Int8Array:e<=32767&&e>=-32768?Int16Array:Int32Array:e<=255?Uint8Array:e<=65535?Uint16Array:Uint32Array:Float64Array};var o={Uint8Array:1,Int8Array:2,Uint16Array:3,Int16Array:4,Uint32Array:5,Int32Array:6,Float32Array:7,Float64Array:8};e.getMinimalRepresentation=function(t,r){var n,a,i,s,u,c=null,l=0;for(s=0,u=t.length;s<u;s++)i=r?r(t[s]):t[s],a=e.getNumberType(i),(n=o[a.name])>l&&(l=n,c=a);return c},e.isTypedArray=function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView(e)},e.concat=function(){var e,t,r,n=0;for(e=0,r=arguments.length;e<r;e++)n+=arguments[e].length;var a=new arguments[0].constructor(n);for(e=0,t=0;e<r;e++)a.set(arguments[e],t),t+=arguments[e].length;return a},e.indices=function(t){for(var r=new(e.getPointerArray(t))(t),n=0;n<t;n++)r[n]=n;return r}}}),m=l({"node_modules/mnemonist/utils/iterables.js"(e){var t=g(),r=y();function n(e){return"number"==typeof e.length?e.length:"number"==typeof e.size?e.size:void 0}e.isArrayLike=function(e){return Array.isArray(e)||r.isTypedArray(e)},e.guessLength=n,e.toArray=function(e){var r=n(e),a="number"==typeof r?new Array(r):[],i=0;return t(e,(function(e){a[i++]=e})),a},e.toArrayWithIndices=function(e){var a=n(e),i="number"==typeof a?r.getPointerArray(a):Array,s="number"==typeof a?new Array(a):[],o="number"==typeof a?new i(a):[],u=0;return t(e,(function(e){s[u]=e,o[u]=u++})),[s,o]}}}),v=l({"node_modules/mnemonist/lru-cache.js"(e,t){var r=f(),n=g(),a=y(),i=m();function s(e,t,r){if(arguments.length<2&&(r=e,e=null,t=null),this.capacity=r,"number"!=typeof this.capacity||this.capacity<=0)throw new Error("mnemonist/lru-cache: capacity should be positive number.");if(!isFinite(this.capacity)||Math.floor(this.capacity)!==this.capacity)throw new Error("mnemonist/lru-cache: capacity should be a finite positive integer.");var n=a.getPointerArray(r);this.forward=new n(r),this.backward=new n(r),this.K="function"==typeof e?new e(r):new Array(r),this.V="function"==typeof t?new t(r):new Array(r),this.size=0,this.head=0,this.tail=0,this.items={}}s.prototype.clear=function(){this.size=0,this.head=0,this.tail=0,this.items={}},s.prototype.splayOnTop=function(e){var t=this.head;if(this.head===e)return this;var r=this.backward[e],n=this.forward[e];return this.tail===e?this.tail=r:this.backward[n]=r,this.forward[r]=n,this.backward[t]=e,this.head=e,this.forward[e]=t,this},s.prototype.set=function(e,t){var r=this.items[e];if(void 0!==r)return this.splayOnTop(r),void(this.V[r]=t);this.size<this.capacity?r=this.size++:(r=this.tail,this.tail=this.backward[r],delete this.items[this.K[r]]),this.items[e]=r,this.K[r]=e,this.V[r]=t,this.forward[r]=this.head,this.backward[this.head]=r,this.head=r},s.prototype.setpop=function(e,t){var r=null,n=null,a=this.items[e];return void 0!==a?(this.splayOnTop(a),r=this.V[a],this.V[a]=t,{evicted:!1,key:e,value:r}):(this.size<this.capacity?a=this.size++:(a=this.tail,this.tail=this.backward[a],r=this.V[a],n=this.K[a],delete this.items[n]),this.items[e]=a,this.K[a]=e,this.V[a]=t,this.forward[a]=this.head,this.backward[this.head]=a,this.head=a,n?{evicted:!0,key:n,value:r}:null)},s.prototype.has=function(e){return e in this.items},s.prototype.get=function(e){var t=this.items[e];if(void 0!==t)return this.splayOnTop(t),this.V[t]},s.prototype.peek=function(e){var t=this.items[e];if(void 0!==t)return this.V[t]},s.prototype.forEach=function(e,t){t=arguments.length>1?t:this;for(var r=0,n=this.size,a=this.head,i=this.K,s=this.V,o=this.forward;r<n;)e.call(t,s[a],i[a],this),a=o[a],r++},s.prototype.keys=function(){var e=0,t=this.size,n=this.head,a=this.K,i=this.forward;return new r((function(){if(e>=t)return{done:!0};var r=a[n];return++e<t&&(n=i[n]),{done:!1,value:r}}))},s.prototype.values=function(){var e=0,t=this.size,n=this.head,a=this.V,i=this.forward;return new r((function(){if(e>=t)return{done:!0};var r=a[n];return++e<t&&(n=i[n]),{done:!1,value:r}}))},s.prototype.entries=function(){var e=0,t=this.size,n=this.head,a=this.K,i=this.V,s=this.forward;return new r((function(){if(e>=t)return{done:!0};var r=a[n],o=i[n];return++e<t&&(n=s[n]),{done:!1,value:[r,o]}}))},"undefined"!=typeof Symbol&&(s.prototype[Symbol.iterator]=s.prototype.entries),s.prototype.inspect=function(){for(var e,t=new Map,r=this.entries();!(e=r.next()).done;)t.set(e.value[0],e.value[1]);return Object.defineProperty(t,"constructor",{value:s,enumerable:!1}),t},"undefined"!=typeof Symbol&&(s.prototype[Symbol.for("nodejs.util.inspect.custom")]=s.prototype.inspect),s.from=function(e,t,r,a){if(arguments.length<2){if("number"!=typeof(a=i.guessLength(e)))throw new Error("mnemonist/lru-cache.from: could not guess iterable length. Please provide desired capacity as last argument.")}else 2===arguments.length&&(a=t,t=null,r=null);var o=new s(t,r,a);return n(e,(function(e,t){o.set(t,e)})),o},t.exports=s}}),w=l({"node_modules/mnemonist/lru-map.js"(e,t){var r=v(),n=g(),a=y(),i=m();function s(e,t,r){if(arguments.length<2&&(r=e,e=null,t=null),this.capacity=r,"number"!=typeof this.capacity||this.capacity<=0)throw new Error("mnemonist/lru-map: capacity should be positive number.");if(!isFinite(this.capacity)||Math.floor(this.capacity)!==this.capacity)throw new Error("mnemonist/lru-map: capacity should be a finite positive integer.");var n=a.getPointerArray(r);this.forward=new n(r),this.backward=new n(r),this.K="function"==typeof e?new e(r):new Array(r),this.V="function"==typeof t?new t(r):new Array(r),this.size=0,this.head=0,this.tail=0,this.items=new Map}s.prototype.clear=function(){this.size=0,this.head=0,this.tail=0,this.items.clear()},s.prototype.set=function(e,t){var r=this.items.get(e);if(void 0!==r)return this.splayOnTop(r),void(this.V[r]=t);this.size<this.capacity?r=this.size++:(r=this.tail,this.tail=this.backward[r],this.items.delete(this.K[r])),this.items.set(e,r),this.K[r]=e,this.V[r]=t,this.forward[r]=this.head,this.backward[this.head]=r,this.head=r},s.prototype.setpop=function(e,t){var r=null,n=null,a=this.items.get(e);return void 0!==a?(this.splayOnTop(a),r=this.V[a],this.V[a]=t,{evicted:!1,key:e,value:r}):(this.size<this.capacity?a=this.size++:(a=this.tail,this.tail=this.backward[a],r=this.V[a],n=this.K[a],this.items.delete(n)),this.items.set(e,a),this.K[a]=e,this.V[a]=t,this.forward[a]=this.head,this.backward[this.head]=a,this.head=a,n?{evicted:!0,key:n,value:r}:null)},s.prototype.has=function(e){return this.items.has(e)},s.prototype.get=function(e){var t=this.items.get(e);if(void 0!==t)return this.splayOnTop(t),this.V[t]},s.prototype.peek=function(e){var t=this.items.get(e);if(void 0!==t)return this.V[t]},s.prototype.splayOnTop=r.prototype.splayOnTop,s.prototype.forEach=r.prototype.forEach,s.prototype.keys=r.prototype.keys,s.prototype.values=r.prototype.values,s.prototype.entries=r.prototype.entries,"undefined"!=typeof Symbol&&(s.prototype[Symbol.iterator]=s.prototype.entries),s.prototype.inspect=r.prototype.inspect,s.from=function(e,t,r,a){if(arguments.length<2){if("number"!=typeof(a=i.guessLength(e)))throw new Error("mnemonist/lru-cache.from: could not guess iterable length. Please provide desired capacity as last argument.")}else 2===arguments.length&&(a=t,t=null,r=null);var o=new s(t,r,a);return n(e,(function(e,t){o.set(t,e)})),o},t.exports=s}}),b=l({"node_modules/ms/index.js"(e,t){var r=1e3,n=60*r,a=60*n,i=24*a,s=7*i;function o(e,t,r,n){var a=t>=1.5*r;return Math.round(e/r)+" "+n+(a?"s":"")}t.exports=function(e,t){t=t||{};var u,c,l=typeof e;if("string"===l&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var o=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*o;case"weeks":case"week":case"w":return o*s;case"days":case"day":case"d":return o*i;case"hours":case"hour":case"hrs":case"hr":case"h":return o*a;case"minutes":case"minute":case"mins":case"min":case"m":return o*n;case"seconds":case"second":case"secs":case"sec":case"s":return o*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return o;default:return}}}}(e);if("number"===l&&isFinite(e))return t.long?(u=e,(c=Math.abs(u))>=i?o(u,c,i,"day"):c>=a?o(u,c,a,"hour"):c>=n?o(u,c,n,"minute"):c>=r?o(u,c,r,"second"):u+" ms"):function(e){var t=Math.abs(e);return t>=i?Math.round(e/i)+"d":t>=a?Math.round(e/a)+"h":t>=n?Math.round(e/n)+"m":t>=r?Math.round(e/r)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}}}),_=l({"node_modules/debug/src/common.js"(e,t){t.exports=function(e){function t(e){let n,a,i,s=null;function o(...e){if(!o.enabled)return;const r=o,a=Number(new Date),i=a-(n||a);r.diff=i,r.prev=n,r.curr=a,n=a,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,a)=>{if("%%"===n)return"%";s++;const i=t.formatters[a];if("function"==typeof i){const t=e[s];n=i.call(r,t),e.splice(s,1),s--}return n})),t.formatArgs.call(r,e),(r.log||t.log).apply(r,e)}return o.namespace=e,o.useColors=t.useColors(),o.color=t.selectColor(e),o.extend=r,o.destroy=t.destroy,Object.defineProperty(o,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(a!==t.namespaces&&(a=t.namespaces,i=t.enabled(e)),i),set:e=>{s=e}}),"function"==typeof t.init&&t.init(o),o}function r(e,r){const n=t(this.namespace+(void 0===r?":":r)+e);return n.log=this.log,n}function n(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names.map(n),...t.skips.map(n).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let r;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").split(/[\s,]+/),a=n.length;for(r=0;r<a;r++)n[r]&&("-"===(e=n[r].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let r,n;for(r=0,n=t.skips.length;r<n;r++)if(t.skips[r].test(e))return!1;for(r=0,n=t.names.length;r<n;r++)if(t.names[r].test(e))return!0;return!1},t.humanize=b(),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((r=>{t[r]=e[r]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t<e.length;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;return t.colors[Math.abs(r)%t.colors.length]},t.enable(t.load()),t}}}),T=l({"node_modules/debug/src/browser.js"(e,t){e.formatArgs=function(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;e.splice(1,0,r,"color: inherit");let n=0,a=0;e[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(n++,"%c"===e&&(a=n))})),e.splice(a,0,r)},e.save=function(t){try{t?e.storage.setItem("debug",t):e.storage.removeItem("debug")}catch(e){}},e.load=function(){let t;try{t=e.storage.getItem("debug")}catch(e){}return!t&&"undefined"!=typeof process&&"env"in process&&(t=process.env.DEBUG),t},e.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},e.storage=function(){try{return localStorage}catch(e){}}(),e.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),e.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],e.log=console.debug||console.log||(()=>{}),t.exports=_()(e);var{formatters:r}=t.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}}),E=l({"node_modules/base64-js/index.js"(e){e.byteLength=function(e){var t=s(e),r=t[0],n=t[1];return 3*(r+n)/4-n},e.toByteArray=function(e){var t,r,i=s(e),o=i[0],u=i[1],c=new a(function(e,t,r){return 3*(t+r)/4-r}(0,o,u)),l=0,h=u>0?o-4:o;for(r=0;r<h;r+=4)t=n[e.charCodeAt(r)]<<18|n[e.charCodeAt(r+1)]<<12|n[e.charCodeAt(r+2)]<<6|n[e.charCodeAt(r+3)],c[l++]=t>>16&255,c[l++]=t>>8&255,c[l++]=255&t;return 2===u&&(t=n[e.charCodeAt(r)]<<2|n[e.charCodeAt(r+1)]>>4,c[l++]=255&t),1===u&&(t=n[e.charCodeAt(r)]<<10|n[e.charCodeAt(r+1)]<<4|n[e.charCodeAt(r+2)]>>2,c[l++]=t>>8&255,c[l++]=255&t),c},e.fromByteArray=function(e){for(var t,n=e.length,a=n%3,i=[],s=16383,u=0,c=n-a;u<c;u+=s)i.push(o(e,u,u+s>c?c:u+s));return 1===a?(t=e[n-1],i.push(r[t>>2]+r[t<<4&63]+"==")):2===a&&(t=(e[n-2]<<8)+e[n-1],i.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"=")),i.join("")};var t,r=[],n=[],a="undefined"!=typeof Uint8Array?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(t=0;t<64;++t)r[t]=i[t],n[i.charCodeAt(t)]=t;function s(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function o(e,t,n){for(var a,i,s=[],o=t;o<n;o+=3)a=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(255&e[o+2]),s.push(r[(i=a)>>18&63]+r[i>>12&63]+r[i>>6&63]+r[63&i]);return s.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63}}),k=l({"node_modules/ieee754/index.js"(e){e.read=function(e,t,r,n,a){var i,s,o=8*a-n-1,u=(1<<o)-1,c=u>>1,l=-7,h=r?a-1:0,d=r?-1:1,f=e[t+h];for(h+=d,i=f&(1<<-l)-1,f>>=-l,l+=o;l>0;i=256*i+e[t+h],h+=d,l-=8);for(s=i&(1<<-l)-1,i>>=-l,l+=n;l>0;s=256*s+e[t+h],h+=d,l-=8);if(0===i)i=1-c;else{if(i===u)return s?NaN:1/0*(f?-1:1);s+=Math.pow(2,n),i-=c}return(f?-1:1)*s*Math.pow(2,i-n)},e.write=function(e,t,r,n,a,i){var s,o,u,c=8*i-a-1,l=(1<<c)-1,h=l>>1,d=23===a?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:i-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(o=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+h>=1?d/u:d*Math.pow(2,1-h))*u>=2&&(s++,u/=2),s+h>=l?(o=0,s=l):s+h>=1?(o=(t*u-1)*Math.pow(2,a),s+=h):(o=t*Math.pow(2,h-1)*Math.pow(2,a),s=0));a>=8;e[r+f]=255&o,f+=p,o/=256,a-=8);for(s=s<<a|o,c+=a;c>0;e[r+f]=255&s,f+=p,s/=256,c-=8);e[r+f-p]|=128*g}}}),A=l({"node_modules/buffer/index.js"(e){var t=E(),r=k(),n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=s,e.SlowBuffer=function(e){return+e!=e&&(e=0),s.alloc(+e)},e.INSPECT_MAX_BYTES=50;var a=2147483647;function i(e){if(e>a)throw new RangeError('The value "'+e+'" is invalid for option "size"');const t=new Uint8Array(e);return Object.setPrototypeOf(t,s.prototype),t}function s(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return c(e)}return o(e,t,r)}function o(e,t,r){if("string"==typeof e)return function(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!s.isEncoding(t))throw new TypeError("Unknown encoding: "+t);const r=0|f(e,t);let n=i(r);const a=n.write(e,t);return a!==r&&(n=n.slice(0,a)),n}(e,t);if(ArrayBuffer.isView(e))return function(e){if(W(e,Uint8Array)){const t=new Uint8Array(e);return h(t.buffer,t.byteOffset,t.byteLength)}return l(e)}(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(W(e,ArrayBuffer)||e&&W(e.buffer,ArrayBuffer))return h(e,t,r);if("undefined"!=typeof SharedArrayBuffer&&(W(e,SharedArrayBuffer)||e&&W(e.buffer,SharedArrayBuffer)))return h(e,t,r);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=e.valueOf&&e.valueOf();if(null!=n&&n!==e)return s.from(n,t,r);const a=function(e){if(s.isBuffer(e)){const t=0|d(e.length),r=i(t);return 0===r.length||e.copy(r,0,0,t),r}return void 0!==e.length?"number"!=typeof e.length||Y(e.length)?i(0):l(e):"Buffer"===e.type&&Array.isArray(e.data)?l(e.data):void 0}(e);if(a)return a;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return s.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function u(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function c(e){return u(e),i(e<0?0:0|d(e))}function l(e){const t=e.length<0?0:0|d(e.length),r=i(t);for(let n=0;n<t;n+=1)r[n]=255&e[n];return r}function h(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===t&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,t):new Uint8Array(e,t,r),Object.setPrototypeOf(n,s.prototype),n}function d(e){if(e>=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|e}function f(e,t){if(s.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||W(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);const r=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let a=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return H(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return G(e).length;default:if(a)return n?-1:H(e).length;t=(""+t).toLowerCase(),a=!0}}function p(e,t,r){let n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return R(this,t,r);case"utf8":case"utf-8":return x(this,t,r);case"ascii":return O(this,t,r);case"latin1":case"binary":return C(this,t,r);case"base64":return A(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function g(e,t,r){const n=e[t];e[t]=e[r],e[r]=n}function y(e,t,r,n,a){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),Y(r=+r)&&(r=a?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(a)return-1;r=e.length-1}else if(r<0){if(!a)return-1;r=0}if("string"==typeof t&&(t=s.from(t,n)),s.isBuffer(t))return 0===t.length?-1:m(e,t,r,n,a);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?a?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):m(e,[t],r,n,a);throw new TypeError("val must be string, number or Buffer")}function m(e,t,r,n,a){let i,s=1,o=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,o/=2,u/=2,r/=2}function c(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(a){let n=-1;for(i=r;i<o;i++)if(c(e,i)===c(t,-1===n?0:i-n)){if(-1===n&&(n=i),i-n+1===u)return n*s}else-1!==n&&(i-=i-n),n=-1}else for(r+u>o&&(r=o-u),i=r;i>=0;i--){let r=!0;for(let n=0;n<u;n++)if(c(e,i+n)!==c(t,n)){r=!1;break}if(r)return i}return-1}function v(e,t,r,n){r=Number(r)||0;const a=e.length-r;n?(n=Number(n))>a&&(n=a):n=a;const i=t.length;let s;for(n>i/2&&(n=i/2),s=0;s<n;++s){const n=parseInt(t.substr(2*s,2),16);if(Y(n))return s;e[r+s]=n}return s}function w(e,t,r,n){return V(H(t,e.length-r),e,r,n)}function b(e,t,r,n){return V(function(e){const t=[];for(let r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,n)}function _(e,t,r,n){return V(G(t),e,r,n)}function T(e,t,r,n){return V(function(e,t){let r,n,a;const i=[];for(let s=0;s<e.length&&!((t-=2)<0);++s)r=e.charCodeAt(s),n=r>>8,a=r%256,i.push(a),i.push(n);return i}(t,e.length-r),e,r,n)}function A(e,r,n){return 0===r&&n===e.length?t.fromByteArray(e):t.fromByteArray(e.slice(r,n))}function x(e,t,r){r=Math.min(e.length,r);const n=[];let a=t;for(;a<r;){const t=e[a];let i=null,s=t>239?4:t>223?3:t>191?2:1;if(a+s<=r){let r,n,o,u;switch(s){case 1:t<128&&(i=t);break;case 2:r=e[a+1],128==(192&r)&&(u=(31&t)<<6|63&r,u>127&&(i=u));break;case 3:r=e[a+1],n=e[a+2],128==(192&r)&&128==(192&n)&&(u=(15&t)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:r=e[a+1],n=e[a+2],o=e[a+3],128==(192&r)&&128==(192&n)&&128==(192&o)&&(u=(15&t)<<18|(63&r)<<12|(63&n)<<6|63&o,u>65535&&u<1114112&&(i=u))}}null===i?(i=65533,s=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),a+=s}return function(e){const t=e.length;if(t<=S)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=S));return r}(n)}e.kMaxLength=a,s.TYPED_ARRAY_SUPPORT=function(){try{const e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch(e){return!1}}(),s.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(s.prototype,"parent",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}}),Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}}),s.poolSize=8192,s.from=function(e,t,r){return o(e,t,r)},Object.setPrototypeOf(s.prototype,Uint8Array.prototype),Object.setPrototypeOf(s,Uint8Array),s.alloc=function(e,t,r){return function(e,t,r){return u(e),e<=0?i(e):void 0!==t?"string"==typeof r?i(e).fill(t,r):i(e).fill(t):i(e)}(e,t,r)},s.allocUnsafe=function(e){return c(e)},s.allocUnsafeSlow=function(e){return c(e)},s.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==s.prototype},s.compare=function(e,t){if(W(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),W(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(e)||!s.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let r=e.length,n=t.length;for(let a=0,i=Math.min(r,n);a<i;++a)if(e[a]!==t[a]){r=e[a],n=t[a];break}return r<n?-1:n<r?1:0},s.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},s.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return s.alloc(0);let r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;const n=s.allocUnsafe(t);let a=0;for(r=0;r<e.length;++r){let t=e[r];if(W(t,Uint8Array))a+t.length>n.length?(s.isBuffer(t)||(t=s.from(t)),t.copy(n,a)):Uint8Array.prototype.set.call(n,t,a);else{if(!s.isBuffer(t))throw new TypeError('"list" argument must be an Array of Buffers');t.copy(n,a)}a+=t.length}return n},s.byteLength=f,s.prototype._isBuffer=!0,s.prototype.swap16=function(){const e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)g(this,t,t+1);return this},s.prototype.swap32=function(){const e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)g(this,t,t+3),g(this,t+1,t+2);return this},s.prototype.swap64=function(){const e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)g(this,t,t+7),g(this,t+1,t+6),g(this,t+2,t+5),g(this,t+3,t+4);return this},s.prototype.toString=function(){const e=this.length;return 0===e?"":0===arguments.length?x(this,0,e):p.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(e){if(!s.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===s.compare(this,e)},s.prototype.inspect=function(){let t="";const r=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},n&&(s.prototype[n]=s.prototype.inspect),s.prototype.compare=function(e,t,r,n,a){if(W(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),!s.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===a&&(a=this.length),t<0||r>e.length||n<0||a>this.length)throw new RangeError("out of range index");if(n>=a&&t>=r)return 0;if(n>=a)return-1;if(t>=r)return 1;if(this===e)return 0;let i=(a>>>=0)-(n>>>=0),o=(r>>>=0)-(t>>>=0);const u=Math.min(i,o),c=this.slice(n,a),l=e.slice(t,r);for(let e=0;e<u;++e)if(c[e]!==l[e]){i=c[e],o=l[e];break}return i<o?-1:o<i?1:0},s.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},s.prototype.indexOf=function(e,t,r){return y(this,e,t,r,!0)},s.prototype.lastIndexOf=function(e,t,r){return y(this,e,t,r,!1)},s.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const a=this.length-t;if((void 0===r||r>a)&&(r=a),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let i=!1;for(;;)switch(n){case"hex":return v(this,e,t,r);case"utf8":case"utf-8":return w(this,e,t,r);case"ascii":case"latin1":case"binary":return b(this,e,t,r);case"base64":return _(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,e,t,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var S=4096;function O(e,t,r){let n="";r=Math.min(e.length,r);for(let a=t;a<r;++a)n+=String.fromCharCode(127&e[a]);return n}function C(e,t,r){let n="";r=Math.min(e.length,r);for(let a=t;a<r;++a)n+=String.fromCharCode(e[a]);return n}function R(e,t,r){const n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);let a="";for(let n=t;n<r;++n)a+=J[e[n]];return a}function I(e,t,r){const n=e.slice(t,r);let a="";for(let e=0;e<n.length-1;e+=2)a+=String.fromCharCode(n[e]+256*n[e+1]);return a}function B(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function U(e,t,r,n,a,i){if(!s.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>a||t<i)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function j(e,t,r,n,a){F(t,n,a,e,r,7);let i=Number(t&BigInt(4294967295));e[r++]=i,i>>=8,e[r++]=i,i>>=8,e[r++]=i,i>>=8,e[r++]=i;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r++]=s,s>>=8,e[r++]=s,s>>=8,e[r++]=s,s>>=8,e[r++]=s,r}function N(e,t,r,n,a){F(t,n,a,e,r,7);let i=Number(t&BigInt(4294967295));e[r+7]=i,i>>=8,e[r+6]=i,i>>=8,e[r+5]=i,i>>=8,e[r+4]=i;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r+3]=s,s>>=8,e[r+2]=s,s>>=8,e[r+1]=s,s>>=8,e[r]=s,r+8}function P(e,t,r,n,a,i){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function L(e,t,n,a,i){return t=+t,n>>>=0,i||P(e,0,n,4),r.write(e,t,n,a,23,4),n+4}function $(e,t,n,a,i){return t=+t,n>>>=0,i||P(e,0,n,8),r.write(e,t,n,a,52,8),n+8}s.prototype.slice=function(e,t){const r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e);const n=this.subarray(e,t);return Object.setPrototypeOf(n,s.prototype),n},s.prototype.readUintLE=s.prototype.readUIntLE=function(e,t,r){e>>>=0,t>>>=0,r||B(e,t,this.length);let n=this[e],a=1,i=0;for(;++i<t&&(a*=256);)n+=this[e+i]*a;return n},s.prototype.readUintBE=s.prototype.readUIntBE=function(e,t,r){e>>>=0,t>>>=0,r||B(e,t,this.length);let n=this[e+--t],a=1;for(;t>0&&(a*=256);)n+=this[e+--t]*a;return n},s.prototype.readUint8=s.prototype.readUInt8=function(e,t){return e>>>=0,t||B(e,1,this.length),this[e]},s.prototype.readUint16LE=s.prototype.readUInt16LE=function(e,t){return e>>>=0,t||B(e,2,this.length),this[e]|this[e+1]<<8},s.prototype.readUint16BE=s.prototype.readUInt16BE=function(e,t){return e>>>=0,t||B(e,2,this.length),this[e]<<8|this[e+1]},s.prototype.readUint32LE=s.prototype.readUInt32LE=function(e,t){return e>>>=0,t||B(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},s.prototype.readUint32BE=s.prototype.readUInt32BE=function(e,t){return e>>>=0,t||B(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},s.prototype.readBigUInt64LE=Q((function(e){z(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||K(e,this.length-8);const n=t+256*this[++e]+65536*this[++e]+this[++e]*2**24,a=this[++e]+256*this[++e]+65536*this[++e]+r*2**24;return BigInt(n)+(BigInt(a)<<BigInt(32))})),s.prototype.readBigUInt64BE=Q((function(e){z(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||K(e,this.length-8);const n=t*2**24+65536*this[++e]+256*this[++e]+this[++e],a=this[++e]*2**24+65536*this[++e]+256*this[++e]+r;return(BigInt(n)<<BigInt(32))+BigInt(a)})),s.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||B(e,t,this.length);let n=this[e],a=1,i=0;for(;++i<t&&(a*=256);)n+=this[e+i]*a;return a*=128,n>=a&&(n-=Math.pow(2,8*t)),n},s.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||B(e,t,this.length);let n=t,a=1,i=this[e+--n];for(;n>0&&(a*=256);)i+=this[e+--n]*a;return a*=128,i>=a&&(i-=Math.pow(2,8*t)),i},s.prototype.readInt8=function(e,t){return e>>>=0,t||B(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},s.prototype.readInt16LE=function(e,t){e>>>=0,t||B(e,2,this.length);const r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(e,t){e>>>=0,t||B(e,2,this.length);const r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(e,t){return e>>>=0,t||B(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},s.prototype.readInt32BE=function(e,t){return e>>>=0,t||B(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},s.prototype.readBigInt64LE=Q((function(e){z(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||K(e,this.length-8);const n=this[e+4]+256*this[e+5]+65536*this[e+6]+(r<<24);return(BigInt(n)<<BigInt(32))+BigInt(t+256*this[++e]+65536*this[++e]+this[++e]*2**24)})),s.prototype.readBigInt64BE=Q((function(e){z(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||K(e,this.length-8);const n=(t<<24)+65536*this[++e]+256*this[++e]+this[++e];return(BigInt(n)<<BigInt(32))+BigInt(this[++e]*2**24+65536*this[++e]+256*this[++e]+r)})),s.prototype.readFloatLE=function(e,t){return e>>>=0,t||B(e,4,this.length),r.read(this,e,!0,23,4)},s.prototype.readFloatBE=function(e,t){return e>>>=0,t||B(e,4,this.length),r.read(this,e,!1,23,4)},s.prototype.readDoubleLE=function(e,t){return e>>>=0,t||B(e,8,this.length),r.read(this,e,!0,52,8)},s.prototype.readDoubleBE=function(e,t){return e>>>=0,t||B(e,8,this.length),r.read(this,e,!1,52,8)},s.prototype.writeUintLE=s.prototype.writeUIntLE=function(e,t,r,n){e=+e,t>>>=0,r>>>=0,n||U(this,e,t,r,Math.pow(2,8*r)-1,0);let a=1,i=0;for(this[t]=255&e;++i<r&&(a*=256);)this[t+i]=e/a&255;return t+r},s.prototype.writeUintBE=s.prototype.writeUIntBE=function(e,t,r,n){e=+e,t>>>=0,r>>>=0,n||U(this,e,t,r,Math.pow(2,8*r)-1,0);let a=r-1,i=1;for(this[t+a]=255&e;--a>=0&&(i*=256);)this[t+a]=e/i&255;return t+r},s.prototype.writeUint8=s.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||U(this,e,t,1,255,0),this[t]=255&e,t+1},s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||U(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||U(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||U(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||U(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},s.prototype.writeBigUInt64LE=Q((function(e,t=0){return j(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))})),s.prototype.writeBigUInt64BE=Q((function(e,t=0){return N(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))})),s.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){const n=Math.pow(2,8*r-1);U(this,e,t,r,n-1,-n)}let a=0,i=1,s=0;for(this[t]=255&e;++a<r&&(i*=256);)e<0&&0===s&&0!==this[t+a-1]&&(s=1),this[t+a]=(e/i|0)-s&255;return t+r},s.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){const n=Math.pow(2,8*r-1);U(this,e,t,r,n-1,-n)}let a=r-1,i=1,s=0;for(this[t+a]=255&e;--a>=0&&(i*=256);)e<0&&0===s&&0!==this[t+a+1]&&(s=1),this[t+a]=(e/i|0)-s&255;return t+r},s.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||U(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},s.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||U(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},s.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||U(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},s.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||U(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},s.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||U(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},s.prototype.writeBigInt64LE=Q((function(e,t=0){return j(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),s.prototype.writeBigInt64BE=Q((function(e,t=0){return N(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),s.prototype.writeFloatLE=function(e,t,r){return L(this,e,t,!0,r)},s.prototype.writeFloatBE=function(e,t,r){return L(this,e,t,!1,r)},s.prototype.writeDoubleLE=function(e,t,r){return $(this,e,t,!0,r)},s.prototype.writeDoubleBE=function(e,t,r){return $(this,e,t,!1,r)},s.prototype.copy=function(e,t,r,n){if(!s.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);const a=n-r;return this===e&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(t,r,n):Uint8Array.prototype.set.call(e,this.subarray(r,n),t),a},s.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===e.length){const t=e.charCodeAt(0);("utf8"===n&&t<128||"latin1"===n)&&(e=t)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;let a;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(a=t;a<r;++a)this[a]=e;else{const i=s.isBuffer(e)?e:s.from(e,n),o=i.length;if(0===o)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(a=0;a<r-t;++a)this[a+t]=i[a%o]}return this};var M={};function Z(e,t,r){M[e]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(e){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:e,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}function D(e){let t="",r=e.length;const n="-"===e[0]?1:0;for(;r>=n+4;r-=3)t=`_${e.slice(r-3,r)}${t}`;return`${e.slice(0,r)}${t}`}function F(e,t,r,n,a,i){if(e>r||e<t){const n="bigint"==typeof t?"n":"";let a;throw a=i>3?0===t||t===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(i+1)}${n}`:`>= -(2${n} ** ${8*(i+1)-1}${n}) and < 2 ** ${8*(i+1)-1}${n}`:`>= ${t}${n} and <= ${r}${n}`,new M.ERR_OUT_OF_RANGE("value",a,e)}!function(e,t,r){z(t,"offset"),void 0!==e[t]&&void 0!==e[t+r]||K(t,e.length-(r+1))}(n,a,i)}function z(e,t){if("number"!=typeof e)throw new M.ERR_INVALID_ARG_TYPE(t,"number",e)}function K(e,t,r){if(Math.floor(e)!==e)throw z(e,r),new M.ERR_OUT_OF_RANGE(r||"offset","an integer",e);if(t<0)throw new M.ERR_BUFFER_OUT_OF_BOUNDS;throw new M.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${t}`,e)}Z("ERR_BUFFER_OUT_OF_BOUNDS",(function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),Z("ERR_INVALID_ARG_TYPE",(function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`}),TypeError),Z("ERR_OUT_OF_RANGE",(function(e,t,r){let n=`The value of "${e}" is out of range.`,a=r;return Number.isInteger(r)&&Math.abs(r)>2**32?a=D(String(r)):"bigint"==typeof r&&(a=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(a=D(a)),a+="n"),n+=` It must be ${t}. Received ${a}`,n}),RangeError);var q=/[^+/0-9A-Za-z-_]/g;function H(e,t){let r;t=t||1/0;const n=e.length;let a=null;const i=[];for(let s=0;s<n;++s){if(r=e.charCodeAt(s),r>55295&&r<57344){if(!a){if(r>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&i.push(239,191,189);continue}a=r;continue}if(r<56320){(t-=3)>-1&&i.push(239,191,189),a=r;continue}r=65536+(a-55296<<10|r-56320)}else a&&(t-=3)>-1&&i.push(239,191,189);if(a=null,r<128){if((t-=1)<0)break;i.push(r)}else if(r<2048){if((t-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function G(e){return t.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(q,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function V(e,t,r,n){let a;for(a=0;a<n&&!(a+r>=t.length||a>=e.length);++a)t[a+r]=e[a];return a}function W(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function Y(e){return e!=e}var J=function(){const e="0123456789abcdef",t=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let a=0;a<16;++a)t[n+a]=e[r]+e[a]}return t}();function Q(e){return"undefined"==typeof BigInt?X:e}function X(){throw new Error("BigInt not supported")}}}),x={"@@functional/placeholder":!0};function S(e){return e===x}function O(e){return function t(r){return 0===arguments.length||S(r)?t:e.apply(this,arguments)}}function C(e){return function t(r,n){switch(arguments.length){case 0:return t;case 1:return S(r)?t:O((function(t){return e(r,t)}));default:return S(r)&&S(n)?t:S(r)?O((function(t){return e(t,n)})):S(n)?O((function(t){return e(r,t)})):e(r,n)}}}function R(e,t){switch(e){case 0:return function(){return t.apply(this,arguments)};case 1:return function(e){return t.apply(this,arguments)};case 2:return function(e,r){return t.apply(this,arguments)};case 3:return function(e,r,n){return t.apply(this,arguments)};case 4:return function(e,r,n,a){return t.apply(this,arguments)};case 5:return function(e,r,n,a,i){return t.apply(this,arguments)};case 6:return function(e,r,n,a,i,s){return t.apply(this,arguments)};case 7:return function(e,r,n,a,i,s,o){return t.apply(this,arguments)};case 8:return function(e,r,n,a,i,s,o,u){return t.apply(this,arguments)};case 9:return function(e,r,n,a,i,s,o,u,c){return t.apply(this,arguments)};case 10:return function(e,r,n,a,i,s,o,u,c,l){return t.apply(this,arguments)};default:throw new Error("First argument to _arity must be a non-negative integer no greater than ten")}}function I(e,t,r){return function(){for(var n=[],a=0,i=e,s=0,o=!1;s<t.length||a<arguments.length;){var u;s<t.length&&(!S(t[s])||a>=arguments.length)?u=t[s]:(u=arguments[a],a+=1),n[s]=u,S(u)?o=!0:i-=1,s+=1}return!o&&i<=0?r.apply(this,n):R(Math.max(0,i),I(e,n,r))}}var B=C((function(e,t){return 1===e?O(t):R(e,I(e,[],t))})),U=B;function j(e){return function t(r,n,a){switch(arguments.length){case 0:return t;case 1:return S(r)?t:C((function(t,n){return e(r,t,n)}));case 2:return S(r)&&S(n)?t:S(r)?C((function(t,r){return e(t,n,r)})):S(n)?C((function(t,n){return e(r,t,n)})):O((function(t){return e(r,n,t)}));default:return S(r)&&S(n)&&S(a)?t:S(r)&&S(n)?C((function(t,r){return e(t,r,a)})):S(r)&&S(a)?C((function(t,r){return e(t,n,r)})):S(n)&&S(a)?C((function(t,n){return e(r,t,n)})):S(r)?O((function(t){return e(t,n,a)})):S(n)?O((function(t){return e(r,t,a)})):S(a)?O((function(t){return e(r,n,t)})):e(r,n,a)}}}var N=Array.isArray||function(e){return null!=e&&e.length>=0&&"[object Array]"===Object.prototype.toString.call(e)};function P(e,t,r){return function(){if(0===arguments.length)return r();var n=arguments[arguments.length-1];if(!N(n)){for(var a=0;a<e.length;){if("function"==typeof n[e[a]])return n[e[a]].apply(n,Array.prototype.slice.call(arguments,0,-1));a+=1}if(function(e){return null!=e&&"function"==typeof e["@@transducer/step"]}(n))return t.apply(null,Array.prototype.slice.call(arguments,0,-1))(n)}return r.apply(this,arguments)}}var L=function(){return this.xf["@@transducer/init"]()},$=function(e){return this.xf["@@transducer/result"](e)};function M(e){for(var t,r=[];!(t=e.next()).done;)r.push(t.value);return r}function Z(e,t,r){for(var n=0,a=r.length;n<a;){if(e(t,r[n]))return!0;n+=1}return!1}function D(e,t){return Object.prototype.hasOwnProperty.call(t,e)}var F="function"==typeof Object.is?Object.is:function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t},z=Object.prototype.toString,K=function(){return"[object Arguments]"===z.call(arguments)?function(e){return"[object Arguments]"===z.call(e)}:function(e){return D("callee",e)}}(),q=K,H=!{toString:null}.propertyIsEnumerable("toString"),G=["constructor","valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],V=function(){return arguments.propertyIsEnumerable("length")}(),W=function(e,t){for(var r=0;r<e.length;){if(e[r]===t)return!0;r+=1}return!1},Y="function"!=typeof Object.keys||V?O((function(e){if(Object(e)!==e)return[];var t,r,n=[],a=V&&q(e);for(t in e)D(t,e)&&(!a||"length"!==t)&&(n[n.length]=t);if(H)for(r=G.length-1;r>=0;)D(t=G[r],e)&&!W(n,t)&&(n[n.length]=t),r-=1;return n})):O((function(e){return Object(e)!==e?[]:Object.keys(e)})),J=Y,Q=O((function(e){return null===e?"Null":void 0===e?"Undefined":Object.prototype.toString.call(e).slice(8,-1)})),X=Q;function ee(e,t,r,n){var a=M(e);function i(e,t){return te(e,t,r.slice(),n.slice())}return!Z((function(e,t){return!Z(i,t,e)}),M(t),a)}function te(e,t,r,n){if(F(e,t))return!0;var a=X(e);if(a!==X(t))return!1;if("function"==typeof e["fantasy-land/equals"]||"function"==typeof t["fantasy-land/equals"])return"function"==typeof e["fantasy-land/equals"]&&e["fantasy-land/equals"](t)&&"function"==typeof t["fantasy-land/equals"]&&t["fantasy-land/equals"](e);if("function"==typeof e.equals||"function"==typeof t.equals)return"function"==typeof e.equals&&e.equals(t)&&"function"==typeof t.equals&&t.equals(e);switch(a){case"Arguments":case"Array":case"Object":if("function"==typeof e.constructor&&"Promise"===function(e){var t=String(e).match(/^function (\w*)/);return null==t?"":t[1]}(e.constructor))return e===t;break;case"Boolean":case"Number":case"String":if(typeof e!=typeof t||!F(e.valueOf(),t.valueOf()))return!1;break;case"Date":if(!F(e.valueOf(),t.valueOf()))return!1;break;case"Error":return e.name===t.name&&e.message===t.message;case"RegExp":if(e.source!==t.source||e.global!==t.global||e.ignoreCase!==t.ignoreCase||e.multiline!==t.multiline||e.sticky!==t.sticky||e.unicode!==t.unicode)return!1}for(var i=r.length-1;i>=0;){if(r[i]===e)return n[i]===t;i-=1}switch(a){case"Map":return e.size===t.size&&ee(e.entries(),t.entries(),r.concat([e]),n.concat([t]));case"Set":return e.size===t.size&&ee(e.values(),t.values(),r.concat([e]),n.concat([t]));case"Arguments":case"Array":case"Object":case"Boolean":case"Number":case"String":case"Date":case"Error":case"RegExp":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"ArrayBuffer":break;default:return!1}var s=J(e);if(s.length!==J(t).length)return!1;var o=r.concat([e]),u=n.concat([t]);for(i=s.length-1;i>=0;){var c=s[i];if(!D(c,t)||!te(t[c],e[c],o,u))return!1;i-=1}return!0}var re=C((function(e,t){return te(e,t,[],[])})),ne=re;function ae(e,t){for(var r=0,n=t.length,a=Array(n);r<n;)a[r]=e(t[r]),r+=1;return a}function ie(e){return'"'+e.replace(/\\/g,"\\\\").replace(/[\b]/g,"\\b").replace(/\f/g,"\\f").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t").replace(/\v/g,"\\v").replace(/\0/g,"\\0").replace(/"/g,'\\"')+'"'}var se=function(e){return(e<10?"0":"")+e},oe="function"==typeof Date.prototype.toISOString?function(e){return e.toISOString()}:function(e){return e.getUTCFullYear()+"-"+se(e.getUTCMonth()+1)+"-"+se(e.getUTCDate())+"T"+se(e.getUTCHours())+":"+se(e.getUTCMinutes())+":"+se(e.getUTCSeconds())+"."+(e.getUTCMilliseconds()/1e3).toFixed(3).slice(2,5)+"Z"},ue=oe;function ce(e,t,r){for(var n=0,a=r.length;n<a;)t=e(t,r[n]),n+=1;return t}var le=function(){function e(e,t){this.xf=t,this.f=e}return e.prototype["@@transducer/init"]=L,e.prototype["@@transducer/result"]=$,e.prototype["@@transducer/step"]=function(e,t){return this.f(t)?this.xf["@@transducer/step"](e,t):e},e}(),he=C(P(["fantasy-land/filter","filter"],(function(e){return function(t){return new le(e,t)}}),(function(e,t){return function(e){return"[object Object]"===Object.prototype.toString.call(e)}(t)?ce((function(r,n){return e(t[n])&&(r[n]=t[n]),r}),{},J(t)):function(e,t){for(var r=0,n=t.length,a=[];r<n;)e(t[r])&&(a[a.length]=t[r]),r+=1;return a}(e,t)}))),de=he,fe=C((function(e,t){return de((r=e,function(){return!r.apply(this,arguments)}),t);var r})),pe=fe;function ge(e,t){var r=function(r){var n=t.concat([e]);return function(e,t){return function(e,t,r){var n,a;if("function"==typeof e.indexOf)switch(typeof t){case"number":if(0===t){for(n=1/t;r<e.length;){if(0===(a=e[r])&&1/a===n)return r;r+=1}return-1}if(t!=t){for(;r<e.length;){if("number"==typeof(a=e[r])&&a!=a)return r;r+=1}return-1}return e.indexOf(t,r);case"string":case"boolean":case"function":case"undefined":return e.indexOf(t,r);case"object":if(null===t)return e.indexOf(t,r)}for(;r<e.length;){if(ne(e[r],t))return r;r+=1}return-1}(t,e,0)>=0}(r,n)?"<Circular>":ge(r,n)},n=function(e,t){return ae((function(t){return ie(t)+": "+r(e[t])}),t.slice().sort())};switch(Object.prototype.toString.call(e)){case"[object Arguments]":return"(function() { return arguments; }("+ae(r,e).join(", ")+"))";case"[object Array]":return"["+ae(r,e).concat(n(e,pe((function(e){return/^\d+$/.test(e)}),J(e)))).join(", ")+"]";case"[object Boolean]":return"object"==typeof e?"new Boolean("+r(e.valueOf())+")":e.toString();case"[object Date]":return"new Date("+(isNaN(e.valueOf())?r(NaN):ie(ue(e)))+")";case"[object Map]":return"new Map("+r(Array.from(e))+")";case"[object Null]":return"null";case"[object Number]":return"object"==typeof e?"new Number("+r(e.valueOf())+")":1/e==-1/0?"-0":e.toString(10);case"[object Set]":return"new Set("+r(Array.from(e).sort())+")";case"[object String]":return"object"==typeof e?"new String("+r(e.valueOf())+")":ie(e);case"[object Undefined]":return"undefined";default:if("function"==typeof e.toString){var a=e.toString();if("[object Object]"!==a)return a}return"{"+n(e,J(e)).join(", ")+"}"}}var ye=O((function(e){return ge(e,[])})),me=ye,ve=C((function(e,t){if(e===t)return t;function r(e,t){if(e>t!=t>e)return t>e?t:e}var n=r(e,t);if(void 0!==n)return n;var a=r(typeof e,typeof t);if(void 0!==a)return a===typeof e?e:t;var i=me(e),s=r(i,me(t));return void 0!==s&&s===i?e:t})),we=ve,be=function(){function e(e,t){this.xf=t,this.f=e}return e.prototype["@@transducer/init"]=L,e.prototype["@@transducer/result"]=$,e.prototype["@@transducer/step"]=function(e,t){return this.xf["@@transducer/step"](e,this.f(t))},e}(),_e=C(P(["fantasy-land/map","map"],(function(e){return function(t){return new be(e,t)}}),(function(e,t){switch(Object.prototype.toString.call(t)){case"[object Function]":return U(t.length,(function(){return e.call(this,t.apply(this,arguments))}));case"[object Object]":return ce((function(r,n){return r[n]=e(t[n]),r}),{},J(t));default:return ae(e,t)}}))),Te=_e,Ee=Number.isInteger||function(e){return(0|e)===e};function ke(e){return"[object String]"===Object.prototype.toString.call(e)}function Ae(e,t){var r=e<0?t.length+e:e;return ke(t)?t.charAt(r):t[r]}var xe,Se,Oe,Ce=C((function(e,t){if(null!=t)return Ee(e)?Ae(e,t):t[e]})),Re=Ce,Ie=C((function(e,t){return Te(Re(e),t)})),Be=Ie,Ue=O((function(e){return!!N(e)||!(!e||"object"!=typeof e||ke(e))&&(0===e.length||e.length>0&&e.hasOwnProperty(0)&&e.hasOwnProperty(e.length-1))})),je=Ue,Ne=typeof Symbol<"u"?Symbol.iterator:"@@iterator",Pe=C((function(e,t){return R(e.length,(function(){return e.apply(t,arguments)}))})),Le=Pe,$e=(xe=function(e,t,r){for(var n=0,a=r.length;n<a;){if((t=e["@@transducer/step"](t,r[n]))&&t["@@transducer/reduced"]){t=t["@@transducer/value"];break}n+=1}return e["@@transducer/result"](t)},Se=function(e,t,r,n){return e["@@transducer/result"](r[n](Le(e["@@transducer/step"],e),t))},Oe=function(e,t,r){for(var n=r.next();!n.done;){if((t=e["@@transducer/step"](t,n.value))&&t["@@transducer/reduced"]){t=t["@@transducer/value"];break}n=r.next()}return e["@@transducer/result"](t)},function(e,t,r){if(je(r))return xe(e,t,r);if(null==r)return t;if("function"==typeof r["fantasy-land/reduce"])return Se(e,t,r,"fantasy-land/reduce");if(null!=r[Ne])return Oe(e,t,r[Ne]());if("function"==typeof r.next)return Oe(e,t,r);if("function"==typeof r.reduce)return Se(e,t,r,"reduce");throw new TypeError("reduce: list must be array or iterable")}),Me=$e,Ze=function(){function e(e){this.f=e}return e.prototype["@@transducer/init"]=function(){throw new Error("init not implemented on XWrap")},e.prototype["@@transducer/result"]=function(e){return e},e.prototype["@@transducer/step"]=function(e,t){return this.f(e,t)},e}(),De=j((function(e,t,r){return Me("function"==typeof e?function(e){return new Ze(e)}(e):e,t,r)})),Fe=De;function ze(e,t){return function(){return t.call(this,e.apply(this,arguments))}}function Ke(e,t){return function(){var r=arguments.length;if(0===r)return t();var n=arguments[r-1];return N(n)||"function"!=typeof n[e]?t.apply(this,arguments):n[e].apply(n,Array.prototype.slice.call(arguments,0,r-1))}}var qe=j(Ke("slice",(function(e,t,r){return Array.prototype.slice.call(r,e,t)}))),He=O(Ke("tail",qe(1,1/0)));function Ge(){if(0===arguments.length)throw new Error("pipe requires at least one argument");return R(arguments[0].length,Fe(ze,arguments[0],He(arguments)))}var Ve=C((function(e,t){return U(Fe(we,0,Be("length",t)),(function(){var r=arguments,n=this;return e.apply(n,ae((function(e){return e.apply(n,r)}),t))}))})),We=Ve,Ye=C((function(e,t){return null==t||t!=t?e:t})),Je=Ye,Qe=function(){function e(e,t){this.xf=t,this.f=e,this.found=!1}return e.prototype["@@transducer/init"]=L,e.prototype["@@transducer/result"]=function(e){return this.found||(e=this.xf["@@transducer/step"](e,void 0)),this.xf["@@transducer/result"](e)},e.prototype["@@transducer/step"]=function(e,t){return this.f(t)&&(this.found=!0,e=function(e){return e&&e["@@transducer/reduced"]?e:{"@@transducer/value":e,"@@transducer/reduced":!0}}(this.xf["@@transducer/step"](e,t))),e},e}(),Xe=C(P(["find"],(function(e){return function(t){return new Qe(e,t)}}),(function(e,t){for(var r=0,n=t.length;r<n;){if(e(t[r]))return t[r];r+=1}}))),et=Xe,tt=O((function(e){return We((function(){return Array.prototype.slice.call(arguments,0)}),e)})),rt=tt,nt=C((function(e,t){for(var r=t,n=0;n<e.length;n+=1){if(null==r)return;var a=e[n];r=Ee(a)?Ae(a,r):r[a]}return r})),at=nt,it=j((function(e,t,r){return ne(e,Re(t,r))})),st=it,ot=class extends Error{name="InvalidSchedulerLocation"},ut=class extends Error{name="SchedulerTagNotFound"},ct=class extends Error{name="TransactionNotFound"};function lt(e=""){return(e=e.trim()).endsWith("/")?lt(e.slice(0,-1)):e}var ht=e=>{if(e.ok)return e;throw e},dt=e=>Ge(Je([]),et(st(e,"name")),Je({}),Re("value")),ft=e=>Ge((t=>{if(!t)throw new ct(e);return t}),Re("tags"),Je([]));function pt({fetch:e,GRAPHQL_URL:t,GRAPHQL_MAX_RETRIES:r=0,GRAPHQL_RETRY_BACKOFF:n=300}){return async({query:a,variables:i})=>((e,{maxRetries:t=0,delay:r=300})=>{let n=(r,a)=>Promise.resolve().then(e).catch((e=>{if(r>=t)return Promise.reject(e);let i=r+1,s=a+a;return new Promise((e=>setTimeout(e,a))).then((()=>n(i,s)))}));return n(0,r)})((()=>e(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:a,variables:i})}).then(ht).then((e=>e.json()))),{maxRetries:r,delay:n})}function gt({fetch:e,GRAPHQL_URL:t,GRAPHQL_MAX_RETRIES:r,GRAPHQL_RETRY_BACKOFF:n}){let a=pt({fetch:e,GRAPHQL_URL:t,GRAPHQL_MAX_RETRIES:r,GRAPHQL_RETRY_BACKOFF:n}),i=yt({fetch:e,GRAPHQL_URL:t,GRAPHQL_MAX_RETRIES:r,GRAPHQL_RETRY_BACKOFF:n});return async e=>a({query:"\n query GetTransactions ($transactionIds: [ID!]!) {\n transactions(ids: $transactionIds) {\n edges {\n node {\n tags {\n name\n value\n }\n }\n }\n }\n }\n ",variables:{transactionIds:[e]}}).then(at(["data","transactions","edges","0","node"])).then(ft(`Process ${e} was not found on gateway`)).then(dt("Scheduler")).then((e=>{if(!e)throw new ut('No "Scheduler" tag found on process');return i(e)}))}function yt({fetch:e,GRAPHQL_URL:t,GRAPHQL_MAX_RETRIES:r,GRAPHQL_RETRY_BACKOFF:n}){let a=pt({fetch:e,GRAPHQL_URL:t,GRAPHQL_MAX_RETRIES:r,GRAPHQL_RETRY_BACKOFF:n});return async e=>a({query:'\n query GetSchedulerLocation ($owner: String!) {\n transactions (\n owners: [$owner]\n tags: [\n { name: "Data-Protocol", values: ["ao"] },\n { name: "Type", values: ["Scheduler-Location"] }\n ]\n # Only need the most recent Scheduler-Location\n sort: HEIGHT_DESC\n first: 1\n ) {\n edges {\n node {\n tags {\n name\n value\n }\n }\n }\n }\n }\n ',variables:{owner:e}}).then(at(["data","transactions","edges","0","node"])).then(ft(`Could not find 'Scheduler-Location' owner by wallet ${e}`)).then(rt([dt("Url"),dt("Time-To-Live")])).then((([t,r])=>{if(!t)throw new ot('No "Url" tag found on Scheduler-Location');if(!r)throw new ot('No "Time-To-Live" tag found on Scheduler-Location');return{url:t,ttl:r,address:e}}))}var mt="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,vt=new Set,wt="object"==typeof process&&process?process:{},bt=(e,t,r,n)=>{"function"==typeof wt.emitWarning?wt.emitWarning(e,t,r,n):console.error(`[${r}] ${t}: ${e}`)},_t=globalThis.AbortController,Tt=globalThis.AbortSignal;if(typeof _t>"u"){Tt=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(e,t){this._onabort.push(t)}},_t=class{constructor(){t()}signal=new Tt;abort(e){if(!this.signal.aborted){this.signal.reason=e,this.signal.aborted=!0;for(let t of this.signal._onabort)t(e);this.signal.onabort?.(e)}}};let e="1"!==wt.env?.LRU_CACHE_IGNORE_AC_WARNING,t=()=>{e&&(e=!1,bt("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",t))}}Symbol("type");var Et,kt,At=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),xt=e=>At(e)?e<=Math.pow(2,8)?Uint8Array:e<=Math.pow(2,16)?Uint16Array:e<=Math.pow(2,32)?Uint32Array:e<=Number.MAX_SAFE_INTEGER?St:null:null,St=class extends Array{constructor(e){super(e),this.fill(0)}},Ot=class e{heap;length;static#e=!1;static create(t){let r=xt(t);if(!r)return[];e.#e=!0;let n=new e(t,r);return e.#e=!1,n}constructor(t,r){if(!e.#e)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new r(t),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},Ct=class e{#e;#t;#r;#n;#a;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#i;#s;#o;#u;#c;#l;#h;#d;#f;#p;#g;#y;#m;#v;#w;#b;#_;static unsafeExposeInternals(e){return{starts:e.#m,ttls:e.#v,sizes:e.#y,keyMap:e.#o,keyList:e.#u,valList:e.#c,next:e.#l,prev:e.#h,get head(){return e.#d},get tail(){return e.#f},free:e.#p,isBackgroundFetch:t=>e.#T(t),backgroundFetch:(t,r,n,a)=>e.#E(t,r,n,a),moveToTail:t=>e.#k(t),indexes:t=>e.#A(t),rindexes:t=>e.#x(t),isStale:t=>e.#S(t)}}get max(){return this.#e}get maxSize(){return this.#t}get calculatedSize(){return this.#s}get size(){return this.#i}get fetchMethod(){return this.#a}get dispose(){return this.#r}get disposeAfter(){return this.#n}constructor(t){let{max:r=0,ttl:n,ttlResolution:a=1,ttlAutopurge:i,updateAgeOnGet:s,updateAgeOnHas:o,allowStale:u,dispose:c,disposeAfter:l,noDisposeOnSet:h,noUpdateTTL:d,maxSize:f=0,maxEntrySize:p=0,sizeCalculation:g,fetchMethod:y,noDeleteOnFetchRejection:m,noDeleteOnStaleGet:v,allowStaleOnFetchRejection:w,allowStaleOnFetchAbort:b,ignoreFetchAbort:_}=t;if(0!==r&&!At(r))throw new TypeError("max option must be a nonnegative integer");let T=r?xt(r):Array;if(!T)throw new Error("invalid max value: "+r);if(this.#e=r,this.#t=f,this.maxEntrySize=p||this.#t,this.sizeCalculation=g,this.sizeCalculation){if(!this.#t&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if("function"!=typeof this.sizeCalculation)throw new TypeError("sizeCalculation set to non-function")}if(void 0!==y&&"function"!=typeof y)throw new TypeError("fetchMethod must be a function if specified");if(this.#a=y,this.#b=!!y,this.#o=new Map,this.#u=new Array(r).fill(void 0),this.#c=new Array(r).fill(void 0),this.#l=new T(r),this.#h=new T(r),this.#d=0,this.#f=0,this.#p=Ot.create(r),this.#i=0,this.#s=0,"function"==typeof c&&(this.#r=c),"function"==typeof l?(this.#n=l,this.#g=[]):(this.#n=void 0,this.#g=void 0),this.#w=!!this.#r,this.#_=!!this.#n,this.noDisposeOnSet=!!h,this.noUpdateTTL=!!d,this.noDeleteOnFetchRejection=!!m,this.allowStaleOnFetchRejection=!!w,this.allowStaleOnFetchAbort=!!b,this.ignoreFetchAbort=!!_,0!==this.maxEntrySize){if(0!==this.#t&&!At(this.#t))throw new TypeError("maxSize must be a positive integer if specified");if(!At(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#O()}if(this.allowStale=!!u,this.noDeleteOnStaleGet=!!v,this.updateAgeOnGet=!!s,this.updateAgeOnHas=!!o,this.ttlResolution=At(a)||0===a?a:1,this.ttlAutopurge=!!i,this.ttl=n||0,this.ttl){if(!At(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#C()}if(0===this.#e&&0===this.ttl&&0===this.#t)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#e&&!this.#t){let t="LRU_CACHE_UNBOUNDED";(e=>!vt.has(e))(t)&&(vt.add(t),bt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",t,e))}}getRemainingTTL(e){return this.#o.has(e)?1/0:0}#C(){let e=new St(this.#e),t=new St(this.#e);this.#v=e,this.#m=t,this.#R=(r,n,a=mt.now())=>{if(t[r]=0!==n?a:0,e[r]=n,0!==n&&this.ttlAutopurge){let e=setTimeout((()=>{this.#S(r)&&this.delete(this.#u[r])}),n+1);e.unref&&e.unref()}},this.#I=r=>{t[r]=0!==e[r]?mt.now():0},this.#B=(a,i)=>{if(e[i]){let s=e[i],o=t[i];if(!s||!o)return;a.ttl=s,a.start=o,a.now=r||n();let u=a.now-o;a.remainingTTL=s-u}};let r=0,n=()=>{let e=mt.now();if(this.ttlResolution>0){r=e;let t=setTimeout((()=>r=0),this.ttlResolution);t.unref&&t.unref()}return e};this.getRemainingTTL=a=>{let i=this.#o.get(a);if(void 0===i)return 0;let s=e[i],o=t[i];return s&&o?s-((r||n())-o):1/0},this.#S=a=>{let i=t[a],s=e[a];return!!s&&!!i&&(r||n())-i>s}}#I=()=>{};#B=()=>{};#R=()=>{};#S=()=>!1;#O(){let e=new St(this.#e);this.#s=0,this.#y=e,this.#U=t=>{this.#s-=e[t],e[t]=0},this.#j=(e,t,r,n)=>{if(this.#T(t))return 0;if(!At(r)){if(!n)throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");if("function"!=typeof n)throw new TypeError("sizeCalculation must be a function");if(r=n(t,e),!At(r))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}return r},this.#N=(t,r,n)=>{if(e[t]=r,this.#t){let r=this.#t-e[t];for(;this.#s>r;)this.#P(!0)}this.#s+=e[t],n&&(n.entrySize=r,n.totalCalculatedSize=this.#s)}}#U=e=>{};#N=(e,t,r)=>{};#j=(e,t,r,n)=>{if(r||n)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#A({allowStale:e=this.allowStale}={}){if(this.#i)for(let t=this.#f;this.#L(t)&&((e||!this.#S(t))&&(yield t),t!==this.#d);)t=this.#h[t]}*#x({allowStale:e=this.allowStale}={}){if(this.#i)for(let t=this.#d;this.#L(t)&&((e||!this.#S(t))&&(yield t),t!==this.#f);)t=this.#l[t]}#L(e){return void 0!==e&&this.#o.get(this.#u[e])===e}*entries(){for(let e of this.#A())void 0!==this.#c[e]&&void 0!==this.#u[e]&&!this.#T(this.#c[e])&&(yield[this.#u[e],this.#c[e]])}*rentries(){for(let e of this.#x())void 0!==this.#c[e]&&void 0!==this.#u[e]&&!this.#T(this.#c[e])&&(yield[this.#u[e],this.#c[e]])}*keys(){for(let e of this.#A()){let t=this.#u[e];void 0!==t&&!this.#T(this.#c[e])&&(yield t)}}*rkeys(){for(let e of this.#x()){let t=this.#u[e];void 0!==t&&!this.#T(this.#c[e])&&(yield t)}}*values(){for(let e of this.#A())void 0!==this.#c[e]&&!this.#T(this.#c[e])&&(yield this.#c[e])}*rvalues(){for(let e of this.#x())void 0!==this.#c[e]&&!this.#T(this.#c[e])&&(yield this.#c[e])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(e,t={}){for(let r of this.#A()){let n=this.#c[r],a=this.#T(n)?n.__staleWhileFetching:n;if(void 0!==a&&e(a,this.#u[r],this))return this.get(this.#u[r],t)}}forEach(e,t=this){for(let r of this.#A()){let n=this.#c[r],a=this.#T(n)?n.__staleWhileFetching:n;void 0!==a&&e.call(t,a,this.#u[r],this)}}rforEach(e,t=this){for(let r of this.#x()){let n=this.#c[r],a=this.#T(n)?n.__staleWhileFetching:n;void 0!==a&&e.call(t,a,this.#u[r],this)}}purgeStale(){let e=!1;for(let t of this.#x({allowStale:!0}))this.#S(t)&&(this.delete(this.#u[t]),e=!0);return e}info(e){let t=this.#o.get(e);if(void 0===t)return;let r=this.#c[t],n=this.#T(r)?r.__staleWhileFetching:r;if(void 0===n)return;let a={value:n};if(this.#v&&this.#m){let e=this.#v[t],r=this.#m[t];if(e&&r){let t=e-(mt.now()-r);a.ttl=t,a.start=Date.now()}}return this.#y&&(a.size=this.#y[t]),a}dump(){let e=[];for(let t of this.#A({allowStale:!0})){let r=this.#u[t],n=this.#c[t],a=this.#T(n)?n.__staleWhileFetching:n;if(void 0===a||void 0===r)continue;let i={value:a};if(this.#v&&this.#m){i.ttl=this.#v[t];let e=mt.now()-this.#m[t];i.start=Math.floor(Date.now()-e)}this.#y&&(i.size=this.#y[t]),e.unshift([r,i])}return e}load(e){this.clear();for(let[t,r]of e){if(r.start){let e=Date.now()-r.start;r.start=mt.now()-e}this.set(t,r.value,r)}}set(e,t,r={}){if(void 0===t)return this.delete(e),this;let{ttl:n=this.ttl,start:a,noDisposeOnSet:i=this.noDisposeOnSet,sizeCalculation:s=this.sizeCalculation,status:o}=r,{noUpdateTTL:u=this.noUpdateTTL}=r,c=this.#j(e,t,r.size||0,s);if(this.maxEntrySize&&c>this.maxEntrySize)return o&&(o.set="miss",o.maxEntrySizeExceeded=!0),this.delete(e),this;let l=0===this.#i?void 0:this.#o.get(e);if(void 0===l)l=0===this.#i?this.#f:0!==this.#p.length?this.#p.pop():this.#i===this.#e?this.#P(!1):this.#i,this.#u[l]=e,this.#c[l]=t,this.#o.set(e,l),this.#l[this.#f]=l,this.#h[l]=this.#f,this.#f=l,this.#i++,this.#N(l,c,o),o&&(o.set="add"),u=!1;else{this.#k(l);let r=this.#c[l];if(t!==r){if(this.#b&&this.#T(r)){r.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:t}=r;void 0!==t&&!i&&(this.#w&&this.#r?.(t,e,"set"),this.#_&&this.#g?.push([t,e,"set"]))}else i||(this.#w&&this.#r?.(r,e,"set"),this.#_&&this.#g?.push([r,e,"set"]));if(this.#U(l),this.#N(l,c,o),this.#c[l]=t,o){o.set="replace";let e=r&&this.#T(r)?r.__staleWhileFetching:r;void 0!==e&&(o.oldValue=e)}}else o&&(o.set="update")}if(0!==n&&!this.#v&&this.#C(),this.#v&&(u||this.#R(l,n,a),o&&this.#B(o,l)),!i&&this.#_&&this.#g){let e,t=this.#g;for(;e=t?.shift();)this.#n?.(...e)}return this}pop(){try{for(;this.#i;){let e=this.#c[this.#d];if(this.#P(!0),this.#T(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(void 0!==e)return e}}finally{if(this.#_&&this.#g){let e,t=this.#g;for(;e=t?.shift();)this.#n?.(...e)}}}#P(e){let t=this.#d,r=this.#u[t],n=this.#c[t];return this.#b&&this.#T(n)?n.__abortController.abort(new Error("evicted")):(this.#w||this.#_)&&(this.#w&&this.#r?.(n,r,"evict"),this.#_&&this.#g?.push([n,r,"evict"])),this.#U(t),e&&(this.#u[t]=void 0,this.#c[t]=void 0,this.#p.push(t)),1===this.#i?(this.#d=this.#f=0,this.#p.length=0):this.#d=this.#l[t],this.#o.delete(r),this.#i--,t}has(e,t={}){let{updateAgeOnHas:r=this.updateAgeOnHas,status:n}=t,a=this.#o.get(e);if(void 0!==a){let e=this.#c[a];if(this.#T(e)&&void 0===e.__staleWhileFetching)return!1;if(!this.#S(a))return r&&this.#I(a),n&&(n.has="hit",this.#B(n,a)),!0;n&&(n.has="stale",this.#B(n,a))}else n&&(n.has="miss");return!1}peek(e,t={}){let{allowStale:r=this.allowStale}=t,n=this.#o.get(e);if(void 0===n||!r&&this.#S(n))return;let a=this.#c[n];return this.#T(a)?a.__staleWhileFetching:a}#E(e,t,r,n){let a=void 0===t?void 0:this.#c[t];if(this.#T(a))return a;let i=new _t,{signal:s}=r;s?.addEventListener("abort",(()=>i.abort(s.reason)),{signal:i.signal});let o={signal:i.signal,options:r,context:n},u=(n,a=!1)=>{let{aborted:s}=i.signal,u=r.ignoreFetchAbort&&void 0!==n;if(r.status&&(s&&!a?(r.status.fetchAborted=!0,r.status.fetchError=i.signal.reason,u&&(r.status.fetchAbortIgnored=!0)):r.status.fetchResolved=!0),s&&!u&&!a)return c(i.signal.reason);let h=l;return this.#c[t]===l&&(void 0===n?h.__staleWhileFetching?this.#c[t]=h.__staleWhileFetching:this.delete(e):(r.status&&(r.status.fetchUpdated=!0),this.set(e,n,o.options))),n},c=n=>{let{aborted:a}=i.signal,s=a&&r.allowStaleOnFetchAbort,o=s||r.allowStaleOnFetchRejection,u=o||r.noDeleteOnFetchRejection,c=l;if(this.#c[t]===l&&(u&&void 0!==c.__staleWhileFetching?s||(this.#c[t]=c.__staleWhileFetching):this.delete(e)),o)return r.status&&void 0!==c.__staleWhileFetching&&(r.status.returnedStale=!0),c.__staleWhileFetching;if(c.__returned===c)throw n};r.status&&(r.status.fetchDispatched=!0);let l=new Promise(((t,n)=>{let s=this.#a?.(e,a,o);s&&s instanceof Promise&&s.then((e=>t(void 0===e?void 0:e)),n),i.signal.addEventListener("abort",(()=>{(!r.ignoreFetchAbort||r.allowStaleOnFetchAbort)&&(t(void 0),r.allowStaleOnFetchAbort&&(t=e=>u(e,!0)))}))})).then(u,(e=>(r.status&&(r.status.fetchRejected=!0,r.status.fetchError=e),c(e)))),h=Object.assign(l,{__abortController:i,__staleWhileFetching:a,__returned:void 0});return void 0===t?(this.set(e,h,{...o.options,status:void 0}),t=this.#o.get(e)):this.#c[t]=h,h}#T(e){if(!this.#b)return!1;let t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof _t}async fetch(e,t={}){let{allowStale:r=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,ttl:i=this.ttl,noDisposeOnSet:s=this.noDisposeOnSet,size:o=0,sizeCalculation:u=this.sizeCalculation,noUpdateTTL:c=this.noUpdateTTL,noDeleteOnFetchRejection:l=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:h=this.allowStaleOnFetchRejection,ignoreFetchAbort:d=this.ignoreFetchAbort,allowStaleOnFetchAbort:f=this.allowStaleOnFetchAbort,context:p,forceRefresh:g=!1,status:y,signal:m}=t;if(!this.#b)return y&&(y.fetch="get"),this.get(e,{allowStale:r,updateAgeOnGet:n,noDeleteOnStaleGet:a,status:y});let v={allowStale:r,updateAgeOnGet:n,noDeleteOnStaleGet:a,ttl:i,noDisposeOnSet:s,size:o,sizeCalculation:u,noUpdateTTL:c,noDeleteOnFetchRejection:l,allowStaleOnFetchRejection:h,allowStaleOnFetchAbort:f,ignoreFetchAbort:d,status:y,signal:m},w=this.#o.get(e);if(void 0===w){y&&(y.fetch="miss");let t=this.#E(e,w,v,p);return t.__returned=t}{let t=this.#c[w];if(this.#T(t)){let e=r&&void 0!==t.__staleWhileFetching;return y&&(y.fetch="inflight",e&&(y.returnedStale=!0)),e?t.__staleWhileFetching:t.__returned=t}let a=this.#S(w);if(!g&&!a)return y&&(y.fetch="hit"),this.#k(w),n&&this.#I(w),y&&this.#B(y,w),t;let i=this.#E(e,w,v,p),s=void 0!==i.__staleWhileFetching&&r;return y&&(y.fetch=a?"stale":"refresh",s&&a&&(y.returnedStale=!0)),s?i.__staleWhileFetching:i.__returned=i}}get(e,t={}){let{allowStale:r=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,status:i}=t,s=this.#o.get(e);if(void 0!==s){let t=this.#c[s],o=this.#T(t);return i&&this.#B(i,s),this.#S(s)?(i&&(i.get="stale"),o?(i&&r&&void 0!==t.__staleWhileFetching&&(i.returnedStale=!0),r?t.__staleWhileFetching:void 0):(a||this.delete(e),i&&r&&(i.returnedStale=!0),r?t:void 0)):(i&&(i.get="hit"),o?t.__staleWhileFetching:(this.#k(s),n&&this.#I(s),t))}i&&(i.get="miss")}#$(e,t){this.#h[t]=e,this.#l[e]=t}#k(e){e!==this.#f&&(e===this.#d?this.#d=this.#l[e]:this.#$(this.#h[e],this.#l[e]),this.#$(this.#f,e),this.#f=e)}delete(e){let t=!1;if(0!==this.#i){let r=this.#o.get(e);if(void 0!==r)if(t=!0,1===this.#i)this.clear();else{this.#U(r);let t=this.#c[r];if(this.#T(t)?t.__abortController.abort(new Error("deleted")):(this.#w||this.#_)&&(this.#w&&this.#r?.(t,e,"delete"),this.#_&&this.#g?.push([t,e,"delete"])),this.#o.delete(e),this.#u[r]=void 0,this.#c[r]=void 0,r===this.#f)this.#f=this.#h[r];else if(r===this.#d)this.#d=this.#l[r];else{let e=this.#h[r];this.#l[e]=this.#l[r];let t=this.#l[r];this.#h[t]=this.#h[r]}this.#i--,this.#p.push(r)}}if(this.#_&&this.#g?.length){let e,t=this.#g;for(;e=t?.shift();)this.#n?.(...e)}return t}clear(){for(let e of this.#x({allowStale:!0})){let t=this.#c[e];if(this.#T(t))t.__abortController.abort(new Error("deleted"));else{let r=this.#u[e];this.#w&&this.#r?.(t,r,"delete"),this.#_&&this.#g?.push([t,r,"delete"])}}if(this.#o.clear(),this.#c.fill(void 0),this.#u.fill(void 0),this.#v&&this.#m&&(this.#v.fill(0),this.#m.fill(0)),this.#y&&this.#y.fill(0),this.#d=0,this.#f=0,this.#p.length=0,this.#s=0,this.#i=0,this.#_&&this.#g){let e,t=this.#g;for(;e=t?.shift();)this.#n?.(...e)}}};function Rt({cache:e}){return async t=>{if(e.max)return e.get(t)}}function It({cache:e}){return async(t,{url:r,address:n},a)=>{if(e.max)return e.set(t,{url:r,address:n},{ttl:a})}}function Bt({cache:e}){return async t=>{if(e.max)return e.get(t)}}function Ut({cache:e}){return async(t,r,n)=>{if(e.max)return e.set(t,{url:r,address:t,ttl:n},{ttl:n})}}function jt({fetch:e}){return async(t,r)=>{let n=await e(`${t}?process-id=${r}`,{method:"GET",redirect:"manual"});return[301,302,307,308].includes(n.status)?new URL(n.headers.get("Location")).origin:t}}!function(e){e.assertEqual=e=>e,e.assertIs=function(e){},e.assertNever=function(e){throw new Error},e.arrayToEnum=e=>{let t={};for(let r of e)t[r]=r;return t},e.getValidEnumValues=t=>{let r=e.objectKeys(t).filter((e=>"number"!=typeof t[t[e]])),n={};for(let e of r)n[e]=t[e];return e.objectValues(n)},e.objectValues=t=>e.objectKeys(t).map((function(e){return t[e]})),e.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{let t=[];for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.push(r);return t},e.find=(e,t)=>{for(let r of e)if(t(r))return r},e.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&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}(Et||(Et={})),(kt||(kt={})).mergeShapes=(e,t)=>({...e,...t});var Nt=Et.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Pt=e=>{switch(typeof e){case"undefined":return Nt.undefined;case"string":return Nt.string;case"number":return isNaN(e)?Nt.nan:Nt.number;case"boolean":return Nt.boolean;case"function":return Nt.function;case"bigint":return Nt.bigint;case"symbol":return Nt.symbol;case"object":return Array.isArray(e)?Nt.array:null===e?Nt.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?Nt.promise:typeof Map<"u"&&e instanceof Map?Nt.map:typeof Set<"u"&&e instanceof Set?Nt.set:typeof Date<"u"&&e instanceof Date?Nt.date:Nt.object;default:return Nt.unknown}},Lt=Et.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"]),$t=class e extends Error{constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){let t=e||function(e){return e.message},r={_errors:[]},n=e=>{for(let a of e.issues)if("invalid_union"===a.code)a.unionErrors.map(n);else if("invalid_return_type"===a.code)n(a.returnTypeError);else if("invalid_arguments"===a.code)n(a.argumentsError);else if(0===a.path.length)r._errors.push(t(a));else{let e=r,n=0;for(;n<a.path.length;){let r=a.path[n];n===a.path.length-1?(e[r]=e[r]||{_errors:[]},e[r]._errors.push(t(a))):e[r]=e[r]||{_errors:[]},e=e[r],n++}}};return n(this),r}static assert(t){if(!(t instanceof e))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Et.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){let t={},r=[];for(let n of this.issues)n.path.length>0?(t[n.path[0]]=t[n.path[0]]||[],t[n.path[0]].push(e(n))):r.push(e(n));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}};$t.create=e=>new $t(e);var Mt=(e,t)=>{let r;switch(e.code){case Lt.invalid_type:r=e.received===Nt.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case Lt.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,Et.jsonStringifyReplacer)}`;break;case Lt.unrecognized_keys:r=`Unrecognized key(s) in object: ${Et.joinValues(e.keys,", ")}`;break;case Lt.invalid_union:r="Invalid input";break;case Lt.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Et.joinValues(e.options)}`;break;case Lt.invalid_enum_value:r=`Invalid enum value. Expected ${Et.joinValues(e.options)}, received '${e.received}'`;break;case Lt.invalid_arguments:r="Invalid function arguments";break;case Lt.invalid_return_type:r="Invalid function return type";break;case Lt.invalid_date:r="Invalid date";break;case Lt.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:Et.assertNever(e.validation):r="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case Lt.too_small:r="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?`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 Lt.too_big:r="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 Lt.custom:r="Invalid input";break;case Lt.invalid_intersection_types:r="Intersection results could not be merged";break;case Lt.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case Lt.not_finite:r="Number must be finite";break;default:r=t.defaultError,Et.assertNever(e)}return{message:r}},Zt=Mt;function Dt(){return Zt}var Ft=e=>{let{data:t,path:r,errorMaps:n,issueData:a}=e,i=[...r,...a.path||[]],s={...a,path:i};if(void 0!==a.message)return{...a,path:i,message:a.message};let o="",u=n.filter((e=>!!e)).slice().reverse();for(let e of u)o=e(s,{data:t,defaultError:o}).message;return{...a,path:i,message:o}};function zt(e,t){let r=Dt(),n=Ft({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===Mt?void 0:Mt].filter((e=>!!e))});e.common.issues.push(n)}var Kt,qt,Ht,Gt=class e{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){let r=[];for(let n of t){if("aborted"===n.status)return Vt;"dirty"===n.status&&e.dirty(),r.push(n.value)}return{status:e.value,value:r}}static async mergeObjectAsync(t,r){let n=[];for(let e of r){let t=await e.key,r=await e.value;n.push({key:t,value:r})}return e.mergeObjectSync(t,n)}static mergeObjectSync(e,t){let r={};for(let n of t){let{key:t,value:a}=n;if("aborted"===t.status||"aborted"===a.status)return Vt;"dirty"===t.status&&e.dirty(),"dirty"===a.status&&e.dirty(),"__proto__"!==t.value&&(typeof a.value<"u"||n.alwaysSet)&&(r[t.value]=a.value)}return{status:e.value,value:r}}},Vt=Object.freeze({status:"aborted"}),Wt=e=>({status:"dirty",value:e}),Yt=e=>({status:"valid",value:e}),Jt=e=>"aborted"===e.status,Qt=e=>"dirty"===e.status,Xt=e=>"valid"===e.status,er=e=>typeof Promise<"u"&&e instanceof Promise;function tr(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)}function rr(e,t,r,n,a){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!a)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?a.call(e,r):a?a.value=r:t.set(e,r),r}!function(e){e.errToObj=e=>"string"==typeof e?{message:e}:e||{},e.toString=e=>"string"==typeof e?e:e?.message}(Kt||(Kt={}));var nr=class{constructor(e,t,r,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=n}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},ar=(e,t)=>{if(Xt(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;let t=new $t(e.common.issues);return this._error=t,this._error}}};function ir(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:n,description:a}=e;if(t&&(r||n))throw new Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');return t?{errorMap:t,description:a}:{errorMap:(t,a)=>{var i,s;let{message:o}=e;return"invalid_enum_value"===t.code?{message:o??a.defaultError}:typeof a.data>"u"?{message:null!==(i=o??n)&&void 0!==i?i:a.defaultError}:"invalid_type"!==t.code?{message:a.defaultError}:{message:null!==(s=o??r)&&void 0!==s?s:a.defaultError}},description:a}}var sr,or=class{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)}get description(){return this._def.description}_getType(e){return Pt(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Pt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Gt,ctx:{common:e.parent.common,data:e.data,parsedType:Pt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(er(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){var r;let n={common:{issues:[],async:null!==(r=t?.async)&&void 0!==r&&r,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Pt(e)},a=this._parseSync({data:e,path:n.path,parent:n});return ar(n,a)}async parseAsync(e,t){let r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){let r={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Pt(e)},n=this._parse({data:e,path:r.path,parent:r}),a=await(er(n)?n:Promise.resolve(n));return ar(r,a)}refine(e,t){let r=e=>"string"==typeof t||typeof t>"u"?{message:t}:"function"==typeof t?t(e):t;return this._refinement(((t,n)=>{let a=e(t),i=()=>n.addIssue({code:Lt.custom,...r(t)});return typeof Promise<"u"&&a instanceof Promise?a.then((e=>!!e||(i(),!1))):!!a||(i(),!1)}))}refinement(e,t){return this._refinement(((r,n)=>!!e(r)||(n.addIssue("function"==typeof t?t(r,n):t),!1)))}_refinement(e){return new rn({schema:this,typeName:pn.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return nn.create(this,this._def)}nullable(){return an.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Lr.create(this,this._def)}promise(){return tn.create(this,this._def)}or(e){return Zr.create([this,e],this._def)}and(e){return Kr.create(this,e,this._def)}transform(e){return new rn({...ir(this._def),schema:this,typeName:pn.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t="function"==typeof e?e:()=>e;return new sn({...ir(this._def),innerType:this,defaultValue:t,typeName:pn.ZodDefault})}brand(){return new ln({typeName:pn.ZodBranded,type:this,...ir(this._def)})}catch(e){let t="function"==typeof e?e:()=>e;return new on({...ir(this._def),innerType:this,catchValue:t,typeName:pn.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return hn.create(this,e)}readonly(){return dn.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},ur=/^c[^\s-]{8,}$/i,cr=/^[0-9a-z]+$/,lr=/^[0-9A-HJKMNP-TV-Z]{26}$/,hr=/^[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,dr=/^[a-z0-9_-]{21}$/i,fr=/^[-+]?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)?)??$/,pr=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,gr=/^(?:(?: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])$/,yr=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,mr=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,vr="((\\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])))",wr=new RegExp(`^${vr}$`);function br(e){let t="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`),t}function _r(e){return new RegExp(`^${br(e)}$`)}function Tr(e){let t=`${vr}T${br(e)}`,r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function Er(e,t){return!(("v4"!==t&&t||!gr.test(e))&&("v6"!==t&&t||!yr.test(e)))}var kr=class e extends or{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==Nt.string){let t=this._getOrReturnCtx(e);return zt(t,{code:Lt.invalid_type,expected:Nt.string,received:t.parsedType}),Vt}let t,r=new Gt;for(let n of this._def.checks)if("min"===n.kind)e.data.length<n.value&&(t=this._getOrReturnCtx(e,t),zt(t,{code:Lt.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),r.dirty());else if("max"===n.kind)e.data.length>n.value&&(t=this._getOrReturnCtx(e,t),zt(t,{code:Lt.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),r.dirty());else if("length"===n.kind){let a=e.data.length>n.value,i=e.data.length<n.value;(a||i)&&(t=this._getOrReturnCtx(e,t),a?zt(t,{code:Lt.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}):i&&zt(t,{code:Lt.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}),r.dirty())}else if("email"===n.kind)pr.test(e.data)||(t=this._getOrReturnCtx(e,t),zt(t,{validation:"email",code:Lt.invalid_string,message:n.message}),r.dirty());else if("emoji"===n.kind)sr||(sr=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),sr.test(e.data)||(t=this._getOrReturnCtx(e,t),zt(t,{validation:"emoji",code:Lt.invalid_string,message:n.message}),r.dirty());else if("uuid"===n.kind)hr.test(e.data)||(t=this._getOrReturnCtx(e,t),zt(t,{validation:"uuid",code:Lt.invalid_string,message:n.message}),r.dirty());else if("nanoid"===n.kind)dr.test(e.data)||(t=this._getOrReturnCtx(e,t),zt(t,{validation:"nanoid",code:Lt.invalid_string,message:n.message}),r.dirty());else if("cuid"===n.kind)ur.test(e.data)||(t=this._getOrReturnCtx(e,t),zt(t,{validation:"cuid",code:Lt.invalid_string,message:n.message}),r.dirty());else if("cuid2"===n.kind)cr.test(e.data)||(t=this._getOrReturnCtx(e,t),zt(t,{validation:"cuid2",code:Lt.invalid_string,message:n.message}),r.dirty());else if("ulid"===n.kind)lr.test(e.data)||(t=this._getOrReturnCtx(e,t),zt(t,{validation:"ulid",code:Lt.invalid_string,message:n.message}),r.dirty());else if("url"===n.kind)try{new URL(e.data)}catch{t=this._getOrReturnCtx(e,t),zt(t,{validation:"url",code:Lt.invalid_string,message:n.message}),r.dirty()}else"regex"===n.kind?(n.regex.lastIndex=0,n.regex.test(e.data)||(t=this._getOrReturnCtx(e,t),zt(t,{validation:"regex",code:Lt.invalid_string,message:n.message}),r.dirty())):"trim"===n.kind?e.data=e.data.trim():"includes"===n.kind?e.data.includes(n.value,n.position)||(t=this._getOrReturnCtx(e,t),zt(t,{code:Lt.invalid_string,validation:{includes:n.value,position:n.position},message:n.message}),r.dirty()):"toLowerCase"===n.kind?e.data=e.data.toLowerCase():"toUpperCase"===n.kind?e.data=e.data.toUpperCase():"startsWith"===n.kind?e.data.startsWith(n.value)||(t=this._getOrReturnCtx(e,t),zt(t,{code:Lt.invalid_string,validation:{startsWith:n.value},message:n.message}),r.dirty()):"endsWith"===n.kind?e.data.endsWith(n.value)||(t=this._getOrReturnCtx(e,t),zt(t,{code:Lt.invalid_string,validation:{endsWith:n.value},message:n.message}),r.dirty()):"datetime"===n.kind?Tr(n).test(e.data)||(t=this._getOrReturnCtx(e,t),zt(t,{code:Lt.invalid_string,validation:"datetime",message:n.message}),r.dirty()):"date"===n.kind?wr.test(e.data)||(t=this._getOrReturnCtx(e,t),zt(t,{code:Lt.invalid_string,validation:"date",message:n.message}),r.dirty()):"time"===n.kind?_r(n).test(e.data)||(t=this._getOrReturnCtx(e,t),zt(t,{code:Lt.invalid_string,validation:"time",message:n.message}),r.dirty()):"duration"===n.kind?fr.test(e.data)||(t=this._getOrReturnCtx(e,t),zt(t,{validation:"duration",code:Lt.invalid_string,message:n.message}),r.dirty()):"ip"===n.kind?Er(e.data,n.version)||(t=this._getOrReturnCtx(e,t),zt(t,{validation:"ip",code:Lt.invalid_string,message:n.message}),r.dirty()):"base64"===n.kind?mr.test(e.data)||(t=this._getOrReturnCtx(e,t),zt(t,{validation:"base64",code:Lt.invalid_string,message:n.message}),r.dirty()):Et.assertNever(n);return{status:r.value,value:e.data}}_regex(e,t,r){return this.refinement((t=>e.test(t)),{validation:t,code:Lt.invalid_string,...Kt.errToObj(r)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:"email",...Kt.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Kt.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Kt.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Kt.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Kt.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Kt.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Kt.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Kt.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Kt.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Kt.errToObj(e)})}datetime(e){var t,r;return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:null!==(t=e?.offset)&&void 0!==t&&t,local:null!==(r=e?.local)&&void 0!==r&&r,...Kt.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:typeof e?.precision>"u"?null:e?.precision,...Kt.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...Kt.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Kt.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...Kt.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Kt.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Kt.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Kt.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Kt.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Kt.errToObj(t)})}nonempty(e){return this.min(1,Kt.errToObj(e))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new e({...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 isBase64(){return!!this._def.checks.find((e=>"base64"===e.kind))}get minLength(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}};function Ar(e,t){let r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,a=r>n?r:n;return parseInt(e.toFixed(a).replace(".",""))%parseInt(t.toFixed(a).replace(".",""))/Math.pow(10,a)}kr.create=e=>{var t;return new kr({checks:[],typeName:pn.ZodString,coerce:null!==(t=e?.coerce)&&void 0!==t&&t,...ir(e)})};var xr=class e extends or{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)!==Nt.number){let t=this._getOrReturnCtx(e);return zt(t,{code:Lt.invalid_type,expected:Nt.number,received:t.parsedType}),Vt}let t,r=new Gt;for(let n of this._def.checks)"int"===n.kind?Et.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),zt(t,{code:Lt.invalid_type,expected:"integer",received:"float",message:n.message}),r.dirty()):"min"===n.kind?(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),zt(t,{code:Lt.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),r.dirty()):"max"===n.kind?(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),zt(t,{code:Lt.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),r.dirty()):"multipleOf"===n.kind?0!==Ar(e.data,n.value)&&(t=this._getOrReturnCtx(e,t),zt(t,{code:Lt.not_multiple_of,multipleOf:n.value,message:n.message}),r.dirty()):"finite"===n.kind?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),zt(t,{code:Lt.not_finite,message:n.message}),r.dirty()):Et.assertNever(n);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Kt.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Kt.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Kt.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Kt.toString(t))}setLimit(t,r,n,a){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:Kt.toString(a)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:"int",message:Kt.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Kt.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Kt.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Kt.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Kt.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Kt.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Kt.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Kt.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Kt.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let 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&&Et.isInteger(e.value)))}get isFinite(){let e=null,t=null;for(let r of this._def.checks){if("finite"===r.kind||"int"===r.kind||"multipleOf"===r.kind)return!0;"min"===r.kind?(null===t||r.value>t)&&(t=r.value):"max"===r.kind&&(null===e||r.value<e)&&(e=r.value)}return Number.isFinite(t)&&Number.isFinite(e)}};xr.create=e=>new xr({checks:[],typeName:pn.ZodNumber,coerce:e?.coerce||!1,...ir(e)});var Sr=class e extends or{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==Nt.bigint){let t=this._getOrReturnCtx(e);return zt(t,{code:Lt.invalid_type,expected:Nt.bigint,received:t.parsedType}),Vt}let t,r=new Gt;for(let n of this._def.checks)"min"===n.kind?(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),zt(t,{code:Lt.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),r.dirty()):"max"===n.kind?(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),zt(t,{code:Lt.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),r.dirty()):"multipleOf"===n.kind?e.data%n.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),zt(t,{code:Lt.not_multiple_of,multipleOf:n.value,message:n.message}),r.dirty()):Et.assertNever(n);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Kt.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Kt.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Kt.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Kt.toString(t))}setLimit(t,r,n,a){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:Kt.toString(a)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Kt.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Kt.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Kt.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Kt.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Kt.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}};Sr.create=e=>{var t;return new Sr({checks:[],typeName:pn.ZodBigInt,coerce:null!==(t=e?.coerce)&&void 0!==t&&t,...ir(e)})};var Or=class extends or{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==Nt.boolean){let t=this._getOrReturnCtx(e);return zt(t,{code:Lt.invalid_type,expected:Nt.boolean,received:t.parsedType}),Vt}return Yt(e.data)}};Or.create=e=>new Or({typeName:pn.ZodBoolean,coerce:e?.coerce||!1,...ir(e)});var Cr=class e extends or{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==Nt.date){let t=this._getOrReturnCtx(e);return zt(t,{code:Lt.invalid_type,expected:Nt.date,received:t.parsedType}),Vt}if(isNaN(e.data.getTime()))return zt(this._getOrReturnCtx(e),{code:Lt.invalid_date}),Vt;let t,r=new Gt;for(let n of this._def.checks)"min"===n.kind?e.data.getTime()<n.value&&(t=this._getOrReturnCtx(e,t),zt(t,{code:Lt.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),r.dirty()):"max"===n.kind?e.data.getTime()>n.value&&(t=this._getOrReturnCtx(e,t),zt(t,{code:Lt.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),r.dirty()):Et.assertNever(n);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Kt.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Kt.toString(t)})}get minDate(){let e=null;for(let 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(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return null!=e?new Date(e):null}};Cr.create=e=>new Cr({checks:[],coerce:e?.coerce||!1,typeName:pn.ZodDate,...ir(e)});var Rr=class extends or{_parse(e){if(this._getType(e)!==Nt.symbol){let t=this._getOrReturnCtx(e);return zt(t,{code:Lt.invalid_type,expected:Nt.symbol,received:t.parsedType}),Vt}return Yt(e.data)}};Rr.create=e=>new Rr({typeName:pn.ZodSymbol,...ir(e)});var Ir=class extends or{_parse(e){if(this._getType(e)!==Nt.undefined){let t=this._getOrReturnCtx(e);return zt(t,{code:Lt.invalid_type,expected:Nt.undefined,received:t.parsedType}),Vt}return Yt(e.data)}};Ir.create=e=>new Ir({typeName:pn.ZodUndefined,...ir(e)});var Br=class extends or{_parse(e){if(this._getType(e)!==Nt.null){let t=this._getOrReturnCtx(e);return zt(t,{code:Lt.invalid_type,expected:Nt.null,received:t.parsedType}),Vt}return Yt(e.data)}};Br.create=e=>new Br({typeName:pn.ZodNull,...ir(e)});var Ur=class extends or{constructor(){super(...arguments),this._any=!0}_parse(e){return Yt(e.data)}};Ur.create=e=>new Ur({typeName:pn.ZodAny,...ir(e)});var jr=class extends or{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Yt(e.data)}};jr.create=e=>new jr({typeName:pn.ZodUnknown,...ir(e)});var Nr=class extends or{_parse(e){let t=this._getOrReturnCtx(e);return zt(t,{code:Lt.invalid_type,expected:Nt.never,received:t.parsedType}),Vt}};Nr.create=e=>new Nr({typeName:pn.ZodNever,...ir(e)});var Pr=class extends or{_parse(e){if(this._getType(e)!==Nt.undefined){let t=this._getOrReturnCtx(e);return zt(t,{code:Lt.invalid_type,expected:Nt.void,received:t.parsedType}),Vt}return Yt(e.data)}};Pr.create=e=>new Pr({typeName:pn.ZodVoid,...ir(e)});var Lr=class e extends or{_parse(e){let{ctx:t,status:r}=this._processInputParams(e),n=this._def;if(t.parsedType!==Nt.array)return zt(t,{code:Lt.invalid_type,expected:Nt.array,received:t.parsedType}),Vt;if(null!==n.exactLength){let e=t.data.length>n.exactLength.value,a=t.data.length<n.exactLength.value;(e||a)&&(zt(t,{code:e?Lt.too_big:Lt.too_small,minimum:a?n.exactLength.value:void 0,maximum:e?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),r.dirty())}if(null!==n.minLength&&t.data.length<n.minLength.value&&(zt(t,{code:Lt.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),r.dirty()),null!==n.maxLength&&t.data.length>n.maxLength.value&&(zt(t,{code:Lt.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map(((e,r)=>n.type._parseAsync(new nr(t,e,t.path,r))))).then((e=>Gt.mergeArray(r,e)));let a=[...t.data].map(((e,r)=>n.type._parseSync(new nr(t,e,t.path,r))));return Gt.mergeArray(r,a)}get element(){return this._def.type}min(t,r){return new e({...this._def,minLength:{value:t,message:Kt.toString(r)}})}max(t,r){return new e({...this._def,maxLength:{value:t,message:Kt.toString(r)}})}length(t,r){return new e({...this._def,exactLength:{value:t,message:Kt.toString(r)}})}nonempty(e){return this.min(1,e)}};function $r(e){if(e instanceof Mr){let t={};for(let r in e.shape){let n=e.shape[r];t[r]=nn.create($r(n))}return new Mr({...e._def,shape:()=>t})}return e instanceof Lr?new Lr({...e._def,type:$r(e.element)}):e instanceof nn?nn.create($r(e.unwrap())):e instanceof an?an.create($r(e.unwrap())):e instanceof qr?qr.create(e.items.map((e=>$r(e)))):e}Lr.create=(e,t)=>new Lr({type:e,minLength:null,maxLength:null,exactLength:null,typeName:pn.ZodArray,...ir(t)});var Mr=class e extends or{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;let e=this._def.shape(),t=Et.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==Nt.object){let t=this._getOrReturnCtx(e);return zt(t,{code:Lt.invalid_type,expected:Nt.object,received:t.parsedType}),Vt}let{status:t,ctx:r}=this._processInputParams(e),{shape:n,keys:a}=this._getCached(),i=[];if(!(this._def.catchall instanceof Nr&&"strip"===this._def.unknownKeys))for(let e in r.data)a.includes(e)||i.push(e);let s=[];for(let e of a){let t=n[e],a=r.data[e];s.push({key:{status:"valid",value:e},value:t._parse(new nr(r,a,r.path,e)),alwaysSet:e in r.data})}if(this._def.catchall instanceof Nr){let e=this._def.unknownKeys;if("passthrough"===e)for(let e of i)s.push({key:{status:"valid",value:e},value:{status:"valid",value:r.data[e]}});else if("strict"===e)i.length>0&&(zt(r,{code:Lt.unrecognized_keys,keys:i}),t.dirty());else if("strip"!==e)throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let e=this._def.catchall;for(let t of i){let n=r.data[t];s.push({key:{status:"valid",value:t},value:e._parse(new nr(r,n,r.path,t)),alwaysSet:t in r.data})}}return r.common.async?Promise.resolve().then((async()=>{let e=[];for(let t of s){let r=await t.key,n=await t.value;e.push({key:r,value:n,alwaysSet:t.alwaysSet})}return e})).then((e=>Gt.mergeObjectSync(t,e))):Gt.mergeObjectSync(t,s)}get shape(){return this._def.shape()}strict(t){return Kt.errToObj,new e({...this._def,unknownKeys:"strict",...void 0!==t?{errorMap:(e,r)=>{var n,a,i,s;let o=null!==(i=null===(a=(n=this._def).errorMap)||void 0===a?void 0:a.call(n,e,r).message)&&void 0!==i?i:r.defaultError;return"unrecognized_keys"===e.code?{message:null!==(s=Kt.errToObj(t).message)&&void 0!==s?s:o}:{message:o}}}:{}})}strip(){return new e({...this._def,unknownKeys:"strip"})}passthrough(){return new e({...this._def,unknownKeys:"passthrough"})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:pn.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let r={};return Et.objectKeys(t).forEach((e=>{t[e]&&this.shape[e]&&(r[e]=this.shape[e])})),new e({...this._def,shape:()=>r})}omit(t){let r={};return Et.objectKeys(this.shape).forEach((e=>{t[e]||(r[e]=this.shape[e])})),new e({...this._def,shape:()=>r})}deepPartial(){return $r(this)}partial(t){let r={};return Et.objectKeys(this.shape).forEach((e=>{let n=this.shape[e];t&&!t[e]?r[e]=n:r[e]=n.optional()})),new e({...this._def,shape:()=>r})}required(t){let r={};return Et.objectKeys(this.shape).forEach((e=>{if(t&&!t[e])r[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof nn;)t=t._def.innerType;r[e]=t}})),new e({...this._def,shape:()=>r})}keyof(){return Qr(Et.objectKeys(this.shape))}};Mr.create=(e,t)=>new Mr({shape:()=>e,unknownKeys:"strip",catchall:Nr.create(),typeName:pn.ZodObject,...ir(t)}),Mr.strictCreate=(e,t)=>new Mr({shape:()=>e,unknownKeys:"strict",catchall:Nr.create(),typeName:pn.ZodObject,...ir(t)}),Mr.lazycreate=(e,t)=>new Mr({shape:e,unknownKeys:"strip",catchall:Nr.create(),typeName:pn.ZodObject,...ir(t)});var Zr=class extends or{_parse(e){let{ctx:t}=this._processInputParams(e),r=this._def.options;if(t.common.async)return Promise.all(r.map((async e=>{let r={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:r}),ctx:r}}))).then((function(e){for(let t of e)if("valid"===t.result.status)return t.result;for(let r of e)if("dirty"===r.result.status)return t.common.issues.push(...r.ctx.common.issues),r.result;let r=e.map((e=>new $t(e.ctx.common.issues)));return zt(t,{code:Lt.invalid_union,unionErrors:r}),Vt}));{let e,n=[];for(let a of r){let r={...t,common:{...t.common,issues:[]},parent:null},i=a._parseSync({data:t.data,path:t.path,parent:r});if("valid"===i.status)return i;"dirty"===i.status&&!e&&(e={result:i,ctx:r}),r.common.issues.length&&n.push(r.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let a=n.map((e=>new $t(e)));return zt(t,{code:Lt.invalid_union,unionErrors:a}),Vt}}get options(){return this._def.options}};Zr.create=(e,t)=>new Zr({options:e,typeName:pn.ZodUnion,...ir(t)});var Dr=e=>e instanceof Yr?Dr(e.schema):e instanceof rn?Dr(e.innerType()):e instanceof Jr?[e.value]:e instanceof Xr?e.options:e instanceof en?Et.objectValues(e.enum):e instanceof sn?Dr(e._def.innerType):e instanceof Ir?[void 0]:e instanceof Br?[null]:e instanceof nn?[void 0,...Dr(e.unwrap())]:e instanceof an?[null,...Dr(e.unwrap())]:e instanceof ln||e instanceof dn?Dr(e.unwrap()):e instanceof on?Dr(e._def.innerType):[],Fr=class e extends or{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==Nt.object)return zt(t,{code:Lt.invalid_type,expected:Nt.object,received:t.parsedType}),Vt;let r=this.discriminator,n=t.data[r],a=this.optionsMap.get(n);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(zt(t,{code:Lt.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),Vt)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,r,n){let a=new Map;for(let e of r){let r=Dr(e.shape[t]);if(!r.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let n of r){if(a.has(n))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(n)}`);a.set(n,e)}}return new e({typeName:pn.ZodDiscriminatedUnion,discriminator:t,options:r,optionsMap:a,...ir(n)})}};function zr(e,t){let r=Pt(e),n=Pt(t);if(e===t)return{valid:!0,data:e};if(r===Nt.object&&n===Nt.object){let r=Et.objectKeys(t),n=Et.objectKeys(e).filter((e=>-1!==r.indexOf(e))),a={...e,...t};for(let r of n){let n=zr(e[r],t[r]);if(!n.valid)return{valid:!1};a[r]=n.data}return{valid:!0,data:a}}if(r===Nt.array&&n===Nt.array){if(e.length!==t.length)return{valid:!1};let r=[];for(let n=0;n<e.length;n++){let a=zr(e[n],t[n]);if(!a.valid)return{valid:!1};r.push(a.data)}return{valid:!0,data:r}}return r===Nt.date&&n===Nt.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var Kr=class extends or{_parse(e){let{status:t,ctx:r}=this._processInputParams(e),n=(e,n)=>{if(Jt(e)||Jt(n))return Vt;let a=zr(e.value,n.value);return a.valid?((Qt(e)||Qt(n))&&t.dirty(),{status:t.value,value:a.data}):(zt(r,{code:Lt.invalid_intersection_types}),Vt)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then((([e,t])=>n(e,t))):n(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};Kr.create=(e,t,r)=>new Kr({left:e,right:t,typeName:pn.ZodIntersection,...ir(r)});var qr=class e extends or{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==Nt.array)return zt(r,{code:Lt.invalid_type,expected:Nt.array,received:r.parsedType}),Vt;if(r.data.length<this._def.items.length)return zt(r,{code:Lt.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Vt;!this._def.rest&&r.data.length>this._def.items.length&&(zt(r,{code:Lt.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let n=[...r.data].map(((e,t)=>{let n=this._def.items[t]||this._def.rest;return n?n._parse(new nr(r,e,r.path,t)):null})).filter((e=>!!e));return r.common.async?Promise.all(n).then((e=>Gt.mergeArray(t,e))):Gt.mergeArray(t,n)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};qr.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new qr({items:e,typeName:pn.ZodTuple,rest:null,...ir(t)})};var Hr=class e extends or{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==Nt.object)return zt(r,{code:Lt.invalid_type,expected:Nt.object,received:r.parsedType}),Vt;let n=[],a=this._def.keyType,i=this._def.valueType;for(let e in r.data)n.push({key:a._parse(new nr(r,e,r.path,e)),value:i._parse(new nr(r,r.data[e],r.path,e)),alwaysSet:e in r.data});return r.common.async?Gt.mergeObjectAsync(t,n):Gt.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(t,r,n){return new e(r instanceof or?{keyType:t,valueType:r,typeName:pn.ZodRecord,...ir(n)}:{keyType:kr.create(),valueType:t,typeName:pn.ZodRecord,...ir(r)})}},Gr=class extends or{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==Nt.map)return zt(r,{code:Lt.invalid_type,expected:Nt.map,received:r.parsedType}),Vt;let n=this._def.keyType,a=this._def.valueType,i=[...r.data.entries()].map((([e,t],i)=>({key:n._parse(new nr(r,e,r.path,[i,"key"])),value:a._parse(new nr(r,t,r.path,[i,"value"]))})));if(r.common.async){let e=new Map;return Promise.resolve().then((async()=>{for(let r of i){let n=await r.key,a=await r.value;if("aborted"===n.status||"aborted"===a.status)return Vt;("dirty"===n.status||"dirty"===a.status)&&t.dirty(),e.set(n.value,a.value)}return{status:t.value,value:e}}))}{let e=new Map;for(let r of i){let n=r.key,a=r.value;if("aborted"===n.status||"aborted"===a.status)return Vt;("dirty"===n.status||"dirty"===a.status)&&t.dirty(),e.set(n.value,a.value)}return{status:t.value,value:e}}}};Gr.create=(e,t,r)=>new Gr({valueType:t,keyType:e,typeName:pn.ZodMap,...ir(r)});var Vr=class e extends or{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==Nt.set)return zt(r,{code:Lt.invalid_type,expected:Nt.set,received:r.parsedType}),Vt;let n=this._def;null!==n.minSize&&r.data.size<n.minSize.value&&(zt(r,{code:Lt.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),null!==n.maxSize&&r.data.size>n.maxSize.value&&(zt(r,{code:Lt.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());let a=this._def.valueType;function i(e){let r=new Set;for(let n of e){if("aborted"===n.status)return Vt;"dirty"===n.status&&t.dirty(),r.add(n.value)}return{status:t.value,value:r}}let s=[...r.data.values()].map(((e,t)=>a._parse(new nr(r,e,r.path,t))));return r.common.async?Promise.all(s).then((e=>i(e))):i(s)}min(t,r){return new e({...this._def,minSize:{value:t,message:Kt.toString(r)}})}max(t,r){return new e({...this._def,maxSize:{value:t,message:Kt.toString(r)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Vr.create=(e,t)=>new Vr({valueType:e,minSize:null,maxSize:null,typeName:pn.ZodSet,...ir(t)});var Wr=class e extends or{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==Nt.function)return zt(t,{code:Lt.invalid_type,expected:Nt.function,received:t.parsedType}),Vt;function r(e,r){return Ft({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Dt(),Mt].filter((e=>!!e)),issueData:{code:Lt.invalid_arguments,argumentsError:r}})}function n(e,r){return Ft({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Dt(),Mt].filter((e=>!!e)),issueData:{code:Lt.invalid_return_type,returnTypeError:r}})}let a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof tn){let e=this;return Yt((async function(...t){let s=new $t([]),o=await e._def.args.parseAsync(t,a).catch((e=>{throw s.addIssue(r(t,e)),s})),u=await Reflect.apply(i,this,o);return await e._def.returns._def.type.parseAsync(u,a).catch((e=>{throw s.addIssue(n(u,e)),s}))}))}{let e=this;return Yt((function(...t){let s=e._def.args.safeParse(t,a);if(!s.success)throw new $t([r(t,s.error)]);let o=Reflect.apply(i,this,s.data),u=e._def.returns.safeParse(o,a);if(!u.success)throw new $t([n(o,u.error)]);return u.data}))}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:qr.create(t).rest(jr.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(t,r,n){return new e({args:t||qr.create([]).rest(jr.create()),returns:r||jr.create(),typeName:pn.ZodFunction,...ir(n)})}},Yr=class extends or{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};Yr.create=(e,t)=>new Yr({getter:e,typeName:pn.ZodLazy,...ir(t)});var Jr=class extends or{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return zt(t,{received:t.data,code:Lt.invalid_literal,expected:this._def.value}),Vt}return{status:"valid",value:e.data}}get value(){return this._def.value}};function Qr(e,t){return new Xr({values:e,typeName:pn.ZodEnum,...ir(t)})}Jr.create=(e,t)=>new Jr({value:e,typeName:pn.ZodLiteral,...ir(t)});var Xr=class e extends or{constructor(){super(...arguments),qt.set(this,void 0)}_parse(e){if("string"!=typeof e.data){let t=this._getOrReturnCtx(e),r=this._def.values;return zt(t,{expected:Et.joinValues(r),received:t.parsedType,code:Lt.invalid_type}),Vt}if(tr(this,qt,"f")||rr(this,qt,new Set(this._def.values),"f"),!tr(this,qt,"f").has(e.data)){let t=this._getOrReturnCtx(e),r=this._def.values;return zt(t,{received:t.data,code:Lt.invalid_enum_value,options:r}),Vt}return Yt(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(t,r=this._def){return e.create(t,{...this._def,...r})}exclude(t,r=this._def){return e.create(this.options.filter((e=>!t.includes(e))),{...this._def,...r})}};qt=new WeakMap,Xr.create=Qr;var en=class extends or{constructor(){super(...arguments),Ht.set(this,void 0)}_parse(e){let t=Et.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==Nt.string&&r.parsedType!==Nt.number){let e=Et.objectValues(t);return zt(r,{expected:Et.joinValues(e),received:r.parsedType,code:Lt.invalid_type}),Vt}if(tr(this,Ht,"f")||rr(this,Ht,new Set(Et.getValidEnumValues(this._def.values)),"f"),!tr(this,Ht,"f").has(e.data)){let e=Et.objectValues(t);return zt(r,{received:r.data,code:Lt.invalid_enum_value,options:e}),Vt}return Yt(e.data)}get enum(){return this._def.values}};Ht=new WeakMap,en.create=(e,t)=>new en({values:e,typeName:pn.ZodNativeEnum,...ir(t)});var tn=class extends or{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==Nt.promise&&!1===t.common.async)return zt(t,{code:Lt.invalid_type,expected:Nt.promise,received:t.parsedType}),Vt;let r=t.parsedType===Nt.promise?t.data:Promise.resolve(t.data);return Yt(r.then((e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap}))))}};tn.create=(e,t)=>new tn({type:e,typeName:pn.ZodPromise,...ir(t)});var rn=class extends or{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===pn.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:r}=this._processInputParams(e),n=this._def.effect||null,a={addIssue:e=>{zt(r,e),e.fatal?t.abort():t.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),"preprocess"===n.type){let e=n.transform(r.data,a);if(r.common.async)return Promise.resolve(e).then((async e=>{if("aborted"===t.value)return Vt;let n=await this._def.schema._parseAsync({data:e,path:r.path,parent:r});return"aborted"===n.status?Vt:"dirty"===n.status||"dirty"===t.value?Wt(n.value):n}));{if("aborted"===t.value)return Vt;let n=this._def.schema._parseSync({data:e,path:r.path,parent:r});return"aborted"===n.status?Vt:"dirty"===n.status||"dirty"===t.value?Wt(n.value):n}}if("refinement"===n.type){let e=e=>{let t=n.refinement(e,a);if(r.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===r.common.async){let n=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return"aborted"===n.status?Vt:("dirty"===n.status&&t.dirty(),e(n.value),{status:t.value,value:n.value})}return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then((r=>"aborted"===r.status?Vt:("dirty"===r.status&&t.dirty(),e(r.value).then((()=>({status:t.value,value:r.value}))))))}if("transform"===n.type){if(!1===r.common.async){let e=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Xt(e))return e;let i=n.transform(e.value,a);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:r.data,path:r.path,parent:r}).then((e=>Xt(e)?Promise.resolve(n.transform(e.value,a)).then((e=>({status:t.value,value:e}))):e))}Et.assertNever(n)}};rn.create=(e,t,r)=>new rn({schema:e,typeName:pn.ZodEffects,effect:t,...ir(r)}),rn.createWithPreprocess=(e,t,r)=>new rn({schema:t,effect:{type:"preprocess",transform:e},typeName:pn.ZodEffects,...ir(r)});var nn=class extends or{_parse(e){return this._getType(e)===Nt.undefined?Yt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};nn.create=(e,t)=>new nn({innerType:e,typeName:pn.ZodOptional,...ir(t)});var an=class extends or{_parse(e){return this._getType(e)===Nt.null?Yt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};an.create=(e,t)=>new an({innerType:e,typeName:pn.ZodNullable,...ir(t)});var sn=class extends or{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;return t.parsedType===Nt.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};sn.create=(e,t)=>new sn({innerType:e,typeName:pn.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...ir(t)});var on=class extends or{_parse(e){let{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return er(n)?n.then((e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new $t(r.common.issues)},input:r.data})}))):{status:"valid",value:"valid"===n.status?n.value:this._def.catchValue({get error(){return new $t(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};on.create=(e,t)=>new on({innerType:e,typeName:pn.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...ir(t)});var un=class extends or{_parse(e){if(this._getType(e)!==Nt.nan){let t=this._getOrReturnCtx(e);return zt(t,{code:Lt.invalid_type,expected:Nt.nan,received:t.parsedType}),Vt}return{status:"valid",value:e.data}}};un.create=e=>new un({typeName:pn.ZodNaN,...ir(e)});var cn=Symbol("zod_brand"),ln=class extends or{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}},hn=class e extends or{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return"aborted"===e.status?Vt:"dirty"===e.status?(t.dirty(),Wt(e.value)):this._def.out._parseAsync({data:e.value,path:r.path,parent:r})})();{let e=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return"aborted"===e.status?Vt:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:r.path,parent:r})}}static create(t,r){return new e({in:t,out:r,typeName:pn.ZodPipeline})}},dn=class extends or{_parse(e){let t=this._def.innerType._parse(e);return Xt(t)&&(t.value=Object.freeze(t.value)),t}unwrap(){return this._def.innerType}};function fn(e,t={},r){return e?Ur.create().superRefine(((n,a)=>{var i,s;if(!e(n)){let e="function"==typeof t?t(n):"string"==typeof t?{message:t}:t,o=null===(s=null!==(i=e.fatal)&&void 0!==i?i:r)||void 0===s||s,u="string"==typeof e?{message:e}:e;a.addIssue({code:"custom",...u,fatal:o})}})):Ur.create()}dn.create=(e,t)=>new dn({innerType:e,typeName:pn.ZodReadonly,...ir(t)});var pn,gn={object:Mr.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"}(pn||(pn={}));var yn=kr.create,mn=xr.create,vn=un.create,wn=Sr.create,bn=Or.create,_n=Cr.create,Tn=Rr.create,En=Ir.create,kn=Br.create,An=Ur.create,xn=jr.create,Sn=Nr.create,On=Pr.create,Cn=Lr.create,Rn=Mr.create,In=Mr.strictCreate,Bn=Zr.create,Un=Fr.create,jn=Kr.create,Nn=qr.create,Pn=Hr.create,Ln=Gr.create,$n=Vr.create,Mn=Wr.create,Zn=Yr.create,Dn=Jr.create,Fn=Xr.create,zn=en.create,Kn=tn.create,qn=rn.create,Hn=nn.create,Gn=an.create,Vn=rn.createWithPreprocess,Wn=hn.create,Yn={string:e=>kr.create({...e,coerce:!0}),number:e=>xr.create({...e,coerce:!0}),boolean:e=>Or.create({...e,coerce:!0}),bigint:e=>Sr.create({...e,coerce:!0}),date:e=>Cr.create({...e,coerce:!0})},Jn=Vt,Qn=Object.freeze({__proto__:null,defaultErrorMap:Mt,setErrorMap:function(e){Zt=e},getErrorMap:Dt,makeIssue:Ft,EMPTY_PATH:[],addIssueToContext:zt,ParseStatus:Gt,INVALID:Vt,DIRTY:Wt,OK:Yt,isAborted:Jt,isDirty:Qt,isValid:Xt,isAsync:er,get util(){return Et},get objectUtil(){return kt},ZodParsedType:Nt,getParsedType:Pt,ZodType:or,datetimeRegex:Tr,ZodString:kr,ZodNumber:xr,ZodBigInt:Sr,ZodBoolean:Or,ZodDate:Cr,ZodSymbol:Rr,ZodUndefined:Ir,ZodNull:Br,ZodAny:Ur,ZodUnknown:jr,ZodNever:Nr,ZodVoid:Pr,ZodArray:Lr,ZodObject:Mr,ZodUnion:Zr,ZodDiscriminatedUnion:Fr,ZodIntersection:Kr,ZodTuple:qr,ZodRecord:Hr,ZodMap:Gr,ZodSet:Vr,ZodFunction:Wr,ZodLazy:Yr,ZodLiteral:Jr,ZodEnum:Xr,ZodNativeEnum:en,ZodPromise:tn,ZodEffects:rn,ZodTransformer:rn,ZodOptional:nn,ZodNullable:an,ZodDefault:sn,ZodCatch:on,ZodNaN:un,BRAND:cn,ZodBranded:ln,ZodPipeline:hn,ZodReadonly:dn,custom:fn,Schema:or,ZodSchema:or,late:gn,get ZodFirstPartyTypeKind(){return pn},coerce:Yn,any:An,array:Cn,bigint:wn,boolean:bn,date:_n,discriminatedUnion:Un,effect:qn,enum:Fn,function:Mn,instanceof:(e,t={message:`Input not instance of ${e.name}`})=>fn((t=>t instanceof e),t),intersection:jn,lazy:Zn,literal:Dn,map:Ln,nan:vn,nativeEnum:zn,never:Sn,null:kn,nullable:Gn,number:mn,object:Rn,oboolean:()=>bn().optional(),onumber:()=>mn().optional(),optional:Hn,ostring:()=>yn().optional(),pipeline:Wn,preprocess:Vn,promise:Kn,record:Pn,set:$n,strictObject:In,string:yn,symbol:Tn,transformer:qn,tuple:Nn,undefined:En,union:Bn,unknown:xn,void:On,NEVER:Jn,ZodIssueCode:Lt,quotelessJson:e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),ZodError:$t}),Xn=Qn.object({url:Qn.string(),address:Qn.string()}),ea=Qn.object({url:Qn.string(),address:Qn.string(),ttl:Qn.coerce.number()}),ta=Qn.function().args(Qn.string(),Qn.string()).returns(Qn.promise(Qn.string())),ra=Qn.function().args(Qn.string()).returns(Qn.promise(Xn.nullish())),na=Qn.function().args(Qn.string(),Xn,Qn.number()).returns(Qn.promise(Qn.any())),aa=Qn.function().args(Qn.string()).returns(Qn.promise(ea.nullish())),ia=Qn.function().args(Qn.string(),Qn.string(),Qn.number()).returns(Qn.promise(Qn.any())),sa=Qn.function().args(Qn.string()).returns(Qn.promise(ea)),oa=sa;function ua({cacheSize:e=100,followRedirects:t=!1,GRAPHQL_URL:r="https://arweave.net/graphql",GRAPHQL_MAX_RETRIES:n=0,GRAPHQL_RETRY_BACKOFF:a=300}={}){let i=function({size:e}){return new Ct({max:e,maxSize:5e6,sizeCalculation:e=>JSON.stringify(e).length,allowStale:!0})}({size:e}),s=yt({fetch,GRAPHQL_URL:r,GRAPHQL_MAX_RETRIES:n,GRAPHQL_RETRY_BACKOFF:a}),o={getByProcess:Rt({cache:i}),getByOwner:Bt({cache:i}),setByProcess:It({cache:i}),setByOwner:Ut({cache:i})},u=function({loadProcessScheduler:e,loadScheduler:t,cache:r,followRedirects:n,checkForRedirect:a}){e=oa.implement(e),t=sa.implement(t),a=ta.implement(a);let i=ra.implement(r.getByProcess),s=aa.implement(r.getByOwner),o=na.implement(r.setByProcess),u=ia.implement(r.setByOwner);return(r,c)=>i(r).then((async i=>i||Promise.resolve().then((async()=>c?await s(c)||t(c).then((e=>(u(e.address,e.url,e.ttl),e))):e(r))).then((async e=>{let t=e.url;n&&(t=await a(e.url,r));let i={url:lt(t),address:e.address};return await o(r,i,e.ttl),i}))))}({loadProcessScheduler:gt({fetch,GRAPHQL_URL:r,GRAPHQL_MAX_RETRIES:n,GRAPHQL_RETRY_BACKOFF:a}),loadScheduler:s,cache:o,followRedirects:t,checkForRedirect:jt({fetch})}),c=function({loadScheduler:e,cache:t}){e=sa.implement(e);let r=aa.implement(t.getByOwner),n=ia.implement(t.setByOwner);return t=>r(t).then((r=>!!r||e(t).then((e=>n(t,e.url,e.ttl))).then((()=>!0)).catch((e=>{if(e instanceof ot)return!1;throw e}))))}({loadScheduler:s,cache:o}),l=function({loadScheduler:e,cache:t}){e=sa.implement(e);let r=aa.implement(t.getByOwner),n=ia.implement(t.setByOwner);return t=>r(t).then((r=>r?{url:r.url}:e(t).then((e=>n(t,e.url,e.ttl).then((()=>({url:lt(e.url)}))))).catch((e=>{if(!(e instanceof ot))throw e}))))}({loadScheduler:s,cache:o});return{locate:u,validate:c,raw:l}}var ca=globalThis.GRAPHQL_URL||void 0,la=globalThis.SCHEDULER_UTILS_CACHE_SIZE||void 0,ha="true"===globalThis.SCHEDULER_UTILS_FOLLOW_REDIRECTS||void 0,da=globalThis.GRAPHQL_MAX_RETRIES||void 0,fa=globalThis.GRAPHQL_RETRY_BACKOFF||void 0,{locate:pa,validate:ga,raw:ya}=ua({GRAPHQL_URL:ca,cacheSize:la,followRedirects:ha,GRAPHQL_MAX_RETRIES:da,GRAPHQL_RETRY_BACKOFF:fa}),ma=e=>({fork:e,toPromise:()=>new Promise(((t,r)=>e(r,t))),map:t=>ma(((r,n)=>e(r,(e=>n(t(e)))))),bimap:(t,r)=>ma(((n,a)=>e((e=>n(t(e))),(e=>a(r(e)))))),chain:t=>ma(((r,n)=>e(r,(e=>t(e).fork(r,n))))),bichain:(t,r)=>ma(((n,a)=>e((e=>t(e).fork(n,a)),(e=>r(e).fork(n,a))))),fold:(t,r)=>ma(((n,a)=>e((e=>t(e).fork(n,a)),(e=>r(e).fork(n,a)))))}),va=e=>ma(((t,r)=>r(e))),wa=e=>ma(((t,r)=>r(e))),ba=e=>ma(((t,r)=>t(e))),_a=e=>(...t)=>ma(((r,n)=>e(...t).then(n).catch(r)));function Ta({fetch:e,MU_URL:t,logger:r}){const n=r.child("deployMessage");return r=>va(r).chain(_a((({processId:e,data:t,tags:r,anchor:n,signer:a})=>a({data:t,tags:r,target:e,anchor:n})))).chain((r=>va(r).chain(_a((async r=>e(t,{method:"POST",headers:{"Content-Type":"application/octet-stream",Accept:"application/json"},redirect:"follow",body:r.raw})))).bichain((e=>ba(new Error(`Error while communicating with MU: ${JSON.stringify(e)}`))),_a((async e=>{if(e.ok)return e.json();throw new Error(`${e.status}: ${await e.text()}`)}))).bimap(n.tap("Error encountered when writing message via MU"),n.tap("Successfully wrote message via MU")).map((e=>({res:e,messageId:r.id}))))).toPromise()}function Ea({fetch:e,MU_URL:t,logger:r}){const n=r.child("deployProcess");return r=>va(r).chain(_a((({data:e,tags:t,signer:r})=>r({data:e,tags:t})))).chain((r=>va(r).chain(_a((async r=>e(t,{method:"POST",headers:{"Content-Type":"application/octet-stream",Accept:"application/json"},redirect:"follow",body:r.raw})))).bichain((e=>ba(new Error(`Error while communicating with MU: ${JSON.stringify(e)}`))),_a((async e=>{if(e.ok)return e.json();throw new Error(`${e.status}: ${await e.text()}`)}))).bimap(n.tap("Error encountered when deploying process via MU"),n.tap("Successfully deployed process via MU")).map((e=>({res:e,processId:r.id}))))).toPromise()}function ka({fetch:e,MU_URL:t,logger:r}){const n=r.child("deployMonitor");return r=>va(r).chain(_a((({processId:e,data:t,tags:r,anchor:n,signer:a})=>a({data:t,tags:r,target:e,anchor:n})))).chain((a=>va(a).chain(_a((async n=>e(t+"/monitor/"+r.processId,{method:"POST",headers:{"Content-Type":"application/octet-stream",Accept:"application/json"},redirect:"follow",body:n.raw})))).bichain((e=>ba(new Error(`Error while communicating with MU: ${JSON.stringify(e)}`))),_a((async e=>{if(e.ok)return{ok:!0};throw new Error(`${e.status}: ${await e.text()}`)}))).bimap(n.tap("Error encountered when subscribing to process via MU"),n.tap("Successfully subscribed to process via MU")).map((e=>({res:e,messageId:a.id}))))).toPromise()}function Aa({fetch:e,MU_URL:t,logger:r}){const n=r.child("deployUnmonitor");return r=>va(r).chain(_a((({processId:e,data:t,tags:r,anchor:n,signer:a})=>a({data:t,tags:r,target:e,anchor:n})))).chain((a=>va(a).chain(_a((async n=>e(t+"/monitor/"+r.processId,{method:"DELETE",headers:{"Content-Type":"application/octet-stream",Accept:"application/json"},redirect:"follow",body:n.raw})))).bichain((e=>ba(new Error(`Error while communicating with MU: ${JSON.stringify(e)}`))),_a((async e=>{if(e.ok)return{ok:!0};throw new Error(`${e.status}: ${await e.text()}`)}))).bimap(n.tap("Error encountered when unsubscribing to process via MU"),n.tap("Successfully unsubscribed to process via MU")).map((e=>({res:e,messageId:a.id}))))).toPromise()}function xa({fetch:e,MU_URL:t,logger:r}){const n=r.child("deployAssign");return r=>va(r).chain(_a((async({process:r,message:n,baseLayer:a,exclude:i})=>e(`${t}?process-id=${r}&assign=${n}${a?"&base-layer":""}${i?"&exclude="+i.join(","):""}`,{method:"POST",headers:{"Content-Type":"application/octet-stream",Accept:"application/json"}})))).bichain((e=>ba(new Error(`Error while communicating with MU: ${JSON.stringify(e)}`))),_a((async e=>{if(e.ok)return e.json();throw new Error(`${e.status}: ${await e.text()}`)}))).bimap(n.tap("Error encountered when writing assignment via MU"),n.tap("Successfully wrote assignment via MU")).map((e=>({res:e,assignmentId:e.id}))).toPromise()}function Sa({fetch:e,CU_URL:t,logger:r}){return n=>va(n).map(r.tap("posting dryrun request to CU")).chain(_a((r=>e(`${t}/dry-run?process-id=${r.Target}`,{method:"POST",headers:{"Content-Type":"application/json"},redirect:"follow",body:JSON.stringify(r)}).then((e=>e.json()))))).toPromise()}function Oa({fetch:e,CU_URL:t,logger:r}){return({id:n,processId:a})=>va(`${t}/result/${n}?process-id=${a}`).map(r.tap("fetching message result from CU")).chain(_a((async t=>e(t,{method:"GET",headers:{Accept:"application/json"},redirect:"follow"}).then((e=>e.json()))))).toPromise()}function Ca({fetch:e,CU_URL:t,logger:r}){return({process:n,from:a,to:i,sort:s,limit:o})=>{const u=new URL(`${t}/results/${n}`),c=new URLSearchParams(u.search);return a&&c.append("from",a),i&&c.append("to",i),s&&c.append("sort",s),o&&c.append("limit",o),u.search=c,va(u.toString()).map(r.tap("fetching message result from CU")).chain(_a((async t=>e(t,{method:"GET",headers:{Accept:"application/json"},redirect:"follow"}).then((e=>e.json()))))).toPromise()}}var Ra,Ia=d(w(),1),Ba=({logger:e,fetch:t,cache:r=Ra})=>async({suUrl:n,processId:a})=>r.has(a)?r.get(a):t(`${n}/processes/${a}`,{method:"GET",redirect:"follow"}).then((async t=>{if(t.ok)return t.json();throw e("Error Encountered when fetching process meta from SU '%s' for process '%s'",n,a),new Error(`Encountered Error fetching scheduled messages from Scheduler Unit: ${t.status}: ${await t.text()}`)})).then((t=>(e("Caching process meta for process '%s'",a),r.set(a,{tags:t.tags}),t))),Ua=function(){return!1},ja=function(){return!0},Na={"@@functional/placeholder":!0};function Pa(e){return null!=e&&"object"==typeof e&&!0===e["@@functional/placeholder"]}function La(e){return function t(r){return 0===arguments.length||Pa(r)?t:e.apply(this,arguments)}}function $a(e){return function t(r,n){switch(arguments.length){case 0:return t;case 1:return Pa(r)?t:La((function(t){return e(r,t)}));default:return Pa(r)&&Pa(n)?t:Pa(r)?La((function(t){return e(t,n)})):Pa(n)?La((function(t){return e(r,t)})):e(r,n)}}}function Ma(e,t){switch(e){case 0:return function(){return t.apply(this,arguments)};case 1:return function(e){return t.apply(this,arguments)};case 2:return function(e,r){return t.apply(this,arguments)};case 3:return function(e,r,n){return t.apply(this,arguments)};case 4:return function(e,r,n,a){return t.apply(this,arguments)};case 5:return function(e,r,n,a,i){return t.apply(this,arguments)};case 6:return function(e,r,n,a,i,s){return t.apply(this,arguments)};case 7:return function(e,r,n,a,i,s,o){return t.apply(this,arguments)};case 8:return function(e,r,n,a,i,s,o,u){return t.apply(this,arguments)};case 9:return function(e,r,n,a,i,s,o,u,c){return t.apply(this,arguments)};case 10:return function(e,r,n,a,i,s,o,u,c,l){return t.apply(this,arguments)};default:throw new Error("First argument to _arity must be a non-negative integer no greater than ten")}}function Za(e,t,r){return function(){for(var n=[],a=0,i=e,s=0,o=!1;s<t.length||a<arguments.length;){var u;s<t.length&&(!Pa(t[s])||a>=arguments.length)?u=t[s]:(u=arguments[a],a+=1),n[s]=u,Pa(u)?o=!0:i-=1,s+=1}return!o&&i<=0?r.apply(this,n):Ma(Math.max(0,i),Za(e,n,r))}}var Da=$a((function(e,t){return 1===e?La(t):Ma(e,Za(e,[],t))}));function Fa(e){return function t(r,n,a){switch(arguments.length){case 0:return t;case 1:return Pa(r)?t:$a((function(t,n){return e(r,t,n)}));case 2:return Pa(r)&&Pa(n)?t:Pa(r)?$a((function(t,r){return e(t,n,r)})):Pa(n)?$a((function(t,n){return e(r,t,n)})):La((function(t){return e(r,n,t)}));default:return Pa(r)&&Pa(n)&&Pa(a)?t:Pa(r)&&Pa(n)?$a((function(t,r){return e(t,r,a)})):Pa(r)&&Pa(a)?$a((function(t,r){return e(t,n,r)})):Pa(n)&&Pa(a)?$a((function(t,n){return e(r,t,n)})):Pa(r)?La((function(t){return e(t,n,a)})):Pa(n)?La((function(t){return e(r,t,a)})):Pa(a)?La((function(t){return e(r,n,t)})):e(r,n,a)}}}var za=Array.isArray||function(e){return null!=e&&e.length>=0&&"[object Array]"===Object.prototype.toString.call(e)};function Ka(e,t,r){return function(){if(0===arguments.length)return r();var n=arguments[arguments.length-1];if(!za(n)){for(var a=0;a<e.length;){if("function"==typeof n[e[a]])return n[e[a]].apply(n,Array.prototype.slice.call(arguments,0,-1));a+=1}if(function(e){return null!=e&&"function"==typeof e["@@transducer/step"]}(n))return t.apply(null,Array.prototype.slice.call(arguments,0,-1))(n)}return r.apply(this,arguments)}}var qa=function(){return this.xf["@@transducer/init"]()},Ha=function(e){return this.xf["@@transducer/result"](e)};function Ga(e){for(var t,r=[];!(t=e.next()).done;)r.push(t.value);return r}function Va(e,t,r){for(var n=0,a=r.length;n<a;){if(e(t,r[n]))return!0;n+=1}return!1}function Wa(e,t){return Object.prototype.hasOwnProperty.call(t,e)}var Ya="function"==typeof Object.is?Object.is:function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t},Ja=Object.prototype.toString,Qa=function(){return"[object Arguments]"===Ja.call(arguments)?function(e){return"[object Arguments]"===Ja.call(e)}:function(e){return Wa("callee",e)}}(),Xa=!{toString:null}.propertyIsEnumerable("toString"),ei=["constructor","valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],ti=function(){return arguments.propertyIsEnumerable("length")}(),ri=function(e,t){for(var r=0;r<e.length;){if(e[r]===t)return!0;r+=1}return!1},ni="function"!=typeof Object.keys||ti?La((function(e){if(Object(e)!==e)return[];var t,r,n=[],a=ti&&Qa(e);for(t in e)!Wa(t,e)||a&&"length"===t||(n[n.length]=t);if(Xa)for(r=ei.length-1;r>=0;)Wa(t=ei[r],e)&&!ri(n,t)&&(n[n.length]=t),r-=1;return n})):La((function(e){return Object(e)!==e?[]:Object.keys(e)})),ai=La((function(e){return null===e?"Null":void 0===e?"Undefined":Object.prototype.toString.call(e).slice(8,-1)}));function ii(e,t,r,n){var a=Ga(e);function i(e,t){return si(e,t,r.slice(),n.slice())}return!Va((function(e,t){return!Va(i,t,e)}),Ga(t),a)}function si(e,t,r,n){if(Ya(e,t))return!0;var a,i,s=ai(e);if(s!==ai(t))return!1;if("function"==typeof e["fantasy-land/equals"]||"function"==typeof t["fantasy-land/equals"])return"function"==typeof e["fantasy-land/equals"]&&e["fantasy-land/equals"](t)&&"function"==typeof t["fantasy-land/equals"]&&t["fantasy-land/equals"](e);if("function"==typeof e.equals||"function"==typeof t.equals)return"function"==typeof e.equals&&e.equals(t)&&"function"==typeof t.equals&&t.equals(e);switch(s){case"Arguments":case"Array":case"Object":if("function"==typeof e.constructor&&"Promise"===(a=e.constructor,null==(i=String(a).match(/^function (\w*)/))?"":i[1]))return e===t;break;case"Boolean":case"Number":case"String":if(typeof e!=typeof t||!Ya(e.valueOf(),t.valueOf()))return!1;break;case"Date":if(!Ya(e.valueOf(),t.valueOf()))return!1;break;case"Error":return e.name===t.name&&e.message===t.message;case"RegExp":if(e.source!==t.source||e.global!==t.global||e.ignoreCase!==t.ignoreCase||e.multiline!==t.multiline||e.sticky!==t.sticky||e.unicode!==t.unicode)return!1}for(var o=r.length-1;o>=0;){if(r[o]===e)return n[o]===t;o-=1}switch(s){case"Map":return e.size===t.size&&ii(e.entries(),t.entries(),r.concat([e]),n.concat([t]));case"Set":return e.size===t.size&&ii(e.values(),t.values(),r.concat([e]),n.concat([t]));case"Arguments":case"Array":case"Object":case"Boolean":case"Number":case"String":case"Date":case"Error":case"RegExp":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"ArrayBuffer":break;default:return!1}var u=ni(e);if(u.length!==ni(t).length)return!1;var c=r.concat([e]),l=n.concat([t]);for(o=u.length-1;o>=0;){var h=u[o];if(!Wa(h,t)||!si(t[h],e[h],c,l))return!1;o-=1}return!0}var oi=$a((function(e,t){return si(e,t,[],[])}));function ui(e,t){return function(e,t,r){var n,a;if("function"==typeof e.indexOf)switch(typeof t){case"number":if(0===t){for(n=1/t;r<e.length;){if(0===(a=e[r])&&1/a===n)return r;r+=1}return-1}if(t!=t){for(;r<e.length;){if("number"==typeof(a=e[r])&&a!=a)return r;r+=1}return-1}return e.indexOf(t,r);case"string":case"boolean":case"function":case"undefined":return e.indexOf(t,r);case"object":if(null===t)return e.indexOf(t,r)}for(;r<e.length;){if(oi(e[r],t))return r;r+=1}return-1}(t,e,0)>=0}function ci(e,t){for(var r=0,n=t.length,a=Array(n);r<n;)a[r]=e(t[r]),r+=1;return a}function li(e){return'"'+e.replace(/\\/g,"\\\\").replace(/[\b]/g,"\\b").replace(/\f/g,"\\f").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t").replace(/\v/g,"\\v").replace(/\0/g,"\\0").replace(/"/g,'\\"')+'"'}var hi=function(e){return(e<10?"0":"")+e},di="function"==typeof Date.prototype.toISOString?function(e){return e.toISOString()}:function(e){return e.getUTCFullYear()+"-"+hi(e.getUTCMonth()+1)+"-"+hi(e.getUTCDate())+"T"+hi(e.getUTCHours())+":"+hi(e.getUTCMinutes())+":"+hi(e.getUTCSeconds())+"."+(e.getUTCMilliseconds()/1e3).toFixed(3).slice(2,5)+"Z"};function fi(e,t,r){for(var n=0,a=r.length;n<a;)t=e(t,r[n]),n+=1;return t}var pi=function(){function e(e,t){this.xf=t,this.f=e}return e.prototype["@@transducer/init"]=qa,e.prototype["@@transducer/result"]=Ha,e.prototype["@@transducer/step"]=function(e,t){return this.f(t)?this.xf["@@transducer/step"](e,t):e},e}();function gi(e){return function(t){return new pi(e,t)}}var yi=$a(Ka(["fantasy-land/filter","filter"],gi,(function(e,t){return r=t,"[object Object]"===Object.prototype.toString.call(r)?fi((function(r,n){return e(t[n])&&(r[n]=t[n]),r}),{},ni(t)):function(e,t){for(var r=0,n=t.length,a=[];r<n;)e(t[r])&&(a[a.length]=t[r]),r+=1;return a}(e,t);var r}))),mi=$a((function(e,t){return yi((r=e,function(){return!r.apply(this,arguments)}),t);var r}));function vi(e,t){var r=function(r){var n=t.concat([e]);return ui(r,n)?"<Circular>":vi(r,n)},n=function(e,t){return ci((function(t){return li(t)+": "+r(e[t])}),t.slice().sort())};switch(Object.prototype.toString.call(e)){case"[object Arguments]":return"(function() { return arguments; }("+ci(r,e).join(", ")+"))";case"[object Array]":return"["+ci(r,e).concat(n(e,mi((function(e){return/^\d+$/.test(e)}),ni(e)))).join(", ")+"]";case"[object Boolean]":return"object"==typeof e?"new Boolean("+r(e.valueOf())+")":e.toString();case"[object Date]":return"new Date("+(isNaN(e.valueOf())?r(NaN):li(di(e)))+")";case"[object Map]":return"new Map("+r(Array.from(e))+")";case"[object Null]":return"null";case"[object Number]":return"object"==typeof e?"new Number("+r(e.valueOf())+")":1/e==-1/0?"-0":e.toString(10);case"[object Set]":return"new Set("+r(Array.from(e).sort())+")";case"[object String]":return"object"==typeof e?"new String("+r(e.valueOf())+")":li(e);case"[object Undefined]":return"undefined";default:if("function"==typeof e.toString){var a=e.toString();if("[object Object]"!==a)return a}return"{"+n(e,ni(e)).join(", ")+"}"}}var wi=La((function(e){return vi(e,[])})),bi=$a((function(e,t){if(e===t)return t;function r(e,t){if(e>t!=t>e)return t>e?t:e}var n=r(e,t);if(void 0!==n)return n;var a=r(typeof e,typeof t);if(void 0!==a)return a===typeof e?e:t;var i=wi(e),s=r(i,wi(t));return void 0!==s&&s===i?e:t})),_i=function(){function e(e,t){this.xf=t,this.f=e}return e.prototype["@@transducer/init"]=qa,e.prototype["@@transducer/result"]=Ha,e.prototype["@@transducer/step"]=function(e,t){return this.xf["@@transducer/step"](e,this.f(t))},e}(),Ti=function(e){return function(t){return new _i(e,t)}},Ei=$a(Ka(["fantasy-land/map","map"],Ti,(function(e,t){switch(Object.prototype.toString.call(t)){case"[object Function]":return Da(t.length,(function(){return e.call(this,t.apply(this,arguments))}));case"[object Object]":return fi((function(r,n){return r[n]=e(t[n]),r}),{},ni(t));default:return ci(e,t)}}))),ki=Number.isInteger||function(e){return(0|e)===e};function Ai(e){return"[object String]"===Object.prototype.toString.call(e)}function xi(e,t){var r=e<0?t.length+e:e;return Ai(t)?t.charAt(r):t[r]}var Si=$a((function(e,t){if(null!=t)return ki(e)?xi(e,t):t[e]})),Oi=$a((function(e,t){return Ei(Si(e),t)})),Ci=La((function(e){return!!za(e)||!!e&&"object"==typeof e&&!Ai(e)&&(0===e.length||e.length>0&&e.hasOwnProperty(0)&&e.hasOwnProperty(e.length-1))})),Ri="undefined"!=typeof Symbol?Symbol.iterator:"@@iterator";function Ii(e,t,r){return function(n,a,i){if(Ci(i))return e(n,a,i);if(null==i)return a;if("function"==typeof i["fantasy-land/reduce"])return t(n,a,i,"fantasy-land/reduce");if(null!=i[Ri])return r(n,a,i[Ri]());if("function"==typeof i.next)return r(n,a,i);if("function"==typeof i.reduce)return t(n,a,i,"reduce");throw new TypeError("reduce: list must be array or iterable")}}function Bi(e,t,r){for(var n=0,a=r.length;n<a;){if((t=e["@@transducer/step"](t,r[n]))&&t["@@transducer/reduced"]){t=t["@@transducer/value"];break}n+=1}return e["@@transducer/result"](t)}var Ui=$a((function(e,t){return Ma(e.length,(function(){return e.apply(t,arguments)}))}));function ji(e,t,r){for(var n=r.next();!n.done;){if((t=e["@@transducer/step"](t,n.value))&&t["@@transducer/reduced"]){t=t["@@transducer/value"];break}n=r.next()}return e["@@transducer/result"](t)}function Ni(e,t,r,n){return e["@@transducer/result"](r[n](Ui(e["@@transducer/step"],e),t))}var Pi=Ii(Bi,Ni,ji),Li=function(){function e(e){this.f=e}return e.prototype["@@transducer/init"]=function(){throw new Error("init not implemented on XWrap")},e.prototype["@@transducer/result"]=function(e){return e},e.prototype["@@transducer/step"]=function(e,t){return this.f(e,t)},e}(),$i=Fa((function(e,t,r){return Pi("function"==typeof e?new Li(e):e,t,r)})),Mi=La((function(e){return Da($i(bi,0,Oi("length",e)),(function(){for(var t=0,r=e.length;t<r;){if(!e[t].apply(this,arguments))return!1;t+=1}return!0}))})),Zi=La((function(e){return function(){return e}})),Di=$a((function(e,t){return function(e,t){var r;t=t||[];var n=(e=e||[]).length,a=t.length,i=[];for(r=0;r<n;)i[i.length]=e[r],r+=1;for(r=0;r<a;)i[i.length]=t[r],r+=1;return i}(t,[e])})),Fi=La((function(e){return null==e})),zi=Fa((function e(t,r,n){if(0===t.length)return r;var a=t[0];if(t.length>1){var i=!Fi(n)&&Wa(a,n)&&"object"==typeof n[a]?n[a]:ki(t[1])?[]:{};r=e(Array.prototype.slice.call(t,1),r,i)}return function(e,t,r){if(ki(e)&&za(r)){var n=[].concat(r);return n[e]=t,n}var a={};for(var i in r)a[i]=r[i];return a[e]=t,a}(a,r,n)})),Ki=Fa((function(e,t,r){return zi([e],t,r)}));function qi(e){var t=Object.prototype.toString.call(e);return"[object Function]"===t||"[object AsyncFunction]"===t||"[object GeneratorFunction]"===t||"[object AsyncGeneratorFunction]"===t}var Hi="@@transducer/init",Gi="@@transducer/step",Vi="@@transducer/result",Wi=function(){function e(e){this.xf=e}return e.prototype[Hi]=qa,e.prototype[Vi]=Ha,e.prototype[Gi]=function(e,t){var r=this.xf[Gi](e,t);return r["@@transducer/reduced"]?{"@@transducer/value":r,"@@transducer/reduced":!0}:r},e}(),Yi=function(){function e(e){this.xf=new Wi(e)}return e.prototype[Hi]=qa,e.prototype[Vi]=Ha,e.prototype[Gi]=function(e,t){return Ci(t)?Pi(this.xf,e,t):Bi(this.xf,e,[t])},e}();function Ji(e){return function(t){return Ti(e)(function(e){return new Yi(e)}(t))}}var Qi=$a(Ka(["fantasy-land/chain","chain"],Ji,(function(e,t){return"function"==typeof t?function(r){return e(t(r))(r)}:function(e){for(var t,r,n,a=[],i=0,s=e.length;i<s;){if(Ci(e[i]))for(n=0,r=(t=e[i]).length;n<r;)a[a.length]=t[n],n+=1;else a[a.length]=e[i];i+=1}return a}(Ei(e,t))})));function Xi(e,t){return function(){return t.call(this,e.apply(this,arguments))}}function es(e,t){return function(){var r=arguments.length;if(0===r)return t();var n=arguments[r-1];return za(n)||"function"!=typeof n[e]?t.apply(this,arguments):n[e].apply(n,Array.prototype.slice.call(arguments,0,r-1))}}var ts=La(es("tail",Fa(es("slice",(function(e,t,r){return Array.prototype.slice.call(r,e,t)})))(1,1/0)));function rs(){if(0===arguments.length)throw new Error("pipe requires at least one argument");return Ma(arguments[0].length,$i(Xi,arguments[0],ts(arguments)))}function ns(e){return e}var as=La(ns),is=$a((function(e,t){if(za(e)){if(za(t))return e.concat(t);throw new TypeError(wi(t)+" is not an array")}if(Ai(e)){if(Ai(t))return e+t;throw new TypeError(wi(t)+" is not a string")}if(null!=e&&qi(e["fantasy-land/concat"]))return e["fantasy-land/concat"](t);if(null!=e&&qi(e.concat))return e.concat(t);throw new TypeError(wi(e)+' does not have a method named "concat" or "fantasy-land/concat"')})),ss=La((function(e){return Ma($i(bi,0,Ei((function(e){return e[0].length}),e)),(function(){for(var t=0;t<e.length;){if(e[t][0].apply(this,arguments))return e[t][1].apply(this,arguments);t+=1}}))})),os=$a((function(e,t){return null==t||t!=t?e:t})),us=$a((function(e,t){if(0===e.length||Fi(t))return!1;for(var r=t,n=0;n<e.length;){if(Fi(r)||!Wa(e[n],r))return!1;r=r[e[n]],n+=1}return!0})),cs=$a((function(e,t){return us([e],t)})),ls=Fa((function(e,t,r){return Da(Math.max(e.length,t.length,r.length),(function(){return e.apply(this,arguments)?t.apply(this,arguments):r.apply(this,arguments)}))})),hs=$a(ui),ds=$a((function(e,t){return Da(e+1,(function(){var r=arguments[e];if(null!=r&&qi(r[t]))return r[t].apply(r,Array.prototype.slice.call(arguments,0,e));throw new TypeError(wi(r)+' does not have a method named "'+t+'"')}))})),fs=$a((function(e,t){return t instanceof e||null!=t&&(t.constructor===e||"Object"===e.name&&"object"==typeof t)})),ps=La((function(e){return!Fi(e)})),gs=ds(1,"join");function ys(e,t){for(var r=t,n=0;n<e.length;n+=1){if(null==r)return;var a=e[n];r=ki(a)?xi(a,r):r[a]}return r}var ms=$a(ys),vs=Fa((function(e,t,r){return oi(e,Si(t,r))})),ws=Fa((function(e,t,r){return os(e,Si(t,r))})),bs=function(){function e(e,t){this.xf=t,this.f=e}return e.prototype["@@transducer/init"]=qa,e.prototype["@@transducer/result"]=Ha,e.prototype["@@transducer/step"]=function(e,t){return this.f(t),this.xf["@@transducer/step"](e,t)},e}();function _s(e){return function(t){return new bs(e,t)}}var Ts,Es,ks,As=$a(Ka([],_s,(function(e,t){return e(t),t})));(Es=Ts||(Ts={})).assertEqual=e=>e,Es.assertIs=function(e){},Es.assertNever=function(e){throw new Error},Es.arrayToEnum=e=>{const t={};for(const r of e)t[r]=r;return t},Es.getValidEnumValues=e=>{const t=Es.objectKeys(e).filter((t=>"number"!=typeof e[e[t]])),r={};for(const n of t)r[n]=e[n];return Es.objectValues(r)},Es.objectValues=e=>Es.objectKeys(e).map((function(t){return e[t]})),Es.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{const t=[];for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.push(r);return t},Es.find=(e,t)=>{for(const r of e)if(t(r))return r},Es.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&isFinite(e)&&Math.floor(e)===e,Es.joinValues=function(e,t=" | "){return e.map((e=>"string"==typeof e?`'${e}'`:e)).join(t)},Es.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t,(ks||(ks={})).mergeShapes=(e,t)=>({...e,...t});var xs=Ts.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ss=e=>{switch(typeof e){case"undefined":return xs.undefined;case"string":return xs.string;case"number":return isNaN(e)?xs.nan:xs.number;case"boolean":return xs.boolean;case"function":return xs.function;case"bigint":return xs.bigint;case"symbol":return xs.symbol;case"object":return Array.isArray(e)?xs.array:null===e?xs.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?xs.promise:"undefined"!=typeof Map&&e instanceof Map?xs.map:"undefined"!=typeof Set&&e instanceof Set?xs.set:"undefined"!=typeof Date&&e instanceof Date?xs.date:xs.object;default:return xs.unknown}},Os=Ts.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"]),Cs=class e extends Error{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}get errors(){return this.issues}format(e){const t=e||function(e){return e.message},r={_errors:[]},n=e=>{for(const a of e.issues)if("invalid_union"===a.code)a.unionErrors.map(n);else if("invalid_return_type"===a.code)n(a.returnTypeError);else if("invalid_arguments"===a.code)n(a.argumentsError);else if(0===a.path.length)r._errors.push(t(a));else{let e=r,n=0;for(;n<a.path.length;){const r=a.path[n];n===a.path.length-1?(e[r]=e[r]||{_errors:[]},e[r]._errors.push(t(a))):e[r]=e[r]||{_errors:[]},e=e[r],n++}}};return n(this),r}static assert(t){if(!(t instanceof e))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Ts.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){const t={},r=[];for(const n of this.issues)n.path.length>0?(t[n.path[0]]=t[n.path[0]]||[],t[n.path[0]].push(e(n))):r.push(e(n));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}};Cs.create=e=>new Cs(e);var Rs=(e,t)=>{let r;switch(e.code){case Os.invalid_type:r=e.received===xs.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case Os.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,Ts.jsonStringifyReplacer)}`;break;case Os.unrecognized_keys:r=`Unrecognized key(s) in object: ${Ts.joinValues(e.keys,", ")}`;break;case Os.invalid_union:r="Invalid input";break;case Os.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Ts.joinValues(e.options)}`;break;case Os.invalid_enum_value:r=`Invalid enum value. Expected ${Ts.joinValues(e.options)}, received '${e.received}'`;break;case Os.invalid_arguments:r="Invalid function arguments";break;case Os.invalid_return_type:r="Invalid function return type";break;case Os.invalid_date:r="Invalid date";break;case Os.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:Ts.assertNever(e.validation):r="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case Os.too_small:r="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?`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 Os.too_big:r="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 Os.custom:r="Invalid input";break;case Os.invalid_intersection_types:r="Intersection results could not be merged";break;case Os.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case Os.not_finite:r="Number must be finite";break;default:r=t.defaultError,Ts.assertNever(e)}return{message:r}},Is=Rs;function Bs(){return Is}var Us=e=>{const{data:t,path:r,errorMaps:n,issueData:a}=e,i=[...r,...a.path||[]],s={...a,path:i};if(void 0!==a.message)return{...a,path:i,message:a.message};let o="";const u=n.filter((e=>!!e)).slice().reverse();for(const e of u)o=e(s,{data:t,defaultError:o}).message;return{...a,path:i,message:o}};function js(e,t){const r=Bs(),n=Us({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===Rs?void 0:Rs].filter((e=>!!e))});e.common.issues.push(n)}var Ns,Ps,Ls,$s,Ms=class e{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){const r=[];for(const n of t){if("aborted"===n.status)return Zs;"dirty"===n.status&&e.dirty(),r.push(n.value)}return{status:e.value,value:r}}static async mergeObjectAsync(t,r){const n=[];for(const e of r){const t=await e.key,r=await e.value;n.push({key:t,value:r})}return e.mergeObjectSync(t,n)}static mergeObjectSync(e,t){const r={};for(const n of t){const{key:t,value:a}=n;if("aborted"===t.status)return Zs;if("aborted"===a.status)return Zs;"dirty"===t.status&&e.dirty(),"dirty"===a.status&&e.dirty(),"__proto__"===t.value||void 0===a.value&&!n.alwaysSet||(r[t.value]=a.value)}return{status:e.value,value:r}}},Zs=Object.freeze({status:"aborted"}),Ds=e=>({status:"dirty",value:e}),Fs=e=>({status:"valid",value:e}),zs=e=>"aborted"===e.status,Ks=e=>"dirty"===e.status,qs=e=>"valid"===e.status,Hs=e=>"undefined"!=typeof Promise&&e instanceof Promise;function Gs(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)}function Vs(e,t,r,n,a){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!a)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?a.call(e,r):a?a.value=r:t.set(e,r),r}(Ps=Ns||(Ns={})).errToObj=e=>"string"==typeof e?{message:e}:e||{},Ps.toString=e=>"string"==typeof e?e:null==e?void 0:e.message;var Ws=class{constructor(e,t,r,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=n}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Ys=(e,t)=>{if(qs(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 Cs(e.common.issues);return this._error=t,this._error}}};function Js(e){if(!e)return{};const{errorMap:t,invalid_type_error:r,required_error:n,description:a}=e;if(t&&(r||n))throw new Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');return t?{errorMap:t,description:a}:{errorMap:(t,a)=>{var i,s;const{message:o}=e;return"invalid_enum_value"===t.code?{message:null!=o?o:a.defaultError}:void 0===a.data?{message:null!==(i=null!=o?o:n)&&void 0!==i?i:a.defaultError}:"invalid_type"!==t.code?{message:a.defaultError}:{message:null!==(s=null!=o?o:r)&&void 0!==s?s:a.defaultError}},description:a}}var Qs,Xs=class{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)}get description(){return this._def.description}_getType(e){return Ss(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Ss(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Ms,ctx:{common:e.parent.common,data:e.data,parsedType:Ss(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Hs(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 r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){var r;const n={common:{issues:[],async:null!==(r=null==t?void 0:t.async)&&void 0!==r&&r,contextualErrorMap:null==t?void 0:t.errorMap},path:(null==t?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ss(e)},a=this._parseSync({data:e,path:n.path,parent:n});return Ys(n,a)}async parseAsync(e,t){const r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){const r={common:{issues:[],contextualErrorMap:null==t?void 0:t.errorMap,async:!0},path:(null==t?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ss(e)},n=this._parse({data:e,path:r.path,parent:r}),a=await(Hs(n)?n:Promise.resolve(n));return Ys(r,a)}refine(e,t){const r=e=>"string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(e):t;return this._refinement(((t,n)=>{const a=e(t),i=()=>n.addIssue({code:Os.custom,...r(t)});return"undefined"!=typeof Promise&&a instanceof Promise?a.then((e=>!!e||(i(),!1))):!!a||(i(),!1)}))}refinement(e,t){return this._refinement(((r,n)=>!!e(r)||(n.addIssue("function"==typeof t?t(r,n):t),!1)))}_refinement(e){return new Go({schema:this,typeName:au.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Vo.create(this,this._def)}nullable(){return Wo.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Oo.create(this,this._def)}promise(){return Ho.create(this,this._def)}or(e){return Io.create([this,e],this._def)}and(e){return No.create(this,e,this._def)}transform(e){return new Go({...Js(this._def),schema:this,typeName:au.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t="function"==typeof e?e:()=>e;return new Yo({...Js(this._def),innerType:this,defaultValue:t,typeName:au.ZodDefault})}brand(){return new eu({typeName:au.ZodBranded,type:this,...Js(this._def)})}catch(e){const t="function"==typeof e?e:()=>e;return new Jo({...Js(this._def),innerType:this,catchValue:t,typeName:au.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return tu.create(this,e)}readonly(){return ru.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},eo=/^c[^\s-]{8,}$/i,to=/^[0-9a-z]+$/,ro=/^[0-9A-HJKMNP-TV-Z]{26}$/,no=/^[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,ao=/^[a-z0-9_-]{21}$/i,io=/^[-+]?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)?)??$/,so=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,oo=/^(?:(?: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])$/,uo=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,co=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,lo="((\\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])))",ho=new RegExp(`^${lo}$`);function fo(e){let t="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`),t}function po(e){let t=`${lo}T${fo(e)}`;const r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}var go=class e extends Xs{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==xs.string){const t=this._getOrReturnCtx(e);return js(t,{code:Os.invalid_type,expected:xs.string,received:t.parsedType}),Zs}const t=new Ms;let r;for(const i of this._def.checks)if("min"===i.kind)e.data.length<i.value&&(r=this._getOrReturnCtx(e,r),js(r,{code:Os.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),t.dirty());else if("max"===i.kind)e.data.length>i.value&&(r=this._getOrReturnCtx(e,r),js(r,{code:Os.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),t.dirty());else if("length"===i.kind){const n=e.data.length>i.value,a=e.data.length<i.value;(n||a)&&(r=this._getOrReturnCtx(e,r),n?js(r,{code:Os.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&js(r,{code:Os.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),t.dirty())}else if("email"===i.kind)so.test(e.data)||(r=this._getOrReturnCtx(e,r),js(r,{validation:"email",code:Os.invalid_string,message:i.message}),t.dirty());else if("emoji"===i.kind)Qs||(Qs=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Qs.test(e.data)||(r=this._getOrReturnCtx(e,r),js(r,{validation:"emoji",code:Os.invalid_string,message:i.message}),t.dirty());else if("uuid"===i.kind)no.test(e.data)||(r=this._getOrReturnCtx(e,r),js(r,{validation:"uuid",code:Os.invalid_string,message:i.message}),t.dirty());else if("nanoid"===i.kind)ao.test(e.data)||(r=this._getOrReturnCtx(e,r),js(r,{validation:"nanoid",code:Os.invalid_string,message:i.message}),t.dirty());else if("cuid"===i.kind)eo.test(e.data)||(r=this._getOrReturnCtx(e,r),js(r,{validation:"cuid",code:Os.invalid_string,message:i.message}),t.dirty());else if("cuid2"===i.kind)to.test(e.data)||(r=this._getOrReturnCtx(e,r),js(r,{validation:"cuid2",code:Os.invalid_string,message:i.message}),t.dirty());else if("ulid"===i.kind)ro.test(e.data)||(r=this._getOrReturnCtx(e,r),js(r,{validation:"ulid",code:Os.invalid_string,message:i.message}),t.dirty());else if("url"===i.kind)try{new URL(e.data)}catch(n){r=this._getOrReturnCtx(e,r),js(r,{validation:"url",code:Os.invalid_string,message:i.message}),t.dirty()}else"regex"===i.kind?(i.regex.lastIndex=0,i.regex.test(e.data)||(r=this._getOrReturnCtx(e,r),js(r,{validation:"regex",code:Os.invalid_string,message:i.message}),t.dirty())):"trim"===i.kind?e.data=e.data.trim():"includes"===i.kind?e.data.includes(i.value,i.position)||(r=this._getOrReturnCtx(e,r),js(r,{code:Os.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),t.dirty()):"toLowerCase"===i.kind?e.data=e.data.toLowerCase():"toUpperCase"===i.kind?e.data=e.data.toUpperCase():"startsWith"===i.kind?e.data.startsWith(i.value)||(r=this._getOrReturnCtx(e,r),js(r,{code:Os.invalid_string,validation:{startsWith:i.value},message:i.message}),t.dirty()):"endsWith"===i.kind?e.data.endsWith(i.value)||(r=this._getOrReturnCtx(e,r),js(r,{code:Os.invalid_string,validation:{endsWith:i.value},message:i.message}),t.dirty()):"datetime"===i.kind?po(i).test(e.data)||(r=this._getOrReturnCtx(e,r),js(r,{code:Os.invalid_string,validation:"datetime",message:i.message}),t.dirty()):"date"===i.kind?ho.test(e.data)||(r=this._getOrReturnCtx(e,r),js(r,{code:Os.invalid_string,validation:"date",message:i.message}),t.dirty()):"time"===i.kind?new RegExp(`^${fo(i)}$`).test(e.data)||(r=this._getOrReturnCtx(e,r),js(r,{code:Os.invalid_string,validation:"time",message:i.message}),t.dirty()):"duration"===i.kind?io.test(e.data)||(r=this._getOrReturnCtx(e,r),js(r,{validation:"duration",code:Os.invalid_string,message:i.message}),t.dirty()):"ip"===i.kind?(n=e.data,("v4"!==(a=i.version)&&a||!oo.test(n))&&("v6"!==a&&a||!uo.test(n))&&(r=this._getOrReturnCtx(e,r),js(r,{validation:"ip",code:Os.invalid_string,message:i.message}),t.dirty())):"base64"===i.kind?co.test(e.data)||(r=this._getOrReturnCtx(e,r),js(r,{validation:"base64",code:Os.invalid_string,message:i.message}),t.dirty()):Ts.assertNever(i);var n,a;return{status:t.value,value:e.data}}_regex(e,t,r){return this.refinement((t=>e.test(t)),{validation:t,code:Os.invalid_string,...Ns.errToObj(r)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:"email",...Ns.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Ns.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Ns.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Ns.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Ns.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Ns.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Ns.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Ns.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Ns.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Ns.errToObj(e)})}datetime(e){var t,r;return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===(null==e?void 0:e.precision)?null:null==e?void 0:e.precision,offset:null!==(t=null==e?void 0:e.offset)&&void 0!==t&&t,local:null!==(r=null==e?void 0:e.local)&&void 0!==r&&r,...Ns.errToObj(null==e?void 0: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===(null==e?void 0:e.precision)?null:null==e?void 0:e.precision,...Ns.errToObj(null==e?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...Ns.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Ns.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:null==t?void 0:t.position,...Ns.errToObj(null==t?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Ns.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Ns.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Ns.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Ns.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Ns.errToObj(t)})}nonempty(e){return this.min(1,Ns.errToObj(e))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new e({...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 isBase64(){return!!this._def.checks.find((e=>"base64"===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 yo(e,t){const r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,a=r>n?r:n;return parseInt(e.toFixed(a).replace(".",""))%parseInt(t.toFixed(a).replace(".",""))/Math.pow(10,a)}go.create=e=>{var t;return new go({checks:[],typeName:au.ZodString,coerce:null!==(t=null==e?void 0:e.coerce)&&void 0!==t&&t,...Js(e)})};var mo=class e extends Xs{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)!==xs.number){const t=this._getOrReturnCtx(e);return js(t,{code:Os.invalid_type,expected:xs.number,received:t.parsedType}),Zs}let t;const r=new Ms;for(const n of this._def.checks)"int"===n.kind?Ts.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),js(t,{code:Os.invalid_type,expected:"integer",received:"float",message:n.message}),r.dirty()):"min"===n.kind?(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),js(t,{code:Os.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),r.dirty()):"max"===n.kind?(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),js(t,{code:Os.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),r.dirty()):"multipleOf"===n.kind?0!==yo(e.data,n.value)&&(t=this._getOrReturnCtx(e,t),js(t,{code:Os.not_multiple_of,multipleOf:n.value,message:n.message}),r.dirty()):"finite"===n.kind?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),js(t,{code:Os.not_finite,message:n.message}),r.dirty()):Ts.assertNever(n);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Ns.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Ns.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Ns.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Ns.toString(t))}setLimit(t,r,n,a){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:Ns.toString(a)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:"int",message:Ns.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Ns.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Ns.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Ns.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Ns.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Ns.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Ns.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Ns.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Ns.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&&Ts.isInteger(e.value)))}get isFinite(){let e=null,t=null;for(const r of this._def.checks){if("finite"===r.kind||"int"===r.kind||"multipleOf"===r.kind)return!0;"min"===r.kind?(null===t||r.value>t)&&(t=r.value):"max"===r.kind&&(null===e||r.value<e)&&(e=r.value)}return Number.isFinite(t)&&Number.isFinite(e)}};mo.create=e=>new mo({checks:[],typeName:au.ZodNumber,coerce:(null==e?void 0:e.coerce)||!1,...Js(e)});var vo=class e extends Xs{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==xs.bigint){const t=this._getOrReturnCtx(e);return js(t,{code:Os.invalid_type,expected:xs.bigint,received:t.parsedType}),Zs}let t;const r=new Ms;for(const n of this._def.checks)"min"===n.kind?(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),js(t,{code:Os.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),r.dirty()):"max"===n.kind?(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),js(t,{code:Os.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),r.dirty()):"multipleOf"===n.kind?e.data%n.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),js(t,{code:Os.not_multiple_of,multipleOf:n.value,message:n.message}),r.dirty()):Ts.assertNever(n);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Ns.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Ns.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Ns.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Ns.toString(t))}setLimit(t,r,n,a){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:Ns.toString(a)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Ns.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Ns.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Ns.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Ns.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Ns.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}};vo.create=e=>{var t;return new vo({checks:[],typeName:au.ZodBigInt,coerce:null!==(t=null==e?void 0:e.coerce)&&void 0!==t&&t,...Js(e)})};var wo=class extends Xs{_parse(e){if(this._def.coerce&&(e.data=Boolean(e.data)),this._getType(e)!==xs.boolean){const t=this._getOrReturnCtx(e);return js(t,{code:Os.invalid_type,expected:xs.boolean,received:t.parsedType}),Zs}return Fs(e.data)}};wo.create=e=>new wo({typeName:au.ZodBoolean,coerce:(null==e?void 0:e.coerce)||!1,...Js(e)});var bo=class e extends Xs{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==xs.date){const t=this._getOrReturnCtx(e);return js(t,{code:Os.invalid_type,expected:xs.date,received:t.parsedType}),Zs}if(isNaN(e.data.getTime()))return js(this._getOrReturnCtx(e),{code:Os.invalid_date}),Zs;const t=new Ms;let r;for(const n of this._def.checks)"min"===n.kind?e.data.getTime()<n.value&&(r=this._getOrReturnCtx(e,r),js(r,{code:Os.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),t.dirty()):"max"===n.kind?e.data.getTime()>n.value&&(r=this._getOrReturnCtx(e,r),js(r,{code:Os.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),t.dirty()):Ts.assertNever(n);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Ns.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Ns.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}};bo.create=e=>new bo({checks:[],coerce:(null==e?void 0:e.coerce)||!1,typeName:au.ZodDate,...Js(e)});var _o=class extends Xs{_parse(e){if(this._getType(e)!==xs.symbol){const t=this._getOrReturnCtx(e);return js(t,{code:Os.invalid_type,expected:xs.symbol,received:t.parsedType}),Zs}return Fs(e.data)}};_o.create=e=>new _o({typeName:au.ZodSymbol,...Js(e)});var To=class extends Xs{_parse(e){if(this._getType(e)!==xs.undefined){const t=this._getOrReturnCtx(e);return js(t,{code:Os.invalid_type,expected:xs.undefined,received:t.parsedType}),Zs}return Fs(e.data)}};To.create=e=>new To({typeName:au.ZodUndefined,...Js(e)});var Eo=class extends Xs{_parse(e){if(this._getType(e)!==xs.null){const t=this._getOrReturnCtx(e);return js(t,{code:Os.invalid_type,expected:xs.null,received:t.parsedType}),Zs}return Fs(e.data)}};Eo.create=e=>new Eo({typeName:au.ZodNull,...Js(e)});var ko=class extends Xs{constructor(){super(...arguments),this._any=!0}_parse(e){return Fs(e.data)}};ko.create=e=>new ko({typeName:au.ZodAny,...Js(e)});var Ao=class extends Xs{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Fs(e.data)}};Ao.create=e=>new Ao({typeName:au.ZodUnknown,...Js(e)});var xo=class extends Xs{_parse(e){const t=this._getOrReturnCtx(e);return js(t,{code:Os.invalid_type,expected:xs.never,received:t.parsedType}),Zs}};xo.create=e=>new xo({typeName:au.ZodNever,...Js(e)});var So=class extends Xs{_parse(e){if(this._getType(e)!==xs.undefined){const t=this._getOrReturnCtx(e);return js(t,{code:Os.invalid_type,expected:xs.void,received:t.parsedType}),Zs}return Fs(e.data)}};So.create=e=>new So({typeName:au.ZodVoid,...Js(e)});var Oo=class e extends Xs{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),n=this._def;if(t.parsedType!==xs.array)return js(t,{code:Os.invalid_type,expected:xs.array,received:t.parsedType}),Zs;if(null!==n.exactLength){const e=t.data.length>n.exactLength.value,a=t.data.length<n.exactLength.value;(e||a)&&(js(t,{code:e?Os.too_big:Os.too_small,minimum:a?n.exactLength.value:void 0,maximum:e?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),r.dirty())}if(null!==n.minLength&&t.data.length<n.minLength.value&&(js(t,{code:Os.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),r.dirty()),null!==n.maxLength&&t.data.length>n.maxLength.value&&(js(t,{code:Os.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map(((e,r)=>n.type._parseAsync(new Ws(t,e,t.path,r))))).then((e=>Ms.mergeArray(r,e)));const a=[...t.data].map(((e,r)=>n.type._parseSync(new Ws(t,e,t.path,r))));return Ms.mergeArray(r,a)}get element(){return this._def.type}min(t,r){return new e({...this._def,minLength:{value:t,message:Ns.toString(r)}})}max(t,r){return new e({...this._def,maxLength:{value:t,message:Ns.toString(r)}})}length(t,r){return new e({...this._def,exactLength:{value:t,message:Ns.toString(r)}})}nonempty(e){return this.min(1,e)}};function Co(e){if(e instanceof Ro){const t={};for(const r in e.shape){const n=e.shape[r];t[r]=Vo.create(Co(n))}return new Ro({...e._def,shape:()=>t})}return e instanceof Oo?new Oo({...e._def,type:Co(e.element)}):e instanceof Vo?Vo.create(Co(e.unwrap())):e instanceof Wo?Wo.create(Co(e.unwrap())):e instanceof Po?Po.create(e.items.map((e=>Co(e)))):e}Oo.create=(e,t)=>new Oo({type:e,minLength:null,maxLength:null,exactLength:null,typeName:au.ZodArray,...Js(t)});var Ro=class e extends Xs{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=Ts.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==xs.object){const t=this._getOrReturnCtx(e);return js(t,{code:Os.invalid_type,expected:xs.object,received:t.parsedType}),Zs}const{status:t,ctx:r}=this._processInputParams(e),{shape:n,keys:a}=this._getCached(),i=[];if(!(this._def.catchall instanceof xo&&"strip"===this._def.unknownKeys))for(const e in r.data)a.includes(e)||i.push(e);const s=[];for(const e of a){const t=n[e],a=r.data[e];s.push({key:{status:"valid",value:e},value:t._parse(new Ws(r,a,r.path,e)),alwaysSet:e in r.data})}if(this._def.catchall instanceof xo){const e=this._def.unknownKeys;if("passthrough"===e)for(const e of i)s.push({key:{status:"valid",value:e},value:{status:"valid",value:r.data[e]}});else if("strict"===e)i.length>0&&(js(r,{code:Os.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 n=r.data[t];s.push({key:{status:"valid",value:t},value:e._parse(new Ws(r,n,r.path,t)),alwaysSet:t in r.data})}}return r.common.async?Promise.resolve().then((async()=>{const e=[];for(const t of s){const r=await t.key,n=await t.value;e.push({key:r,value:n,alwaysSet:t.alwaysSet})}return e})).then((e=>Ms.mergeObjectSync(t,e))):Ms.mergeObjectSync(t,s)}get shape(){return this._def.shape()}strict(t){return Ns.errToObj,new e({...this._def,unknownKeys:"strict",...void 0!==t?{errorMap:(e,r)=>{var n,a,i,s;const o=null!==(i=null===(a=(n=this._def).errorMap)||void 0===a?void 0:a.call(n,e,r).message)&&void 0!==i?i:r.defaultError;return"unrecognized_keys"===e.code?{message:null!==(s=Ns.errToObj(t).message)&&void 0!==s?s:o}:{message:o}}}:{}})}strip(){return new e({...this._def,unknownKeys:"strip"})}passthrough(){return new e({...this._def,unknownKeys:"passthrough"})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:au.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(t){return new e({...this._def,catchall:t})}pick(t){const r={};return Ts.objectKeys(t).forEach((e=>{t[e]&&this.shape[e]&&(r[e]=this.shape[e])})),new e({...this._def,shape:()=>r})}omit(t){const r={};return Ts.objectKeys(this.shape).forEach((e=>{t[e]||(r[e]=this.shape[e])})),new e({...this._def,shape:()=>r})}deepPartial(){return Co(this)}partial(t){const r={};return Ts.objectKeys(this.shape).forEach((e=>{const n=this.shape[e];t&&!t[e]?r[e]=n:r[e]=n.optional()})),new e({...this._def,shape:()=>r})}required(t){const r={};return Ts.objectKeys(this.shape).forEach((e=>{if(t&&!t[e])r[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof Vo;)t=t._def.innerType;r[e]=t}})),new e({...this._def,shape:()=>r})}keyof(){return zo(Ts.objectKeys(this.shape))}};Ro.create=(e,t)=>new Ro({shape:()=>e,unknownKeys:"strip",catchall:xo.create(),typeName:au.ZodObject,...Js(t)}),Ro.strictCreate=(e,t)=>new Ro({shape:()=>e,unknownKeys:"strict",catchall:xo.create(),typeName:au.ZodObject,...Js(t)}),Ro.lazycreate=(e,t)=>new Ro({shape:e,unknownKeys:"strip",catchall:xo.create(),typeName:au.ZodObject,...Js(t)});var Io=class extends Xs{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.options;if(t.common.async)return Promise.all(r.map((async e=>{const r={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:r}),ctx:r}}))).then((function(e){for(const t of e)if("valid"===t.result.status)return t.result;for(const r of e)if("dirty"===r.result.status)return t.common.issues.push(...r.ctx.common.issues),r.result;const r=e.map((e=>new Cs(e.ctx.common.issues)));return js(t,{code:Os.invalid_union,unionErrors:r}),Zs}));{let e;const n=[];for(const a of r){const r={...t,common:{...t.common,issues:[]},parent:null},i=a._parseSync({data:t.data,path:t.path,parent:r});if("valid"===i.status)return i;"dirty"!==i.status||e||(e={result:i,ctx:r}),r.common.issues.length&&n.push(r.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;const a=n.map((e=>new Cs(e)));return js(t,{code:Os.invalid_union,unionErrors:a}),Zs}}get options(){return this._def.options}};Io.create=(e,t)=>new Io({options:e,typeName:au.ZodUnion,...Js(t)});var Bo=e=>e instanceof Do?Bo(e.schema):e instanceof Go?Bo(e.innerType()):e instanceof Fo?[e.value]:e instanceof Ko?e.options:e instanceof qo?Ts.objectValues(e.enum):e instanceof Yo?Bo(e._def.innerType):e instanceof To?[void 0]:e instanceof Eo?[null]:e instanceof Vo?[void 0,...Bo(e.unwrap())]:e instanceof Wo?[null,...Bo(e.unwrap())]:e instanceof eu||e instanceof ru?Bo(e.unwrap()):e instanceof Jo?Bo(e._def.innerType):[],Uo=class e extends Xs{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==xs.object)return js(t,{code:Os.invalid_type,expected:xs.object,received:t.parsedType}),Zs;const r=this.discriminator,n=t.data[r],a=this.optionsMap.get(n);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(js(t,{code:Os.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),Zs)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,r,n){const a=new Map;for(const e of r){const r=Bo(e.shape[t]);if(!r.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(const n of r){if(a.has(n))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(n)}`);a.set(n,e)}}return new e({typeName:au.ZodDiscriminatedUnion,discriminator:t,options:r,optionsMap:a,...Js(n)})}};function jo(e,t){const r=Ss(e),n=Ss(t);if(e===t)return{valid:!0,data:e};if(r===xs.object&&n===xs.object){const r=Ts.objectKeys(t),n=Ts.objectKeys(e).filter((e=>-1!==r.indexOf(e))),a={...e,...t};for(const r of n){const n=jo(e[r],t[r]);if(!n.valid)return{valid:!1};a[r]=n.data}return{valid:!0,data:a}}if(r===xs.array&&n===xs.array){if(e.length!==t.length)return{valid:!1};const r=[];for(let n=0;n<e.length;n++){const a=jo(e[n],t[n]);if(!a.valid)return{valid:!1};r.push(a.data)}return{valid:!0,data:r}}return r===xs.date&&n===xs.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var No=class extends Xs{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),n=(e,n)=>{if(zs(e)||zs(n))return Zs;const a=jo(e.value,n.value);return a.valid?((Ks(e)||Ks(n))&&t.dirty(),{status:t.value,value:a.data}):(js(r,{code:Os.invalid_intersection_types}),Zs)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then((([e,t])=>n(e,t))):n(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};No.create=(e,t,r)=>new No({left:e,right:t,typeName:au.ZodIntersection,...Js(r)});var Po=class e extends Xs{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==xs.array)return js(r,{code:Os.invalid_type,expected:xs.array,received:r.parsedType}),Zs;if(r.data.length<this._def.items.length)return js(r,{code:Os.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Zs;!this._def.rest&&r.data.length>this._def.items.length&&(js(r,{code:Os.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const n=[...r.data].map(((e,t)=>{const n=this._def.items[t]||this._def.rest;return n?n._parse(new Ws(r,e,r.path,t)):null})).filter((e=>!!e));return r.common.async?Promise.all(n).then((e=>Ms.mergeArray(t,e))):Ms.mergeArray(t,n)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};Po.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Po({items:e,typeName:au.ZodTuple,rest:null,...Js(t)})};var Lo=class e extends Xs{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==xs.object)return js(r,{code:Os.invalid_type,expected:xs.object,received:r.parsedType}),Zs;const n=[],a=this._def.keyType,i=this._def.valueType;for(const e in r.data)n.push({key:a._parse(new Ws(r,e,r.path,e)),value:i._parse(new Ws(r,r.data[e],r.path,e)),alwaysSet:e in r.data});return r.common.async?Ms.mergeObjectAsync(t,n):Ms.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(t,r,n){return new e(r instanceof Xs?{keyType:t,valueType:r,typeName:au.ZodRecord,...Js(n)}:{keyType:go.create(),valueType:t,typeName:au.ZodRecord,...Js(r)})}},$o=class extends Xs{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==xs.map)return js(r,{code:Os.invalid_type,expected:xs.map,received:r.parsedType}),Zs;const n=this._def.keyType,a=this._def.valueType,i=[...r.data.entries()].map((([e,t],i)=>({key:n._parse(new Ws(r,e,r.path,[i,"key"])),value:a._parse(new Ws(r,t,r.path,[i,"value"]))})));if(r.common.async){const e=new Map;return Promise.resolve().then((async()=>{for(const r of i){const n=await r.key,a=await r.value;if("aborted"===n.status||"aborted"===a.status)return Zs;"dirty"!==n.status&&"dirty"!==a.status||t.dirty(),e.set(n.value,a.value)}return{status:t.value,value:e}}))}{const e=new Map;for(const r of i){const n=r.key,a=r.value;if("aborted"===n.status||"aborted"===a.status)return Zs;"dirty"!==n.status&&"dirty"!==a.status||t.dirty(),e.set(n.value,a.value)}return{status:t.value,value:e}}}};$o.create=(e,t,r)=>new $o({valueType:t,keyType:e,typeName:au.ZodMap,...Js(r)});var Mo=class e extends Xs{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==xs.set)return js(r,{code:Os.invalid_type,expected:xs.set,received:r.parsedType}),Zs;const n=this._def;null!==n.minSize&&r.data.size<n.minSize.value&&(js(r,{code:Os.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),null!==n.maxSize&&r.data.size>n.maxSize.value&&(js(r,{code:Os.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());const a=this._def.valueType;function i(e){const r=new Set;for(const n of e){if("aborted"===n.status)return Zs;"dirty"===n.status&&t.dirty(),r.add(n.value)}return{status:t.value,value:r}}const s=[...r.data.values()].map(((e,t)=>a._parse(new Ws(r,e,r.path,t))));return r.common.async?Promise.all(s).then((e=>i(e))):i(s)}min(t,r){return new e({...this._def,minSize:{value:t,message:Ns.toString(r)}})}max(t,r){return new e({...this._def,maxSize:{value:t,message:Ns.toString(r)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Mo.create=(e,t)=>new Mo({valueType:e,minSize:null,maxSize:null,typeName:au.ZodSet,...Js(t)});var Zo=class e extends Xs{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==xs.function)return js(t,{code:Os.invalid_type,expected:xs.function,received:t.parsedType}),Zs;function r(e,r){return Us({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Bs(),Rs].filter((e=>!!e)),issueData:{code:Os.invalid_arguments,argumentsError:r}})}function n(e,r){return Us({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Bs(),Rs].filter((e=>!!e)),issueData:{code:Os.invalid_return_type,returnTypeError:r}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof Ho){const e=this;return Fs((async function(...t){const s=new Cs([]),o=await e._def.args.parseAsync(t,a).catch((e=>{throw s.addIssue(r(t,e)),s})),u=await Reflect.apply(i,this,o),c=await e._def.returns._def.type.parseAsync(u,a).catch((e=>{throw s.addIssue(n(u,e)),s}));return c}))}{const e=this;return Fs((function(...t){const s=e._def.args.safeParse(t,a);if(!s.success)throw new Cs([r(t,s.error)]);const o=Reflect.apply(i,this,s.data),u=e._def.returns.safeParse(o,a);if(!u.success)throw new Cs([n(o,u.error)]);return u.data}))}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:Po.create(t).rest(Ao.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(t,r,n){return new e({args:t||Po.create([]).rest(Ao.create()),returns:r||Ao.create(),typeName:au.ZodFunction,...Js(n)})}},Do=class extends Xs{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})}};Do.create=(e,t)=>new Do({getter:e,typeName:au.ZodLazy,...Js(t)});var Fo=class extends Xs{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return js(t,{received:t.data,code:Os.invalid_literal,expected:this._def.value}),Zs}return{status:"valid",value:e.data}}get value(){return this._def.value}};function zo(e,t){return new Ko({values:e,typeName:au.ZodEnum,...Js(t)})}Fo.create=(e,t)=>new Fo({value:e,typeName:au.ZodLiteral,...Js(t)});var Ko=class e extends Xs{constructor(){super(...arguments),Ls.set(this,void 0)}_parse(e){if("string"!=typeof e.data){const t=this._getOrReturnCtx(e),r=this._def.values;return js(t,{expected:Ts.joinValues(r),received:t.parsedType,code:Os.invalid_type}),Zs}if(Gs(this,Ls,"f")||Vs(this,Ls,new Set(this._def.values),"f"),!Gs(this,Ls,"f").has(e.data)){const t=this._getOrReturnCtx(e),r=this._def.values;return js(t,{received:t.data,code:Os.invalid_enum_value,options:r}),Zs}return Fs(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(t,r=this._def){return e.create(t,{...this._def,...r})}exclude(t,r=this._def){return e.create(this.options.filter((e=>!t.includes(e))),{...this._def,...r})}};Ls=new WeakMap,Ko.create=zo;var qo=class extends Xs{constructor(){super(...arguments),$s.set(this,void 0)}_parse(e){const t=Ts.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==xs.string&&r.parsedType!==xs.number){const e=Ts.objectValues(t);return js(r,{expected:Ts.joinValues(e),received:r.parsedType,code:Os.invalid_type}),Zs}if(Gs(this,$s,"f")||Vs(this,$s,new Set(Ts.getValidEnumValues(this._def.values)),"f"),!Gs(this,$s,"f").has(e.data)){const e=Ts.objectValues(t);return js(r,{received:r.data,code:Os.invalid_enum_value,options:e}),Zs}return Fs(e.data)}get enum(){return this._def.values}};$s=new WeakMap,qo.create=(e,t)=>new qo({values:e,typeName:au.ZodNativeEnum,...Js(t)});var Ho=class extends Xs{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==xs.promise&&!1===t.common.async)return js(t,{code:Os.invalid_type,expected:xs.promise,received:t.parsedType}),Zs;const r=t.parsedType===xs.promise?t.data:Promise.resolve(t.data);return Fs(r.then((e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap}))))}};Ho.create=(e,t)=>new Ho({type:e,typeName:au.ZodPromise,...Js(t)});var Go=class extends Xs{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===au.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:r}=this._processInputParams(e),n=this._def.effect||null,a={addIssue:e=>{js(r,e),e.fatal?t.abort():t.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),"preprocess"===n.type){const e=n.transform(r.data,a);if(r.common.async)return Promise.resolve(e).then((async e=>{if("aborted"===t.value)return Zs;const n=await this._def.schema._parseAsync({data:e,path:r.path,parent:r});return"aborted"===n.status?Zs:"dirty"===n.status||"dirty"===t.value?Ds(n.value):n}));{if("aborted"===t.value)return Zs;const n=this._def.schema._parseSync({data:e,path:r.path,parent:r});return"aborted"===n.status?Zs:"dirty"===n.status||"dirty"===t.value?Ds(n.value):n}}if("refinement"===n.type){const e=e=>{const t=n.refinement(e,a);if(r.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===r.common.async){const n=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return"aborted"===n.status?Zs:("dirty"===n.status&&t.dirty(),e(n.value),{status:t.value,value:n.value})}return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then((r=>"aborted"===r.status?Zs:("dirty"===r.status&&t.dirty(),e(r.value).then((()=>({status:t.value,value:r.value}))))))}if("transform"===n.type){if(!1===r.common.async){const e=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!qs(e))return e;const i=n.transform(e.value,a);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:r.data,path:r.path,parent:r}).then((e=>qs(e)?Promise.resolve(n.transform(e.value,a)).then((e=>({status:t.value,value:e}))):e))}Ts.assertNever(n)}};Go.create=(e,t,r)=>new Go({schema:e,typeName:au.ZodEffects,effect:t,...Js(r)}),Go.createWithPreprocess=(e,t,r)=>new Go({schema:t,effect:{type:"preprocess",transform:e},typeName:au.ZodEffects,...Js(r)});var Vo=class extends Xs{_parse(e){return this._getType(e)===xs.undefined?Fs(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Vo.create=(e,t)=>new Vo({innerType:e,typeName:au.ZodOptional,...Js(t)});var Wo=class extends Xs{_parse(e){return this._getType(e)===xs.null?Fs(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Wo.create=(e,t)=>new Wo({innerType:e,typeName:au.ZodNullable,...Js(t)});var Yo=class extends Xs{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===xs.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};Yo.create=(e,t)=>new Yo({innerType:e,typeName:au.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...Js(t)});var Jo=class extends Xs{_parse(e){const{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Hs(n)?n.then((e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new Cs(r.common.issues)},input:r.data})}))):{status:"valid",value:"valid"===n.status?n.value:this._def.catchValue({get error(){return new Cs(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};Jo.create=(e,t)=>new Jo({innerType:e,typeName:au.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...Js(t)});var Qo=class extends Xs{_parse(e){if(this._getType(e)!==xs.nan){const t=this._getOrReturnCtx(e);return js(t,{code:Os.invalid_type,expected:xs.nan,received:t.parsedType}),Zs}return{status:"valid",value:e.data}}};Qo.create=e=>new Qo({typeName:au.ZodNaN,...Js(e)});var Xo=Symbol("zod_brand"),eu=class extends Xs{_parse(e){const{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}},tu=class e extends Xs{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const e=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return"aborted"===e.status?Zs:"dirty"===e.status?(t.dirty(),Ds(e.value)):this._def.out._parseAsync({data:e.value,path:r.path,parent:r})})();{const e=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return"aborted"===e.status?Zs:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:r.path,parent:r})}}static create(t,r){return new e({in:t,out:r,typeName:au.ZodPipeline})}},ru=class extends Xs{_parse(e){const t=this._def.innerType._parse(e),r=e=>(qs(e)&&(e.value=Object.freeze(e.value)),e);return Hs(t)?t.then((e=>r(e))):r(t)}unwrap(){return this._def.innerType}};function nu(e,t={},r){return e?ko.create().superRefine(((n,a)=>{var i,s;if(!e(n)){const e="function"==typeof t?t(n):"string"==typeof t?{message:t}:t,o=null===(s=null!==(i=e.fatal)&&void 0!==i?i:r)||void 0===s||s,u="string"==typeof e?{message:e}:e;a.addIssue({code:"custom",...u,fatal:o})}})):ko.create()}ru.create=(e,t)=>new ru({innerType:e,typeName:au.ZodReadonly,...Js(t)});var au,iu,su={object:Ro.lazycreate};(iu=au||(au={})).ZodString="ZodString",iu.ZodNumber="ZodNumber",iu.ZodNaN="ZodNaN",iu.ZodBigInt="ZodBigInt",iu.ZodBoolean="ZodBoolean",iu.ZodDate="ZodDate",iu.ZodSymbol="ZodSymbol",iu.ZodUndefined="ZodUndefined",iu.ZodNull="ZodNull",iu.ZodAny="ZodAny",iu.ZodUnknown="ZodUnknown",iu.ZodNever="ZodNever",iu.ZodVoid="ZodVoid",iu.ZodArray="ZodArray",iu.ZodObject="ZodObject",iu.ZodUnion="ZodUnion",iu.ZodDiscriminatedUnion="ZodDiscriminatedUnion",iu.ZodIntersection="ZodIntersection",iu.ZodTuple="ZodTuple",iu.ZodRecord="ZodRecord",iu.ZodMap="ZodMap",iu.ZodSet="ZodSet",iu.ZodFunction="ZodFunction",iu.ZodLazy="ZodLazy",iu.ZodLiteral="ZodLiteral",iu.ZodEnum="ZodEnum",iu.ZodEffects="ZodEffects",iu.ZodNativeEnum="ZodNativeEnum",iu.ZodOptional="ZodOptional",iu.ZodNullable="ZodNullable",iu.ZodDefault="ZodDefault",iu.ZodCatch="ZodCatch",iu.ZodPromise="ZodPromise",iu.ZodBranded="ZodBranded",iu.ZodPipeline="ZodPipeline",iu.ZodReadonly="ZodReadonly";var ou=go.create,uu=mo.create,cu=Qo.create,lu=vo.create,hu=wo.create,du=bo.create,fu=_o.create,pu=To.create,gu=Eo.create,yu=ko.create,mu=Ao.create,vu=xo.create,wu=So.create,bu=Oo.create,_u=Ro.create,Tu=Ro.strictCreate,Eu=Io.create,ku=Uo.create,Au=No.create,xu=Po.create,Su=Lo.create,Ou=$o.create,Cu=Mo.create,Ru=Zo.create,Iu=Do.create,Bu=Fo.create,Uu=Ko.create,ju=qo.create,Nu=Ho.create,Pu=Go.create,Lu=Vo.create,$u=Wo.create,Mu=Go.createWithPreprocess,Zu=tu.create,Du={string:e=>go.create({...e,coerce:!0}),number:e=>mo.create({...e,coerce:!0}),boolean:e=>wo.create({...e,coerce:!0}),bigint:e=>vo.create({...e,coerce:!0}),date:e=>bo.create({...e,coerce:!0})},Fu=Zs,zu=Object.freeze({__proto__:null,defaultErrorMap:Rs,setErrorMap:function(e){Is=e},getErrorMap:Bs,makeIssue:Us,EMPTY_PATH:[],addIssueToContext:js,ParseStatus:Ms,INVALID:Zs,DIRTY:Ds,OK:Fs,isAborted:zs,isDirty:Ks,isValid:qs,isAsync:Hs,get util(){return Ts},get objectUtil(){return ks},ZodParsedType:xs,getParsedType:Ss,ZodType:Xs,datetimeRegex:po,ZodString:go,ZodNumber:mo,ZodBigInt:vo,ZodBoolean:wo,ZodDate:bo,ZodSymbol:_o,ZodUndefined:To,ZodNull:Eo,ZodAny:ko,ZodUnknown:Ao,ZodNever:xo,ZodVoid:So,ZodArray:Oo,ZodObject:Ro,ZodUnion:Io,ZodDiscriminatedUnion:Uo,ZodIntersection:No,ZodTuple:Po,ZodRecord:Lo,ZodMap:$o,ZodSet:Mo,ZodFunction:Zo,ZodLazy:Do,ZodLiteral:Fo,ZodEnum:Ko,ZodNativeEnum:qo,ZodPromise:Ho,ZodEffects:Go,ZodTransformer:Go,ZodOptional:Vo,ZodNullable:Wo,ZodDefault:Yo,ZodCatch:Jo,ZodNaN:Qo,BRAND:Xo,ZodBranded:eu,ZodPipeline:tu,ZodReadonly:ru,custom:nu,Schema:Xs,ZodSchema:Xs,late:su,get ZodFirstPartyTypeKind(){return au},coerce:Du,any:yu,array:bu,bigint:lu,boolean:hu,date:du,discriminatedUnion:ku,effect:Pu,enum:Uu,function:Ru,instanceof:(e,t={message:`Input not instance of ${e.name}`})=>nu((t=>t instanceof e),t),intersection:Au,lazy:Iu,literal:Bu,map:Ou,nan:cu,nativeEnum:ju,never:vu,null:gu,nullable:$u,number:uu,object:_u,oboolean:()=>hu().optional(),onumber:()=>uu().optional(),optional:Lu,ostring:()=>ou().optional(),pipeline:Zu,preprocess:Mu,promise:Nu,record:Su,set:Cu,strictObject:Tu,string:ou,symbol:fu,transformer:Pu,tuple:xu,undefined:pu,union:Eu,unknown:mu,void:wu,NEVER:Fu,ZodIssueCode:Os,quotelessJson:e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),ZodError:Cs});function Ku({fetch:e,GRAPHQL_URL:t,logger:r}){const n=zu.object({data:zu.object({transactions:zu.object({edges:zu.array(zu.object({node:zu.record(zu.any())}))})})});return a=>va(a).chain(_a((a=>e(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:"\n query GetTransactions ($transactionIds: [ID!]!) {\n transactions(ids: $transactionIds) {\n edges {\n node {\n owner {\n address\n }\n tags {\n name\n value\n }\n block {\n id\n height\n timestamp\n }\n }\n }\n }\n }",variables:{transactionIds:[a]}})}).then((async e=>{if(e.ok)return e.json();throw r('Error Encountered when querying gateway for transaction "%s"',a),new Error(`${e.status}: ${await e.text()}`)})).then(n.parse).then(ms(["data","transactions","edges","0","node"]))))).toPromise()}var qu=d(T(),1),Hu=(e="@permaweb/aoconnect")=>{const t=(0,qu.default)(e);return t.child=e=>Hu(`${t.namespace}:${e}`),t.tap=(e,...r)=>As(((...n)=>t(e,...r,...n))),t},Gu=({url:e,path:t})=>t?t.startsWith("/")?Gu({url:e,path:t.slice(1)}):((e=new URL(e)).pathname+=t,e.toString()):e;function Vu(e){return rs(os([]),$i(((e,t)=>rs(ws([],t.name),Di(t.value),Ki(t.name,Na,e))(e)),{}),Ei((e=>e.length>1?e:e[0])))(e)}function Wu(e,t){return r=>mi(Mi([vs(e,"name"),ls(Zi(t),vs(t,"value"),ja)]),r)}function Yu(e){return ss([[fs(String),oi(e)],[fs(Array),hs(e)],[ja,Ua]])}function Ju(e){let t;var r;return fs(Cs,e)?(t=new Error((r=e,rs((e=>function e(t,r,n){return $i(((t,a)=>rs(ss([[oi(Os.invalid_arguments),()=>e(a.argumentsError,422,"Invalid Arguments")],[oi(Os.invalid_return_type),()=>e(a.returnTypeError,500,"Invalid Return")],[oi(Os.invalid_union),()=>Qi((t=>e(t,400,"Invalid Union")),a.unionErrors)],[ja,()=>[{...a,status:r,contextCode:n}]]]),is(t))(a.code)),[],t.issues)}(e,400,"")),(e=>$i(((e,t)=>{const{message:r,path:n,contextCode:a}=t,i=n[1]||n[0],s=a?`${a} `:"";return e.push(`${s}'${i}': ${r}.`),e}),[],e)),gs(" | "))(r))),t.stack+=e.stack):t=fs(Error,e)?e:cs("message",e)?new Error(e.message):fs(String,e)?new Error(e):new Error("An error occurred"),t}var Qu=zu.object({id:zu.string().min(1,{message:"message is required to be a message id"}),processId:zu.string().min(1,{message:"process is required to be a process id"})}),Xu=zu.object({name:zu.string(),value:zu.string()}),ec=zu.function().args(zu.object({Id:zu.string(),Target:zu.string(),Owner:zu.string(),Anchor:zu.string().optional(),Data:zu.any().default("1234"),Tags:zu.array(zu.object({name:zu.string(),value:zu.string()}))})).returns(zu.promise(zu.any())),tc=zu.function().args(zu.object({id:zu.string().min(1,{message:"message id is required"}),processId:zu.string().min(1,{message:"process id is required"})})).returns(zu.promise(zu.any())),rc=zu.function().args(zu.object({process:zu.string().min(1,{message:"process id is required"}),from:zu.string().optional(),to:zu.string().optional(),sort:zu.enum(["ASC","DESC"]).default("ASC"),limit:zu.number().optional()})).returns(zu.promise(zu.object({edges:zu.array(zu.object({cursor:zu.string(),node:zu.object({Output:zu.any().optional(),Messages:zu.array(zu.any()).optional(),Spawns:zu.array(zu.any()).optional(),Error:zu.any().optional()})}))}))),nc=zu.function().args(zu.object({processId:zu.string(),data:zu.any(),tags:zu.array(Xu),anchor:zu.string().optional(),signer:zu.any()})).returns(zu.promise(zu.object({messageId:zu.string()}).passthrough())),ac=zu.function().args(zu.object({data:zu.any(),tags:zu.array(Xu),signer:zu.any()})).returns(zu.promise(zu.object({processId:zu.string()}).passthrough())),ic=zu.function().args(zu.object({process:zu.string(),message:zu.string(),baseLayer:zu.boolean().optional(),exclude:zu.array(zu.string()).optional()})).returns(zu.promise(zu.object({assignmentId:zu.string()}).passthrough())),sc=nc,oc=(zu.function().args(zu.object({suUrl:zu.string().url(),processId:zu.string()})).returns(zu.promise(zu.object({tags:zu.array(Xu)}).passthrough())),zu.function().args(zu.string()).returns(zu.promise(zu.object({url:zu.string()}))),zu.function().args(zu.string()).returns(zu.promise(zu.boolean()))),uc=zu.function().args(zu.string()).returns(zu.promise(zu.object({tags:zu.array(Xu)}).passthrough())),cc=zu.function().args(zu.object({data:zu.any(),tags:zu.array(Xu),target:zu.string().optional(),anchor:zu.string().optional()})).returns(zu.promise(zu.object({id:zu.string(),raw:zu.any()})));var lc=zu.array(zu.object({name:zu.string(),value:zu.string()}));var hc=(e,t,r)=>n=>t(n[e])?wa(n):ba(`Tag '${e}': ${r}`);var dc=zu.array(zu.object({name:zu.string(),value:zu.string()}));var fc=zu.object({process:zu.string().min(1,{message:"process identifier is required"}),from:zu.string().optional(),to:zu.string().optional(),sort:zu.enum(["ASC","DESC"]).default("ASC"),limit:zu.number().optional()});var pc=zu.object({Id:zu.string(),Target:zu.string(),Owner:zu.string(),Anchor:zu.string().optional(),Data:zu.any().default("1234"),Tags:zu.array(zu.object({name:zu.string(),value:zu.string()}))});function gc({process:e,data:t,tags:r,anchor:n,...a}){return{Id:"1234",Owner:"1234",...a,Target:e,Data:t||"1234",Tags:r||[],Anchor:n||"0"}}function yc(e){const t=function(e){const t=ic.implement(e.deployAssign);return e=>va(e).chain(_a((({process:e,message:r,baseLayer:n,exclude:a})=>t({process:e,message:r,baseLayer:n,exclude:a})))).map((t=>Ki("assignmentId",t.assignmentId,e)))}(e);return({process:e,message:r,baseLayer:n,exclude:a})=>va({process:e,message:r,baseLayer:n,exclude:a}).chain(t).map((e=>e.assignmentId)).bimap(Ju,as).toPromise()}function mc({GRAPHQL_URL:e,GRAPHQL_MAX_RETRIES:t,GRAPHQL_RETRY_BACKOFF:r,GATEWAY_URL:n="https://arweave.net",MU_URL:a="https://mu.ao-testnet.xyz",CU_URL:i="https://cu.ao-testnet.xyz"}={}){const s=Hu();e||(e=Gu({url:n,path:"/graphql"}));const{validate:o}=ua({cacheSize:100,GRAPHQL_URL:e,GRAPHQL_MAX_RETRIES:t,GRAPHQL_RETRY_BACKOFF:r}),u=(({MAX_SIZE:e})=>Ra||(Ra=new Ia.default(e)))({MAX_SIZE:25}),c=s.child("result"),l=function(e){const t=e=>va(e).map(Qu.parse).map((()=>e)),r=function({loadResult:e}){return e=_a(tc.implement(e)),t=>va({id:t.id,processId:t.processId}).chain(e)}(e);return({message:n,process:a})=>va({id:n,processId:a}).chain(t).chain(r).map(e.logger.tap('readResult result for message "%s": %O',n)).map((e=>e)).bimap(Ju,as).toPromise()}({loadResult:Oa({fetch,CU_URL:i,logger:c}),logger:c}),h=s.child("message"),d=function(e){const t=function(e){const t=e=>va(e.tags).map(os([])).map(Wu("Data-Protocol","ao")).map(Wu("Variant")).map(Wu("Type")).map(Wu("SDK")).map(is(Na,[{name:"Data-Protocol",value:"ao"},{name:"Variant",value:"ao.TN.1"},{name:"Type",value:"Message"},{name:"SDK",value:"aoconnect"}])).map(lc.parse).map(Ki("tags",Na,e)),r=function({logger:e}){return t=>va(t).chain(ls(Zi(t.data),(()=>wa(t)),(()=>wa(" ").map(Ki("data",Na,t)).map((e=>rs(Si("tags"),Wu("Content-Type"),Di({name:"Content-Type",value:"text/plain"}),Ki("tags",Na,e))(e))).map(e.tap('added pseudo-random string as message "data"')))))}(e),n=nc.implement(e.deployMessage);return e=>va(e).chain(t).chain(r).chain(_a((({id:e,data:t,tags:r,anchor:a,signer:i})=>n({processId:e,data:t,tags:r,anchor:a,signer:cc.implement(i)})))).map((t=>Ki("messageId",t.messageId,e)))}(e);return({process:e,data:r,tags:n,anchor:a,signer:i})=>va({id:e,data:r,tags:n,anchor:a,signer:i}).chain(t).map((e=>e.messageId)).bimap(Ju,as).toPromise()}({loadProcessMeta:Ba({fetch,cache:u,logger:h}),deployMessage:Ta({fetch,MU_URL:a,logger:h}),logger:h}),f=s.child("spawn"),p=function(e){const t=function(e){const t=e.logger.child("verifyInput"),r=function({loadTransactionMeta:e,logger:t}){return e=_a(uc.implement(e)),r=>va(r).chain(e).map(Si("tags")).map(Vu).chain(hc("Data-Protocol",Yu("ao"),"value 'ao' was not found on module")).chain(hc("Type",Yu("Module"),"value 'Module' was not found on module")).chain(hc("Module-Format",ps,"was not found on module")).chain(hc("Input-Encoding",ps,"was not found on module")).chain(hc("Output-Encoding",ps,"was not found on module")).bimap(t.tap("Verifying module source failed: %s"),t.tap("Verified module source"))}(e={...e,logger:t}),n=function({logger:e,validateScheduler:t}){return t=_a(oc.implement(t)),r=>va(r).chain((e=>t(e).chain((t=>t?wa(e):ba(`Valid Scheduler-Location owned by ${e} not found`))))).bimap(e.tap("Verifying scheduler failed: %s"),e.tap("Verified scheduler"))}(e),a=function({logger:e}){return t=>va(t).map(e.tap("Checking for signer")).chain((e=>e?wa(e):ba("signer not found")))}(e);return e=>va(e).chain((e=>r(e.module).map((()=>e)))).chain((e=>n(e.scheduler))).map((()=>e)).chain((e=>a(e.signer).map((()=>e)))).bimap(t.tap("Error when verify input: %s"),t.tap("Successfully verified inputs"))}(e),r=function(e){const t=e.logger.child("uploadProcess");e={...e,logger:t};const r=e=>va(e).map(Si("tags")).map(os([])).map(Wu("Data-Protocol","ao")).map(Wu("Variant")).map(Wu("Type")).map(Wu("Module")).map(Wu("Scheduler")).map(Wu("SDK")).map(is(Na,[{name:"Data-Protocol",value:"ao"},{name:"Variant",value:"ao.TN.1"},{name:"Type",value:"Process"},{name:"Module",value:e.module},{name:"Scheduler",value:e.scheduler},{name:"SDK",value:"aoconnect"}])).map(dc.parse).map(Ki("tags",Na,e)),n=function({logger:e}){return t=>va(t).chain(ls(Zi(t.data),(()=>wa(t)),(()=>wa(" ").map(Ki("data",Na,t)).map((e=>rs(Si("tags"),Wu("Content-Type"),Di({name:"Content-Type",value:"text/plain"}),Ki("tags",Na,e))(e))).map(e.tap('added pseudo-random string as process "data"')))))}(e),a=ac.implement(e.deployProcess);return e=>va(e).chain(r).chain(n).chain(_a((({data:e,tags:t,signer:r})=>a({data:e,tags:t,signer:cc.implement(r)})))).map((t=>Ki("processId",t.processId,e)))}(e);return({module:e,scheduler:n,signer:a,tags:i,data:s})=>va({module:e,scheduler:n,signer:a,tags:i,data:s}).chain(t).chain(r).map((e=>e.processId)).bimap(Ju,as).toPromise()}({loadTransactionMeta:Ku({fetch,GRAPHQL_URL:e,logger:f}),validateScheduler:o,deployProcess:Ea({fetch,MU_URL:a,logger:f}),logger:f}),g=s.child("monitor"),y=function(e){const t=function(e){const t=sc.implement(e.deployMonitor);return e=>va(e).chain(_a((({id:e,signer:r})=>t({processId:e,signer:cc.implement(r),data:" ",tags:[]})))).map((t=>Ki("monitorId",t.messageId,e)))}(e);return({process:e,signer:r})=>va({id:e,signer:r}).chain(t).map((e=>e.monitorId)).bimap(Ju,as).toPromise()}({loadProcessMeta:Ba({fetch,cache:u,logger:g}),deployMonitor:ka({fetch,MU_URL:a,logger:g}),logger:g}),m=s.child("unmonitor"),v=function(e){const t=function(e){const t=sc.implement(e.deployUnmonitor);return e=>va(e).chain(_a((({id:e,signer:r})=>t({processId:e,signer:cc.implement(r),data:" ",tags:[]})))).map((t=>Ki("monitorId",t.messageId,e)))}(e);return({process:e,signer:r})=>va({id:e,signer:r}).chain(t).map((e=>e.monitorId)).bimap(Ju,as).toPromise()}({loadProcessMeta:Ba({fetch,cache:u,logger:m}),deployUnmonitor:Aa({fetch,MU_URL:a,logger:m}),logger:g}),w=s.child("results"),b=function(e){const t=e=>va(e).map(fc.parse).map((()=>e)),r=function({queryResults:e}){return e=_a(rc.implement(e)),t=>va({process:t.process,from:t.from,to:t.to,sort:t.sort,limit:t.limit}).chain(e)}(e);return({process:n,from:a,to:i,sort:s,limit:o})=>va({process:n,from:a,to:i,sort:s,limit:o}).chain(t).chain(r).map(e.logger.tap('readResults result for message "%s": %O',n)).map((e=>e)).bimap(Ju,as).toPromise()}({queryResults:Ca({fetch,CU_URL:i,logger:w}),logger:w}),_=s.child("dryrun"),T=function(e){const t=e=>va(e).map(pc.parse).map((e=>(e.Tags=e.Tags.concat([{name:"Data-Protocol",value:"ao"},{name:"Type",value:"Message"},{name:"Variant",value:"ao.TN.1"}]),e))),r=function({dryrunFetch:e}){return _a(ec.implement(e))}(e);return e=>va(e).map(gc).chain(t).chain(r).toPromise()}({dryrunFetch:Sa({fetch,CU_URL:i,logger:_}),logger:_}),E=s.child("assign");return{result:l,results:b,message:d,spawn:p,monitor:y,unmonitor:v,dryrun:T,assign:yc({deployAssign:xa({fetch,MU_URL:a,logger:E}),logger:h})}}var vc={};h(vc,{createDataItemSigner:()=>vl});var wc=d(A(),1),bc={};h(bc,{AVSCTap:()=>tl,ArweaveSigner:()=>Jc,DataItem:()=>hl,MAX_TAG_BYTES:()=>cl,MIN_BINARY_SIZE:()=>ll,SIG_CONFIG:()=>Yc,SignatureConfig:()=>qc,Signer:()=>Mc,createData:()=>fl,default:()=>gl,deserializeTags:()=>al,indexToType:()=>Qc,serializeTags:()=>rl,tagsExceedLimit:()=>nl,warparbundles:()=>yl});var _c=Object.create,Tc=Object.defineProperty,Ec=Object.getOwnPropertyDescriptor,kc=Object.getOwnPropertyNames,Ac=Object.getPrototypeOf,xc=Object.prototype.hasOwnProperty,Sc=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Oc=(e,t,r)=>(r=null!=e?_c(Ac(e)):{},((e,t,r,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of kc(t))!xc.call(e,r)&&undefined!==r&&Tc(e,r,{get:()=>t[r],enumerable:!(n=Ec(t,r))||n.enumerable});return e})(!t&&e&&e.__esModule?r:Tc(r,"default",{value:e,enumerable:!0}),e)),Cc=Sc((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(e){var t=e.length,r=t%4;if(!r)return e;var n=t,a=4-r,i=t+a,s=Buffer.alloc(i);for(s.write(e);a--;)s.write("=",n++);return s.toString()}})),Rc=Sc((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Cc();function r(e,t){return void 0===t&&(t="utf8"),Buffer.isBuffer(e)?a(e.toString("base64")):a(Buffer.from(e,t).toString("base64"))}function n(e){return e=e.toString(),t.default(e).replace(/\-/g,"+").replace(/_/g,"/")}function a(e){return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}var i=r;i.encode=r,i.decode=function(e,t){return void 0===t&&(t="utf8"),Buffer.from(n(e),"base64").toString(t)},i.toBase64=n,i.fromBase64=a,i.toBuffer=function(e){return Buffer.from(n(e),"base64")},e.default=i})),Ic=Sc(((e,t)=>{t.exports=Rc().default,t.exports.default=t.exports})),Bc=Sc((e=>{e.byteLength=function(e){var t=s(e),r=t[0],n=t[1];return 3*(r+n)/4-n},e.toByteArray=function(e){var t,r,i=s(e),o=i[0],u=i[1],c=new a(function(e,t,r){return 3*(t+r)/4-r}(0,o,u)),l=0,h=u>0?o-4:o;for(r=0;r<h;r+=4)t=n[e.charCodeAt(r)]<<18|n[e.charCodeAt(r+1)]<<12|n[e.charCodeAt(r+2)]<<6|n[e.charCodeAt(r+3)],c[l++]=t>>16&255,c[l++]=t>>8&255,c[l++]=255&t;return 2===u&&(t=n[e.charCodeAt(r)]<<2|n[e.charCodeAt(r+1)]>>4,c[l++]=255&t),1===u&&(t=n[e.charCodeAt(r)]<<10|n[e.charCodeAt(r+1)]<<4|n[e.charCodeAt(r+2)]>>2,c[l++]=t>>8&255,c[l++]=255&t),c},e.fromByteArray=function(e){for(var t,n=e.length,a=n%3,i=[],s=16383,o=0,c=n-a;o<c;o+=s)i.push(u(e,o,o+s>c?c:o+s));return 1===a?(t=e[n-1],i.push(r[t>>2]+r[t<<4&63]+"==")):2===a&&(t=(e[n-2]<<8)+e[n-1],i.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"=")),i.join("")};var t,r=[],n=[],a=typeof Uint8Array<"u"?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(t=0;t<64;++t)r[t]=i[t],n[i.charCodeAt(t)]=t;function s(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function o(e){return r[e>>18&63]+r[e>>12&63]+r[e>>6&63]+r[63&e]}function u(e,t,r){for(var n,a=[],i=t;i<r;i+=3)n=(e[i]<<16&16711680)+(e[i+1]<<8&65280)+(255&e[i+2]),a.push(o(n));return a.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63})),Uc=Sc((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.b64UrlDecode=e.b64UrlEncode=e.bufferTob64Url=e.bufferTob64=e.b64UrlToBuffer=e.stringToB64Url=e.stringToBuffer=e.bufferToString=e.b64UrlToString=e.concatBuffers=void 0;var t=Bc();function r(e){return new TextDecoder("utf-8",{fatal:!0}).decode(e)}function n(e){return(new TextEncoder).encode(e)}function a(e){return new Uint8Array(t.toByteArray(u(e)))}function i(e){return t.fromByteArray(new Uint8Array(e))}function s(e){return o(i(e))}function o(e){return e.replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}function u(e){let t;return t=(e=e.replace(/\-/g,"+").replace(/\_/g,"/")).length%4==0?0:4-e.length%4,e.concat("=".repeat(t))}e.concatBuffers=function(e){let t=0;for(let r=0;r<e.length;r++)t+=e[r].byteLength;let r=new Uint8Array(t),n=0;r.set(new Uint8Array(e[0]),n),n+=e[0].byteLength;for(let t=1;t<e.length;t++)r.set(new Uint8Array(e[t]),n),n+=e[t].byteLength;return r},e.b64UrlToString=function(e){return r(a(e))},e.bufferToString=r,e.stringToBuffer=n,e.stringToB64Url=function(e){return s(n(e))},e.b64UrlToBuffer=a,e.bufferTob64=i,e.bufferTob64Url=s,e.b64UrlEncode=o,e.b64UrlDecode=u})),jc=Sc((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Uc();e.default=class{keyLength=4096;publicExponent=65537;hashAlgorithm="sha256";driver;constructor(){if(!this.detectWebCrypto())throw new Error("SubtleCrypto not available!");this.driver=crypto.subtle}async generateJWK(){let e=await this.driver.generateKey({name:"RSA-PSS",modulusLength:4096,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign"]),t=await this.driver.exportKey("jwk",e.privateKey);return{kty:t.kty,e:t.e,n:t.n,d:t.d,p:t.p,q:t.q,dp:t.dp,dq:t.dq,qi:t.qi}}async sign(e,t,{saltLength:r}={}){let n=await this.driver.sign({name:"RSA-PSS",saltLength:32},await this.jwkToCryptoKey(e),t);return new Uint8Array(n)}async hash(e,t="SHA-256"){let r=await this.driver.digest(t,e);return new Uint8Array(r)}async verify(e,t,r){let n={kty:"RSA",e:"AQAB",n:e},a=await this.jwkToPublicCryptoKey(n),i=await this.driver.digest("SHA-256",t),s=await this.driver.verify({name:"RSA-PSS",saltLength:0},a,r,t),o=await this.driver.verify({name:"RSA-PSS",saltLength:32},a,r,t),u=await this.driver.verify({name:"RSA-PSS",saltLength:Math.ceil((a.algorithm.modulusLength-1)/8)-i.byteLength-2},a,r,t);return s||o||u}async jwkToCryptoKey(e){return this.driver.importKey("jwk",e,{name:"RSA-PSS",hash:{name:"SHA-256"}},!1,["sign"])}async jwkToPublicCryptoKey(e){return this.driver.importKey("jwk",e,{name:"RSA-PSS",hash:{name:"SHA-256"}},!1,["verify"])}detectWebCrypto(){if(typeof crypto>"u")return!1;let e=crypto?.subtle;return void 0!==e&&["generateKey","importKey","exportKey","digest","sign"].every((t=>"function"==typeof e[t]))}async encrypt(e,r,n){let a=await this.driver.importKey("raw","string"==typeof r?t.stringToBuffer(r):r,{name:"PBKDF2",length:32},!1,["deriveKey"]),i=await this.driver.deriveKey({name:"PBKDF2",salt:n?t.stringToBuffer(n):t.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},a,{name:"AES-CBC",length:256},!1,["encrypt","decrypt"]),s=new Uint8Array(16);crypto.getRandomValues(s);let o=await this.driver.encrypt({name:"AES-CBC",iv:s},i,e);return t.concatBuffers([s,o])}async decrypt(e,r,n){let a=await this.driver.importKey("raw","string"==typeof r?t.stringToBuffer(r):r,{name:"PBKDF2",length:32},!1,["deriveKey"]),i=await this.driver.deriveKey({name:"PBKDF2",salt:n?t.stringToBuffer(n):t.stringToBuffer("salt"),iterations:1e5,hash:"SHA-256"},a,{name:"AES-CBC",length:256},!1,["encrypt","decrypt"]),s=e.slice(0,16),o=await this.driver.decrypt({name:"AES-CBC",iv:s},i,e.slice(16));return t.concatBuffers([o])}}})),Nc=Sc((e=>{e.read=function(e,t,r,n,a){var i,s,o=8*a-n-1,u=(1<<o)-1,c=u>>1,l=-7,h=r?a-1:0,d=r?-1:1,f=e[t+h];for(h+=d,i=f&(1<<-l)-1,f>>=-l,l+=o;l>0;i=256*i+e[t+h],h+=d,l-=8);for(s=i&(1<<-l)-1,i>>=-l,l+=n;l>0;s=256*s+e[t+h],h+=d,l-=8);if(0===i)i=1-c;else{if(i===u)return s?NaN:1/0*(f?-1:1);s+=Math.pow(2,n),i-=c}return(f?-1:1)*s*Math.pow(2,i-n)},e.write=function(e,t,r,n,a,i){var s,o,u,c=8*i-a-1,l=(1<<c)-1,h=l>>1,d=23===a?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:i-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(o=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+h>=1?d/u:d*Math.pow(2,1-h))*u>=2&&(s++,u/=2),s+h>=l?(o=0,s=l):s+h>=1?(o=(t*u-1)*Math.pow(2,a),s+=h):(o=t*Math.pow(2,h-1)*Math.pow(2,a),s=0));a>=8;e[r+f]=255&o,f+=p,o/=256,a-=8);for(s=s<<a|o,c+=a;c>0;e[r+f]=255&s,f+=p,s/=256,c-=8);e[r+f-p]|=128*g}})),Pc=Sc((e=>{var t=Bc(),r=Nc(),n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=s,e.SlowBuffer=function(e){return+e!=e&&(e=0),s.alloc(+e)},e.INSPECT_MAX_BYTES=50;var a=2147483647;function i(e){if(e>a)throw new RangeError('The value "'+e+'" is invalid for option "size"');let t=new Uint8Array(e);return Object.setPrototypeOf(t,s.prototype),t}function s(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return c(e)}return o(e,t,r)}function o(e,t,r){if("string"==typeof e)return function(e,t){if(("string"!=typeof t||""===t)&&(t="utf8"),!s.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let r=0|f(e,t),n=i(r),a=n.write(e,t);return a!==r&&(n=n.slice(0,a)),n}(e,t);if(ArrayBuffer.isView(e))return function(e){if(G(e,Uint8Array)){let t=new Uint8Array(e);return h(t.buffer,t.byteOffset,t.byteLength)}return l(e)}(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(G(e,ArrayBuffer)||e&&G(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(G(e,SharedArrayBuffer)||e&&G(e.buffer,SharedArrayBuffer)))return h(e,t,r);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');let n=e.valueOf&&e.valueOf();if(null!=n&&n!==e)return s.from(n,t,r);let a=function(e){if(s.isBuffer(e)){let t=0|d(e.length),r=i(t);return 0===r.length||e.copy(r,0,0,t),r}return void 0!==e.length?"number"!=typeof e.length||V(e.length)?i(0):l(e):"Buffer"===e.type&&Array.isArray(e.data)?l(e.data):void 0}(e);if(a)return a;if(typeof Symbol<"u"&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return s.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function u(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function c(e){return u(e),i(e<0?0:0|d(e))}function l(e){let t=e.length<0?0:0|d(e.length),r=i(t);for(let n=0;n<t;n+=1)r[n]=255&e[n];return r}function h(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===t&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,t):new Uint8Array(e,t,r),Object.setPrototypeOf(n,s.prototype),n}function d(e){if(e>=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|e}function f(e,t){if(s.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||G(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);let r=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let a=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return K(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return q(e).length;default:if(a)return n?-1:K(e).length;t=(""+t).toLowerCase(),a=!0}}function p(e,t,r){let n=!1;if((void 0===t||t<0)&&(t=0),t>this.length||((void 0===r||r>this.length)&&(r=this.length),r<=0)||(r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return O(this,t,r);case"utf8":case"utf-8":return k(this,t,r);case"ascii":return x(this,t,r);case"latin1":case"binary":return S(this,t,r);case"base64":return E(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function g(e,t,r){let n=e[t];e[t]=e[r],e[r]=n}function y(e,t,r,n,a){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),V(r=+r)&&(r=a?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(a)return-1;r=e.length-1}else if(r<0){if(!a)return-1;r=0}if("string"==typeof t&&(t=s.from(t,n)),s.isBuffer(t))return 0===t.length?-1:m(e,t,r,n,a);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?a?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):m(e,[t],r,n,a);throw new TypeError("val must be string, number or Buffer")}function m(e,t,r,n,a){let i,s=1,o=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,o/=2,u/=2,r/=2}function c(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(a){let n=-1;for(i=r;i<o;i++)if(c(e,i)===c(t,-1===n?0:i-n)){if(-1===n&&(n=i),i-n+1===u)return n*s}else-1!==n&&(i-=i-n),n=-1}else for(r+u>o&&(r=o-u),i=r;i>=0;i--){let r=!0;for(let n=0;n<u;n++)if(c(e,i+n)!==c(t,n)){r=!1;break}if(r)return i}return-1}function v(e,t,r,n){r=Number(r)||0;let a=e.length-r;n?(n=Number(n))>a&&(n=a):n=a;let i,s=t.length;for(n>s/2&&(n=s/2),i=0;i<n;++i){let n=parseInt(t.substr(2*i,2),16);if(V(n))return i;e[r+i]=n}return i}function w(e,t,r,n){return H(K(t,e.length-r),e,r,n)}function b(e,t,r,n){return H(function(e){let t=[];for(let r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,n)}function _(e,t,r,n){return H(q(t),e,r,n)}function T(e,t,r,n){return H(function(e,t){let r,n,a,i=[];for(let s=0;s<e.length&&!((t-=2)<0);++s)r=e.charCodeAt(s),n=r>>8,a=r%256,i.push(a),i.push(n);return i}(t,e.length-r),e,r,n)}function E(e,r,n){return 0===r&&n===e.length?t.fromByteArray(e):t.fromByteArray(e.slice(r,n))}function k(e,t,r){r=Math.min(e.length,r);let n=[],a=t;for(;a<r;){let t=e[a],i=null,s=t>239?4:t>223?3:t>191?2:1;if(a+s<=r){let r,n,o,u;switch(s){case 1:t<128&&(i=t);break;case 2:r=e[a+1],128==(192&r)&&(u=(31&t)<<6|63&r,u>127&&(i=u));break;case 3:r=e[a+1],n=e[a+2],128==(192&r)&&128==(192&n)&&(u=(15&t)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:r=e[a+1],n=e[a+2],o=e[a+3],128==(192&r)&&128==(192&n)&&128==(192&o)&&(u=(15&t)<<18|(63&r)<<12|(63&n)<<6|63&o,u>65535&&u<1114112&&(i=u))}}null===i?(i=65533,s=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),a+=s}return function(e){let t=e.length;if(t<=A)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=A));return r}(n)}e.kMaxLength=a,s.TYPED_ARRAY_SUPPORT=function(){try{let e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch{return!1}}(),!s.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&"function"==typeof console.error&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(s.prototype,"parent",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}}),Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}}),s.poolSize=8192,s.from=function(e,t,r){return o(e,t,r)},Object.setPrototypeOf(s.prototype,Uint8Array.prototype),Object.setPrototypeOf(s,Uint8Array),s.alloc=function(e,t,r){return function(e,t,r){return u(e),e<=0?i(e):void 0!==t?"string"==typeof r?i(e).fill(t,r):i(e).fill(t):i(e)}(e,t,r)},s.allocUnsafe=function(e){return c(e)},s.allocUnsafeSlow=function(e){return c(e)},s.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==s.prototype},s.compare=function(e,t){if(G(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),G(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(e)||!s.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let r=e.length,n=t.length;for(let a=0,i=Math.min(r,n);a<i;++a)if(e[a]!==t[a]){r=e[a],n=t[a];break}return r<n?-1:n<r?1:0},s.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},s.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return s.alloc(0);let r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;let n=s.allocUnsafe(t),a=0;for(r=0;r<e.length;++r){let t=e[r];if(G(t,Uint8Array))a+t.length>n.length?(s.isBuffer(t)||(t=s.from(t)),t.copy(n,a)):Uint8Array.prototype.set.call(n,t,a);else{if(!s.isBuffer(t))throw new TypeError('"list" argument must be an Array of Buffers');t.copy(n,a)}a+=t.length}return n},s.byteLength=f,s.prototype._isBuffer=!0,s.prototype.swap16=function(){let e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)g(this,t,t+1);return this},s.prototype.swap32=function(){let e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)g(this,t,t+3),g(this,t+1,t+2);return this},s.prototype.swap64=function(){let e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)g(this,t,t+7),g(this,t+1,t+6),g(this,t+2,t+5),g(this,t+3,t+4);return this},s.prototype.toString=function(){let e=this.length;return 0===e?"":0===arguments.length?k(this,0,e):p.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(e){if(!s.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===s.compare(this,e)},s.prototype.inspect=function(){let t="",r=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},n&&(s.prototype[n]=s.prototype.inspect),s.prototype.compare=function(e,t,r,n,a){if(G(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),!s.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===a&&(a=this.length),t<0||r>e.length||n<0||a>this.length)throw new RangeError("out of range index");if(n>=a&&t>=r)return 0;if(n>=a)return-1;if(t>=r)return 1;if(this===e)return 0;let i=(a>>>=0)-(n>>>=0),o=(r>>>=0)-(t>>>=0),u=Math.min(i,o),c=this.slice(n,a),l=e.slice(t,r);for(let e=0;e<u;++e)if(c[e]!==l[e]){i=c[e],o=l[e];break}return i<o?-1:o<i?1:0},s.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},s.prototype.indexOf=function(e,t,r){return y(this,e,t,r,!0)},s.prototype.lastIndexOf=function(e,t,r){return y(this,e,t,r,!1)},s.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}let a=this.length-t;if((void 0===r||r>a)&&(r=a),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let i=!1;for(;;)switch(n){case"hex":return v(this,e,t,r);case"utf8":case"utf-8":return w(this,e,t,r);case"ascii":case"latin1":case"binary":return b(this,e,t,r);case"base64":return _(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,e,t,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;function x(e,t,r){let n="";r=Math.min(e.length,r);for(let a=t;a<r;++a)n+=String.fromCharCode(127&e[a]);return n}function S(e,t,r){let n="";r=Math.min(e.length,r);for(let a=t;a<r;++a)n+=String.fromCharCode(e[a]);return n}function O(e,t,r){let n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);let a="";for(let n=t;n<r;++n)a+=W[e[n]];return a}function C(e,t,r){let n=e.slice(t,r),a="";for(let e=0;e<n.length-1;e+=2)a+=String.fromCharCode(n[e]+256*n[e+1]);return a}function R(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function I(e,t,r,n,a,i){if(!s.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>a||t<i)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function B(e,t,r,n,a){Z(t,n,a,e,r,7);let i=Number(t&BigInt(4294967295));e[r++]=i,i>>=8,e[r++]=i,i>>=8,e[r++]=i,i>>=8,e[r++]=i;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r++]=s,s>>=8,e[r++]=s,s>>=8,e[r++]=s,s>>=8,e[r++]=s,r}function U(e,t,r,n,a){Z(t,n,a,e,r,7);let i=Number(t&BigInt(4294967295));e[r+7]=i,i>>=8,e[r+6]=i,i>>=8,e[r+5]=i,i>>=8,e[r+4]=i;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r+3]=s,s>>=8,e[r+2]=s,s>>=8,e[r+1]=s,s>>=8,e[r]=s,r+8}function j(e,t,r,n,a,i){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function N(e,t,n,a,i){return t=+t,n>>>=0,i||j(e,0,n,4),r.write(e,t,n,a,23,4),n+4}function P(e,t,n,a,i){return t=+t,n>>>=0,i||j(e,0,n,8),r.write(e,t,n,a,52,8),n+8}s.prototype.slice=function(e,t){let r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e);let n=this.subarray(e,t);return Object.setPrototypeOf(n,s.prototype),n},s.prototype.readUintLE=s.prototype.readUIntLE=function(e,t,r){e>>>=0,t>>>=0,r||R(e,t,this.length);let n=this[e],a=1,i=0;for(;++i<t&&(a*=256);)n+=this[e+i]*a;return n},s.prototype.readUintBE=s.prototype.readUIntBE=function(e,t,r){e>>>=0,t>>>=0,r||R(e,t,this.length);let n=this[e+--t],a=1;for(;t>0&&(a*=256);)n+=this[e+--t]*a;return n},s.prototype.readUint8=s.prototype.readUInt8=function(e,t){return e>>>=0,t||R(e,1,this.length),this[e]},s.prototype.readUint16LE=s.prototype.readUInt16LE=function(e,t){return e>>>=0,t||R(e,2,this.length),this[e]|this[e+1]<<8},s.prototype.readUint16BE=s.prototype.readUInt16BE=function(e,t){return e>>>=0,t||R(e,2,this.length),this[e]<<8|this[e+1]},s.prototype.readUint32LE=s.prototype.readUInt32LE=function(e,t){return e>>>=0,t||R(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},s.prototype.readUint32BE=s.prototype.readUInt32BE=function(e,t){return e>>>=0,t||R(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},s.prototype.readBigUInt64LE=Y((function(e){D(e>>>=0,"offset");let t=this[e],r=this[e+7];(void 0===t||void 0===r)&&F(e,this.length-8);let n=t+256*this[++e]+65536*this[++e]+this[++e]*2**24,a=this[++e]+256*this[++e]+65536*this[++e]+r*2**24;return BigInt(n)+(BigInt(a)<<BigInt(32))})),s.prototype.readBigUInt64BE=Y((function(e){D(e>>>=0,"offset");let t=this[e],r=this[e+7];(void 0===t||void 0===r)&&F(e,this.length-8);let n=t*2**24+65536*this[++e]+256*this[++e]+this[++e],a=this[++e]*2**24+65536*this[++e]+256*this[++e]+r;return(BigInt(n)<<BigInt(32))+BigInt(a)})),s.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||R(e,t,this.length);let n=this[e],a=1,i=0;for(;++i<t&&(a*=256);)n+=this[e+i]*a;return a*=128,n>=a&&(n-=Math.pow(2,8*t)),n},s.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||R(e,t,this.length);let n=t,a=1,i=this[e+--n];for(;n>0&&(a*=256);)i+=this[e+--n]*a;return a*=128,i>=a&&(i-=Math.pow(2,8*t)),i},s.prototype.readInt8=function(e,t){return e>>>=0,t||R(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},s.prototype.readInt16LE=function(e,t){e>>>=0,t||R(e,2,this.length);let r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(e,t){e>>>=0,t||R(e,2,this.length);let r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(e,t){return e>>>=0,t||R(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},s.prototype.readInt32BE=function(e,t){return e>>>=0,t||R(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},s.prototype.readBigInt64LE=Y((function(e){D(e>>>=0,"offset");let t=this[e],r=this[e+7];(void 0===t||void 0===r)&&F(e,this.length-8);let n=this[e+4]+256*this[e+5]+65536*this[e+6]+(r<<24);return(BigInt(n)<<BigInt(32))+BigInt(t+256*this[++e]+65536*this[++e]+this[++e]*2**24)})),s.prototype.readBigInt64BE=Y((function(e){D(e>>>=0,"offset");let t=this[e],r=this[e+7];(void 0===t||void 0===r)&&F(e,this.length-8);let n=(t<<24)+65536*this[++e]+256*this[++e]+this[++e];return(BigInt(n)<<BigInt(32))+BigInt(this[++e]*2**24+65536*this[++e]+256*this[++e]+r)})),s.prototype.readFloatLE=function(e,t){return e>>>=0,t||R(e,4,this.length),r.read(this,e,!0,23,4)},s.prototype.readFloatBE=function(e,t){return e>>>=0,t||R(e,4,this.length),r.read(this,e,!1,23,4)},s.prototype.readDoubleLE=function(e,t){return e>>>=0,t||R(e,8,this.length),r.read(this,e,!0,52,8)},s.prototype.readDoubleBE=function(e,t){return e>>>=0,t||R(e,8,this.length),r.read(this,e,!1,52,8)},s.prototype.writeUintLE=s.prototype.writeUIntLE=function(e,t,r,n){e=+e,t>>>=0,r>>>=0,n||I(this,e,t,r,Math.pow(2,8*r)-1,0);let a=1,i=0;for(this[t]=255&e;++i<r&&(a*=256);)this[t+i]=e/a&255;return t+r},s.prototype.writeUintBE=s.prototype.writeUIntBE=function(e,t,r,n){e=+e,t>>>=0,r>>>=0,n||I(this,e,t,r,Math.pow(2,8*r)-1,0);let a=r-1,i=1;for(this[t+a]=255&e;--a>=0&&(i*=256);)this[t+a]=e/i&255;return t+r},s.prototype.writeUint8=s.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||I(this,e,t,1,255,0),this[t]=255&e,t+1},s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||I(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||I(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||I(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||I(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},s.prototype.writeBigUInt64LE=Y((function(e,t=0){return B(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))})),s.prototype.writeBigUInt64BE=Y((function(e,t=0){return U(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))})),s.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){let n=Math.pow(2,8*r-1);I(this,e,t,r,n-1,-n)}let a=0,i=1,s=0;for(this[t]=255&e;++a<r&&(i*=256);)e<0&&0===s&&0!==this[t+a-1]&&(s=1),this[t+a]=(e/i|0)-s&255;return t+r},s.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){let n=Math.pow(2,8*r-1);I(this,e,t,r,n-1,-n)}let a=r-1,i=1,s=0;for(this[t+a]=255&e;--a>=0&&(i*=256);)e<0&&0===s&&0!==this[t+a+1]&&(s=1),this[t+a]=(e/i|0)-s&255;return t+r},s.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||I(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},s.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||I(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},s.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||I(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},s.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||I(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},s.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||I(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},s.prototype.writeBigInt64LE=Y((function(e,t=0){return B(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),s.prototype.writeBigInt64BE=Y((function(e,t=0){return U(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),s.prototype.writeFloatLE=function(e,t,r){return N(this,e,t,!0,r)},s.prototype.writeFloatBE=function(e,t,r){return N(this,e,t,!1,r)},s.prototype.writeDoubleLE=function(e,t,r){return P(this,e,t,!0,r)},s.prototype.writeDoubleBE=function(e,t,r){return P(this,e,t,!1,r)},s.prototype.copy=function(e,t,r,n){if(!s.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),!n&&0!==n&&(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r||0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);let a=n-r;return this===e&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(t,r,n):Uint8Array.prototype.set.call(e,this.subarray(r,n),t),a},s.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===e.length){let t=e.charCodeAt(0);("utf8"===n&&t<128||"latin1"===n)&&(e=t)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;let a;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(a=t;a<r;++a)this[a]=e;else{let i=s.isBuffer(e)?e:s.from(e,n),o=i.length;if(0===o)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(a=0;a<r-t;++a)this[a+t]=i[a%o]}return this};var L={};function $(e,t,r){L[e]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(e){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:e,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}function M(e){let t="",r=e.length,n="-"===e[0]?1:0;for(;r>=n+4;r-=3)t=`_${e.slice(r-3,r)}${t}`;return`${e.slice(0,r)}${t}`}function Z(e,t,r,n,a,i){if(e>r||e<t){let n,a="bigint"==typeof t?"n":"";throw n=i>3?0===t||t===BigInt(0)?`>= 0${a} and < 2${a} ** ${8*(i+1)}${a}`:`>= -(2${a} ** ${8*(i+1)-1}${a}) and < 2 ** ${8*(i+1)-1}${a}`:`>= ${t}${a} and <= ${r}${a}`,new L.ERR_OUT_OF_RANGE("value",n,e)}!function(e,t,r){D(t,"offset"),(void 0===e[t]||void 0===e[t+r])&&F(t,e.length-(r+1))}(n,a,i)}function D(e,t){if("number"!=typeof e)throw new L.ERR_INVALID_ARG_TYPE(t,"number",e)}function F(e,t,r){throw Math.floor(e)!==e?(D(e,r),new L.ERR_OUT_OF_RANGE(r||"offset","an integer",e)):t<0?new L.ERR_BUFFER_OUT_OF_BOUNDS:new L.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${t}`,e)}$("ERR_BUFFER_OUT_OF_BOUNDS",(function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),$("ERR_INVALID_ARG_TYPE",(function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`}),TypeError),$("ERR_OUT_OF_RANGE",(function(e,t,r){let n=`The value of "${e}" is out of range.`,a=r;return Number.isInteger(r)&&Math.abs(r)>2**32?a=M(String(r)):"bigint"==typeof r&&(a=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(a=M(a)),a+="n"),n+=` It must be ${t}. Received ${a}`,n}),RangeError);var z=/[^+/0-9A-Za-z-_]/g;function K(e,t){t=t||1/0;let r,n=e.length,a=null,i=[];for(let s=0;s<n;++s){if(r=e.charCodeAt(s),r>55295&&r<57344){if(!a){if(r>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&i.push(239,191,189);continue}a=r;continue}if(r<56320){(t-=3)>-1&&i.push(239,191,189),a=r;continue}r=65536+(a-55296<<10|r-56320)}else a&&(t-=3)>-1&&i.push(239,191,189);if(a=null,r<128){if((t-=1)<0)break;i.push(r)}else if(r<2048){if((t-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function q(e){return t.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(z,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function H(e,t,r,n){let a;for(a=0;a<n&&!(a+r>=t.length||a>=e.length);++a)t[a+r]=e[a];return a}function G(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function V(e){return e!=e}var W=function(){let e="0123456789abcdef",t=new Array(256);for(let r=0;r<16;++r){let n=16*r;for(let a=0;a<16;++a)t[n+a]=e[r]+e[a]}return t}();function Y(e){return typeof BigInt>"u"?J:e}function J(){throw new Error("BigInt not supported")}})),Lc=Sc(((e,t)=>{typeof window<"u"?(window.global=window,global.fetch=window.fetch,t.exports={Buffer:Pc().Buffer,Crypto:window.crypto}):t.exports={Buffer:Pc().Buffer,Crypto:crypto}})),$c={};((e,t)=>{for(var r in t)Tc(e,r,{get:t[r],enumerable:!0})})($c,{AVSCTap:()=>tl,ArweaveSigner:()=>Jc,DataItem:()=>hl,MAX_TAG_BYTES:()=>cl,MIN_BINARY_SIZE:()=>ll,SIG_CONFIG:()=>Yc,SignatureConfig:()=>qc,Signer:()=>Mc,createData:()=>fl,deserializeTags:()=>al,indexToType:()=>Qc,serializeTags:()=>rl,tagsExceedLimit:()=>nl});var Mc=class{signer;publicKey;signatureType;signatureLength;ownerLength;pem;static verify(e,t,r,n){throw new Error("You must implement verify method on child")}},Zc=Oc(Ic(),1),Dc=Oc(Uc(),1);async function Fc(e){if(Array.isArray(e)){let t=(0,Dc.concatBuffers)([(0,Dc.stringToBuffer)("list"),(0,Dc.stringToBuffer)(e.length.toString())]);return await zc(e,await Wc().hash(t,"SHA-384"))}let t=e,r=(0,Dc.concatBuffers)([(0,Dc.stringToBuffer)("blob"),(0,Dc.stringToBuffer)(t.byteLength.toString())]),n=(0,Dc.concatBuffers)([await Wc().hash(r,"SHA-384"),await Wc().hash(t,"SHA-384")]);return await Wc().hash(n,"SHA-384")}async function zc(e,t){if(e.length<1)return t;let r=(0,Dc.concatBuffers)([t,await Fc(e[0])]),n=await Wc().hash(r,"SHA-384");return await zc(e.slice(1),n)}var Kc,qc,Hc=Oc(jc(),1),Gc=Hc.default.default?Hc.default.default:Hc.default,Vc=class extends Gc{getPublicKey(e){throw new Error("Unimplemented")}};function Wc(){return Kc??=new Vc}!function(e){e[e.ARWEAVE=1]="ARWEAVE",e[e.ED25519=2]="ED25519",e[e.ETHEREUM=3]="ETHEREUM",e[e.SOLANA=4]="SOLANA",e[e.INJECTEDAPTOS=5]="INJECTEDAPTOS",e[e.MULTIAPTOS=6]="MULTIAPTOS",e[e.TYPEDETHEREUM=7]="TYPEDETHEREUM"}(qc||(qc={}));var Yc={[qc.ARWEAVE]:{sigLength:512,pubLength:512,sigName:"arweave"},[qc.ED25519]:{sigLength:64,pubLength:32,sigName:"ed25519"},[qc.ETHEREUM]:{sigLength:65,pubLength:65,sigName:"ethereum"},[qc.SOLANA]:{sigLength:64,pubLength:32,sigName:"solana"},[qc.INJECTEDAPTOS]:{sigLength:64,pubLength:32,sigName:"injectedAptos"},[qc.MULTIAPTOS]:{sigLength:2052,pubLength:1025,sigName:"multiAptos"},[qc.TYPEDETHEREUM]:{sigLength:65,pubLength:42,sigName:"typedEthereum"}},Jc=class{signatureType=1;ownerLength=Yc[1].pubLength;signatureLength=Yc[1].sigLength;jwk;pk;constructor(e){this.pk=e.n,this.jwk=e}get publicKey(){return Zc.default.toBuffer(this.pk)}sign(e){return Wc().sign(this.jwk,e)}static async verify(e,t,r){return await Wc().verify(e,t,r)}},Qc={1:Jc},Xc=Oc(Ic(),1);async function el(e){return Fc([(0,Dc.stringToBuffer)("dataitem"),(0,Dc.stringToBuffer)("1"),(0,Dc.stringToBuffer)(e.signatureType.toString()),e.rawOwner,e.rawTarget,e.rawAnchor,e.rawTags,e.rawData])}var tl=class{buf;pos;constructor(e=Buffer.alloc(cl),t=0){this.buf=e,this.pos=t}writeTags(e){if(!Array.isArray(e))throw new Error("input must be array");let t,r=e.length;if(r)for(this.writeLong(r),t=0;t<r;t++){let r=e[t];if(void 0===r?.name||void 0===r?.value)throw new Error(`Invalid tag format for ${r}, expected {name:string, value: string}`);this.writeString(r.name),this.writeString(r.value)}this.writeLong(0)}toBuffer(){let e=Buffer.alloc(this.pos);if(this.pos>this.buf.length)throw new Error(`Too many tag bytes (${this.pos} > ${this.buf.length})`);return this.buf.copy(e,0,0,this.pos),e}tagsExceedLimit(){return this.pos>this.buf.length}writeLong(e){let t,r,n=this.buf;if(e>=-1073741824&&e<1073741824){r=e>=0?e<<1:~e<<1|1;do{n[this.pos]=127&r,r>>=7}while(r&&(n[this.pos++]|=128))}else{t=e>=0?2*e:2*-e-1;do{n[this.pos]=127&t,t/=128}while(t>=1&&(n[this.pos++]|=128))}this.pos++,this.buf=n}writeString(e){let t=Buffer.byteLength(e),r=this.buf;this.writeLong(t);let n=this.pos;if(this.pos+=t,!(this.pos>r.length)){if(t>64)this.buf.write(e,this.pos-t,t,"utf8");else{let a,i,s,o;for(a=0,i=t;a<i;a++)s=e.charCodeAt(a),s<128?r[n++]=s:s<2048?(r[n++]=s>>6|192,r[n++]=63&s|128):55296==(64512&s)&&56320==(64512&(o=e.charCodeAt(a+1)))?(s=65536+((1023&s)<<10)+(1023&o),a++,r[n++]=s>>18|240,r[n++]=s>>12&63|128,r[n++]=s>>6&63|128,r[n++]=63&s|128):(r[n++]=s>>12|224,r[n++]=s>>6&63|128,r[n++]=63&s|128)}this.buf=r}}readLong(){let e,t,r,n,a=0,i=0,s=this.buf;do{e=s[this.pos++],t=128&e,a|=(127&e)<<i,i+=7}while(t&&i<28);if(t){r=a,n=268435456;do{e=s[this.pos++],r+=(127&e)*n,n*=128}while(128&e);return(r%2?-(r+1):r)/2}return a>>1^-(1&a)}skipLong(){let e=this.buf;for(;128&e[this.pos++];);}readTags(){let e,t=[];for(;e=this.readLong();)for(e<0&&(e=-e,this.skipLong());e--;){let e=this.readString(),r=this.readString();t.push({name:e,value:r})}return t}readString(){let e=this.readLong(),t=this.pos,r=this.buf;if(this.pos+=e,!(this.pos>r.length))return this.buf.slice(t,t+e).toString()}};function rl(e){let t=new tl;return t.writeTags(e),t.toBuffer()}function nl(e){let t=new tl;return t.writeTags(e),t.tagsExceedLimit()}function al(e){return new tl(e).readTags()}function il(e){let t=0;for(let r=e.length-1;r>=0;r--)t=256*t+e[r];return t}function sl(e){let t=[0,0,0,0,0,0,0,0];for(let r=0;r<t.length;r++){let n=255&e;t[r]=n,e=(e-n)/256}return Uint8Array.from(t)}var ol=Oc(Lc(),1),ul=Oc(Pc(),1),cl=4096,ll=80,hl=class{binary;_id;constructor(e){this.binary=e}static isDataItem(e){return void 0!==e.binary}get signatureType(){let e=il(this.binary.subarray(0,2));if(void 0!==qc?.[e])return e;throw new Error("Unknown signature type: "+e)}async isValid(){return hl.verify(this.binary)}get id(){return(async()=>Xc.default.encode(await this.rawId))()}set id(e){this._id=Xc.default.toBuffer(e)}get rawId(){return(async()=>ul.Buffer.from(await ol.Crypto.subtle.digest("SHA-256",this.rawSignature)))()}set rawId(e){this._id=e}get rawSignature(){return this.binary.subarray(2,2+this.signatureLength)}get signature(){return Xc.default.encode(this.rawSignature)}set rawOwner(e){if(e.byteLength!=this.ownerLength)throw new Error(`Expected raw owner (pubkey) to be ${this.ownerLength} bytes, got ${e.byteLength} bytes.`);this.binary.set(e,2+this.signatureLength)}get rawOwner(){return this.binary.subarray(2+this.signatureLength,2+this.signatureLength+this.ownerLength)}get signatureLength(){return Yc[this.signatureType].sigLength}get owner(){return Xc.default.encode(this.rawOwner)}get ownerLength(){return Yc[this.signatureType].pubLength}get rawTarget(){let e=this.getTargetStart();return 1==this.binary[e]?this.binary.subarray(e+1,e+33):ul.Buffer.alloc(0)}get target(){return Xc.default.encode(this.rawTarget)}get rawAnchor(){let e=this.getAnchorStart();return 1==this.binary[e]?this.binary.subarray(e+1,e+33):ul.Buffer.alloc(0)}get anchor(){return this.rawAnchor.toString()}get rawTags(){let e=this.getTagsStart(),t=il(this.binary.subarray(e+8,e+16));return this.binary.subarray(e+16,e+16+t)}get tags(){let e=this.getTagsStart();if(0==il(this.binary.subarray(e,e+8)))return[];let t=il(this.binary.subarray(e+8,e+16));return al(ul.Buffer.from(this.binary.subarray(e+16,e+16+t)))}get tagsB64Url(){return this.tags.map((e=>({name:Xc.default.encode(e.name),value:Xc.default.encode(e.value)})))}getStartOfData(){let e=this.getTagsStart();return e+16+il(this.binary.subarray(e+8,e+16))}get rawData(){let e=this.getTagsStart(),t=e+16+il(this.binary.subarray(e+8,e+16));return this.binary.subarray(t,this.binary.length)}get data(){return Xc.default.encode(this.rawData)}getRaw(){return this.binary}async sign(e){return this._id=await async function(e,t){let{signature:r,id:n}=await async function(e,t){let r=await el(e),n=await t.sign(r),a=await Wc().hash(n);return{signature:Buffer.from(n),id:Buffer.from(a)}}(e,t);return e.getRaw().set(r,2),n}(this,e),this.rawId}async setSignature(e){this.binary.set(e,2),this._id=ul.Buffer.from(await Wc().hash(e))}isSigned(){return(this._id?.length??0)>0}toJSON(){return{signature:this.signature,owner:this.owner,target:this.target,tags:this.tags.map((e=>({name:Xc.default.encode(e.name),value:Xc.default.encode(e.value)}))),data:this.data}}static async verify(e){if(e.byteLength<ll)return!1;let t=new hl(e),r=t.signatureType,n=t.getTagsStart(),a=il(e.subarray(n,n+8)),i=il(e.subarray(n+8,n+16));if(i>cl)return!1;if(a>0)try{if(al(ul.Buffer.from(e.subarray(n+16,n+16+i))).length!==a)return!1}catch{return!1}let s=Qc[r],o=await el(t);return await s.verify(t.rawOwner,o,t.rawSignature)}async getSignatureData(){return el(this)}getTagsStart(){let e=this.getTargetStart(),t=e+(1==this.binary[e]?33:1);return t+=1==this.binary[t]?33:1,t}getTargetStart(){return 2+this.signatureLength+this.ownerLength}getAnchorStart(){let e=this.getTargetStart()+1;return e+=1==this.binary[this.getTargetStart()]?32:0,e}},dl=Oc(Ic(),1);function fl(e,t,r){let n=t.publicKey,a=r?.target?dl.default.toBuffer(r.target):null,i=1+(a?.byteLength??0),s=r?.anchor?Buffer.from(r.anchor):null,o=1+(s?.byteLength??0),u=(r?.tags?.length??0)>0?rl(r.tags):null,c=16+(u?u.byteLength:0),l=Buffer.from(e),h=l.byteLength,d=2+t.signatureLength+t.ownerLength+i+o+c+h,f=Buffer.alloc(d);if(f.set(function(e){if(e>29)throw new Error("Short too long");let t=[0,0];for(let r=0;r<t.length;r++){let n=255&e;t[r]=n,e=(e-n)/256}return Uint8Array.from(t)}(t.signatureType),0),f.set(new Uint8Array(t.signatureLength).fill(0),2),n.byteLength!==t.ownerLength)throw new Error(`Owner must be ${t.ownerLength} bytes, but was incorrectly ${n.byteLength}`);f.set(n,2+t.signatureLength);let p=2+t.signatureLength+t.ownerLength;if(f[p]=a?1:0,a){if(32!==a.byteLength)throw new Error(`Target must be 32 bytes but was incorrectly ${a.byteLength}`);f.set(a,p+1)}let g=p+i,y=g+1;if(f[g]=s?1:0,s){if(y+=s.byteLength,32!==s.byteLength)throw new Error("Anchor must be 32 bytes");f.set(s,g+1)}f.set(sl(r?.tags?.length??0),y);let m=sl(u?.byteLength??0);f.set(m,y+8),u&&f.set(u,y+16);let v=y+c;return f.set(l,v),new hl(f)}var pl={...$c};globalThis.arbundles??=pl;var gl=pl,yl=pl;globalThis.Buffer||(globalThis.Buffer=wc.Buffer);var{DataItem:ml}=bc;function vl(e){return async({data:t,tags:r,target:n,anchor:a,createDataItem:i=e=>new ml(e)})=>{const s=await e.signDataItem({data:t,tags:r,target:n,anchor:a}),o=i(wc.Buffer.from(s));return{id:await o.id,raw:await o.getRaw()}}}var wl=globalThis.GATEWAY_URL||void 0,bl=globalThis.MU_URL||void 0,_l=globalThis.CU_URL||void 0,Tl=globalThis.GRAPHQL_URL||void 0,El=globalThis.GRAPHQL_MAX_RETRIES||void 0,kl=globalThis.GRAPHQL_RETRY_BACKOFF||void 0,{result:Al,results:xl,message:Sl,spawn:Ol,monitor:Cl,unmonitor:Rl,dryrun:Il,assign:Bl}=mc({GATEWAY_URL:wl,MU_URL:bl,CU_URL:_l,GRAPHQL_URL:Tl,GRAPHQL_MAX_RETRIES:El,GRAPHQL_RETRY_BACKOFF:kl}),Ul=vc.createDataItemSigner;const jl={module:"Do_Uc2Sju_ffp6Ev0AnLVdPtot15rvMjP-a9VVaA5fM",scheduler:"_GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA",mu:"fcoN_xJeisVsPXA-trzVAuIiqO3ydLQxM-L4XbrQKzY",src:{asset:"gyvfBebLlNJw0_bdq6NLL_BK_dqpgj9nRTYebyoOmKI",zone:"UmDqxL8ufIj2Zj9eKDQfDj_hyJ8rWZn7VaTgpyeRT94"}},Nl={"application/json":{type:"application/json",serialize:e=>JSON.stringify(e)}},Pl={arweave:"arweave.net",goldsky:"arweave-search.goldsky.com"},Ll={udl:{label:"Universal Data License",address:"dE0rmDfl9_OWjkDznNEXHaSO_JohJkRolvMzaCroUdw"}},$l={keys:{access:"Access-Fee",banner:"Banner",bootloader:"Bootloader",bootloaderInit:"On-Boot",collectionId:"Collection-Id",collectionName:"Collection-Name",commericalUse:"Commercial-Use",contentType:"Content-Type",creator:"Creator",currency:"Currency",dataModelTraining:"Data-Model-Training",dataProtocol:"Data-Protocol",dateCreated:"Date-Created",derivations:"Derivations",description:"Description",displayName:"Display-Name",handle:"Handle",implements:"Implements",initialOwner:"Initial-Owner",license:"License",name:"Name",paymentAddress:"Payment-Address",paymentMode:"Payment-Mode",profileIndex:"Profile-Index",protocolName:"Protocol-Name",renderWith:"Render-With",thumbnail:"Thumbnail",title:"Title",topic:"Topic",type:"Type",zoneType:"Zone-Type"}},Ml={node1:"https://up.arweave.net",node2:"https://turbo.ardrive.io",batchSize:1,chunkSize:75e5,dispatchUploadSize:102400};function Zl(e){return!!e&&/^[a-z0-9_-]{43}$/i.test(e)}function Dl(e,t){if(!e)return"";if(!Zl(e))return e;const r=e.substring(0,5)+"..."+e.substring(36,e.length);return t?`(${r})`:r}function Fl(e,t){for(let r=0;r<e.length;r++)if(e[r]&&e[r].name===t)return e[r].value;return null}function zl(e){if("0"===e||!Number(e))return"0";if(e.includes(".")){let t=e.split(".");t[0]=t[0].replace(/\B(?=(\d{3})+(?!\d))/g,",");let r=0;for(let e=0;e<Math.min(t[1].length,6);e++)"0"!==t[1][e]&&(r=e+1);return 0===r?t[1]="00":(t[1]=t[1].substring(0,r),t[1].length>4&&"0000"!==t[1].substring(0,4)&&(t[1]=t[1].substring(0,4))),t.join(".")}return e.replace(/\B(?=(\d{3})+(?!\d))/g,",")}function Kl(e){if(isNaN(e))return"0%";let t=100*e,r=t.toString().split(".")[1];if(!r)return`${t.toFixed(0)}%`;if(r.length>6&&"000000"===r.substring(0,6))return`${t.toFixed(0)}%`;let n=r.length;for(let e=0;e<r.length;e++)if("0"!==r[e]){n=e+1;break}return`${t.toFixed(n)}%`}function ql(e,t,r){if(!e)return null;let n=null;switch(t){case"iso":default:n=new Date(e);break;case"epoch":n=new Date(Number(e))}return r?`${n.toLocaleString("default",{month:"long"})} ${n.getDate()}, ${n.getUTCFullYear()} at ${n.getHours()%12||12}:${n.getMinutes().toString().padStart(2,"0")} ${n.getHours()>=12?"PM":"AM"}`:`${n.toLocaleString("default",{month:"long"})} ${n.getDate()}, ${n.getUTCFullYear()}`}function Hl(e){if(!e)return"-";const t=new Date,r=new Date(e),n=t.getTime()-r.getTime(),a=Math.floor(n/1e3),i=Math.floor(a/60),s=Math.floor(i/60),o=Math.floor(s/24),u=Math.floor(o/30.44),c=Math.floor(u/12);return c>0?`${c} year${c>1?"s":""} ago`:u>0?`${u} month${u>1?"s":""} ago`:o>0?`${o} day${o>1?"s":""} ago`:s>0?`${s} hour${s>1?"s":""} ago`:i>0?`${i} minute${i>1?"s":""} ago`:`${a} second${1!==a?"s":""} ago`}function Gl(e){return`${e} *`}function Vl(e){let t=e.split("-"),r=t[t.length-1];return t=isNaN(r)?t.join(" "):t.slice(0,-1).join(" ")+": "+r,t}function Wl(e){let t=e.replace(/([A-Z])/g," $1").trim();return t=t.charAt(0).toUpperCase()+t.slice(1),t}function Yl(e){const t=e.match(/^data:([a-zA-Z0-9]+\/[a-zA-Z0-9-.+]+);base64,/);return t?t[1]:null}function Jl(e){return e.split(",")[1]}function Ql(e){let t;if(Buffer.isBuffer(e))t=e.length;else{if("string"!=typeof e)throw new Error("Input must be a string or a Buffer");t=Buffer.byteLength(e,"utf-8")}return t}function Xl(e){return e?(e.profileBalance||0)+(e.walletBalance||0):null}function eh(){return"undefined"!=typeof InstallTrigger}function th(e){let t=0;for(;e>0&&e%10==0;)t++,e/=10;return t}function rh(e){let t;return t=e.replace(/\[|\]/g,""),t}function nh(e,t){if(!t)return[];const r=`${e}:`;return Object.keys(t).filter((e=>e.startsWith(r))).map((e=>t[e]))}function ah(e,t){return`${e}:${t.toLowerCase().replace(/\s+/g,"-")}`}const ih=(...e)=>{console.log("[@permaweb/libs]",...e)};function sh(e){return Array.isArray(e)?e.map(sh):e&&"object"==typeof e?Object.entries(e).reduce(((e,[t,r])=>(e[t.replace(/^[a-z]/,(e=>e.toUpperCase()))]=sh(r),e)),{}):e}function oh(e){return Array.isArray(e)?e.map(oh):e&&"object"==typeof e?Object.entries(e).reduce(((e,[t,r])=>{var n;return e[(n=t).charAt(0).toLowerCase()+n.slice(1)]=oh(r),e}),{}):e}function uh(e,t){return{name:`${$l.keys.bootloader}-${e}`,value:t}}const ch="https://arweave.net";function lh(e){return`${ch}/wallet/${e}/balance`}function hh(e){return`${ch}/${e}`}function dh(e,t){return Zl(e)?`${ch}/${e}/?tx=${t}`:`https://${e}.arweave.net/?tx=${t}`}const fh={p1:"P1",end:"END"},ph={default:100};async function gh(e){const t=e.paginator?e.paginator:ph.default;let r=[],n=0,a=null;if(e.ids&&!e.ids.length)return{data:r,count:n,nextCursor:a,previousCursor:null};try{let i=vh(e);const s=await wh({gateway:e.gateway,query:mh(i)});return s.data.transactions.edges.length?(r=[...s.data.transactions.edges],n=s.data.transactions.count??0,a=r.length<t||!s.data.transactions.pageInfo.hasNextPage?fh.end:r[r.length-1].cursor,{data:r,count:n,nextCursor:a,previousCursor:null}):{data:r,count:n,nextCursor:a,previousCursor:null}}catch(e){return console.error(e),{data:r,count:n,nextCursor:a,previousCursor:null}}}async function yh(e){let t={},r="";for(const[n,a]of Object.entries(e.entries))t[n]={data:[],count:0,nextCursor:null,previousCursor:null},r+=vh({...a,gateway:e.gateway,queryKey:n});try{const n=await wh({gateway:e.gateway,query:mh(r)});if(n&&n.data)for(const r of Object.keys(n.data)){const a=e.entries[r].paginator?e.entries[r].paginator:ph.default;let i=[],s=0,o=null;n.data[r].edges.length&&(i=[...n.data[r].edges],s=n.data[r].count??0,o=i.length<a||!n.data[r].pageInfo.hasNextPage?fh.end:i[i.length-1].cursor,t[r]={data:[...n.data[r].edges],count:s,nextCursor:o,previousCursor:null})}return t}catch(e){return console.error(e),t}}function mh(e){const t={query:`query { ${e} }`};return JSON.stringify(t)}function vh(e){const t=e.paginator?e.paginator:ph.default,r=e.ids?JSON.stringify(e.ids):null;let n=null;void 0!==e.minBlock&&null!==e.minBlock&&(n={},n.min=e.minBlock);const a=n?JSON.stringify(n).replace(/"([^"]+)":/g,"$1:"):null,i=e.tags?JSON.stringify(e.tags).replace(/"(name)":/g,"$1:").replace(/"(values)":/g,"$1:").replace(/"FUZZY_OR"/g,"FUZZY_OR"):null,s=e.owners?JSON.stringify(e.owners):null,o=e.cursor&&e.cursor!==fh.end?`"${e.cursor}"`:null;let u=`first: ${t}`,c="";switch(e.gateway){case Pl.arweave:break;case Pl.goldsky:c="count"}let l=`\n\t\ttransactions(\n\t\t\t\tids: ${r},\n\t\t\t\ttags: ${i},\n\t\t\t\t${u}\n\t\t\t\towners: ${s},\n\t\t\t\tblock: ${a},\n\t\t\t\tafter: ${o},\n\t\t\t\t\n\t\t\t\t\n\t\t\t){\n\t\t\t${c}\n\t\t\t\tpageInfo {\n\t\t\t\t\thasNextPage\n\t\t\t\t}\n\t\t\t\tedges {\n\t\t\t\t\tcursor\n\t\t\t\t\tnode {\n\t\t\t\t\t\tid\n\t\t\t\t\t\ttags {\n\t\t\t\t\t\t\tname \n\t\t\t\t\t\t\tvalue \n\t\t\t\t\t\t}\n\t\t\t\t\t\tdata { size type } owner { address } block { height timestamp }\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t}`;return e.queryKey&&(l=`${e.queryKey}: ${l}`),l}async function wh(e){try{const t=await fetch(`https://${e.gateway}/graphql`,{method:"POST",headers:{"Content-Type":"application/json"},body:e.query});return await t.json()}catch(e){throw e}}const bh=Pl.goldsky,_h=1e3,{result:Th,results:Eh,message:kh,spawn:Ah,dryrun:xh}=mc({GATEWAY_URL:`https://${bh}`});async function Sh(e){const t=[{name:"Authority",value:jl.mu}];e.tags&&e.tags.length>0&&e.tags.forEach((e=>t.push(e)));try{return await Ah({module:e.module,scheduler:e.scheduler,signer:Ul(e.wallet),tags:t,data:e.data})}catch(e){throw new Error(e.message??"Error spawning process")}}async function Oh(e){try{const t=[{name:"Action",value:e.action}];e.tags&&t.push(...e.tags);const r=e.useRawData?e.data:JSON.stringify(e.data);return await kh({process:e.processId,signer:Ul(e.wallet),tags:t,data:r})}catch(e){throw new Error(e)}}async function Ch(e){try{const t=[{name:"Action",value:e.action}];let r;if(e.tags&&t.push(...e.tags),"object"==typeof e.data)r=JSON.stringify(e.data||{});else if("string"==typeof e.data){try{JSON.parse(e.data)}catch(e){throw console.error(e),new Error("Invalid JSON data")}r=e.data}const n=await xh({process:e.processId,tags:t,data:r});if(n.Messages&&n.Messages.length){if(n.Messages[0].Data)return JSON.parse(n.Messages[0].Data);if(n.Messages[0].Tags)return n.Messages[0].Tags.reduce(((e,t)=>(e[t.name]=t.value,e)),{})}}catch(e){throw new Error(e.message??"Error dryrunning process")}}async function Rh(e){try{const{Messages:t}=await Th({message:e.messageId,process:e.processId});if(t&&t.length){const r={};return t.forEach((t=>{const n=Fl(t.Tags,"Action")||e.action;let a=null;const i=t.Data;if(i)try{a=JSON.parse(i)}catch{a=i}const s=Fl(t.Tags,"Status"),o=Fl(t.Tags,"Message");r[n]={id:e.messageId,status:s,message:o,data:a}})),r}return null}catch(e){console.error(e)}}async function Ih(e){try{const t=[{name:"Action",value:e.action}];e.tags&&t.push(...e.tags),await kh({process:e.processId,signer:Ul(e.wallet),tags:t,data:JSON.stringify(e.data)}),await new Promise((e=>setTimeout(e,1e3)));const r=await Eh({process:e.processId,sort:"DESC",limit:100});if(r&&r.edges&&r.edges.length){const t={};for(const n of r.edges)if(n.node&&n.node.Messages&&n.node.Messages.length){const r=[e.action];e.responses&&r.push(...e.responses);for(const a of n.node.Messages){const n=Fl(a.Tags,"Action");if(n){let i=null;const s=a.Data;if(s)try{i=JSON.parse(s)}catch{i=s}const o=Fl(a.Tags,"Status"),u=Fl(a.Tags,"Message");if("Action-Response"===n){const r=Fl(a.Tags,"Handler");e.handler&&e.handler===r&&(t[n]={status:o,message:u,data:i})}else-1!==r.indexOf(n)&&(t[n]={status:o,message:u,data:i});if(Object.keys(t).length===r.length)break}}}return t}return null}catch(e){console.error(e)}}async function Bh(e,t){let r=0;for(;r<_h;){await new Promise((e=>setTimeout(e,2e3)));const t=await gh({gateway:bh,ids:[e]});if(t?.data?.length){const e=t.data[0].node.id;return ih(`Fetched transaction: ${e} (Try ${r+1})`),e}ih(`Transaction not found: ${e} (Try ${r+1})`),r++}throw new Error("Process not found, please try again")}async function Uh(e){try{const t=await fetch(hh(e));return await t.text()}catch(e){throw new Error(e)}}async function jh(e){let t=null;if(e.evalSrc?t=e.evalSrc:e.evalTxId&&(t=await Uh(e.evalTxId)),t)try{const r=await Oh({processId:e.processId,wallet:e.wallet,action:"Eval",data:t,tags:e.evalTags||null,useRawData:!0});return ih(`Eval: ${r}`),await Rh({processId:e.processId,messageId:r,action:"Eval"})}catch(e){throw new Error(e.message??"Error sending process eval")}return null}async function Nh(e,t){try{const r={module:e.module||jl.module,scheduler:e.scheduler||jl.scheduler,wallet:e.wallet};e.spawnData&&(r.data=e.spawnData),e.spawnTags&&(r.tags=e.spawnTags),t&&t("Spawning process...");const n=await Sh(r);if(e.evalTxId||e.evalSrc){t&&t("Retrieving process..."),await Bh(n),t&&t("Process retrieved!"),t&&t("Sending eval...");try{await jh({processId:n,evalTxId:e.evalTxId||null,evalSrc:e.evalSrc||null,evalTags:e.evalTags,wallet:e.wallet})&&t&&t("Eval complete")}catch(e){throw new Error(e.message??"Error creating process")}}return n}catch(e){throw new Error(e.message??"Error creating process")}}var Ph=r(69),Lh=r.n(Ph);async function $h(e){let t=null,n=null;try{"string"==typeof e.data&&e.data.startsWith("data:")&&(t=Buffer.from(Jl(e.data),"base64"),n=Yl(e.data))}catch(e){throw new Error(e)}if(t&&n){const a=Ql(t);if(ih(`Content upload size: ${a}`),a<Number(Ml.dispatchUploadSize)){const a=await Lh().init({}).createTransaction({data:t},"use_wallet");return a.addTag($l.keys.contentType,n),e.tags&&e.tags.length>0&&e.tags.forEach((e=>a.addTag(e.name,e.value))),(await r.g.window.arweaveWallet.dispatch(a)).id}throw new Error("Data exceeds max upload limit")}throw new Error("Error preparing transaction data")}async function Mh(e){if(Zl(e))return e;try{return await $h({data:e})}catch(e){throw new Error(e.message??"Error resolving transaction")}}async function Zh(e,t,r){const n=function(e){if("object"!=typeof e||null===e)return"The provided arguments are invalid or empty.";const t=["title","description","type","topics","contentType","data"];for(const r of t)if(!(r in e))return`Missing field '${r}'.`;return"string"!=typeof e.title||""===e.title.trim()?"Title is required":"string"!=typeof e.description?"The description must be a valid string":"string"!=typeof e.type||""===e.type.trim()?"Type must be a non-empty string":Array.isArray(e.topics)&&0!==e.topics.length?"string"!=typeof e.contentType||""===e.contentType.trim()?"Content type must be a non-empty string":void 0===e.data||null===e.data?"The data field is required":"creator"in e&&"string"!=typeof e.creator?"Creator must be a valid string":"collectionId"in e&&"string"!=typeof e.collectionId?"Collection ID must be a valid string":"renderWith"in e&&"string"!=typeof e.renderWith?"Render with value must be a valid string":"thumbnail"in e&&"string"!=typeof e.thumbnail?"Thumbnail must be a valid string":"supply"in e&&("number"!=typeof e.supply||e.supply<=0)?"Supply must be a positive number":"transferable"in e&&"boolean"!=typeof e.transferable?"Transferable must be a boolean value":!("tags"in e)||Array.isArray(e.tags)&&!e.tags.some((e=>"object"!=typeof e))?"src"in e&&"string"!=typeof e.src?"Source must be a valid string":null:"Tags must be an array of objects":"Topics are required"}(e);if(n)throw new Error(n);const a=Nl[e.contentType]?.serialize(e.data)??e.data,i=[{name:$l.keys.bootloaderInit,value:jl.src.asset}];i.push(...function(e){const t=[{name:$l.keys.title,value:e.title},{name:$l.keys.description,value:e.description},{name:$l.keys.type,value:e.type},{name:$l.keys.contentType,value:e.contentType},{name:$l.keys.implements,value:"ANS-110"},{name:$l.keys.dateCreated,value:(new Date).getTime().toString()}];return e.topics.forEach((e=>t.push({name:$l.keys.topic,value:e}))),e.creator&&t.push({name:$l.keys.creator,value:e.creator}),e.collectionId&&t.push({name:$l.keys.collectionId,value:e.collectionId}),e.renderWith&&t.push({name:$l.keys.renderWith,value:e.renderWith}),e.thumbnail&&Zl(e.thumbnail)&&t.push({name:$l.keys.thumbnail,value:e.thumbnail}),e.tags&&e.tags.forEach((e=>t.push(e))),t}(e)),i.push(uh("Name",e.title)),i.push(uh("Ticker","ATOMIC")),i.push(uh("Denomination",e.denomination?e.denomination.toString():"1")),i.push(uh("TotalSupply",e.supply?e.supply.toString():"1")),e.creator&&i.push(uh("Creator",e.creator)),e.collectionId&&i.push(uh("Collection",e.collectionId)),e.transferable||i.push(uh("Transferable","false"));try{return await Nh({wallet:t,spawnTags:i,spawnData:a},r?e=>r(e):void 0)}catch(e){throw new Error(e.message??"Error creating asset")}}async function Dh(e){try{const t=await gh({gateway:Pl.goldsky,ids:[e],tags:null,owners:null,cursor:null});if(t&&t.data.length){const e=zh(t.data[0]);let r={ticker:null,denomination:null,balances:null,transferable:null};const n=await Ch({processId:e.id,action:"Info"});if(n){(n.Name||n.name)&&(e.title=n.Name||n.name),(n.Ticker||n.ticker)&&(r.ticker=n.Ticker||n.ticker),(n.Denomination||n.denomination)&&(r.denomination=n.Denomination||n.denomination),(n.Logo||n.logo)&&(e.thumbnail=n.Logo||n.logo),n.Balances&&(r.balances=Object.fromEntries(Object.entries(n.Balances).filter((([e,t])=>0!==Number(t))))),void 0!==n.Transferable?r.transferable=n.Transferable:r.transferable=!0;for(const[e,t]of Object.entries(n))e in r||(r[e]=t)}if(!r.balances)try{const t=await Ch({processId:e.id,action:"Balances"});t&&(r.balances=t)}catch(e){console.error(e)}return{...e,...oh(r)}}return null}catch(e){throw new Error(e.message||"Error fetching atomic asset")}}async function Fh(e){try{const t=await gh({gateway:Pl.arweave,ids:e??null,tags:null,owners:null,cursor:null});return t&&t.data.length?t.data.map((e=>zh(e))):null}catch(e){throw new Error(e)}}function zh(e){const t=new Set([$l.keys.creator,$l.keys.title,$l.keys.name,$l.keys.description,$l.keys.type,$l.keys.topic,$l.keys.implements,$l.keys.contentType,$l.keys.renderWith,$l.keys.thumbnail,$l.keys.license,$l.keys.access,$l.keys.derivations,$l.keys.commericalUse,$l.keys.dataModelTraining,$l.keys.paymentMode,$l.keys.paymentAddress,$l.keys.currency,$l.keys.collectionId,$l.keys.dateCreated]);return{id:e.node.id,owner:e.node.owner.address,creator:Fl(e.node.tags,$l.keys.creator),title:Kh(e),description:Fl(e.node.tags,$l.keys.description),type:Fl(e.node.tags,$l.keys.type),topics:qh(e),implementation:Fl(e.node.tags,$l.keys.implements),contentType:Fl(e.node.tags,$l.keys.contentType),renderWith:Fl(e.node.tags,$l.keys.renderWith),thumbnail:Fl(e.node.tags,$l.keys.thumbnail),udl:Gh(e),collectionId:Fl(e.node.tags,$l.keys.collectionId),dateCreated:Hh(e),blockHeight:e.node.block?e.node.block.height:0,tags:e.node.tags.filter((e=>!t.has(e.name)))}}function Kh(e){return Fl(e.node.tags,$l.keys.title)||Fl(e.node.tags,$l.keys.name)||Dl(e.node.id,!1)}function qh(e){return e.node.tags.filter((e=>e.name.includes($l.keys.topic.toLowerCase()))).map((e=>e.value))}function Hh(e){if(e.node.block)return 1e3*e.node.block.timestamp;const t=Fl(e.node.tags,$l.keys.dateCreated);return t?Number(t):0}function Gh(e){const t=Fl(e.node.tags,$l.keys.license);return t&&t===Ll.udl.address?{access:{value:Fl(e.node.tags,$l.keys.access)},derivations:{value:Fl(e.node.tags,$l.keys.derivations)},commercialUse:{value:Fl(e.node.tags,$l.keys.commericalUse)},dataModelTraining:{value:Fl(e.node.tags,$l.keys.dataModelTraining)},paymentMode:Fl(e.node.tags,$l.keys.paymentMode),paymentAddress:Fl(e.node.tags,$l.keys.paymentAddress),currency:Fl(e.node.tags,$l.keys.currency)}:null}async function Vh(e,t,r){try{const n=[{name:$l.keys.bootloaderInit,value:jl.src.zone}];return e.tags&&e.tags.length&&e.tags.forEach((e=>n.push(e))),await Nh({wallet:t,spawnTags:n},r?e=>r(e):void 0)}catch(e){throw new Error(e.message??"Error creating zone")}}async function Wh(e,t,r){try{const n=Object.entries(e).map((([e,t])=>({key:e,value:t})));return await Oh({processId:t,wallet:r,action:"Zone-Update",data:n})}catch(e){throw new Error(e)}}async function Yh(e,t,r){try{return await Oh({processId:t,wallet:r,action:"Zone-Append",tags:[{name:"Path",value:e.path}],data:e.data})}catch(e){throw new Error(e)}}async function Jh(e){try{return await Ch({processId:e,action:"Info"})}catch(e){throw new Error(e)}}async function Qh(e,t,r){let n=null;const a=[{name:$l.keys.dataProtocol,value:"Zone"},{name:$l.keys.zoneType,value:"User"}],i=async t=>{const n=t.toLowerCase();if(e[n])try{const r=await Mh(e[n]);a.push(uh(t,r))}catch(e){r?r(`Failed to resolve ${t}: ${e.message}`):console.error(e)}};a.push(uh("Username",e.username)),a.push(uh("DisplayName",e.displayName)),a.push(uh("Description",e.description)),await Promise.all([i("Thumbnail"),i("Banner")]);try{n=await Vh({tags:a},t,r)}catch(e){throw new Error(e.message??"Error creating profile")}return n}async function Xh(e,t,r,n){if(!t)throw new Error("No profile provided");{let a={Username:e.username,DisplayName:e.displayName,Description:e.description};if(e.thumbnail)try{a.Thumbnail=await Mh(e.thumbnail)}catch(e){n&&n(`Failed to resolve thumbnail: ${e.message}`)}if(e.banner)try{a.Banner=await Mh(e.banner)}catch(e){n&&n(`Failed to resolve banner: ${e.message}`)}try{return await Wh(a,t,r)}catch(e){throw new Error(e.message??"Error creating profile")}}}async function ed(e){try{const t=await Jh(e);return{id:e,...oh(t.Store??{}),assets:oh(t.Assets??[])}}catch(e){throw new Error(e.message??"Error fetching profile")}}async function td(e){try{const t=await gh({gateway:Pl.arweave,tags:[{name:$l.keys.dataProtocol,values:["Zone"]},{name:$l.keys.zoneType,values:["User"]}],owners:[e]});return t?.data?.length>0?(t.data.sort(((e,t)=>{const r=e.node.block?.timestamp??0;return(t.node.block?.timestamp??0)-r})),await ed(t.data[0].node.id)):{id:null}}catch(e){throw new Error(e.message??"Error fetching profile")}}var rd=n.AO,nd=n.yw,ad=n.it,id=n.Bw,sd=n.gp,od=n.oH,ud=n.xH,cd=n.CH,ld=n.FV,hd=n.T1,dd=n.G3,fd=n.P8,pd=n.as,gd=n.xS,yd=n.L_,md=n.hs,vd=n.Dq,wd=n.YX,bd=n.SH,_d=n.zS,Td=n.TW,Ed=n.Ie,kd=n.M0,Ad=n.B4,xd=n.Yq,Sd=n.Ee,Od=n.pi,Cd=n.zb,Rd=n.i$,Id=n.t$,Bd=n.WS,Ud=n.jU,jd=n.$r,Nd=n.Ok,Pd=n.UT,Ld=n.NG,$d=n.ay,Md=n.KW,Zd=n.PG,Dd=n.Bq,Fd=n.Xc,zd=n.dg,Kd=n.Gb,qd=n.IX,Hd=n.GR,Gd=n.HD,Vd=n.U1,Wd=n.nG,Yd=n.gm,Jd=n.sY,Qd=n.TT,Xd=n.IF,ef=n.CE,tf=n.go,rf=n.r7,nf=n.G5,af=n.gD;export{ud as addToZone,rd as AO,cd as aoCreateProcess,ld as aoDryRun,hd as aoMessageResult,dd as aoMessageResults,fd as aoSend,pd as aoSpawn,gd as buildAsset,yd as buildStoreNamespace,md as checkValidAddress,vd as cleanTagValue,nd as CONTENT_TYPES,wd as createAtomicAsset,bd as createProfile,_d as createTransaction,Td as createZone,Ed as fetchProcessSrc,kd as formatAddress,Ad as formatCount,xd as formatDate,Sd as formatPercentage,Od as formatRequiredField,ad as GATEWAYS,Cd as getARBalanceEndpoint,Rd as getAtomicAsset,Id as getAtomicAssets,Bd as getBase64Data,Ud as getBatchGQLData,jd as getBootTag,Nd as getByteSize,Pd as getDataURLContentType,Ld as getGQLData,$d as getProfileById,Md as getProfileByWalletAddress,Zd as getRelativeDate,Dd as getRendererEndpoint,Fd as getStoreNamespace,zd as getTagDisplay,Kd as getTagValue,qd as getTotalTokenBalance,Hd as getTxEndpoint,Gd as getZone,Vd as globalLog,Wd as handleProcessEval,Yd as isFirefox,id as LICENSES,Jd as mapFromProcessCase,Qd as mapToProcessCase,Xd as resolveTransaction,ef as reverseDenomination,tf as splitTagValue,sd as TAGS,rf as updateProfile,nf as updateZone,od as UPLOAD,af as waitForProcess};