@learncard/ceramic-plugin 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ceramic-plugin.cjs.development.js +3 -3
- package/dist/ceramic-plugin.cjs.development.js.map +2 -2
- package/dist/ceramic-plugin.cjs.production.min.js +1 -1
- package/dist/ceramic-plugin.cjs.production.min.js.map +2 -2
- package/dist/ceramic-plugin.esm.js +3 -3
- package/dist/ceramic-plugin.esm.js.map +2 -2
- package/package.json +4 -4
|
@@ -814,7 +814,7 @@ HEXDIG = DIGIT / "A" / "B" / "C" / "D" / "E" / "F"
|
|
|
814
814
|
`)}o(OL,"asString");var Wu=class extends Vu{toMessage(){return super.toMessage("Ethereum")}signMessage(){let e;switch(this.type){case Ju.PERSONAL_SIGNATURE:{e=this.toMessage();break}default:{e=this.toMessage();break}}return e}};o(Wu,"SiweMessage");var zd=class extends Vu{toMessage(){return super.toMessage("Solana")}signMessage(){let e;switch(this.type){case Ju.PERSONAL_SIGNATURE:{e=new TextEncoder().encode(this.toMessage());break}default:{e=new TextEncoder().encode(this.toMessage());break}}return e}};o(zd,"SiwsMessage");var RL=5*60,NL=new Date("2022-09-20").valueOf(),Yu;(function(t){function e(c){let u={h:{t:"eip4361"},p:{domain:c.domain,iat:c.issuedAt,iss:`did:pkh:eip155:${c.chainId}:${c.address}`,aud:c.uri,version:c.version,nonce:c.nonce}};return c.signature&&(u.s={t:"eip191",s:c.signature}),c.notBefore&&(u.p.nbf=c.notBefore),c.expirationTime&&(u.p.exp=c.expirationTime),c.statement&&(u.p.statement=c.statement),c.requestId&&(u.p.requestId=c.requestId),c.resources&&(u.p.resources=c.resources),u}o(e,"fromSiweMessage");let r=o(function(c){try{return Promise.resolve(Jx({bytes:c,codec:Hi,hasher:Ss})).then(function(u){return u.value})}catch(u){return Promise.reject(u)}},"fromBlockBytes");t.fromSiweMessage=e;function n(c){let u={h:{t:"caip122"},p:{domain:c.domain,iat:c.issuedAt,iss:`did:pkh:solana:${c.chainId}:${c.address}`,aud:c.uri,version:c.version,nonce:c.nonce}};return c.signature&&(u.s={t:"solana:ed25519",s:c.signature}),c.notBefore&&(u.p.nbf=c.notBefore),c.expirationTime&&(u.p.exp=c.expirationTime),c.statement&&(u.p.statement=c.statement),c.requestId&&(u.p.requestId=c.requestId),c.resources&&(u.p.resources=c.resources),u}o(n,"fromSiwsMessage"),t.fromSiwsMessage=n,t.fromBlockBytes=r;function i(c,u={}){var m,v;if(((m=c.s)==null?void 0:m.t)==="eip191")return a(c,u);if(((v=c.s)==null?void 0:v.t)==="solana:ed25519")return PL(c,u);throw new Error("Unsupported CACAO signature type")}o(i,"verify"),t.verify=i;function a(c,u){if(!c.s)throw new Error("CACAO does not have a signature");let m=u.atTime?u.atTime.getTime():Date.now(),v=(u.clockSkewSecs??RL)*1e3;if(Date.parse(c.p.iat)>m+v||Date.parse(c.p.nbf)>m+v)throw new Error("CACAO is not valid yet");let x=u.revocationPhaseOutSecs?u.revocationPhaseOutSecs*1e3:0;if(!u.disableExpirationCheck&&Date.parse(c.p.exp)+x+v<m)throw new Error("CACAO has expired");let O=[Cb(Wu.fromCacao(c).toMessage(),c.s.s).toLowerCase()];if(Date.parse(c.p.iat)<=NL){let D=Cb(DL(Wu.fromCacao(c),"Ethereum"),c.s.s).toLowerCase();O.push(D)}let R=zs.parse(c.p.iss.replace("did:pkh:","")).address.toLowerCase();if(!O.includes(R))throw new Error("Signature does not belong to issuer")}o(a,"verifyEIP191Signature"),t.verifyEIP191Signature=a})(Yu||(Yu={}));function PL(t,e){if(!t.s)throw new Error("CACAO does not have a signature");let r=e.atTime?e.atTime.getTime():Date.now();if(Date.parse(t.p.iat)>r||Date.parse(t.p.nbf)>r)throw new Error("CACAO is not valid yet");let n=e.revocationPhaseOutSecs?e.revocationPhaseOutSecs*1e3:0;if(!e.disableExpirationCheck&&Date.parse(t.p.exp)+n<r)throw new Error("CACAO has expired");let i=zd.fromCacao(t),a=t.s.s,c=i.signMessage(),u=Ot(a,"base58btc"),m=zs.parse(t.p.iss.replace("did:pkh:","")).address,v=Ot(m,"base58btc");if(!(0,q5.verify)(v,c,u))throw new Error("Signature does not belong to issuer")}o(PL,"verifySolanaSignature");var Xu;(function(t){function e(r){return Ua({value:r,codec:Hi,hasher:Ss})}o(e,"fromCacao"),t.fromCacao=e})(Xu||(Xu={}));$f();hu();var H5=Lt(Oa(),1);$f();function z5(){return kt((0,H5.randomBytes)(16),"base64")}o(z5,"randomString");var K5="base64pad",j5="base64url";function G5(t){return kt(t,K5)}o(G5,"encodeBase64");function V5(t){return kt(t,j5)}o(V5,"encodeBase64Url");function W5(t){return Ot(t,K5)}o(W5,"decodeBase64");function Kd(t){return JSON.parse(kt(Ot(t,j5)))}o(Kd,"base64urlToJSON");function J5(t){if(t.signatures.length>1)throw new Error("Cant convert to compact jws");return`${t.signatures[0].protected}.${t.payload}.${t.signatures[0].signature}`}o(J5,"fromDagJWS");function Y5(t,e){if(e){let r=e.toISOString().split(".")[0]+"Z";return`${t}?versionTime=${r}`}else return t}o(Y5,"didWithTime");function X5(t){return t?Array.isArray(t)?t:[t]:[]}o(X5,"extractControllers");function LL(t){return"registry"in t&&"cache"in t}o(LL,"isResolver");var Va=class{constructor({provider:e,resolver:r={},resolverOptions:n,capability:i,parent:a}={}){if(e!=null&&(this._client=new fc(e)),i){if(this._capability=i,this._parentId=this._capability.p.iss,a&&this._parentId!==a)throw new Error("Capability issuer and parent not equal")}else a&&(this._parentId=a);this.setResolver(r,n)}get capability(){if(!this._capability)throw new Error("DID has no capability attached");return this._capability}get hasCapability(){return this._capability!=null}get parent(){if(!this._parentId)throw new Error("DID has no parent DID");return this._parentId}get hasParent(){return this._parentId!=null}get id(){if(this._id==null)throw new Error("DID is not authenticated");return this._id}get authenticated(){return this._id!=null}withCapability(e){return new Va({provider:this._client?.connection,resolver:this._resolver,capability:e,parent:this._parentId})}setProvider(e){if(this._client==null)this._client=new fc(e);else if(this._client.connection!==e)throw new Error("A different provider is already set, create a new DID instance to use another provider")}setResolver(e,r){this._resolver=LL(e)?e:new nu(e,r)}async authenticate({provider:e,paths:r=[],aud:n}={}){if(e!=null&&this.setProvider(e),this._client==null)throw new Error("No provider available");let i=z5(),a=await this._client.request("did_authenticate",{nonce:i,aud:n,paths:r}),{kid:c}=await this.verifyJWS(a),u=Kd(a.payload);if(!c.includes(u.did))throw new Error("Invalid authencation response, kid mismatch");if(u.nonce!==i)throw new Error("Invalid authencation response, wrong nonce");if(u.aud!==n)throw new Error("Invalid authencation response, wrong aud");if(u.exp<Date.now()/1e3)throw new Error("Invalid authencation response, expired");return this._id=u.did,this._id}async createJWS(e,r={}){if(this._client==null)throw new Error("No provider available");if(this._id==null)throw new Error("DID is not authenticated");if(this._capability){let i=await Xu.fromCacao(this._capability),a=We.asCID(i.cid);if(!a)throw new Error("Capability CID of the JWS cannot be set to the capability payload cid as they are incompatible");r.protected=r.protected||{},r.protected.cap=`ipfs://${a?.toString()}`}let{jws:n}=await this._client.request("did_createJWS",{did:this._id,...r,payload:e});return n}async createDagJWS(e,r={}){let{cid:n,linkedBlock:i}=await r4(e),a=V5(n.bytes);Object.assign(r,{linkedBlock:G5(i)});let c=await this.createJWS(a,r),u=We.asCID(n);if(!u)throw new Error("CID of the JWS cannot be set to the encoded payload cid as they are incompatible");if(c.link=u,this._capability){let m=await Xu.fromCacao(this._capability);return{jws:c,linkedBlock:i,cacaoBlock:m.bytes}}return{jws:c,linkedBlock:i}}async verifyJWS(e,r={}){typeof e!="string"&&(e=J5(e));let n=Kd(e.split(".")[0]).kid;if(!n)throw new Error('No "kid" found in jws');let i=await this.resolve(n);if(!r.disableTimecheck){let v=i.didDocumentMetadata?.nextUpdate;if(v){let S=r.revocationPhaseOutSecs?r.revocationPhaseOutSecs*1e3:0,O=new Date(v).valueOf()+S;if(!(r.atTime&&r.atTime.getTime()<O))throw new Error(`invalid_jws: signature authored with a revoked DID version: ${n}`)}let x=i.didDocumentMetadata?.updated;if(x&&r.atTime&&r.atTime.getTime()<new Date(x).valueOf())throw new Error(`invalid_jws: signature authored before creation of DID version: ${n}`)}let c=i.didDocument?.id;if(r.issuer&&r.issuer===r.capability?.p.iss&&c===r.capability.p.aud)Yu.verify(r.capability,{atTime:r.atTime?r.atTime:void 0,revocationPhaseOutSecs:r.revocationPhaseOutSecs});else if(r.issuer&&r.issuer!==c){let v=Y5(r.issuer,r.atTime),S=(await this.resolve(v)).didDocument?.controller,O=X5(S);if(r.capability?.s&&r.capability.p.aud===c&&O.includes(r.capability.p.iss))Yu.verify(r.capability,{atTime:r.atTime?r.atTime:void 0,revocationPhaseOutSecs:r.revocationPhaseOutSecs});else if(!(c?O.includes(c):!1))throw new Error(`invalid_jws: not a valid verificationMethod for issuer: ${n}`)}let u=i.didDocument?.verificationMethod||[];zx(e,u);let m;try{m=Kd(e.split(".")[1])}catch{}return{kid:n,payload:m,didResolutionResult:i}}async createJWE(e,r,n={}){let i=await Gx(r,this._resolver);return jx(e,i,n.protectedHeader,n.aad)}async createDagJWE(e,r,n={}){let i=await n4(e);return this.createJWE(i,r,n)}async decryptJWE(e,r={}){if(this._client==null)throw new Error("No provider available");if(this._id==null)throw new Error("DID is not authenticated");let{cleartext:n}=await this._client.request("did_decryptJWE",{did:this._id,...r,jwe:e});return W5(n)}async decryptDagJWE(e){let r=await this.decryptJWE(e);return i4(r)}async resolve(e){let r=await this._resolver.resolve(e);if(r.didResolutionMetadata.error){let{error:n,message:i}=r.didResolutionMetadata,a=i?`, ${i}`:"";throw new Error(`Failed to resolve ${e}: ${n}${a}`)}return r}};o(Va,"DID");function Z5(t){var e=0,r=t.length,n=[];if(r%2)throw new Error("invalid hex:"+t);for(;e<r;e+=2)n.push(parseInt(t.substr(e,2),16));return new Uint8Array(n)}o(Z5,"toUint8Array");var Fb=Lt(Zu(),1);_h();var Db={};Jt(Db,{keyToDidDoc:()=>YL});function YL(t,e){let r=`did:key:${e}`,n=`${r}#${e}`;return{id:r,verificationMethod:[{id:n,type:"Secp256k1VerificationKey2018",controller:r,publicKeyBase58:kt(t,"base58btc")}],authentication:[n],assertionMethod:[n],capabilityDelegation:[n],capabilityInvocation:[n]}}o(YL,"keyToDidDoc");var Ob={};Jt(Ob,{keyToDidDoc:()=>ZL});$f();var f8=Lt(_u(),1);function XL(t){let e=new Uint8Array(t.length+2);return e[0]=236,e[1]=1,e.set(t,2),`z${kt(e,"base58btc")}`}o(XL,"encodeKey");function ZL(t,e){let r=`did:key:${e}`,n=`${r}#${e}`,i=(0,f8.convertPublicKeyToX25519)(t),a=`${r}#${XL(i)}`;return{id:r,verificationMethod:[{id:n,type:"Ed25519VerificationKey2018",controller:r,publicKeyBase58:kt(t,"base58btc")}],authentication:[n],assertionMethod:[n],capabilityDelegation:[n],capabilityInvocation:[n],keyAgreement:[{id:a,type:"X25519KeyAgreementKey2019",controller:r,publicKeyBase58:kt(i,"base58btc")}]}}o(ZL,"keyToDidDoc");var Bb={};Jt(Bb,{keyToDidDoc:()=>fB,pubKeyBytesToXY:()=>l8});var jd={};Jt(jd,{ECPointDecompress:()=>oB});function QL(t){return t>=0?t:-t}o(QL,"n");function eB(t,e){if(typeof t=="number"&&(t=BigInt(t)),typeof e=="number"&&(e=BigInt(e)),t<=0n||e<=0n)throw new RangeError("a and b MUST be > 0");let r=0n,n=1n,i=1n,a=0n;for(;t!==0n;){let c=e/t,u=e%t,m=r-i*c,v=n-a*c;e=t,t=u,r=i,n=a,i=m,a=v}return{g:e,x:r,y:n}}o(eB,"r");function Rb(t,e){if(typeof t=="number"&&(t=BigInt(t)),typeof e=="number"&&(e=BigInt(e)),e<=0n)throw new RangeError("n must be > 0");let r=t%e;return r<0n?r+e:r}o(Rb,"f");function tB(t,e){let r=eB(Rb(t,e),e);if(r.g!==1n)throw new RangeError(`${t.toString()} does not have inverse modulo ${e.toString()}`);return Rb(r.x,e)}o(tB,"g");function Wa(t,e,r){if(typeof t=="number"&&(t=BigInt(t)),typeof e=="number"&&(e=BigInt(e)),typeof r=="number"&&(r=BigInt(r)),r<=0n)throw new RangeError("n must be > 0");if(r===1n)return 0n;if(t=Rb(t,r),e<0n)return tB(Wa(t,QL(e),r),r);let n=1n;for(;e>0;)e%2n===1n&&(n=n*t%r),e/=2n,t=t**2n%r;return n}o(Wa,"b");var vr={};Jt(vr,{pubKeyBytesToHex:()=>rB,publicKeyHexToUint8ArrayPointPair:()=>c8,publicKeyIntToUint8ArrayPointPair:()=>u8,publicKeyIntToXY:()=>iB,publicKeyToXY:()=>nB,testHexString:()=>Pb,testUint8Array:()=>Vs});Eh();function rB(t){if(!Vs(t))throw new TypeError("input must be a Uint8Array");return kt(t,"base16")}o(rB,"pubKeyBytesToHex");function nB(t){if(!Pb(t))throw new TypeError("input must be string with characters 0-9,A-F,a-f");let e=c8(t),r=_a.encode(e.xOctet).slice(1),n=_a.encode(e.yOctet).slice(1);return{xm:r,ym:n}}o(nB,"publicKeyToXY");function c8(t){if(!Pb(t))throw new TypeError("input must be string with characters 0-9,A-F,a-f");let e=t.slice(0,t.length/2),r=t.slice(t.length/2,t.length),n=Ot(e,"base16"),i=Ot(r,"base16");return{xOctet:n,yOctet:i}}o(c8,"publicKeyHexToUint8ArrayPointPair");function Pb(t){let e=/^[A-Fa-f0-9]+$/i;return!!(e.exec(t)!==null&&e.test(t)&&typeof t=="string")}o(Pb,"testHexString");function Vs(t){return t==null?!1:t.constructor===Uint8Array}o(Vs,"testUint8Array");function iB(t){if(t==null)throw new TypeError("input cannot be null or undefined.");if(typeof t!="object")throw new TypeError("Input must be an object with properties x and y");if(!Object.prototype.hasOwnProperty.call(t,"x")||!Object.prototype.hasOwnProperty.call(t,"y"))throw new Error("Input must have properties x and y");if(typeof t.x!="bigint"&&typeof t.y!="bigint")throw new Error("Input coordinates must be BigInt");let e=u8(t),r=_a.encode(e.xOctet).slice(1),n=_a.encode(e.yOctet).slice(1);return{xm:r,ym:n}}o(iB,"publicKeyIntToXY");function u8(t){if(t==null)throw new TypeError("input cannot be null or undefined.");if(typeof t!="object")throw new TypeError("Input must be an object with properties x and y");if(!Object.prototype.hasOwnProperty.call(t,"x")||!Object.prototype.hasOwnProperty.call(t,"y"))throw new Error("Input must have properties x and y");if(typeof t.x!="bigint"&&typeof t.y!="bigint")throw new Error("Input coordinates must be BigInt");let e=t.x.toString(),r=t.y.toString(),n=Ot(e,"base10"),i=Ot(r,"base10");return{xOctet:n,yOctet:i}}o(u8,"publicKeyIntToUint8ArrayPointPair");function oB(t){if(!Vs(t))throw new TypeError("input must be a Uint8Array");let e=BigInt(2),r=e**256n-e**224n+e**192n+e**96n-1n,n=41058363725152142129326129780047268409114441015993725554835256314039467401291n,i=(r+1n)/4n,a=BigInt(t[0]-2),c=t.subarray(1),u=BigInt(kt(c,"base10")),m=u**3n-u*3n+n,v=Wa(m,i,r);return v%2n!==a&&(v=r-v),{x:u,y:v}}o(oB,"ECPointDecompress");var Gd={};Jt(Gd,{ECPointDecompress:()=>sB});function sB(t){if(!Vs(t))throw new TypeError("input must be a Uint8Array");let e=BigInt(2),r=e**384n-e**128n-e**96n+e**32n-1n,n=27580193559959705877849011840389048093056905856361568521428707301988689241309860865136260764883745107765439761230575n,i=(r+1n)/4n,a=BigInt(t[0]-2),c=t.subarray(1),u=BigInt(kt(c,"base10")),m=u**3n-u*3n+n,v=Wa(m,i,r);return v%2n!==a&&(v=r-v),{x:u,y:v}}o(sB,"ECPointDecompress");var Vd={};Jt(Vd,{ECPointDecompress:()=>aB});function aB(t){if(!Vs(t))throw new TypeError("input must be a Uint8Array");let r=BigInt(2)**521n-1n,n=1093849038073734274511112390766805569936207598951683748994586394495953116150735016013708737573759623248592132296706313309438452531591012912142327488478985984n,i=(r+1n)/4n,a=BigInt(t[0]-2),c=t.subarray(1),u=BigInt(kt(c,"base10")),m=u**3n-u*3n+n,v=Wa(m,i,r);return v%2n!==a&&(v=r-v),{x:u,y:v}}o(aB,"ECPointDecompress");function fB(t,e){let r=`did:key:${e}`,n=`${r}#${e}`,i=l8(t);return{id:r,verificationMethod:[{id:n,type:"JsonWebKey2020",controller:r,publicKeyJwk:{kty:"EC",crv:"P-256",x:i.xm,y:i.ym}}],authentication:[n],assertionMethod:[n],capabilityDelegation:[n],capabilityInvocation:[n]}}o(fB,"keyToDidDoc");function l8(t){if(!vr.testUint8Array(t))throw new TypeError("input must be a Uint8Array");let e=vr.pubKeyBytesToHex(t),r=e.length/2;if(r==64)return vr.publicKeyToXY(e);if(r==65&&e.slice(0,2)=="04"){let n=e.slice(2);return vr.publicKeyToXY(n)}if(r==33&&(e.slice(0,2)=="03"||e.slice(0,2)=="02")){let n=Ot(e,"base16"),i=jd.ECPointDecompress(n);return vr.publicKeyIntToXY(i)}throw new Error("Unexpected pubKeyBytes")}o(l8,"pubKeyBytesToXY");var Ub={};Jt(Ub,{keyToDidDoc:()=>cB,pubKeyBytesToXY:()=>h8});function cB(t,e){let r=`did:key:${e}`,n=`${r}#${e}`,i=h8(t);return{id:r,verificationMethod:[{id:n,type:"JsonWebKey2020",controller:r,publicKeyJwk:{kty:"EC",crv:"P-384",x:i.xm,y:i.ym}}],authentication:[n],assertionMethod:[n],capabilityDelegation:[n],capabilityInvocation:[n]}}o(cB,"keyToDidDoc");function h8(t){if(!vr.testUint8Array(t))throw new TypeError("input must be a Uint8Array");let e=vr.pubKeyBytesToHex(t),r=e.length/2;if(r==96)return vr.publicKeyToXY(e);if(r==97&&e.slice(0,2)=="04"){let n=e.slice(2);return vr.publicKeyToXY(n)}if(r==49&&(e.slice(0,2)=="03"||e.slice(0,2)=="02")){let n=Ot(e,"base16"),i=Gd.ECPointDecompress(n);return vr.publicKeyIntToXY(i)}throw new Error("Unexpected pubKeyBytes")}o(h8,"pubKeyBytesToXY");var $b={};Jt($b,{keyToDidDoc:()=>uB,pubKeyBytesToXY:()=>d8});function uB(t,e){let r=`did:key:${e}`,n=`${r}#${e}`,i=d8(t);return{id:r,verificationMethod:[{id:n,type:"JsonWebKey2020",controller:r,publicKeyJwk:{kty:"EC",crv:"P-521",x:i.xm,y:i.ym}}],authentication:[n],assertionMethod:[n],capabilityDelegation:[n],capabilityInvocation:[n]}}o(uB,"keyToDidDoc");function d8(t){if(!vr.testUint8Array(t))throw new TypeError("input must be a Uint8Array");let e=vr.pubKeyBytesToHex(t);if(132<=e.length&&e.length<=134&&(e.slice(0,2)=="03"||e.slice(0,2)=="02")){let r=Ot(e,"base16"),n=Vd.ECPointDecompress(r);return vr.publicKeyIntToXY(n)}throw new Error("Unexpected pubKeyBytes")}o(d8,"pubKeyBytesToXY");var lB="application/did+ld+json",p8="application/did+json",hB={231:Db,237:Ob,4608:Bb,4609:Ub,4610:$b};function dB(){return{key:async(t,e,r,n)=>{let i=n.accept||p8,a={didResolutionMetadata:{contentType:i},didDocument:null,didDocumentMetadata:{}};try{let c=ui.decode(e.id),u=Fb.default.decode(c),m=c.slice(Fb.default.decode.bytes),v=await hB[u].keyToDidDoc(m,e.id);i===lB?(v["@context"]="https://w3id.org/did/v1",a.didDocument=v):i===p8?a.didDocument=v:(delete a.didResolutionMetadata.contentType,a.didResolutionMetadata.error="representationNotSupported")}catch(c){a.didResolutionMetadata.error="invalidDid",a.didResolutionMetadata.message=c.toString()}return a}}}o(dB,"getResolver");var m8={getResolver:dB};var Wd=Lt(_u(),1);var w8=Lt(g8(),1);var pB="base64pad";function v8(t){return JSON.parse((0,w8.default)(t))}o(v8,"toStableObject");function mB(t){let e=new Uint8Array(t.length+2);return e[0]=237,e[1]=1,e.set(t,2),`did:key:z${kt(e,"base58btc")}`}o(mB,"encodeDID");function y8(t){let[e,r,n]=t.split(".");return{payload:r,signatures:[{protected:e,signature:n}]}}o(y8,"toGeneralJWS");var x8=o(async(t,e,r,n={})=>{let i=`${e}#${e.split(":")[2]}`,a=Ux(r),c=v8(Object.assign(n,{kid:i,alg:"EdDSA"}));return Hx(typeof t=="string"?t:v8(t),a,c)},"sign"),bB={did_authenticate:async({did:t,secretKey:e},r)=>{let n=await x8({did:t,aud:r.aud,nonce:r.nonce,paths:r.paths,exp:Math.floor(Date.now()/1e3)+600},t,e);return y8(n)},did_createJWS:async({did:t,secretKey:e},r)=>{if(r.did.split("#")[0]!==t)throw new wn(4100,`Unknown DID: ${t}`);let i=await x8(r.payload,t,e,r.protected);return{jws:y8(i)}},did_decryptJWE:async({secretKey:t},e)=>{let r=Wx((0,Wd.convertSecretKeyToX25519)(t));try{let n=await Kx(e.jwe,r);return{cleartext:kt(n,pB)}}catch(n){throw new wn(-32e3,n.message)}}},Qu=class{constructor(e){let{secretKey:r,publicKey:n}=(0,Wd.generateKeyPairFromSeed)(e),i=mB(n),a=l4(bB);this._handle=async c=>await a({did:i,secretKey:r},c)}get isDidProvider(){return!0}async send(e){return await this._handle(e)}};o(Qu,"Ed25519Provider");var qb={};Jt(qb,{JsonPatchError:()=>dr,_areEquals:()=>rl,applyOperation:()=>Ja,applyPatch:()=>t0,applyReducer:()=>wB,deepClone:()=>yB,getValueByPointer:()=>Qd,validate:()=>E8,validator:()=>e0});var gB=function(){var t=o(function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},t(e,r)},"extendStatics");return function(e,r){t(e,r);function n(){this.constructor=e}o(n,"__"),e.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n)}}(),vB=Object.prototype.hasOwnProperty;function Yd(t,e){return vB.call(t,e)}o(Yd,"hasOwnProperty");function Xd(t){if(Array.isArray(t)){for(var e=new Array(t.length),r=0;r<e.length;r++)e[r]=""+r;return e}if(Object.keys)return Object.keys(t);var n=[];for(var i in t)Yd(t,i)&&n.push(i);return n}o(Xd,"_objectKeys");function qr(t){switch(typeof t){case"object":return JSON.parse(JSON.stringify(t));case"undefined":return null;default:return t}}o(qr,"_deepClone");function Zd(t){for(var e=0,r=t.length,n;e<r;){if(n=t.charCodeAt(e),n>=48&&n<=57){e++;continue}return!1}return!0}o(Zd,"isInteger");function vo(t){return t.indexOf("/")===-1&&t.indexOf("~")===-1?t:t.replace(/~/g,"~0").replace(/\//g,"~1")}o(vo,"escapePathComponent");function el(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}o(el,"unescapePathComponent");function Jd(t){if(t===void 0)return!0;if(t){if(Array.isArray(t)){for(var e=0,r=t.length;e<r;e++)if(Jd(t[e]))return!0}else if(typeof t=="object"){for(var n=Xd(t),i=n.length,a=0;a<i;a++)if(Jd(t[n[a]]))return!0}}return!1}o(Jd,"hasUndefined");function _8(t,e){var r=[t];for(var n in e){var i=typeof e[n]=="object"?JSON.stringify(e[n],null,2):e[n];typeof i<"u"&&r.push(n+": "+i)}return r.join(`
|
|
815
815
|
`)}o(_8,"patchErrorMessageFormatter");var tl=function(t){gB(e,t);function e(r,n,i,a,c){var u=this.constructor,m=t.call(this,_8(r,{name:n,index:i,operation:a,tree:c}))||this;return m.name=n,m.index=i,m.operation=a,m.tree=c,Object.setPrototypeOf(m,u.prototype),m.message=_8(r,{name:n,index:i,operation:a,tree:c}),m}return o(e,"PatchError"),e}(Error);var dr=tl,yB=qr,vc={add:function(t,e,r){return t[e]=this.value,{newDocument:r}},remove:function(t,e,r){var n=t[e];return delete t[e],{newDocument:r,removed:n}},replace:function(t,e,r){var n=t[e];return t[e]=this.value,{newDocument:r,removed:n}},move:function(t,e,r){var n=Qd(r,this.path);n&&(n=qr(n));var i=Ja(r,{op:"remove",path:this.from}).removed;return Ja(r,{op:"add",path:this.path,value:i}),{newDocument:r,removed:n}},copy:function(t,e,r){var n=Qd(r,this.from);return Ja(r,{op:"add",path:this.path,value:qr(n)}),{newDocument:r}},test:function(t,e,r){return{newDocument:r,test:rl(t[e],this.value)}},_get:function(t,e,r){return this.value=t[e],{newDocument:r}}},xB={add:function(t,e,r){return Zd(e)?t.splice(e,0,this.value):t[e]=this.value,{newDocument:r,index:e}},remove:function(t,e,r){var n=t.splice(e,1);return{newDocument:r,removed:n[0]}},replace:function(t,e,r){var n=t[e];return t[e]=this.value,{newDocument:r,removed:n}},move:vc.move,copy:vc.copy,test:vc.test,_get:vc._get};function Qd(t,e){if(e=="")return t;var r={op:"_get",path:e};return Ja(t,r),r.value}o(Qd,"getValueByPointer");function Ja(t,e,r,n,i,a){if(r===void 0&&(r=!1),n===void 0&&(n=!0),i===void 0&&(i=!0),a===void 0&&(a=0),r&&(typeof r=="function"?r(e,0,t,e.path):e0(e,0)),e.path===""){var c={newDocument:t};if(e.op==="add")return c.newDocument=e.value,c;if(e.op==="replace")return c.newDocument=e.value,c.removed=t,c;if(e.op==="move"||e.op==="copy")return c.newDocument=Qd(t,e.from),e.op==="move"&&(c.removed=t),c;if(e.op==="test"){if(c.test=rl(t,e.value),c.test===!1)throw new dr("Test operation failed","TEST_OPERATION_FAILED",a,e,t);return c.newDocument=t,c}else{if(e.op==="remove")return c.removed=t,c.newDocument=null,c;if(e.op==="_get")return e.value=t,c;if(r)throw new dr("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",a,e,t);return c}}else{n||(t=qr(t));var u=e.path||"",m=u.split("/"),v=t,x=1,S=m.length,O=void 0,R=void 0,D=void 0;for(typeof r=="function"?D=r:D=e0;;){if(R=m[x],R&&R.indexOf("~")!=-1&&(R=el(R)),i&&(R=="__proto__"||R=="prototype"&&x>0&&m[x-1]=="constructor"))throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README");if(r&&O===void 0&&(v[R]===void 0?O=m.slice(0,x).join("/"):x==S-1&&(O=e.path),O!==void 0&&D(e,0,t,O)),x++,Array.isArray(v)){if(R==="-")R=v.length;else{if(r&&!Zd(R))throw new dr("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index","OPERATION_PATH_ILLEGAL_ARRAY_INDEX",a,e,t);Zd(R)&&(R=~~R)}if(x>=S){if(r&&e.op==="add"&&R>v.length)throw new dr("The specified index MUST NOT be greater than the number of elements in the array","OPERATION_VALUE_OUT_OF_BOUNDS",a,e,t);var c=xB[e.op].call(e,v,R,t);if(c.test===!1)throw new dr("Test operation failed","TEST_OPERATION_FAILED",a,e,t);return c}}else if(x>=S){var c=vc[e.op].call(e,v,R,t);if(c.test===!1)throw new dr("Test operation failed","TEST_OPERATION_FAILED",a,e,t);return c}if(v=v[R],r&&x<S&&(!v||typeof v!="object"))throw new dr("Cannot perform operation at the desired path","OPERATION_PATH_UNRESOLVABLE",a,e,t)}}}o(Ja,"applyOperation");function t0(t,e,r,n,i){if(n===void 0&&(n=!0),i===void 0&&(i=!0),r&&!Array.isArray(e))throw new dr("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");n||(t=qr(t));for(var a=new Array(e.length),c=0,u=e.length;c<u;c++)a[c]=Ja(t,e[c],r,!0,i,c),t=a[c].newDocument;return a.newDocument=t,a}o(t0,"applyPatch");function wB(t,e,r){var n=Ja(t,e);if(n.test===!1)throw new dr("Test operation failed","TEST_OPERATION_FAILED",r,e,t);return n.newDocument}o(wB,"applyReducer");function e0(t,e,r,n){if(typeof t!="object"||t===null||Array.isArray(t))throw new dr("Operation is not an object","OPERATION_NOT_AN_OBJECT",e,t,r);if(vc[t.op]){if(typeof t.path!="string")throw new dr("Operation `path` property is not a string","OPERATION_PATH_INVALID",e,t,r);if(t.path.indexOf("/")!==0&&t.path.length>0)throw new dr('Operation `path` property must start with "/"',"OPERATION_PATH_INVALID",e,t,r);if((t.op==="move"||t.op==="copy")&&typeof t.from!="string")throw new dr("Operation `from` property is not present (applicable in `move` and `copy` operations)","OPERATION_FROM_REQUIRED",e,t,r);if((t.op==="add"||t.op==="replace"||t.op==="test")&&t.value===void 0)throw new dr("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_REQUIRED",e,t,r);if((t.op==="add"||t.op==="replace"||t.op==="test")&&Jd(t.value))throw new dr("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED",e,t,r);if(r){if(t.op=="add"){var i=t.path.split("/").length,a=n.split("/").length;if(i!==a+1&&i!==a)throw new dr("Cannot perform an `add` operation at the desired path","OPERATION_PATH_CANNOT_ADD",e,t,r)}else if(t.op==="replace"||t.op==="remove"||t.op==="_get"){if(t.path!==n)throw new dr("Cannot perform the operation at a path that does not exist","OPERATION_PATH_UNRESOLVABLE",e,t,r)}else if(t.op==="move"||t.op==="copy"){var c={op:"_get",path:t.from,value:void 0},u=E8([c],r);if(u&&u.name==="OPERATION_PATH_UNRESOLVABLE")throw new dr("Cannot perform the operation from a path that does not exist","OPERATION_FROM_UNRESOLVABLE",e,t,r)}}}else throw new dr("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",e,t,r)}o(e0,"validator");function E8(t,e,r){try{if(!Array.isArray(t))throw new dr("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");if(e)t0(qr(e),qr(t),r||!0);else{r=r||e0;for(var n=0;n<t.length;n++)r(t[n],n,e,void 0)}}catch(i){if(i instanceof dr)return i;throw i}}o(E8,"validate");function rl(t,e){if(t===e)return!0;if(t&&e&&typeof t=="object"&&typeof e=="object"){var r=Array.isArray(t),n=Array.isArray(e),i,a,c;if(r&&n){if(a=t.length,a!=e.length)return!1;for(i=a;i--!==0;)if(!rl(t[i],e[i]))return!1;return!0}if(r!=n)return!1;var u=Object.keys(t);if(a=u.length,a!==Object.keys(e).length)return!1;for(i=a;i--!==0;)if(!e.hasOwnProperty(u[i]))return!1;for(i=a;i--!==0;)if(c=u[i],!rl(t[c],e[c]))return!1;return!0}return t!==t&&e!==e}o(rl,"_areEquals");var jb={};Jt(jb,{compare:()=>kB,generate:()=>Hb,observe:()=>CB,unobserve:()=>TB});var zb=new WeakMap,_B=function(){function t(e){this.observers=new Map,this.obj=e}return o(t,"Mirror"),t}(),EB=function(){function t(e,r){this.callback=e,this.observer=r}return o(t,"ObserverInfo"),t}();function AB(t){return zb.get(t)}o(AB,"getMirror");function SB(t,e){return t.observers.get(e)}o(SB,"getObserverFromMirror");function MB(t,e){t.observers.delete(e.callback)}o(MB,"removeObserverFromMirror");function TB(t,e){e.unobserve()}o(TB,"unobserve");function CB(t,e){var r=[],n,i=AB(t);if(!i)i=new _B(t),zb.set(t,i);else{var a=SB(i,e);n=a&&a.observer}if(n)return n;if(n={},i.value=qr(t),e){n.callback=e,n.next=null;var c=o(function(){Hb(n)},"dirtyCheck"),u=o(function(){clearTimeout(n.next),n.next=setTimeout(c)},"fastCheck");typeof window<"u"&&(window.addEventListener("mouseup",u),window.addEventListener("keyup",u),window.addEventListener("mousedown",u),window.addEventListener("keydown",u),window.addEventListener("change",u))}return n.patches=r,n.object=t,n.unobserve=function(){Hb(n),clearTimeout(n.next),MB(i,n),typeof window<"u"&&(window.removeEventListener("mouseup",u),window.removeEventListener("keyup",u),window.removeEventListener("mousedown",u),window.removeEventListener("keydown",u),window.removeEventListener("change",u))},i.observers.set(e,new EB(e,n)),n}o(CB,"observe");function Hb(t,e){e===void 0&&(e=!1);var r=zb.get(t.object);Kb(r.value,t.object,t.patches,"",e),t.patches.length&&t0(r.value,t.patches);var n=t.patches;return n.length>0&&(t.patches=[],t.callback&&t.callback(n)),n}o(Hb,"generate");function Kb(t,e,r,n,i){if(e!==t){typeof e.toJSON=="function"&&(e=e.toJSON());for(var a=Xd(e),c=Xd(t),u=!1,m=!1,v=c.length-1;v>=0;v--){var x=c[v],S=t[x];if(Yd(e,x)&&!(e[x]===void 0&&S!==void 0&&Array.isArray(e)===!1)){var O=e[x];typeof S=="object"&&S!=null&&typeof O=="object"&&O!=null&&Array.isArray(S)===Array.isArray(O)?Kb(S,O,r,n+"/"+vo(x),i):S!==O&&(u=!0,i&&r.push({op:"test",path:n+"/"+vo(x),value:qr(S)}),r.push({op:"replace",path:n+"/"+vo(x),value:qr(O)}))}else Array.isArray(t)===Array.isArray(e)?(i&&r.push({op:"test",path:n+"/"+vo(x),value:qr(S)}),r.push({op:"remove",path:n+"/"+vo(x)}),m=!0):(i&&r.push({op:"test",path:n,value:t}),r.push({op:"replace",path:n,value:e}),u=!0)}if(!(!m&&a.length==c.length))for(var v=0;v<a.length;v++){var x=a[v];!Yd(t,x)&&e[x]!==void 0&&r.push({op:"add",path:n+"/"+vo(x),value:qr(e[x])})}}}o(Kb,"_generate");function kB(t,e,r){r===void 0&&(r=!1);var n=[];return Kb(t,e,n,"",r),n}o(kB,"compare");var r0=Object.assign({},qb,jb,{JsonPatchError:tl,deepClone:qr,escapePathComponent:vo,unescapePathComponent:el});var hE=Lt(Ec(),1);var dE=Lt(Oa(),1);var yr;(function(t){t[t.PREFER_CACHE=0]="PREFER_CACHE",t[t.SYNC_ALWAYS=1]="SYNC_ALWAYS",t[t.NEVER_SYNC=2]="NEVER_SYNC"})(yr||(yr={}));var Tg=Lt(Ec(),1);Pi();Lf();var l_={tile:0,"caip10-link":1,model:2,MID:3,UNLOADABLE:4};function n$(t){let e=l_[t];if(typeof e<"u")return e;throw new Error(`No stream type registered for name ${t}`)}o(n$,"codeByName");function i$(t){let e=Object.entries(l_).find(([,r])=>r===t);if(e)return e[0];throw new Error(`No stream type registered for index ${t}`)}o(i$,"nameByCode");var En=class{};o(En,"StreamType");En.nameByCode=i$;En.codeByName=n$;var dg=Lt(Zu(),1);function zn(t){let e,r,n;return typeof t=="object"?(e=t.hashFunction,r=t.expiring,n=t.tags):e=t,(i,a,c)=>{if(c.value!=null)c.value=h_(c.value,e,r,n);else if(c.get!=null)c.get=h_(c.get,e,r,n);else throw"Only put a Memoize() decorator on a method or get accessor."}}o(zn,"Memoize");var sg=new Map;function h_(t,e,r=0,n){let i=Symbol("__memoized_map__");return function(...a){let c;this.hasOwnProperty(i)||Object.defineProperty(this,i,{configurable:!1,enumerable:!1,writable:!1,value:new Map});let u=this[i];if(Array.isArray(n))for(let m of n)sg.has(m)?sg.get(m).push(u):sg.set(m,[u]);if(e||a.length>0||r>0){let m;e===!0?m=a.map(S=>S.toString()).join("!"):e?m=e.apply(this,a):m=a[0];let v=`${m}__timestamp`,x=!1;if(r>0)if(!u.has(v))x=!0;else{let S=u.get(v);x=Date.now()-S>r}u.has(m)&&!x?c=u.get(m):(c=t.apply(this,a),u.set(m,c),r>0&&u.set(v,Date.now()))}else{let m=this;u.has(m)?c=u.get(m):(c=t.apply(this,a),u.set(m,c))}return c}}o(h_,"getNewFunction");Pi();Lf();cu();var lg=Lt(Zu(),1);function Ac(t){try{return t()}catch(e){return e}}o(Ac,"tryCatch");Pi();var ag=Lt(Zu(),1);Aa();function Qa(t){let e=ag.default.decode(t),r=ag.default.decode.bytes,n=t.subarray(r);return[e,n,r]}o(Qa,"readVarint");function o$(t){return t===0||t===1}o(o$,"isCidVersion");function fg(t){let[e,r]=Qa(t);if(!o$(e))throw new Error(`Unknown CID version ${e}`);let[n,i]=Qa(r),[,a,c]=Qa(i),[u,,m]=Qa(a),v=i.subarray(0,c+m+u),x=i.subarray(c+m+u);return[We.create(e,n,Mh(v)),x]}o(fg,"readCid");Pi();Lf();function ef(t,e="StreamRef"){let[r,n]=Qa(t);if(r!==206)throw new Error(`Invalid ${e}, does not include streamid codec`);let[i,a]=Qa(n),c=fg(a),[u,m]=c;if(m.length===0)return{kind:"stream-id",type:i,genesis:u};if(m.length===1&&m[0]===0)return{kind:"commit-id",type:i,genesis:u,commit:null};{let[v]=fg(m);return{kind:"commit-id",type:i,genesis:u,commit:v}}}o(ef,"fromBytes");var s$=/(ceramic:\/\/|\/ceramic\/)?([a-zA-Z0-9]+)(\?commit=([a-zA-Z0-9]+))?/;function Sc(t,e="StreamRef"){let r=s$.exec(t)||[],n=r[2];if(!n)throw new Error(`Malformed ${e} string: ${t}`);let i=Ni.decode(n),a=ef(i),c=r[4];return c?{kind:"commit-id",type:a.type,genesis:a.genesis,commit:cg(a.genesis,c)}:a}o(Sc,"fromString");function a$(t){try{return typeof t=="string"?We.parse(t):We.asCID(t)}catch{return null}}o(a$,"parseCID");function cg(t,e=null){if(!e||e==="0")return null;let r=a$(e);if(r)return t.equals(r)?null:r;throw new Error("Cannot specify commit as a number except to request commit 0 (the genesis commit)")}o(cg,"parseCommit");var sl=function(t,e,r,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(t,e,r,n);else for(var u=t.length-1;u>=0;u--)(c=t[u])&&(a=(i<3?c(a):i>3?c(e,r,a):c(e,r))||a);return i>3&&a&&Object.defineProperty(e,r,a),a},Ei=function(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)},l0=class extends Error{constructor(e){super(`Invalid StreamID bytes ${Ni.encode(e)}: contains commit`)}};o(l0,"InvalidStreamIDBytesError");var h0=class extends Error{constructor(e){super(`Invalid StreamID string ${e}: contains commit`)}};o(h0,"InvalidStreamIDStringError");function m_(t){let e=ef(t,"StreamID");if(e.kind==="stream-id")return new rt(e.type,e.genesis);throw new l0(t)}o(m_,"fromBytes");function f$(t){return Ac(()=>m_(t))}o(f$,"fromBytesNoThrow");function b_(t){let e=Sc(t,"StreamID");if(e.kind==="stream-id")return new rt(e.type,e.genesis);throw new h0(t)}o(b_,"fromString");function c$(t){return Ac(()=>b_(t))}o(c$,"fromStringNoThrow");var p_=Symbol.for("@ceramicnetwork/streamid/StreamID"),rt=class{constructor(e,r){if(this._tag=p_,!(e||e===0))throw new Error("StreamID constructor: type required");if(!r)throw new Error("StreamID constructor: cid required");this._type=typeof e=="string"?En.codeByName(e):e,this._cid=typeof r=="string"?We.parse(r):r}static isInstance(e){return typeof e=="object"&&"_tag"in e&&e._tag===p_}static async fromGenesis(e,r){let n=await Ua({value:r,codec:Hi,hasher:Ss});return new rt(e,n.cid)}get type(){return this._type}get typeName(){return En.nameByCode(this._type)}get cid(){return this._cid}get bytes(){let e=lg.default.encode(206),r=lg.default.encode(this.type);return Oi([e,r,this.cid.bytes])}get baseID(){return new rt(this._type,this._cid)}equals(e){return rt.isInstance(e)?this.type===e.type&&this.cid.equals(e.cid):!1}toString(){return Ni.encode(this.bytes)}toUrl(){return`ceramic://${this.toString()}`}[Symbol.for("nodejs.util.inspect.custom")](){return`StreamID(${this.toString()})`}[Symbol.toPrimitive](){return this.toString()}};o(rt,"StreamID");rt.fromBytes=m_;rt.fromBytesNoThrow=f$;rt.fromString=b_;rt.fromStringNoThrow=c$;sl([zn(),Ei("design:type",String),Ei("design:paramtypes",[])],rt.prototype,"typeName",null);sl([zn(),Ei("design:type",Uint8Array),Ei("design:paramtypes",[])],rt.prototype,"bytes",null);sl([zn(),Ei("design:type",rt),Ei("design:paramtypes",[])],rt.prototype,"baseID",null);sl([zn(),Ei("design:type",Function),Ei("design:paramtypes",[]),Ei("design:returntype",String)],rt.prototype,"toString",null);sl([zn(),Ei("design:type",Function),Ei("design:paramtypes",[]),Ei("design:returntype",String)],rt.prototype,"toUrl",null);var Tc=function(t,e,r,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(t,e,r,n);else for(var u=t.length-1;u>=0;u--)(c=t[u])&&(a=(i<3?c(a):i>3?c(e,r,a):c(e,r))||a);return i>3&&a&&Object.defineProperty(e,r,a),a},An=function(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)},hg=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},is=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Mc,tf,al,d0=class extends Error{constructor(e){super(`Error while parsing CommitID from bytes ${Ni.encode(e)}: no commit information provided`)}};o(d0,"InvalidCommitIDBytesError");var p0=class extends Error{constructor(e){super(`Error while parsing CommitID from string ${e}: no commit information provided`)}};o(p0,"InvalidCommitIDStringError");function v_(t){let e=ef(t,"CommitID");if(e.kind==="commit-id")return new Pt(e.type,e.genesis,e.commit);throw new d0(t)}o(v_,"fromBytes");function u$(t){return Ac(()=>v_(t))}o(u$,"fromBytesNoThrow");function y_(t){let e=Sc(t,"CommitID");if(e.kind==="commit-id")return new Pt(e.type,e.genesis,e.commit);throw new p0(t)}o(y_,"fromString");function l$(t){return Ac(()=>y_(t))}o(l$,"fromStringNoThrow");var g_=Symbol.for("@ceramicnetwork/streamid/CommitID");function h$(t,e){return new Pt(t.type,t.cid,e)}o(h$,"make");var Pt=class{constructor(e,r,n=null){if(this._tag=g_,Mc.set(this,void 0),tf.set(this,void 0),al.set(this,void 0),!e&&e!==0)throw new Error("constructor: type required");if(!r)throw new Error("constructor: cid required");hg(this,Mc,typeof e=="string"?En.codeByName(e):e,"f"),hg(this,tf,typeof r=="string"?We.parse(r):r,"f"),hg(this,al,cg(is(this,tf,"f"),n),"f")}static isInstance(e){return typeof e=="object"&&"_tag"in e&&e._tag===g_}get baseID(){return new rt(is(this,Mc,"f"),is(this,tf,"f"))}get type(){return is(this,Mc,"f")}get typeName(){return En.nameByCode(is(this,Mc,"f"))}get cid(){return is(this,tf,"f")}get commit(){return is(this,al,"f")||is(this,tf,"f")}get bytes(){let e=dg.default.encode(206),r=dg.default.encode(this.type),n=is(this,al,"f")?.bytes||new Uint8Array([0]);return Oi([e,r,this.cid.bytes,n])}equals(e){return this.type===e.type&&this.cid.equals(e.cid)&&this.commit.equals(e.commit)}toString(){return Ni.encode(this.bytes)}toUrl(){return`ceramic://${this.toString()}`}[(Mc=new WeakMap,tf=new WeakMap,al=new WeakMap,Symbol.for("nodejs.util.inspect.custom"))](){return`CommitID(${this.toString()})`}[Symbol.toPrimitive](){return this.toString()}};o(Pt,"CommitID");Pt.fromBytes=v_;Pt.fromBytesNoThrow=u$;Pt.fromString=y_;Pt.fromStringNoThrow=l$;Pt.make=h$;Tc([zn(),An("design:type",rt),An("design:paramtypes",[])],Pt.prototype,"baseID",null);Tc([zn(),An("design:type",String),An("design:paramtypes",[])],Pt.prototype,"typeName",null);Tc([zn(),An("design:type",We),An("design:paramtypes",[])],Pt.prototype,"commit",null);Tc([zn(),An("design:type",Uint8Array),An("design:paramtypes",[])],Pt.prototype,"bytes",null);Tc([zn(),An("design:type",Function),An("design:paramtypes",[]),An("design:returntype",String)],Pt.prototype,"toString",null);Tc([zn(),An("design:type",Function),An("design:paramtypes",[]),An("design:returntype",String)],Pt.prototype,"toUrl",null);Lf();var fn;(function(t){function e(i){let a=ef(i);switch(a.kind){case"commit-id":return new Pt(a.type,a.genesis,a.commit);case"stream-id":return new rt(a.type,a.genesis);default:throw new Error(`Malformed StreamRef bytes: ${Ni.encode(i)}`)}}o(e,"fromBytes"),t.fromBytes=e;function r(i){let a=Sc(i);switch(a.kind){case"commit-id":return new Pt(a.type,a.genesis,a.commit);case"stream-id":return new rt(a.type,a.genesis);default:throw new Error(`Malformed StreamRef string: ${i}`)}}o(r,"fromString"),t.fromString=r;function n(i){if(rt.isInstance(i)||Pt.isInstance(i))return i;if(i instanceof Uint8Array)return e(i);if(typeof i=="string")return r(i);throw new Error(`Can not build CommitID or StreamID from ${JSON.stringify(i)}`)}o(n,"from"),t.from=n})(fn||(fn={}));var pg=o(function(t,e){return pg=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(r[i]=n[i])},pg(t,e)},"extendStatics");function Qr(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");pg(t,e);function r(){this.constructor=t}o(r,"__"),t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}o(Qr,"__extends");function x_(t,e,r,n){function i(a){return a instanceof r?a:new r(function(c){c(a)})}return o(i,"adopt"),new(r||(r=Promise))(function(a,c){function u(x){try{v(n.next(x))}catch(S){c(S)}}o(u,"fulfilled");function m(x){try{v(n.throw(x))}catch(S){c(S)}}o(m,"rejected");function v(x){x.done?a(x.value):i(x.value).then(u,m)}o(v,"step"),v((n=n.apply(t,e||[])).next())})}o(x_,"__awaiter");function m0(t,e){var r={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},n,i,a,c;return c={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(c[Symbol.iterator]=function(){return this}),c;function u(v){return function(x){return m([v,x])}}function m(v){if(n)throw new TypeError("Generator is already executing.");for(;c&&(c=0,v[0]&&(r=0)),r;)try{if(n=1,i&&(a=v[0]&2?i.return:v[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,v[1])).done)return a;switch(i=0,a&&(v=[v[0]&2,a.value]),v[0]){case 0:case 1:a=v;break;case 4:return r.label++,{value:v[1],done:!1};case 5:r.label++,i=v[1],v=[0];continue;case 7:v=r.ops.pop(),r.trys.pop();continue;default:if(a=r.trys,!(a=a.length>0&&a[a.length-1])&&(v[0]===6||v[0]===2)){r=0;continue}if(v[0]===3&&(!a||v[1]>a[0]&&v[1]<a[3])){r.label=v[1];break}if(v[0]===6&&r.label<a[1]){r.label=a[1],a=v;break}if(a&&r.label<a[2]){r.label=a[2],r.ops.push(v);break}a[2]&&r.ops.pop(),r.trys.pop();continue}v=e.call(t,r)}catch(x){v=[6,x],i=0}finally{n=a=0}if(v[0]&5)throw v[1];return{value:v[0]?v[1]:void 0,done:!0}}}o(m0,"__generator");function os(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}o(os,"__values");function Kn(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,a=[],c;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)a.push(i.value)}catch(u){c={error:u}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(c)throw c.error}}return a}o(Kn,"__read");function Vi(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,a;n<i;n++)(a||!(n in e))&&(a||(a=Array.prototype.slice.call(e,0,n)),a[n]=e[n]);return t.concat(a||Array.prototype.slice.call(e))}o(Vi,"__spreadArray");function rf(t){return this instanceof rf?(this.v=t,this):new rf(t)}o(rf,"__await");function w_(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),i,a=[];return i={},c("next"),c("throw"),c("return"),i[Symbol.asyncIterator]=function(){return this},i;function c(O){n[O]&&(i[O]=function(R){return new Promise(function(D,P){a.push([O,R,D,P])>1||u(O,R)})})}function u(O,R){try{m(n[O](R))}catch(D){S(a[0][3],D)}}function m(O){O.value instanceof rf?Promise.resolve(O.value.v).then(v,x):S(a[0][2],O)}function v(O){u("next",O)}function x(O){u("throw",O)}function S(O,R){O(R),a.shift(),a.length&&u(a[0][0],a[0][1])}}o(w_,"__asyncGenerator");function __(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof os=="function"?os(t):t[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(a){r[a]=t[a]&&function(c){return new Promise(function(u,m){c=t[a](c),i(u,m,c.done,c.value)})}}function i(a,c,u,m){Promise.resolve(m).then(function(v){a({value:v,done:u})},c)}}o(__,"__asyncValues");function At(t){return typeof t=="function"}o(At,"isFunction");function Cc(t){var e=o(function(n){Error.call(n),n.stack=new Error().stack},"_super"),r=t(e);return r.prototype=Object.create(Error.prototype),r.prototype.constructor=r,r}o(Cc,"createErrorClass");var b0=Cc(function(t){return o(function(r){t(this),this.message=r?r.length+` errors occurred during unsubscription:
|
|
816
816
|
`+r.map(function(n,i){return i+1+") "+n.toString()}).join(`
|
|
817
|
-
`):"",this.name="UnsubscriptionError",this.errors=r},"UnsubscriptionErrorImpl")});function nf(t,e){if(t){var r=t.indexOf(e);0<=r&&t.splice(r,1)}}o(nf,"arrRemove");var Js=function(){function t(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return o(t,"Subscription"),t.prototype.unsubscribe=function(){var e,r,n,i,a;if(!this.closed){this.closed=!0;var c=this._parentage;if(c)if(this._parentage=null,Array.isArray(c))try{for(var u=os(c),m=u.next();!m.done;m=u.next()){var v=m.value;v.remove(this)}}catch(P){e={error:P}}finally{try{m&&!m.done&&(r=u.return)&&r.call(u)}finally{if(e)throw e.error}}else c.remove(this);var x=this.initialTeardown;if(At(x))try{x()}catch(P){a=P instanceof b0?P.errors:[P]}var S=this._finalizers;if(S){this._finalizers=null;try{for(var O=os(S),R=O.next();!R.done;R=O.next()){var D=R.value;try{E_(D)}catch(P){a=a??[],P instanceof b0?a=Vi(Vi([],Kn(a)),Kn(P.errors)):a.push(P)}}}catch(P){n={error:P}}finally{try{R&&!R.done&&(i=O.return)&&i.call(O)}finally{if(n)throw n.error}}}if(a)throw new b0(a)}},t.prototype.add=function(e){var r;if(e&&e!==this)if(this.closed)E_(e);else{if(e instanceof t){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(r=this._finalizers)!==null&&r!==void 0?r:[]).push(e)}},t.prototype._hasParent=function(e){var r=this._parentage;return r===e||Array.isArray(r)&&r.includes(e)},t.prototype._addParent=function(e){var r=this._parentage;this._parentage=Array.isArray(r)?(r.push(e),r):r?[r,e]:e},t.prototype._removeParent=function(e){var r=this._parentage;r===e?this._parentage=null:Array.isArray(r)&&nf(r,e)},t.prototype.remove=function(e){var r=this._finalizers;r&&nf(r,e),e instanceof t&&e._removeParent(this)},t.EMPTY=function(){var e=new t;return e.closed=!0,e}(),t}();var mg=Js.EMPTY;function g0(t){return t instanceof Js||t&&"closed"in t&&At(t.remove)&&At(t.add)&&At(t.unsubscribe)}o(g0,"isSubscription");function E_(t){At(t)?t():t.unsubscribe()}o(E_,"execFinalizer");var Wi={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1};var kc={setTimeout:function(t,e){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];var i=kc.delegate;return i?.setTimeout?i.setTimeout.apply(i,Vi([t,e],Kn(r))):setTimeout.apply(void 0,Vi([t,e],Kn(r)))},clearTimeout:function(t){var e=kc.delegate;return(e?.clearTimeout||clearTimeout)(t)},delegate:void 0};function v0(t){kc.setTimeout(function(){var e=Wi.onUnhandledError;if(e)e(t);else throw t})}o(v0,"reportUnhandledError");function bg(){}o(bg,"noop");var A_=function(){return gg("C",void 0,void 0)}();function S_(t){return gg("E",void 0,t)}o(S_,"errorNotification");function M_(t){return gg("N",t,void 0)}o(M_,"nextNotification");function gg(t,e,r){return{kind:t,value:e,error:r}}o(gg,"createNotification");var of=null;function Ic(t){if(Wi.useDeprecatedSynchronousErrorHandling){var e=!of;if(e&&(of={errorThrown:!1,error:null}),t(),e){var r=of,n=r.errorThrown,i=r.error;if(of=null,n)throw i}}else t()}o(Ic,"errorContext");function T_(t){Wi.useDeprecatedSynchronousErrorHandling&&of&&(of.errorThrown=!0,of.error=t)}o(T_,"captureError");var fl=function(t){Qr(e,t);function e(r){var n=t.call(this)||this;return n.isStopped=!1,r?(n.destination=r,g0(r)&&r.add(n)):n.destination=b$,n}return o(e,"Subscriber"),e.create=function(r,n,i){return new x0(r,n,i)},e.prototype.next=function(r){this.isStopped?yg(M_(r),this):this._next(r)},e.prototype.error=function(r){this.isStopped?yg(S_(r),this):(this.isStopped=!0,this._error(r))},e.prototype.complete=function(){this.isStopped?yg(A_,this):(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(r){this.destination.next(r)},e.prototype._error=function(r){try{this.destination.error(r)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(Js);var d$=Function.prototype.bind;function vg(t,e){return d$.call(t,e)}o(vg,"bind");var p$=function(){function t(e){this.partialObserver=e}return o(t,"ConsumerObserver"),t.prototype.next=function(e){var r=this.partialObserver;if(r.next)try{r.next(e)}catch(n){y0(n)}},t.prototype.error=function(e){var r=this.partialObserver;if(r.error)try{r.error(e)}catch(n){y0(n)}else y0(e)},t.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(r){y0(r)}},t}(),x0=function(t){Qr(e,t);function e(r,n,i){var a=t.call(this)||this,c;if(At(r)||!r)c={next:r??void 0,error:n??void 0,complete:i??void 0};else{var u;a&&Wi.useDeprecatedNextContext?(u=Object.create(r),u.unsubscribe=function(){return a.unsubscribe()},c={next:r.next&&vg(r.next,u),error:r.error&&vg(r.error,u),complete:r.complete&&vg(r.complete,u)}):c=r}return a.destination=new p$(c),a}return o(e,"SafeSubscriber"),e}(fl);function y0(t){Wi.useDeprecatedSynchronousErrorHandling?T_(t):v0(t)}o(y0,"handleUnhandledError");function m$(t){throw t}o(m$,"defaultErrorHandler");function yg(t,e){var r=Wi.onStoppedNotification;r&&kc.setTimeout(function(){return r(t,e)})}o(yg,"handleStoppedNotification");var b$={closed:!0,next:bg,error:m$,complete:bg};var Dc=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Oc(t){return t}o(Oc,"identity");function C_(t){return t.length===0?Oc:t.length===1?t[0]:o(function(r){return t.reduce(function(n,i){return i(n)},r)},"piped")}o(C_,"pipeFromArray");var Wt=function(){function t(e){e&&(this._subscribe=e)}return o(t,"Observable"),t.prototype.lift=function(e){var r=new t;return r.source=this,r.operator=e,r},t.prototype.subscribe=function(e,r,n){var i=this,a=v$(e)?e:new x0(e,r,n);return Ic(function(){var c=i,u=c.operator,m=c.source;a.add(u?u.call(a,m):m?i._subscribe(a):i._trySubscribe(a))}),a},t.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(r){e.error(r)}},t.prototype.forEach=function(e,r){var n=this;return r=k_(r),new r(function(i,a){var c=new x0({next:function(u){try{e(u)}catch(m){a(m),c.unsubscribe()}},error:a,complete:i});n.subscribe(c)})},t.prototype._subscribe=function(e){var r;return(r=this.source)===null||r===void 0?void 0:r.subscribe(e)},t.prototype[Dc]=function(){return this},t.prototype.pipe=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return C_(e)(this)},t.prototype.toPromise=function(e){var r=this;return e=k_(e),new e(function(n,i){var a;r.subscribe(function(c){return a=c},function(c){return i(c)},function(){return n(a)})})},t.create=function(e){return new t(e)},t}();function k_(t){var e;return(e=t??Wi.Promise)!==null&&e!==void 0?e:Promise}o(k_,"getPromiseCtor");function g$(t){return t&&At(t.next)&&At(t.error)&&At(t.complete)}o(g$,"isObserver");function v$(t){return t&&t instanceof fl||g$(t)&&g0(t)}o(v$,"isSubscriber");function y$(t){return At(t?.lift)}o(y$,"hasLift");function Dr(t){return function(e){if(y$(e))return e.lift(function(r){try{return t(r,this)}catch(n){this.error(n)}});throw new TypeError("Unable to lift unknown Observable type")}}o(Dr,"operate");function Or(t,e,r,n,i){return new x$(t,e,r,n,i)}o(Or,"createOperatorSubscriber");var x$=function(t){Qr(e,t);function e(r,n,i,a,c,u){var m=t.call(this,r)||this;return m.onFinalize=c,m.shouldUnsubscribe=u,m._next=n?function(v){try{n(v)}catch(x){r.error(x)}}:t.prototype._next,m._error=a?function(v){try{a(v)}catch(x){r.error(x)}finally{this.unsubscribe()}}:t.prototype._error,m._complete=i?function(){try{i()}catch(v){r.error(v)}finally{this.unsubscribe()}}:t.prototype._complete,m}return o(e,"OperatorSubscriber"),e.prototype.unsubscribe=function(){var r;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;t.prototype.unsubscribe.call(this),!n&&((r=this.onFinalize)===null||r===void 0||r.call(this))}},e}(fl);var I_=Cc(function(t){return o(function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"},"ObjectUnsubscribedErrorImpl")});var xg=function(t){Qr(e,t);function e(){var r=t.call(this)||this;return r.closed=!1,r.currentObservers=null,r.observers=[],r.isStopped=!1,r.hasError=!1,r.thrownError=null,r}return o(e,"Subject"),e.prototype.lift=function(r){var n=new D_(this,this);return n.operator=r,n},e.prototype._throwIfClosed=function(){if(this.closed)throw new I_},e.prototype.next=function(r){var n=this;Ic(function(){var i,a;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var c=os(n.currentObservers),u=c.next();!u.done;u=c.next()){var m=u.value;m.next(r)}}catch(v){i={error:v}}finally{try{u&&!u.done&&(a=c.return)&&a.call(c)}finally{if(i)throw i.error}}}})},e.prototype.error=function(r){var n=this;Ic(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=r;for(var i=n.observers;i.length;)i.shift().error(r)}})},e.prototype.complete=function(){var r=this;Ic(function(){if(r._throwIfClosed(),!r.isStopped){r.isStopped=!0;for(var n=r.observers;n.length;)n.shift().complete()}})},e.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(e.prototype,"observed",{get:function(){var r;return((r=this.observers)===null||r===void 0?void 0:r.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(r){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,r)},e.prototype._subscribe=function(r){return this._throwIfClosed(),this._checkFinalizedStatuses(r),this._innerSubscribe(r)},e.prototype._innerSubscribe=function(r){var n=this,i=this,a=i.hasError,c=i.isStopped,u=i.observers;return a||c?mg:(this.currentObservers=null,u.push(r),new Js(function(){n.currentObservers=null,nf(u,r)}))},e.prototype._checkFinalizedStatuses=function(r){var n=this,i=n.hasError,a=n.thrownError,c=n.isStopped;i?r.error(a):c&&r.complete()},e.prototype.asObservable=function(){var r=new Wt;return r.source=this,r},e.create=function(r,n){return new D_(r,n)},e}(Wt);var D_=function(t){Qr(e,t);function e(r,n){var i=t.call(this)||this;return i.destination=r,i.source=n,i}return o(e,"AnonymousSubject"),e.prototype.next=function(r){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.next)===null||i===void 0||i.call(n,r)},e.prototype.error=function(r){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.error)===null||i===void 0||i.call(n,r)},e.prototype.complete=function(){var r,n;(n=(r=this.destination)===null||r===void 0?void 0:r.complete)===null||n===void 0||n.call(r)},e.prototype._subscribe=function(r){var n,i;return(i=(n=this.source)===null||n===void 0?void 0:n.subscribe(r))!==null&&i!==void 0?i:mg},e}(xg);var wg=function(t){Qr(e,t);function e(r){var n=t.call(this)||this;return n._value=r,n}return o(e,"BehaviorSubject"),Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),e.prototype._subscribe=function(r){var n=t.prototype._subscribe.call(this,r);return!n.closed&&r.next(this._value),n},e.prototype.getValue=function(){var r=this,n=r.hasError,i=r.thrownError,a=r._value;if(n)throw i;return this._throwIfClosed(),a},e.prototype.next=function(r){t.prototype.next.call(this,this._value=r)},e}(xg);var _g={now:function(){return(_g.delegate||Date).now()},delegate:void 0};var O_=function(t){Qr(e,t);function e(r,n){return t.call(this)||this}return o(e,"Action"),e.prototype.schedule=function(r,n){return n===void 0&&(n=0),this},e}(Js);var cl={setInterval:function(t,e){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];var i=cl.delegate;return i?.setInterval?i.setInterval.apply(i,Vi([t,e],Kn(r))):setInterval.apply(void 0,Vi([t,e],Kn(r)))},clearInterval:function(t){var e=cl.delegate;return(e?.clearInterval||clearInterval)(t)},delegate:void 0};var R_=function(t){Qr(e,t);function e(r,n){var i=t.call(this,r,n)||this;return i.scheduler=r,i.work=n,i.pending=!1,i}return o(e,"AsyncAction"),e.prototype.schedule=function(r,n){var i;if(n===void 0&&(n=0),this.closed)return this;this.state=r;var a=this.id,c=this.scheduler;return a!=null&&(this.id=this.recycleAsyncId(c,a,n)),this.pending=!0,this.delay=n,this.id=(i=this.id)!==null&&i!==void 0?i:this.requestAsyncId(c,this.id,n),this},e.prototype.requestAsyncId=function(r,n,i){return i===void 0&&(i=0),cl.setInterval(r.flush.bind(r,this),i)},e.prototype.recycleAsyncId=function(r,n,i){if(i===void 0&&(i=0),i!=null&&this.delay===i&&this.pending===!1)return n;n!=null&&cl.clearInterval(n)},e.prototype.execute=function(r,n){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var i=this._execute(r,n);if(i)return i;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(r,n){var i=!1,a;try{this.work(r)}catch(c){i=!0,a=c||new Error("Scheduled action threw falsy error")}if(i)return this.unsubscribe(),a},e.prototype.unsubscribe=function(){if(!this.closed){var r=this,n=r.id,i=r.scheduler,a=i.actions;this.work=this.state=this.scheduler=null,this.pending=!1,nf(a,this),n!=null&&(this.id=this.recycleAsyncId(i,n,null)),this.delay=null,t.prototype.unsubscribe.call(this)}},e}(O_);var Eg=function(){function t(e,r){r===void 0&&(r=t.now),this.schedulerActionCtor=e,this.now=r}return o(t,"Scheduler"),t.prototype.schedule=function(e,r,n){return r===void 0&&(r=0),new this.schedulerActionCtor(this,e).schedule(n,r)},t.now=_g.now,t}();var N_=function(t){Qr(e,t);function e(r,n){n===void 0&&(n=Eg.now);var i=t.call(this,r,n)||this;return i.actions=[],i._active=!1,i}return o(e,"AsyncScheduler"),e.prototype.flush=function(r){var n=this.actions;if(this._active){n.push(r);return}var i;this._active=!0;do if(i=r.execute(r.state,r.delay))break;while(r=n.shift());if(this._active=!1,i){for(;r=n.shift();)r.unsubscribe();throw i}},e}(Eg);var w$=new N_(R_),P_=w$;var w0=new Wt(function(t){return t.complete()});function _0(t){return t&&At(t.schedule)}o(_0,"isScheduler");function L_(t){return t[t.length-1]}o(L_,"last");function B_(t){return _0(L_(t))?t.pop():void 0}o(B_,"popScheduler");function U_(t,e){return typeof L_(t)=="number"?t.pop():e}o(U_,"popNumber");var Rc=o(function(t){return t&&typeof t.length=="number"&&typeof t!="function"},"isArrayLike");function E0(t){return At(t?.then)}o(E0,"isPromise");function A0(t){return At(t[Dc])}o(A0,"isInteropObservable");function S0(t){return Symbol.asyncIterator&&At(t?.[Symbol.asyncIterator])}o(S0,"isAsyncIterable");function M0(t){return new TypeError("You provided "+(t!==null&&typeof t=="object"?"an invalid object":"'"+t+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}o(M0,"createInvalidObservableTypeError");function _$(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}o(_$,"getSymbolIterator");var T0=_$();function C0(t){return At(t?.[T0])}o(C0,"isIterable");function k0(t){return w_(this,arguments,o(function(){var r,n,i,a;return m0(this,function(c){switch(c.label){case 0:r=t.getReader(),c.label=1;case 1:c.trys.push([1,,9,10]),c.label=2;case 2:return[4,rf(r.read())];case 3:return n=c.sent(),i=n.value,a=n.done,a?[4,rf(void 0)]:[3,5];case 4:return[2,c.sent()];case 5:return[4,rf(i)];case 6:return[4,c.sent()];case 7:return c.sent(),[3,2];case 8:return[3,10];case 9:return r.releaseLock(),[7];case 10:return[2]}})},"readableStreamLikeToAsyncGenerator_1"))}o(k0,"readableStreamLikeToAsyncGenerator");function I0(t){return At(t?.getReader)}o(I0,"isReadableStreamLike");function en(t){if(t instanceof Wt)return t;if(t!=null){if(A0(t))return E$(t);if(Rc(t))return A$(t);if(E0(t))return S$(t);if(S0(t))return $_(t);if(C0(t))return M$(t);if(I0(t))return T$(t)}throw M0(t)}o(en,"innerFrom");function E$(t){return new Wt(function(e){var r=t[Dc]();if(At(r.subscribe))return r.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}o(E$,"fromInteropObservable");function A$(t){return new Wt(function(e){for(var r=0;r<t.length&&!e.closed;r++)e.next(t[r]);e.complete()})}o(A$,"fromArrayLike");function S$(t){return new Wt(function(e){t.then(function(r){e.closed||(e.next(r),e.complete())},function(r){return e.error(r)}).then(null,v0)})}o(S$,"fromPromise");function M$(t){return new Wt(function(e){var r,n;try{for(var i=os(t),a=i.next();!a.done;a=i.next()){var c=a.value;if(e.next(c),e.closed)return}}catch(u){r={error:u}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}e.complete()})}o(M$,"fromIterable");function $_(t){return new Wt(function(e){C$(t,e).catch(function(r){return e.error(r)})})}o($_,"fromAsyncIterable");function T$(t){return $_(k0(t))}o(T$,"fromReadableStreamLike");function C$(t,e){var r,n,i,a;return x_(this,void 0,void 0,function(){var c,u;return m0(this,function(m){switch(m.label){case 0:m.trys.push([0,5,6,11]),r=__(t),m.label=1;case 1:return[4,r.next()];case 2:if(n=m.sent(),!!n.done)return[3,4];if(c=n.value,e.next(c),e.closed)return[2];m.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return u=m.sent(),i={error:u},[3,11];case 6:return m.trys.push([6,,9,10]),n&&!n.done&&(a=r.return)?[4,a.call(r)]:[3,8];case 7:m.sent(),m.label=8;case 8:return[3,10];case 9:if(i)throw i.error;return[7];case 10:return[7];case 11:return e.complete(),[2]}})})}o(C$,"process");function Ai(t,e,r,n,i){n===void 0&&(n=0),i===void 0&&(i=!1);var a=e.schedule(function(){r(),i?t.add(this.schedule(null,n)):this.unsubscribe()},n);if(t.add(a),!i)return a}o(Ai,"executeSchedule");function D0(t,e){return e===void 0&&(e=0),Dr(function(r,n){r.subscribe(Or(n,function(i){return Ai(n,t,function(){return n.next(i)},e)},function(){return Ai(n,t,function(){return n.complete()},e)},function(i){return Ai(n,t,function(){return n.error(i)},e)}))})}o(D0,"observeOn");function O0(t,e){return e===void 0&&(e=0),Dr(function(r,n){n.add(t.schedule(function(){return r.subscribe(n)},e))})}o(O0,"subscribeOn");function F_(t,e){return en(t).pipe(O0(e),D0(e))}o(F_,"scheduleObservable");function q_(t,e){return en(t).pipe(O0(e),D0(e))}o(q_,"schedulePromise");function H_(t,e){return new Wt(function(r){var n=0;return e.schedule(function(){n===t.length?r.complete():(r.next(t[n++]),r.closed||this.schedule())})})}o(H_,"scheduleArray");function z_(t,e){return new Wt(function(r){var n;return Ai(r,e,function(){n=t[T0](),Ai(r,e,function(){var i,a,c;try{i=n.next(),a=i.value,c=i.done}catch(u){r.error(u);return}c?r.complete():r.next(a)},0,!0)}),function(){return At(n?.return)&&n.return()}})}o(z_,"scheduleIterable");function R0(t,e){if(!t)throw new Error("Iterable cannot be null");return new Wt(function(r){Ai(r,e,function(){var n=t[Symbol.asyncIterator]();Ai(r,e,function(){n.next().then(function(i){i.done?r.complete():r.next(i.value)})},0,!0)})})}o(R0,"scheduleAsyncIterable");function K_(t,e){return R0(k0(t),e)}o(K_,"scheduleReadableStreamLike");function j_(t,e){if(t!=null){if(A0(t))return F_(t,e);if(Rc(t))return H_(t,e);if(E0(t))return q_(t,e);if(S0(t))return R0(t,e);if(C0(t))return z_(t,e);if(I0(t))return K_(t,e)}throw M0(t)}o(j_,"scheduled");function G_(t,e){return e?j_(t,e):en(t)}o(G_,"from");var N0=Cc(function(t){return o(function(){t(this),this.name="EmptyError",this.message="no elements in sequence"},"EmptyErrorImpl")});function V_(t){return t instanceof Date&&!isNaN(t)}o(V_,"isValidDate");function P0(t,e){return Dr(function(r,n){var i=0;r.subscribe(Or(n,function(a){n.next(t.call(e,a,i++))}))})}o(P0,"map");var k$=Array.isArray;function I$(t,e){return k$(e)?t.apply(void 0,Vi([],Kn(e))):t(e)}o(I$,"callOrApply");function W_(t){return P0(function(e){return I$(t,e)})}o(W_,"mapOneOrManyArgs");function J_(t,e,r,n,i,a,c,u){var m=[],v=0,x=0,S=!1,O=o(function(){S&&!m.length&&!v&&e.complete()},"checkComplete"),R=o(function(P){return v<n?D(P):m.push(P)},"outerNext"),D=o(function(P){a&&e.next(P),v++;var J=!1;en(r(P,x++)).subscribe(Or(e,function(L){i?.(L),a?R(L):e.next(L)},function(){J=!0},void 0,function(){if(J)try{v--;for(var L=o(function(){var W=m.shift();c?Ai(e,c,function(){return D(W)}):D(W)},"_loop_1");m.length&&v<n;)L();O()}catch(W){e.error(W)}}))},"doInnerSub");return t.subscribe(Or(e,R,function(){S=!0,O()})),function(){u?.()}}o(J_,"mergeInternals");function ul(t,e,r){return r===void 0&&(r=1/0),At(e)?ul(function(n,i){return P0(function(a,c){return e(n,a,i,c)})(en(t(n,i)))},r):(typeof e=="number"&&(r=e),Dr(function(n,i){return J_(n,i,t,r)}))}o(ul,"mergeMap");function Y_(t){return t===void 0&&(t=1/0),ul(Oc,t)}o(Y_,"mergeAll");var D$=["addListener","removeListener"],O$=["addEventListener","removeEventListener"],R$=["on","off"];function ll(t,e,r,n){if(At(r)&&(n=r,r=void 0),n)return ll(t,e,r).pipe(W_(n));var i=Kn(L$(t)?O$.map(function(u){return function(m){return t[u](e,m,r)}}):N$(t)?D$.map(X_(t,e)):P$(t)?R$.map(X_(t,e)):[],2),a=i[0],c=i[1];if(!a&&Rc(t))return ul(function(u){return ll(u,e,r)})(en(t));if(!a)throw new TypeError("Invalid event target");return new Wt(function(u){var m=o(function(){for(var v=[],x=0;x<arguments.length;x++)v[x]=arguments[x];return u.next(1<v.length?v:v[0])},"handler");return a(m),function(){return c(m)}})}o(ll,"fromEvent");function X_(t,e){return function(r){return function(n){return t[r](e,n)}}}o(X_,"toCommonHandlerRegistry");function N$(t){return At(t.addListener)&&At(t.removeListener)}o(N$,"isNodeStyleEventEmitter");function P$(t){return At(t.on)&&At(t.off)}o(P$,"isJQueryStyleEventEmitter");function L$(t){return At(t.addEventListener)&&At(t.removeEventListener)}o(L$,"isEventTarget");function hl(t,e,r){t===void 0&&(t=0),r===void 0&&(r=P_);var n=-1;return e!=null&&(_0(e)?r=e:n=e),new Wt(function(i){var a=V_(t)?+t-r.now():t;a<0&&(a=0);var c=0;return r.schedule(function(){i.closed||(i.next(c++),0<=n?this.schedule(void 0,n):i.complete())},a)})}o(hl,"timer");function Ag(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=B_(t),n=U_(t,1/0),i=t;return i.length?i.length===1?en(i[0]):Y_(n)(G_(i,r)):w0}o(Ag,"merge");function Z_(t,e){return Dr(function(r,n){var i=0;r.subscribe(Or(n,function(a){return t.call(e,a,i++)&&n.next(a)}))})}o(Z_,"filter");function Q_(t){return Dr(function(e,r){var n=!1;e.subscribe(Or(r,function(i){n=!0,r.next(i)},function(){n||r.next(t),r.complete()}))})}o(Q_,"defaultIfEmpty");function eE(t){return t<=0?function(){return w0}:Dr(function(e,r){var n=0;e.subscribe(Or(r,function(i){++n<=t&&(r.next(i),t<=n&&r.complete())}))})}o(eE,"take");function tE(t){return t===void 0&&(t=B$),Dr(function(e,r){var n=!1;e.subscribe(Or(r,function(i){n=!0,r.next(i)},function(){return n?r.complete():r.error(t())}))})}o(tE,"throwIfEmpty");function B$(){return new N0}o(B$,"defaultErrorFactory");function Sg(t,e){var r=arguments.length>=2;return function(n){return n.pipe(t?Z_(function(i,a){return t(i,a,n)}):Oc,eE(1),r?Q_(e):tE(function(){return new N0}))}}o(Sg,"first");function Mg(t,e){return Dr(function(r,n){var i=e??{},a=i.leading,c=a===void 0?!0:a,u=i.trailing,m=u===void 0?!1:u,v=!1,x=null,S=null,O=!1,R=o(function(){S?.unsubscribe(),S=null,m&&(J(),O&&n.complete())},"endThrottling"),D=o(function(){S=null,O&&n.complete()},"cleanupThrottling"),P=o(function(L){return S=en(t(L)).subscribe(Or(n,R,D))},"startThrottle"),J=o(function(){if(v){v=!1;var L=x;x=null,n.next(L),!O&&P(L)}},"send");r.subscribe(Or(n,function(L){v=!0,x=L,!(S&&!S.closed)&&(c?J():P(L))},function(){O=!0,!(m&&v&&S&&!S.closed)&&n.complete()}))})}o(Mg,"throttle");var rE;(function(t){t[t.GENESIS=0]="GENESIS",t[t.PARTIAL=1]="PARTIAL",t[t.SIGNED=2]="SIGNED"})(rE||(rE={}));var dl;(function(t){t[t.NOT_REQUESTED=0]="NOT_REQUESTED",t[t.PENDING=1]="PENDING",t[t.PROCESSING=2]="PROCESSING",t[t.ANCHORED=3]="ANCHORED",t[t.FAILED=4]="FAILED"})(dl||(dl={}));var Cg;(function(t){t[t.GENESIS=0]="GENESIS",t[t.SIGNED=1]="SIGNED",t[t.ANCHOR=2]="ANCHOR"})(Cg||(Cg={}));var ss=class extends Wt{constructor(e,r){super(n=>{e.subscribe(n)}),this.state$=e,this._context=r}get id(){return new rt(this.state$.value.type,this.state$.value.log[0].cid)}get api(){return this._context.api}get content(){let{next:e,content:r}=this.state$.value;return(0,Tg.default)(e?.content??r)}get tip(){return this.state$.value.log[this.state$.value.log.length-1].cid}get commitId(){return Pt.make(this.id,this.tip)}get allCommitIds(){return this.state$.value.log.map(({cid:e})=>Pt.make(this.id,e))}get anchorCommitIds(){return this.state$.value.log.filter(({type:e})=>e===Cg.ANCHOR).map(({cid:e})=>Pt.make(this.id,e))}get state(){return(0,Tg.default)(this.state$.value)}async sync(e={}){e={sync:yr.PREFER_CACHE,...e};let r=await this.api.loadStream(this.id,e);this.state$.next(r.state)}async requestAnchor(){return this.api.requestAnchor(this.id)}};o(ss,"Stream");function Nc(){return t=>{}}o(Nc,"StreamStatic");var fE=Lt(oE(),1);function sE(t){let e=new AbortController;if(t.length===0)throw Error("Need abort signals to create a merged abort signal");return t.some(r=>r.aborted)?(e.abort(),e.signal):(Ag(...t.map(r=>ll(r,"abort"))).pipe(Sg()).subscribe(()=>{e.abort()}),e.signal)}o(sE,"mergeAbortSignals");var pl=class{constructor(e){let r=new AbortController;if(this.signal=r.signal,e<=0){r.abort();return}this._subscription=hl(e).subscribe(()=>{r.abort()})}clear(){this._subscription?.unsubscribe()}};o(pl,"TimedAbortSignal");async function aE(t,e){let r=new AbortController,n=o(()=>{r.abort()},"onAbort");return t.addEventListener("abort",n),t.aborted&&r.abort(),e(r.signal).finally(()=>{t.removeEventListener("abort",n)})}o(aE,"abortable");var U$=60*1e3*3;async function Hr(t,e={}){e.body&&Object.assign(e,{body:JSON.stringify(e.body),headers:{...e.headers,"Content-Type":"application/json"}});let r=e.timeout||U$,n=new pl(r),i=e.signal?sE([e.signal,n.signal]):n.signal,a=await aE(i,c=>(0,fE.default)(String(t),{...e,signal:c})).finally(()=>n.clear());if(!a.ok){let c=await a.text();throw new Error(`HTTP request to '${t}' failed with status '${a.statusText}': ${c}`)}return a.json()}o(Hr,"fetchJson");var ml=Lt(Ec(),1);Pi();function fs(t){let e=We.asCID(t);if(e)return e;if(typeof t=="string")return We.parse(t);if(t instanceof Uint8Array)return We.decode(t);throw new Error(`${t} cannot be converted to a CID`)}o(fs,"toCID");var cE=0,Xt=class{static streamIdFromState(e){return new rt(e.type,e.log[0].cid)}static serializeCommit(e){let r=(0,ml.default)(e);return Xt.isSignedCommitContainer(r)?(r.jws.link=r.jws.link.toString(),r.linkedBlock=kt(r.linkedBlock,"base64"),r.cacaoBlock&&(r.cacaoBlock=kt(r.cacaoBlock,"base64")),r):(Xt.isSignedCommit(e)&&(r.link=r.link.toString()),Xt.isAnchorCommit(e)&&(r.proof=r.proof.toString()),r.id&&(r.id=r.id.toString()),r.prev&&(r.prev=r.prev.toString()),e.header?.model&&(r.header.model=kt(e.header.model,"base64")),r)}static deserializeCommit(e){let r=(0,ml.default)(e);return Xt.isSignedCommitContainer(r)?(r.jws.link=fs(r.jws.link),r.linkedBlock=Ot(r.linkedBlock,"base64"),r.cacaoBlock&&(r.cacaoBlock=Ot(r.cacaoBlock,"base64")),r):(Xt.isSignedCommit(r)&&(r.link=fs(r.link)),Xt.isAnchorCommit(r)&&(r.proof=fs(r.proof)),r.id&&(r.id=fs(r.id)),r.prev&&(r.prev=fs(r.prev)),r.header?.model&&(r.header.model=Ot(r.header.model,"base64")),r)}static serializeState(e){let r=(0,ml.default)(e);return r.log=r.log.map(n=>({...n,cid:n.cid.toString()})),r.anchorStatus!=null&&(r.anchorStatus=dl[r.anchorStatus]),r.anchorProof!=null&&(r.anchorProof.txHash=r.anchorProof.txHash.toString(),r.anchorProof.root=r.anchorProof.root.toString()),e.metadata?.model&&(r.metadata.model=e.metadata.model.toString()),e.next?.metadata?.model&&(r.next.metadata.model=e.next.metadata.model.toString()),e.metadata?.unique&&e.type!=cE&&(r.metadata.unique=kt(r.metadata.unique,"base64")),r.doctype=En.nameByCode(r.type),r}static deserializeState(e){if(!e)return null;let r=(0,ml.default)(e);return r.doctype&&(r.type=En.codeByName(r.doctype),delete r.doctype),r.log=r.log.map(n=>({...n,cid:fs(n.cid)})),r.anchorProof&&(r.anchorProof.txHash=fs(r.anchorProof.txHash),r.anchorProof.root=fs(r.anchorProof.root)),r.anchorStatus&&(r.anchorStatus=dl[r.anchorStatus]),e.metadata?.model&&(r.metadata.model=rt.fromString(e.metadata.model)),e.next?.metadata?.model&&(r.next.metadata.model=rt.fromString(e.next.metadata.model)),e.metadata?.unique&&e.type!=cE&&(r.metadata.unique=Ot(e.metadata.unique,"base64")),r}static statesEqual(e,r){return JSON.stringify(Xt.serializeState(e))===JSON.stringify(Xt.serializeState(r))}static isStateSupersetOf(e,r){if(e.log.length<r.log.length)return!1;for(let n in r.log)if(!e.log[n].cid.equals(r.log[n].cid))return!1;return!(e.log.length===r.log.length&&e.anchorStatus!=r.anchorStatus)}static assertCommitLinksToState(e,r){let n=this.streamIdFromState(e);if(r.id&&!r.id.equals(e.log[0].cid))throw new Error(`Invalid genesis CID in commit for StreamID ${n.toString()}. Found: ${r.id}, expected ${e.log[0].cid}`);let i=e.log[e.log.length-1].cid;if(!r.prev.equals(i))throw new Error(`Commit doesn't properly point to previous commit in log. Expected ${i}, found 'prev' ${r.prev}`)}static async convertCommitToSignedCommitContainer(e,r){if(Xt.isSignedCommit(e)){let n=await r.block.get(e.link);return{jws:e,linkedBlock:n}}return e}static isSignedCommitContainer(e){return e&&e.jws!==void 0}static isSignedCommit(e){return e&&e.link!==void 0}static isAnchorCommit(e){return e&&e.proof!==void 0}static isSignedCommitData(e){return e&&e.envelope!==void 0}static isAnchorCommitData(e){return e&&e.proof!==void 0}};o(Xt,"StreamUtils");var bl=class extends wg{next(e){let r=this.value;Xt.statesEqual(r,e)||super.next(e)}};o(bl,"StreamStateSubject");var $$=function(t,e,r,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(t,e,r,n);else for(var u=t.length-1;u>=0;u--)(c=t[u])&&(a=(i<3?c(a):i>3?c(e,r,a):c(e,r))||a);return i>3&&a&&Object.defineProperty(e,r,a),a},jn,kg={anchor:!0,publish:!0,pin:!0,sync:yr.PREFER_CACHE},F$={sync:yr.PREFER_CACHE},uE={anchor:!0,publish:!0,throwOnInvalidCommit:!0};function Ig(t,e){if(typeof t?.schema=="string")try{Pt.fromString(t.schema)}catch{throw new Error("Schema must be a CommitID")}let r={controllers:t?.controllers,family:t?.family,schema:t?.schema?.toString(),tags:t?.tags};if(e)t?.deterministic||(r.unique=kt((0,dE.randomBytes)(12),"base64")),t?.forbidControllerChange&&(r.forbidControllerChange=!0);else{if(t?.deterministic!==void 0||t?.unique!==void 0)throw new Error("Cannot change 'deterministic' or 'unique' properties on existing Streams");if(t?.forbidControllerChange!==void 0)throw new Error("Cannot change 'forbidControllerChange' property on existing Streams")}return Object.keys(r).forEach(n=>r[n]===void 0&&delete r[n]),r}o(Ig,"headerFromMetadata");async function lE(t){if(!t.did)throw new Error("No DID provided");return t.did.authenticated||(await t.did.authenticate(),t.loggerProvider&&t.loggerProvider.getDiagnosticsLogger().imp(`Now authenticated as DID ${t.did.id}`)),t.did}o(lE,"getAuthenticatedDID");async function Dg(){throw new Error("Historical stream commits cannot be modified. Load the stream without specifying a commit to make updates.")}o(Dg,"throwReadOnlyError");var Gn=jn=o(class extends ss{constructor(){super(...arguments),this._isReadOnly=!1}get content(){return super.content}get metadata(){let{next:e,metadata:r}=this.state$.value;return(0,hE.default)(e?.metadata??r)}get controllers(){return this.metadata.controllers}static async create(e,r,n,i={}){i={...kg,...i},!n?.deterministic&&i.syncTimeoutSeconds==null&&(i.syncTimeoutSeconds=0);let a=i.asDID?{did:i.asDID}:e,c=await jn.makeGenesis(a,r,n);return e.createStreamFromGenesis(jn.STREAM_TYPE_ID,c,i)}static async createFromGenesis(e,r,n={}){n={...kg,...n},r.header?.unique&&n.syncTimeoutSeconds==null&&(n.syncTimeoutSeconds=0);let i=r.data?await jn._signDagJWS(e,r):r;return e.createStreamFromGenesis(jn.STREAM_TYPE_ID,i,n)}static async deterministic(e,r,n={}){if(n={...kg,...n},r={...r,deterministic:!0},r.family==null&&r.tags==null)throw new Error("Family and/or tags are required when creating a deterministic tile document");let i=await jn.makeGenesis(e,null,r);return e.createStreamFromGenesis(jn.STREAM_TYPE_ID,i,n)}static async load(e,r,n={}){n={...F$,...n};let i=fn.from(r);if(i.type!=jn.STREAM_TYPE_ID)throw new Error(`StreamID ${i.toString()} does not refer to a '${jn.STREAM_TYPE_NAME}' stream, but to a ${i.typeName}`);return e.loadStream(i,n)}async update(e,r,n={}){n={...uE,...n};let i=n.asDID?{did:n.asDID}:this.api,a=await this.makeCommit(i,e,r),c=await this.api.applyCommit(this.id,a,n);this.state$.next(c.state)}async patch(e,r={}){r={...uE,...r};let i={header:Ig(this.metadata,!1),data:e,prev:this.tip,id:this.id.cid},a=await jn._signDagJWS(this.api,i),c=await this.api.applyCommit(this.id,a,r);this.state$.next(c.state)}makeReadOnly(){this.update=Dg,this.patch=Dg,this.sync=Dg,this._isReadOnly=!0}get isReadOnly(){return this._isReadOnly}async makeCommit(e,r,n){let i=await this._makeRawCommit(r,n);return jn._signDagJWS(e,i)}async _makeRawCommit(e,r){r||(r={});let n=Ig(r,!1);if(e==null&&(e=this.content),n.controllers){if(n.controllers.length!==1)throw new Error("Exactly one controller must be specified");if(!n.controllers[0])throw new Error("Controller cannot be updated to an undefined value.")}let i=r0.compare(this.content,e),a=this.state.log[0];return{header:n,data:i,prev:this.tip,id:a.cid}}static async makeGenesis(e,r,n){if(n||(n={}),!n.controllers||n.controllers.length===0)if(e.did){let c=await lE(e);n.controllers=[c.hasParent?c.parent:c.id]}else throw new Error("No controllers specified");if(n.controllers?.length!==1)throw new Error("Exactly one controller must be specified");let i=Ig(n,!0);if(n?.deterministic&&r)throw new Error("Initial content must be null when creating a deterministic Tile document");if(r==null){let c={header:i};return qa(c),c}let a={data:r,header:i};return jn._signDagJWS(e,a)}static async _signDagJWS(e,r){return(await lE(e)).createDagJWS(r)}},"TileDocument");Gn.STREAM_TYPE_NAME="tile";Gn.STREAM_TYPE_ID=0;Gn=jn=$$([Nc()],Gn);var xE=Lt(bE(),1);function Y$(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}o(Y$,"_checkPrivateRedeclaration");function X$(t,e){return e.get?e.get.call(t):e.value}o(X$,"_classApplyDescriptorGet");function Z$(t,e,r){if(e.set)e.set.call(t,r);else{if(!e.writable)throw new TypeError("attempted to set read only private field");e.value=r}}o(Z$,"_classApplyDescriptorSet");function yE(t,e,r){if(!e.has(t))throw new TypeError("attempted to "+r+" private field on non-instance");return e.get(t)}o(yE,"_classExtractFieldDescriptor");function Pg(t,e){var r=yE(t,e,"get");return X$(t,r)}o(Pg,"_classPrivateFieldGet");function gE(t,e,r){Y$(t,e),e.set(t,r)}o(gE,"_classPrivateFieldInit");function vE(t,e,r){var n=yE(t,e,"set");return Z$(t,n,r),r}o(vE,"_classPrivateFieldSet");function Q$(t){return typeof t=="string"||Pt.isInstance(t)||rt.isInstance(t)?{streamId:t}:{streamId:t.streamId,genesis:t.genesis}}o(Q$,"keyToQuery");function Lg(t){return typeof t=="string"?fn.from(t).toString():Pt.isInstance(t)||rt.isInstance(t)?t.toString():t.streamId.toString()}o(Lg,"keyToString");async function eF(t){let e=await Gn.makeGenesis({},null,{...t,deterministic:!0}),r=await rt.fromGenesis("tile",e);return{genesis:e,streamId:r}}o(eF,"getDeterministicQuery");var tF=o(()=>Promise.resolve([]),"tempBatchLoadFn"),B0=new WeakMap,Bg=new WeakMap,gl=class extends xE.default{cache(e){if(!Pg(this,Bg))return!1;let r=e.id.toString();return this.clear(r).prime(r,e),!0}async create(e,r,n){let i=await Gn.create(Pg(this,B0),e,r,n);return this.cache(i),i}async deterministic(e,r){let n=await eF(e);try{return await super.load(n)}catch{let a=await Gn.createFromGenesis(Pg(this,B0),n.genesis,r);return this.cache(a),a}}async load(e){return await super.load(e)}async update(e,r,n,i){let a=Lg(e);this.clear(a);let c=await this.load({streamId:a});return await c.update(r,n,i),c}constructor(e){super(tF,{cache:!0,cacheKeyFn:Lg,cacheMap:e.cache!=null&&typeof e.cache!="boolean"?e.cache:void 0}),gE(this,B0,{writable:!0,value:void 0}),gE(this,Bg,{writable:!0,value:void 0}),this._batchLoadFn=async r=>{e.cache||this.clearAll();let n=await e.ceramic.multiQuery(r.map(Q$),e.multiqueryTimeout);return r.map(i=>{let a=Lg(i),c=n[a];return c||new Error(`Failed to load stream: ${a}`)})},vE(this,B0,e.ceramic),vE(this,Bg,!!e.cache)}};o(gl,"TileLoader");function Ug(t){return typeof t=="string"?rt.fromString(t):t}o(Ug,"typeStreamID");function wE(t,e){let r=new URL(t);for(let[n,i]of Object.entries(e))rt.isInstance(i)?r.searchParams.set(n,i.toString()):typeof i=="object"?r.searchParams.set(n,JSON.stringify(i)):r.searchParams.set(n,i);return r}o(wE,"serializeObjectToSearchParams");function $g(t){let e={};for(let[r,n]of Object.entries(t))rt.isInstance(n)?e[r]=n.toString():e[r]=n;return e}o($g,"serializeObjectForHttpPost");var tn=class extends Wt{constructor(e,r,n){super(i=>{this.state$.observers.length===0&&(this.periodicSubscription=hl(0,n).pipe(Mg(()=>this._syncState(this.id,{sync:yr.PREFER_CACHE}))).subscribe()),this.state$.subscribe(i).add(()=>{this.state$.observers.length===0&&this.periodicSubscription?.unsubscribe()})}),this.state$=new bl(e),this._apiUrl=new URL(r)}get value(){return this.state$.value}get state(){return this.state$.value}next(e){this.state$.next(e)}async _syncState(e,r){let n=await tn._load(e,this._apiUrl,r);this.state$.next(Xt.deserializeState(n))}get id(){return new rt(this.state$.value.type,this.state$.value.log[0].cid)}static async createFromGenesis(e,r,n,i,a){let c=new URL("./streams",e),{state:u}=await Hr(c,{method:"post",body:{type:r,genesis:Xt.serializeCommit(n),opts:i}});return new tn(Xt.deserializeState(u),e,a)}static async applyCommit(e,r,n,i,a){let c=new URL("./commits",e),{state:u}=await Hr(c,{method:"post",body:{streamId:r.toString(),commit:Xt.serializeCommit(n),opts:i}});return new tn(Xt.deserializeState(u),e,a)}static async _load(e,r,n){let i=wE(new URL(`./streams/${e}`,r),n),{state:a}=await Hr(i);return a}static async load(e,r,n,i){let a=await tn._load(e,r,i);return new tn(Xt.deserializeState(a),r,n)}static async loadStreamCommits(e,r){let n=new URL(`./commits/${e}`,r),{commits:i}=await Hr(n);return i.map(a=>({cid:a.cid,value:Xt.deserializeCommit(a.value)}))}complete(){this.state$.complete()}};o(tn,"Document");var sf;(function(t){t[t.PREFER_CACHE=0]="PREFER_CACHE",t[t.SYNC_ALWAYS=1]="SYNC_ALWAYS",t[t.NEVER_SYNC=2]="NEVER_SYNC",t[t.SYNC_ON_ERROR=3]="SYNC_ON_ERROR"})(sf||(sf={}));var Fg=Lt(Ec(),1);var _E;(function(t){t[t.GENESIS=0]="GENESIS",t[t.PARTIAL=1]="PARTIAL",t[t.SIGNED=2]="SIGNED"})(_E||(_E={}));var qg;(function(t){t[t.GENESIS=0]="GENESIS",t[t.SIGNED=1]="SIGNED",t[t.ANCHOR=2]="ANCHOR"})(qg||(qg={}));var vl=class extends Wt{constructor(e,r){super(n=>{e.subscribe(n)}),this.state$=e,this._context=r}get id(){return new rt(this.state$.value.type,this.state$.value.log[0].cid)}get api(){return this._context.api}get content(){let{next:e,content:r}=this.state$.value;return(0,Fg.default)(e?.content??r)}get tip(){return this.state$.value.log[this.state$.value.log.length-1].cid}get commitId(){return Pt.make(this.id,this.tip)}get allCommitIds(){return this.state$.value.log.map(({cid:e})=>Pt.make(this.id,e))}get anchorCommitIds(){return this.state$.value.log.filter(({type:e})=>e===qg.ANCHOR).map(({cid:e})=>Pt.make(this.id,e))}get state(){return(0,Fg.default)(this.state$.value)}async sync(e={}){e={sync:sf.PREFER_CACHE,...e};let r=await this.api.loadStream(this.id,e);this.state$.next(r.state)}async requestAnchor(){return this.api.requestAnchor(this.id)}};o(vl,"Stream");function EE(){return t=>{}}o(EE,"StreamStatic");function AE(t){if(typeof t=="string"&&t.includes("@")){let[e,r]=t.split("@");if(!e||!r)throw new Error("Invalid accountId provided");return new zs({address:e,chainId:r})}return new zs(t)}o(AE,"normalizeAccountId");var rF="(?:%[0-9a-fA-F]{2})",SE=`(?:[a-zA-Z0-9._-]|${rF})`,nF="([a-z0-9]+)",iF=`((?:${SE}*:)*(${SE}+))`,ME="[a-zA-Z0-9_.:%-]",oF=`;${ME}+=${ME}*`,sF=`((${oF})*)`,aF="(/[^#?]*)?",fF="([?][^#]*)?",cF="(#.*)?",uF=new RegExp(`^did:${nF}:${iF}${sF}${aF}${fF}${cF}$`);function TE(t){if(t===""||!t)return null;let e=t.match(uF);if(e){let r={did:`did:${e[1]}:${e[2]}`,method:e[1],id:e[2],didUrl:t};if(e[4]){let n=e[4].slice(1).split(";");r.params={};for(let i of n){let a=i.split("=");r.params[a[0]]=a[1]}}return e[6]&&(r.path=e[6]),e[7]&&(r.query=e[7].slice(1)),e[8]&&(r.fragment=e[8].slice(1)),r}return null}o(TE,"parse");var kE=Lt(Ec(),1),lF=function(t,e,r,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(t,e,r,n);else for(var u=t.length-1;u>=0;u--)(c=t[u])&&(a=(i<3?c(a):i>3?c(e,r,a):c(e,r))||a);return i>3&&a&&Object.defineProperty(e,r,a),a},af,Hg=o(()=>{throw new Error("Historical stream commits cannot be modified. Load the stream without specifying a commit to make updates.")},"throwReadOnlyError"),CE={anchor:!1,publish:!0,sync:sf.PREFER_CACHE},zg={anchor:!0,publish:!0},hF={sync:sf.PREFER_CACHE},ff=af=o(class extends vl{constructor(){super(...arguments),this._isReadOnly=!1}get did(){return this.content}get metadata(){let{next:e,metadata:r}=this.state$.value;return(0,kE.default)(e?.metadata??r)}get controllers(){return this.metadata.controllers}static async fromAccount(e,r,n={}){n={...CE,...n};let i=AE(r),a=af.makeGenesis(i);return af.fromGenesis(e,a,n)}static async fromGenesis(e,r,n={}){return n={...CE,...n},e.createStreamFromGenesis(af.STREAM_TYPE_ID,r,n)}async setDid(e,r,n={}){n={...zg,...n};let i=typeof e=="string"?e.trim():e.id;if(TE(i)?.did!==i)throw new Error(`DID is not valid: '${i}'`);let c=await r.createLink(i);return this.setDidProof(c,n)}async setDidProof(e,r={}){r={...zg,...r};let n=this.makeCommit(e),i=await this.api.applyCommit(this.id,n,r);this.state$.next(i.state)}async clearDid(e,r={}){r={...zg,...r};let n=await e.createLink("");return this.setDidProof(n,r)}static async load(e,r,n={}){n={...hF,...n};let i=fn.from(r);if(i.type!=af.STREAM_TYPE_ID)throw new Error(`StreamID ${i.toString()} does not refer to a '${af.STREAM_TYPE_NAME}' stream, but to a ${i.typeName}`);return e.loadStream(i,n)}static makeGenesis(e){return e.chainId.namespace==="eip155"&&(e.address=e.address.toLowerCase()),{header:{controllers:[`${e.address}@${e.chainId.toString()}`],family:`caip10-${e.chainId.toString()}`}}}makeCommit(e){return{data:e,prev:this.tip,id:this.id.cid}}makeReadOnly(){this.setDidProof=Hg,this.setDid=Hg,this.sync=Hg,this._isReadOnly=!0}get isReadOnly(){return this._isReadOnly}},"Caip10Link");ff.STREAM_TYPE_NAME="caip10-link";ff.STREAM_TYPE_ID=1;ff=af=lF([EE()],ff);Pi();Aa();var l9=Lt(c9(),1),oq=function(t,e,r,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(t,e,r,n);else for(var u=t.length-1;u>=0;u--)(c=t[u])&&(a=(i<3?c(a):i>3?c(e,r,a):c(e,r))||a);return i>3&&a&&Object.defineProperty(e,r,a),a},yo,sq={sync:yr.PREFER_CACHE};async function u9(t){if(t.did==null)throw new Error("No DID provided");t.did.authenticated||(await t.did.authenticate(),t.loggerProvider&&t.loggerProvider.getDiagnosticsLogger().imp(`Now authenticated as DID ${t.did.id}`))}o(u9,"_ensureAuthenticated");async function aq(){throw new Error("Historical stream commits cannot be modified. Load the stream without specifying a commit to make updates.")}o(aq,"throwReadOnlyError");var Ys=yo=o(class extends ss{constructor(){super(...arguments),this._isReadOnly=!1}get content(){return super.content}get metadata(){return{controller:this.state$.value.metadata.controllers[0],model:yo.MODEL}}static async create(e,r,n){yo.assertComplete(r);let i={publish:!0,anchor:!0,pin:!0,sync:yr.NEVER_SYNC,throwOnInvalidCommit:!0},a=await yo._makeGenesis(e,r,n);return await e.createStreamFromGenesis(yo.STREAM_TYPE_ID,a,i)}static assertComplete(e,r){if(!e.name)throw r?new Error(`Model with StreamID ${r.toString()} is missing a 'name' field`):new Error("Model is missing a 'name' field");if(!e.schema)throw r?new Error(`Model ${e.name} (${r.toString()}) is missing a 'schema' field`):new Error(`Model ${e.name} is missing a 'schema' field`);if(!e.accountRelation)throw r?new Error(`Model ${e.name} (${r.toString()}) is missing a 'accountRelation' field`):new Error(`Model ${e.name} is missing a 'accountRelation' field`)}static async load(e,r,n={}){n={...sq,...n};let i=fn.from(r);if(i.type!=yo.STREAM_TYPE_ID)throw new Error(`StreamID ${i.toString()} does not refer to a '${yo.STREAM_TYPE_NAME}' stream, but to a ${i.typeName}`);return await e.loadStream(i,n)}static async _makeGenesis(e,r,n){let i=await this._makeRawGenesis(e,r,n);return yo._signDagJWS(e,i)}static async _makeRawGenesis(e,r,n){if(r==null)throw new Error("Genesis content cannot be null");if(!n||!n.controller)if(e.did)await u9(e),n={controller:e.did.hasParent?e.did.parent:e.did.id};else throw new Error("No controller specified");let i={controllers:[n.controller],model:yo.MODEL.bytes};return{data:r,header:i}}makeReadOnly(){this.sync=aq,this._isReadOnly=!0}get isReadOnly(){return this._isReadOnly}static async _signDagJWS(e,r){return await u9(e),e.did.createDagJWS(r)}},"Model");Ys.STREAM_TYPE_NAME="model";Ys.STREAM_TYPE_ID=2;Ys.MODEL=function(){let t=qa("model-v1"),e=l9.default.encode(t,"identity"),r=qo(ac,e),n=We.createV1(ac,r);return new rt("UNLOADABLE",n)}();Ys=yo=oq([Nc()],Ys);var p9=Lt(Oa(),1);var fq=function(t,e,r,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(t,e,r,n);else for(var u=t.length-1;u>=0;u--)(c=t[u])&&(a=(i<3?c(a):i>3?c(e,r,a):c(e,r))||a);return i>3&&a&&Object.defineProperty(e,r,a),a},Ji,cq={anchor:!0,publish:!0,pin:!0,sync:yr.NEVER_SYNC,syncTimeoutSeconds:0},uq={anchor:!1,publish:!1,pin:!0,sync:yr.PREFER_CACHE},lq={sync:yr.PREFER_CACHE},h9={anchor:!0,publish:!0,throwOnInvalidCommit:!0};async function d9(t){if(t.did==null)throw new Error("No DID provided");t.did.authenticated||(await t.did.authenticate(),t.loggerProvider&&t.loggerProvider.getDiagnosticsLogger().imp(`Now authenticated as DID ${t.did.id}`))}o(d9,"_ensureAuthenticated");async function Gg(){throw new Error("Historical stream commits cannot be modified. Load the stream without specifying a commit to make updates.")}o(Gg,"throwReadOnlyError");var uf=Ji=o(class extends ss{constructor(){super(...arguments),this._isReadOnly=!1}get content(){return super.content}get metadata(){let e=this.state$.value.metadata;return{controller:e.controllers[0],model:e.model}}static async create(e,r,n,i={}){i={...cq,...i};let a=i.asDID?{did:i.asDID}:e,c=await Ji._makeGenesis(a,r,n);return e.createStreamFromGenesis(Ji.STREAM_TYPE_ID,c,i)}static async single(e,r,n={}){n={...uq,...n};let i=n.asDID?{did:n.asDID}:e;r={...r,deterministic:!0};let a=await Ji._makeGenesis(i,null,r);return e.createStreamFromGenesis(Ji.STREAM_TYPE_ID,a,n)}static async load(e,r,n={}){n={...lq,...n};let i=fn.from(r);if(i.type!=Ji.STREAM_TYPE_ID)throw new Error(`StreamID ${i.toString()} does not refer to a '${Ji.STREAM_TYPE_NAME}' stream, but to a ${i.typeName}`);return e.loadStream(i,n)}async replace(e,r={}){r={...h9,...r};let n=r.asDID?{did:r.asDID}:this.api,i=await this._makeCommit(n,e),a=await this.api.applyCommit(this.id,i,r);this.state$.next(a.state)}async patch(e,r={}){r={...h9,...r};let n={data:e,prev:this.tip,id:this.id.cid},i=await Ji._signDagJWS(this.api,n),a=await this.api.applyCommit(this.id,i,r);this.state$.next(a.state)}makeReadOnly(){this.replace=Gg,this.patch=Gg,this.sync=Gg,this._isReadOnly=!0}get isReadOnly(){return this._isReadOnly}_makeCommit(e,r){let n=this._makeRawCommit(r);return Ji._signDagJWS(e,n)}_makeRawCommit(e){return{data:r0.compare(this.content,e||{}),prev:this.tip,id:this.state.log[0].cid}}static async _makeGenesis(e,r,n){let i=await this._makeRawGenesis(e,r,n);return n.deterministic?(qa(i),i):Ji._signDagJWS(e,i)}static async _makeRawGenesis(e,r,n){if(!n.model)throw new Error("Must specify a 'model' when creating a ModelInstanceDocument");let i=n.controller;if(!i)if(e.did)await d9(e),i=e.did.hasParent?e.did.parent:e.did.id;else throw new Error("No controller specified");let a={controllers:[i],model:n.model.bytes};return n.deterministic||(a.unique=(0,p9.randomBytes)(12)),{data:r,header:a}}static async _signDagJWS(e,r){return await d9(e),e.did.createDagJWS(r)}},"ModelInstanceDocument");uf.STREAM_TYPE_NAME="MID";uf.STREAM_TYPE_ID=3;uf=Ji=fq([Nc()],uf);var wl=class{constructor(e){this._apiUrl=e}async add(e,r){let n={};r&&(n.force=!0);let i=new URL(`./pins/${e}`,this._apiUrl);await Hr(i,{method:"post",body:n})}async rm(e,r){let n=new URL(`./pins/${e}`,this._apiUrl);await Hr(n,{method:"delete",body:{opts:r}})}async ls(e){let r=new URL("./pins",this._apiUrl);e&&(r=new URL(`./pins/${e.toString()}`,this._apiUrl));let n=await Hr(r),{pinnedStreamIds:i}=n;return{[Symbol.asyncIterator](){let a=0;return{next(){return a===i.length?Promise.resolve({value:null,done:!0}):Promise.resolve({value:i[a++],done:!1})}}}}}};o(wl,"RemotePinApi");var _l=class{constructor(e){this._fetchJson=Hr,this._collectionURL=new URL("./collection",e),this._countURL=new URL("./collection/count",e)}async count(e){return(await this._fetchJson(this._countURL,{method:"POST",body:$g(e)})).count}async query(e){let r=await this._fetchJson(this._collectionURL,{method:"POST",body:$g(e)});return{edges:r.edges.map(i=>({cursor:i.cursor,node:Xt.deserializeState(i.node)})),pageInfo:r.pageInfo}}};o(_l,"RemoteIndexApi");var El=class{constructor(e,r){this._apiUrl=e,this._getDidFn=r,this._fetchJson=Hr,this.modelsPath="./admin/models",this.getCodePath="./admin/getCode"}getCodeUrl(){return new URL(this.getCodePath,this._apiUrl)}getModelsUrl(){return new URL(this.modelsPath,this._apiUrl)}async buildJWS(e,r,n){let i=n?{models:n.map(c=>c.toString())}:void 0,a=await e.createJWS({code:r,requestPath:this.getModelsUrl().pathname,requestBody:i});return`${a.signatures[0].protected}.${a.payload}.${a.signatures[0].signature}`}async generateCode(){return(await this._fetchJson(this.getCodeUrl())).code}async startIndexingModels(e){let r=await this.generateCode();await this._fetchJson(this.getModelsUrl(),{method:"post",body:{jws:await this.buildJWS(this._getDidFn(),r,e)}})}async getIndexedModels(){let e=await this.generateCode();return(await this._fetchJson(this.getModelsUrl(),{headers:{Authorization:`Basic ${await this.buildJWS(this._getDidFn(),e)}`}})).models.map(n=>rt.fromString(n))}async stopIndexingModels(e){let r=await this.generateCode();await this._fetchJson(this.getModelsUrl(),{method:"delete",body:{jws:await this.buildJWS(this._getDidFn(),r,e)}})}};o(El,"RemoteAdminApi");var hq="/api/v0/",dq="http://localhost:7007",pq={syncInterval:5e3},mq={anchor:!0,publish:!0,sync:yr.PREFER_CACHE},bq={anchor:!0,publish:!0,sync:yr.PREFER_CACHE},m9={sync:yr.PREFER_CACHE},Al=class{constructor(e=dq,r={}){this._config={...pq,...r},this._apiUrl=new URL(hq,e),this._streamCache=new Map,this.context={api:this},this.pin=new wl(this._apiUrl),this.index=new _l(this._apiUrl);let n=(()=>this.did).bind(this);this.admin=new El(this._apiUrl,n),this._streamConstructors={[ff.STREAM_TYPE_ID]:ff,[Ys.STREAM_TYPE_ID]:Ys,[uf.STREAM_TYPE_ID]:uf,[Gn.STREAM_TYPE_ID]:Gn}}get did(){return this.context.did}set did(e){this.context.did=e}async createStreamFromGenesis(e,r,n={}){n={...bq,...n};let i=await tn.createFromGenesis(this._apiUrl,e,r,n,this._config.syncInterval),a=this._streamCache.get(i.id.toString());return a?(Xt.statesEqual(i.state,a.state)||a.next(i.state),this.buildStreamFromDocument(a)):(this._streamCache.set(i.id.toString(),i),this.buildStreamFromDocument(i))}async loadStream(e,r={}){r={...m9,...r};let n=fn.from(e),i=this._streamCache.get(n.baseID.toString());return i?await i._syncState(n,r):(i=await tn.load(n,this._apiUrl,this._config.syncInterval,r),this._streamCache.set(i.id.toString(),i)),this.buildStreamFromDocument(i)}async multiQuery(e,r){let n=e.map(c=>({...c,streamId:typeof c.streamId=="string"?c.streamId:c.streamId.toString()})),i=new URL("./multiqueries",this._apiUrl),a=await Hr(i,{method:"post",body:{queries:n,timeout:r}});return Object.entries(a).reduce((c,u)=>{let[m,v]=u,x=Xt.deserializeState(v),S=new tn(x,this._apiUrl,this._config.syncInterval);return c[m]=this.buildStreamFromDocument(S),c},{})}loadStreamCommits(e){let r=Ug(e);return tn.loadStreamCommits(r,this._apiUrl)}async applyCommit(e,r,n={}){n={...mq,...n};let i=Ug(e),a=await tn.applyCommit(this._apiUrl,i,r,n,this._config.syncInterval),c=this._streamCache.get(i.toString());return c?(c.next(a.state),this.buildStreamFromDocument(a)):(this._streamCache.set(i.toString(),a),this.buildStreamFromDocument(a))}async requestAnchor(e,r={}){r={...m9,...r};let{anchorStatus:n}=await Hr(`${this._apiUrl}/streams/${e.toString()}/anchor`,{method:"post",body:{opts:r}});return n}addStreamHandler(e){this._streamConstructors[e.name]=e.stream_constructor}buildStreamFromState(e){let r=new tn(e,this._apiUrl,this._config.syncInterval);return this.buildStreamFromDocument(r)}buildStreamFromDocument(e){let r=e.state.type,n=this._streamConstructors[r];if(!n)throw new Error(`Failed to find constructor for stream ${r}`);return new n(e,this.context)}async setDID(e){this.context.did=e}async getSupportedChains(){if(this._supportedChains)return this._supportedChains;let{supportedChains:e}=await Hr(this._apiUrl+"/node/chains");return this._supportedChains=e,e}async close(){Array.from(this._streamCache).map(([,e])=>{e.complete()}),this._streamCache.clear()}};o(Al,"CeramicClient");var Ut;(function(t){t.assertEqual=i=>i;function e(i){}o(e,"assertIs"),t.assertIs=e;function r(i){throw new Error}o(r,"assertNever"),t.assertNever=r,t.arrayToEnum=i=>{let a={};for(let c of i)a[c]=c;return a},t.getValidEnumValues=i=>{let a=t.objectKeys(i).filter(u=>typeof i[i[u]]!="number"),c={};for(let u of a)c[u]=i[u];return t.objectValues(c)},t.objectValues=i=>t.objectKeys(i).map(function(a){return i[a]}),t.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let a=[];for(let c in i)Object.prototype.hasOwnProperty.call(i,c)&&a.push(c);return a},t.find=(i,a)=>{for(let c of i)if(a(c))return c},t.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,a=" | "){return i.map(c=>typeof c=="string"?`'${c}'`:c).join(a)}o(n,"joinValues"),t.joinValues=n,t.jsonStringifyReplacer=(i,a)=>typeof a=="bigint"?a.toString():a})(Ut||(Ut={}));var Fe=Ut.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Xs=o(t=>{switch(typeof t){case"undefined":return Fe.undefined;case"string":return Fe.string;case"number":return isNaN(t)?Fe.nan:Fe.number;case"boolean":return Fe.boolean;case"function":return Fe.function;case"bigint":return Fe.bigint;case"symbol":return Fe.symbol;case"object":return Array.isArray(t)?Fe.array:t===null?Fe.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?Fe.promise:typeof Map<"u"&&t instanceof Map?Fe.map:typeof Set<"u"&&t instanceof Set?Fe.set:typeof Date<"u"&&t instanceof Date?Fe.date:Fe.object;default:return Fe.unknown}},"getParsedType"),Ne=Ut.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"]),gq=o(t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),"quotelessJson"),Si=class extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){let r=e||function(a){return a.message},n={_errors:[]},i=o(a=>{for(let c of a.issues)if(c.code==="invalid_union")c.unionErrors.map(i);else if(c.code==="invalid_return_type")i(c.returnTypeError);else if(c.code==="invalid_arguments")i(c.argumentsError);else if(c.path.length===0)n._errors.push(r(c));else{let u=n,m=0;for(;m<c.path.length;){let v=c.path[m];m===c.path.length-1?(u[v]=u[v]||{_errors:[]},u[v]._errors.push(r(c))):u[v]=u[v]||{_errors:[]},u=u[v],m++}}},"processError");return i(this),n}toString(){return this.message}get message(){return JSON.stringify(this.issues,Ut.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let i of this.issues)i.path.length>0?(r[i.path[0]]=r[i.path[0]]||[],r[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};o(Si,"ZodError");Si.create=t=>new Si(t);var Ml=o((t,e)=>{let r;switch(t.code){case Ne.invalid_type:t.received===Fe.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case Ne.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,Ut.jsonStringifyReplacer)}`;break;case Ne.unrecognized_keys:r=`Unrecognized key(s) in object: ${Ut.joinValues(t.keys,", ")}`;break;case Ne.invalid_union:r="Invalid input";break;case Ne.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Ut.joinValues(t.options)}`;break;case Ne.invalid_enum_value:r=`Invalid enum value. Expected ${Ut.joinValues(t.options)}, received '${t.received}'`;break;case Ne.invalid_arguments:r="Invalid function arguments";break;case Ne.invalid_return_type:r="Invalid function return type";break;case Ne.invalid_date:r="Invalid date";break;case Ne.invalid_string:typeof t.validation=="object"?"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:Ut.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case Ne.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(t.minimum)}`:r="Invalid input";break;case Ne.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(t.maximum)}`:r="Invalid input";break;case Ne.custom:r="Invalid input";break;case Ne.invalid_intersection_types:r="Intersection results could not be merged";break;case Ne.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case Ne.not_finite:r="Number must be finite";break;default:r=e.defaultError,Ut.assertNever(t)}return{message:r}},"errorMap"),y9=Ml;function vq(t){y9=t}o(vq,"setErrorMap");function z0(){return y9}o(z0,"getErrorMap");var K0=o(t=>{let{data:e,path:r,errorMaps:n,issueData:i}=t,a=[...r,...i.path||[]],c={...i,path:a},u="",m=n.filter(v=>!!v).slice().reverse();for(let v of m)u=v(c,{data:e,defaultError:u}).message;return{...i,path:a,message:i.message||u}},"makeIssue"),yq=[];function Ke(t,e){let r=K0({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,z0(),Ml].filter(n=>!!n)});t.common.issues.push(r)}o(Ke,"addIssueToContext");var Rr=class{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let n=[];for(let i of r){if(i.status==="aborted")return gt;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){let n=[];for(let i of r)n.push({key:await i.key,value:await i.value});return Rr.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let i of r){let{key:a,value:c}=i;if(a.status==="aborted"||c.status==="aborted")return gt;a.status==="dirty"&&e.dirty(),c.status==="dirty"&&e.dirty(),(typeof c.value<"u"||i.alwaysSet)&&(n[a.value]=c.value)}return{status:e.value,value:n}}};o(Rr,"ParseStatus");var gt=Object.freeze({status:"aborted"}),x9=o(t=>({status:"dirty",value:t}),"DIRTY"),rn=o(t=>({status:"valid",value:t}),"OK"),Vg=o(t=>t.status==="aborted","isAborted"),Wg=o(t=>t.status==="dirty","isDirty"),j0=o(t=>t.status==="valid","isValid"),G0=o(t=>typeof Promise!==void 0&&t instanceof Promise,"isAsync"),Rt;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(Rt||(Rt={}));var Vn=class{constructor(e,r,n,i){this.parent=e,this.data=r,this._path=n,this._key=i}get path(){return this._path.concat(this._key)}};o(Vn,"ParseInputLazyPath");var b9=o((t,e)=>{if(j0(e))return{success:!0,data:e.value};{if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");let r=new Si(t.common.issues);return{success:!1,error:r}}},"handleResult");function Tt(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:i}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:o((c,u)=>c.code!=="invalid_type"?{message:u.defaultError}:typeof u.data>"u"?{message:n??u.defaultError}:{message:r??u.defaultError},"customMap"),description:i}}o(Tt,"processCreateParams");var xt=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.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return Xs(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:Xs(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Rr,ctx:{common:e.parent.common,data:e.data,parsedType:Xs(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(G0(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){var n;let i={common:{issues:[],async:(n=r?.async)!==null&&n!==void 0?n:!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Xs(e)},a=this._parseSync({data:e,path:i.path,parent:i});return b9(i,a)}async parseAsync(e,r){let n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Xs(e)},i=this._parse({data:e,path:n.path,parent:n}),a=await(G0(i)?i:Promise.resolve(i));return b9(n,a)}refine(e,r){let n=o(i=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(i):r,"getIssueProperties");return this._refinement((i,a)=>{let c=e(i),u=o(()=>a.addIssue({code:Ne.custom,...n(i)}),"setError");return typeof Promise<"u"&&c instanceof Promise?c.then(m=>m?!0:(u(),!1)):c?!0:(u(),!1)})}refinement(e,r){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof r=="function"?r(n,i):r),!1))}_refinement(e){return new Mn({schema:this,typeName:pt.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Jn.create(this)}nullable(){return Eo.create(this)}nullish(){return this.optional().nullable()}array(){return Sn.create(this)}promise(){return hs.create(this)}or(e){return ra.create([this,e])}and(e){return na.create(this,e)}transform(e){return new Mn({schema:this,typeName:pt.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new ca({innerType:this,defaultValue:r,typeName:pt.ZodDefault})}brand(){return new Sl({typeName:pt.ZodBranded,type:this,...Tt(void 0)})}catch(e){let r=typeof e=="function"?e:()=>e;return new mf({innerType:this,defaultValue:r,typeName:pt.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return ua.create(this,e)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};o(xt,"ZodType");var xq=/^c[^\s-]{8,}$/i,wq=/^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i,_q=/^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i,Eq=o(t=>t.precision?t.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${t.precision}}(([+-]\\d{2}:\\d{2})|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${t.precision}}Z$`):t.precision===0?t.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}:\\d{2})|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):t.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}:\\d{2})|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$"),"datetimeRegex"),Mi=class extends xt{constructor(){super(...arguments),this._regex=(e,r,n)=>this.refinement(i=>e.test(i),{validation:r,code:Ne.invalid_string,...Rt.errToObj(n)}),this.nonempty=e=>this.min(1,Rt.errToObj(e)),this.trim=()=>new Mi({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==Fe.string){let a=this._getOrReturnCtx(e);return Ke(a,{code:Ne.invalid_type,expected:Fe.string,received:a.parsedType}),gt}let n=new Rr,i;for(let a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(i=this._getOrReturnCtx(e,i),Ke(i,{code:Ne.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(i=this._getOrReturnCtx(e,i),Ke(i,{code:Ne.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){let c=e.data.length>a.value,u=e.data.length<a.value;(c||u)&&(i=this._getOrReturnCtx(e,i),c?Ke(i,{code:Ne.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):u&&Ke(i,{code:Ne.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")_q.test(e.data)||(i=this._getOrReturnCtx(e,i),Ke(i,{validation:"email",code:Ne.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")wq.test(e.data)||(i=this._getOrReturnCtx(e,i),Ke(i,{validation:"uuid",code:Ne.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")xq.test(e.data)||(i=this._getOrReturnCtx(e,i),Ke(i,{validation:"cuid",code:Ne.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),Ke(i,{validation:"url",code:Ne.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),Ke(i,{validation:"regex",code:Ne.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="startsWith"?e.data.startsWith(a.value)||(i=this._getOrReturnCtx(e,i),Ke(i,{code:Ne.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(i=this._getOrReturnCtx(e,i),Ke(i,{code:Ne.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?Eq(a).test(e.data)||(i=this._getOrReturnCtx(e,i),Ke(i,{code:Ne.invalid_string,validation:"datetime",message:a.message}),n.dirty()):Ut.assertNever(a);return{status:n.value,value:e.data}}_addCheck(e){return new Mi({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Rt.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Rt.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Rt.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Rt.errToObj(e)})}datetime(e){var r;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:(r=e?.offset)!==null&&r!==void 0?r:!1,...Rt.errToObj(e?.message)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...Rt.errToObj(r)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...Rt.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...Rt.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...Rt.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...Rt.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...Rt.errToObj(r)})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get minLength(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};o(Mi,"ZodString");Mi.create=t=>{var e;return new Mi({checks:[],typeName:pt.ZodString,coerce:(e=t?.coerce)!==null&&e!==void 0?e:!1,...Tt(t)})};function Aq(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=r>n?r:n,a=parseInt(t.toFixed(i).replace(".","")),c=parseInt(e.toFixed(i).replace(".",""));return a%c/Math.pow(10,i)}o(Aq,"floatSafeRemainder");var Yi=class extends xt{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)!==Fe.number){let a=this._getOrReturnCtx(e);return Ke(a,{code:Ne.invalid_type,expected:Fe.number,received:a.parsedType}),gt}let n,i=new Rr;for(let a of this._def.checks)a.kind==="int"?Ut.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),Ke(n,{code:Ne.invalid_type,expected:"integer",received:"float",message:a.message}),i.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),Ke(n,{code:Ne.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),i.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),Ke(n,{code:Ne.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),i.dirty()):a.kind==="multipleOf"?Aq(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),Ke(n,{code:Ne.not_multiple_of,multipleOf:a.value,message:a.message}),i.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),Ke(n,{code:Ne.not_finite,message:a.message}),i.dirty()):Ut.assertNever(a);return{status:i.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,Rt.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Rt.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Rt.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Rt.toString(r))}setLimit(e,r,n,i){return new Yi({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:Rt.toString(i)}]})}_addCheck(e){return new Yi({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Rt.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Rt.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Rt.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Rt.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Rt.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Rt.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:Rt.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int")}};o(Yi,"ZodNumber");Yi.create=t=>new Yi({checks:[],typeName:pt.ZodNumber,coerce:t?.coerce||!1,...Tt(t)});var Zs=class extends xt{_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==Fe.bigint){let n=this._getOrReturnCtx(e);return Ke(n,{code:Ne.invalid_type,expected:Fe.bigint,received:n.parsedType}),gt}return rn(e.data)}};o(Zs,"ZodBigInt");Zs.create=t=>{var e;return new Zs({typeName:pt.ZodBigInt,coerce:(e=t?.coerce)!==null&&e!==void 0?e:!1,...Tt(t)})};var Qs=class extends xt{_parse(e){if(this._def.coerce&&(e.data=Boolean(e.data)),this._getType(e)!==Fe.boolean){let n=this._getOrReturnCtx(e);return Ke(n,{code:Ne.invalid_type,expected:Fe.boolean,received:n.parsedType}),gt}return rn(e.data)}};o(Qs,"ZodBoolean");Qs.create=t=>new Qs({typeName:pt.ZodBoolean,coerce:t?.coerce||!1,...Tt(t)});var xo=class extends xt{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==Fe.date){let a=this._getOrReturnCtx(e);return Ke(a,{code:Ne.invalid_type,expected:Fe.date,received:a.parsedType}),gt}if(isNaN(e.data.getTime())){let a=this._getOrReturnCtx(e);return Ke(a,{code:Ne.invalid_date}),gt}let n=new Rr,i;for(let a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(i=this._getOrReturnCtx(e,i),Ke(i,{code:Ne.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(i=this._getOrReturnCtx(e,i),Ke(i,{code:Ne.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):Ut.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new xo({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:Rt.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:Rt.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}};o(xo,"ZodDate");xo.create=t=>new xo({checks:[],coerce:t?.coerce||!1,typeName:pt.ZodDate,...Tt(t)});var lf=class extends xt{_parse(e){if(this._getType(e)!==Fe.symbol){let n=this._getOrReturnCtx(e);return Ke(n,{code:Ne.invalid_type,expected:Fe.symbol,received:n.parsedType}),gt}return rn(e.data)}};o(lf,"ZodSymbol");lf.create=t=>new lf({typeName:pt.ZodSymbol,...Tt(t)});var ea=class extends xt{_parse(e){if(this._getType(e)!==Fe.undefined){let n=this._getOrReturnCtx(e);return Ke(n,{code:Ne.invalid_type,expected:Fe.undefined,received:n.parsedType}),gt}return rn(e.data)}};o(ea,"ZodUndefined");ea.create=t=>new ea({typeName:pt.ZodUndefined,...Tt(t)});var ta=class extends xt{_parse(e){if(this._getType(e)!==Fe.null){let n=this._getOrReturnCtx(e);return Ke(n,{code:Ne.invalid_type,expected:Fe.null,received:n.parsedType}),gt}return rn(e.data)}};o(ta,"ZodNull");ta.create=t=>new ta({typeName:pt.ZodNull,...Tt(t)});var us=class extends xt{constructor(){super(...arguments),this._any=!0}_parse(e){return rn(e.data)}};o(us,"ZodAny");us.create=t=>new us({typeName:pt.ZodAny,...Tt(t)});var wo=class extends xt{constructor(){super(...arguments),this._unknown=!0}_parse(e){return rn(e.data)}};o(wo,"ZodUnknown");wo.create=t=>new wo({typeName:pt.ZodUnknown,...Tt(t)});var Ti=class extends xt{_parse(e){let r=this._getOrReturnCtx(e);return Ke(r,{code:Ne.invalid_type,expected:Fe.never,received:r.parsedType}),gt}};o(Ti,"ZodNever");Ti.create=t=>new Ti({typeName:pt.ZodNever,...Tt(t)});var hf=class extends xt{_parse(e){if(this._getType(e)!==Fe.undefined){let n=this._getOrReturnCtx(e);return Ke(n,{code:Ne.invalid_type,expected:Fe.void,received:n.parsedType}),gt}return rn(e.data)}};o(hf,"ZodVoid");hf.create=t=>new hf({typeName:pt.ZodVoid,...Tt(t)});var Sn=class extends xt{_parse(e){let{ctx:r,status:n}=this._processInputParams(e),i=this._def;if(r.parsedType!==Fe.array)return Ke(r,{code:Ne.invalid_type,expected:Fe.array,received:r.parsedType}),gt;if(i.exactLength!==null){let c=r.data.length>i.exactLength.value,u=r.data.length<i.exactLength.value;(c||u)&&(Ke(r,{code:c?Ne.too_big:Ne.too_small,minimum:u?i.exactLength.value:void 0,maximum:c?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&r.data.length<i.minLength.value&&(Ke(r,{code:Ne.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&r.data.length>i.maxLength.value&&(Ke(r,{code:Ne.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),r.common.async)return Promise.all(r.data.map((c,u)=>i.type._parseAsync(new Vn(r,c,r.path,u)))).then(c=>Rr.mergeArray(n,c));let a=r.data.map((c,u)=>i.type._parseSync(new Vn(r,c,r.path,u)));return Rr.mergeArray(n,a)}get element(){return this._def.type}min(e,r){return new Sn({...this._def,minLength:{value:e,message:Rt.toString(r)}})}max(e,r){return new Sn({...this._def,maxLength:{value:e,message:Rt.toString(r)}})}length(e,r){return new Sn({...this._def,exactLength:{value:e,message:Rt.toString(r)}})}nonempty(e){return this.min(1,e)}};o(Sn,"ZodArray");Sn.create=(t,e)=>new Sn({type:t,minLength:null,maxLength:null,exactLength:null,typeName:pt.ZodArray,...Tt(e)});var V0;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(V0||(V0={}));var g9=o(t=>e=>new er({...t,shape:()=>({...t.shape(),...e})}),"AugmentFactory");function $c(t){if(t instanceof er){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=Jn.create($c(n))}return new er({...t._def,shape:()=>e})}else return t instanceof Sn?Sn.create($c(t.element)):t instanceof Jn?Jn.create($c(t.unwrap())):t instanceof Eo?Eo.create($c(t.unwrap())):t instanceof Wn?Wn.create(t.items.map(e=>$c(e))):t}o($c,"deepPartialify");var er=class extends xt{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=g9(this._def),this.extend=g9(this._def)}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=Ut.objectKeys(e);return this._cached={shape:e,keys:r}}_parse(e){if(this._getType(e)!==Fe.object){let v=this._getOrReturnCtx(e);return Ke(v,{code:Ne.invalid_type,expected:Fe.object,received:v.parsedType}),gt}let{status:n,ctx:i}=this._processInputParams(e),{shape:a,keys:c}=this._getCached(),u=[];if(!(this._def.catchall instanceof Ti&&this._def.unknownKeys==="strip"))for(let v in i.data)c.includes(v)||u.push(v);let m=[];for(let v of c){let x=a[v],S=i.data[v];m.push({key:{status:"valid",value:v},value:x._parse(new Vn(i,S,i.path,v)),alwaysSet:v in i.data})}if(this._def.catchall instanceof Ti){let v=this._def.unknownKeys;if(v==="passthrough")for(let x of u)m.push({key:{status:"valid",value:x},value:{status:"valid",value:i.data[x]}});else if(v==="strict")u.length>0&&(Ke(i,{code:Ne.unrecognized_keys,keys:u}),n.dirty());else if(v!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let v=this._def.catchall;for(let x of u){let S=i.data[x];m.push({key:{status:"valid",value:x},value:v._parse(new Vn(i,S,i.path,x)),alwaysSet:x in i.data})}}return i.common.async?Promise.resolve().then(async()=>{let v=[];for(let x of m){let S=await x.key;v.push({key:S,value:await x.value,alwaysSet:x.alwaysSet})}return v}).then(v=>Rr.mergeObjectSync(n,v)):Rr.mergeObjectSync(n,m)}get shape(){return this._def.shape()}strict(e){return Rt.errToObj,new er({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{var i,a,c,u;let m=(c=(a=(i=this._def).errorMap)===null||a===void 0?void 0:a.call(i,r,n).message)!==null&&c!==void 0?c:n.defaultError;return r.code==="unrecognized_keys"?{message:(u=Rt.errToObj(e).message)!==null&&u!==void 0?u:m}:{message:m}}}:{}})}strip(){return new er({...this._def,unknownKeys:"strip"})}passthrough(){return new er({...this._def,unknownKeys:"passthrough"})}setKey(e,r){return this.augment({[e]:r})}merge(e){return new er({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>V0.mergeShapes(this._def.shape(),e._def.shape()),typeName:pt.ZodObject})}catchall(e){return new er({...this._def,catchall:e})}pick(e){let r={};return Ut.objectKeys(e).map(n=>{this.shape[n]&&(r[n]=this.shape[n])}),new er({...this._def,shape:()=>r})}omit(e){let r={};return Ut.objectKeys(this.shape).map(n=>{Ut.objectKeys(e).indexOf(n)===-1&&(r[n]=this.shape[n])}),new er({...this._def,shape:()=>r})}deepPartial(){return $c(this)}partial(e){let r={};if(e)return Ut.objectKeys(this.shape).map(n=>{Ut.objectKeys(e).indexOf(n)===-1?r[n]=this.shape[n]:r[n]=this.shape[n].optional()}),new er({...this._def,shape:()=>r});for(let n in this.shape){let i=this.shape[n];r[n]=i.optional()}return new er({...this._def,shape:()=>r})}required(e){let r={};if(e)Ut.objectKeys(this.shape).map(n=>{if(Ut.objectKeys(e).indexOf(n)===-1)r[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof Jn;)a=a._def.innerType;r[n]=a}});else for(let n in this.shape){let a=this.shape[n];for(;a instanceof Jn;)a=a._def.innerType;r[n]=a}return new er({...this._def,shape:()=>r})}keyof(){return w9(Ut.objectKeys(this.shape))}};o(er,"ZodObject");er.create=(t,e)=>new er({shape:()=>t,unknownKeys:"strip",catchall:Ti.create(),typeName:pt.ZodObject,...Tt(e)});er.strictCreate=(t,e)=>new er({shape:()=>t,unknownKeys:"strict",catchall:Ti.create(),typeName:pt.ZodObject,...Tt(e)});er.lazycreate=(t,e)=>new er({shape:t,unknownKeys:"strip",catchall:Ti.create(),typeName:pt.ZodObject,...Tt(e)});var ra=class extends xt{_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function i(a){for(let u of a)if(u.result.status==="valid")return u.result;for(let u of a)if(u.result.status==="dirty")return r.common.issues.push(...u.ctx.common.issues),u.result;let c=a.map(u=>new Si(u.ctx.common.issues));return Ke(r,{code:Ne.invalid_union,unionErrors:c}),gt}if(o(i,"handleResults"),r.common.async)return Promise.all(n.map(async a=>{let c={...r,common:{...r.common,issues:[]},parent:null};return{result:await a._parseAsync({data:r.data,path:r.path,parent:c}),ctx:c}})).then(i);{let a,c=[];for(let m of n){let v={...r,common:{...r.common,issues:[]},parent:null},x=m._parseSync({data:r.data,path:r.path,parent:v});if(x.status==="valid")return x;x.status==="dirty"&&!a&&(a={result:x,ctx:v}),v.common.issues.length&&c.push(v.common.issues)}if(a)return r.common.issues.push(...a.ctx.common.issues),a.result;let u=c.map(m=>new Si(m));return Ke(r,{code:Ne.invalid_union,unionErrors:u}),gt}}get options(){return this._def.options}};o(ra,"ZodUnion");ra.create=(t,e)=>new ra({options:t,typeName:pt.ZodUnion,...Tt(e)});var H0=o(t=>t instanceof oa?H0(t.schema):t instanceof Mn?H0(t.innerType()):t instanceof sa?[t.value]:t instanceof aa?t.options:t instanceof fa?Object.keys(t.enum):t instanceof ca?H0(t._def.innerType):t instanceof ea?[void 0]:t instanceof ta?[null]:null,"getDiscriminator"),df=class extends xt{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==Fe.object)return Ke(r,{code:Ne.invalid_type,expected:Fe.object,received:r.parsedType}),gt;let n=this.discriminator,i=r.data[n],a=this.optionsMap.get(i);return a?r.common.async?a._parseAsync({data:r.data,path:r.path,parent:r}):a._parseSync({data:r.data,path:r.path,parent:r}):(Ke(r,{code:Ne.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),gt)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let i=new Map;for(let a of r){let c=H0(a.shape[e]);if(!c)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let u of c){if(i.has(u))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(u)}`);i.set(u,a)}}return new df({typeName:pt.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:i,...Tt(n)})}};o(df,"ZodDiscriminatedUnion");function Jg(t,e){let r=Xs(t),n=Xs(e);if(t===e)return{valid:!0,data:t};if(r===Fe.object&&n===Fe.object){let i=Ut.objectKeys(e),a=Ut.objectKeys(t).filter(u=>i.indexOf(u)!==-1),c={...t,...e};for(let u of a){let m=Jg(t[u],e[u]);if(!m.valid)return{valid:!1};c[u]=m.data}return{valid:!0,data:c}}else if(r===Fe.array&&n===Fe.array){if(t.length!==e.length)return{valid:!1};let i=[];for(let a=0;a<t.length;a++){let c=t[a],u=e[a],m=Jg(c,u);if(!m.valid)return{valid:!1};i.push(m.data)}return{valid:!0,data:i}}else return r===Fe.date&&n===Fe.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}o(Jg,"mergeValues");var na=class extends xt{_parse(e){let{status:r,ctx:n}=this._processInputParams(e),i=o((a,c)=>{if(Vg(a)||Vg(c))return gt;let u=Jg(a.value,c.value);return u.valid?((Wg(a)||Wg(c))&&r.dirty(),{status:r.value,value:u.data}):(Ke(n,{code:Ne.invalid_intersection_types}),gt)},"handleParsed");return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,c])=>i(a,c)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};o(na,"ZodIntersection");na.create=(t,e,r)=>new na({left:t,right:e,typeName:pt.ZodIntersection,...Tt(r)});var Wn=class extends xt{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==Fe.array)return Ke(n,{code:Ne.invalid_type,expected:Fe.array,received:n.parsedType}),gt;if(n.data.length<this._def.items.length)return Ke(n,{code:Ne.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),gt;!this._def.rest&&n.data.length>this._def.items.length&&(Ke(n,{code:Ne.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let a=n.data.map((c,u)=>{let m=this._def.items[u]||this._def.rest;return m?m._parse(new Vn(n,c,n.path,u)):null}).filter(c=>!!c);return n.common.async?Promise.all(a).then(c=>Rr.mergeArray(r,c)):Rr.mergeArray(r,a)}get items(){return this._def.items}rest(e){return new Wn({...this._def,rest:e})}};o(Wn,"ZodTuple");Wn.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Wn({items:t,typeName:pt.ZodTuple,rest:null,...Tt(e)})};var ia=class extends xt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==Fe.object)return Ke(n,{code:Ne.invalid_type,expected:Fe.object,received:n.parsedType}),gt;let i=[],a=this._def.keyType,c=this._def.valueType;for(let u in n.data)i.push({key:a._parse(new Vn(n,u,n.path,u)),value:c._parse(new Vn(n,n.data[u],n.path,u))});return n.common.async?Rr.mergeObjectAsync(r,i):Rr.mergeObjectSync(r,i)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof xt?new ia({keyType:e,valueType:r,typeName:pt.ZodRecord,...Tt(n)}):new ia({keyType:Mi.create(),valueType:e,typeName:pt.ZodRecord,...Tt(r)})}};o(ia,"ZodRecord");var pf=class extends xt{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==Fe.map)return Ke(n,{code:Ne.invalid_type,expected:Fe.map,received:n.parsedType}),gt;let i=this._def.keyType,a=this._def.valueType,c=[...n.data.entries()].map(([u,m],v)=>({key:i._parse(new Vn(n,u,n.path,[v,"key"])),value:a._parse(new Vn(n,m,n.path,[v,"value"]))}));if(n.common.async){let u=new Map;return Promise.resolve().then(async()=>{for(let m of c){let v=await m.key,x=await m.value;if(v.status==="aborted"||x.status==="aborted")return gt;(v.status==="dirty"||x.status==="dirty")&&r.dirty(),u.set(v.value,x.value)}return{status:r.value,value:u}})}else{let u=new Map;for(let m of c){let v=m.key,x=m.value;if(v.status==="aborted"||x.status==="aborted")return gt;(v.status==="dirty"||x.status==="dirty")&&r.dirty(),u.set(v.value,x.value)}return{status:r.value,value:u}}}};o(pf,"ZodMap");pf.create=(t,e,r)=>new pf({valueType:e,keyType:t,typeName:pt.ZodMap,...Tt(r)});var _o=class extends xt{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==Fe.set)return Ke(n,{code:Ne.invalid_type,expected:Fe.set,received:n.parsedType}),gt;let i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(Ke(n,{code:Ne.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),r.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(Ke(n,{code:Ne.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),r.dirty());let a=this._def.valueType;function c(m){let v=new Set;for(let x of m){if(x.status==="aborted")return gt;x.status==="dirty"&&r.dirty(),v.add(x.value)}return{status:r.value,value:v}}o(c,"finalizeSet");let u=[...n.data.values()].map((m,v)=>a._parse(new Vn(n,m,n.path,v)));return n.common.async?Promise.all(u).then(m=>c(m)):c(u)}min(e,r){return new _o({...this._def,minSize:{value:e,message:Rt.toString(r)}})}max(e,r){return new _o({...this._def,maxSize:{value:e,message:Rt.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};o(_o,"ZodSet");_o.create=(t,e)=>new _o({valueType:t,minSize:null,maxSize:null,typeName:pt.ZodSet,...Tt(e)});var ls=class extends xt{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==Fe.function)return Ke(r,{code:Ne.invalid_type,expected:Fe.function,received:r.parsedType}),gt;function n(u,m){return K0({data:u,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,z0(),Ml].filter(v=>!!v),issueData:{code:Ne.invalid_arguments,argumentsError:m}})}o(n,"makeArgsIssue");function i(u,m){return K0({data:u,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,z0(),Ml].filter(v=>!!v),issueData:{code:Ne.invalid_return_type,returnTypeError:m}})}o(i,"makeReturnsIssue");let a={errorMap:r.common.contextualErrorMap},c=r.data;return this._def.returns instanceof hs?rn(async(...u)=>{let m=new Si([]),v=await this._def.args.parseAsync(u,a).catch(O=>{throw m.addIssue(n(u,O)),m}),x=await c(...v);return await this._def.returns._def.type.parseAsync(x,a).catch(O=>{throw m.addIssue(i(x,O)),m})}):rn((...u)=>{let m=this._def.args.safeParse(u,a);if(!m.success)throw new Si([n(u,m.error)]);let v=c(...m.data),x=this._def.returns.safeParse(v,a);if(!x.success)throw new Si([i(v,x.error)]);return x.data})}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ls({...this._def,args:Wn.create(e).rest(wo.create())})}returns(e){return new ls({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new ls({args:e||Wn.create([]).rest(wo.create()),returns:r||wo.create(),typeName:pt.ZodFunction,...Tt(n)})}};o(ls,"ZodFunction");var oa=class extends xt{get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};o(oa,"ZodLazy");oa.create=(t,e)=>new oa({getter:t,typeName:pt.ZodLazy,...Tt(e)});var sa=class extends xt{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return Ke(r,{code:Ne.invalid_literal,expected:this._def.value}),gt}return{status:"valid",value:e.data}}get value(){return this._def.value}};o(sa,"ZodLiteral");sa.create=(t,e)=>new sa({value:t,typeName:pt.ZodLiteral,...Tt(e)});function w9(t,e){return new aa({values:t,typeName:pt.ZodEnum,...Tt(e)})}o(w9,"createZodEnum");var aa=class extends xt{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return Ke(r,{expected:Ut.joinValues(n),received:r.parsedType,code:Ne.invalid_type}),gt}if(this._def.values.indexOf(e.data)===-1){let r=this._getOrReturnCtx(e),n=this._def.values;return Ke(r,{received:r.data,code:Ne.invalid_enum_value,options:n}),gt}return rn(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}};o(aa,"ZodEnum");aa.create=w9;var fa=class extends xt{_parse(e){let r=Ut.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==Fe.string&&n.parsedType!==Fe.number){let i=Ut.objectValues(r);return Ke(n,{expected:Ut.joinValues(i),received:n.parsedType,code:Ne.invalid_type}),gt}if(r.indexOf(e.data)===-1){let i=Ut.objectValues(r);return Ke(n,{received:n.data,code:Ne.invalid_enum_value,options:i}),gt}return rn(e.data)}get enum(){return this._def.values}};o(fa,"ZodNativeEnum");fa.create=(t,e)=>new fa({values:t,typeName:pt.ZodNativeEnum,...Tt(e)});var hs=class extends xt{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==Fe.promise&&r.common.async===!1)return Ke(r,{code:Ne.invalid_type,expected:Fe.promise,received:r.parsedType}),gt;let n=r.parsedType===Fe.promise?r.data:Promise.resolve(r.data);return rn(n.then(i=>this._def.type.parseAsync(i,{path:r.path,errorMap:r.common.contextualErrorMap})))}};o(hs,"ZodPromise");hs.create=(t,e)=>new hs({type:t,typeName:pt.ZodPromise,...Tt(e)});var Mn=class extends xt{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===pt.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),i=this._def.effect||null;if(i.type==="preprocess"){let c=i.transform(n.data);return n.common.async?Promise.resolve(c).then(u=>this._def.schema._parseAsync({data:u,path:n.path,parent:n})):this._def.schema._parseSync({data:c,path:n.path,parent:n})}let a={addIssue:c=>{Ke(n,c),c.fatal?r.abort():r.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),i.type==="refinement"){let c=o(u=>{let m=i.refinement(u,a);if(n.common.async)return Promise.resolve(m);if(m instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return u},"executeRefinement");if(n.common.async===!1){let u=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return u.status==="aborted"?gt:(u.status==="dirty"&&r.dirty(),c(u.value),{status:r.value,value:u.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(u=>u.status==="aborted"?gt:(u.status==="dirty"&&r.dirty(),c(u.value).then(()=>({status:r.value,value:u.value}))))}if(i.type==="transform")if(n.common.async===!1){let c=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!j0(c))return c;let u=i.transform(c.value,a);if(u instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:u}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(c=>j0(c)?Promise.resolve(i.transform(c.value,a)).then(u=>({status:r.value,value:u})):c);Ut.assertNever(i)}};o(Mn,"ZodEffects");Mn.create=(t,e,r)=>new Mn({schema:t,typeName:pt.ZodEffects,effect:e,...Tt(r)});Mn.createWithPreprocess=(t,e,r)=>new Mn({schema:e,effect:{type:"preprocess",transform:t},typeName:pt.ZodEffects,...Tt(r)});var Jn=class extends xt{_parse(e){return this._getType(e)===Fe.undefined?rn(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};o(Jn,"ZodOptional");Jn.create=(t,e)=>new Jn({innerType:t,typeName:pt.ZodOptional,...Tt(e)});var Eo=class extends xt{_parse(e){return this._getType(e)===Fe.null?rn(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};o(Eo,"ZodNullable");Eo.create=(t,e)=>new Eo({innerType:t,typeName:pt.ZodNullable,...Tt(e)});var ca=class extends xt{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===Fe.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};o(ca,"ZodDefault");ca.create=(t,e)=>new ca({innerType:t,typeName:pt.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Tt(e)});var mf=class extends xt{_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.innerType._parse({data:r.data,path:r.path,parent:r});return G0(n)?n.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.defaultValue()})):{status:"valid",value:n.status==="valid"?n.value:this._def.defaultValue()}}removeDefault(){return this._def.innerType}};o(mf,"ZodCatch");mf.create=(t,e)=>new mf({innerType:t,typeName:pt.ZodCatch,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Tt(e)});var bf=class extends xt{_parse(e){if(this._getType(e)!==Fe.nan){let n=this._getOrReturnCtx(e);return Ke(n,{code:Ne.invalid_type,expected:Fe.nan,received:n.parsedType}),gt}return{status:"valid",value:e.data}}};o(bf,"ZodNaN");bf.create=t=>new bf({typeName:pt.ZodNaN,...Tt(t)});var Sq=Symbol("zod_brand"),Sl=class extends xt{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}};o(Sl,"ZodBranded");var ua=class extends xt{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return o(async()=>{let a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?gt:a.status==="dirty"?(r.dirty(),x9(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})},"handleAsync")();{let i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?gt:i.status==="dirty"?(r.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,r){return new ua({in:e,out:r,typeName:pt.ZodPipeline})}};o(ua,"ZodPipeline");var _9=o((t,e={},r)=>t?us.create().superRefine((n,i)=>{if(!t(n)){let a=typeof e=="function"?e(n):e,c=typeof a=="string"?{message:a}:a;i.addIssue({code:"custom",...c,fatal:r})}}):us.create(),"custom"),Mq={object:er.lazycreate},pt;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline"})(pt||(pt={}));var Tq=o((t,e={message:`Input not instance of ${t.name}`})=>_9(r=>r instanceof t,e,!0),"instanceOfType"),E9=Mi.create,A9=Yi.create,Cq=bf.create,kq=Zs.create,S9=Qs.create,Iq=xo.create,Dq=lf.create,Oq=ea.create,Rq=ta.create,Nq=us.create,Pq=wo.create,Lq=Ti.create,Bq=hf.create,Uq=Sn.create,$q=er.create,Fq=er.strictCreate,qq=ra.create,Hq=df.create,zq=na.create,Kq=Wn.create,jq=ia.create,Gq=pf.create,Vq=_o.create,Wq=ls.create,Jq=oa.create,Yq=sa.create,Xq=aa.create,Zq=fa.create,Qq=hs.create,v9=Mn.create,eH=Jn.create,tH=Eo.create,rH=Mn.createWithPreprocess,nH=ua.create,iH=o(()=>E9().optional(),"ostring"),oH=o(()=>A9().optional(),"onumber"),sH=o(()=>S9().optional(),"oboolean"),aH={string:t=>Mi.create({...t,coerce:!0}),number:t=>Yi.create({...t,coerce:!0}),boolean:t=>Qs.create({...t,coerce:!0}),bigint:t=>Zs.create({...t,coerce:!0}),date:t=>xo.create({...t,coerce:!0})},fH=gt,V=Object.freeze({__proto__:null,defaultErrorMap:Ml,setErrorMap:vq,getErrorMap:z0,makeIssue:K0,EMPTY_PATH:yq,addIssueToContext:Ke,ParseStatus:Rr,INVALID:gt,DIRTY:x9,OK:rn,isAborted:Vg,isDirty:Wg,isValid:j0,isAsync:G0,get util(){return Ut},ZodParsedType:Fe,getParsedType:Xs,ZodType:xt,ZodString:Mi,ZodNumber:Yi,ZodBigInt:Zs,ZodBoolean:Qs,ZodDate:xo,ZodSymbol:lf,ZodUndefined:ea,ZodNull:ta,ZodAny:us,ZodUnknown:wo,ZodNever:Ti,ZodVoid:hf,ZodArray:Sn,get objectUtil(){return V0},ZodObject:er,ZodUnion:ra,ZodDiscriminatedUnion:df,ZodIntersection:na,ZodTuple:Wn,ZodRecord:ia,ZodMap:pf,ZodSet:_o,ZodFunction:ls,ZodLazy:oa,ZodLiteral:sa,ZodEnum:aa,ZodNativeEnum:fa,ZodPromise:hs,ZodEffects:Mn,ZodTransformer:Mn,ZodOptional:Jn,ZodNullable:Eo,ZodDefault:ca,ZodCatch:mf,ZodNaN:bf,BRAND:Sq,ZodBranded:Sl,ZodPipeline:ua,custom:_9,Schema:xt,ZodSchema:xt,late:Mq,get ZodFirstPartyTypeKind(){return pt},coerce:aH,any:Nq,array:Uq,bigint:kq,boolean:S9,date:Iq,discriminatedUnion:Hq,effect:v9,enum:Xq,function:Wq,instanceof:Tq,intersection:zq,lazy:Jq,literal:Yq,map:Gq,nan:Cq,nativeEnum:Zq,never:Lq,null:Rq,nullable:tH,number:A9,object:$q,oboolean:sH,onumber:oH,optional:eH,ostring:iH,pipeline:nH,preprocess:rH,promise:Qq,record:jq,set:Vq,strictObject:Fq,string:E9,symbol:Dq,transformer:v9,tuple:Kq,undefined:Oq,union:qq,unknown:Pq,void:Bq,NEVER:fH,ZodIssueCode:Ne,quotelessJson:gq,ZodError:Si});var T9=V.array(V.string().or(V.record(V.any()))),qte=V.object({type:V.string().optional(),narrative:V.string().optional()}),J0=V.string().or(V.object({id:V.string(),type:V.string(),caption:V.string().optional()})),cH=V.object({type:V.string().min(1).or(V.string().array().nonempty()),latitude:V.number(),longitude:V.number()}),uH=V.object({type:V.string().min(1).or(V.string().array().nonempty()),addressCountry:V.string().optional(),addressCountryCode:V.string().optional(),addressRegion:V.string().optional(),addressLocality:V.string().optional(),streetAddress:V.string().optional(),postOfficeBoxNumber:V.string().optional(),postalCode:V.string().optional(),geo:cH.optional()}),lH=V.enum(["sourcedId","systemId","productId","userName","accountId","emailAddress","nationalIdentityNumber","isbn","issn","lisSourcedId","oneRosterSourcedId","sisSourcedId","ltiContextId","ltiDeploymentId","ltiToolId","ltiPlatformId","ltiUserId","identifier"]).or(V.string()),C9=V.object({type:V.string().min(1).or(V.string().array().nonempty()),identifier:V.string(),identifierType:lH}),Tl=V.string().or(V.object({id:V.string().optional(),type:V.string().or(V.string().array().nonempty().optional()),name:V.string().optional(),url:V.string().optional(),phone:V.string().optional(),description:V.string().optional(),endorsement:V.any().array().optional(),image:J0.optional(),email:V.string().email().optional(),address:uH.optional(),otherIdentifier:C9.array().optional(),official:V.string().optional(),parentOrg:V.any().optional(),familyName:V.string().optional(),givenName:V.string().optional(),additionalName:V.string().optional(),patronymicName:V.string().optional(),honorificPrefix:V.string().optional(),honorificSuffix:V.string().optional(),familyNamePrefix:V.string().optional(),dateOfBirth:V.string().optional()}).catchall(V.any())),Yg=V.object({id:V.string().optional()}).catchall(V.any()),hH=V.object({type:V.string(),id:V.string()}),dH=V.object({id:V.string(),type:V.string()}),pH=V.object({id:V.string(),type:V.string()}).catchall(V.any()),W0=V.object({"@context":T9,id:V.string().optional(),type:V.string().array().nonempty(),issuer:Tl,issuanceDate:V.string(),expirationDate:V.string().optional(),credentialSubject:Yg.or(Yg.array()),credentialStatus:hH.optional(),credentialSchema:dH.array().optional(),refreshService:pH.optional()}).catchall(V.any()),la=V.object({type:V.string(),created:V.string(),challenge:V.string().optional(),domain:V.string().optional(),nonce:V.string().optional(),proofPurpose:V.string(),verificationMethod:V.string(),jws:V.string().optional()}).catchall(V.any()),Cl=W0.extend({proof:la.or(la.array())}),mH=V.object({"@context":T9,id:V.string().optional(),type:V.string().array().nonempty(),verifiableCredential:Cl.or(Cl.array()).optional(),holder:V.string().optional()}).catchall(V.any()),Zg=mH.extend({proof:la.or(la.array())}),bH=V.enum(["ceasn:Competency","ceterms:Credential","CFItem","CFRubric","CFRubricCriterion","CFRubricCriterionLevel","CTDL"]).or(V.string()),Y0=V.object({type:V.string().array().nonempty(),targetCode:V.string().optional(),targetDescription:V.string().optional(),targetName:V.string(),targetFramework:V.string().optional(),targetType:bH.optional(),targetUrl:V.string()}),gH=V.enum(["Achievement","ApprenticeshipCertificate","Assessment","Assignment","AssociateDegree","Award","Badge","BachelorDegree","Certificate","CertificateOfCompletion","Certification","CommunityService","Competency","Course","CoCurricular","Degree","Diploma","DoctoralDegree","Fieldwork","GeneralEducationDevelopment","JourneymanCertificate","LearningProgram","License","Membership","ProfessionalDoctorate","QualityAssuranceCredential","MasterCertificate","MasterDegree","MicroCredential","ResearchDoctorate","SecondarySchoolDiploma"]),vH=gH.or(V.string()),yH=V.object({id:V.string().optional(),narrative:V.string().optional()}).catchall(V.any()),xH=V.object({id:V.string(),type:V.string().array().nonempty(),endorsementComment:V.string().optional()}),wH=W0.extend({credentialSubject:xH,proof:la.or(la.array()).optional()}),_H=V.object({id:V.string(),"@language":V.string().optional(),version:V.string().optional()}),EH=V.enum(["GradePointAverage","LetterGrade","Percent","PerformanceLevel","PredictedScore","RawScore","Result","RubricCriterion","RubricCriterionLevel","RubricScore","ScaledScore","Status"]).or(V.string()),AH=V.object({id:V.string(),type:V.string().array().nonempty(),alignment:Y0.array().optional(),description:V.string().optional(),level:V.string().optional(),name:V.string(),points:V.string().optional()}).catchall(V.any()),SH=V.object({id:V.string(),type:V.string().array().nonempty(),alignment:Y0.array().optional(),allowedValue:V.string().array().optional(),name:V.string(),requiredLevel:V.string().optional(),requiredValue:V.string().optional(),resultType:EH,rubricCriterionLevel:AH.array().optional(),valueMax:V.string().optional(),valueMin:V.string().optional()}).catchall(V.any()),MH=V.object({id:V.string().optional(),type:V.string().array().nonempty(),alignment:Y0.array().optional(),achievementType:vH.optional(),creator:Tl.optional(),creditsAvailable:V.number().optional(),criteria:yH,description:V.string(),endorsement:wH.array().optional(),fieldOfStudy:V.string().optional(),humanCode:V.string().optional(),image:J0.optional(),"@language":V.string().optional(),name:V.string(),otherIdentifier:C9.array().optional(),related:_H.array().optional(),resultDescription:SH.array().optional(),specialization:V.string().optional(),tag:V.string().array().optional(),version:V.string().optional()}).catchall(V.any()),TH=V.object({type:V.string(),hashed:V.boolean(),identityHash:V.string(),identityType:V.string(),salt:V.string().optional()}),CH=V.enum(["Completed","Enrolled","Failed","InProgress","OnHold","Withdrew"]),kH=V.object({type:V.string().array().nonempty(),achievedLevel:V.string().optional(),alignment:Y0.array().optional(),resultDescription:V.string().optional(),status:CH.optional(),value:V.string().optional()}).catchall(V.any()),M9=V.object({id:V.string().optional(),type:V.string().array().nonempty(),activityEndDate:V.string().optional(),activityStartDate:V.string().optional(),creditsEarned:V.number().optional(),achievement:MH.optional(),identifier:TH.array().optional(),image:J0.optional(),licenseNumber:V.string().optional(),narrative:V.string().optional(),result:kH.array().optional(),role:V.string().optional(),source:Tl.optional(),term:V.string().optional()}).catchall(V.any()),IH=V.object({id:V.string().optional(),type:V.string().array().nonempty(),narrative:V.string().optional(),name:V.string().optional(),description:V.string().optional(),genre:V.string().optional(),audience:V.string().optional()}).catchall(V.any()),DH=W0.extend({name:V.string().optional(),description:V.string().optional(),image:J0.optional(),credentialSubject:M9.or(M9.array()),endorsement:W0.array().optional(),evidence:IH.array().optional()}),zte=DH.extend({proof:la.or(la.array())}),jte=V.object({checks:V.string().array(),warnings:V.string().array(),errors:V.string().array()}),k9=V.enum(["Success","Failed","Error"]),Gte=k9.enum,Vte=V.object({check:V.string(),status:k9,message:V.string().optional(),details:V.string().optional()}),Wte=V.object({title:V.string().optional(),createdAt:V.string().optional(),issuer:Tl.optional(),issuee:Tl.optional(),credentialSubject:Yg.optional()}),Jte=V.object({id:V.string(),uri:V.string()}).catchall(V.any()),Zte=V.object({limit:V.number(),cursor:V.string().optional()}),I9=V.object({cursor:V.string().optional(),hasMore:V.boolean()}),OH=V.object({kty:V.string(),crv:V.string(),x:V.string(),y:V.string().optional(),n:V.string().optional(),d:V.string()}),RH=V.object({alg:V.string(),iv:V.string(),tag:V.string(),epk:OH.partial().optional(),kid:V.string().optional(),apv:V.string().optional(),apu:V.string().optional()}),NH=V.object({header:RH,encrypted_key:V.string()}),PH=V.object({protected:V.string(),iv:V.string(),ciphertext:V.string(),tag:V.string(),aad:V.string().optional(),recipients:NH.array().optional()}),D9=V.object({encryptedRecord:PH,fields:V.string().array()}).catchall(V.any()),ere=I9.extend({records:D9.array()}),LH=D9.extend({id:V.string()}),tre=I9.extend({records:LH.array()}),Xg=V.object({profileId:V.string().min(3).max(40),displayName:V.string().default(""),did:V.string(),email:V.string().optional(),image:V.string().optional(),isServiceProfile:V.boolean().default(!1).optional(),notificationsWebhook:V.string().url().startsWith("https://").optional()}),nre=V.enum(["CONNECTED","PENDING_REQUEST_SENT","PENDING_REQUEST_RECEIVED","NOT_CONNECTED"]),ire=V.object({uri:V.string(),to:V.string(),from:V.string(),sent:V.string().datetime(),received:V.string().datetime().optional()}),BH=V.enum(["DRAFT","LIVE"]),ore=V.object({uri:V.string(),name:V.string().optional(),type:V.string().optional(),category:V.string().optional(),status:BH.optional()}),sre=V.object({to:Xg,from:V.string(),received:V.string().optional()}),UH=V.enum(["CONNECTION_REQUEST","CONNECTION_ACCEPTED","CREDENTIAL_RECEIVED","CREDENTIAL_ACCEPTED","BOOST_RECEIVED","BOOST_ACCEPTED","PRESENTATION_REQUEST","PRESENTATION_RECEIVED"]),$H=V.object({title:V.string().optional(),body:V.string().optional()}),FH=V.object({vcUris:V.array(V.string()).optional(),vpUris:V.array(V.string()).optional()}),are=V.object({type:UH,to:Xg.partial().and(V.object({did:V.string()})),from:Xg.partial().and(V.object({did:V.string()})),message:$H.optional(),data:FH.optional(),sent:V.string().datetime().optional()}),fre=V.object({endpoint:V.string(),name:V.string(),did:V.string().optional()}),cre=V.object({ttlSeconds:V.number().optional(),totalUses:V.number().optional()}),qH=V.object({endpoint:V.string()}),ure=V.object({signingAuthority:qH,relationship:V.object({name:V.string().max(15).regex(/^[a-z0-9-]+$/,{message:"The input string must contain only lowercase letters, numbers, and hyphens."}),did:V.string()})});var X0=o(t=>`lc:ceramic:${t}`,"streamIdToCeramicURI");var Qg=V.string().refine(t=>t.split(":").length===3&&t.split(":")[0]==="lc","URI must be of the form lc:${storage}:${url}").refine(t=>t.split(":")[1]==="ceramic","URI must use storage type ceramic (i.e. must be lc:ceramic:${streamID})");var Z0=o(async(t,{ceramicEndpoint:e,defaultContentFamily:r})=>{let n=new Al(e),i=o(async(R,D,P,J)=>t.invoke.didResolver(R,J),"learnCardResolver"),a={...m8.getResolver(),web:i},c=new Va({resolver:a});n.did=c;let u=t.invoke.getKey(),m=new Qu(Z5(u));n.did.setProvider(m),await n.did.authenticate();let v=new gl({ceramic:n}),x=o(async(R,D={},P={},J)=>{if(!R)throw new Error("content is required");if(D.controllers||(D.controllers=[n.did.id]),D.family||(D.family=r),"pin"in P||(P.pin=!0),J?.encrypt){t.debug?.("learnCard.store.Ceramic.upload.publishContentToCeramic - encrypt enabled",J);let W=J?.recipients||[];J?.controllersCanDecrypt&&(W=[...W,...D.controllers]),R=await n?.did?.createDagJWE(R,O9.default.uniq(W))}return t.debug?.("learnCard.store.Ceramic.upload.publishContentToCeramic - content to upload",R,D,P),(await Gn.create(n,R,D,P)).id.toString()},"publishContentToCeramic"),S=o(async R=>{let D=(await v.load(R))?.content;if(t.debug?.("learnCard.read.get.readContentFromCeramic",D),D?.ciphertext)try{return await c.decryptDagJWE(D)}catch(P){throw t.debug?.("learnCard.read.get.readContentFromCeramic - Could not decrypt credential - DID not authorized.",P),new Error("Could not decrypt credential - DID not authorized.")}return D},"readContentFromCeramic"),O=o(async(R,D)=>(await Cl.or(Zg).parseAsync(R),X0(await x(R,{},{},D))),"uploadCredential");return{name:"Ceramic",displayName:"Ceramic",description:"Uploads/resolves credentials using the Ceramic Network (https://ceramic.network/)",store:{upload:async(R,D)=>(R.debug?.("learnCard.store.Ceramic.upload"),O(D)),uploadEncrypted:async(R,D,P)=>(R.debug?.("learnCard.store.Ceramic.uploadEncrypted"),O(D,{encrypt:!0,controllersCanDecrypt:!0,...P?{recipients:P.recipients}:{}}))},read:{get:async(R,D)=>{if(R.debug?.("learnCard.read.Ceramic.get"),!D)return;let P=await Qg.spa(D);if(!P.success)return;let J=P.data.split(":")[2];try{return await Cl.or(Zg).parseAsync(await S(J))}catch(L){R.debug?.(L);return}}},methods:{publishContentToCeramic:async(R,D,P)=>X0(await x(D,{},{},P)),readContentFromCeramic:async(R,D)=>S(D),getCeramicClient:()=>n,getDIDObject:()=>n.did}}},"getCeramicPlugin");var HH=Z0;
|
|
817
|
+
`):"",this.name="UnsubscriptionError",this.errors=r},"UnsubscriptionErrorImpl")});function nf(t,e){if(t){var r=t.indexOf(e);0<=r&&t.splice(r,1)}}o(nf,"arrRemove");var Js=function(){function t(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return o(t,"Subscription"),t.prototype.unsubscribe=function(){var e,r,n,i,a;if(!this.closed){this.closed=!0;var c=this._parentage;if(c)if(this._parentage=null,Array.isArray(c))try{for(var u=os(c),m=u.next();!m.done;m=u.next()){var v=m.value;v.remove(this)}}catch(P){e={error:P}}finally{try{m&&!m.done&&(r=u.return)&&r.call(u)}finally{if(e)throw e.error}}else c.remove(this);var x=this.initialTeardown;if(At(x))try{x()}catch(P){a=P instanceof b0?P.errors:[P]}var S=this._finalizers;if(S){this._finalizers=null;try{for(var O=os(S),R=O.next();!R.done;R=O.next()){var D=R.value;try{E_(D)}catch(P){a=a??[],P instanceof b0?a=Vi(Vi([],Kn(a)),Kn(P.errors)):a.push(P)}}}catch(P){n={error:P}}finally{try{R&&!R.done&&(i=O.return)&&i.call(O)}finally{if(n)throw n.error}}}if(a)throw new b0(a)}},t.prototype.add=function(e){var r;if(e&&e!==this)if(this.closed)E_(e);else{if(e instanceof t){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(r=this._finalizers)!==null&&r!==void 0?r:[]).push(e)}},t.prototype._hasParent=function(e){var r=this._parentage;return r===e||Array.isArray(r)&&r.includes(e)},t.prototype._addParent=function(e){var r=this._parentage;this._parentage=Array.isArray(r)?(r.push(e),r):r?[r,e]:e},t.prototype._removeParent=function(e){var r=this._parentage;r===e?this._parentage=null:Array.isArray(r)&&nf(r,e)},t.prototype.remove=function(e){var r=this._finalizers;r&&nf(r,e),e instanceof t&&e._removeParent(this)},t.EMPTY=function(){var e=new t;return e.closed=!0,e}(),t}();var mg=Js.EMPTY;function g0(t){return t instanceof Js||t&&"closed"in t&&At(t.remove)&&At(t.add)&&At(t.unsubscribe)}o(g0,"isSubscription");function E_(t){At(t)?t():t.unsubscribe()}o(E_,"execFinalizer");var Wi={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1};var kc={setTimeout:function(t,e){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];var i=kc.delegate;return i?.setTimeout?i.setTimeout.apply(i,Vi([t,e],Kn(r))):setTimeout.apply(void 0,Vi([t,e],Kn(r)))},clearTimeout:function(t){var e=kc.delegate;return(e?.clearTimeout||clearTimeout)(t)},delegate:void 0};function v0(t){kc.setTimeout(function(){var e=Wi.onUnhandledError;if(e)e(t);else throw t})}o(v0,"reportUnhandledError");function bg(){}o(bg,"noop");var A_=function(){return gg("C",void 0,void 0)}();function S_(t){return gg("E",void 0,t)}o(S_,"errorNotification");function M_(t){return gg("N",t,void 0)}o(M_,"nextNotification");function gg(t,e,r){return{kind:t,value:e,error:r}}o(gg,"createNotification");var of=null;function Ic(t){if(Wi.useDeprecatedSynchronousErrorHandling){var e=!of;if(e&&(of={errorThrown:!1,error:null}),t(),e){var r=of,n=r.errorThrown,i=r.error;if(of=null,n)throw i}}else t()}o(Ic,"errorContext");function T_(t){Wi.useDeprecatedSynchronousErrorHandling&&of&&(of.errorThrown=!0,of.error=t)}o(T_,"captureError");var fl=function(t){Qr(e,t);function e(r){var n=t.call(this)||this;return n.isStopped=!1,r?(n.destination=r,g0(r)&&r.add(n)):n.destination=b$,n}return o(e,"Subscriber"),e.create=function(r,n,i){return new x0(r,n,i)},e.prototype.next=function(r){this.isStopped?yg(M_(r),this):this._next(r)},e.prototype.error=function(r){this.isStopped?yg(S_(r),this):(this.isStopped=!0,this._error(r))},e.prototype.complete=function(){this.isStopped?yg(A_,this):(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(r){this.destination.next(r)},e.prototype._error=function(r){try{this.destination.error(r)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(Js);var d$=Function.prototype.bind;function vg(t,e){return d$.call(t,e)}o(vg,"bind");var p$=function(){function t(e){this.partialObserver=e}return o(t,"ConsumerObserver"),t.prototype.next=function(e){var r=this.partialObserver;if(r.next)try{r.next(e)}catch(n){y0(n)}},t.prototype.error=function(e){var r=this.partialObserver;if(r.error)try{r.error(e)}catch(n){y0(n)}else y0(e)},t.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(r){y0(r)}},t}(),x0=function(t){Qr(e,t);function e(r,n,i){var a=t.call(this)||this,c;if(At(r)||!r)c={next:r??void 0,error:n??void 0,complete:i??void 0};else{var u;a&&Wi.useDeprecatedNextContext?(u=Object.create(r),u.unsubscribe=function(){return a.unsubscribe()},c={next:r.next&&vg(r.next,u),error:r.error&&vg(r.error,u),complete:r.complete&&vg(r.complete,u)}):c=r}return a.destination=new p$(c),a}return o(e,"SafeSubscriber"),e}(fl);function y0(t){Wi.useDeprecatedSynchronousErrorHandling?T_(t):v0(t)}o(y0,"handleUnhandledError");function m$(t){throw t}o(m$,"defaultErrorHandler");function yg(t,e){var r=Wi.onStoppedNotification;r&&kc.setTimeout(function(){return r(t,e)})}o(yg,"handleStoppedNotification");var b$={closed:!0,next:bg,error:m$,complete:bg};var Dc=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Oc(t){return t}o(Oc,"identity");function C_(t){return t.length===0?Oc:t.length===1?t[0]:o(function(r){return t.reduce(function(n,i){return i(n)},r)},"piped")}o(C_,"pipeFromArray");var Wt=function(){function t(e){e&&(this._subscribe=e)}return o(t,"Observable"),t.prototype.lift=function(e){var r=new t;return r.source=this,r.operator=e,r},t.prototype.subscribe=function(e,r,n){var i=this,a=v$(e)?e:new x0(e,r,n);return Ic(function(){var c=i,u=c.operator,m=c.source;a.add(u?u.call(a,m):m?i._subscribe(a):i._trySubscribe(a))}),a},t.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(r){e.error(r)}},t.prototype.forEach=function(e,r){var n=this;return r=k_(r),new r(function(i,a){var c=new x0({next:function(u){try{e(u)}catch(m){a(m),c.unsubscribe()}},error:a,complete:i});n.subscribe(c)})},t.prototype._subscribe=function(e){var r;return(r=this.source)===null||r===void 0?void 0:r.subscribe(e)},t.prototype[Dc]=function(){return this},t.prototype.pipe=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return C_(e)(this)},t.prototype.toPromise=function(e){var r=this;return e=k_(e),new e(function(n,i){var a;r.subscribe(function(c){return a=c},function(c){return i(c)},function(){return n(a)})})},t.create=function(e){return new t(e)},t}();function k_(t){var e;return(e=t??Wi.Promise)!==null&&e!==void 0?e:Promise}o(k_,"getPromiseCtor");function g$(t){return t&&At(t.next)&&At(t.error)&&At(t.complete)}o(g$,"isObserver");function v$(t){return t&&t instanceof fl||g$(t)&&g0(t)}o(v$,"isSubscriber");function y$(t){return At(t?.lift)}o(y$,"hasLift");function Dr(t){return function(e){if(y$(e))return e.lift(function(r){try{return t(r,this)}catch(n){this.error(n)}});throw new TypeError("Unable to lift unknown Observable type")}}o(Dr,"operate");function Or(t,e,r,n,i){return new x$(t,e,r,n,i)}o(Or,"createOperatorSubscriber");var x$=function(t){Qr(e,t);function e(r,n,i,a,c,u){var m=t.call(this,r)||this;return m.onFinalize=c,m.shouldUnsubscribe=u,m._next=n?function(v){try{n(v)}catch(x){r.error(x)}}:t.prototype._next,m._error=a?function(v){try{a(v)}catch(x){r.error(x)}finally{this.unsubscribe()}}:t.prototype._error,m._complete=i?function(){try{i()}catch(v){r.error(v)}finally{this.unsubscribe()}}:t.prototype._complete,m}return o(e,"OperatorSubscriber"),e.prototype.unsubscribe=function(){var r;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;t.prototype.unsubscribe.call(this),!n&&((r=this.onFinalize)===null||r===void 0||r.call(this))}},e}(fl);var I_=Cc(function(t){return o(function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"},"ObjectUnsubscribedErrorImpl")});var xg=function(t){Qr(e,t);function e(){var r=t.call(this)||this;return r.closed=!1,r.currentObservers=null,r.observers=[],r.isStopped=!1,r.hasError=!1,r.thrownError=null,r}return o(e,"Subject"),e.prototype.lift=function(r){var n=new D_(this,this);return n.operator=r,n},e.prototype._throwIfClosed=function(){if(this.closed)throw new I_},e.prototype.next=function(r){var n=this;Ic(function(){var i,a;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var c=os(n.currentObservers),u=c.next();!u.done;u=c.next()){var m=u.value;m.next(r)}}catch(v){i={error:v}}finally{try{u&&!u.done&&(a=c.return)&&a.call(c)}finally{if(i)throw i.error}}}})},e.prototype.error=function(r){var n=this;Ic(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=r;for(var i=n.observers;i.length;)i.shift().error(r)}})},e.prototype.complete=function(){var r=this;Ic(function(){if(r._throwIfClosed(),!r.isStopped){r.isStopped=!0;for(var n=r.observers;n.length;)n.shift().complete()}})},e.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(e.prototype,"observed",{get:function(){var r;return((r=this.observers)===null||r===void 0?void 0:r.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(r){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,r)},e.prototype._subscribe=function(r){return this._throwIfClosed(),this._checkFinalizedStatuses(r),this._innerSubscribe(r)},e.prototype._innerSubscribe=function(r){var n=this,i=this,a=i.hasError,c=i.isStopped,u=i.observers;return a||c?mg:(this.currentObservers=null,u.push(r),new Js(function(){n.currentObservers=null,nf(u,r)}))},e.prototype._checkFinalizedStatuses=function(r){var n=this,i=n.hasError,a=n.thrownError,c=n.isStopped;i?r.error(a):c&&r.complete()},e.prototype.asObservable=function(){var r=new Wt;return r.source=this,r},e.create=function(r,n){return new D_(r,n)},e}(Wt);var D_=function(t){Qr(e,t);function e(r,n){var i=t.call(this)||this;return i.destination=r,i.source=n,i}return o(e,"AnonymousSubject"),e.prototype.next=function(r){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.next)===null||i===void 0||i.call(n,r)},e.prototype.error=function(r){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.error)===null||i===void 0||i.call(n,r)},e.prototype.complete=function(){var r,n;(n=(r=this.destination)===null||r===void 0?void 0:r.complete)===null||n===void 0||n.call(r)},e.prototype._subscribe=function(r){var n,i;return(i=(n=this.source)===null||n===void 0?void 0:n.subscribe(r))!==null&&i!==void 0?i:mg},e}(xg);var wg=function(t){Qr(e,t);function e(r){var n=t.call(this)||this;return n._value=r,n}return o(e,"BehaviorSubject"),Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),e.prototype._subscribe=function(r){var n=t.prototype._subscribe.call(this,r);return!n.closed&&r.next(this._value),n},e.prototype.getValue=function(){var r=this,n=r.hasError,i=r.thrownError,a=r._value;if(n)throw i;return this._throwIfClosed(),a},e.prototype.next=function(r){t.prototype.next.call(this,this._value=r)},e}(xg);var _g={now:function(){return(_g.delegate||Date).now()},delegate:void 0};var O_=function(t){Qr(e,t);function e(r,n){return t.call(this)||this}return o(e,"Action"),e.prototype.schedule=function(r,n){return n===void 0&&(n=0),this},e}(Js);var cl={setInterval:function(t,e){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];var i=cl.delegate;return i?.setInterval?i.setInterval.apply(i,Vi([t,e],Kn(r))):setInterval.apply(void 0,Vi([t,e],Kn(r)))},clearInterval:function(t){var e=cl.delegate;return(e?.clearInterval||clearInterval)(t)},delegate:void 0};var R_=function(t){Qr(e,t);function e(r,n){var i=t.call(this,r,n)||this;return i.scheduler=r,i.work=n,i.pending=!1,i}return o(e,"AsyncAction"),e.prototype.schedule=function(r,n){var i;if(n===void 0&&(n=0),this.closed)return this;this.state=r;var a=this.id,c=this.scheduler;return a!=null&&(this.id=this.recycleAsyncId(c,a,n)),this.pending=!0,this.delay=n,this.id=(i=this.id)!==null&&i!==void 0?i:this.requestAsyncId(c,this.id,n),this},e.prototype.requestAsyncId=function(r,n,i){return i===void 0&&(i=0),cl.setInterval(r.flush.bind(r,this),i)},e.prototype.recycleAsyncId=function(r,n,i){if(i===void 0&&(i=0),i!=null&&this.delay===i&&this.pending===!1)return n;n!=null&&cl.clearInterval(n)},e.prototype.execute=function(r,n){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var i=this._execute(r,n);if(i)return i;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(r,n){var i=!1,a;try{this.work(r)}catch(c){i=!0,a=c||new Error("Scheduled action threw falsy error")}if(i)return this.unsubscribe(),a},e.prototype.unsubscribe=function(){if(!this.closed){var r=this,n=r.id,i=r.scheduler,a=i.actions;this.work=this.state=this.scheduler=null,this.pending=!1,nf(a,this),n!=null&&(this.id=this.recycleAsyncId(i,n,null)),this.delay=null,t.prototype.unsubscribe.call(this)}},e}(O_);var Eg=function(){function t(e,r){r===void 0&&(r=t.now),this.schedulerActionCtor=e,this.now=r}return o(t,"Scheduler"),t.prototype.schedule=function(e,r,n){return r===void 0&&(r=0),new this.schedulerActionCtor(this,e).schedule(n,r)},t.now=_g.now,t}();var N_=function(t){Qr(e,t);function e(r,n){n===void 0&&(n=Eg.now);var i=t.call(this,r,n)||this;return i.actions=[],i._active=!1,i}return o(e,"AsyncScheduler"),e.prototype.flush=function(r){var n=this.actions;if(this._active){n.push(r);return}var i;this._active=!0;do if(i=r.execute(r.state,r.delay))break;while(r=n.shift());if(this._active=!1,i){for(;r=n.shift();)r.unsubscribe();throw i}},e}(Eg);var w$=new N_(R_),P_=w$;var w0=new Wt(function(t){return t.complete()});function _0(t){return t&&At(t.schedule)}o(_0,"isScheduler");function L_(t){return t[t.length-1]}o(L_,"last");function B_(t){return _0(L_(t))?t.pop():void 0}o(B_,"popScheduler");function U_(t,e){return typeof L_(t)=="number"?t.pop():e}o(U_,"popNumber");var Rc=o(function(t){return t&&typeof t.length=="number"&&typeof t!="function"},"isArrayLike");function E0(t){return At(t?.then)}o(E0,"isPromise");function A0(t){return At(t[Dc])}o(A0,"isInteropObservable");function S0(t){return Symbol.asyncIterator&&At(t?.[Symbol.asyncIterator])}o(S0,"isAsyncIterable");function M0(t){return new TypeError("You provided "+(t!==null&&typeof t=="object"?"an invalid object":"'"+t+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}o(M0,"createInvalidObservableTypeError");function _$(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}o(_$,"getSymbolIterator");var T0=_$();function C0(t){return At(t?.[T0])}o(C0,"isIterable");function k0(t){return w_(this,arguments,o(function(){var r,n,i,a;return m0(this,function(c){switch(c.label){case 0:r=t.getReader(),c.label=1;case 1:c.trys.push([1,,9,10]),c.label=2;case 2:return[4,rf(r.read())];case 3:return n=c.sent(),i=n.value,a=n.done,a?[4,rf(void 0)]:[3,5];case 4:return[2,c.sent()];case 5:return[4,rf(i)];case 6:return[4,c.sent()];case 7:return c.sent(),[3,2];case 8:return[3,10];case 9:return r.releaseLock(),[7];case 10:return[2]}})},"readableStreamLikeToAsyncGenerator_1"))}o(k0,"readableStreamLikeToAsyncGenerator");function I0(t){return At(t?.getReader)}o(I0,"isReadableStreamLike");function en(t){if(t instanceof Wt)return t;if(t!=null){if(A0(t))return E$(t);if(Rc(t))return A$(t);if(E0(t))return S$(t);if(S0(t))return $_(t);if(C0(t))return M$(t);if(I0(t))return T$(t)}throw M0(t)}o(en,"innerFrom");function E$(t){return new Wt(function(e){var r=t[Dc]();if(At(r.subscribe))return r.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}o(E$,"fromInteropObservable");function A$(t){return new Wt(function(e){for(var r=0;r<t.length&&!e.closed;r++)e.next(t[r]);e.complete()})}o(A$,"fromArrayLike");function S$(t){return new Wt(function(e){t.then(function(r){e.closed||(e.next(r),e.complete())},function(r){return e.error(r)}).then(null,v0)})}o(S$,"fromPromise");function M$(t){return new Wt(function(e){var r,n;try{for(var i=os(t),a=i.next();!a.done;a=i.next()){var c=a.value;if(e.next(c),e.closed)return}}catch(u){r={error:u}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}e.complete()})}o(M$,"fromIterable");function $_(t){return new Wt(function(e){C$(t,e).catch(function(r){return e.error(r)})})}o($_,"fromAsyncIterable");function T$(t){return $_(k0(t))}o(T$,"fromReadableStreamLike");function C$(t,e){var r,n,i,a;return x_(this,void 0,void 0,function(){var c,u;return m0(this,function(m){switch(m.label){case 0:m.trys.push([0,5,6,11]),r=__(t),m.label=1;case 1:return[4,r.next()];case 2:if(n=m.sent(),!!n.done)return[3,4];if(c=n.value,e.next(c),e.closed)return[2];m.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return u=m.sent(),i={error:u},[3,11];case 6:return m.trys.push([6,,9,10]),n&&!n.done&&(a=r.return)?[4,a.call(r)]:[3,8];case 7:m.sent(),m.label=8;case 8:return[3,10];case 9:if(i)throw i.error;return[7];case 10:return[7];case 11:return e.complete(),[2]}})})}o(C$,"process");function Ai(t,e,r,n,i){n===void 0&&(n=0),i===void 0&&(i=!1);var a=e.schedule(function(){r(),i?t.add(this.schedule(null,n)):this.unsubscribe()},n);if(t.add(a),!i)return a}o(Ai,"executeSchedule");function D0(t,e){return e===void 0&&(e=0),Dr(function(r,n){r.subscribe(Or(n,function(i){return Ai(n,t,function(){return n.next(i)},e)},function(){return Ai(n,t,function(){return n.complete()},e)},function(i){return Ai(n,t,function(){return n.error(i)},e)}))})}o(D0,"observeOn");function O0(t,e){return e===void 0&&(e=0),Dr(function(r,n){n.add(t.schedule(function(){return r.subscribe(n)},e))})}o(O0,"subscribeOn");function F_(t,e){return en(t).pipe(O0(e),D0(e))}o(F_,"scheduleObservable");function q_(t,e){return en(t).pipe(O0(e),D0(e))}o(q_,"schedulePromise");function H_(t,e){return new Wt(function(r){var n=0;return e.schedule(function(){n===t.length?r.complete():(r.next(t[n++]),r.closed||this.schedule())})})}o(H_,"scheduleArray");function z_(t,e){return new Wt(function(r){var n;return Ai(r,e,function(){n=t[T0](),Ai(r,e,function(){var i,a,c;try{i=n.next(),a=i.value,c=i.done}catch(u){r.error(u);return}c?r.complete():r.next(a)},0,!0)}),function(){return At(n?.return)&&n.return()}})}o(z_,"scheduleIterable");function R0(t,e){if(!t)throw new Error("Iterable cannot be null");return new Wt(function(r){Ai(r,e,function(){var n=t[Symbol.asyncIterator]();Ai(r,e,function(){n.next().then(function(i){i.done?r.complete():r.next(i.value)})},0,!0)})})}o(R0,"scheduleAsyncIterable");function K_(t,e){return R0(k0(t),e)}o(K_,"scheduleReadableStreamLike");function j_(t,e){if(t!=null){if(A0(t))return F_(t,e);if(Rc(t))return H_(t,e);if(E0(t))return q_(t,e);if(S0(t))return R0(t,e);if(C0(t))return z_(t,e);if(I0(t))return K_(t,e)}throw M0(t)}o(j_,"scheduled");function G_(t,e){return e?j_(t,e):en(t)}o(G_,"from");var N0=Cc(function(t){return o(function(){t(this),this.name="EmptyError",this.message="no elements in sequence"},"EmptyErrorImpl")});function V_(t){return t instanceof Date&&!isNaN(t)}o(V_,"isValidDate");function P0(t,e){return Dr(function(r,n){var i=0;r.subscribe(Or(n,function(a){n.next(t.call(e,a,i++))}))})}o(P0,"map");var k$=Array.isArray;function I$(t,e){return k$(e)?t.apply(void 0,Vi([],Kn(e))):t(e)}o(I$,"callOrApply");function W_(t){return P0(function(e){return I$(t,e)})}o(W_,"mapOneOrManyArgs");function J_(t,e,r,n,i,a,c,u){var m=[],v=0,x=0,S=!1,O=o(function(){S&&!m.length&&!v&&e.complete()},"checkComplete"),R=o(function(P){return v<n?D(P):m.push(P)},"outerNext"),D=o(function(P){a&&e.next(P),v++;var J=!1;en(r(P,x++)).subscribe(Or(e,function(L){i?.(L),a?R(L):e.next(L)},function(){J=!0},void 0,function(){if(J)try{v--;for(var L=o(function(){var W=m.shift();c?Ai(e,c,function(){return D(W)}):D(W)},"_loop_1");m.length&&v<n;)L();O()}catch(W){e.error(W)}}))},"doInnerSub");return t.subscribe(Or(e,R,function(){S=!0,O()})),function(){u?.()}}o(J_,"mergeInternals");function ul(t,e,r){return r===void 0&&(r=1/0),At(e)?ul(function(n,i){return P0(function(a,c){return e(n,a,i,c)})(en(t(n,i)))},r):(typeof e=="number"&&(r=e),Dr(function(n,i){return J_(n,i,t,r)}))}o(ul,"mergeMap");function Y_(t){return t===void 0&&(t=1/0),ul(Oc,t)}o(Y_,"mergeAll");var D$=["addListener","removeListener"],O$=["addEventListener","removeEventListener"],R$=["on","off"];function ll(t,e,r,n){if(At(r)&&(n=r,r=void 0),n)return ll(t,e,r).pipe(W_(n));var i=Kn(L$(t)?O$.map(function(u){return function(m){return t[u](e,m,r)}}):N$(t)?D$.map(X_(t,e)):P$(t)?R$.map(X_(t,e)):[],2),a=i[0],c=i[1];if(!a&&Rc(t))return ul(function(u){return ll(u,e,r)})(en(t));if(!a)throw new TypeError("Invalid event target");return new Wt(function(u){var m=o(function(){for(var v=[],x=0;x<arguments.length;x++)v[x]=arguments[x];return u.next(1<v.length?v:v[0])},"handler");return a(m),function(){return c(m)}})}o(ll,"fromEvent");function X_(t,e){return function(r){return function(n){return t[r](e,n)}}}o(X_,"toCommonHandlerRegistry");function N$(t){return At(t.addListener)&&At(t.removeListener)}o(N$,"isNodeStyleEventEmitter");function P$(t){return At(t.on)&&At(t.off)}o(P$,"isJQueryStyleEventEmitter");function L$(t){return At(t.addEventListener)&&At(t.removeEventListener)}o(L$,"isEventTarget");function hl(t,e,r){t===void 0&&(t=0),r===void 0&&(r=P_);var n=-1;return e!=null&&(_0(e)?r=e:n=e),new Wt(function(i){var a=V_(t)?+t-r.now():t;a<0&&(a=0);var c=0;return r.schedule(function(){i.closed||(i.next(c++),0<=n?this.schedule(void 0,n):i.complete())},a)})}o(hl,"timer");function Ag(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=B_(t),n=U_(t,1/0),i=t;return i.length?i.length===1?en(i[0]):Y_(n)(G_(i,r)):w0}o(Ag,"merge");function Z_(t,e){return Dr(function(r,n){var i=0;r.subscribe(Or(n,function(a){return t.call(e,a,i++)&&n.next(a)}))})}o(Z_,"filter");function Q_(t){return Dr(function(e,r){var n=!1;e.subscribe(Or(r,function(i){n=!0,r.next(i)},function(){n||r.next(t),r.complete()}))})}o(Q_,"defaultIfEmpty");function eE(t){return t<=0?function(){return w0}:Dr(function(e,r){var n=0;e.subscribe(Or(r,function(i){++n<=t&&(r.next(i),t<=n&&r.complete())}))})}o(eE,"take");function tE(t){return t===void 0&&(t=B$),Dr(function(e,r){var n=!1;e.subscribe(Or(r,function(i){n=!0,r.next(i)},function(){return n?r.complete():r.error(t())}))})}o(tE,"throwIfEmpty");function B$(){return new N0}o(B$,"defaultErrorFactory");function Sg(t,e){var r=arguments.length>=2;return function(n){return n.pipe(t?Z_(function(i,a){return t(i,a,n)}):Oc,eE(1),r?Q_(e):tE(function(){return new N0}))}}o(Sg,"first");function Mg(t,e){return Dr(function(r,n){var i=e??{},a=i.leading,c=a===void 0?!0:a,u=i.trailing,m=u===void 0?!1:u,v=!1,x=null,S=null,O=!1,R=o(function(){S?.unsubscribe(),S=null,m&&(J(),O&&n.complete())},"endThrottling"),D=o(function(){S=null,O&&n.complete()},"cleanupThrottling"),P=o(function(L){return S=en(t(L)).subscribe(Or(n,R,D))},"startThrottle"),J=o(function(){if(v){v=!1;var L=x;x=null,n.next(L),!O&&P(L)}},"send");r.subscribe(Or(n,function(L){v=!0,x=L,!(S&&!S.closed)&&(c?J():P(L))},function(){O=!0,!(m&&v&&S&&!S.closed)&&n.complete()}))})}o(Mg,"throttle");var rE;(function(t){t[t.GENESIS=0]="GENESIS",t[t.PARTIAL=1]="PARTIAL",t[t.SIGNED=2]="SIGNED"})(rE||(rE={}));var dl;(function(t){t[t.NOT_REQUESTED=0]="NOT_REQUESTED",t[t.PENDING=1]="PENDING",t[t.PROCESSING=2]="PROCESSING",t[t.ANCHORED=3]="ANCHORED",t[t.FAILED=4]="FAILED"})(dl||(dl={}));var Cg;(function(t){t[t.GENESIS=0]="GENESIS",t[t.SIGNED=1]="SIGNED",t[t.ANCHOR=2]="ANCHOR"})(Cg||(Cg={}));var ss=class extends Wt{constructor(e,r){super(n=>{e.subscribe(n)}),this.state$=e,this._context=r}get id(){return new rt(this.state$.value.type,this.state$.value.log[0].cid)}get api(){return this._context.api}get content(){let{next:e,content:r}=this.state$.value;return(0,Tg.default)(e?.content??r)}get tip(){return this.state$.value.log[this.state$.value.log.length-1].cid}get commitId(){return Pt.make(this.id,this.tip)}get allCommitIds(){return this.state$.value.log.map(({cid:e})=>Pt.make(this.id,e))}get anchorCommitIds(){return this.state$.value.log.filter(({type:e})=>e===Cg.ANCHOR).map(({cid:e})=>Pt.make(this.id,e))}get state(){return(0,Tg.default)(this.state$.value)}async sync(e={}){e={sync:yr.PREFER_CACHE,...e};let r=await this.api.loadStream(this.id,e);this.state$.next(r.state)}async requestAnchor(){return this.api.requestAnchor(this.id)}};o(ss,"Stream");function Nc(){return t=>{}}o(Nc,"StreamStatic");var fE=Lt(oE(),1);function sE(t){let e=new AbortController;if(t.length===0)throw Error("Need abort signals to create a merged abort signal");return t.some(r=>r.aborted)?(e.abort(),e.signal):(Ag(...t.map(r=>ll(r,"abort"))).pipe(Sg()).subscribe(()=>{e.abort()}),e.signal)}o(sE,"mergeAbortSignals");var pl=class{constructor(e){let r=new AbortController;if(this.signal=r.signal,e<=0){r.abort();return}this._subscription=hl(e).subscribe(()=>{r.abort()})}clear(){this._subscription?.unsubscribe()}};o(pl,"TimedAbortSignal");async function aE(t,e){let r=new AbortController,n=o(()=>{r.abort()},"onAbort");return t.addEventListener("abort",n),t.aborted&&r.abort(),e(r.signal).finally(()=>{t.removeEventListener("abort",n)})}o(aE,"abortable");var U$=60*1e3*3;async function Hr(t,e={}){e.body&&Object.assign(e,{body:JSON.stringify(e.body),headers:{...e.headers,"Content-Type":"application/json"}});let r=e.timeout||U$,n=new pl(r),i=e.signal?sE([e.signal,n.signal]):n.signal,a=await aE(i,c=>(0,fE.default)(String(t),{...e,signal:c})).finally(()=>n.clear());if(!a.ok){let c=await a.text();throw new Error(`HTTP request to '${t}' failed with status '${a.statusText}': ${c}`)}return a.json()}o(Hr,"fetchJson");var ml=Lt(Ec(),1);Pi();function fs(t){let e=We.asCID(t);if(e)return e;if(typeof t=="string")return We.parse(t);if(t instanceof Uint8Array)return We.decode(t);throw new Error(`${t} cannot be converted to a CID`)}o(fs,"toCID");var cE=0,Xt=class{static streamIdFromState(e){return new rt(e.type,e.log[0].cid)}static serializeCommit(e){let r=(0,ml.default)(e);return Xt.isSignedCommitContainer(r)?(r.jws.link=r.jws.link.toString(),r.linkedBlock=kt(r.linkedBlock,"base64"),r.cacaoBlock&&(r.cacaoBlock=kt(r.cacaoBlock,"base64")),r):(Xt.isSignedCommit(e)&&(r.link=r.link.toString()),Xt.isAnchorCommit(e)&&(r.proof=r.proof.toString()),r.id&&(r.id=r.id.toString()),r.prev&&(r.prev=r.prev.toString()),e.header?.model&&(r.header.model=kt(e.header.model,"base64")),r)}static deserializeCommit(e){let r=(0,ml.default)(e);return Xt.isSignedCommitContainer(r)?(r.jws.link=fs(r.jws.link),r.linkedBlock=Ot(r.linkedBlock,"base64"),r.cacaoBlock&&(r.cacaoBlock=Ot(r.cacaoBlock,"base64")),r):(Xt.isSignedCommit(r)&&(r.link=fs(r.link)),Xt.isAnchorCommit(r)&&(r.proof=fs(r.proof)),r.id&&(r.id=fs(r.id)),r.prev&&(r.prev=fs(r.prev)),r.header?.model&&(r.header.model=Ot(r.header.model,"base64")),r)}static serializeState(e){let r=(0,ml.default)(e);return r.log=r.log.map(n=>({...n,cid:n.cid.toString()})),r.anchorStatus!=null&&(r.anchorStatus=dl[r.anchorStatus]),r.anchorProof!=null&&(r.anchorProof.txHash=r.anchorProof.txHash.toString(),r.anchorProof.root=r.anchorProof.root.toString()),e.metadata?.model&&(r.metadata.model=e.metadata.model.toString()),e.next?.metadata?.model&&(r.next.metadata.model=e.next.metadata.model.toString()),e.metadata?.unique&&e.type!=cE&&(r.metadata.unique=kt(r.metadata.unique,"base64")),r.doctype=En.nameByCode(r.type),r}static deserializeState(e){if(!e)return null;let r=(0,ml.default)(e);return r.doctype&&(r.type=En.codeByName(r.doctype),delete r.doctype),r.log=r.log.map(n=>({...n,cid:fs(n.cid)})),r.anchorProof&&(r.anchorProof.txHash=fs(r.anchorProof.txHash),r.anchorProof.root=fs(r.anchorProof.root)),r.anchorStatus&&(r.anchorStatus=dl[r.anchorStatus]),e.metadata?.model&&(r.metadata.model=rt.fromString(e.metadata.model)),e.next?.metadata?.model&&(r.next.metadata.model=rt.fromString(e.next.metadata.model)),e.metadata?.unique&&e.type!=cE&&(r.metadata.unique=Ot(e.metadata.unique,"base64")),r}static statesEqual(e,r){return JSON.stringify(Xt.serializeState(e))===JSON.stringify(Xt.serializeState(r))}static isStateSupersetOf(e,r){if(e.log.length<r.log.length)return!1;for(let n in r.log)if(!e.log[n].cid.equals(r.log[n].cid))return!1;return!(e.log.length===r.log.length&&e.anchorStatus!=r.anchorStatus)}static assertCommitLinksToState(e,r){let n=this.streamIdFromState(e);if(r.id&&!r.id.equals(e.log[0].cid))throw new Error(`Invalid genesis CID in commit for StreamID ${n.toString()}. Found: ${r.id}, expected ${e.log[0].cid}`);let i=e.log[e.log.length-1].cid;if(!r.prev.equals(i))throw new Error(`Commit doesn't properly point to previous commit in log. Expected ${i}, found 'prev' ${r.prev}`)}static async convertCommitToSignedCommitContainer(e,r){if(Xt.isSignedCommit(e)){let n=await r.block.get(e.link);return{jws:e,linkedBlock:n}}return e}static isSignedCommitContainer(e){return e&&e.jws!==void 0}static isSignedCommit(e){return e&&e.link!==void 0}static isAnchorCommit(e){return e&&e.proof!==void 0}static isSignedCommitData(e){return e&&e.envelope!==void 0}static isAnchorCommitData(e){return e&&e.proof!==void 0}};o(Xt,"StreamUtils");var bl=class extends wg{next(e){let r=this.value;Xt.statesEqual(r,e)||super.next(e)}};o(bl,"StreamStateSubject");var $$=function(t,e,r,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(t,e,r,n);else for(var u=t.length-1;u>=0;u--)(c=t[u])&&(a=(i<3?c(a):i>3?c(e,r,a):c(e,r))||a);return i>3&&a&&Object.defineProperty(e,r,a),a},jn,kg={anchor:!0,publish:!0,pin:!0,sync:yr.PREFER_CACHE},F$={sync:yr.PREFER_CACHE},uE={anchor:!0,publish:!0,throwOnInvalidCommit:!0};function Ig(t,e){if(typeof t?.schema=="string")try{Pt.fromString(t.schema)}catch{throw new Error("Schema must be a CommitID")}let r={controllers:t?.controllers,family:t?.family,schema:t?.schema?.toString(),tags:t?.tags};if(e)t?.deterministic||(r.unique=kt((0,dE.randomBytes)(12),"base64")),t?.forbidControllerChange&&(r.forbidControllerChange=!0);else{if(t?.deterministic!==void 0||t?.unique!==void 0)throw new Error("Cannot change 'deterministic' or 'unique' properties on existing Streams");if(t?.forbidControllerChange!==void 0)throw new Error("Cannot change 'forbidControllerChange' property on existing Streams")}return Object.keys(r).forEach(n=>r[n]===void 0&&delete r[n]),r}o(Ig,"headerFromMetadata");async function lE(t){if(!t.did)throw new Error("No DID provided");return t.did.authenticated||(await t.did.authenticate(),t.loggerProvider&&t.loggerProvider.getDiagnosticsLogger().imp(`Now authenticated as DID ${t.did.id}`)),t.did}o(lE,"getAuthenticatedDID");async function Dg(){throw new Error("Historical stream commits cannot be modified. Load the stream without specifying a commit to make updates.")}o(Dg,"throwReadOnlyError");var Gn=jn=o(class extends ss{constructor(){super(...arguments),this._isReadOnly=!1}get content(){return super.content}get metadata(){let{next:e,metadata:r}=this.state$.value;return(0,hE.default)(e?.metadata??r)}get controllers(){return this.metadata.controllers}static async create(e,r,n,i={}){i={...kg,...i},!n?.deterministic&&i.syncTimeoutSeconds==null&&(i.syncTimeoutSeconds=0);let a=i.asDID?{did:i.asDID}:e,c=await jn.makeGenesis(a,r,n);return e.createStreamFromGenesis(jn.STREAM_TYPE_ID,c,i)}static async createFromGenesis(e,r,n={}){n={...kg,...n},r.header?.unique&&n.syncTimeoutSeconds==null&&(n.syncTimeoutSeconds=0);let i=r.data?await jn._signDagJWS(e,r):r;return e.createStreamFromGenesis(jn.STREAM_TYPE_ID,i,n)}static async deterministic(e,r,n={}){if(n={...kg,...n},r={...r,deterministic:!0},r.family==null&&r.tags==null)throw new Error("Family and/or tags are required when creating a deterministic tile document");let i=await jn.makeGenesis(e,null,r);return e.createStreamFromGenesis(jn.STREAM_TYPE_ID,i,n)}static async load(e,r,n={}){n={...F$,...n};let i=fn.from(r);if(i.type!=jn.STREAM_TYPE_ID)throw new Error(`StreamID ${i.toString()} does not refer to a '${jn.STREAM_TYPE_NAME}' stream, but to a ${i.typeName}`);return e.loadStream(i,n)}async update(e,r,n={}){n={...uE,...n};let i=n.asDID?{did:n.asDID}:this.api,a=await this.makeCommit(i,e,r),c=await this.api.applyCommit(this.id,a,n);this.state$.next(c.state)}async patch(e,r={}){r={...uE,...r};let i={header:Ig(this.metadata,!1),data:e,prev:this.tip,id:this.id.cid},a=await jn._signDagJWS(this.api,i),c=await this.api.applyCommit(this.id,a,r);this.state$.next(c.state)}makeReadOnly(){this.update=Dg,this.patch=Dg,this.sync=Dg,this._isReadOnly=!0}get isReadOnly(){return this._isReadOnly}async makeCommit(e,r,n){let i=await this._makeRawCommit(r,n);return jn._signDagJWS(e,i)}async _makeRawCommit(e,r){r||(r={});let n=Ig(r,!1);if(e==null&&(e=this.content),n.controllers){if(n.controllers.length!==1)throw new Error("Exactly one controller must be specified");if(!n.controllers[0])throw new Error("Controller cannot be updated to an undefined value.")}let i=r0.compare(this.content,e),a=this.state.log[0];return{header:n,data:i,prev:this.tip,id:a.cid}}static async makeGenesis(e,r,n){if(n||(n={}),!n.controllers||n.controllers.length===0)if(e.did){let c=await lE(e);n.controllers=[c.hasParent?c.parent:c.id]}else throw new Error("No controllers specified");if(n.controllers?.length!==1)throw new Error("Exactly one controller must be specified");let i=Ig(n,!0);if(n?.deterministic&&r)throw new Error("Initial content must be null when creating a deterministic Tile document");if(r==null){let c={header:i};return qa(c),c}let a={data:r,header:i};return jn._signDagJWS(e,a)}static async _signDagJWS(e,r){return(await lE(e)).createDagJWS(r)}},"TileDocument");Gn.STREAM_TYPE_NAME="tile";Gn.STREAM_TYPE_ID=0;Gn=jn=$$([Nc()],Gn);var xE=Lt(bE(),1);function Y$(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}o(Y$,"_checkPrivateRedeclaration");function X$(t,e){return e.get?e.get.call(t):e.value}o(X$,"_classApplyDescriptorGet");function Z$(t,e,r){if(e.set)e.set.call(t,r);else{if(!e.writable)throw new TypeError("attempted to set read only private field");e.value=r}}o(Z$,"_classApplyDescriptorSet");function yE(t,e,r){if(!e.has(t))throw new TypeError("attempted to "+r+" private field on non-instance");return e.get(t)}o(yE,"_classExtractFieldDescriptor");function Pg(t,e){var r=yE(t,e,"get");return X$(t,r)}o(Pg,"_classPrivateFieldGet");function gE(t,e,r){Y$(t,e),e.set(t,r)}o(gE,"_classPrivateFieldInit");function vE(t,e,r){var n=yE(t,e,"set");return Z$(t,n,r),r}o(vE,"_classPrivateFieldSet");function Q$(t){return typeof t=="string"||Pt.isInstance(t)||rt.isInstance(t)?{streamId:t}:{streamId:t.streamId,genesis:t.genesis}}o(Q$,"keyToQuery");function Lg(t){return typeof t=="string"?fn.from(t).toString():Pt.isInstance(t)||rt.isInstance(t)?t.toString():t.streamId.toString()}o(Lg,"keyToString");async function eF(t){let e=await Gn.makeGenesis({},null,{...t,deterministic:!0}),r=await rt.fromGenesis("tile",e);return{genesis:e,streamId:r}}o(eF,"getDeterministicQuery");var tF=o(()=>Promise.resolve([]),"tempBatchLoadFn"),B0=new WeakMap,Bg=new WeakMap,gl=class extends xE.default{cache(e){if(!Pg(this,Bg))return!1;let r=e.id.toString();return this.clear(r).prime(r,e),!0}async create(e,r,n){let i=await Gn.create(Pg(this,B0),e,r,n);return this.cache(i),i}async deterministic(e,r){let n=await eF(e);try{return await super.load(n)}catch{let a=await Gn.createFromGenesis(Pg(this,B0),n.genesis,r);return this.cache(a),a}}async load(e){return await super.load(e)}async update(e,r,n,i){let a=Lg(e);this.clear(a);let c=await this.load({streamId:a});return await c.update(r,n,i),c}constructor(e){super(tF,{cache:!0,cacheKeyFn:Lg,cacheMap:e.cache!=null&&typeof e.cache!="boolean"?e.cache:void 0}),gE(this,B0,{writable:!0,value:void 0}),gE(this,Bg,{writable:!0,value:void 0}),this._batchLoadFn=async r=>{e.cache||this.clearAll();let n=await e.ceramic.multiQuery(r.map(Q$),e.multiqueryTimeout);return r.map(i=>{let a=Lg(i),c=n[a];return c||new Error(`Failed to load stream: ${a}`)})},vE(this,B0,e.ceramic),vE(this,Bg,!!e.cache)}};o(gl,"TileLoader");function Ug(t){return typeof t=="string"?rt.fromString(t):t}o(Ug,"typeStreamID");function wE(t,e){let r=new URL(t);for(let[n,i]of Object.entries(e))rt.isInstance(i)?r.searchParams.set(n,i.toString()):typeof i=="object"?r.searchParams.set(n,JSON.stringify(i)):r.searchParams.set(n,i);return r}o(wE,"serializeObjectToSearchParams");function $g(t){let e={};for(let[r,n]of Object.entries(t))rt.isInstance(n)?e[r]=n.toString():e[r]=n;return e}o($g,"serializeObjectForHttpPost");var tn=class extends Wt{constructor(e,r,n){super(i=>{this.state$.observers.length===0&&(this.periodicSubscription=hl(0,n).pipe(Mg(()=>this._syncState(this.id,{sync:yr.PREFER_CACHE}))).subscribe()),this.state$.subscribe(i).add(()=>{this.state$.observers.length===0&&this.periodicSubscription?.unsubscribe()})}),this.state$=new bl(e),this._apiUrl=new URL(r)}get value(){return this.state$.value}get state(){return this.state$.value}next(e){this.state$.next(e)}async _syncState(e,r){let n=await tn._load(e,this._apiUrl,r);this.state$.next(Xt.deserializeState(n))}get id(){return new rt(this.state$.value.type,this.state$.value.log[0].cid)}static async createFromGenesis(e,r,n,i,a){let c=new URL("./streams",e),{state:u}=await Hr(c,{method:"post",body:{type:r,genesis:Xt.serializeCommit(n),opts:i}});return new tn(Xt.deserializeState(u),e,a)}static async applyCommit(e,r,n,i,a){let c=new URL("./commits",e),{state:u}=await Hr(c,{method:"post",body:{streamId:r.toString(),commit:Xt.serializeCommit(n),opts:i}});return new tn(Xt.deserializeState(u),e,a)}static async _load(e,r,n){let i=wE(new URL(`./streams/${e}`,r),n),{state:a}=await Hr(i);return a}static async load(e,r,n,i){let a=await tn._load(e,r,i);return new tn(Xt.deserializeState(a),r,n)}static async loadStreamCommits(e,r){let n=new URL(`./commits/${e}`,r),{commits:i}=await Hr(n);return i.map(a=>({cid:a.cid,value:Xt.deserializeCommit(a.value)}))}complete(){this.state$.complete()}};o(tn,"Document");var sf;(function(t){t[t.PREFER_CACHE=0]="PREFER_CACHE",t[t.SYNC_ALWAYS=1]="SYNC_ALWAYS",t[t.NEVER_SYNC=2]="NEVER_SYNC",t[t.SYNC_ON_ERROR=3]="SYNC_ON_ERROR"})(sf||(sf={}));var Fg=Lt(Ec(),1);var _E;(function(t){t[t.GENESIS=0]="GENESIS",t[t.PARTIAL=1]="PARTIAL",t[t.SIGNED=2]="SIGNED"})(_E||(_E={}));var qg;(function(t){t[t.GENESIS=0]="GENESIS",t[t.SIGNED=1]="SIGNED",t[t.ANCHOR=2]="ANCHOR"})(qg||(qg={}));var vl=class extends Wt{constructor(e,r){super(n=>{e.subscribe(n)}),this.state$=e,this._context=r}get id(){return new rt(this.state$.value.type,this.state$.value.log[0].cid)}get api(){return this._context.api}get content(){let{next:e,content:r}=this.state$.value;return(0,Fg.default)(e?.content??r)}get tip(){return this.state$.value.log[this.state$.value.log.length-1].cid}get commitId(){return Pt.make(this.id,this.tip)}get allCommitIds(){return this.state$.value.log.map(({cid:e})=>Pt.make(this.id,e))}get anchorCommitIds(){return this.state$.value.log.filter(({type:e})=>e===qg.ANCHOR).map(({cid:e})=>Pt.make(this.id,e))}get state(){return(0,Fg.default)(this.state$.value)}async sync(e={}){e={sync:sf.PREFER_CACHE,...e};let r=await this.api.loadStream(this.id,e);this.state$.next(r.state)}async requestAnchor(){return this.api.requestAnchor(this.id)}};o(vl,"Stream");function EE(){return t=>{}}o(EE,"StreamStatic");function AE(t){if(typeof t=="string"&&t.includes("@")){let[e,r]=t.split("@");if(!e||!r)throw new Error("Invalid accountId provided");return new zs({address:e,chainId:r})}return new zs(t)}o(AE,"normalizeAccountId");var rF="(?:%[0-9a-fA-F]{2})",SE=`(?:[a-zA-Z0-9._-]|${rF})`,nF="([a-z0-9]+)",iF=`((?:${SE}*:)*(${SE}+))`,ME="[a-zA-Z0-9_.:%-]",oF=`;${ME}+=${ME}*`,sF=`((${oF})*)`,aF="(/[^#?]*)?",fF="([?][^#]*)?",cF="(#.*)?",uF=new RegExp(`^did:${nF}:${iF}${sF}${aF}${fF}${cF}$`);function TE(t){if(t===""||!t)return null;let e=t.match(uF);if(e){let r={did:`did:${e[1]}:${e[2]}`,method:e[1],id:e[2],didUrl:t};if(e[4]){let n=e[4].slice(1).split(";");r.params={};for(let i of n){let a=i.split("=");r.params[a[0]]=a[1]}}return e[6]&&(r.path=e[6]),e[7]&&(r.query=e[7].slice(1)),e[8]&&(r.fragment=e[8].slice(1)),r}return null}o(TE,"parse");var kE=Lt(Ec(),1),lF=function(t,e,r,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(t,e,r,n);else for(var u=t.length-1;u>=0;u--)(c=t[u])&&(a=(i<3?c(a):i>3?c(e,r,a):c(e,r))||a);return i>3&&a&&Object.defineProperty(e,r,a),a},af,Hg=o(()=>{throw new Error("Historical stream commits cannot be modified. Load the stream without specifying a commit to make updates.")},"throwReadOnlyError"),CE={anchor:!1,publish:!0,sync:sf.PREFER_CACHE},zg={anchor:!0,publish:!0},hF={sync:sf.PREFER_CACHE},ff=af=o(class extends vl{constructor(){super(...arguments),this._isReadOnly=!1}get did(){return this.content}get metadata(){let{next:e,metadata:r}=this.state$.value;return(0,kE.default)(e?.metadata??r)}get controllers(){return this.metadata.controllers}static async fromAccount(e,r,n={}){n={...CE,...n};let i=AE(r),a=af.makeGenesis(i);return af.fromGenesis(e,a,n)}static async fromGenesis(e,r,n={}){return n={...CE,...n},e.createStreamFromGenesis(af.STREAM_TYPE_ID,r,n)}async setDid(e,r,n={}){n={...zg,...n};let i=typeof e=="string"?e.trim():e.id;if(TE(i)?.did!==i)throw new Error(`DID is not valid: '${i}'`);let c=await r.createLink(i);return this.setDidProof(c,n)}async setDidProof(e,r={}){r={...zg,...r};let n=this.makeCommit(e),i=await this.api.applyCommit(this.id,n,r);this.state$.next(i.state)}async clearDid(e,r={}){r={...zg,...r};let n=await e.createLink("");return this.setDidProof(n,r)}static async load(e,r,n={}){n={...hF,...n};let i=fn.from(r);if(i.type!=af.STREAM_TYPE_ID)throw new Error(`StreamID ${i.toString()} does not refer to a '${af.STREAM_TYPE_NAME}' stream, but to a ${i.typeName}`);return e.loadStream(i,n)}static makeGenesis(e){return e.chainId.namespace==="eip155"&&(e.address=e.address.toLowerCase()),{header:{controllers:[`${e.address}@${e.chainId.toString()}`],family:`caip10-${e.chainId.toString()}`}}}makeCommit(e){return{data:e,prev:this.tip,id:this.id.cid}}makeReadOnly(){this.setDidProof=Hg,this.setDid=Hg,this.sync=Hg,this._isReadOnly=!0}get isReadOnly(){return this._isReadOnly}},"Caip10Link");ff.STREAM_TYPE_NAME="caip10-link";ff.STREAM_TYPE_ID=1;ff=af=lF([EE()],ff);Pi();Aa();var l9=Lt(c9(),1),oq=function(t,e,r,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(t,e,r,n);else for(var u=t.length-1;u>=0;u--)(c=t[u])&&(a=(i<3?c(a):i>3?c(e,r,a):c(e,r))||a);return i>3&&a&&Object.defineProperty(e,r,a),a},yo,sq={sync:yr.PREFER_CACHE};async function u9(t){if(t.did==null)throw new Error("No DID provided");t.did.authenticated||(await t.did.authenticate(),t.loggerProvider&&t.loggerProvider.getDiagnosticsLogger().imp(`Now authenticated as DID ${t.did.id}`))}o(u9,"_ensureAuthenticated");async function aq(){throw new Error("Historical stream commits cannot be modified. Load the stream without specifying a commit to make updates.")}o(aq,"throwReadOnlyError");var Ys=yo=o(class extends ss{constructor(){super(...arguments),this._isReadOnly=!1}get content(){return super.content}get metadata(){return{controller:this.state$.value.metadata.controllers[0],model:yo.MODEL}}static async create(e,r,n){yo.assertComplete(r);let i={publish:!0,anchor:!0,pin:!0,sync:yr.NEVER_SYNC,throwOnInvalidCommit:!0},a=await yo._makeGenesis(e,r,n);return await e.createStreamFromGenesis(yo.STREAM_TYPE_ID,a,i)}static assertComplete(e,r){if(!e.name)throw r?new Error(`Model with StreamID ${r.toString()} is missing a 'name' field`):new Error("Model is missing a 'name' field");if(!e.schema)throw r?new Error(`Model ${e.name} (${r.toString()}) is missing a 'schema' field`):new Error(`Model ${e.name} is missing a 'schema' field`);if(!e.accountRelation)throw r?new Error(`Model ${e.name} (${r.toString()}) is missing a 'accountRelation' field`):new Error(`Model ${e.name} is missing a 'accountRelation' field`)}static async load(e,r,n={}){n={...sq,...n};let i=fn.from(r);if(i.type!=yo.STREAM_TYPE_ID)throw new Error(`StreamID ${i.toString()} does not refer to a '${yo.STREAM_TYPE_NAME}' stream, but to a ${i.typeName}`);return await e.loadStream(i,n)}static async _makeGenesis(e,r,n){let i=await this._makeRawGenesis(e,r,n);return yo._signDagJWS(e,i)}static async _makeRawGenesis(e,r,n){if(r==null)throw new Error("Genesis content cannot be null");if(!n||!n.controller)if(e.did)await u9(e),n={controller:e.did.hasParent?e.did.parent:e.did.id};else throw new Error("No controller specified");let i={controllers:[n.controller],model:yo.MODEL.bytes};return{data:r,header:i}}makeReadOnly(){this.sync=aq,this._isReadOnly=!0}get isReadOnly(){return this._isReadOnly}static async _signDagJWS(e,r){return await u9(e),e.did.createDagJWS(r)}},"Model");Ys.STREAM_TYPE_NAME="model";Ys.STREAM_TYPE_ID=2;Ys.MODEL=function(){let t=qa("model-v1"),e=l9.default.encode(t,"identity"),r=qo(ac,e),n=We.createV1(ac,r);return new rt("UNLOADABLE",n)}();Ys=yo=oq([Nc()],Ys);var p9=Lt(Oa(),1);var fq=function(t,e,r,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(t,e,r,n);else for(var u=t.length-1;u>=0;u--)(c=t[u])&&(a=(i<3?c(a):i>3?c(e,r,a):c(e,r))||a);return i>3&&a&&Object.defineProperty(e,r,a),a},Ji,cq={anchor:!0,publish:!0,pin:!0,sync:yr.NEVER_SYNC,syncTimeoutSeconds:0},uq={anchor:!1,publish:!1,pin:!0,sync:yr.PREFER_CACHE},lq={sync:yr.PREFER_CACHE},h9={anchor:!0,publish:!0,throwOnInvalidCommit:!0};async function d9(t){if(t.did==null)throw new Error("No DID provided");t.did.authenticated||(await t.did.authenticate(),t.loggerProvider&&t.loggerProvider.getDiagnosticsLogger().imp(`Now authenticated as DID ${t.did.id}`))}o(d9,"_ensureAuthenticated");async function Gg(){throw new Error("Historical stream commits cannot be modified. Load the stream without specifying a commit to make updates.")}o(Gg,"throwReadOnlyError");var uf=Ji=o(class extends ss{constructor(){super(...arguments),this._isReadOnly=!1}get content(){return super.content}get metadata(){let e=this.state$.value.metadata;return{controller:e.controllers[0],model:e.model}}static async create(e,r,n,i={}){i={...cq,...i};let a=i.asDID?{did:i.asDID}:e,c=await Ji._makeGenesis(a,r,n);return e.createStreamFromGenesis(Ji.STREAM_TYPE_ID,c,i)}static async single(e,r,n={}){n={...uq,...n};let i=n.asDID?{did:n.asDID}:e;r={...r,deterministic:!0};let a=await Ji._makeGenesis(i,null,r);return e.createStreamFromGenesis(Ji.STREAM_TYPE_ID,a,n)}static async load(e,r,n={}){n={...lq,...n};let i=fn.from(r);if(i.type!=Ji.STREAM_TYPE_ID)throw new Error(`StreamID ${i.toString()} does not refer to a '${Ji.STREAM_TYPE_NAME}' stream, but to a ${i.typeName}`);return e.loadStream(i,n)}async replace(e,r={}){r={...h9,...r};let n=r.asDID?{did:r.asDID}:this.api,i=await this._makeCommit(n,e),a=await this.api.applyCommit(this.id,i,r);this.state$.next(a.state)}async patch(e,r={}){r={...h9,...r};let n={data:e,prev:this.tip,id:this.id.cid},i=await Ji._signDagJWS(this.api,n),a=await this.api.applyCommit(this.id,i,r);this.state$.next(a.state)}makeReadOnly(){this.replace=Gg,this.patch=Gg,this.sync=Gg,this._isReadOnly=!0}get isReadOnly(){return this._isReadOnly}_makeCommit(e,r){let n=this._makeRawCommit(r);return Ji._signDagJWS(e,n)}_makeRawCommit(e){return{data:r0.compare(this.content,e||{}),prev:this.tip,id:this.state.log[0].cid}}static async _makeGenesis(e,r,n){let i=await this._makeRawGenesis(e,r,n);return n.deterministic?(qa(i),i):Ji._signDagJWS(e,i)}static async _makeRawGenesis(e,r,n){if(!n.model)throw new Error("Must specify a 'model' when creating a ModelInstanceDocument");let i=n.controller;if(!i)if(e.did)await d9(e),i=e.did.hasParent?e.did.parent:e.did.id;else throw new Error("No controller specified");let a={controllers:[i],model:n.model.bytes};return n.deterministic||(a.unique=(0,p9.randomBytes)(12)),{data:r,header:a}}static async _signDagJWS(e,r){return await d9(e),e.did.createDagJWS(r)}},"ModelInstanceDocument");uf.STREAM_TYPE_NAME="MID";uf.STREAM_TYPE_ID=3;uf=Ji=fq([Nc()],uf);var wl=class{constructor(e){this._apiUrl=e}async add(e,r){let n={};r&&(n.force=!0);let i=new URL(`./pins/${e}`,this._apiUrl);await Hr(i,{method:"post",body:n})}async rm(e,r){let n=new URL(`./pins/${e}`,this._apiUrl);await Hr(n,{method:"delete",body:{opts:r}})}async ls(e){let r=new URL("./pins",this._apiUrl);e&&(r=new URL(`./pins/${e.toString()}`,this._apiUrl));let n=await Hr(r),{pinnedStreamIds:i}=n;return{[Symbol.asyncIterator](){let a=0;return{next(){return a===i.length?Promise.resolve({value:null,done:!0}):Promise.resolve({value:i[a++],done:!1})}}}}}};o(wl,"RemotePinApi");var _l=class{constructor(e){this._fetchJson=Hr,this._collectionURL=new URL("./collection",e),this._countURL=new URL("./collection/count",e)}async count(e){return(await this._fetchJson(this._countURL,{method:"POST",body:$g(e)})).count}async query(e){let r=await this._fetchJson(this._collectionURL,{method:"POST",body:$g(e)});return{edges:r.edges.map(i=>({cursor:i.cursor,node:Xt.deserializeState(i.node)})),pageInfo:r.pageInfo}}};o(_l,"RemoteIndexApi");var El=class{constructor(e,r){this._apiUrl=e,this._getDidFn=r,this._fetchJson=Hr,this.modelsPath="./admin/models",this.getCodePath="./admin/getCode"}getCodeUrl(){return new URL(this.getCodePath,this._apiUrl)}getModelsUrl(){return new URL(this.modelsPath,this._apiUrl)}async buildJWS(e,r,n){let i=n?{models:n.map(c=>c.toString())}:void 0,a=await e.createJWS({code:r,requestPath:this.getModelsUrl().pathname,requestBody:i});return`${a.signatures[0].protected}.${a.payload}.${a.signatures[0].signature}`}async generateCode(){return(await this._fetchJson(this.getCodeUrl())).code}async startIndexingModels(e){let r=await this.generateCode();await this._fetchJson(this.getModelsUrl(),{method:"post",body:{jws:await this.buildJWS(this._getDidFn(),r,e)}})}async getIndexedModels(){let e=await this.generateCode();return(await this._fetchJson(this.getModelsUrl(),{headers:{Authorization:`Basic ${await this.buildJWS(this._getDidFn(),e)}`}})).models.map(n=>rt.fromString(n))}async stopIndexingModels(e){let r=await this.generateCode();await this._fetchJson(this.getModelsUrl(),{method:"delete",body:{jws:await this.buildJWS(this._getDidFn(),r,e)}})}};o(El,"RemoteAdminApi");var hq="/api/v0/",dq="http://localhost:7007",pq={syncInterval:5e3},mq={anchor:!0,publish:!0,sync:yr.PREFER_CACHE},bq={anchor:!0,publish:!0,sync:yr.PREFER_CACHE},m9={sync:yr.PREFER_CACHE},Al=class{constructor(e=dq,r={}){this._config={...pq,...r},this._apiUrl=new URL(hq,e),this._streamCache=new Map,this.context={api:this},this.pin=new wl(this._apiUrl),this.index=new _l(this._apiUrl);let n=(()=>this.did).bind(this);this.admin=new El(this._apiUrl,n),this._streamConstructors={[ff.STREAM_TYPE_ID]:ff,[Ys.STREAM_TYPE_ID]:Ys,[uf.STREAM_TYPE_ID]:uf,[Gn.STREAM_TYPE_ID]:Gn}}get did(){return this.context.did}set did(e){this.context.did=e}async createStreamFromGenesis(e,r,n={}){n={...bq,...n};let i=await tn.createFromGenesis(this._apiUrl,e,r,n,this._config.syncInterval),a=this._streamCache.get(i.id.toString());return a?(Xt.statesEqual(i.state,a.state)||a.next(i.state),this.buildStreamFromDocument(a)):(this._streamCache.set(i.id.toString(),i),this.buildStreamFromDocument(i))}async loadStream(e,r={}){r={...m9,...r};let n=fn.from(e),i=this._streamCache.get(n.baseID.toString());return i?await i._syncState(n,r):(i=await tn.load(n,this._apiUrl,this._config.syncInterval,r),this._streamCache.set(i.id.toString(),i)),this.buildStreamFromDocument(i)}async multiQuery(e,r){let n=e.map(c=>({...c,streamId:typeof c.streamId=="string"?c.streamId:c.streamId.toString()})),i=new URL("./multiqueries",this._apiUrl),a=await Hr(i,{method:"post",body:{queries:n,timeout:r}});return Object.entries(a).reduce((c,u)=>{let[m,v]=u,x=Xt.deserializeState(v),S=new tn(x,this._apiUrl,this._config.syncInterval);return c[m]=this.buildStreamFromDocument(S),c},{})}loadStreamCommits(e){let r=Ug(e);return tn.loadStreamCommits(r,this._apiUrl)}async applyCommit(e,r,n={}){n={...mq,...n};let i=Ug(e),a=await tn.applyCommit(this._apiUrl,i,r,n,this._config.syncInterval),c=this._streamCache.get(i.toString());return c?(c.next(a.state),this.buildStreamFromDocument(a)):(this._streamCache.set(i.toString(),a),this.buildStreamFromDocument(a))}async requestAnchor(e,r={}){r={...m9,...r};let{anchorStatus:n}=await Hr(`${this._apiUrl}/streams/${e.toString()}/anchor`,{method:"post",body:{opts:r}});return n}addStreamHandler(e){this._streamConstructors[e.name]=e.stream_constructor}buildStreamFromState(e){let r=new tn(e,this._apiUrl,this._config.syncInterval);return this.buildStreamFromDocument(r)}buildStreamFromDocument(e){let r=e.state.type,n=this._streamConstructors[r];if(!n)throw new Error(`Failed to find constructor for stream ${r}`);return new n(e,this.context)}async setDID(e){this.context.did=e}async getSupportedChains(){if(this._supportedChains)return this._supportedChains;let{supportedChains:e}=await Hr(this._apiUrl+"/node/chains");return this._supportedChains=e,e}async close(){Array.from(this._streamCache).map(([,e])=>{e.complete()}),this._streamCache.clear()}};o(Al,"CeramicClient");var Ut;(function(t){t.assertEqual=i=>i;function e(i){}o(e,"assertIs"),t.assertIs=e;function r(i){throw new Error}o(r,"assertNever"),t.assertNever=r,t.arrayToEnum=i=>{let a={};for(let c of i)a[c]=c;return a},t.getValidEnumValues=i=>{let a=t.objectKeys(i).filter(u=>typeof i[i[u]]!="number"),c={};for(let u of a)c[u]=i[u];return t.objectValues(c)},t.objectValues=i=>t.objectKeys(i).map(function(a){return i[a]}),t.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let a=[];for(let c in i)Object.prototype.hasOwnProperty.call(i,c)&&a.push(c);return a},t.find=(i,a)=>{for(let c of i)if(a(c))return c},t.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,a=" | "){return i.map(c=>typeof c=="string"?`'${c}'`:c).join(a)}o(n,"joinValues"),t.joinValues=n,t.jsonStringifyReplacer=(i,a)=>typeof a=="bigint"?a.toString():a})(Ut||(Ut={}));var Fe=Ut.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Xs=o(t=>{switch(typeof t){case"undefined":return Fe.undefined;case"string":return Fe.string;case"number":return isNaN(t)?Fe.nan:Fe.number;case"boolean":return Fe.boolean;case"function":return Fe.function;case"bigint":return Fe.bigint;case"symbol":return Fe.symbol;case"object":return Array.isArray(t)?Fe.array:t===null?Fe.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?Fe.promise:typeof Map<"u"&&t instanceof Map?Fe.map:typeof Set<"u"&&t instanceof Set?Fe.set:typeof Date<"u"&&t instanceof Date?Fe.date:Fe.object;default:return Fe.unknown}},"getParsedType"),Ne=Ut.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"]),gq=o(t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),"quotelessJson"),Si=class extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){let r=e||function(a){return a.message},n={_errors:[]},i=o(a=>{for(let c of a.issues)if(c.code==="invalid_union")c.unionErrors.map(i);else if(c.code==="invalid_return_type")i(c.returnTypeError);else if(c.code==="invalid_arguments")i(c.argumentsError);else if(c.path.length===0)n._errors.push(r(c));else{let u=n,m=0;for(;m<c.path.length;){let v=c.path[m];m===c.path.length-1?(u[v]=u[v]||{_errors:[]},u[v]._errors.push(r(c))):u[v]=u[v]||{_errors:[]},u=u[v],m++}}},"processError");return i(this),n}toString(){return this.message}get message(){return JSON.stringify(this.issues,Ut.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let i of this.issues)i.path.length>0?(r[i.path[0]]=r[i.path[0]]||[],r[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};o(Si,"ZodError");Si.create=t=>new Si(t);var Ml=o((t,e)=>{let r;switch(t.code){case Ne.invalid_type:t.received===Fe.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case Ne.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,Ut.jsonStringifyReplacer)}`;break;case Ne.unrecognized_keys:r=`Unrecognized key(s) in object: ${Ut.joinValues(t.keys,", ")}`;break;case Ne.invalid_union:r="Invalid input";break;case Ne.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Ut.joinValues(t.options)}`;break;case Ne.invalid_enum_value:r=`Invalid enum value. Expected ${Ut.joinValues(t.options)}, received '${t.received}'`;break;case Ne.invalid_arguments:r="Invalid function arguments";break;case Ne.invalid_return_type:r="Invalid function return type";break;case Ne.invalid_date:r="Invalid date";break;case Ne.invalid_string:typeof t.validation=="object"?"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:Ut.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case Ne.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(t.minimum)}`:r="Invalid input";break;case Ne.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(t.maximum)}`:r="Invalid input";break;case Ne.custom:r="Invalid input";break;case Ne.invalid_intersection_types:r="Intersection results could not be merged";break;case Ne.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case Ne.not_finite:r="Number must be finite";break;default:r=e.defaultError,Ut.assertNever(t)}return{message:r}},"errorMap"),y9=Ml;function vq(t){y9=t}o(vq,"setErrorMap");function z0(){return y9}o(z0,"getErrorMap");var K0=o(t=>{let{data:e,path:r,errorMaps:n,issueData:i}=t,a=[...r,...i.path||[]],c={...i,path:a},u="",m=n.filter(v=>!!v).slice().reverse();for(let v of m)u=v(c,{data:e,defaultError:u}).message;return{...i,path:a,message:i.message||u}},"makeIssue"),yq=[];function Ke(t,e){let r=K0({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,z0(),Ml].filter(n=>!!n)});t.common.issues.push(r)}o(Ke,"addIssueToContext");var Rr=class{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let n=[];for(let i of r){if(i.status==="aborted")return gt;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){let n=[];for(let i of r)n.push({key:await i.key,value:await i.value});return Rr.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let i of r){let{key:a,value:c}=i;if(a.status==="aborted"||c.status==="aborted")return gt;a.status==="dirty"&&e.dirty(),c.status==="dirty"&&e.dirty(),(typeof c.value<"u"||i.alwaysSet)&&(n[a.value]=c.value)}return{status:e.value,value:n}}};o(Rr,"ParseStatus");var gt=Object.freeze({status:"aborted"}),x9=o(t=>({status:"dirty",value:t}),"DIRTY"),rn=o(t=>({status:"valid",value:t}),"OK"),Vg=o(t=>t.status==="aborted","isAborted"),Wg=o(t=>t.status==="dirty","isDirty"),j0=o(t=>t.status==="valid","isValid"),G0=o(t=>typeof Promise!==void 0&&t instanceof Promise,"isAsync"),Rt;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(Rt||(Rt={}));var Vn=class{constructor(e,r,n,i){this.parent=e,this.data=r,this._path=n,this._key=i}get path(){return this._path.concat(this._key)}};o(Vn,"ParseInputLazyPath");var b9=o((t,e)=>{if(j0(e))return{success:!0,data:e.value};{if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");let r=new Si(t.common.issues);return{success:!1,error:r}}},"handleResult");function Tt(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:i}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:o((c,u)=>c.code!=="invalid_type"?{message:u.defaultError}:typeof u.data>"u"?{message:n??u.defaultError}:{message:r??u.defaultError},"customMap"),description:i}}o(Tt,"processCreateParams");var xt=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.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return Xs(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:Xs(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Rr,ctx:{common:e.parent.common,data:e.data,parsedType:Xs(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(G0(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){var n;let i={common:{issues:[],async:(n=r?.async)!==null&&n!==void 0?n:!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Xs(e)},a=this._parseSync({data:e,path:i.path,parent:i});return b9(i,a)}async parseAsync(e,r){let n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Xs(e)},i=this._parse({data:e,path:n.path,parent:n}),a=await(G0(i)?i:Promise.resolve(i));return b9(n,a)}refine(e,r){let n=o(i=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(i):r,"getIssueProperties");return this._refinement((i,a)=>{let c=e(i),u=o(()=>a.addIssue({code:Ne.custom,...n(i)}),"setError");return typeof Promise<"u"&&c instanceof Promise?c.then(m=>m?!0:(u(),!1)):c?!0:(u(),!1)})}refinement(e,r){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof r=="function"?r(n,i):r),!1))}_refinement(e){return new Mn({schema:this,typeName:pt.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Jn.create(this)}nullable(){return Eo.create(this)}nullish(){return this.optional().nullable()}array(){return Sn.create(this)}promise(){return hs.create(this)}or(e){return ra.create([this,e])}and(e){return na.create(this,e)}transform(e){return new Mn({schema:this,typeName:pt.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new ca({innerType:this,defaultValue:r,typeName:pt.ZodDefault})}brand(){return new Sl({typeName:pt.ZodBranded,type:this,...Tt(void 0)})}catch(e){let r=typeof e=="function"?e:()=>e;return new mf({innerType:this,defaultValue:r,typeName:pt.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return ua.create(this,e)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};o(xt,"ZodType");var xq=/^c[^\s-]{8,}$/i,wq=/^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i,_q=/^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i,Eq=o(t=>t.precision?t.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${t.precision}}(([+-]\\d{2}:\\d{2})|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${t.precision}}Z$`):t.precision===0?t.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}:\\d{2})|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):t.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}:\\d{2})|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$"),"datetimeRegex"),Mi=class extends xt{constructor(){super(...arguments),this._regex=(e,r,n)=>this.refinement(i=>e.test(i),{validation:r,code:Ne.invalid_string,...Rt.errToObj(n)}),this.nonempty=e=>this.min(1,Rt.errToObj(e)),this.trim=()=>new Mi({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==Fe.string){let a=this._getOrReturnCtx(e);return Ke(a,{code:Ne.invalid_type,expected:Fe.string,received:a.parsedType}),gt}let n=new Rr,i;for(let a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(i=this._getOrReturnCtx(e,i),Ke(i,{code:Ne.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(i=this._getOrReturnCtx(e,i),Ke(i,{code:Ne.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){let c=e.data.length>a.value,u=e.data.length<a.value;(c||u)&&(i=this._getOrReturnCtx(e,i),c?Ke(i,{code:Ne.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):u&&Ke(i,{code:Ne.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")_q.test(e.data)||(i=this._getOrReturnCtx(e,i),Ke(i,{validation:"email",code:Ne.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")wq.test(e.data)||(i=this._getOrReturnCtx(e,i),Ke(i,{validation:"uuid",code:Ne.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")xq.test(e.data)||(i=this._getOrReturnCtx(e,i),Ke(i,{validation:"cuid",code:Ne.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),Ke(i,{validation:"url",code:Ne.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),Ke(i,{validation:"regex",code:Ne.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="startsWith"?e.data.startsWith(a.value)||(i=this._getOrReturnCtx(e,i),Ke(i,{code:Ne.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(i=this._getOrReturnCtx(e,i),Ke(i,{code:Ne.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?Eq(a).test(e.data)||(i=this._getOrReturnCtx(e,i),Ke(i,{code:Ne.invalid_string,validation:"datetime",message:a.message}),n.dirty()):Ut.assertNever(a);return{status:n.value,value:e.data}}_addCheck(e){return new Mi({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Rt.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Rt.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Rt.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Rt.errToObj(e)})}datetime(e){var r;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:(r=e?.offset)!==null&&r!==void 0?r:!1,...Rt.errToObj(e?.message)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...Rt.errToObj(r)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...Rt.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...Rt.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...Rt.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...Rt.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...Rt.errToObj(r)})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get minLength(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};o(Mi,"ZodString");Mi.create=t=>{var e;return new Mi({checks:[],typeName:pt.ZodString,coerce:(e=t?.coerce)!==null&&e!==void 0?e:!1,...Tt(t)})};function Aq(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=r>n?r:n,a=parseInt(t.toFixed(i).replace(".","")),c=parseInt(e.toFixed(i).replace(".",""));return a%c/Math.pow(10,i)}o(Aq,"floatSafeRemainder");var Yi=class extends xt{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)!==Fe.number){let a=this._getOrReturnCtx(e);return Ke(a,{code:Ne.invalid_type,expected:Fe.number,received:a.parsedType}),gt}let n,i=new Rr;for(let a of this._def.checks)a.kind==="int"?Ut.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),Ke(n,{code:Ne.invalid_type,expected:"integer",received:"float",message:a.message}),i.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),Ke(n,{code:Ne.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),i.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),Ke(n,{code:Ne.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),i.dirty()):a.kind==="multipleOf"?Aq(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),Ke(n,{code:Ne.not_multiple_of,multipleOf:a.value,message:a.message}),i.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),Ke(n,{code:Ne.not_finite,message:a.message}),i.dirty()):Ut.assertNever(a);return{status:i.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,Rt.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Rt.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Rt.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Rt.toString(r))}setLimit(e,r,n,i){return new Yi({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:Rt.toString(i)}]})}_addCheck(e){return new Yi({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Rt.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Rt.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Rt.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Rt.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Rt.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Rt.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:Rt.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int")}};o(Yi,"ZodNumber");Yi.create=t=>new Yi({checks:[],typeName:pt.ZodNumber,coerce:t?.coerce||!1,...Tt(t)});var Zs=class extends xt{_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==Fe.bigint){let n=this._getOrReturnCtx(e);return Ke(n,{code:Ne.invalid_type,expected:Fe.bigint,received:n.parsedType}),gt}return rn(e.data)}};o(Zs,"ZodBigInt");Zs.create=t=>{var e;return new Zs({typeName:pt.ZodBigInt,coerce:(e=t?.coerce)!==null&&e!==void 0?e:!1,...Tt(t)})};var Qs=class extends xt{_parse(e){if(this._def.coerce&&(e.data=Boolean(e.data)),this._getType(e)!==Fe.boolean){let n=this._getOrReturnCtx(e);return Ke(n,{code:Ne.invalid_type,expected:Fe.boolean,received:n.parsedType}),gt}return rn(e.data)}};o(Qs,"ZodBoolean");Qs.create=t=>new Qs({typeName:pt.ZodBoolean,coerce:t?.coerce||!1,...Tt(t)});var xo=class extends xt{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==Fe.date){let a=this._getOrReturnCtx(e);return Ke(a,{code:Ne.invalid_type,expected:Fe.date,received:a.parsedType}),gt}if(isNaN(e.data.getTime())){let a=this._getOrReturnCtx(e);return Ke(a,{code:Ne.invalid_date}),gt}let n=new Rr,i;for(let a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(i=this._getOrReturnCtx(e,i),Ke(i,{code:Ne.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(i=this._getOrReturnCtx(e,i),Ke(i,{code:Ne.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):Ut.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new xo({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:Rt.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:Rt.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}};o(xo,"ZodDate");xo.create=t=>new xo({checks:[],coerce:t?.coerce||!1,typeName:pt.ZodDate,...Tt(t)});var lf=class extends xt{_parse(e){if(this._getType(e)!==Fe.symbol){let n=this._getOrReturnCtx(e);return Ke(n,{code:Ne.invalid_type,expected:Fe.symbol,received:n.parsedType}),gt}return rn(e.data)}};o(lf,"ZodSymbol");lf.create=t=>new lf({typeName:pt.ZodSymbol,...Tt(t)});var ea=class extends xt{_parse(e){if(this._getType(e)!==Fe.undefined){let n=this._getOrReturnCtx(e);return Ke(n,{code:Ne.invalid_type,expected:Fe.undefined,received:n.parsedType}),gt}return rn(e.data)}};o(ea,"ZodUndefined");ea.create=t=>new ea({typeName:pt.ZodUndefined,...Tt(t)});var ta=class extends xt{_parse(e){if(this._getType(e)!==Fe.null){let n=this._getOrReturnCtx(e);return Ke(n,{code:Ne.invalid_type,expected:Fe.null,received:n.parsedType}),gt}return rn(e.data)}};o(ta,"ZodNull");ta.create=t=>new ta({typeName:pt.ZodNull,...Tt(t)});var us=class extends xt{constructor(){super(...arguments),this._any=!0}_parse(e){return rn(e.data)}};o(us,"ZodAny");us.create=t=>new us({typeName:pt.ZodAny,...Tt(t)});var wo=class extends xt{constructor(){super(...arguments),this._unknown=!0}_parse(e){return rn(e.data)}};o(wo,"ZodUnknown");wo.create=t=>new wo({typeName:pt.ZodUnknown,...Tt(t)});var Ti=class extends xt{_parse(e){let r=this._getOrReturnCtx(e);return Ke(r,{code:Ne.invalid_type,expected:Fe.never,received:r.parsedType}),gt}};o(Ti,"ZodNever");Ti.create=t=>new Ti({typeName:pt.ZodNever,...Tt(t)});var hf=class extends xt{_parse(e){if(this._getType(e)!==Fe.undefined){let n=this._getOrReturnCtx(e);return Ke(n,{code:Ne.invalid_type,expected:Fe.void,received:n.parsedType}),gt}return rn(e.data)}};o(hf,"ZodVoid");hf.create=t=>new hf({typeName:pt.ZodVoid,...Tt(t)});var Sn=class extends xt{_parse(e){let{ctx:r,status:n}=this._processInputParams(e),i=this._def;if(r.parsedType!==Fe.array)return Ke(r,{code:Ne.invalid_type,expected:Fe.array,received:r.parsedType}),gt;if(i.exactLength!==null){let c=r.data.length>i.exactLength.value,u=r.data.length<i.exactLength.value;(c||u)&&(Ke(r,{code:c?Ne.too_big:Ne.too_small,minimum:u?i.exactLength.value:void 0,maximum:c?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&r.data.length<i.minLength.value&&(Ke(r,{code:Ne.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&r.data.length>i.maxLength.value&&(Ke(r,{code:Ne.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),r.common.async)return Promise.all(r.data.map((c,u)=>i.type._parseAsync(new Vn(r,c,r.path,u)))).then(c=>Rr.mergeArray(n,c));let a=r.data.map((c,u)=>i.type._parseSync(new Vn(r,c,r.path,u)));return Rr.mergeArray(n,a)}get element(){return this._def.type}min(e,r){return new Sn({...this._def,minLength:{value:e,message:Rt.toString(r)}})}max(e,r){return new Sn({...this._def,maxLength:{value:e,message:Rt.toString(r)}})}length(e,r){return new Sn({...this._def,exactLength:{value:e,message:Rt.toString(r)}})}nonempty(e){return this.min(1,e)}};o(Sn,"ZodArray");Sn.create=(t,e)=>new Sn({type:t,minLength:null,maxLength:null,exactLength:null,typeName:pt.ZodArray,...Tt(e)});var V0;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(V0||(V0={}));var g9=o(t=>e=>new er({...t,shape:()=>({...t.shape(),...e})}),"AugmentFactory");function $c(t){if(t instanceof er){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=Jn.create($c(n))}return new er({...t._def,shape:()=>e})}else return t instanceof Sn?Sn.create($c(t.element)):t instanceof Jn?Jn.create($c(t.unwrap())):t instanceof Eo?Eo.create($c(t.unwrap())):t instanceof Wn?Wn.create(t.items.map(e=>$c(e))):t}o($c,"deepPartialify");var er=class extends xt{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=g9(this._def),this.extend=g9(this._def)}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=Ut.objectKeys(e);return this._cached={shape:e,keys:r}}_parse(e){if(this._getType(e)!==Fe.object){let v=this._getOrReturnCtx(e);return Ke(v,{code:Ne.invalid_type,expected:Fe.object,received:v.parsedType}),gt}let{status:n,ctx:i}=this._processInputParams(e),{shape:a,keys:c}=this._getCached(),u=[];if(!(this._def.catchall instanceof Ti&&this._def.unknownKeys==="strip"))for(let v in i.data)c.includes(v)||u.push(v);let m=[];for(let v of c){let x=a[v],S=i.data[v];m.push({key:{status:"valid",value:v},value:x._parse(new Vn(i,S,i.path,v)),alwaysSet:v in i.data})}if(this._def.catchall instanceof Ti){let v=this._def.unknownKeys;if(v==="passthrough")for(let x of u)m.push({key:{status:"valid",value:x},value:{status:"valid",value:i.data[x]}});else if(v==="strict")u.length>0&&(Ke(i,{code:Ne.unrecognized_keys,keys:u}),n.dirty());else if(v!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let v=this._def.catchall;for(let x of u){let S=i.data[x];m.push({key:{status:"valid",value:x},value:v._parse(new Vn(i,S,i.path,x)),alwaysSet:x in i.data})}}return i.common.async?Promise.resolve().then(async()=>{let v=[];for(let x of m){let S=await x.key;v.push({key:S,value:await x.value,alwaysSet:x.alwaysSet})}return v}).then(v=>Rr.mergeObjectSync(n,v)):Rr.mergeObjectSync(n,m)}get shape(){return this._def.shape()}strict(e){return Rt.errToObj,new er({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{var i,a,c,u;let m=(c=(a=(i=this._def).errorMap)===null||a===void 0?void 0:a.call(i,r,n).message)!==null&&c!==void 0?c:n.defaultError;return r.code==="unrecognized_keys"?{message:(u=Rt.errToObj(e).message)!==null&&u!==void 0?u:m}:{message:m}}}:{}})}strip(){return new er({...this._def,unknownKeys:"strip"})}passthrough(){return new er({...this._def,unknownKeys:"passthrough"})}setKey(e,r){return this.augment({[e]:r})}merge(e){return new er({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>V0.mergeShapes(this._def.shape(),e._def.shape()),typeName:pt.ZodObject})}catchall(e){return new er({...this._def,catchall:e})}pick(e){let r={};return Ut.objectKeys(e).map(n=>{this.shape[n]&&(r[n]=this.shape[n])}),new er({...this._def,shape:()=>r})}omit(e){let r={};return Ut.objectKeys(this.shape).map(n=>{Ut.objectKeys(e).indexOf(n)===-1&&(r[n]=this.shape[n])}),new er({...this._def,shape:()=>r})}deepPartial(){return $c(this)}partial(e){let r={};if(e)return Ut.objectKeys(this.shape).map(n=>{Ut.objectKeys(e).indexOf(n)===-1?r[n]=this.shape[n]:r[n]=this.shape[n].optional()}),new er({...this._def,shape:()=>r});for(let n in this.shape){let i=this.shape[n];r[n]=i.optional()}return new er({...this._def,shape:()=>r})}required(e){let r={};if(e)Ut.objectKeys(this.shape).map(n=>{if(Ut.objectKeys(e).indexOf(n)===-1)r[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof Jn;)a=a._def.innerType;r[n]=a}});else for(let n in this.shape){let a=this.shape[n];for(;a instanceof Jn;)a=a._def.innerType;r[n]=a}return new er({...this._def,shape:()=>r})}keyof(){return w9(Ut.objectKeys(this.shape))}};o(er,"ZodObject");er.create=(t,e)=>new er({shape:()=>t,unknownKeys:"strip",catchall:Ti.create(),typeName:pt.ZodObject,...Tt(e)});er.strictCreate=(t,e)=>new er({shape:()=>t,unknownKeys:"strict",catchall:Ti.create(),typeName:pt.ZodObject,...Tt(e)});er.lazycreate=(t,e)=>new er({shape:t,unknownKeys:"strip",catchall:Ti.create(),typeName:pt.ZodObject,...Tt(e)});var ra=class extends xt{_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function i(a){for(let u of a)if(u.result.status==="valid")return u.result;for(let u of a)if(u.result.status==="dirty")return r.common.issues.push(...u.ctx.common.issues),u.result;let c=a.map(u=>new Si(u.ctx.common.issues));return Ke(r,{code:Ne.invalid_union,unionErrors:c}),gt}if(o(i,"handleResults"),r.common.async)return Promise.all(n.map(async a=>{let c={...r,common:{...r.common,issues:[]},parent:null};return{result:await a._parseAsync({data:r.data,path:r.path,parent:c}),ctx:c}})).then(i);{let a,c=[];for(let m of n){let v={...r,common:{...r.common,issues:[]},parent:null},x=m._parseSync({data:r.data,path:r.path,parent:v});if(x.status==="valid")return x;x.status==="dirty"&&!a&&(a={result:x,ctx:v}),v.common.issues.length&&c.push(v.common.issues)}if(a)return r.common.issues.push(...a.ctx.common.issues),a.result;let u=c.map(m=>new Si(m));return Ke(r,{code:Ne.invalid_union,unionErrors:u}),gt}}get options(){return this._def.options}};o(ra,"ZodUnion");ra.create=(t,e)=>new ra({options:t,typeName:pt.ZodUnion,...Tt(e)});var H0=o(t=>t instanceof oa?H0(t.schema):t instanceof Mn?H0(t.innerType()):t instanceof sa?[t.value]:t instanceof aa?t.options:t instanceof fa?Object.keys(t.enum):t instanceof ca?H0(t._def.innerType):t instanceof ea?[void 0]:t instanceof ta?[null]:null,"getDiscriminator"),df=class extends xt{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==Fe.object)return Ke(r,{code:Ne.invalid_type,expected:Fe.object,received:r.parsedType}),gt;let n=this.discriminator,i=r.data[n],a=this.optionsMap.get(i);return a?r.common.async?a._parseAsync({data:r.data,path:r.path,parent:r}):a._parseSync({data:r.data,path:r.path,parent:r}):(Ke(r,{code:Ne.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),gt)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let i=new Map;for(let a of r){let c=H0(a.shape[e]);if(!c)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let u of c){if(i.has(u))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(u)}`);i.set(u,a)}}return new df({typeName:pt.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:i,...Tt(n)})}};o(df,"ZodDiscriminatedUnion");function Jg(t,e){let r=Xs(t),n=Xs(e);if(t===e)return{valid:!0,data:t};if(r===Fe.object&&n===Fe.object){let i=Ut.objectKeys(e),a=Ut.objectKeys(t).filter(u=>i.indexOf(u)!==-1),c={...t,...e};for(let u of a){let m=Jg(t[u],e[u]);if(!m.valid)return{valid:!1};c[u]=m.data}return{valid:!0,data:c}}else if(r===Fe.array&&n===Fe.array){if(t.length!==e.length)return{valid:!1};let i=[];for(let a=0;a<t.length;a++){let c=t[a],u=e[a],m=Jg(c,u);if(!m.valid)return{valid:!1};i.push(m.data)}return{valid:!0,data:i}}else return r===Fe.date&&n===Fe.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}o(Jg,"mergeValues");var na=class extends xt{_parse(e){let{status:r,ctx:n}=this._processInputParams(e),i=o((a,c)=>{if(Vg(a)||Vg(c))return gt;let u=Jg(a.value,c.value);return u.valid?((Wg(a)||Wg(c))&&r.dirty(),{status:r.value,value:u.data}):(Ke(n,{code:Ne.invalid_intersection_types}),gt)},"handleParsed");return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,c])=>i(a,c)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};o(na,"ZodIntersection");na.create=(t,e,r)=>new na({left:t,right:e,typeName:pt.ZodIntersection,...Tt(r)});var Wn=class extends xt{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==Fe.array)return Ke(n,{code:Ne.invalid_type,expected:Fe.array,received:n.parsedType}),gt;if(n.data.length<this._def.items.length)return Ke(n,{code:Ne.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),gt;!this._def.rest&&n.data.length>this._def.items.length&&(Ke(n,{code:Ne.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let a=n.data.map((c,u)=>{let m=this._def.items[u]||this._def.rest;return m?m._parse(new Vn(n,c,n.path,u)):null}).filter(c=>!!c);return n.common.async?Promise.all(a).then(c=>Rr.mergeArray(r,c)):Rr.mergeArray(r,a)}get items(){return this._def.items}rest(e){return new Wn({...this._def,rest:e})}};o(Wn,"ZodTuple");Wn.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Wn({items:t,typeName:pt.ZodTuple,rest:null,...Tt(e)})};var ia=class extends xt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==Fe.object)return Ke(n,{code:Ne.invalid_type,expected:Fe.object,received:n.parsedType}),gt;let i=[],a=this._def.keyType,c=this._def.valueType;for(let u in n.data)i.push({key:a._parse(new Vn(n,u,n.path,u)),value:c._parse(new Vn(n,n.data[u],n.path,u))});return n.common.async?Rr.mergeObjectAsync(r,i):Rr.mergeObjectSync(r,i)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof xt?new ia({keyType:e,valueType:r,typeName:pt.ZodRecord,...Tt(n)}):new ia({keyType:Mi.create(),valueType:e,typeName:pt.ZodRecord,...Tt(r)})}};o(ia,"ZodRecord");var pf=class extends xt{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==Fe.map)return Ke(n,{code:Ne.invalid_type,expected:Fe.map,received:n.parsedType}),gt;let i=this._def.keyType,a=this._def.valueType,c=[...n.data.entries()].map(([u,m],v)=>({key:i._parse(new Vn(n,u,n.path,[v,"key"])),value:a._parse(new Vn(n,m,n.path,[v,"value"]))}));if(n.common.async){let u=new Map;return Promise.resolve().then(async()=>{for(let m of c){let v=await m.key,x=await m.value;if(v.status==="aborted"||x.status==="aborted")return gt;(v.status==="dirty"||x.status==="dirty")&&r.dirty(),u.set(v.value,x.value)}return{status:r.value,value:u}})}else{let u=new Map;for(let m of c){let v=m.key,x=m.value;if(v.status==="aborted"||x.status==="aborted")return gt;(v.status==="dirty"||x.status==="dirty")&&r.dirty(),u.set(v.value,x.value)}return{status:r.value,value:u}}}};o(pf,"ZodMap");pf.create=(t,e,r)=>new pf({valueType:e,keyType:t,typeName:pt.ZodMap,...Tt(r)});var _o=class extends xt{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==Fe.set)return Ke(n,{code:Ne.invalid_type,expected:Fe.set,received:n.parsedType}),gt;let i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(Ke(n,{code:Ne.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),r.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(Ke(n,{code:Ne.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),r.dirty());let a=this._def.valueType;function c(m){let v=new Set;for(let x of m){if(x.status==="aborted")return gt;x.status==="dirty"&&r.dirty(),v.add(x.value)}return{status:r.value,value:v}}o(c,"finalizeSet");let u=[...n.data.values()].map((m,v)=>a._parse(new Vn(n,m,n.path,v)));return n.common.async?Promise.all(u).then(m=>c(m)):c(u)}min(e,r){return new _o({...this._def,minSize:{value:e,message:Rt.toString(r)}})}max(e,r){return new _o({...this._def,maxSize:{value:e,message:Rt.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};o(_o,"ZodSet");_o.create=(t,e)=>new _o({valueType:t,minSize:null,maxSize:null,typeName:pt.ZodSet,...Tt(e)});var ls=class extends xt{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==Fe.function)return Ke(r,{code:Ne.invalid_type,expected:Fe.function,received:r.parsedType}),gt;function n(u,m){return K0({data:u,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,z0(),Ml].filter(v=>!!v),issueData:{code:Ne.invalid_arguments,argumentsError:m}})}o(n,"makeArgsIssue");function i(u,m){return K0({data:u,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,z0(),Ml].filter(v=>!!v),issueData:{code:Ne.invalid_return_type,returnTypeError:m}})}o(i,"makeReturnsIssue");let a={errorMap:r.common.contextualErrorMap},c=r.data;return this._def.returns instanceof hs?rn(async(...u)=>{let m=new Si([]),v=await this._def.args.parseAsync(u,a).catch(O=>{throw m.addIssue(n(u,O)),m}),x=await c(...v);return await this._def.returns._def.type.parseAsync(x,a).catch(O=>{throw m.addIssue(i(x,O)),m})}):rn((...u)=>{let m=this._def.args.safeParse(u,a);if(!m.success)throw new Si([n(u,m.error)]);let v=c(...m.data),x=this._def.returns.safeParse(v,a);if(!x.success)throw new Si([i(v,x.error)]);return x.data})}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ls({...this._def,args:Wn.create(e).rest(wo.create())})}returns(e){return new ls({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new ls({args:e||Wn.create([]).rest(wo.create()),returns:r||wo.create(),typeName:pt.ZodFunction,...Tt(n)})}};o(ls,"ZodFunction");var oa=class extends xt{get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};o(oa,"ZodLazy");oa.create=(t,e)=>new oa({getter:t,typeName:pt.ZodLazy,...Tt(e)});var sa=class extends xt{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return Ke(r,{code:Ne.invalid_literal,expected:this._def.value}),gt}return{status:"valid",value:e.data}}get value(){return this._def.value}};o(sa,"ZodLiteral");sa.create=(t,e)=>new sa({value:t,typeName:pt.ZodLiteral,...Tt(e)});function w9(t,e){return new aa({values:t,typeName:pt.ZodEnum,...Tt(e)})}o(w9,"createZodEnum");var aa=class extends xt{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return Ke(r,{expected:Ut.joinValues(n),received:r.parsedType,code:Ne.invalid_type}),gt}if(this._def.values.indexOf(e.data)===-1){let r=this._getOrReturnCtx(e),n=this._def.values;return Ke(r,{received:r.data,code:Ne.invalid_enum_value,options:n}),gt}return rn(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}};o(aa,"ZodEnum");aa.create=w9;var fa=class extends xt{_parse(e){let r=Ut.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==Fe.string&&n.parsedType!==Fe.number){let i=Ut.objectValues(r);return Ke(n,{expected:Ut.joinValues(i),received:n.parsedType,code:Ne.invalid_type}),gt}if(r.indexOf(e.data)===-1){let i=Ut.objectValues(r);return Ke(n,{received:n.data,code:Ne.invalid_enum_value,options:i}),gt}return rn(e.data)}get enum(){return this._def.values}};o(fa,"ZodNativeEnum");fa.create=(t,e)=>new fa({values:t,typeName:pt.ZodNativeEnum,...Tt(e)});var hs=class extends xt{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==Fe.promise&&r.common.async===!1)return Ke(r,{code:Ne.invalid_type,expected:Fe.promise,received:r.parsedType}),gt;let n=r.parsedType===Fe.promise?r.data:Promise.resolve(r.data);return rn(n.then(i=>this._def.type.parseAsync(i,{path:r.path,errorMap:r.common.contextualErrorMap})))}};o(hs,"ZodPromise");hs.create=(t,e)=>new hs({type:t,typeName:pt.ZodPromise,...Tt(e)});var Mn=class extends xt{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===pt.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),i=this._def.effect||null;if(i.type==="preprocess"){let c=i.transform(n.data);return n.common.async?Promise.resolve(c).then(u=>this._def.schema._parseAsync({data:u,path:n.path,parent:n})):this._def.schema._parseSync({data:c,path:n.path,parent:n})}let a={addIssue:c=>{Ke(n,c),c.fatal?r.abort():r.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),i.type==="refinement"){let c=o(u=>{let m=i.refinement(u,a);if(n.common.async)return Promise.resolve(m);if(m instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return u},"executeRefinement");if(n.common.async===!1){let u=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return u.status==="aborted"?gt:(u.status==="dirty"&&r.dirty(),c(u.value),{status:r.value,value:u.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(u=>u.status==="aborted"?gt:(u.status==="dirty"&&r.dirty(),c(u.value).then(()=>({status:r.value,value:u.value}))))}if(i.type==="transform")if(n.common.async===!1){let c=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!j0(c))return c;let u=i.transform(c.value,a);if(u instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:u}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(c=>j0(c)?Promise.resolve(i.transform(c.value,a)).then(u=>({status:r.value,value:u})):c);Ut.assertNever(i)}};o(Mn,"ZodEffects");Mn.create=(t,e,r)=>new Mn({schema:t,typeName:pt.ZodEffects,effect:e,...Tt(r)});Mn.createWithPreprocess=(t,e,r)=>new Mn({schema:e,effect:{type:"preprocess",transform:t},typeName:pt.ZodEffects,...Tt(r)});var Jn=class extends xt{_parse(e){return this._getType(e)===Fe.undefined?rn(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};o(Jn,"ZodOptional");Jn.create=(t,e)=>new Jn({innerType:t,typeName:pt.ZodOptional,...Tt(e)});var Eo=class extends xt{_parse(e){return this._getType(e)===Fe.null?rn(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};o(Eo,"ZodNullable");Eo.create=(t,e)=>new Eo({innerType:t,typeName:pt.ZodNullable,...Tt(e)});var ca=class extends xt{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===Fe.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};o(ca,"ZodDefault");ca.create=(t,e)=>new ca({innerType:t,typeName:pt.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Tt(e)});var mf=class extends xt{_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.innerType._parse({data:r.data,path:r.path,parent:r});return G0(n)?n.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.defaultValue()})):{status:"valid",value:n.status==="valid"?n.value:this._def.defaultValue()}}removeDefault(){return this._def.innerType}};o(mf,"ZodCatch");mf.create=(t,e)=>new mf({innerType:t,typeName:pt.ZodCatch,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Tt(e)});var bf=class extends xt{_parse(e){if(this._getType(e)!==Fe.nan){let n=this._getOrReturnCtx(e);return Ke(n,{code:Ne.invalid_type,expected:Fe.nan,received:n.parsedType}),gt}return{status:"valid",value:e.data}}};o(bf,"ZodNaN");bf.create=t=>new bf({typeName:pt.ZodNaN,...Tt(t)});var Sq=Symbol("zod_brand"),Sl=class extends xt{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}};o(Sl,"ZodBranded");var ua=class extends xt{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return o(async()=>{let a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?gt:a.status==="dirty"?(r.dirty(),x9(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})},"handleAsync")();{let i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?gt:i.status==="dirty"?(r.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,r){return new ua({in:e,out:r,typeName:pt.ZodPipeline})}};o(ua,"ZodPipeline");var _9=o((t,e={},r)=>t?us.create().superRefine((n,i)=>{if(!t(n)){let a=typeof e=="function"?e(n):e,c=typeof a=="string"?{message:a}:a;i.addIssue({code:"custom",...c,fatal:r})}}):us.create(),"custom"),Mq={object:er.lazycreate},pt;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline"})(pt||(pt={}));var Tq=o((t,e={message:`Input not instance of ${t.name}`})=>_9(r=>r instanceof t,e,!0),"instanceOfType"),E9=Mi.create,A9=Yi.create,Cq=bf.create,kq=Zs.create,S9=Qs.create,Iq=xo.create,Dq=lf.create,Oq=ea.create,Rq=ta.create,Nq=us.create,Pq=wo.create,Lq=Ti.create,Bq=hf.create,Uq=Sn.create,$q=er.create,Fq=er.strictCreate,qq=ra.create,Hq=df.create,zq=na.create,Kq=Wn.create,jq=ia.create,Gq=pf.create,Vq=_o.create,Wq=ls.create,Jq=oa.create,Yq=sa.create,Xq=aa.create,Zq=fa.create,Qq=hs.create,v9=Mn.create,eH=Jn.create,tH=Eo.create,rH=Mn.createWithPreprocess,nH=ua.create,iH=o(()=>E9().optional(),"ostring"),oH=o(()=>A9().optional(),"onumber"),sH=o(()=>S9().optional(),"oboolean"),aH={string:t=>Mi.create({...t,coerce:!0}),number:t=>Yi.create({...t,coerce:!0}),boolean:t=>Qs.create({...t,coerce:!0}),bigint:t=>Zs.create({...t,coerce:!0}),date:t=>xo.create({...t,coerce:!0})},fH=gt,V=Object.freeze({__proto__:null,defaultErrorMap:Ml,setErrorMap:vq,getErrorMap:z0,makeIssue:K0,EMPTY_PATH:yq,addIssueToContext:Ke,ParseStatus:Rr,INVALID:gt,DIRTY:x9,OK:rn,isAborted:Vg,isDirty:Wg,isValid:j0,isAsync:G0,get util(){return Ut},ZodParsedType:Fe,getParsedType:Xs,ZodType:xt,ZodString:Mi,ZodNumber:Yi,ZodBigInt:Zs,ZodBoolean:Qs,ZodDate:xo,ZodSymbol:lf,ZodUndefined:ea,ZodNull:ta,ZodAny:us,ZodUnknown:wo,ZodNever:Ti,ZodVoid:hf,ZodArray:Sn,get objectUtil(){return V0},ZodObject:er,ZodUnion:ra,ZodDiscriminatedUnion:df,ZodIntersection:na,ZodTuple:Wn,ZodRecord:ia,ZodMap:pf,ZodSet:_o,ZodFunction:ls,ZodLazy:oa,ZodLiteral:sa,ZodEnum:aa,ZodNativeEnum:fa,ZodPromise:hs,ZodEffects:Mn,ZodTransformer:Mn,ZodOptional:Jn,ZodNullable:Eo,ZodDefault:ca,ZodCatch:mf,ZodNaN:bf,BRAND:Sq,ZodBranded:Sl,ZodPipeline:ua,custom:_9,Schema:xt,ZodSchema:xt,late:Mq,get ZodFirstPartyTypeKind(){return pt},coerce:aH,any:Nq,array:Uq,bigint:kq,boolean:S9,date:Iq,discriminatedUnion:Hq,effect:v9,enum:Xq,function:Wq,instanceof:Tq,intersection:zq,lazy:Jq,literal:Yq,map:Gq,nan:Cq,nativeEnum:Zq,never:Lq,null:Rq,nullable:tH,number:A9,object:$q,oboolean:sH,onumber:oH,optional:eH,ostring:iH,pipeline:nH,preprocess:rH,promise:Qq,record:jq,set:Vq,strictObject:Fq,string:E9,symbol:Dq,transformer:v9,tuple:Kq,undefined:Oq,union:qq,unknown:Pq,void:Bq,NEVER:fH,ZodIssueCode:Ne,quotelessJson:gq,ZodError:Si});var T9=V.array(V.string().or(V.record(V.any()))),qte=V.object({type:V.string().optional(),narrative:V.string().optional()}),J0=V.string().or(V.object({id:V.string(),type:V.string(),caption:V.string().optional()})),cH=V.object({type:V.string().min(1).or(V.string().array().nonempty()),latitude:V.number(),longitude:V.number()}),uH=V.object({type:V.string().min(1).or(V.string().array().nonempty()),addressCountry:V.string().optional(),addressCountryCode:V.string().optional(),addressRegion:V.string().optional(),addressLocality:V.string().optional(),streetAddress:V.string().optional(),postOfficeBoxNumber:V.string().optional(),postalCode:V.string().optional(),geo:cH.optional()}),lH=V.enum(["sourcedId","systemId","productId","userName","accountId","emailAddress","nationalIdentityNumber","isbn","issn","lisSourcedId","oneRosterSourcedId","sisSourcedId","ltiContextId","ltiDeploymentId","ltiToolId","ltiPlatformId","ltiUserId","identifier"]).or(V.string()),C9=V.object({type:V.string().min(1).or(V.string().array().nonempty()),identifier:V.string(),identifierType:lH}),Tl=V.string().or(V.object({id:V.string().optional(),type:V.string().or(V.string().array().nonempty().optional()),name:V.string().optional(),url:V.string().optional(),phone:V.string().optional(),description:V.string().optional(),endorsement:V.any().array().optional(),image:J0.optional(),email:V.string().email().optional(),address:uH.optional(),otherIdentifier:C9.array().optional(),official:V.string().optional(),parentOrg:V.any().optional(),familyName:V.string().optional(),givenName:V.string().optional(),additionalName:V.string().optional(),patronymicName:V.string().optional(),honorificPrefix:V.string().optional(),honorificSuffix:V.string().optional(),familyNamePrefix:V.string().optional(),dateOfBirth:V.string().optional()}).catchall(V.any())),Yg=V.object({id:V.string().optional()}).catchall(V.any()),hH=V.object({type:V.string(),id:V.string()}).catchall(V.any()),dH=V.object({id:V.string(),type:V.string()}).catchall(V.any()),pH=V.object({id:V.string(),type:V.string()}).catchall(V.any()),W0=V.object({"@context":T9,id:V.string().optional(),type:V.string().array().nonempty(),issuer:Tl,issuanceDate:V.string(),expirationDate:V.string().optional(),credentialSubject:Yg.or(Yg.array()),credentialStatus:hH.optional(),credentialSchema:dH.array().optional(),refreshService:pH.optional()}).catchall(V.any()),la=V.object({type:V.string(),created:V.string(),challenge:V.string().optional(),domain:V.string().optional(),nonce:V.string().optional(),proofPurpose:V.string(),verificationMethod:V.string(),jws:V.string().optional()}).catchall(V.any()),Cl=W0.extend({proof:la.or(la.array())}),mH=V.object({"@context":T9,id:V.string().optional(),type:V.string().or(V.string().array().nonempty()),verifiableCredential:Cl.or(Cl.array()).optional(),holder:V.string().optional()}).catchall(V.any()),Zg=mH.extend({proof:la.or(la.array())}),bH=V.enum(["ceasn:Competency","ceterms:Credential","CFItem","CFRubric","CFRubricCriterion","CFRubricCriterionLevel","CTDL"]).or(V.string()),Y0=V.object({type:V.string().array().nonempty(),targetCode:V.string().optional(),targetDescription:V.string().optional(),targetName:V.string(),targetFramework:V.string().optional(),targetType:bH.optional(),targetUrl:V.string()}),gH=V.enum(["Achievement","ApprenticeshipCertificate","Assessment","Assignment","AssociateDegree","Award","Badge","BachelorDegree","Certificate","CertificateOfCompletion","Certification","CommunityService","Competency","Course","CoCurricular","Degree","Diploma","DoctoralDegree","Fieldwork","GeneralEducationDevelopment","JourneymanCertificate","LearningProgram","License","Membership","ProfessionalDoctorate","QualityAssuranceCredential","MasterCertificate","MasterDegree","MicroCredential","ResearchDoctorate","SecondarySchoolDiploma"]),vH=gH.or(V.string()),yH=V.object({id:V.string().optional(),narrative:V.string().optional()}).catchall(V.any()),xH=V.object({id:V.string(),type:V.string().array().nonempty(),endorsementComment:V.string().optional()}),wH=W0.extend({credentialSubject:xH,proof:la.or(la.array()).optional()}),_H=V.object({id:V.string(),"@language":V.string().optional(),version:V.string().optional()}),EH=V.enum(["GradePointAverage","LetterGrade","Percent","PerformanceLevel","PredictedScore","RawScore","Result","RubricCriterion","RubricCriterionLevel","RubricScore","ScaledScore","Status"]).or(V.string()),AH=V.object({id:V.string(),type:V.string().array().nonempty(),alignment:Y0.array().optional(),description:V.string().optional(),level:V.string().optional(),name:V.string(),points:V.string().optional()}).catchall(V.any()),SH=V.object({id:V.string(),type:V.string().array().nonempty(),alignment:Y0.array().optional(),allowedValue:V.string().array().optional(),name:V.string(),requiredLevel:V.string().optional(),requiredValue:V.string().optional(),resultType:EH,rubricCriterionLevel:AH.array().optional(),valueMax:V.string().optional(),valueMin:V.string().optional()}).catchall(V.any()),MH=V.object({id:V.string().optional(),type:V.string().array().nonempty(),alignment:Y0.array().optional(),achievementType:vH.optional(),creator:Tl.optional(),creditsAvailable:V.number().optional(),criteria:yH,description:V.string(),endorsement:wH.array().optional(),fieldOfStudy:V.string().optional(),humanCode:V.string().optional(),image:J0.optional(),"@language":V.string().optional(),name:V.string(),otherIdentifier:C9.array().optional(),related:_H.array().optional(),resultDescription:SH.array().optional(),specialization:V.string().optional(),tag:V.string().array().optional(),version:V.string().optional()}).catchall(V.any()),TH=V.object({type:V.string(),hashed:V.boolean(),identityHash:V.string(),identityType:V.string(),salt:V.string().optional()}),CH=V.enum(["Completed","Enrolled","Failed","InProgress","OnHold","Withdrew"]),kH=V.object({type:V.string().array().nonempty(),achievedLevel:V.string().optional(),alignment:Y0.array().optional(),resultDescription:V.string().optional(),status:CH.optional(),value:V.string().optional()}).catchall(V.any()),M9=V.object({id:V.string().optional(),type:V.string().array().nonempty(),activityEndDate:V.string().optional(),activityStartDate:V.string().optional(),creditsEarned:V.number().optional(),achievement:MH.optional(),identifier:TH.array().optional(),image:J0.optional(),licenseNumber:V.string().optional(),narrative:V.string().optional(),result:kH.array().optional(),role:V.string().optional(),source:Tl.optional(),term:V.string().optional()}).catchall(V.any()),IH=V.object({id:V.string().optional(),type:V.string().array().nonempty(),narrative:V.string().optional(),name:V.string().optional(),description:V.string().optional(),genre:V.string().optional(),audience:V.string().optional()}).catchall(V.any()),DH=W0.extend({name:V.string().optional(),description:V.string().optional(),image:J0.optional(),credentialSubject:M9.or(M9.array()),endorsement:W0.array().optional(),evidence:IH.array().optional()}),zte=DH.extend({proof:la.or(la.array())}),jte=V.object({checks:V.string().array(),warnings:V.string().array(),errors:V.string().array()}),k9=V.enum(["Success","Failed","Error"]),Gte=k9.enum,Vte=V.object({check:V.string(),status:k9,message:V.string().optional(),details:V.string().optional()}),Wte=V.object({title:V.string().optional(),createdAt:V.string().optional(),issuer:Tl.optional(),issuee:Tl.optional(),credentialSubject:Yg.optional()}),Jte=V.object({id:V.string(),uri:V.string()}).catchall(V.any()),Zte=V.object({limit:V.number(),cursor:V.string().optional()}),I9=V.object({cursor:V.string().optional(),hasMore:V.boolean()}),OH=V.object({kty:V.string(),crv:V.string(),x:V.string(),y:V.string().optional(),n:V.string().optional(),d:V.string()}),RH=V.object({alg:V.string(),iv:V.string(),tag:V.string(),epk:OH.partial().optional(),kid:V.string().optional(),apv:V.string().optional(),apu:V.string().optional()}),NH=V.object({header:RH,encrypted_key:V.string()}),PH=V.object({protected:V.string(),iv:V.string(),ciphertext:V.string(),tag:V.string(),aad:V.string().optional(),recipients:NH.array().optional()}),D9=V.object({encryptedRecord:PH,fields:V.string().array()}).catchall(V.any()),ere=I9.extend({records:D9.array()}),LH=D9.extend({id:V.string()}),tre=I9.extend({records:LH.array()}),Xg=V.object({profileId:V.string().min(3).max(40),displayName:V.string().default(""),did:V.string(),email:V.string().optional(),image:V.string().optional(),isServiceProfile:V.boolean().default(!1).optional(),notificationsWebhook:V.string().url().startsWith("https://").optional()}),nre=V.enum(["CONNECTED","PENDING_REQUEST_SENT","PENDING_REQUEST_RECEIVED","NOT_CONNECTED"]),ire=V.object({uri:V.string(),to:V.string(),from:V.string(),sent:V.string().datetime(),received:V.string().datetime().optional()}),BH=V.enum(["DRAFT","LIVE"]),ore=V.object({uri:V.string(),name:V.string().optional(),type:V.string().optional(),category:V.string().optional(),status:BH.optional()}),sre=V.object({to:Xg,from:V.string(),received:V.string().optional()}),UH=V.enum(["CONNECTION_REQUEST","CONNECTION_ACCEPTED","CREDENTIAL_RECEIVED","CREDENTIAL_ACCEPTED","BOOST_RECEIVED","BOOST_ACCEPTED","PRESENTATION_REQUEST","PRESENTATION_RECEIVED"]),$H=V.object({title:V.string().optional(),body:V.string().optional()}),FH=V.object({vcUris:V.array(V.string()).optional(),vpUris:V.array(V.string()).optional()}),are=V.object({type:UH,to:Xg.partial().and(V.object({did:V.string()})),from:Xg.partial().and(V.object({did:V.string()})),message:$H.optional(),data:FH.optional(),sent:V.string().datetime().optional()}),fre=V.object({endpoint:V.string(),name:V.string(),did:V.string().optional()}),cre=V.object({ttlSeconds:V.number().optional(),totalUses:V.number().optional()}),qH=V.object({endpoint:V.string()}),ure=V.object({signingAuthority:qH,relationship:V.object({name:V.string().max(15).regex(/^[a-z0-9-]+$/,{message:"The input string must contain only lowercase letters, numbers, and hyphens."}),did:V.string()})});var X0=o(t=>`lc:ceramic:${t}`,"streamIdToCeramicURI");var Qg=V.string().refine(t=>t.split(":").length===3&&t.split(":")[0]==="lc","URI must be of the form lc:${storage}:${url}").refine(t=>t.split(":")[1]==="ceramic","URI must use storage type ceramic (i.e. must be lc:ceramic:${streamID})");var Z0=o(async(t,{ceramicEndpoint:e,defaultContentFamily:r})=>{let n=new Al(e),i=o(async(R,D,P,J)=>t.invoke.didResolver(R,J),"learnCardResolver"),a={...m8.getResolver(),web:i},c=new Va({resolver:a});n.did=c;let u=t.invoke.getKey(),m=new Qu(Z5(u));n.did.setProvider(m),await n.did.authenticate();let v=new gl({ceramic:n}),x=o(async(R,D={},P={},J)=>{if(!R)throw new Error("content is required");if(D.controllers||(D.controllers=[n.did.id]),D.family||(D.family=r),"pin"in P||(P.pin=!0),J?.encrypt){t.debug?.("learnCard.store.Ceramic.upload.publishContentToCeramic - encrypt enabled",J);let W=J?.recipients||[];J?.controllersCanDecrypt&&(W=[...W,...D.controllers]),R=await n?.did?.createDagJWE(R,O9.default.uniq(W))}return t.debug?.("learnCard.store.Ceramic.upload.publishContentToCeramic - content to upload",R,D,P),(await Gn.create(n,R,D,P)).id.toString()},"publishContentToCeramic"),S=o(async R=>{let D=(await v.load(R))?.content;if(t.debug?.("learnCard.read.get.readContentFromCeramic",D),D?.ciphertext)try{return await c.decryptDagJWE(D)}catch(P){throw t.debug?.("learnCard.read.get.readContentFromCeramic - Could not decrypt credential - DID not authorized.",P),new Error("Could not decrypt credential - DID not authorized.")}return D},"readContentFromCeramic"),O=o(async(R,D)=>(await Cl.or(Zg).parseAsync(R),X0(await x(R,{},{},D))),"uploadCredential");return{name:"Ceramic",displayName:"Ceramic",description:"Uploads/resolves credentials using the Ceramic Network (https://ceramic.network/)",store:{upload:async(R,D)=>(R.debug?.("learnCard.store.Ceramic.upload"),O(D)),uploadEncrypted:async(R,D,P)=>(R.debug?.("learnCard.store.Ceramic.uploadEncrypted"),O(D,{encrypt:!0,controllersCanDecrypt:!0,...P?{recipients:P.recipients}:{}}))},read:{get:async(R,D)=>{if(R.debug?.("learnCard.read.Ceramic.get"),!D)return;let P=await Qg.spa(D);if(!P.success)return;let J=P.data.split(":")[2];try{return await Cl.or(Zg).parseAsync(await S(J))}catch(L){R.debug?.(L);return}}},methods:{publishContentToCeramic:async(R,D,P)=>X0(await x(D,{},{},P)),readContentFromCeramic:async(R,D)=>S(D),getCeramicClient:()=>n,getDIDObject:()=>n.did}}},"getCeramicPlugin");var HH=Z0;
|
|
818
818
|
/*!
|
|
819
819
|
* https://github.com/Starcounter-Jack/JSON-Patch
|
|
820
820
|
* (c) 2017-2021 Joachim Wester
|