@learncard/ceramic-plugin 1.0.53 → 1.0.54
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 +5 -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 +5 -3
- package/dist/ceramic-plugin.esm.js.map +2 -2
- package/package.json +4 -4
|
@@ -819,7 +819,7 @@ HEXDIG = DIGIT / "A" / "B" / "C" / "D" / "E" / "F"
|
|
|
819
819
|
`;function lg(r){return typeof r=="string"&&(r=El(r)),Uc(sg([El(H8),El(String(r.length)),r]))}o(lg,"hashMessage");var vt=Ft(fg()),ko=Ft(Vu());function $c(r,e,t){return t={path:e,exports:{},require:function(n,i){return PU(n,i??t.path)}},r(t,t.exports),t.exports}o($c,"createCommonjsModule");function PU(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}o(PU,"commonjsRequire");var mg=K8;function K8(r,e){if(!r)throw new Error(e||"Assertion failed")}o(K8,"assert");K8.equal=o(function(e,t,n){if(e!=t)throw new Error(n||"Assertion failed: "+e+" != "+t)},"assertEqual");var eo=$c(function(r,e){"use strict";var t=e;function n(f,u){if(Array.isArray(f))return f.slice();if(!f)return[];var d=[];if(typeof f!="string"){for(var y=0;y<f.length;y++)d[y]=f[y]|0;return d}if(u==="hex"){f=f.replace(/[^a-z0-9]+/ig,""),f.length%2!==0&&(f="0"+f);for(var y=0;y<f.length;y+=2)d.push(parseInt(f[y]+f[y+1],16))}else for(var y=0;y<f.length;y++){var w=f.charCodeAt(y),A=w>>8,O=w&255;A?d.push(A,O):d.push(O)}return d}o(n,"toArray"),t.toArray=n;function i(f){return f.length===1?"0"+f:f}o(i,"zero2"),t.zero2=i;function s(f){for(var u="",d=0;d<f.length;d++)u+=i(f[d].toString(16));return u}o(s,"toHex"),t.toHex=s,t.encode=o(function(u,d){return d==="hex"?s(u):u},"encode")}),Yn=$c(function(r,e){"use strict";var t=e;t.assert=mg,t.toArray=eo.toArray,t.zero2=eo.zero2,t.toHex=eo.toHex,t.encode=eo.encode;function n(d,y,w){var A=new Array(Math.max(d.bitLength(),w)+1),O;for(O=0;O<A.length;O+=1)A[O]=0;var R=1<<y+1,I=d.clone();for(O=0;O<A.length;O++){var B,Y=I.andln(R-1);I.isOdd()?(Y>(R>>1)-1?B=(R>>1)-Y:B=Y,I.isubn(B)):B=0,A[O]=B,I.iushrn(1)}return A}o(n,"getNAF"),t.getNAF=n;function i(d,y){var w=[[],[]];d=d.clone(),y=y.clone();for(var A=0,O=0,R;d.cmpn(-A)>0||y.cmpn(-O)>0;){var I=d.andln(3)+A&3,B=y.andln(3)+O&3;I===3&&(I=-1),B===3&&(B=-1);var Y;(I&1)===0?Y=0:(R=d.andln(7)+A&7,(R===3||R===5)&&B===2?Y=-I:Y=I),w[0].push(Y);var P;(B&1)===0?P=0:(R=y.andln(7)+O&7,(R===3||R===5)&&I===2?P=-B:P=B),w[1].push(P),2*A===Y+1&&(A=1-A),2*O===P+1&&(O=1-O),d.iushrn(1),y.iushrn(1)}return w}o(i,"getJSF"),t.getJSF=i;function s(d,y,w){var A="_"+y;d.prototype[y]=o(function(){return this[A]!==void 0?this[A]:this[A]=w.call(this)},"cachedProperty")}o(s,"cachedProperty"),t.cachedProperty=s;function f(d){return typeof d=="string"?t.toArray(d,"hex"):d}o(f,"parseBytes"),t.parseBytes=f;function u(d){return new vt.default(d,"hex","le")}o(u,"intFromLE"),t.intFromLE=u}),x0=Yn.getNAF,BU=Yn.getJSF,w0=Yn.assert;function sa(r,e){this.type=r,this.p=new vt.default(e.p,16),this.red=e.prime?vt.default.red(e.prime):vt.default.mont(this.p),this.zero=new vt.default(0).toRed(this.red),this.one=new vt.default(1).toRed(this.red),this.two=new vt.default(2).toRed(this.red),this.n=e.n&&new vt.default(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var t=this.n&&this.p.div(this.n);!t||t.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}o(sa,"BaseCurve");var lf=sa;sa.prototype.point=o(function(){throw new Error("Not implemented")},"point");sa.prototype.validate=o(function(){throw new Error("Not implemented")},"validate");sa.prototype._fixedNafMul=o(function(e,t){w0(e.precomputed);var n=e._getDoubles(),i=x0(t,1,this._bitLength),s=(1<<n.step+1)-(n.step%2===0?2:1);s/=3;var f=[],u,d;for(u=0;u<i.length;u+=n.step){d=0;for(var y=u+n.step-1;y>=u;y--)d=(d<<1)+i[y];f.push(d)}for(var w=this.jpoint(null,null,null),A=this.jpoint(null,null,null),O=s;O>0;O--){for(u=0;u<f.length;u++)d=f[u],d===O?A=A.mixedAdd(n.points[u]):d===-O&&(A=A.mixedAdd(n.points[u].neg()));w=w.add(A)}return w.toP()},"_fixedNafMul");sa.prototype._wnafMul=o(function(e,t){var n=4,i=e._getNAFPoints(n);n=i.wnd;for(var s=i.points,f=x0(t,n,this._bitLength),u=this.jpoint(null,null,null),d=f.length-1;d>=0;d--){for(var y=0;d>=0&&f[d]===0;d--)y++;if(d>=0&&y++,u=u.dblp(y),d<0)break;var w=f[d];w0(w!==0),e.type==="affine"?w>0?u=u.mixedAdd(s[w-1>>1]):u=u.mixedAdd(s[-w-1>>1].neg()):w>0?u=u.add(s[w-1>>1]):u=u.add(s[-w-1>>1].neg())}return e.type==="affine"?u.toP():u},"_wnafMul");sa.prototype._wnafMulAdd=o(function(e,t,n,i,s){var f=this._wnafT1,u=this._wnafT2,d=this._wnafT3,y=0,w,A,O;for(w=0;w<i;w++){O=t[w];var R=O._getNAFPoints(e);f[w]=R.wnd,u[w]=R.points}for(w=i-1;w>=1;w-=2){var I=w-1,B=w;if(f[I]!==1||f[B]!==1){d[I]=x0(n[I],f[I],this._bitLength),d[B]=x0(n[B],f[B],this._bitLength),y=Math.max(d[I].length,y),y=Math.max(d[B].length,y);continue}var Y=[t[I],null,null,t[B]];t[I].y.cmp(t[B].y)===0?(Y[1]=t[I].add(t[B]),Y[2]=t[I].toJ().mixedAdd(t[B].neg())):t[I].y.cmp(t[B].y.redNeg())===0?(Y[1]=t[I].toJ().mixedAdd(t[B]),Y[2]=t[I].add(t[B].neg())):(Y[1]=t[I].toJ().mixedAdd(t[B]),Y[2]=t[I].toJ().mixedAdd(t[B].neg()));var P=[-3,-1,-5,-7,0,7,5,1,3],J=BU(n[I],n[B]);for(y=Math.max(J[0].length,y),d[I]=new Array(y),d[B]=new Array(y),A=0;A<y;A++){var ee=J[0][A]|0,Z=J[1][A]|0;d[I][A]=P[(ee+1)*3+(Z+1)],d[B][A]=0,u[I]=Y}}var ne=this.jpoint(null,null,null),V=this._wnafT4;for(w=y;w>=0;w--){for(var j=0;w>=0;){var H=!0;for(A=0;A<i;A++)V[A]=d[A][w]|0,V[A]!==0&&(H=!1);if(!H)break;j++,w--}if(w>=0&&j++,ne=ne.dblp(j),w<0)break;for(A=0;A<i;A++){var he=V[A];he!==0&&(he>0?O=u[A][he-1>>1]:he<0&&(O=u[A][-he-1>>1].neg()),O.type==="affine"?ne=ne.mixedAdd(O):ne=ne.add(O))}}for(w=0;w<i;w++)u[w]=null;return s?ne:ne.toP()},"_wnafMulAdd");function Ii(r,e){this.curve=r,this.type=e,this.precomputed=null}o(Ii,"BasePoint");sa.BasePoint=Ii;Ii.prototype.eq=o(function(){throw new Error("Not implemented")},"eq");Ii.prototype.validate=o(function(){return this.curve.validate(this)},"validate");sa.prototype.decodePoint=o(function(e,t){e=Yn.toArray(e,t);var n=this.p.byteLength();if((e[0]===4||e[0]===6||e[0]===7)&&e.length-1===2*n){e[0]===6?w0(e[e.length-1]%2===0):e[0]===7&&w0(e[e.length-1]%2===1);var i=this.point(e.slice(1,1+n),e.slice(1+n,1+2*n));return i}else if((e[0]===2||e[0]===3)&&e.length-1===n)return this.pointFromX(e.slice(1,1+n),e[0]===3);throw new Error("Unknown point format")},"decodePoint");Ii.prototype.encodeCompressed=o(function(e){return this.encode(e,!0)},"encodeCompressed");Ii.prototype._encode=o(function(e){var t=this.curve.p.byteLength(),n=this.getX().toArray("be",t);return e?[this.getY().isEven()?2:3].concat(n):[4].concat(n,this.getY().toArray("be",t))},"_encode");Ii.prototype.encode=o(function(e,t){return Yn.encode(this._encode(t),e)},"encode");Ii.prototype.precompute=o(function(e){if(this.precomputed)return this;var t={doubles:null,naf:null,beta:null};return t.naf=this._getNAFPoints(8),t.doubles=this._getDoubles(4,e),t.beta=this._getBeta(),this.precomputed=t,this},"precompute");Ii.prototype._hasDoubles=o(function(e){if(!this.precomputed)return!1;var t=this.precomputed.doubles;return t?t.points.length>=Math.ceil((e.bitLength()+1)/t.step):!1},"_hasDoubles");Ii.prototype._getDoubles=o(function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var n=[this],i=this,s=0;s<t;s+=e){for(var f=0;f<e;f++)i=i.dbl();n.push(i)}return{step:e,points:n}},"_getDoubles");Ii.prototype._getNAFPoints=o(function(e){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var t=[this],n=(1<<e)-1,i=n===1?null:this.dbl(),s=1;s<n;s++)t[s]=t[s-1].add(i);return{wnd:e,points:t}},"_getNAFPoints");Ii.prototype._getBeta=o(function(){return null},"_getBeta");Ii.prototype.dblp=o(function(e){for(var t=this,n=0;n<e;n++)t=t.dbl();return t},"dblp");var bg=$c(function(r){typeof Object.create=="function"?r.exports=o(function(t,n){n&&(t.super_=n,t.prototype=Object.create(n.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))},"inherits"):r.exports=o(function(t,n){if(n){t.super_=n;var i=o(function(){},"TempCtor");i.prototype=n.prototype,t.prototype=new i,t.prototype.constructor=t}},"inherits")}),LU=Yn.assert;function Di(r){lf.call(this,"short",r),this.a=new vt.default(r.a,16).toRed(this.red),this.b=new vt.default(r.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(r),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}o(Di,"ShortCurve");bg(Di,lf);var UU=Di;Di.prototype._getEndomorphism=o(function(e){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var t,n;if(e.beta)t=new vt.default(e.beta,16).toRed(this.red);else{var i=this._getEndoRoots(this.p);t=i[0].cmp(i[1])<0?i[0]:i[1],t=t.toRed(this.red)}if(e.lambda)n=new vt.default(e.lambda,16);else{var s=this._getEndoRoots(this.n);this.g.mul(s[0]).x.cmp(this.g.x.redMul(t))===0?n=s[0]:(n=s[1],LU(this.g.mul(n).x.cmp(this.g.x.redMul(t))===0))}var f;return e.basis?f=e.basis.map(function(u){return{a:new vt.default(u.a,16),b:new vt.default(u.b,16)}}):f=this._getEndoBasis(n),{beta:t,lambda:n,basis:f}}},"_getEndomorphism");Di.prototype._getEndoRoots=o(function(e){var t=e===this.p?this.red:vt.default.mont(e),n=new vt.default(2).toRed(t).redInvm(),i=n.redNeg(),s=new vt.default(3).toRed(t).redNeg().redSqrt().redMul(n),f=i.redAdd(s).fromRed(),u=i.redSub(s).fromRed();return[f,u]},"_getEndoRoots");Di.prototype._getEndoBasis=o(function(e){for(var t=this.n.ushrn(Math.floor(this.n.bitLength()/2)),n=e,i=this.n.clone(),s=new vt.default(1),f=new vt.default(0),u=new vt.default(0),d=new vt.default(1),y,w,A,O,R,I,B,Y=0,P,J;n.cmpn(0)!==0;){var ee=i.div(n);P=i.sub(ee.mul(n)),J=u.sub(ee.mul(s));var Z=d.sub(ee.mul(f));if(!A&&P.cmp(t)<0)y=B.neg(),w=s,A=P.neg(),O=J;else if(A&&++Y===2)break;B=P,i=n,n=P,u=s,s=J,d=f,f=Z}R=P.neg(),I=J;var ne=A.sqr().add(O.sqr()),V=R.sqr().add(I.sqr());return V.cmp(ne)>=0&&(R=y,I=w),A.negative&&(A=A.neg(),O=O.neg()),R.negative&&(R=R.neg(),I=I.neg()),[{a:A,b:O},{a:R,b:I}]},"_getEndoBasis");Di.prototype._endoSplit=o(function(e){var t=this.endo.basis,n=t[0],i=t[1],s=i.b.mul(e).divRound(this.n),f=n.b.neg().mul(e).divRound(this.n),u=s.mul(n.a),d=f.mul(i.a),y=s.mul(n.b),w=f.mul(i.b),A=e.sub(u).sub(d),O=y.add(w).neg();return{k1:A,k2:O}},"_endoSplit");Di.prototype.pointFromX=o(function(e,t){e=new vt.default(e,16),e.red||(e=e.toRed(this.red));var n=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),i=n.redSqrt();if(i.redSqr().redSub(n).cmp(this.zero)!==0)throw new Error("invalid point");var s=i.fromRed().isOdd();return(t&&!s||!t&&s)&&(i=i.redNeg()),this.point(e,i)},"pointFromX");Di.prototype.validate=o(function(e){if(e.inf)return!0;var t=e.x,n=e.y,i=this.a.redMul(t),s=t.redSqr().redMul(t).redIAdd(i).redIAdd(this.b);return n.redSqr().redISub(s).cmpn(0)===0},"validate");Di.prototype._endoWnafMulAdd=o(function(e,t,n){for(var i=this._endoWnafT1,s=this._endoWnafT2,f=0;f<e.length;f++){var u=this._endoSplit(t[f]),d=e[f],y=d._getBeta();u.k1.negative&&(u.k1.ineg(),d=d.neg(!0)),u.k2.negative&&(u.k2.ineg(),y=y.neg(!0)),i[f*2]=d,i[f*2+1]=y,s[f*2]=u.k1,s[f*2+1]=u.k2}for(var w=this._wnafMulAdd(1,i,s,f*2,n),A=0;A<f*2;A++)i[A]=null,s[A]=null;return w},"_endoWnafMulAdd");function Br(r,e,t,n){lf.BasePoint.call(this,r,"affine"),e===null&&t===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new vt.default(e,16),this.y=new vt.default(t,16),n&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}o(Br,"Point");bg(Br,lf.BasePoint);Di.prototype.point=o(function(e,t,n){return new Br(this,e,t,n)},"point");Di.prototype.pointFromJSON=o(function(e,t){return Br.fromJSON(this,e,t)},"pointFromJSON");Br.prototype._getBeta=o(function(){if(!!this.curve.endo){var e=this.precomputed;if(e&&e.beta)return e.beta;var t=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(e){var n=this.curve,i=o(function(s){return n.point(s.x.redMul(n.endo.beta),s.y)},"endoMul");e.beta=t,t.precomputed={beta:null,naf:e.naf&&{wnd:e.naf.wnd,points:e.naf.points.map(i)},doubles:e.doubles&&{step:e.doubles.step,points:e.doubles.points.map(i)}}}return t}},"_getBeta");Br.prototype.toJSON=o(function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},"toJSON");Br.fromJSON=o(function(e,t,n){typeof t=="string"&&(t=JSON.parse(t));var i=e.point(t[0],t[1],n);if(!t[2])return i;function s(u){return e.point(u[0],u[1],n)}o(s,"obj2point");var f=t[2];return i.precomputed={beta:null,doubles:f.doubles&&{step:f.doubles.step,points:[i].concat(f.doubles.points.map(s))},naf:f.naf&&{wnd:f.naf.wnd,points:[i].concat(f.naf.points.map(s))}},i},"fromJSON");Br.prototype.inspect=o(function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},"inspect");Br.prototype.isInfinity=o(function(){return this.inf},"isInfinity");Br.prototype.add=o(function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var t=this.y.redSub(e.y);t.cmpn(0)!==0&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var n=t.redSqr().redISub(this.x).redISub(e.x),i=t.redMul(this.x.redSub(n)).redISub(this.y);return this.curve.point(n,i)},"add");Br.prototype.dbl=o(function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var t=this.curve.a,n=this.x.redSqr(),i=e.redInvm(),s=n.redAdd(n).redIAdd(n).redIAdd(t).redMul(i),f=s.redSqr().redISub(this.x.redAdd(this.x)),u=s.redMul(this.x.redSub(f)).redISub(this.y);return this.curve.point(f,u)},"dbl");Br.prototype.getX=o(function(){return this.x.fromRed()},"getX");Br.prototype.getY=o(function(){return this.y.fromRed()},"getY");Br.prototype.mul=o(function(e){return e=new vt.default(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},"mul");Br.prototype.mulAdd=o(function(e,t,n){var i=[this,t],s=[e,n];return this.curve.endo?this.curve._endoWnafMulAdd(i,s):this.curve._wnafMulAdd(1,i,s,2)},"mulAdd");Br.prototype.jmulAdd=o(function(e,t,n){var i=[this,t],s=[e,n];return this.curve.endo?this.curve._endoWnafMulAdd(i,s,!0):this.curve._wnafMulAdd(1,i,s,2,!0)},"jmulAdd");Br.prototype.eq=o(function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)},"eq");Br.prototype.neg=o(function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var n=this.precomputed,i=o(function(s){return s.neg()},"negate");t.precomputed={naf:n.naf&&{wnd:n.naf.wnd,points:n.naf.points.map(i)},doubles:n.doubles&&{step:n.doubles.step,points:n.doubles.points.map(i)}}}return t},"neg");Br.prototype.toJ=o(function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e},"toJ");function zr(r,e,t,n){lf.BasePoint.call(this,r,"jacobian"),e===null&&t===null&&n===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new vt.default(0)):(this.x=new vt.default(e,16),this.y=new vt.default(t,16),this.z=new vt.default(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}o(zr,"JPoint");bg(zr,lf.BasePoint);Di.prototype.jpoint=o(function(e,t,n){return new zr(this,e,t,n)},"jpoint");zr.prototype.toP=o(function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),n=this.x.redMul(t),i=this.y.redMul(t).redMul(e);return this.curve.point(n,i)},"toP");zr.prototype.neg=o(function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},"neg");zr.prototype.add=o(function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),n=this.z.redSqr(),i=this.x.redMul(t),s=e.x.redMul(n),f=this.y.redMul(t.redMul(e.z)),u=e.y.redMul(n.redMul(this.z)),d=i.redSub(s),y=f.redSub(u);if(d.cmpn(0)===0)return y.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var w=d.redSqr(),A=w.redMul(d),O=i.redMul(w),R=y.redSqr().redIAdd(A).redISub(O).redISub(O),I=y.redMul(O.redISub(R)).redISub(f.redMul(A)),B=this.z.redMul(e.z).redMul(d);return this.curve.jpoint(R,I,B)},"add");zr.prototype.mixedAdd=o(function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),n=this.x,i=e.x.redMul(t),s=this.y,f=e.y.redMul(t).redMul(this.z),u=n.redSub(i),d=s.redSub(f);if(u.cmpn(0)===0)return d.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var y=u.redSqr(),w=y.redMul(u),A=n.redMul(y),O=d.redSqr().redIAdd(w).redISub(A).redISub(A),R=d.redMul(A.redISub(O)).redISub(s.redMul(w)),I=this.z.redMul(u);return this.curve.jpoint(O,R,I)},"mixedAdd");zr.prototype.dblp=o(function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var n=this;for(t=0;t<e;t++)n=n.dbl();return n}var i=this.curve.a,s=this.curve.tinv,f=this.x,u=this.y,d=this.z,y=d.redSqr().redSqr(),w=u.redAdd(u);for(t=0;t<e;t++){var A=f.redSqr(),O=w.redSqr(),R=O.redSqr(),I=A.redAdd(A).redIAdd(A).redIAdd(i.redMul(y)),B=f.redMul(O),Y=I.redSqr().redISub(B.redAdd(B)),P=B.redISub(Y),J=I.redMul(P);J=J.redIAdd(J).redISub(R);var ee=w.redMul(d);t+1<e&&(y=y.redMul(R)),f=Y,d=ee,w=J}return this.curve.jpoint(f,w.redMul(s),d)},"dblp");zr.prototype.dbl=o(function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},"dbl");zr.prototype._zeroDbl=o(function(){var e,t,n;if(this.zOne){var i=this.x.redSqr(),s=this.y.redSqr(),f=s.redSqr(),u=this.x.redAdd(s).redSqr().redISub(i).redISub(f);u=u.redIAdd(u);var d=i.redAdd(i).redIAdd(i),y=d.redSqr().redISub(u).redISub(u),w=f.redIAdd(f);w=w.redIAdd(w),w=w.redIAdd(w),e=y,t=d.redMul(u.redISub(y)).redISub(w),n=this.y.redAdd(this.y)}else{var A=this.x.redSqr(),O=this.y.redSqr(),R=O.redSqr(),I=this.x.redAdd(O).redSqr().redISub(A).redISub(R);I=I.redIAdd(I);var B=A.redAdd(A).redIAdd(A),Y=B.redSqr(),P=R.redIAdd(R);P=P.redIAdd(P),P=P.redIAdd(P),e=Y.redISub(I).redISub(I),t=B.redMul(I.redISub(e)).redISub(P),n=this.y.redMul(this.z),n=n.redIAdd(n)}return this.curve.jpoint(e,t,n)},"_zeroDbl");zr.prototype._threeDbl=o(function(){var e,t,n;if(this.zOne){var i=this.x.redSqr(),s=this.y.redSqr(),f=s.redSqr(),u=this.x.redAdd(s).redSqr().redISub(i).redISub(f);u=u.redIAdd(u);var d=i.redAdd(i).redIAdd(i).redIAdd(this.curve.a),y=d.redSqr().redISub(u).redISub(u);e=y;var w=f.redIAdd(f);w=w.redIAdd(w),w=w.redIAdd(w),t=d.redMul(u.redISub(y)).redISub(w),n=this.y.redAdd(this.y)}else{var A=this.z.redSqr(),O=this.y.redSqr(),R=this.x.redMul(O),I=this.x.redSub(A).redMul(this.x.redAdd(A));I=I.redAdd(I).redIAdd(I);var B=R.redIAdd(R);B=B.redIAdd(B);var Y=B.redAdd(B);e=I.redSqr().redISub(Y),n=this.y.redAdd(this.z).redSqr().redISub(O).redISub(A);var P=O.redSqr();P=P.redIAdd(P),P=P.redIAdd(P),P=P.redIAdd(P),t=I.redMul(B.redISub(e)).redISub(P)}return this.curve.jpoint(e,t,n)},"_threeDbl");zr.prototype._dbl=o(function(){var e=this.curve.a,t=this.x,n=this.y,i=this.z,s=i.redSqr().redSqr(),f=t.redSqr(),u=n.redSqr(),d=f.redAdd(f).redIAdd(f).redIAdd(e.redMul(s)),y=t.redAdd(t);y=y.redIAdd(y);var w=y.redMul(u),A=d.redSqr().redISub(w.redAdd(w)),O=w.redISub(A),R=u.redSqr();R=R.redIAdd(R),R=R.redIAdd(R),R=R.redIAdd(R);var I=d.redMul(O).redISub(R),B=n.redAdd(n).redMul(i);return this.curve.jpoint(A,I,B)},"_dbl");zr.prototype.trpl=o(function(){if(!this.curve.zeroA)return this.dbl().add(this);var e=this.x.redSqr(),t=this.y.redSqr(),n=this.z.redSqr(),i=t.redSqr(),s=e.redAdd(e).redIAdd(e),f=s.redSqr(),u=this.x.redAdd(t).redSqr().redISub(e).redISub(i);u=u.redIAdd(u),u=u.redAdd(u).redIAdd(u),u=u.redISub(f);var d=u.redSqr(),y=i.redIAdd(i);y=y.redIAdd(y),y=y.redIAdd(y),y=y.redIAdd(y);var w=s.redIAdd(u).redSqr().redISub(f).redISub(d).redISub(y),A=t.redMul(w);A=A.redIAdd(A),A=A.redIAdd(A);var O=this.x.redMul(d).redISub(A);O=O.redIAdd(O),O=O.redIAdd(O);var R=this.y.redMul(w.redMul(y.redISub(w)).redISub(u.redMul(d)));R=R.redIAdd(R),R=R.redIAdd(R),R=R.redIAdd(R);var I=this.z.redAdd(u).redSqr().redISub(n).redISub(d);return this.curve.jpoint(O,R,I)},"trpl");zr.prototype.mul=o(function(e,t){return e=new vt.default(e,t),this.curve._wnafMul(this,e)},"mul");zr.prototype.eq=o(function(e){if(e.type==="affine")return this.eq(e.toJ());if(this===e)return!0;var t=this.z.redSqr(),n=e.z.redSqr();if(this.x.redMul(n).redISub(e.x.redMul(t)).cmpn(0)!==0)return!1;var i=t.redMul(this.z),s=n.redMul(e.z);return this.y.redMul(s).redISub(e.y.redMul(i)).cmpn(0)===0},"eq");zr.prototype.eqXToP=o(function(e){var t=this.z.redSqr(),n=e.toRed(this.curve.red).redMul(t);if(this.x.cmp(n)===0)return!0;for(var i=e.clone(),s=this.curve.redN.redMul(t);;){if(i.iadd(this.curve.n),i.cmp(this.curve.p)>=0)return!1;if(n.redIAdd(s),this.x.cmp(n)===0)return!0}},"eqXToP");zr.prototype.inspect=o(function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},"inspect");zr.prototype.isInfinity=o(function(){return this.z.cmpn(0)===0},"isInfinity");var v0=$c(function(r,e){"use strict";var t=e;t.base=lf,t.short=UU,t.mont=null,t.edwards=null}),y0=$c(function(r,e){"use strict";var t=e,n=Yn.assert;function i(u){u.type==="short"?this.curve=new v0.short(u):u.type==="edwards"?this.curve=new v0.edwards(u):this.curve=new v0.mont(u),this.g=this.curve.g,this.n=this.curve.n,this.hash=u.hash,n(this.g.validate(),"Invalid curve"),n(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}o(i,"PresetCurve"),t.PresetCurve=i;function s(u,d){Object.defineProperty(t,u,{configurable:!0,enumerable:!0,get:function(){var y=new i(d);return Object.defineProperty(t,u,{configurable:!0,enumerable:!0,value:y}),y}})}o(s,"defineCurve"),s("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:ko.default.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),s("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:ko.default.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),s("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:ko.default.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),s("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:ko.default.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),s("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:ko.default.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),s("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:ko.default.sha256,gRed:!1,g:["9"]}),s("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:ko.default.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var f;try{f=null.crash()}catch{f=void 0}s("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:ko.default.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",f]})});function oa(r){if(!(this instanceof oa))return new oa(r);this.hash=r.hash,this.predResist=!!r.predResist,this.outLen=this.hash.outSize,this.minEntropy=r.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=eo.toArray(r.entropy,r.entropyEnc||"hex"),t=eo.toArray(r.nonce,r.nonceEnc||"hex"),n=eo.toArray(r.pers,r.persEnc||"hex");mg(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,t,n)}o(oa,"HmacDRBG");var V8=oa;oa.prototype._init=o(function(e,t,n){var i=e.concat(t).concat(n);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var s=0;s<this.V.length;s++)this.K[s]=0,this.V[s]=1;this._update(i),this._reseed=1,this.reseedInterval=281474976710656},"init");oa.prototype._hmac=o(function(){return new ko.default.hmac(this.hash,this.K)},"hmac");oa.prototype._update=o(function(e){var t=this._hmac().update(this.V).update([0]);e&&(t=t.update(e)),this.K=t.digest(),this.V=this._hmac().update(this.V).digest(),e&&(this.K=this._hmac().update(this.V).update([1]).update(e).digest(),this.V=this._hmac().update(this.V).digest())},"update");oa.prototype.reseed=o(function(e,t,n,i){typeof t!="string"&&(i=n,n=t,t=null),e=eo.toArray(e,t),n=eo.toArray(n,i),mg(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(n||[])),this._reseed=1},"reseed");oa.prototype.generate=o(function(e,t,n,i){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof t!="string"&&(i=n,n=t,t=null),n&&(n=eo.toArray(n,i||"hex"),this._update(n));for(var s=[];s.length<e;)this.V=this._hmac().update(this.V).digest(),s=s.concat(this.V);var f=s.slice(0,e);return this._update(n),this._reseed++,eo.encode(f,t)},"generate");var pg=Yn.assert;function nn(r,e){this.ec=r,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}o(nn,"KeyPair");var gg=nn;nn.fromPublic=o(function(e,t,n){return t instanceof nn?t:new nn(e,{pub:t,pubEnc:n})},"fromPublic");nn.fromPrivate=o(function(e,t,n){return t instanceof nn?t:new nn(e,{priv:t,privEnc:n})},"fromPrivate");nn.prototype.validate=o(function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},"validate");nn.prototype.getPublic=o(function(e,t){return typeof e=="string"&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub},"getPublic");nn.prototype.getPrivate=o(function(e){return e==="hex"?this.priv.toString(16,2):this.priv},"getPrivate");nn.prototype._importPrivate=o(function(e,t){this.priv=new vt.default(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)},"_importPrivate");nn.prototype._importPublic=o(function(e,t){if(e.x||e.y){this.ec.curve.type==="mont"?pg(e.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&pg(e.x&&e.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(e.x,e.y);return}this.pub=this.ec.curve.decodePoint(e,t)},"_importPublic");nn.prototype.derive=o(function(e){return e.validate()||pg(e.validate(),"public point not validated"),e.mul(this.priv).getX()},"derive");nn.prototype.sign=o(function(e,t,n){return this.ec.sign(e,this,t,n)},"sign");nn.prototype.verify=o(function(e,t,n){return this.ec.verify(e,t,this,void 0,n)},"verify");nn.prototype.inspect=o(function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"},"inspect");var FU=Yn.assert;function _0(r,e){if(r instanceof _0)return r;this._importDER(r,e)||(FU(r.r&&r.s,"Signature without r or s"),this.r=new vt.default(r.r,16),this.s=new vt.default(r.s,16),r.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=r.recoveryParam)}o(_0,"Signature");var E0=_0;function $U(){this.place=0}o($U,"Position");function hg(r,e){var t=r[e.place++];if(!(t&128))return t;var n=t&15;if(n===0||n>4||r[e.place]===0)return!1;for(var i=0,s=0,f=e.place;s<n;s++,f++)i<<=8,i|=r[f],i>>>=0;return i<=127?!1:(e.place=f,i)}o(hg,"getLength");function z8(r){for(var e=0,t=r.length-1;!r[e]&&!(r[e+1]&128)&&e<t;)e++;return e===0?r:r.slice(e)}o(z8,"rmPadding");_0.prototype._importDER=o(function(e,t){e=Yn.toArray(e,t);var n=new $U;if(e[n.place++]!==48)return!1;var i=hg(e,n);if(i===!1||i+n.place!==e.length||e[n.place++]!==2)return!1;var s=hg(e,n);if(s===!1||(e[n.place]&128)!==0)return!1;var f=e.slice(n.place,s+n.place);if(n.place+=s,e[n.place++]!==2)return!1;var u=hg(e,n);if(u===!1||e.length!==u+n.place||(e[n.place]&128)!==0)return!1;var d=e.slice(n.place,u+n.place);if(f[0]===0)if(f[1]&128)f=f.slice(1);else return!1;if(d[0]===0)if(d[1]&128)d=d.slice(1);else return!1;return this.r=new vt.default(f),this.s=new vt.default(d),this.recoveryParam=null,!0},"_importDER");function dg(r,e){if(e<128){r.push(e);return}var t=1+(Math.log(e)/Math.LN2>>>3);for(r.push(t|128);--t;)r.push(e>>>(t<<3)&255);r.push(e)}o(dg,"constructLength");_0.prototype.toDER=o(function(e){var t=this.r.toArray(),n=this.s.toArray();for(t[0]&128&&(t=[0].concat(t)),n[0]&128&&(n=[0].concat(n)),t=z8(t),n=z8(n);!n[0]&&!(n[1]&128);)n=n.slice(1);var i=[2];dg(i,t.length),i=i.concat(t),i.push(2),dg(i,n.length);var s=i.concat(n),f=[48];return dg(f,s.length),f=f.concat(s),Yn.encode(f,e)},"toDER");var qU=o(function(){throw new Error("unsupported")},"rand"),uf=Yn.assert;function ki(r){if(!(this instanceof ki))return new ki(r);typeof r=="string"&&(uf(Object.prototype.hasOwnProperty.call(y0,r),"Unknown curve "+r),r=y0[r]),r instanceof y0.PresetCurve&&(r={curve:r}),this.curve=r.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=r.curve.g,this.g.precompute(r.curve.n.bitLength()+1),this.hash=r.hash||r.curve.hash}o(ki,"EC");var jU=ki;ki.prototype.keyPair=o(function(e){return new gg(this,e)},"keyPair");ki.prototype.keyFromPrivate=o(function(e,t){return gg.fromPrivate(this,e,t)},"keyFromPrivate");ki.prototype.keyFromPublic=o(function(e,t){return gg.fromPublic(this,e,t)},"keyFromPublic");ki.prototype.genKeyPair=o(function(e){e||(e={});for(var t=new V8({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||qU(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),n=this.n.byteLength(),i=this.n.sub(new vt.default(2));;){var s=new vt.default(t.generate(n));if(!(s.cmp(i)>0))return s.iaddn(1),this.keyFromPrivate(s)}},"genKeyPair");ki.prototype._truncateToN=o(function(e,t,n){var i;if(vt.default.isBN(e)||typeof e=="number")e=new vt.default(e,16),i=e.byteLength();else if(typeof e=="object")i=e.length,e=new vt.default(e,16);else{var s=e.toString();i=s.length+1>>>1,e=new vt.default(s,16)}typeof n!="number"&&(n=i*8);var f=n-this.n.bitLength();return f>0&&(e=e.ushrn(f)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},"_truncateToN");ki.prototype.sign=o(function(e,t,n,i){if(typeof n=="object"&&(i=n,n=null),i||(i={}),typeof e!="string"&&typeof e!="number"&&!vt.default.isBN(e)){uf(typeof e=="object"&&e&&typeof e.length=="number","Expected message to be an array-like, a hex string, or a BN instance"),uf(e.length>>>0===e.length);for(var s=0;s<e.length;s++)uf((e[s]&255)===e[s])}t=this.keyFromPrivate(t,n),e=this._truncateToN(e,!1,i.msgBitLength),uf(!e.isNeg(),"Can not sign a negative message");var f=this.n.byteLength(),u=t.getPrivate().toArray("be",f),d=e.toArray("be",f);uf(new vt.default(d).eq(e),"Can not sign message");for(var y=new V8({hash:this.hash,entropy:u,nonce:d,pers:i.pers,persEnc:i.persEnc||"utf8"}),w=this.n.sub(new vt.default(1)),A=0;;A++){var O=i.k?i.k(A):new vt.default(y.generate(this.n.byteLength()));if(O=this._truncateToN(O,!0),!(O.cmpn(1)<=0||O.cmp(w)>=0)){var R=this.g.mul(O);if(!R.isInfinity()){var I=R.getX(),B=I.umod(this.n);if(B.cmpn(0)!==0){var Y=O.invm(this.n).mul(B.mul(t.getPrivate()).iadd(e));if(Y=Y.umod(this.n),Y.cmpn(0)!==0){var P=(R.getY().isOdd()?1:0)|(I.cmp(B)!==0?2:0);return i.canonical&&Y.cmp(this.nh)>0&&(Y=this.n.sub(Y),P^=1),new E0({r:B,s:Y,recoveryParam:P})}}}}}},"sign");ki.prototype.verify=o(function(e,t,n,i,s){s||(s={}),e=this._truncateToN(e,!1,s.msgBitLength),n=this.keyFromPublic(n,i),t=new E0(t,"hex");var f=t.r,u=t.s;if(f.cmpn(1)<0||f.cmp(this.n)>=0||u.cmpn(1)<0||u.cmp(this.n)>=0)return!1;var d=u.invm(this.n),y=d.mul(e).umod(this.n),w=d.mul(f).umod(this.n),A;return this.curve._maxwellTrick?(A=this.g.jmulAdd(y,n.getPublic(),w),A.isInfinity()?!1:A.eqXToP(f)):(A=this.g.mulAdd(y,n.getPublic(),w),A.isInfinity()?!1:A.getX().umod(this.n).cmp(f)===0)},"verify");ki.prototype.recoverPubKey=function(r,e,t,n){uf((3&t)===t,"The recovery param is more than two bits"),e=new E0(e,n);var i=this.n,s=new vt.default(r),f=e.r,u=e.s,d=t&1,y=t>>1;if(f.cmp(this.curve.p.umod(this.curve.n))>=0&&y)throw new Error("Unable to find sencond key candinate");y?f=this.curve.pointFromX(f.add(this.curve.n),d):f=this.curve.pointFromX(f,d);var w=e.r.invm(i),A=i.sub(s).mul(w).umod(i),O=u.mul(w).umod(i);return this.g.mulAdd(A,f,O)};ki.prototype.getKeyRecoveryParam=function(r,e,t,n){if(e=new E0(e,n),e.recoveryParam!==null)return e.recoveryParam;for(var i=0;i<4;i++){var s;try{s=this.recoverPubKey(r,e,i)}catch{continue}if(s.eq(t))return i}throw new Error("Unable to find valid recovery factor")};var HU=$c(function(r,e){"use strict";var t=e;t.version="6.6.1",t.utils=Yn,t.rand=function(){throw new Error("unsupported")},t.curve=v0,t.curves=y0,t.ec=jU,t.eddsa=null}),G8=HU.ec;var W8="signing-key/5.8.0";var yg=new Tt(W8),vg=null;function Io(){return vg||(vg=new G8("secp256k1")),vg}o(Io,"getCurve");var A0=class{constructor(e){Fc(this,"curve","secp256k1"),Fc(this,"privateKey",rn(e)),m0(this.privateKey)!==32&&yg.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");let t=Io().keyFromPrivate(fr(this.privateKey));Fc(this,"publicKey","0x"+t.getPublic(!1,"hex")),Fc(this,"compressedPublicKey","0x"+t.getPublic(!0,"hex")),Fc(this,"_isSigningKey",!0)}_addPoint(e){let t=Io().keyFromPublic(fr(this.publicKey)),n=Io().keyFromPublic(fr(e));return"0x"+t.pub.add(n.pub).encodeCompressed("hex")}signDigest(e){let t=Io().keyFromPrivate(fr(this.privateKey)),n=fr(e);n.length!==32&&yg.throwArgumentError("bad digest length","digest",e);let i=t.sign(n,{canonical:!0});return g0({recoveryParam:i.recoveryParam,r:ia("0x"+i.r.toString(16),32),s:ia("0x"+i.s.toString(16),32)})}computeSharedSecret(e){let t=Io().keyFromPrivate(fr(this.privateKey)),n=Io().keyFromPublic(fr(xg(e)));return ia("0x"+t.derive(n.getPublic()).toString(16),32)}static isSigningKey(e){return!!(e&&e._isSigningKey)}};o(A0,"SigningKey");function J8(r,e){let t=g0(e),n={r:fr(t.r),s:fr(t.s)};return"0x"+Io().recoverPubKey(fr(r),n,t.recoveryParam).encode("hex",!1)}o(J8,"recoverPublicKey");function xg(r,e){let t=fr(r);if(t.length===32){let n=new A0(t);return e?"0x"+Io().keyFromPrivate(t).getPublic(!0,"hex"):n.publicKey}else{if(t.length===33)return e?rn(t):"0x"+Io().keyFromPublic(t).getPublic(!1,"hex");if(t.length===65)return e?"0x"+Io().keyFromPublic(t).getPublic(!0,"hex"):rn(t)}return yg.throwArgumentError("invalid public or private key","key","[REDACTED]")}o(xg,"computePublicKey");var Y8="transactions/5.8.0";var iZ=new Tt(Y8),Z8;(function(r){r[r.legacy=0]="legacy",r[r.eip2930=1]="eip2930",r[r.eip1559=2]="eip1559"})(Z8||(Z8={}));function X8(r){let e=xg(r);return U8(b0(Uc(b0(e,1)),12))}o(X8,"computeAddress");function Q8(r,e){return X8(J8(fr(r),e))}o(Q8,"recoverAddress");var e_="wallet/5.8.0";var dZ=new Tt(e_);function wg(r,e){return Q8(lg(r),e)}o(wg,"verifyMessage");function t_(){return{eip191:async(r,e)=>{KU(r,e)}}}o(t_,"getEIP191Verifier");var zU=new Date("2022-09-20").valueOf();function KU(r,e){tg(r),x8(r,e);let n=[wg(Bc.fromCacao(r).toMessage(),r.s.s).toLowerCase()];if(Date.parse(r.p.iat)<=zU){let s=wg(y8(Bc.fromCacao(r),"Ethereum"),r.s.s).toLowerCase();n.push(s)}let i=na.parse(r.p.iss.replace("did:pkh:","")).address.toLowerCase();if(!n.includes(i))throw new Error("Signature does not belong to issuer")}o(KU,"verifyEIP191Signature");ic();cd();var r_=Ft(Ga(),1);ic();function n_(){return Rt((0,r_.randomBytes)(16),"base64")}o(n_,"randomString");var i_="base64pad",o_="base64url";function s_(r){return Rt(r,i_)}o(s_,"encodeBase64");function a_(r){return Rt(r,o_)}o(a_,"encodeBase64Url");function f_(r){return $t(r,i_)}o(f_,"decodeBase64");function S0(r){return JSON.parse(Rt($t(r,o_)))}o(S0,"base64urlToJSON");function c_(r){if(r.signatures.length>1)throw new Error("Cant convert to compact jws");return`${r.signatures[0].protected}.${r.payload}.${r.signatures[0].signature}`}o(c_,"fromDagJWS");function u_(r,e){if(e){let t=e.toISOString().split(".")[0]+"Z";return`${r}?versionTime=${t}`}else return r}o(u_,"didWithTime");function l_(r){return r?Array.isArray(r)?r:[r]:[]}o(l_,"extractControllers");var VU={...t_()};function GU(r){return"registry"in r&&"cache"in r}o(GU,"isResolver");var hf=class{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 hf({provider:this._client?.connection,resolver:this._resolver,capability:e,parent:this._parentId})}setProvider(e){if(this._client==null)this._client=new Tc(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,t){this._resolver=GU(e)?e:new Ru(e,t)}async authenticate({provider:e,paths:t=[],aud:n}={}){if(e!=null&&this.setProvider(e),this._client==null)throw new Error("No provider available");let i=n_(),s=await this._client.request("did_authenticate",{nonce:i,aud:n,paths:t}),{kid:f}=await this.verifyJWS(s),u=S0(s.payload);if(!f.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,t={}){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=this._capability.p.exp;if(i&&Date.parse(i)<Date.now())throw new Error("Capability is expired, cannot create a valid signature");let s=await xl.fromCacao(this._capability),f=Ye.asCID(s.cid);if(!f)throw new Error("Capability CID of the JWS cannot be set to the capability payload cid as they are incompatible");t.protected=t.protected||{},t.protected.cap=`ipfs://${f?.toString()}`}let{jws:n}=await this._client.request("did_createJWS",{did:this._id,...t,payload:e});return n}async createDagJWS(e,t={}){let{cid:n,linkedBlock:i}=await t5(e),s=a_(n.bytes);Object.assign(t,{linkedBlock:s_(i)});let f=await this.createJWS(s,t),u=Ye.asCID(n);if(!u)throw new Error("CID of the JWS cannot be set to the encoded payload cid as they are incompatible");if(f.link=u,this._capability){let d=await xl.fromCacao(this._capability);return{jws:f,linkedBlock:i,cacaoBlock:d.bytes}}return{jws:f,linkedBlock:i}}async verifyJWS(e,t={}){t=Object.assign({verifiers:VU},t),typeof e!="string"&&(e=c_(e));let n=S0(e.split(".")[0]).kid;if(!n)throw new Error('No "kid" found in jws');let i=await this.resolve(n);if(!t.disableTimecheck){let y=i.didDocumentMetadata?.nextUpdate;if(y){let A=t.revocationPhaseOutSecs?t.revocationPhaseOutSecs*1e3:0,O=new Date(y).valueOf()+A;if(!(t.atTime&&t.atTime.getTime()<O))throw new Error(`invalid_jws: signature authored with a revoked DID version: ${n}`)}let w=i.didDocumentMetadata?.updated;if(w&&t.atTime&&t.atTime.getTime()<new Date(w).valueOf())throw new Error(`invalid_jws: signature authored before creation of DID version: ${n}`)}let f=i.didDocument?.id;if(t.issuer&&t.issuer===t.capability?.p.iss&&f===t.capability.p.aud){if(!t.verifiers)throw new Error("Registered verifiers needed for CACAO");await yl.verify(t.capability,{disableExpirationCheck:t.disableTimecheck,atTime:t.atTime?t.atTime:void 0,revocationPhaseOutSecs:t.revocationPhaseOutSecs,verifiers:t.verifiers??{}})}else if(t.issuer&&t.issuer!==f){let y=u_(t.issuer,t.atTime),A=(await this.resolve(y)).didDocument?.controller,O=l_(A);if(t.capability?.s&&t.capability.p.aud===f&&O.includes(t.capability.p.iss))await yl.verify(t.capability,{atTime:t.atTime?t.atTime:void 0,revocationPhaseOutSecs:t.revocationPhaseOutSecs,verifiers:t.verifiers??{}});else if(!(f?O.includes(f):!1))throw new Error(`invalid_jws: not a valid verificationMethod for issuer: ${n}`)}let u=i.didDocument?.verificationMethod||[];jw(e,u);let d;try{d=S0(e.split(".")[1])}catch{}return{kid:n,payload:d,didResolutionResult:i}}async createJWE(e,t,n={}){let i=await Kw(t,this._resolver);return zw(e,i,n.protectedHeader,n.aad)}async createDagJWE(e,t,n={}){let i=await r5(e);return this.createJWE(i,t,n)}async decryptJWE(e,t={}){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,...t,jwe:e});return f_(n)}async decryptDagJWE(e){let t=await this.decryptJWE(e);return n5(t)}async resolve(e){let t=await this._resolver.resolve(e);if(t.didResolutionMetadata.error){let{error:n,message:i}=t.didResolutionMetadata,s=i?`, ${i}`:"";throw new Error(`Failed to resolve ${e}: ${n}${s}`)}return t}constructor({provider:e,resolver:t={},resolverOptions:n,capability:i,parent:s}={}){if(e!=null&&(this._client=new Tc(e)),i){if(this._capability=i,this._parentId=this._capability.p.iss,s&&this._parentId!==s)throw new Error("Capability issuer and parent not equal")}else s&&(this._parentId=s);this.setResolver(t,n)}};o(hf,"DID");function h_(r){var e=0,t=r.length,n=[];if(t%2)throw new Error("invalid hex:"+r);for(;e<t;e+=2)n.push(parseInt(r.substr(e,2),16));return new Uint8Array(n)}o(h_,"toUint8Array");var Rg=Ft(Al(),1);Qh();var Ag={};Zt(Ag,{keyToDidDoc:()=>aF});function aF(r,e){let t=`did:key:${e}`,n=`${t}#${e}`;return{id:t,verificationMethod:[{id:n,type:"Secp256k1VerificationKey2018",controller:t,publicKeyBase58:Rt(r,"base58btc")}],authentication:[n],assertionMethod:[n],capabilityDelegation:[n],capabilityInvocation:[n]}}o(aF,"keyToDidDoc");var Sg={};Zt(Sg,{keyToDidDoc:()=>cF});ic();var __=Ft(Bd(),1);function fF(r){let e=new Uint8Array(r.length+2);return e[0]=236,e[1]=1,e.set(r,2),`z${Rt(e,"base58btc")}`}o(fF,"encodeKey");function cF(r,e){let t=`did:key:${e}`,n=`${t}#${e}`,i=(0,__.convertPublicKeyToX25519)(r),s=`${t}#${fF(i)}`;return{id:t,verificationMethod:[{id:n,type:"Ed25519VerificationKey2018",controller:t,publicKeyBase58:Rt(r,"base58btc")}],authentication:[n],assertionMethod:[n],capabilityDelegation:[n],capabilityInvocation:[n],keyAgreement:[{id:s,type:"X25519KeyAgreementKey2019",controller:t,publicKeyBase58:Rt(i,"base58btc")}]}}o(cF,"keyToDidDoc");var kg={};Zt(kg,{keyToDidDoc:()=>xF,pubKeyBytesToXY:()=>M_});var T0={};Zt(T0,{ECPointDecompress:()=>gF});function uF(r){return r>=0?r:-r}o(uF,"n");function lF(r,e){if(typeof r=="number"&&(r=BigInt(r)),typeof e=="number"&&(e=BigInt(e)),r<=0n||e<=0n)throw new RangeError("a and b MUST be > 0");let t=0n,n=1n,i=1n,s=0n;for(;r!==0n;){let f=e/r,u=e%r,d=t-i*f,y=n-s*f;e=r,r=u,t=i,n=s,i=d,s=y}return{g:e,x:t,y:n}}o(lF,"r");function M0(r,e){if(typeof r=="number"&&(r=BigInt(r)),typeof e=="number"&&(e=BigInt(e)),e<=0n)throw new RangeError("n must be > 0");let t=r%e;return t<0n?t+e:t}o(M0,"e");function E_(r,e){let t=lF(M0(r,e),e);if(t.g!==1n)throw new RangeError(`${r.toString()} does not have inverse modulo ${e.toString()}`);return M0(t.x,e)}o(E_,"o");function hF(r,e,t){if(r.length!==e.length)throw new RangeError("The remainders and modulos arrays should have the same length");let n=t??e.reduce((i,s)=>i*s,1n);return e.reduce((i,s,f)=>{let u=n/s;return M0(i+u*E_(u,s)%n*r[f]%n,n)},0n)}o(hF,"i");function dF(r){return r.map(e=>e[0]**(e[1]-1n)*(e[0]-1n)).reduce((e,t)=>t*e,1n)}o(dF,"a");function aa(r,e,t,n){if(typeof r=="number"&&(r=BigInt(r)),typeof e=="number"&&(e=BigInt(e)),typeof t=="number"&&(t=BigInt(t)),t<=0n)throw new RangeError("n must be > 0");if(t===1n)return 0n;if(r=M0(r,t),e<0n)return E_(aa(r,uF(e),t,n),t);if(n!==void 0)return function(s,f,u,d){let y=d.map(O=>O[0]**O[1]),w=d.map(O=>dF([O])),A=w.map((O,R)=>aa(s,f%O,y[R]));return hF(A,y,u)}(r,e,t,function(s){let f={};return s.forEach(u=>{if(typeof u=="bigint"||typeof u=="number"){let d=String(u);f[d]===void 0?f[d]={p:BigInt(u),k:1n}:f[d].k+=1n}else{let d=String(u[0]);f[d]===void 0?f[d]={p:BigInt(u[0]),k:BigInt(u[1])}:f[d].k+=BigInt(u[1])}}),Object.values(f).map(u=>[u.p,u.k])}(n));let i=1n;for(;e>0;)e%2n===1n&&(i=i*r%t),e/=2n,r=r**2n%t;return i}o(aa,"s");var wr={};Zt(wr,{pubKeyBytesToHex:()=>pF,publicKeyHexToUint8ArrayPointPair:()=>A_,publicKeyIntToUint8ArrayPointPair:()=>S_,publicKeyIntToXY:()=>bF,publicKeyToXY:()=>mF,testHexString:()=>Tg,testUint8Array:()=>fa});ed();function pF(r){if(!fa(r))throw new TypeError("input must be a Uint8Array");return Rt(r,"base16")}o(pF,"pubKeyBytesToHex");function mF(r){if(!Tg(r))throw new TypeError("input must be string with characters 0-9,A-F,a-f");let e=A_(r),t=La.encode(e.xOctet).slice(1),n=La.encode(e.yOctet).slice(1);return{xm:t,ym:n}}o(mF,"publicKeyToXY");function A_(r){if(!Tg(r))throw new TypeError("input must be string with characters 0-9,A-F,a-f");let e=r.slice(0,r.length/2),t=r.slice(r.length/2,r.length),n=$t(e,"base16"),i=$t(t,"base16");return{xOctet:n,yOctet:i}}o(A_,"publicKeyHexToUint8ArrayPointPair");function Tg(r){let e=/^[A-Fa-f0-9]+$/i;return!!(e.exec(r)!==null&&e.test(r)&&typeof r=="string")}o(Tg,"testHexString");function fa(r){return r==null?!1:r.constructor===Uint8Array}o(fa,"testUint8Array");function bF(r){if(r==null)throw new TypeError("input cannot be null or undefined.");if(typeof r!="object")throw new TypeError("Input must be an object with properties x and y");if(!Object.prototype.hasOwnProperty.call(r,"x")||!Object.prototype.hasOwnProperty.call(r,"y"))throw new Error("Input must have properties x and y");if(typeof r.x!="bigint"&&typeof r.y!="bigint")throw new Error("Input coordinates must be BigInt");let e=S_(r),t=La.encode(e.xOctet).slice(1),n=La.encode(e.yOctet).slice(1);return{xm:t,ym:n}}o(bF,"publicKeyIntToXY");function S_(r){if(r==null)throw new TypeError("input cannot be null or undefined.");if(typeof r!="object")throw new TypeError("Input must be an object with properties x and y");if(!Object.prototype.hasOwnProperty.call(r,"x")||!Object.prototype.hasOwnProperty.call(r,"y"))throw new Error("Input must have properties x and y");if(typeof r.x!="bigint"&&typeof r.y!="bigint")throw new Error("Input coordinates must be BigInt");let e=r.x.toString(),t=r.y.toString(),n=$t(e,"base10"),i=$t(t,"base10");return{xOctet:n,yOctet:i}}o(S_,"publicKeyIntToUint8ArrayPointPair");function gF(r){if(!fa(r))throw new TypeError("input must be a Uint8Array");let e=BigInt(2),t=e**256n-e**224n+e**192n+e**96n-1n,n=41058363725152142129326129780047268409114441015993725554835256314039467401291n,i=(t+1n)/4n,s=BigInt(r[0]-2),f=r.subarray(1),u=BigInt(Rt(f,"base10")),d=u**3n-u*3n+n,y=aa(d,i,t);return y%2n!==s&&(y=t-y),{x:u,y}}o(gF,"ECPointDecompress");var C0={};Zt(C0,{ECPointDecompress:()=>vF});function vF(r){if(!fa(r))throw new TypeError("input must be a Uint8Array");let e=BigInt(2),t=e**384n-e**128n-e**96n+e**32n-1n,n=27580193559959705877849011840389048093056905856361568521428707301988689241309860865136260764883745107765439761230575n,i=(t+1n)/4n,s=BigInt(r[0]-2),f=r.subarray(1),u=BigInt(Rt(f,"base10")),d=u**3n-u*3n+n,y=aa(d,i,t);return y%2n!==s&&(y=t-y),{x:u,y}}o(vF,"ECPointDecompress");var k0={};Zt(k0,{ECPointDecompress:()=>yF});function yF(r){if(!fa(r))throw new TypeError("input must be a Uint8Array");let t=BigInt(2)**521n-1n,n=1093849038073734274511112390766805569936207598951683748994586394495953116150735016013708737573759623248592132296706313309438452531591012912142327488478985984n,i=(t+1n)/4n,s=BigInt(r[0]-2),f=r.subarray(1),u=BigInt(Rt(f,"base10")),d=u**3n-u*3n+n,y=aa(d,i,t);return y%2n!==s&&(y=t-y),{x:u,y}}o(yF,"ECPointDecompress");function xF(r,e){let t=`did:key:${e}`,n=`${t}#${e}`,i=M_(r);return{id:t,verificationMethod:[{id:n,type:"JsonWebKey2020",controller:t,publicKeyJwk:{kty:"EC",crv:"P-256",x:i.xm,y:i.ym}}],authentication:[n],assertionMethod:[n],capabilityDelegation:[n],capabilityInvocation:[n]}}o(xF,"keyToDidDoc");function M_(r){if(!wr.testUint8Array(r))throw new TypeError("input must be a Uint8Array");let e=wr.pubKeyBytesToHex(r),t=e.length/2;if(t==64)return wr.publicKeyToXY(e);if(t==65&&e.slice(0,2)=="04"){let n=e.slice(2);return wr.publicKeyToXY(n)}if(t==33&&(e.slice(0,2)=="03"||e.slice(0,2)=="02")){let n=$t(e,"base16"),i=T0.ECPointDecompress(n);return wr.publicKeyIntToXY(i)}throw new Error("Unexpected pubKeyBytes")}o(M_,"pubKeyBytesToXY");var Ig={};Zt(Ig,{keyToDidDoc:()=>wF,pubKeyBytesToXY:()=>T_});function wF(r,e){let t=`did:key:${e}`,n=`${t}#${e}`,i=T_(r);return{id:t,verificationMethod:[{id:n,type:"JsonWebKey2020",controller:t,publicKeyJwk:{kty:"EC",crv:"P-384",x:i.xm,y:i.ym}}],authentication:[n],assertionMethod:[n],capabilityDelegation:[n],capabilityInvocation:[n]}}o(wF,"keyToDidDoc");function T_(r){if(!wr.testUint8Array(r))throw new TypeError("input must be a Uint8Array");let e=wr.pubKeyBytesToHex(r),t=e.length/2;if(t==96)return wr.publicKeyToXY(e);if(t==97&&e.slice(0,2)=="04"){let n=e.slice(2);return wr.publicKeyToXY(n)}if(t==49&&(e.slice(0,2)=="03"||e.slice(0,2)=="02")){let n=$t(e,"base16"),i=C0.ECPointDecompress(n);return wr.publicKeyIntToXY(i)}throw new Error("Unexpected pubKeyBytes")}o(T_,"pubKeyBytesToXY");var Dg={};Zt(Dg,{keyToDidDoc:()=>_F,pubKeyBytesToXY:()=>C_});function _F(r,e){let t=`did:key:${e}`,n=`${t}#${e}`,i=C_(r);return{id:t,verificationMethod:[{id:n,type:"JsonWebKey2020",controller:t,publicKeyJwk:{kty:"EC",crv:"P-521",x:i.xm,y:i.ym}}],authentication:[n],assertionMethod:[n],capabilityDelegation:[n],capabilityInvocation:[n]}}o(_F,"keyToDidDoc");function C_(r){if(!wr.testUint8Array(r))throw new TypeError("input must be a Uint8Array");let e=wr.pubKeyBytesToHex(r);if(132<=e.length&&e.length<=134&&(e.slice(0,2)=="03"||e.slice(0,2)=="02")){let t=$t(e,"base16"),n=k0.ECPointDecompress(t);return wr.publicKeyIntToXY(n)}throw new Error("Unexpected pubKeyBytes")}o(C_,"pubKeyBytesToXY");var EF="application/did+ld+json",k_="application/did+json",AF={231:Ag,237:Sg,4608:kg,4609:Ig,4610:Dg};function SF(){return{key:async(r,e,t,n)=>{let i=n.accept||k_,s={didResolutionMetadata:{contentType:i},didDocument:null,didDocumentMetadata:{}};try{let f=vi.decode(e.id),u=Rg.default.decode(f),d=f.slice(Rg.default.decode.bytes),y=await AF[u].keyToDidDoc(d,e.id);i===EF?(y["@context"]="https://w3id.org/did/v1",s.didDocument=y):i===k_?s.didDocument=y:(delete s.didResolutionMetadata.contentType,s.didResolutionMetadata.error="representationNotSupported")}catch(f){s.didResolutionMetadata.error="invalidDid",s.didResolutionMetadata.message=f.toString()}return s}}}o(SF,"getResolver");var I_={getResolver:SF};var I0=Ft(Bd(),1);var B_=Ft(R_(),1);var MF="base64pad";function O_(r){return JSON.parse((0,B_.default)(r))}o(O_,"toStableObject");function TF(r){let e=new Uint8Array(r.length+2);return e[0]=237,e[1]=1,e.set(r,2),`did:key:z${Rt(e,"base58btc")}`}o(TF,"encodeDID");function N_(r){let[e,t,n]=r.split(".");return{payload:t,signatures:[{protected:e,signature:n}]}}o(N_,"toGeneralJWS");var P_=o(async(r,e,t,n={})=>{let i=`${e}#${e.split(":")[2]}`,s=Lw(t),f=O_(Object.assign(n,{kid:i,alg:"EdDSA"}));return qw(typeof r=="string"?r:O_(r),s,f)},"sign"),CF={did_authenticate:async({did:r,secretKey:e},t)=>{let n=await P_({did:r,aud:t.aud,nonce:t.nonce,paths:t.paths,exp:Math.floor(Date.now()/1e3)+600},r,e);return N_(n)},did_createJWS:async({did:r,secretKey:e},t)=>{if(t.did.split("#")[0]!==r)throw new Tn(4100,`Unknown DID: ${r}`);let i=await P_(t.payload,r,e,t.protected);return{jws:N_(i)}},did_decryptJWE:async({secretKey:r},e)=>{let t=Gw((0,I0.convertSecretKeyToX25519)(r));try{let n=await Hw(e.jwe,t);return{cleartext:Rt(n,MF)}}catch(n){throw new Tn(-32e3,n.message)}}},Sl=class{constructor(e){let{secretKey:t,publicKey:n}=(0,I0.generateKeyPairFromSeed)(e),i=TF(n),s=u5(CF);this._handle=async f=>await s({did:i,secretKey:t},f)}get isDidProvider(){return!0}async send(e){return await this._handle(e)}};o(Sl,"Ed25519Provider");var Og={};Zt(Og,{JsonPatchError:()=>br,_areEquals:()=>Cl,applyOperation:()=>df,applyPatch:()=>L0,applyReducer:()=>OF,deepClone:()=>DF,getValueByPointer:()=>P0,validate:()=>U_,validator:()=>B0});var kF=function(){var r=o(function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var s in i)i.hasOwnProperty(s)&&(n[s]=i[s])},r(e,t)},"extendStatics");return function(e,t){r(e,t);function n(){this.constructor=e}o(n,"__"),e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),IF=Object.prototype.hasOwnProperty;function R0(r,e){return IF.call(r,e)}o(R0,"hasOwnProperty");function O0(r){if(Array.isArray(r)){for(var e=new Array(r.length),t=0;t<e.length;t++)e[t]=""+t;return e}if(Object.keys)return Object.keys(r);var n=[];for(var i in r)R0(r,i)&&n.push(i);return n}o(O0,"_objectKeys");function Kr(r){switch(typeof r){case"object":return JSON.parse(JSON.stringify(r));case"undefined":return null;default:return r}}o(Kr,"_deepClone");function N0(r){for(var e=0,t=r.length,n;e<t;){if(n=r.charCodeAt(e),n>=48&&n<=57){e++;continue}return!1}return!0}o(N0,"isInteger");function Do(r){return r.indexOf("/")===-1&&r.indexOf("~")===-1?r:r.replace(/~/g,"~0").replace(/\//g,"~1")}o(Do,"escapePathComponent");function Ml(r){return r.replace(/~1/g,"/").replace(/~0/g,"~")}o(Ml,"unescapePathComponent");function D0(r){if(r===void 0)return!0;if(r){if(Array.isArray(r)){for(var e=0,t=r.length;e<t;e++)if(D0(r[e]))return!0}else if(typeof r=="object"){for(var n=O0(r),i=n.length,s=0;s<i;s++)if(D0(r[n[s]]))return!0}}return!1}o(D0,"hasUndefined");function L_(r,e){var t=[r];for(var n in e){var i=typeof e[n]=="object"?JSON.stringify(e[n],null,2):e[n];typeof i<"u"&&t.push(n+": "+i)}return t.join(`
|
|
820
820
|
`)}o(L_,"patchErrorMessageFormatter");var Tl=function(r){kF(e,r);function e(t,n,i,s,f){var u=this.constructor,d=r.call(this,L_(t,{name:n,index:i,operation:s,tree:f}))||this;return d.name=n,d.index=i,d.operation=s,d.tree=f,Object.setPrototypeOf(d,u.prototype),d.message=L_(t,{name:n,index:i,operation:s,tree:f}),d}return o(e,"PatchError"),e}(Error);var br=Tl,DF=Kr,qc={add:function(r,e,t){return r[e]=this.value,{newDocument:t}},remove:function(r,e,t){var n=r[e];return delete r[e],{newDocument:t,removed:n}},replace:function(r,e,t){var n=r[e];return r[e]=this.value,{newDocument:t,removed:n}},move:function(r,e,t){var n=P0(t,this.path);n&&(n=Kr(n));var i=df(t,{op:"remove",path:this.from}).removed;return df(t,{op:"add",path:this.path,value:i}),{newDocument:t,removed:n}},copy:function(r,e,t){var n=P0(t,this.from);return df(t,{op:"add",path:this.path,value:Kr(n)}),{newDocument:t}},test:function(r,e,t){return{newDocument:t,test:Cl(r[e],this.value)}},_get:function(r,e,t){return this.value=r[e],{newDocument:t}}},RF={add:function(r,e,t){return N0(e)?r.splice(e,0,this.value):r[e]=this.value,{newDocument:t,index:e}},remove:function(r,e,t){var n=r.splice(e,1);return{newDocument:t,removed:n[0]}},replace:function(r,e,t){var n=r[e];return r[e]=this.value,{newDocument:t,removed:n}},move:qc.move,copy:qc.copy,test:qc.test,_get:qc._get};function P0(r,e){if(e=="")return r;var t={op:"_get",path:e};return df(r,t),t.value}o(P0,"getValueByPointer");function df(r,e,t,n,i,s){if(t===void 0&&(t=!1),n===void 0&&(n=!0),i===void 0&&(i=!0),s===void 0&&(s=0),t&&(typeof t=="function"?t(e,0,r,e.path):B0(e,0)),e.path===""){var f={newDocument:r};if(e.op==="add")return f.newDocument=e.value,f;if(e.op==="replace")return f.newDocument=e.value,f.removed=r,f;if(e.op==="move"||e.op==="copy")return f.newDocument=P0(r,e.from),e.op==="move"&&(f.removed=r),f;if(e.op==="test"){if(f.test=Cl(r,e.value),f.test===!1)throw new br("Test operation failed","TEST_OPERATION_FAILED",s,e,r);return f.newDocument=r,f}else{if(e.op==="remove")return f.removed=r,f.newDocument=null,f;if(e.op==="_get")return e.value=r,f;if(t)throw new br("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",s,e,r);return f}}else{n||(r=Kr(r));var u=e.path||"",d=u.split("/"),y=r,w=1,A=d.length,O=void 0,R=void 0,I=void 0;for(typeof t=="function"?I=t:I=B0;;){if(R=d[w],R&&R.indexOf("~")!=-1&&(R=Ml(R)),i&&(R=="__proto__"||R=="prototype"&&w>0&&d[w-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(t&&O===void 0&&(y[R]===void 0?O=d.slice(0,w).join("/"):w==A-1&&(O=e.path),O!==void 0&&I(e,0,r,O)),w++,Array.isArray(y)){if(R==="-")R=y.length;else{if(t&&!N0(R))throw new br("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",s,e,r);N0(R)&&(R=~~R)}if(w>=A){if(t&&e.op==="add"&&R>y.length)throw new br("The specified index MUST NOT be greater than the number of elements in the array","OPERATION_VALUE_OUT_OF_BOUNDS",s,e,r);var f=RF[e.op].call(e,y,R,r);if(f.test===!1)throw new br("Test operation failed","TEST_OPERATION_FAILED",s,e,r);return f}}else if(w>=A){var f=qc[e.op].call(e,y,R,r);if(f.test===!1)throw new br("Test operation failed","TEST_OPERATION_FAILED",s,e,r);return f}if(y=y[R],t&&w<A&&(!y||typeof y!="object"))throw new br("Cannot perform operation at the desired path","OPERATION_PATH_UNRESOLVABLE",s,e,r)}}}o(df,"applyOperation");function L0(r,e,t,n,i){if(n===void 0&&(n=!0),i===void 0&&(i=!0),t&&!Array.isArray(e))throw new br("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");n||(r=Kr(r));for(var s=new Array(e.length),f=0,u=e.length;f<u;f++)s[f]=df(r,e[f],t,!0,i,f),r=s[f].newDocument;return s.newDocument=r,s}o(L0,"applyPatch");function OF(r,e,t){var n=df(r,e);if(n.test===!1)throw new br("Test operation failed","TEST_OPERATION_FAILED",t,e,r);return n.newDocument}o(OF,"applyReducer");function B0(r,e,t,n){if(typeof r!="object"||r===null||Array.isArray(r))throw new br("Operation is not an object","OPERATION_NOT_AN_OBJECT",e,r,t);if(qc[r.op]){if(typeof r.path!="string")throw new br("Operation `path` property is not a string","OPERATION_PATH_INVALID",e,r,t);if(r.path.indexOf("/")!==0&&r.path.length>0)throw new br('Operation `path` property must start with "/"',"OPERATION_PATH_INVALID",e,r,t);if((r.op==="move"||r.op==="copy")&&typeof r.from!="string")throw new br("Operation `from` property is not present (applicable in `move` and `copy` operations)","OPERATION_FROM_REQUIRED",e,r,t);if((r.op==="add"||r.op==="replace"||r.op==="test")&&r.value===void 0)throw new br("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_REQUIRED",e,r,t);if((r.op==="add"||r.op==="replace"||r.op==="test")&&D0(r.value))throw new br("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED",e,r,t);if(t){if(r.op=="add"){var i=r.path.split("/").length,s=n.split("/").length;if(i!==s+1&&i!==s)throw new br("Cannot perform an `add` operation at the desired path","OPERATION_PATH_CANNOT_ADD",e,r,t)}else if(r.op==="replace"||r.op==="remove"||r.op==="_get"){if(r.path!==n)throw new br("Cannot perform the operation at a path that does not exist","OPERATION_PATH_UNRESOLVABLE",e,r,t)}else if(r.op==="move"||r.op==="copy"){var f={op:"_get",path:r.from,value:void 0},u=U_([f],t);if(u&&u.name==="OPERATION_PATH_UNRESOLVABLE")throw new br("Cannot perform the operation from a path that does not exist","OPERATION_FROM_UNRESOLVABLE",e,r,t)}}}else throw new br("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",e,r,t)}o(B0,"validator");function U_(r,e,t){try{if(!Array.isArray(r))throw new br("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");if(e)L0(Kr(e),Kr(r),t||!0);else{t=t||B0;for(var n=0;n<r.length;n++)t(r[n],n,e,void 0)}}catch(i){if(i instanceof br)return i;throw i}}o(U_,"validate");function Cl(r,e){if(r===e)return!0;if(r&&e&&typeof r=="object"&&typeof e=="object"){var t=Array.isArray(r),n=Array.isArray(e),i,s,f;if(t&&n){if(s=r.length,s!=e.length)return!1;for(i=s;i--!==0;)if(!Cl(r[i],e[i]))return!1;return!0}if(t!=n)return!1;var u=Object.keys(r);if(s=u.length,s!==Object.keys(e).length)return!1;for(i=s;i--!==0;)if(!e.hasOwnProperty(u[i]))return!1;for(i=s;i--!==0;)if(f=u[i],!Cl(r[f],e[f]))return!1;return!0}return r!==r&&e!==e}o(Cl,"_areEquals");var Lg={};Zt(Lg,{compare:()=>qF,generate:()=>Ng,observe:()=>$F,unobserve:()=>FF});var Pg=new WeakMap,NF=function(){function r(e){this.observers=new Map,this.obj=e}return o(r,"Mirror"),r}(),PF=function(){function r(e,t){this.callback=e,this.observer=t}return o(r,"ObserverInfo"),r}();function BF(r){return Pg.get(r)}o(BF,"getMirror");function LF(r,e){return r.observers.get(e)}o(LF,"getObserverFromMirror");function UF(r,e){r.observers.delete(e.callback)}o(UF,"removeObserverFromMirror");function FF(r,e){e.unobserve()}o(FF,"unobserve");function $F(r,e){var t=[],n,i=BF(r);if(!i)i=new NF(r),Pg.set(r,i);else{var s=LF(i,e);n=s&&s.observer}if(n)return n;if(n={},i.value=Kr(r),e){n.callback=e,n.next=null;var f=o(function(){Ng(n)},"dirtyCheck"),u=o(function(){clearTimeout(n.next),n.next=setTimeout(f)},"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=t,n.object=r,n.unobserve=function(){Ng(n),clearTimeout(n.next),UF(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 PF(e,n)),n}o($F,"observe");function Ng(r,e){e===void 0&&(e=!1);var t=Pg.get(r.object);Bg(t.value,r.object,r.patches,"",e),r.patches.length&&L0(t.value,r.patches);var n=r.patches;return n.length>0&&(r.patches=[],r.callback&&r.callback(n)),n}o(Ng,"generate");function Bg(r,e,t,n,i){if(e!==r){typeof e.toJSON=="function"&&(e=e.toJSON());for(var s=O0(e),f=O0(r),u=!1,d=!1,y=f.length-1;y>=0;y--){var w=f[y],A=r[w];if(R0(e,w)&&!(e[w]===void 0&&A!==void 0&&Array.isArray(e)===!1)){var O=e[w];typeof A=="object"&&A!=null&&typeof O=="object"&&O!=null&&Array.isArray(A)===Array.isArray(O)?Bg(A,O,t,n+"/"+Do(w),i):A!==O&&(u=!0,i&&t.push({op:"test",path:n+"/"+Do(w),value:Kr(A)}),t.push({op:"replace",path:n+"/"+Do(w),value:Kr(O)}))}else Array.isArray(r)===Array.isArray(e)?(i&&t.push({op:"test",path:n+"/"+Do(w),value:Kr(A)}),t.push({op:"remove",path:n+"/"+Do(w)}),d=!0):(i&&t.push({op:"test",path:n,value:r}),t.push({op:"replace",path:n,value:e}),u=!0)}if(!(!d&&s.length==f.length))for(var y=0;y<s.length;y++){var w=s[y];!R0(r,w)&&e[w]!==void 0&&t.push({op:"add",path:n+"/"+Do(w),value:Kr(e[w])})}}}o(Bg,"_generate");function qF(r,e,t){t===void 0&&(t=!1);var n=[];return Bg(r,e,n,"",t),n}o(qF,"compare");var U0=Object.assign({},Og,Lg,{JsonPatchError:Tl,deepClone:Kr,escapePathComponent:Do,unescapePathComponent:Ml});var M9=Ft(Vc(),1);var T9=Ft(Ga(),1);var _r;(function(r){r[r.PREFER_CACHE=0]="PREFER_CACHE",r[r.SYNC_ALWAYS=1]="SYNC_ALWAYS",r[r.NEVER_SYNC=2]="NEVER_SYNC"})(_r||(_r={}));var yv=Ft(Vc(),1);ji();tc();var ME={tile:0,"caip10-link":1,model:2,MID:3,UNLOADABLE:4};function mq(r){let e=ME[r];if(typeof e<"u")return e;throw new Error(`No stream type registered for name ${r}`)}o(mq,"codeByName");function bq(r){let e=Object.entries(ME).find(([,t])=>t===r);if(e)return e[0];throw new Error(`No stream type registered for index ${r}`)}o(bq,"nameByCode");var In=class{};o(In,"StreamType");In.nameByCode=bq;In.codeByName=mq;var ov=Ft(Al(),1);function Zn(r){let e,t,n;return typeof r=="object"?(e=r.hashFunction,t=r.expiring,n=r.tags):e=r,(i,s,f)=>{if(f.value!=null)f.value=TE(f.value,e,t,n);else if(f.get!=null)f.get=TE(f.get,e,t,n);else throw"Only put a Memoize() decorator on a method or get accessor."}}o(Zn,"Memoize");var Xg=new Map;function TE(r,e,t=0,n){let i=Symbol("__memoized_map__");return function(...s){let f;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 d of n)Xg.has(d)?Xg.get(d).push(u):Xg.set(d,[u]);if(e||s.length>0||t>0){let d;e===!0?d=s.map(A=>A.toString()).join("!"):e?d=e.apply(this,s):d=s[0];let y=`${d}__timestamp`,w=!1;if(t>0)if(!u.has(y))w=!0;else{let A=u.get(y);w=Date.now()-A>t}u.has(d)&&!w?f=u.get(d):(f=r.apply(this,s),u.set(d,f),t>0&&u.set(y,Date.now()))}else{let d=this;u.has(d)?f=u.get(d):(f=r.apply(this,s),u.set(d,f))}return f}}o(TE,"getNewFunction");ji();tc();Uu();var nv=Ft(Al(),1);function Gc(r){try{return r()}catch(e){return e}}o(Gc,"tryCatch");ji();var Qg=Ft(Al(),1);Fa();function gf(r){let e=Qg.default.decode(r),t=Qg.default.decode.bytes,n=r.subarray(t);return[e,n,t]}o(gf,"readVarint");function gq(r){return r===0||r===1}o(gq,"isCidVersion");function ev(r){let[e,t]=gf(r);if(!gq(e))throw new Error(`Unknown CID version ${e}`);let[n,i]=gf(t),[,s,f]=gf(i),[u,,d]=gf(s),y=i.subarray(0,f+d+u),w=i.subarray(f+d+u);return[Ye.create(e,n,nd(y)),w]}o(ev,"readCid");ji();tc();function vf(r,e="StreamRef"){let[t,n]=gf(r);if(t!==206)throw new Error(`Invalid ${e}, does not include streamid codec`);let[i,s]=gf(n),f=ev(s),[u,d]=f;if(d.length===0)return{kind:"stream-id",type:i,genesis:u};if(d.length===1&&d[0]===0)return{kind:"commit-id",type:i,genesis:u,commit:null};{let[y]=ev(d);return{kind:"commit-id",type:i,genesis:u,commit:y}}}o(vf,"fromBytes");var vq=/(ceramic:\/\/|\/ceramic\/)?([a-zA-Z0-9]+)(\?commit=([a-zA-Z0-9]+))?/;function Wc(r,e="StreamRef"){let t=vq.exec(r)||[],n=t[2];if(!n)throw new Error(`Malformed ${e} string: ${r}`);let i=qi.decode(n),s=vf(i),f=t[4];return f?{kind:"commit-id",type:s.type,genesis:s.genesis,commit:tv(s.genesis,f)}:s}o(Wc,"fromString");function yq(r){try{return typeof r=="string"?Ye.parse(r):Ye.asCID(r)}catch{return null}}o(yq,"parseCID");function tv(r,e=null){if(!e||e==="0")return null;let t=yq(e);if(t)return r.equals(t)?null:t;throw new Error("Cannot specify commit as a number except to request commit 0 (the genesis commit)")}o(tv,"parseCommit");var Rl=function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var u=r.length-1;u>=0;u--)(f=r[u])&&(s=(i<3?f(s):i>3?f(e,t,s):f(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},Ri=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},G0=class extends Error{constructor(e){super(`Invalid StreamID bytes ${qi.encode(e)}: contains commit`)}};o(G0,"InvalidStreamIDBytesError");var W0=class extends Error{constructor(e){super(`Invalid StreamID string ${e}: contains commit`)}};o(W0,"InvalidStreamIDStringError");function IE(r){let e=vf(r,"StreamID");if(e.kind==="stream-id")return new it(e.type,e.genesis);throw new G0(r)}o(IE,"fromBytes");function xq(r){return Gc(()=>IE(r))}o(xq,"fromBytesNoThrow");function DE(r){let e=Wc(r,"StreamID");if(e.kind==="stream-id")return new it(e.type,e.genesis);throw new W0(r)}o(DE,"fromString");function wq(r){return Gc(()=>DE(r))}o(wq,"fromStringNoThrow");var kE=Symbol.for("@ceramicnetwork/streamid/StreamID"),it=class{constructor(e,t){if(this._tag=kE,!(e||e===0))throw new Error("StreamID constructor: type required");if(!t)throw new Error("StreamID constructor: cid required");this._type=typeof e=="string"?In.codeByName(e):e,this._cid=typeof t=="string"?Ye.parse(t):t}static isInstance(e){return typeof e=="object"&&"_tag"in e&&e._tag===kE}static async fromGenesis(e,t){let n=await Qa({value:t,codec:Yi,hasher:Fs});return new it(e,n.cid)}get type(){return this._type}get typeName(){return In.nameByCode(this._type)}get cid(){return this._cid}get bytes(){let e=nv.default.encode(206),t=nv.default.encode(this.type);return Fi([e,t,this.cid.bytes])}get baseID(){return new it(this._type,this._cid)}equals(e){return it.isInstance(e)?this.type===e.type&&this.cid.equals(e.cid):!1}toString(){return qi.encode(this.bytes)}toUrl(){return`ceramic://${this.toString()}`}[Symbol.for("nodejs.util.inspect.custom")](){return`StreamID(${this.toString()})`}[Symbol.toPrimitive](){return this.toString()}};o(it,"StreamID");it.fromBytes=IE;it.fromBytesNoThrow=xq;it.fromString=DE;it.fromStringNoThrow=wq;Rl([Zn(),Ri("design:type",String),Ri("design:paramtypes",[])],it.prototype,"typeName",null);Rl([Zn(),Ri("design:type",Uint8Array),Ri("design:paramtypes",[])],it.prototype,"bytes",null);Rl([Zn(),Ri("design:type",it),Ri("design:paramtypes",[])],it.prototype,"baseID",null);Rl([Zn(),Ri("design:type",Function),Ri("design:paramtypes",[]),Ri("design:returntype",String)],it.prototype,"toString",null);Rl([Zn(),Ri("design:type",Function),Ri("design:paramtypes",[]),Ri("design:returntype",String)],it.prototype,"toUrl",null);var Yc=function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var u=r.length-1;u>=0;u--)(f=r[u])&&(s=(i<3?f(s):i>3?f(e,t,s):f(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},Dn=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},iv=function(r,e,t,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"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},vs=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},Jc,yf,Ol,J0=class extends Error{constructor(e){super(`Error while parsing CommitID from bytes ${qi.encode(e)}: no commit information provided`)}};o(J0,"InvalidCommitIDBytesError");var Y0=class extends Error{constructor(e){super(`Error while parsing CommitID from string ${e}: no commit information provided`)}};o(Y0,"InvalidCommitIDStringError");function OE(r){let e=vf(r,"CommitID");if(e.kind==="commit-id")return new Bt(e.type,e.genesis,e.commit);throw new J0(r)}o(OE,"fromBytes");function _q(r){return Gc(()=>OE(r))}o(_q,"fromBytesNoThrow");function NE(r){let e=Wc(r,"CommitID");if(e.kind==="commit-id")return new Bt(e.type,e.genesis,e.commit);throw new Y0(r)}o(NE,"fromString");function Eq(r){return Gc(()=>NE(r))}o(Eq,"fromStringNoThrow");var RE=Symbol.for("@ceramicnetwork/streamid/CommitID");function Aq(r,e){return new Bt(r.type,r.cid,e)}o(Aq,"make");var Bt=class{constructor(e,t,n=null){if(this._tag=RE,Jc.set(this,void 0),yf.set(this,void 0),Ol.set(this,void 0),!e&&e!==0)throw new Error("constructor: type required");if(!t)throw new Error("constructor: cid required");iv(this,Jc,typeof e=="string"?In.codeByName(e):e,"f"),iv(this,yf,typeof t=="string"?Ye.parse(t):t,"f"),iv(this,Ol,tv(vs(this,yf,"f"),n),"f")}static isInstance(e){return typeof e=="object"&&"_tag"in e&&e._tag===RE}get baseID(){return new it(vs(this,Jc,"f"),vs(this,yf,"f"))}get type(){return vs(this,Jc,"f")}get typeName(){return In.nameByCode(vs(this,Jc,"f"))}get cid(){return vs(this,yf,"f")}get commit(){return vs(this,Ol,"f")||vs(this,yf,"f")}get bytes(){let e=ov.default.encode(206),t=ov.default.encode(this.type),n=vs(this,Ol,"f")?.bytes||new Uint8Array([0]);return Fi([e,t,this.cid.bytes,n])}equals(e){return this.type===e.type&&this.cid.equals(e.cid)&&this.commit.equals(e.commit)}toString(){return qi.encode(this.bytes)}toUrl(){return`ceramic://${this.toString()}`}[(Jc=new WeakMap,yf=new WeakMap,Ol=new WeakMap,Symbol.for("nodejs.util.inspect.custom"))](){return`CommitID(${this.toString()})`}[Symbol.toPrimitive](){return this.toString()}};o(Bt,"CommitID");Bt.fromBytes=OE;Bt.fromBytesNoThrow=_q;Bt.fromString=NE;Bt.fromStringNoThrow=Eq;Bt.make=Aq;Yc([Zn(),Dn("design:type",it),Dn("design:paramtypes",[])],Bt.prototype,"baseID",null);Yc([Zn(),Dn("design:type",String),Dn("design:paramtypes",[])],Bt.prototype,"typeName",null);Yc([Zn(),Dn("design:type",Ye),Dn("design:paramtypes",[])],Bt.prototype,"commit",null);Yc([Zn(),Dn("design:type",Uint8Array),Dn("design:paramtypes",[])],Bt.prototype,"bytes",null);Yc([Zn(),Dn("design:type",Function),Dn("design:paramtypes",[]),Dn("design:returntype",String)],Bt.prototype,"toString",null);Yc([Zn(),Dn("design:type",Function),Dn("design:paramtypes",[]),Dn("design:returntype",String)],Bt.prototype,"toUrl",null);tc();var dn;(function(r){function e(i){let s=vf(i);switch(s.kind){case"commit-id":return new Bt(s.type,s.genesis,s.commit);case"stream-id":return new it(s.type,s.genesis);default:throw new Error(`Malformed StreamRef bytes: ${qi.encode(i)}`)}}o(e,"fromBytes"),r.fromBytes=e;function t(i){let s=Wc(i);switch(s.kind){case"commit-id":return new Bt(s.type,s.genesis,s.commit);case"stream-id":return new it(s.type,s.genesis);default:throw new Error(`Malformed StreamRef string: ${i}`)}}o(t,"fromString"),r.fromString=t;function n(i){if(it.isInstance(i)||Bt.isInstance(i))return i;if(i instanceof Uint8Array)return e(i);if(typeof i=="string")return t(i);throw new Error(`Can not build CommitID or StreamID from ${JSON.stringify(i)}`)}o(n,"from"),r.from=n})(dn||(dn={}));var sv=o(function(r,e){return sv=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])},sv(r,e)},"extendStatics");function on(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");sv(r,e);function t(){this.constructor=r}o(t,"__"),r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}o(on,"__extends");function PE(r,e,t,n){function i(s){return s instanceof t?s:new t(function(f){f(s)})}return o(i,"adopt"),new(t||(t=Promise))(function(s,f){function u(w){try{y(n.next(w))}catch(A){f(A)}}o(u,"fulfilled");function d(w){try{y(n.throw(w))}catch(A){f(A)}}o(d,"rejected");function y(w){w.done?s(w.value):i(w.value).then(u,d)}o(y,"step"),y((n=n.apply(r,e||[])).next())})}o(PE,"__awaiter");function Z0(r,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,s,f=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return f.next=u(0),f.throw=u(1),f.return=u(2),typeof Symbol=="function"&&(f[Symbol.iterator]=function(){return this}),f;function u(y){return function(w){return d([y,w])}}function d(y){if(n)throw new TypeError("Generator is already executing.");for(;f&&(f=0,y[0]&&(t=0)),t;)try{if(n=1,i&&(s=y[0]&2?i.return:y[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,y[1])).done)return s;switch(i=0,s&&(y=[y[0]&2,s.value]),y[0]){case 0:case 1:s=y;break;case 4:return t.label++,{value:y[1],done:!1};case 5:t.label++,i=y[1],y=[0];continue;case 7:y=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(y[0]===6||y[0]===2)){t=0;continue}if(y[0]===3&&(!s||y[1]>s[0]&&y[1]<s[3])){t.label=y[1];break}if(y[0]===6&&t.label<s[1]){t.label=s[1],s=y;break}if(s&&t.label<s[2]){t.label=s[2],t.ops.push(y);break}s[2]&&t.ops.pop(),t.trys.pop();continue}y=e.call(r,t)}catch(w){y=[6,w],i=0}finally{n=s=0}if(y[0]&5)throw y[1];return{value:y[0]?y[1]:void 0,done:!0}}}o(Z0,"__generator");function ys(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}o(ys,"__values");function Xn(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,s=[],f;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(u){f={error:u}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(f)throw f.error}}return s}o(Xn,"__read");function to(r,e,t){if(t||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return r.concat(s||Array.prototype.slice.call(e))}o(to,"__spreadArray");function xf(r){return this instanceof xf?(this.v=r,this):new xf(r)}o(xf,"__await");function BE(r,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=t.apply(r,e||[]),i,s=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),u("next"),u("throw"),u("return",f),i[Symbol.asyncIterator]=function(){return this},i;function f(R){return function(I){return Promise.resolve(I).then(R,A)}}function u(R,I){n[R]&&(i[R]=function(B){return new Promise(function(Y,P){s.push([R,B,Y,P])>1||d(R,B)})},I&&(i[R]=I(i[R])))}function d(R,I){try{y(n[R](I))}catch(B){O(s[0][3],B)}}function y(R){R.value instanceof xf?Promise.resolve(R.value.v).then(w,A):O(s[0][2],R)}function w(R){d("next",R)}function A(R){d("throw",R)}function O(R,I){R(I),s.shift(),s.length&&d(s[0][0],s[0][1])}}o(BE,"__asyncGenerator");function LE(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof ys=="function"?ys(r):r[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(s){t[s]=r[s]&&function(f){return new Promise(function(u,d){f=r[s](f),i(u,d,f.done,f.value)})}}function i(s,f,u,d){Promise.resolve(d).then(function(y){s({value:y,done:u})},f)}}o(LE,"__asyncValues");function Ct(r){return typeof r=="function"}o(Ct,"isFunction");function Zc(r){var e=o(function(n){Error.call(n),n.stack=new Error().stack},"_super"),t=r(e);return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}o(Zc,"createErrorClass");var X0=Zc(function(r){return o(function(t){r(this),this.message=t?t.length+` errors occurred during unsubscription:
|
|
821
821
|
`+t.map(function(n,i){return i+1+") "+n.toString()}).join(`
|
|
822
|
-
`):"",this.name="UnsubscriptionError",this.errors=t},"UnsubscriptionErrorImpl")});function wf(r,e){if(r){var t=r.indexOf(e);0<=t&&r.splice(t,1)}}o(wf,"arrRemove");var ua=function(){function r(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return o(r,"Subscription"),r.prototype.unsubscribe=function(){var e,t,n,i,s;if(!this.closed){this.closed=!0;var f=this._parentage;if(f)if(this._parentage=null,Array.isArray(f))try{for(var u=ys(f),d=u.next();!d.done;d=u.next()){var y=d.value;y.remove(this)}}catch(B){e={error:B}}finally{try{d&&!d.done&&(t=u.return)&&t.call(u)}finally{if(e)throw e.error}}else f.remove(this);var w=this.initialTeardown;if(Ct(w))try{w()}catch(B){s=B instanceof X0?B.errors:[B]}var A=this._finalizers;if(A){this._finalizers=null;try{for(var O=ys(A),R=O.next();!R.done;R=O.next()){var I=R.value;try{UE(I)}catch(B){s=s??[],B instanceof X0?s=to(to([],Xn(s)),Xn(B.errors)):s.push(B)}}}catch(B){n={error:B}}finally{try{R&&!R.done&&(i=O.return)&&i.call(O)}finally{if(n)throw n.error}}}if(s)throw new X0(s)}},r.prototype.add=function(e){var t;if(e&&e!==this)if(this.closed)UE(e);else{if(e instanceof r){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(t=this._finalizers)!==null&&t!==void 0?t:[]).push(e)}},r.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},r.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},r.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&wf(t,e)},r.prototype.remove=function(e){var t=this._finalizers;t&&wf(t,e),e instanceof r&&e._removeParent(this)},r.EMPTY=function(){var e=new r;return e.closed=!0,e}(),r}();var av=ua.EMPTY;function Q0(r){return r instanceof ua||r&&"closed"in r&&Ct(r.remove)&&Ct(r.add)&&Ct(r.unsubscribe)}o(Q0,"isSubscription");function UE(r){Ct(r)?r():r.unsubscribe()}o(UE,"execFinalizer");var ro={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1};var Xc={setTimeout:function(r,e){for(var t=[],n=2;n<arguments.length;n++)t[n-2]=arguments[n];var i=Xc.delegate;return i?.setTimeout?i.setTimeout.apply(i,to([r,e],Xn(t))):setTimeout.apply(void 0,to([r,e],Xn(t)))},clearTimeout:function(r){var e=Xc.delegate;return(e?.clearTimeout||clearTimeout)(r)},delegate:void 0};function ep(r){Xc.setTimeout(function(){var e=ro.onUnhandledError;if(e)e(r);else throw r})}o(ep,"reportUnhandledError");function fv(){}o(fv,"noop");var FE=function(){return cv("C",void 0,void 0)}();function $E(r){return cv("E",void 0,r)}o($E,"errorNotification");function qE(r){return cv("N",r,void 0)}o(qE,"nextNotification");function cv(r,e,t){return{kind:r,value:e,error:t}}o(cv,"createNotification");var _f=null;function Qc(r){if(ro.useDeprecatedSynchronousErrorHandling){var e=!_f;if(e&&(_f={errorThrown:!1,error:null}),r(),e){var t=_f,n=t.errorThrown,i=t.error;if(_f=null,n)throw i}}else r()}o(Qc,"errorContext");function jE(r){ro.useDeprecatedSynchronousErrorHandling&&_f&&(_f.errorThrown=!0,_f.error=r)}o(jE,"captureError");var Nl=function(r){on(e,r);function e(t){var n=r.call(this)||this;return n.isStopped=!1,t?(n.destination=t,Q0(t)&&t.add(n)):n.destination=Cq,n}return o(e,"Subscriber"),e.create=function(t,n,i){return new rp(t,n,i)},e.prototype.next=function(t){this.isStopped?lv(qE(t),this):this._next(t)},e.prototype.error=function(t){this.isStopped?lv($E(t),this):(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped?lv(FE,this):(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,r.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(ua);var Sq=Function.prototype.bind;function uv(r,e){return Sq.call(r,e)}o(uv,"bind");var Mq=function(){function r(e){this.partialObserver=e}return o(r,"ConsumerObserver"),r.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(n){tp(n)}},r.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(n){tp(n)}else tp(e)},r.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(t){tp(t)}},r}(),rp=function(r){on(e,r);function e(t,n,i){var s=r.call(this)||this,f;if(Ct(t)||!t)f={next:t??void 0,error:n??void 0,complete:i??void 0};else{var u;s&&ro.useDeprecatedNextContext?(u=Object.create(t),u.unsubscribe=function(){return s.unsubscribe()},f={next:t.next&&uv(t.next,u),error:t.error&&uv(t.error,u),complete:t.complete&&uv(t.complete,u)}):f=t}return s.destination=new Mq(f),s}return o(e,"SafeSubscriber"),e}(Nl);function tp(r){ro.useDeprecatedSynchronousErrorHandling?jE(r):ep(r)}o(tp,"handleUnhandledError");function Tq(r){throw r}o(Tq,"defaultErrorHandler");function lv(r,e){var t=ro.onStoppedNotification;t&&Xc.setTimeout(function(){return t(r,e)})}o(lv,"handleStoppedNotification");var Cq={closed:!0,next:fv,error:Tq,complete:fv};var eu=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function tu(r){return r}o(tu,"identity");function HE(r){return r.length===0?tu:r.length===1?r[0]:o(function(t){return r.reduce(function(n,i){return i(n)},t)},"piped")}o(HE,"pipeFromArray");var Yt=function(){function r(e){e&&(this._subscribe=e)}return o(r,"Observable"),r.prototype.lift=function(e){var t=new r;return t.source=this,t.operator=e,t},r.prototype.subscribe=function(e,t,n){var i=this,s=Iq(e)?e:new rp(e,t,n);return Qc(function(){var f=i,u=f.operator,d=f.source;s.add(u?u.call(s,d):d?i._subscribe(s):i._trySubscribe(s))}),s},r.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},r.prototype.forEach=function(e,t){var n=this;return t=zE(t),new t(function(i,s){var f=new rp({next:function(u){try{e(u)}catch(d){s(d),f.unsubscribe()}},error:s,complete:i});n.subscribe(f)})},r.prototype._subscribe=function(e){var t;return(t=this.source)===null||t===void 0?void 0:t.subscribe(e)},r.prototype[eu]=function(){return this},r.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return HE(e)(this)},r.prototype.toPromise=function(e){var t=this;return e=zE(e),new e(function(n,i){var s;t.subscribe(function(f){return s=f},function(f){return i(f)},function(){return n(s)})})},r.create=function(e){return new r(e)},r}();function zE(r){var e;return(e=r??ro.Promise)!==null&&e!==void 0?e:Promise}o(zE,"getPromiseCtor");function kq(r){return r&&Ct(r.next)&&Ct(r.error)&&Ct(r.complete)}o(kq,"isObserver");function Iq(r){return r&&r instanceof Nl||kq(r)&&Q0(r)}o(Iq,"isSubscriber");function Dq(r){return Ct(r?.lift)}o(Dq,"hasLift");function Lr(r){return function(e){if(Dq(e))return e.lift(function(t){try{return r(t,this)}catch(n){this.error(n)}});throw new TypeError("Unable to lift unknown Observable type")}}o(Lr,"operate");function Ur(r,e,t,n,i){return new Rq(r,e,t,n,i)}o(Ur,"createOperatorSubscriber");var Rq=function(r){on(e,r);function e(t,n,i,s,f,u){var d=r.call(this,t)||this;return d.onFinalize=f,d.shouldUnsubscribe=u,d._next=n?function(y){try{n(y)}catch(w){t.error(w)}}:r.prototype._next,d._error=s?function(y){try{s(y)}catch(w){t.error(w)}finally{this.unsubscribe()}}:r.prototype._error,d._complete=i?function(){try{i()}catch(y){t.error(y)}finally{this.unsubscribe()}}:r.prototype._complete,d}return o(e,"OperatorSubscriber"),e.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;r.prototype.unsubscribe.call(this),!n&&((t=this.onFinalize)===null||t===void 0||t.call(this))}},e}(Nl);var KE=Zc(function(r){return o(function(){r(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"},"ObjectUnsubscribedErrorImpl")});var hv=function(r){on(e,r);function e(){var t=r.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return o(e,"Subject"),e.prototype.lift=function(t){var n=new VE(this,this);return n.operator=t,n},e.prototype._throwIfClosed=function(){if(this.closed)throw new KE},e.prototype.next=function(t){var n=this;Qc(function(){var i,s;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var f=ys(n.currentObservers),u=f.next();!u.done;u=f.next()){var d=u.value;d.next(t)}}catch(y){i={error:y}}finally{try{u&&!u.done&&(s=f.return)&&s.call(f)}finally{if(i)throw i.error}}}})},e.prototype.error=function(t){var n=this;Qc(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=t;for(var i=n.observers;i.length;)i.shift().error(t)}})},e.prototype.complete=function(){var t=this;Qc(function(){if(t._throwIfClosed(),!t.isStopped){t.isStopped=!0;for(var n=t.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 t;return((t=this.observers)===null||t===void 0?void 0:t.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(t){return this._throwIfClosed(),r.prototype._trySubscribe.call(this,t)},e.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},e.prototype._innerSubscribe=function(t){var n=this,i=this,s=i.hasError,f=i.isStopped,u=i.observers;return s||f?av:(this.currentObservers=null,u.push(t),new ua(function(){n.currentObservers=null,wf(u,t)}))},e.prototype._checkFinalizedStatuses=function(t){var n=this,i=n.hasError,s=n.thrownError,f=n.isStopped;i?t.error(s):f&&t.complete()},e.prototype.asObservable=function(){var t=new Yt;return t.source=this,t},e.create=function(t,n){return new VE(t,n)},e}(Yt);var VE=function(r){on(e,r);function e(t,n){var i=r.call(this)||this;return i.destination=t,i.source=n,i}return o(e,"AnonymousSubject"),e.prototype.next=function(t){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.next)===null||i===void 0||i.call(n,t)},e.prototype.error=function(t){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.error)===null||i===void 0||i.call(n,t)},e.prototype.complete=function(){var t,n;(n=(t=this.destination)===null||t===void 0?void 0:t.complete)===null||n===void 0||n.call(t)},e.prototype._subscribe=function(t){var n,i;return(i=(n=this.source)===null||n===void 0?void 0:n.subscribe(t))!==null&&i!==void 0?i:av},e}(hv);var dv=function(r){on(e,r);function e(t){var n=r.call(this)||this;return n._value=t,n}return o(e,"BehaviorSubject"),Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),e.prototype._subscribe=function(t){var n=r.prototype._subscribe.call(this,t);return!n.closed&&t.next(this._value),n},e.prototype.getValue=function(){var t=this,n=t.hasError,i=t.thrownError,s=t._value;if(n)throw i;return this._throwIfClosed(),s},e.prototype.next=function(t){r.prototype.next.call(this,this._value=t)},e}(hv);var pv={now:function(){return(pv.delegate||Date).now()},delegate:void 0};var GE=function(r){on(e,r);function e(t,n){return r.call(this)||this}return o(e,"Action"),e.prototype.schedule=function(t,n){return n===void 0&&(n=0),this},e}(ua);var Pl={setInterval:function(r,e){for(var t=[],n=2;n<arguments.length;n++)t[n-2]=arguments[n];var i=Pl.delegate;return i?.setInterval?i.setInterval.apply(i,to([r,e],Xn(t))):setInterval.apply(void 0,to([r,e],Xn(t)))},clearInterval:function(r){var e=Pl.delegate;return(e?.clearInterval||clearInterval)(r)},delegate:void 0};var WE=function(r){on(e,r);function e(t,n){var i=r.call(this,t,n)||this;return i.scheduler=t,i.work=n,i.pending=!1,i}return o(e,"AsyncAction"),e.prototype.schedule=function(t,n){var i;if(n===void 0&&(n=0),this.closed)return this;this.state=t;var s=this.id,f=this.scheduler;return s!=null&&(this.id=this.recycleAsyncId(f,s,n)),this.pending=!0,this.delay=n,this.id=(i=this.id)!==null&&i!==void 0?i:this.requestAsyncId(f,this.id,n),this},e.prototype.requestAsyncId=function(t,n,i){return i===void 0&&(i=0),Pl.setInterval(t.flush.bind(t,this),i)},e.prototype.recycleAsyncId=function(t,n,i){if(i===void 0&&(i=0),i!=null&&this.delay===i&&this.pending===!1)return n;n!=null&&Pl.clearInterval(n)},e.prototype.execute=function(t,n){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var i=this._execute(t,n);if(i)return i;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(t,n){var i=!1,s;try{this.work(t)}catch(f){i=!0,s=f||new Error("Scheduled action threw falsy error")}if(i)return this.unsubscribe(),s},e.prototype.unsubscribe=function(){if(!this.closed){var t=this,n=t.id,i=t.scheduler,s=i.actions;this.work=this.state=this.scheduler=null,this.pending=!1,wf(s,this),n!=null&&(this.id=this.recycleAsyncId(i,n,null)),this.delay=null,r.prototype.unsubscribe.call(this)}},e}(GE);var mv=function(){function r(e,t){t===void 0&&(t=r.now),this.schedulerActionCtor=e,this.now=t}return o(r,"Scheduler"),r.prototype.schedule=function(e,t,n){return t===void 0&&(t=0),new this.schedulerActionCtor(this,e).schedule(n,t)},r.now=pv.now,r}();var JE=function(r){on(e,r);function e(t,n){n===void 0&&(n=mv.now);var i=r.call(this,t,n)||this;return i.actions=[],i._active=!1,i}return o(e,"AsyncScheduler"),e.prototype.flush=function(t){var n=this.actions;if(this._active){n.push(t);return}var i;this._active=!0;do if(i=t.execute(t.state,t.delay))break;while(t=n.shift());if(this._active=!1,i){for(;t=n.shift();)t.unsubscribe();throw i}},e}(mv);var Oq=new JE(WE),YE=Oq;var np=new Yt(function(r){return r.complete()});function ip(r){return r&&Ct(r.schedule)}o(ip,"isScheduler");function ZE(r){return r[r.length-1]}o(ZE,"last");function XE(r){return ip(ZE(r))?r.pop():void 0}o(XE,"popScheduler");function QE(r,e){return typeof ZE(r)=="number"?r.pop():e}o(QE,"popNumber");var ru=o(function(r){return r&&typeof r.length=="number"&&typeof r!="function"},"isArrayLike");function op(r){return Ct(r?.then)}o(op,"isPromise");function sp(r){return Ct(r[eu])}o(sp,"isInteropObservable");function ap(r){return Symbol.asyncIterator&&Ct(r?.[Symbol.asyncIterator])}o(ap,"isAsyncIterable");function fp(r){return new TypeError("You provided "+(r!==null&&typeof r=="object"?"an invalid object":"'"+r+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}o(fp,"createInvalidObservableTypeError");function Nq(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}o(Nq,"getSymbolIterator");var cp=Nq();function up(r){return Ct(r?.[cp])}o(up,"isIterable");function lp(r){return BE(this,arguments,o(function(){var t,n,i,s;return Z0(this,function(f){switch(f.label){case 0:t=r.getReader(),f.label=1;case 1:f.trys.push([1,,9,10]),f.label=2;case 2:return[4,xf(t.read())];case 3:return n=f.sent(),i=n.value,s=n.done,s?[4,xf(void 0)]:[3,5];case 4:return[2,f.sent()];case 5:return[4,xf(i)];case 6:return[4,f.sent()];case 7:return f.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}})},"readableStreamLikeToAsyncGenerator_1"))}o(lp,"readableStreamLikeToAsyncGenerator");function hp(r){return Ct(r?.getReader)}o(hp,"isReadableStreamLike");function sn(r){if(r instanceof Yt)return r;if(r!=null){if(sp(r))return Pq(r);if(ru(r))return Bq(r);if(op(r))return Lq(r);if(ap(r))return e9(r);if(up(r))return Uq(r);if(hp(r))return Fq(r)}throw fp(r)}o(sn,"innerFrom");function Pq(r){return new Yt(function(e){var t=r[eu]();if(Ct(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}o(Pq,"fromInteropObservable");function Bq(r){return new Yt(function(e){for(var t=0;t<r.length&&!e.closed;t++)e.next(r[t]);e.complete()})}o(Bq,"fromArrayLike");function Lq(r){return new Yt(function(e){r.then(function(t){e.closed||(e.next(t),e.complete())},function(t){return e.error(t)}).then(null,ep)})}o(Lq,"fromPromise");function Uq(r){return new Yt(function(e){var t,n;try{for(var i=ys(r),s=i.next();!s.done;s=i.next()){var f=s.value;if(e.next(f),e.closed)return}}catch(u){t={error:u}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}e.complete()})}o(Uq,"fromIterable");function e9(r){return new Yt(function(e){$q(r,e).catch(function(t){return e.error(t)})})}o(e9,"fromAsyncIterable");function Fq(r){return e9(lp(r))}o(Fq,"fromReadableStreamLike");function $q(r,e){var t,n,i,s;return PE(this,void 0,void 0,function(){var f,u;return Z0(this,function(d){switch(d.label){case 0:d.trys.push([0,5,6,11]),t=LE(r),d.label=1;case 1:return[4,t.next()];case 2:if(n=d.sent(),!!n.done)return[3,4];if(f=n.value,e.next(f),e.closed)return[2];d.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return u=d.sent(),i={error:u},[3,11];case 6:return d.trys.push([6,,9,10]),n&&!n.done&&(s=t.return)?[4,s.call(t)]:[3,8];case 7:d.sent(),d.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($q,"process");function Oi(r,e,t,n,i){n===void 0&&(n=0),i===void 0&&(i=!1);var s=e.schedule(function(){t(),i?r.add(this.schedule(null,n)):this.unsubscribe()},n);if(r.add(s),!i)return s}o(Oi,"executeSchedule");function dp(r,e){return e===void 0&&(e=0),Lr(function(t,n){t.subscribe(Ur(n,function(i){return Oi(n,r,function(){return n.next(i)},e)},function(){return Oi(n,r,function(){return n.complete()},e)},function(i){return Oi(n,r,function(){return n.error(i)},e)}))})}o(dp,"observeOn");function pp(r,e){return e===void 0&&(e=0),Lr(function(t,n){n.add(r.schedule(function(){return t.subscribe(n)},e))})}o(pp,"subscribeOn");function t9(r,e){return sn(r).pipe(pp(e),dp(e))}o(t9,"scheduleObservable");function r9(r,e){return sn(r).pipe(pp(e),dp(e))}o(r9,"schedulePromise");function n9(r,e){return new Yt(function(t){var n=0;return e.schedule(function(){n===r.length?t.complete():(t.next(r[n++]),t.closed||this.schedule())})})}o(n9,"scheduleArray");function i9(r,e){return new Yt(function(t){var n;return Oi(t,e,function(){n=r[cp](),Oi(t,e,function(){var i,s,f;try{i=n.next(),s=i.value,f=i.done}catch(u){t.error(u);return}f?t.complete():t.next(s)},0,!0)}),function(){return Ct(n?.return)&&n.return()}})}o(i9,"scheduleIterable");function mp(r,e){if(!r)throw new Error("Iterable cannot be null");return new Yt(function(t){Oi(t,e,function(){var n=r[Symbol.asyncIterator]();Oi(t,e,function(){n.next().then(function(i){i.done?t.complete():t.next(i.value)})},0,!0)})})}o(mp,"scheduleAsyncIterable");function o9(r,e){return mp(lp(r),e)}o(o9,"scheduleReadableStreamLike");function s9(r,e){if(r!=null){if(sp(r))return t9(r,e);if(ru(r))return n9(r,e);if(op(r))return r9(r,e);if(ap(r))return mp(r,e);if(up(r))return i9(r,e);if(hp(r))return o9(r,e)}throw fp(r)}o(s9,"scheduled");function a9(r,e){return e?s9(r,e):sn(r)}o(a9,"from");var bp=Zc(function(r){return o(function(){r(this),this.name="EmptyError",this.message="no elements in sequence"},"EmptyErrorImpl")});function f9(r){return r instanceof Date&&!isNaN(r)}o(f9,"isValidDate");function gp(r,e){return Lr(function(t,n){var i=0;t.subscribe(Ur(n,function(s){n.next(r.call(e,s,i++))}))})}o(gp,"map");var qq=Array.isArray;function jq(r,e){return qq(e)?r.apply(void 0,to([],Xn(e))):r(e)}o(jq,"callOrApply");function c9(r){return gp(function(e){return jq(r,e)})}o(c9,"mapOneOrManyArgs");function u9(r,e,t,n,i,s,f,u){var d=[],y=0,w=0,A=!1,O=o(function(){A&&!d.length&&!y&&e.complete()},"checkComplete"),R=o(function(B){return y<n?I(B):d.push(B)},"outerNext"),I=o(function(B){s&&e.next(B),y++;var Y=!1;sn(t(B,w++)).subscribe(Ur(e,function(P){i?.(P),s?R(P):e.next(P)},function(){Y=!0},void 0,function(){if(Y)try{y--;for(var P=o(function(){var J=d.shift();f?Oi(e,f,function(){return I(J)}):I(J)},"_loop_1");d.length&&y<n;)P();O()}catch(J){e.error(J)}}))},"doInnerSub");return r.subscribe(Ur(e,R,function(){A=!0,O()})),function(){u?.()}}o(u9,"mergeInternals");function Bl(r,e,t){return t===void 0&&(t=1/0),Ct(e)?Bl(function(n,i){return gp(function(s,f){return e(n,s,i,f)})(sn(r(n,i)))},t):(typeof e=="number"&&(t=e),Lr(function(n,i){return u9(n,i,r,t)}))}o(Bl,"mergeMap");function l9(r){return r===void 0&&(r=1/0),Bl(tu,r)}o(l9,"mergeAll");var Hq=["addListener","removeListener"],zq=["addEventListener","removeEventListener"],Kq=["on","off"];function Ll(r,e,t,n){if(Ct(t)&&(n=t,t=void 0),n)return Ll(r,e,t).pipe(c9(n));var i=Xn(Wq(r)?zq.map(function(u){return function(d){return r[u](e,d,t)}}):Vq(r)?Hq.map(h9(r,e)):Gq(r)?Kq.map(h9(r,e)):[],2),s=i[0],f=i[1];if(!s&&ru(r))return Bl(function(u){return Ll(u,e,t)})(sn(r));if(!s)throw new TypeError("Invalid event target");return new Yt(function(u){var d=o(function(){for(var y=[],w=0;w<arguments.length;w++)y[w]=arguments[w];return u.next(1<y.length?y:y[0])},"handler");return s(d),function(){return f(d)}})}o(Ll,"fromEvent");function h9(r,e){return function(t){return function(n){return r[t](e,n)}}}o(h9,"toCommonHandlerRegistry");function Vq(r){return Ct(r.addListener)&&Ct(r.removeListener)}o(Vq,"isNodeStyleEventEmitter");function Gq(r){return Ct(r.on)&&Ct(r.off)}o(Gq,"isJQueryStyleEventEmitter");function Wq(r){return Ct(r.addEventListener)&&Ct(r.removeEventListener)}o(Wq,"isEventTarget");function Ul(r,e,t){r===void 0&&(r=0),t===void 0&&(t=YE);var n=-1;return e!=null&&(ip(e)?t=e:n=e),new Yt(function(i){var s=f9(r)?+r-t.now():r;s<0&&(s=0);var f=0;return t.schedule(function(){i.closed||(i.next(f++),0<=n?this.schedule(void 0,n):i.complete())},s)})}o(Ul,"timer");function bv(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];var t=XE(r),n=QE(r,1/0),i=r;return i.length?i.length===1?sn(i[0]):l9(n)(a9(i,t)):np}o(bv,"merge");function d9(r,e){return Lr(function(t,n){var i=0;t.subscribe(Ur(n,function(s){return r.call(e,s,i++)&&n.next(s)}))})}o(d9,"filter");function p9(r){return Lr(function(e,t){var n=!1;e.subscribe(Ur(t,function(i){n=!0,t.next(i)},function(){n||t.next(r),t.complete()}))})}o(p9,"defaultIfEmpty");function m9(r){return r<=0?function(){return np}:Lr(function(e,t){var n=0;e.subscribe(Ur(t,function(i){++n<=r&&(t.next(i),r<=n&&t.complete())}))})}o(m9,"take");function b9(r){return r===void 0&&(r=Jq),Lr(function(e,t){var n=!1;e.subscribe(Ur(t,function(i){n=!0,t.next(i)},function(){return n?t.complete():t.error(r())}))})}o(b9,"throwIfEmpty");function Jq(){return new bp}o(Jq,"defaultErrorFactory");function gv(r,e){var t=arguments.length>=2;return function(n){return n.pipe(r?d9(function(i,s){return r(i,s,n)}):tu,m9(1),t?p9(e):b9(function(){return new bp}))}}o(gv,"first");function vv(r,e){return Lr(function(t,n){var i=e??{},s=i.leading,f=s===void 0?!0:s,u=i.trailing,d=u===void 0?!1:u,y=!1,w=null,A=null,O=!1,R=o(function(){A?.unsubscribe(),A=null,d&&(Y(),O&&n.complete())},"endThrottling"),I=o(function(){A=null,O&&n.complete()},"cleanupThrottling"),B=o(function(P){return A=sn(r(P)).subscribe(Ur(n,R,I))},"startThrottle"),Y=o(function(){if(y){y=!1;var P=w;w=null,n.next(P),!O&&B(P)}},"send");t.subscribe(Ur(n,function(P){y=!0,w=P,!(A&&!A.closed)&&(f?Y():B(P))},function(){O=!0,!(d&&y&&A&&!A.closed)&&n.complete()}))})}o(vv,"throttle");var g9;(function(r){r[r.GENESIS=0]="GENESIS",r[r.PARTIAL=1]="PARTIAL",r[r.SIGNED=2]="SIGNED"})(g9||(g9={}));var Fl;(function(r){r[r.NOT_REQUESTED=0]="NOT_REQUESTED",r[r.PENDING=1]="PENDING",r[r.PROCESSING=2]="PROCESSING",r[r.ANCHORED=3]="ANCHORED",r[r.FAILED=4]="FAILED"})(Fl||(Fl={}));var xv;(function(r){r[r.GENESIS=0]="GENESIS",r[r.SIGNED=1]="SIGNED",r[r.ANCHOR=2]="ANCHOR"})(xv||(xv={}));var xs=class extends Yt{constructor(e,t){super(n=>{e.subscribe(n)}),this.state$=e,this._context=t}get id(){return new it(this.state$.value.type,this.state$.value.log[0].cid)}get api(){return this._context.api}get content(){let{next:e,content:t}=this.state$.value;return(0,yv.default)(e?.content??t)}get tip(){return this.state$.value.log[this.state$.value.log.length-1].cid}get commitId(){return Bt.make(this.id,this.tip)}get allCommitIds(){return this.state$.value.log.map(({cid:e})=>Bt.make(this.id,e))}get anchorCommitIds(){return this.state$.value.log.filter(({type:e})=>e===xv.ANCHOR).map(({cid:e})=>Bt.make(this.id,e))}get state(){return(0,yv.default)(this.state$.value)}async sync(e={}){e={sync:_r.PREFER_CACHE,...e};let t=await this.api.loadStream(this.id,e);this.state$.next(t.state)}async requestAnchor(){return this.api.requestAnchor(this.id)}};o(xs,"Stream");function nu(){return r=>{}}o(nu,"StreamStatic");var _9=Ft(y9(),1);function x9(r){let e=new AbortController;if(r.length===0)throw Error("Need abort signals to create a merged abort signal");return r.some(t=>t.aborted)?(e.abort(),e.signal):(bv(...r.map(t=>Ll(t,"abort"))).pipe(gv()).subscribe(()=>{e.abort()}),e.signal)}o(x9,"mergeAbortSignals");var $l=class{constructor(e){let t=new AbortController;if(this.signal=t.signal,e<=0){t.abort();return}this._subscription=Ul(e).subscribe(()=>{t.abort()})}clear(){this._subscription?.unsubscribe()}};o($l,"TimedAbortSignal");async function w9(r,e){let t=new AbortController,n=o(()=>{t.abort()},"onAbort");return r.addEventListener("abort",n),r.aborted&&t.abort(),e(t.signal).finally(()=>{r.removeEventListener("abort",n)})}o(w9,"abortable");var Yq=60*1e3*3;async function Vr(r,e={}){e.body&&Object.assign(e,{body:JSON.stringify(e.body),headers:{...e.headers,"Content-Type":"application/json"}});let t=e.timeout||Yq,n=new $l(t),i=e.signal?x9([e.signal,n.signal]):n.signal,s=await w9(i,f=>(0,_9.default)(String(r),{...e,signal:f})).finally(()=>n.clear());if(!s.ok){let f=await s.text();throw new Error(`HTTP request to '${r}' failed with status '${s.statusText}': ${f}`)}return s.json()}o(Vr,"fetchJson");var ql=Ft(Vc(),1);ji();function ws(r){let e=Ye.asCID(r);if(e)return e;if(typeof r=="string")return Ye.parse(r);if(r instanceof Uint8Array)return Ye.decode(r);throw new Error(`${r} cannot be converted to a CID`)}o(ws,"toCID");var E9=0,Qt=class{static streamIdFromState(e){return new it(e.type,e.log[0].cid)}static serializeCommit(e){let t=(0,ql.default)(e);return Qt.isSignedCommitContainer(t)?(t.jws.link=t.jws.link.toString(),t.linkedBlock=Rt(t.linkedBlock,"base64"),t.cacaoBlock&&(t.cacaoBlock=Rt(t.cacaoBlock,"base64")),t):(Qt.isSignedCommit(e)&&(t.link=t.link.toString()),Qt.isAnchorCommit(e)&&(t.proof=t.proof.toString()),t.id&&(t.id=t.id.toString()),t.prev&&(t.prev=t.prev.toString()),e.header?.model&&(t.header.model=Rt(e.header.model,"base64")),t)}static deserializeCommit(e){let t=(0,ql.default)(e);return Qt.isSignedCommitContainer(t)?(t.jws.link=ws(t.jws.link),t.linkedBlock=$t(t.linkedBlock,"base64"),t.cacaoBlock&&(t.cacaoBlock=$t(t.cacaoBlock,"base64")),t):(Qt.isSignedCommit(t)&&(t.link=ws(t.link)),Qt.isAnchorCommit(t)&&(t.proof=ws(t.proof)),t.id&&(t.id=ws(t.id)),t.prev&&(t.prev=ws(t.prev)),t.header?.model&&(t.header.model=$t(t.header.model,"base64")),t)}static serializeState(e){let t=(0,ql.default)(e);return t.log=t.log.map(n=>({...n,cid:n.cid.toString()})),t.anchorStatus!=null&&(t.anchorStatus=Fl[t.anchorStatus]),t.anchorProof!=null&&(t.anchorProof.txHash=t.anchorProof.txHash.toString(),t.anchorProof.root=t.anchorProof.root.toString()),e.metadata?.model&&(t.metadata.model=e.metadata.model.toString()),e.next?.metadata?.model&&(t.next.metadata.model=e.next.metadata.model.toString()),e.metadata?.unique&&e.type!=E9&&(t.metadata.unique=Rt(t.metadata.unique,"base64")),t.doctype=In.nameByCode(t.type),t}static deserializeState(e){if(!e)return null;let t=(0,ql.default)(e);return t.doctype&&(t.type=In.codeByName(t.doctype),delete t.doctype),t.log=t.log.map(n=>({...n,cid:ws(n.cid)})),t.anchorProof&&(t.anchorProof.txHash=ws(t.anchorProof.txHash),t.anchorProof.root=ws(t.anchorProof.root)),t.anchorStatus&&(t.anchorStatus=Fl[t.anchorStatus]),e.metadata?.model&&(t.metadata.model=it.fromString(e.metadata.model)),e.next?.metadata?.model&&(t.next.metadata.model=it.fromString(e.next.metadata.model)),e.metadata?.unique&&e.type!=E9&&(t.metadata.unique=$t(e.metadata.unique,"base64")),t}static statesEqual(e,t){return JSON.stringify(Qt.serializeState(e))===JSON.stringify(Qt.serializeState(t))}static isStateSupersetOf(e,t){if(e.log.length<t.log.length)return!1;for(let n in t.log)if(!e.log[n].cid.equals(t.log[n].cid))return!1;return!(e.log.length===t.log.length&&e.anchorStatus!=t.anchorStatus)}static assertCommitLinksToState(e,t){let n=this.streamIdFromState(e);if(t.id&&!t.id.equals(e.log[0].cid))throw new Error(`Invalid genesis CID in commit for StreamID ${n.toString()}. Found: ${t.id}, expected ${e.log[0].cid}`);let i=e.log[e.log.length-1].cid;if(!t.prev.equals(i))throw new Error(`Commit doesn't properly point to previous commit in log. Expected ${i}, found 'prev' ${t.prev}`)}static async convertCommitToSignedCommitContainer(e,t){if(Qt.isSignedCommit(e)){let n=await t.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(Qt,"StreamUtils");var jl=class extends dv{next(e){let t=this.value;Qt.statesEqual(t,e)||super.next(e)}};o(jl,"StreamStateSubject");var Zq=function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var u=r.length-1;u>=0;u--)(f=r[u])&&(s=(i<3?f(s):i>3?f(e,t,s):f(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},Qn,wv={anchor:!0,publish:!0,pin:!0,sync:_r.PREFER_CACHE},Xq={sync:_r.PREFER_CACHE},A9={anchor:!0,publish:!0,throwOnInvalidCommit:!0};function _v(r,e){if(typeof r?.schema=="string")try{Bt.fromString(r.schema)}catch{throw new Error("Schema must be a CommitID")}let t={controllers:r?.controllers,family:r?.family,schema:r?.schema?.toString(),tags:r?.tags};if(e)r?.deterministic||(t.unique=Rt((0,T9.randomBytes)(12),"base64")),r?.forbidControllerChange&&(t.forbidControllerChange=!0);else{if(r?.deterministic!==void 0||r?.unique!==void 0)throw new Error("Cannot change 'deterministic' or 'unique' properties on existing Streams");if(r?.forbidControllerChange!==void 0)throw new Error("Cannot change 'forbidControllerChange' property on existing Streams")}return Object.keys(t).forEach(n=>t[n]===void 0&&delete t[n]),t}o(_v,"headerFromMetadata");async function S9(r){if(!r.did)throw new Error("No DID provided");return r.did.authenticated||(await r.did.authenticate(),r.loggerProvider&&r.loggerProvider.getDiagnosticsLogger().imp(`Now authenticated as DID ${r.did.id}`)),r.did}o(S9,"getAuthenticatedDID");async function Ev(){throw new Error("Historical stream commits cannot be modified. Load the stream without specifying a commit to make updates.")}o(Ev,"throwReadOnlyError");var ei=Qn=o(class extends xs{constructor(){super(...arguments),this._isReadOnly=!1}get content(){return super.content}get metadata(){let{next:e,metadata:t}=this.state$.value;return(0,M9.default)(e?.metadata??t)}get controllers(){return this.metadata.controllers}static async create(e,t,n,i={}){i={...wv,...i},!n?.deterministic&&i.syncTimeoutSeconds==null&&(i.syncTimeoutSeconds=0);let s=i.asDID?{did:i.asDID}:e,f=await Qn.makeGenesis(s,t,n);return e.createStreamFromGenesis(Qn.STREAM_TYPE_ID,f,i)}static async createFromGenesis(e,t,n={}){n={...wv,...n},t.header?.unique&&n.syncTimeoutSeconds==null&&(n.syncTimeoutSeconds=0);let i=t.data?await Qn._signDagJWS(e,t):t;return e.createStreamFromGenesis(Qn.STREAM_TYPE_ID,i,n)}static async deterministic(e,t,n={}){if(n={...wv,...n},t={...t,deterministic:!0},t.family==null&&t.tags==null)throw new Error("Family and/or tags are required when creating a deterministic tile document");let i=await Qn.makeGenesis(e,null,t);return e.createStreamFromGenesis(Qn.STREAM_TYPE_ID,i,n)}static async load(e,t,n={}){n={...Xq,...n};let i=dn.from(t);if(i.type!=Qn.STREAM_TYPE_ID)throw new Error(`StreamID ${i.toString()} does not refer to a '${Qn.STREAM_TYPE_NAME}' stream, but to a ${i.typeName}`);return e.loadStream(i,n)}async update(e,t,n={}){n={...A9,...n};let i=n.asDID?{did:n.asDID}:this.api,s=await this.makeCommit(i,e,t),f=await this.api.applyCommit(this.id,s,n);this.state$.next(f.state)}async patch(e,t={}){t={...A9,...t};let i={header:_v(this.metadata,!1),data:e,prev:this.tip,id:this.id.cid},s=await Qn._signDagJWS(this.api,i),f=await this.api.applyCommit(this.id,s,t);this.state$.next(f.state)}makeReadOnly(){this.update=Ev,this.patch=Ev,this.sync=Ev,this._isReadOnly=!0}get isReadOnly(){return this._isReadOnly}async makeCommit(e,t,n){let i=await this._makeRawCommit(t,n);return Qn._signDagJWS(e,i)}async _makeRawCommit(e,t){t||(t={});let n=_v(t,!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=U0.compare(this.content,e),s=this.state.log[0];return{header:n,data:i,prev:this.tip,id:s.cid}}static async makeGenesis(e,t,n){if(n||(n={}),!n.controllers||n.controllers.length===0)if(e.did){let f=await S9(e);n.controllers=[f.hasParent?f.parent:f.id]}else throw new Error("No controllers specified");if(n.controllers?.length!==1)throw new Error("Exactly one controller must be specified");let i=_v(n,!0);if(n?.deterministic&&t)throw new Error("Initial content must be null when creating a deterministic Tile document");if(t==null){let f={header:i};return rf(f),f}let s={data:t,header:i};return Qn._signDagJWS(e,s)}static async _signDagJWS(e,t){return(await S9(e)).createDagJWS(t)}},"TileDocument");ei.STREAM_TYPE_NAME="tile";ei.STREAM_TYPE_ID=0;ei=Qn=Zq([nu()],ei);var N9=Ft(I9(),1);function fj(r,e){if(e.has(r))throw new TypeError("Cannot initialize the same private elements twice on an object")}o(fj,"_checkPrivateRedeclaration");function cj(r,e){return e.get?e.get.call(r):e.value}o(cj,"_classApplyDescriptorGet");function uj(r,e,t){if(e.set)e.set.call(r,t);else{if(!e.writable)throw new TypeError("attempted to set read only private field");e.value=t}}o(uj,"_classApplyDescriptorSet");function O9(r,e,t){if(!e.has(r))throw new TypeError("attempted to "+t+" private field on non-instance");return e.get(r)}o(O9,"_classExtractFieldDescriptor");function Tv(r,e){var t=O9(r,e,"get");return cj(r,t)}o(Tv,"_classPrivateFieldGet");function D9(r,e,t){fj(r,e),e.set(r,t)}o(D9,"_classPrivateFieldInit");function R9(r,e,t){var n=O9(r,e,"set");return uj(r,n,t),t}o(R9,"_classPrivateFieldSet");function lj(r){return typeof r=="string"||Bt.isInstance(r)||it.isInstance(r)?{streamId:r}:{streamId:r.streamId,genesis:r.genesis}}o(lj,"keyToQuery");function Cv(r){return typeof r=="string"?dn.from(r).toString():Bt.isInstance(r)||it.isInstance(r)?r.toString():r.streamId.toString()}o(Cv,"keyToString");async function hj(r){let e=await ei.makeGenesis({},null,{...r,deterministic:!0}),t=await it.fromGenesis("tile",e);return{genesis:e,streamId:t}}o(hj,"getDeterministicQuery");var dj=o(()=>Promise.resolve([]),"tempBatchLoadFn"),xp=new WeakMap,kv=new WeakMap,Hl=class extends N9.default{cache(e){if(!Tv(this,kv))return!1;let t=e.id.toString();return this.clear(t).prime(t,e),!0}async create(e,t,n){let i=await ei.create(Tv(this,xp),e,t,n);return this.cache(i),i}async deterministic(e,t){let n=await hj(e);try{return await super.load(n)}catch{let s=await ei.createFromGenesis(Tv(this,xp),n.genesis,t);return this.cache(s),s}}async load(e){return await super.load(e)}async update(e,t,n,i){let s=Cv(e);this.clear(s);let f=await this.load({streamId:s});return await f.update(t,n,i),f}constructor(e){super(dj,{cache:!0,cacheKeyFn:Cv,cacheMap:e.cache!=null&&typeof e.cache!="boolean"?e.cache:void 0}),D9(this,xp,{writable:!0,value:void 0}),D9(this,kv,{writable:!0,value:void 0}),this._batchLoadFn=async t=>{e.cache||this.clearAll();let n=await e.ceramic.multiQuery(t.map(lj),e.multiqueryTimeout);return t.map(i=>{let s=Cv(i),f=n[s];return f||new Error(`Failed to load stream: ${s}`)})},R9(this,xp,e.ceramic),R9(this,kv,!!e.cache)}};o(Hl,"TileLoader");function Iv(r){return typeof r=="string"?it.fromString(r):r}o(Iv,"typeStreamID");function P9(r,e){let t=new URL(r);for(let[n,i]of Object.entries(e))it.isInstance(i)?t.searchParams.set(n,i.toString()):typeof i=="object"?t.searchParams.set(n,JSON.stringify(i)):t.searchParams.set(n,i);return t}o(P9,"serializeObjectToSearchParams");function Dv(r){let e={};for(let[t,n]of Object.entries(r))it.isInstance(n)?e[t]=n.toString():e[t]=n;return e}o(Dv,"serializeObjectForHttpPost");var an=class extends Yt{constructor(e,t,n){super(i=>{this.state$.observers.length===0&&(this.periodicSubscription=Ul(0,n).pipe(vv(()=>this._syncState(this.id,{sync:_r.PREFER_CACHE}))).subscribe()),this.state$.subscribe(i).add(()=>{this.state$.observers.length===0&&this.periodicSubscription?.unsubscribe()})}),this.state$=new jl(e),this._apiUrl=new URL(t)}get value(){return this.state$.value}get state(){return this.state$.value}next(e){this.state$.next(e)}async _syncState(e,t){let n=await an._load(e,this._apiUrl,t);this.state$.next(Qt.deserializeState(n))}get id(){return new it(this.state$.value.type,this.state$.value.log[0].cid)}static async createFromGenesis(e,t,n,i,s){let f=new URL("./streams",e),{state:u}=await Vr(f,{method:"post",body:{type:t,genesis:Qt.serializeCommit(n),opts:i}});return new an(Qt.deserializeState(u),e,s)}static async applyCommit(e,t,n,i,s){let f=new URL("./commits",e),{state:u}=await Vr(f,{method:"post",body:{streamId:t.toString(),commit:Qt.serializeCommit(n),opts:i}});return new an(Qt.deserializeState(u),e,s)}static async _load(e,t,n){let i=P9(new URL(`./streams/${e}`,t),n),{state:s}=await Vr(i);return s}static async load(e,t,n,i){let s=await an._load(e,t,i);return new an(Qt.deserializeState(s),t,n)}static async loadStreamCommits(e,t){let n=new URL(`./commits/${e}`,t),{commits:i}=await Vr(n);return i.map(s=>({cid:s.cid,value:Qt.deserializeCommit(s.value)}))}complete(){this.state$.complete()}};o(an,"Document");var Ef;(function(r){r[r.PREFER_CACHE=0]="PREFER_CACHE",r[r.SYNC_ALWAYS=1]="SYNC_ALWAYS",r[r.NEVER_SYNC=2]="NEVER_SYNC",r[r.SYNC_ON_ERROR=3]="SYNC_ON_ERROR"})(Ef||(Ef={}));var Rv=Ft(Vc(),1);var B9;(function(r){r[r.GENESIS=0]="GENESIS",r[r.PARTIAL=1]="PARTIAL",r[r.SIGNED=2]="SIGNED"})(B9||(B9={}));var Ov;(function(r){r[r.GENESIS=0]="GENESIS",r[r.SIGNED=1]="SIGNED",r[r.ANCHOR=2]="ANCHOR"})(Ov||(Ov={}));var zl=class extends Yt{constructor(e,t){super(n=>{e.subscribe(n)}),this.state$=e,this._context=t}get id(){return new it(this.state$.value.type,this.state$.value.log[0].cid)}get api(){return this._context.api}get content(){let{next:e,content:t}=this.state$.value;return(0,Rv.default)(e?.content??t)}get tip(){return this.state$.value.log[this.state$.value.log.length-1].cid}get commitId(){return Bt.make(this.id,this.tip)}get allCommitIds(){return this.state$.value.log.map(({cid:e})=>Bt.make(this.id,e))}get anchorCommitIds(){return this.state$.value.log.filter(({type:e})=>e===Ov.ANCHOR).map(({cid:e})=>Bt.make(this.id,e))}get state(){return(0,Rv.default)(this.state$.value)}async sync(e={}){e={sync:Ef.PREFER_CACHE,...e};let t=await this.api.loadStream(this.id,e);this.state$.next(t.state)}async requestAnchor(){return this.api.requestAnchor(this.id)}};o(zl,"Stream");function L9(){return r=>{}}o(L9,"StreamStatic");function U9(r){if(typeof r=="string"&&r.includes("@")){let[e,t]=r.split("@");if(!e||!t)throw new Error("Invalid accountId provided");return new na({address:e,chainId:t})}return new na(r)}o(U9,"normalizeAccountId");var pj="(?:%[0-9a-fA-F]{2})",F9=`(?:[a-zA-Z0-9._-]|${pj})`,mj="([a-z0-9]+)",bj=`((?:${F9}*:)*(${F9}+))`,$9="[a-zA-Z0-9_.:%-]",gj=`;${$9}+=${$9}*`,vj=`((${gj})*)`,yj="(/[^#?]*)?",xj="([?][^#]*)?",wj="(#.*)?",_j=new RegExp(`^did:${mj}:${bj}${vj}${yj}${xj}${wj}$`);function q9(r){if(r===""||!r)return null;let e=r.match(_j);if(e){let t={did:`did:${e[1]}:${e[2]}`,method:e[1],id:e[2],didUrl:r};if(e[4]){let n=e[4].slice(1).split(";");t.params={};for(let i of n){let s=i.split("=");t.params[s[0]]=s[1]}}return e[6]&&(t.path=e[6]),e[7]&&(t.query=e[7].slice(1)),e[8]&&(t.fragment=e[8].slice(1)),t}return null}o(q9,"parse");var H9=Ft(Vc(),1);var Ej=function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var u=r.length-1;u>=0;u--)(f=r[u])&&(s=(i<3?f(s):i>3?f(e,t,s):f(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},Af,Nv=o(()=>{throw new Error("Historical stream commits cannot be modified. Load the stream without specifying a commit to make updates.")},"throwReadOnlyError"),j9={anchor:!1,publish:!0,sync:Ef.PREFER_CACHE},Pv={anchor:!0,publish:!0},Aj={sync:Ef.PREFER_CACHE},Sf=Af=o(class extends zl{constructor(){super(...arguments),this._isReadOnly=!1}get did(){return this.content}get metadata(){let{next:e,metadata:t}=this.state$.value;return(0,H9.default)(e?.metadata??t)}get controllers(){return this.metadata.controllers}static async fromAccount(e,t,n={}){n={...j9,...n};let i=U9(t),s=Af.makeGenesis(i);return Af.fromGenesis(e,s,n)}static async fromGenesis(e,t,n={}){return n={...j9,...n},e.createStreamFromGenesis(Af.STREAM_TYPE_ID,t,n)}async setDid(e,t,n={}){n={...Pv,...n};let i=typeof e=="string"?e.trim():e.id;if(q9(i)?.did!==i)throw new Error(`DID is not valid: '${i}'`);let f=await t.createLink(i);return this.setDidProof(f,n)}async setDidProof(e,t={}){t={...Pv,...t};let n=this.makeCommit(e),i=await this.api.applyCommit(this.id,n,t);this.state$.next(i.state)}async clearDid(e,t={}){t={...Pv,...t};let n=await e.createLink("");return this.setDidProof(n,t)}static async load(e,t,n={}){n={...Aj,...n};let i=dn.from(t);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=Nv,this.setDid=Nv,this.sync=Nv,this._isReadOnly=!0}get isReadOnly(){return this._isReadOnly}},"Caip10Link");Sf.STREAM_TYPE_NAME="caip10-link";Sf.STREAM_TYPE_ID=1;Sf=Af=Ej([L9()],Sf);ji();Fa();var SA=Ft(EA(),1);var gH=function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var u=r.length-1;u>=0;u--)(f=r[u])&&(s=(i<3?f(s):i>3?f(e,t,s):f(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},Ro,vH={sync:_r.PREFER_CACHE};async function AA(r){if(r.did==null)throw new Error("No DID provided");r.did.authenticated||(await r.did.authenticate(),r.loggerProvider&&r.loggerProvider.getDiagnosticsLogger().imp(`Now authenticated as DID ${r.did.id}`))}o(AA,"_ensureAuthenticated");async function yH(){throw new Error("Historical stream commits cannot be modified. Load the stream without specifying a commit to make updates.")}o(yH,"throwReadOnlyError");var ha=Ro=o(class extends xs{constructor(){super(...arguments),this._isReadOnly=!1}get content(){return super.content}get metadata(){return{controller:this.state$.value.metadata.controllers[0],model:Ro.MODEL}}static async create(e,t,n){Ro.assertComplete(t);let i={publish:!0,anchor:!0,pin:!0,sync:_r.NEVER_SYNC,throwOnInvalidCommit:!0},s=await Ro._makeGenesis(e,t,n);return await e.createStreamFromGenesis(Ro.STREAM_TYPE_ID,s,i)}static assertComplete(e,t){if(!e.name)throw t?new Error(`Model with StreamID ${t.toString()} is missing a 'name' field`):new Error("Model is missing a 'name' field");if(!e.schema)throw t?new Error(`Model ${e.name} (${t.toString()}) is missing a 'schema' field`):new Error(`Model ${e.name} is missing a 'schema' field`);if(!e.accountRelation)throw t?new Error(`Model ${e.name} (${t.toString()}) is missing a 'accountRelation' field`):new Error(`Model ${e.name} is missing a 'accountRelation' field`)}static async load(e,t,n={}){n={...vH,...n};let i=dn.from(t);if(i.type!=Ro.STREAM_TYPE_ID)throw new Error(`StreamID ${i.toString()} does not refer to a '${Ro.STREAM_TYPE_NAME}' stream, but to a ${i.typeName}`);return await e.loadStream(i,n)}static async _makeGenesis(e,t,n){let i=await this._makeRawGenesis(e,t,n);return Ro._signDagJWS(e,i)}static async _makeRawGenesis(e,t,n){if(t==null)throw new Error("Genesis content cannot be null");if(!n||!n.controller)if(e.did)await AA(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:Ro.MODEL.bytes};return{data:t,header:i}}makeReadOnly(){this.sync=yH,this._isReadOnly=!0}get isReadOnly(){return this._isReadOnly}static async _signDagJWS(e,t){return await AA(e),e.did.createDagJWS(t)}},"Model");ha.STREAM_TYPE_NAME="model";ha.STREAM_TYPE_ID=2;ha.MODEL=function(){let r=rf("model-v1"),e=SA.default.encode(r,"identity"),t=ts(Mc,e),n=Ye.createV1(Mc,t);return new it("UNLOADABLE",n)}();ha=Ro=gH([nu()],ha);var CA=Ft(Ga(),1);var xH=function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var u=r.length-1;u>=0;u--)(f=r[u])&&(s=(i<3?f(s):i>3?f(e,t,s):f(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},no,wH={anchor:!0,publish:!0,pin:!0,sync:_r.NEVER_SYNC,syncTimeoutSeconds:0},_H={anchor:!1,publish:!1,pin:!0,sync:_r.PREFER_CACHE},EH={sync:_r.PREFER_CACHE},MA={anchor:!0,publish:!0,throwOnInvalidCommit:!0};async function TA(r){if(r.did==null)throw new Error("No DID provided");r.did.authenticated||(await r.did.authenticate(),r.loggerProvider&&r.loggerProvider.getDiagnosticsLogger().imp(`Now authenticated as DID ${r.did.id}`))}o(TA,"_ensureAuthenticated");async function Uv(){throw new Error("Historical stream commits cannot be modified. Load the stream without specifying a commit to make updates.")}o(Uv,"throwReadOnlyError");var Tf=no=o(class extends xs{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,t,n,i={}){i={...wH,...i};let s=i.asDID?{did:i.asDID}:e,f=await no._makeGenesis(s,t,n);return e.createStreamFromGenesis(no.STREAM_TYPE_ID,f,i)}static async single(e,t,n={}){n={..._H,...n};let i=n.asDID?{did:n.asDID}:e;t={...t,deterministic:!0};let s=await no._makeGenesis(i,null,t);return e.createStreamFromGenesis(no.STREAM_TYPE_ID,s,n)}static async load(e,t,n={}){n={...EH,...n};let i=dn.from(t);if(i.type!=no.STREAM_TYPE_ID)throw new Error(`StreamID ${i.toString()} does not refer to a '${no.STREAM_TYPE_NAME}' stream, but to a ${i.typeName}`);return e.loadStream(i,n)}async replace(e,t={}){t={...MA,...t};let n=t.asDID?{did:t.asDID}:this.api,i=await this._makeCommit(n,e),s=await this.api.applyCommit(this.id,i,t);this.state$.next(s.state)}async patch(e,t={}){t={...MA,...t};let n={data:e,prev:this.tip,id:this.id.cid},i=await no._signDagJWS(this.api,n),s=await this.api.applyCommit(this.id,i,t);this.state$.next(s.state)}makeReadOnly(){this.replace=Uv,this.patch=Uv,this.sync=Uv,this._isReadOnly=!0}get isReadOnly(){return this._isReadOnly}_makeCommit(e,t){let n=this._makeRawCommit(t);return no._signDagJWS(e,n)}_makeRawCommit(e){return{data:U0.compare(this.content,e||{}),prev:this.tip,id:this.state.log[0].cid}}static async _makeGenesis(e,t,n){let i=await this._makeRawGenesis(e,t,n);return n.deterministic?(rf(i),i):no._signDagJWS(e,i)}static async _makeRawGenesis(e,t,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 TA(e),i=e.did.hasParent?e.did.parent:e.did.id;else throw new Error("No controller specified");let s={controllers:[i],model:n.model.bytes};return n.deterministic||(s.unique=(0,CA.randomBytes)(12)),{data:t,header:s}}static async _signDagJWS(e,t){return await TA(e),e.did.createDagJWS(t)}},"ModelInstanceDocument");Tf.STREAM_TYPE_NAME="MID";Tf.STREAM_TYPE_ID=3;Tf=no=xH([nu()],Tf);var Gl=class{constructor(e){this._apiUrl=e}async add(e,t){let n={};t&&(n.force=!0);let i=new URL(`./pins/${e}`,this._apiUrl);await Vr(i,{method:"post",body:n})}async rm(e,t){let n=new URL(`./pins/${e}`,this._apiUrl);await Vr(n,{method:"delete",body:{opts:t}})}async ls(e){let t=new URL("./pins",this._apiUrl);e&&(t=new URL(`./pins/${e.toString()}`,this._apiUrl));let n=await Vr(t),{pinnedStreamIds:i}=n;return{[Symbol.asyncIterator](){let s=0;return{next(){return s===i.length?Promise.resolve({value:null,done:!0}):Promise.resolve({value:i[s++],done:!1})}}}}}};o(Gl,"RemotePinApi");var Wl=class{constructor(e){this._fetchJson=Vr,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:Dv(e)})).count}async query(e){let t=await this._fetchJson(this._collectionURL,{method:"POST",body:Dv(e)});return{edges:t.edges.map(i=>({cursor:i.cursor,node:Qt.deserializeState(i.node)})),pageInfo:t.pageInfo}}};o(Wl,"RemoteIndexApi");var Jl=class{constructor(e,t){this._apiUrl=e,this._getDidFn=t,this._fetchJson=Vr,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,t,n){let i=n?{models:n.map(f=>f.toString())}:void 0,s=await e.createJWS({code:t,requestPath:this.getModelsUrl().pathname,requestBody:i});return`${s.signatures[0].protected}.${s.payload}.${s.signatures[0].signature}`}async generateCode(){return(await this._fetchJson(this.getCodeUrl())).code}async startIndexingModels(e){let t=await this.generateCode();await this._fetchJson(this.getModelsUrl(),{method:"post",body:{jws:await this.buildJWS(this._getDidFn(),t,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=>it.fromString(n))}async stopIndexingModels(e){let t=await this.generateCode();await this._fetchJson(this.getModelsUrl(),{method:"delete",body:{jws:await this.buildJWS(this._getDidFn(),t,e)}})}};o(Jl,"RemoteAdminApi");var AH="/api/v0/",SH="http://localhost:7007",MH={syncInterval:5e3},TH={anchor:!0,publish:!0,sync:_r.PREFER_CACHE},CH={anchor:!0,publish:!0,sync:_r.PREFER_CACHE},kA={sync:_r.PREFER_CACHE},Yl=class{constructor(e=SH,t={}){this._config={...MH,...t},this._apiUrl=new URL(AH,e),this._streamCache=new Map,this.context={api:this},this.pin=new Gl(this._apiUrl),this.index=new Wl(this._apiUrl);let n=(()=>this.did).bind(this);this.admin=new Jl(this._apiUrl,n),this._streamConstructors={[Sf.STREAM_TYPE_ID]:Sf,[ha.STREAM_TYPE_ID]:ha,[Tf.STREAM_TYPE_ID]:Tf,[ei.STREAM_TYPE_ID]:ei}}get did(){return this.context.did}set did(e){this.context.did=e}async createStreamFromGenesis(e,t,n={}){n={...CH,...n};let i=await an.createFromGenesis(this._apiUrl,e,t,n,this._config.syncInterval),s=this._streamCache.get(i.id.toString());return s?(Qt.statesEqual(i.state,s.state)||s.next(i.state),this.buildStreamFromDocument(s)):(this._streamCache.set(i.id.toString(),i),this.buildStreamFromDocument(i))}async loadStream(e,t={}){t={...kA,...t};let n=dn.from(e),i=this._streamCache.get(n.baseID.toString());return i?await i._syncState(n,t):(i=await an.load(n,this._apiUrl,this._config.syncInterval,t),this._streamCache.set(i.id.toString(),i)),this.buildStreamFromDocument(i)}async multiQuery(e,t){let n=e.map(f=>({...f,streamId:typeof f.streamId=="string"?f.streamId:f.streamId.toString()})),i=new URL("./multiqueries",this._apiUrl),s=await Vr(i,{method:"post",body:{queries:n,timeout:t}});return Object.entries(s).reduce((f,u)=>{let[d,y]=u,w=Qt.deserializeState(y),A=new an(w,this._apiUrl,this._config.syncInterval);return f[d]=this.buildStreamFromDocument(A),f},{})}loadStreamCommits(e){let t=Iv(e);return an.loadStreamCommits(t,this._apiUrl)}async applyCommit(e,t,n={}){n={...TH,...n};let i=Iv(e),s=await an.applyCommit(this._apiUrl,i,t,n,this._config.syncInterval),f=this._streamCache.get(i.toString());return f?(f.next(s.state),this.buildStreamFromDocument(s)):(this._streamCache.set(i.toString(),s),this.buildStreamFromDocument(s))}async requestAnchor(e,t={}){t={...kA,...t};let{anchorStatus:n}=await Vr(`${this._apiUrl}/streams/${e.toString()}/anchor`,{method:"post",body:{opts:t}});return n}addStreamHandler(e){this._streamConstructors[e.name]=e.stream_constructor}buildStreamFromState(e){let t=new an(e,this._apiUrl,this._config.syncInterval);return this.buildStreamFromDocument(t)}buildStreamFromDocument(e){let t=e.state.type,n=this._streamConstructors[t];if(!n)throw new Error(`Failed to find constructor for stream ${t}`);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 Vr(this._apiUrl+"/node/chains");return this._supportedChains=e,e}async close(){Array.from(this._streamCache).map(([,e])=>{e.complete()}),this._streamCache.clear()}};o(Yl,"CeramicClient");var Lt;(function(r){r.assertEqual=i=>i;function e(i){}o(e,"assertIs"),r.assertIs=e;function t(i){throw new Error}o(t,"assertNever"),r.assertNever=t,r.arrayToEnum=i=>{let s={};for(let f of i)s[f]=f;return s},r.getValidEnumValues=i=>{let s=r.objectKeys(i).filter(u=>typeof i[i[u]]!="number"),f={};for(let u of s)f[u]=i[u];return r.objectValues(f)},r.objectValues=i=>r.objectKeys(i).map(function(s){return i[s]}),r.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let s=[];for(let f in i)Object.prototype.hasOwnProperty.call(i,f)&&s.push(f);return s},r.find=(i,s)=>{for(let f of i)if(s(f))return f},r.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,s=" | "){return i.map(f=>typeof f=="string"?`'${f}'`:f).join(s)}o(n,"joinValues"),r.joinValues=n,r.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(Lt||(Lt={}));var $v;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})($v||($v={}));var je=Lt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),da=o(r=>{switch(typeof r){case"undefined":return je.undefined;case"string":return je.string;case"number":return isNaN(r)?je.nan:je.number;case"boolean":return je.boolean;case"function":return je.function;case"bigint":return je.bigint;case"symbol":return je.symbol;case"object":return Array.isArray(r)?je.array:r===null?je.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?je.promise:typeof Map<"u"&&r instanceof Map?je.map:typeof Set<"u"&&r instanceof Set?je.set:typeof Date<"u"&&r instanceof Date?je.date:je.object;default:return je.unknown}},"getParsedType"),Oe=Lt.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"]),kH=o(r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:"),"quotelessJson"),fn=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 t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){let t=e||function(s){return s.message},n={_errors:[]},i=o(s=>{for(let f of s.issues)if(f.code==="invalid_union")f.unionErrors.map(i);else if(f.code==="invalid_return_type")i(f.returnTypeError);else if(f.code==="invalid_arguments")i(f.argumentsError);else if(f.path.length===0)n._errors.push(t(f));else{let u=n,d=0;for(;d<f.path.length;){let y=f.path[d];d===f.path.length-1?(u[y]=u[y]||{_errors:[]},u[y]._errors.push(t(f))):u[y]=u[y]||{_errors:[]},u=u[y],d++}}},"processError");return i(this),n}static assert(e){if(!(e instanceof fn))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Lt.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){let t={},n=[];for(let i of this.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};o(fn,"ZodError");fn.create=r=>new fn(r);var lu=o((r,e)=>{let t;switch(r.code){case Oe.invalid_type:r.received===je.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case Oe.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Lt.jsonStringifyReplacer)}`;break;case Oe.unrecognized_keys:t=`Unrecognized key(s) in object: ${Lt.joinValues(r.keys,", ")}`;break;case Oe.invalid_union:t="Invalid input";break;case Oe.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Lt.joinValues(r.options)}`;break;case Oe.invalid_enum_value:t=`Invalid enum value. Expected ${Lt.joinValues(r.options)}, received '${r.received}'`;break;case Oe.invalid_arguments:t="Invalid function arguments";break;case Oe.invalid_return_type:t="Invalid function return type";break;case Oe.invalid_date:t="Invalid date";break;case Oe.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:Lt.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case Oe.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case Oe.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case Oe.custom:t="Invalid input";break;case Oe.invalid_intersection_types:t="Intersection results could not be merged";break;case Oe.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case Oe.not_finite:t="Number must be finite";break;default:t=e.defaultError,Lt.assertNever(r)}return{message:t}},"errorMap"),RA=lu;function IH(r){RA=r}o(IH,"setErrorMap");function Sp(){return RA}o(Sp,"getErrorMap");var Mp=o(r=>{let{data:e,path:t,errorMaps:n,issueData:i}=r,s=[...t,...i.path||[]],f={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let u="",d=n.filter(y=>!!y).slice().reverse();for(let y of d)u=y(f,{data:e,defaultError:u}).message;return{...i,path:s,message:u}},"makeIssue"),DH=[];function $e(r,e){let t=Sp(),n=Mp({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===lu?void 0:lu].filter(i=>!!i)});r.common.issues.push(n)}o($e,"addIssueToContext");var Tr=class{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){let n=[];for(let i of t){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,t){let n=[];for(let i of t){let s=await i.key,f=await i.value;n.push({key:s,value:f})}return Tr.mergeObjectSync(e,n)}static mergeObjectSync(e,t){let n={};for(let i of t){let{key:s,value:f}=i;if(s.status==="aborted"||f.status==="aborted")return gt;s.status==="dirty"&&e.dirty(),f.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof f.value<"u"||i.alwaysSet)&&(n[s.value]=f.value)}return{status:e.value,value:n}}};o(Tr,"ParseStatus");var gt=Object.freeze({status:"aborted"}),cu=o(r=>({status:"dirty",value:r}),"DIRTY"),pn=o(r=>({status:"valid",value:r}),"OK"),qv=o(r=>r.status==="aborted","isAborted"),jv=o(r=>r.status==="dirty","isDirty"),Ql=o(r=>r.status==="valid","isValid"),eh=o(r=>typeof Promise<"u"&&r instanceof Promise,"isAsync");function Tp(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)}o(Tp,"__classPrivateFieldGet");function OA(r,e,t,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"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t}o(OA,"__classPrivateFieldSet");var Ge;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e?.message})(Ge||(Ge={}));var Zl,Xl,ti=class{constructor(e,t,n,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}};o(ti,"ParseInputLazyPath");var IA=o((r,e)=>{if(Ql(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new fn(r.common.issues);return this._error=t,this._error}}},"handleResult");function At(r){if(!r)return{};let{errorMap:e,invalid_type_error:t,required_error:n,description:i}=r;if(e&&(t||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((f,u)=>{var d,y;let{message:w}=r;return f.code==="invalid_enum_value"?{message:w??u.defaultError}:typeof u.data>"u"?{message:(d=w??n)!==null&&d!==void 0?d:u.defaultError}:f.code!=="invalid_type"?{message:u.defaultError}:{message:(y=w??t)!==null&&y!==void 0?y:u.defaultError}},"customMap"),description:i}}o(At,"processCreateParams");var _t=class{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return da(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:da(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Tr,ctx:{common:e.parent.common,data:e.data,parsedType:da(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(eh(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;let i={common:{issues:[],async:(n=t?.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:da(e)},s=this._parseSync({data:e,path:i.path,parent:i});return IA(i,s)}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:da(e)},i=this._parse({data:e,path:n.path,parent:n}),s=await(eh(i)?i:Promise.resolve(i));return IA(n,s)}refine(e,t){let n=o(i=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(i):t,"getIssueProperties");return this._refinement((i,s)=>{let f=e(i),u=o(()=>s.addIssue({code:Oe.custom,...n(i)}),"setError");return typeof Promise<"u"&&f instanceof Promise?f.then(d=>d?!0:(u(),!1)):f?!0:(u(),!1)})}refinement(e,t){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof t=="function"?t(n,i):t),!1))}_refinement(e){return new Nn({schema:this,typeName:ot.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return ni.create(this,this._def)}nullable(){return ao.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return On.create(this,this._def)}promise(){return Ms.create(this,this._def)}or(e){return ga.create([this,e],this._def)}and(e){return va.create(this,e,this._def)}transform(e){return new Nn({...At(this._def),schema:this,typeName:ot.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e=="function"?e:()=>e;return new Ea({...At(this._def),innerType:this,defaultValue:t,typeName:ot.ZodDefault})}brand(){return new uu({typeName:ot.ZodBranded,type:this,...At(this._def)})}catch(e){let t=typeof e=="function"?e:()=>e;return new Aa({...At(this._def),innerType:this,catchValue:t,typeName:ot.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Sa.create(this,e)}readonly(){return Ma.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};o(_t,"ZodType");var RH=/^c[^\s-]{8,}$/i,OH=/^[0-9a-z]+$/,NH=/^[0-9A-HJKMNP-TV-Z]{26}$/,PH=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,BH=/^[a-z0-9_-]{21}$/i,LH=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,UH=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,FH="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Fv,$H=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,qH=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,jH=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,NA="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",HH=new RegExp(`^${NA}$`);function PA(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}o(PA,"timeRegexSource");function zH(r){return new RegExp(`^${PA(r)}$`)}o(zH,"timeRegex");function BA(r){let e=`${NA}T${PA(r)}`,t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}o(BA,"datetimeRegex");function KH(r,e){return!!((e==="v4"||!e)&&$H.test(r)||(e==="v6"||!e)&&qH.test(r))}o(KH,"isValidIP");var Rn=class extends _t{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==je.string){let s=this._getOrReturnCtx(e);return $e(s,{code:Oe.invalid_type,expected:je.string,received:s.parsedType}),gt}let n=new Tr,i;for(let s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(i=this._getOrReturnCtx(e,i),$e(i,{code:Oe.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="max")e.data.length>s.value&&(i=this._getOrReturnCtx(e,i),$e(i,{code:Oe.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="length"){let f=e.data.length>s.value,u=e.data.length<s.value;(f||u)&&(i=this._getOrReturnCtx(e,i),f?$e(i,{code:Oe.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):u&&$e(i,{code:Oe.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")UH.test(e.data)||(i=this._getOrReturnCtx(e,i),$e(i,{validation:"email",code:Oe.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")Fv||(Fv=new RegExp(FH,"u")),Fv.test(e.data)||(i=this._getOrReturnCtx(e,i),$e(i,{validation:"emoji",code:Oe.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")PH.test(e.data)||(i=this._getOrReturnCtx(e,i),$e(i,{validation:"uuid",code:Oe.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")BH.test(e.data)||(i=this._getOrReturnCtx(e,i),$e(i,{validation:"nanoid",code:Oe.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")RH.test(e.data)||(i=this._getOrReturnCtx(e,i),$e(i,{validation:"cuid",code:Oe.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")OH.test(e.data)||(i=this._getOrReturnCtx(e,i),$e(i,{validation:"cuid2",code:Oe.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")NH.test(e.data)||(i=this._getOrReturnCtx(e,i),$e(i,{validation:"ulid",code:Oe.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),$e(i,{validation:"url",code:Oe.invalid_string,message:s.message}),n.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),$e(i,{validation:"regex",code:Oe.invalid_string,message:s.message}),n.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(e,i),$e(i,{code:Oe.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),n.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(i=this._getOrReturnCtx(e,i),$e(i,{code:Oe.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(i=this._getOrReturnCtx(e,i),$e(i,{code:Oe.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?BA(s).test(e.data)||(i=this._getOrReturnCtx(e,i),$e(i,{code:Oe.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?HH.test(e.data)||(i=this._getOrReturnCtx(e,i),$e(i,{code:Oe.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?zH(s).test(e.data)||(i=this._getOrReturnCtx(e,i),$e(i,{code:Oe.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?LH.test(e.data)||(i=this._getOrReturnCtx(e,i),$e(i,{validation:"duration",code:Oe.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?KH(e.data,s.version)||(i=this._getOrReturnCtx(e,i),$e(i,{validation:"ip",code:Oe.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?jH.test(e.data)||(i=this._getOrReturnCtx(e,i),$e(i,{validation:"base64",code:Oe.invalid_string,message:s.message}),n.dirty()):Lt.assertNever(s);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(i=>e.test(i),{validation:t,code:Oe.invalid_string,...Ge.errToObj(n)})}_addCheck(e){return new Rn({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Ge.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Ge.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Ge.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Ge.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Ge.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Ge.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Ge.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Ge.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Ge.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Ge.errToObj(e)})}datetime(e){var t,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:(t=e?.offset)!==null&&t!==void 0?t:!1,local:(n=e?.local)!==null&&n!==void 0?n:!1,...Ge.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...Ge.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...Ge.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Ge.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...Ge.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Ge.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Ge.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Ge.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Ge.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Ge.errToObj(t)})}nonempty(e){return this.min(1,Ge.errToObj(e))}trim(){return new Rn({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Rn({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Rn({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get minLength(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};o(Rn,"ZodString");Rn.create=r=>{var e;return new Rn({checks:[],typeName:ot.ZodString,coerce:(e=r?.coerce)!==null&&e!==void 0?e:!1,...At(r)})};function VH(r,e){let t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=t>n?t:n,s=parseInt(r.toFixed(i).replace(".","")),f=parseInt(e.toFixed(i).replace(".",""));return s%f/Math.pow(10,i)}o(VH,"floatSafeRemainder");var io=class extends _t{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)!==je.number){let s=this._getOrReturnCtx(e);return $e(s,{code:Oe.invalid_type,expected:je.number,received:s.parsedType}),gt}let n,i=new Tr;for(let s of this._def.checks)s.kind==="int"?Lt.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),$e(n,{code:Oe.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),$e(n,{code:Oe.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),$e(n,{code:Oe.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?VH(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),$e(n,{code:Oe.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),$e(n,{code:Oe.not_finite,message:s.message}),i.dirty()):Lt.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Ge.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Ge.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Ge.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Ge.toString(t))}setLimit(e,t,n,i){return new io({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Ge.toString(i)}]})}_addCheck(e){return new io({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Ge.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Ge.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Ge.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Ge.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Ge.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Ge.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Ge.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Ge.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Ge.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Lt.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}};o(io,"ZodNumber");io.create=r=>new io({checks:[],typeName:ot.ZodNumber,coerce:r?.coerce||!1,...At(r)});var oo=class extends _t{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==je.bigint){let s=this._getOrReturnCtx(e);return $e(s,{code:Oe.invalid_type,expected:je.bigint,received:s.parsedType}),gt}let n,i=new Tr;for(let s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),$e(n,{code:Oe.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),$e(n,{code:Oe.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),$e(n,{code:Oe.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):Lt.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Ge.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Ge.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Ge.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Ge.toString(t))}setLimit(e,t,n,i){return new oo({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Ge.toString(i)}]})}_addCheck(e){return new oo({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Ge.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Ge.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Ge.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Ge.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Ge.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};o(oo,"ZodBigInt");oo.create=r=>{var e;return new oo({checks:[],typeName:ot.ZodBigInt,coerce:(e=r?.coerce)!==null&&e!==void 0?e:!1,...At(r)})};var pa=class extends _t{_parse(e){if(this._def.coerce&&(e.data=Boolean(e.data)),this._getType(e)!==je.boolean){let n=this._getOrReturnCtx(e);return $e(n,{code:Oe.invalid_type,expected:je.boolean,received:n.parsedType}),gt}return pn(e.data)}};o(pa,"ZodBoolean");pa.create=r=>new pa({typeName:ot.ZodBoolean,coerce:r?.coerce||!1,...At(r)});var Oo=class extends _t{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==je.date){let s=this._getOrReturnCtx(e);return $e(s,{code:Oe.invalid_type,expected:je.date,received:s.parsedType}),gt}if(isNaN(e.data.getTime())){let s=this._getOrReturnCtx(e);return $e(s,{code:Oe.invalid_date}),gt}let n=new Tr,i;for(let s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(i=this._getOrReturnCtx(e,i),$e(i,{code:Oe.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),n.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(i=this._getOrReturnCtx(e,i),$e(i,{code:Oe.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):Lt.assertNever(s);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Oo({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Ge.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Ge.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};o(Oo,"ZodDate");Oo.create=r=>new Oo({checks:[],coerce:r?.coerce||!1,typeName:ot.ZodDate,...At(r)});var Cf=class extends _t{_parse(e){if(this._getType(e)!==je.symbol){let n=this._getOrReturnCtx(e);return $e(n,{code:Oe.invalid_type,expected:je.symbol,received:n.parsedType}),gt}return pn(e.data)}};o(Cf,"ZodSymbol");Cf.create=r=>new Cf({typeName:ot.ZodSymbol,...At(r)});var ma=class extends _t{_parse(e){if(this._getType(e)!==je.undefined){let n=this._getOrReturnCtx(e);return $e(n,{code:Oe.invalid_type,expected:je.undefined,received:n.parsedType}),gt}return pn(e.data)}};o(ma,"ZodUndefined");ma.create=r=>new ma({typeName:ot.ZodUndefined,...At(r)});var ba=class extends _t{_parse(e){if(this._getType(e)!==je.null){let n=this._getOrReturnCtx(e);return $e(n,{code:Oe.invalid_type,expected:je.null,received:n.parsedType}),gt}return pn(e.data)}};o(ba,"ZodNull");ba.create=r=>new ba({typeName:ot.ZodNull,...At(r)});var As=class extends _t{constructor(){super(...arguments),this._any=!0}_parse(e){return pn(e.data)}};o(As,"ZodAny");As.create=r=>new As({typeName:ot.ZodAny,...At(r)});var No=class extends _t{constructor(){super(...arguments),this._unknown=!0}_parse(e){return pn(e.data)}};o(No,"ZodUnknown");No.create=r=>new No({typeName:ot.ZodUnknown,...At(r)});var Ni=class extends _t{_parse(e){let t=this._getOrReturnCtx(e);return $e(t,{code:Oe.invalid_type,expected:je.never,received:t.parsedType}),gt}};o(Ni,"ZodNever");Ni.create=r=>new Ni({typeName:ot.ZodNever,...At(r)});var kf=class extends _t{_parse(e){if(this._getType(e)!==je.undefined){let n=this._getOrReturnCtx(e);return $e(n,{code:Oe.invalid_type,expected:je.void,received:n.parsedType}),gt}return pn(e.data)}};o(kf,"ZodVoid");kf.create=r=>new kf({typeName:ot.ZodVoid,...At(r)});var On=class extends _t{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),i=this._def;if(t.parsedType!==je.array)return $e(t,{code:Oe.invalid_type,expected:je.array,received:t.parsedType}),gt;if(i.exactLength!==null){let f=t.data.length>i.exactLength.value,u=t.data.length<i.exactLength.value;(f||u)&&($e(t,{code:f?Oe.too_big:Oe.too_small,minimum:u?i.exactLength.value:void 0,maximum:f?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&t.data.length<i.minLength.value&&($e(t,{code:Oe.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&t.data.length>i.maxLength.value&&($e(t,{code:Oe.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((f,u)=>i.type._parseAsync(new ti(t,f,t.path,u)))).then(f=>Tr.mergeArray(n,f));let s=[...t.data].map((f,u)=>i.type._parseSync(new ti(t,f,t.path,u)));return Tr.mergeArray(n,s)}get element(){return this._def.type}min(e,t){return new On({...this._def,minLength:{value:e,message:Ge.toString(t)}})}max(e,t){return new On({...this._def,maxLength:{value:e,message:Ge.toString(t)}})}length(e,t){return new On({...this._def,exactLength:{value:e,message:Ge.toString(t)}})}nonempty(e){return this.min(1,e)}};o(On,"ZodArray");On.create=(r,e)=>new On({type:r,minLength:null,maxLength:null,exactLength:null,typeName:ot.ZodArray,...At(e)});function fu(r){if(r instanceof sr){let e={};for(let t in r.shape){let n=r.shape[t];e[t]=ni.create(fu(n))}return new sr({...r._def,shape:()=>e})}else return r instanceof On?new On({...r._def,type:fu(r.element)}):r instanceof ni?ni.create(fu(r.unwrap())):r instanceof ao?ao.create(fu(r.unwrap())):r instanceof ri?ri.create(r.items.map(e=>fu(e))):r}o(fu,"deepPartialify");var sr=class extends _t{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=Lt.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==je.object){let y=this._getOrReturnCtx(e);return $e(y,{code:Oe.invalid_type,expected:je.object,received:y.parsedType}),gt}let{status:n,ctx:i}=this._processInputParams(e),{shape:s,keys:f}=this._getCached(),u=[];if(!(this._def.catchall instanceof Ni&&this._def.unknownKeys==="strip"))for(let y in i.data)f.includes(y)||u.push(y);let d=[];for(let y of f){let w=s[y],A=i.data[y];d.push({key:{status:"valid",value:y},value:w._parse(new ti(i,A,i.path,y)),alwaysSet:y in i.data})}if(this._def.catchall instanceof Ni){let y=this._def.unknownKeys;if(y==="passthrough")for(let w of u)d.push({key:{status:"valid",value:w},value:{status:"valid",value:i.data[w]}});else if(y==="strict")u.length>0&&($e(i,{code:Oe.unrecognized_keys,keys:u}),n.dirty());else if(y!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let y=this._def.catchall;for(let w of u){let A=i.data[w];d.push({key:{status:"valid",value:w},value:y._parse(new ti(i,A,i.path,w)),alwaysSet:w in i.data})}}return i.common.async?Promise.resolve().then(async()=>{let y=[];for(let w of d){let A=await w.key,O=await w.value;y.push({key:A,value:O,alwaysSet:w.alwaysSet})}return y}).then(y=>Tr.mergeObjectSync(n,y)):Tr.mergeObjectSync(n,d)}get shape(){return this._def.shape()}strict(e){return Ge.errToObj,new sr({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var i,s,f,u;let d=(f=(s=(i=this._def).errorMap)===null||s===void 0?void 0:s.call(i,t,n).message)!==null&&f!==void 0?f:n.defaultError;return t.code==="unrecognized_keys"?{message:(u=Ge.errToObj(e).message)!==null&&u!==void 0?u:d}:{message:d}}}:{}})}strip(){return new sr({...this._def,unknownKeys:"strip"})}passthrough(){return new sr({...this._def,unknownKeys:"passthrough"})}extend(e){return new sr({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new sr({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:ot.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new sr({...this._def,catchall:e})}pick(e){let t={};return Lt.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new sr({...this._def,shape:()=>t})}omit(e){let t={};return Lt.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new sr({...this._def,shape:()=>t})}deepPartial(){return fu(this)}partial(e){let t={};return Lt.objectKeys(this.shape).forEach(n=>{let i=this.shape[n];e&&!e[n]?t[n]=i:t[n]=i.optional()}),new sr({...this._def,shape:()=>t})}required(e){let t={};return Lt.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof ni;)s=s._def.innerType;t[n]=s}}),new sr({...this._def,shape:()=>t})}keyof(){return LA(Lt.objectKeys(this.shape))}};o(sr,"ZodObject");sr.create=(r,e)=>new sr({shape:()=>r,unknownKeys:"strip",catchall:Ni.create(),typeName:ot.ZodObject,...At(e)});sr.strictCreate=(r,e)=>new sr({shape:()=>r,unknownKeys:"strict",catchall:Ni.create(),typeName:ot.ZodObject,...At(e)});sr.lazycreate=(r,e)=>new sr({shape:r,unknownKeys:"strip",catchall:Ni.create(),typeName:ot.ZodObject,...At(e)});var ga=class extends _t{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function i(s){for(let u of s)if(u.result.status==="valid")return u.result;for(let u of s)if(u.result.status==="dirty")return t.common.issues.push(...u.ctx.common.issues),u.result;let f=s.map(u=>new fn(u.ctx.common.issues));return $e(t,{code:Oe.invalid_union,unionErrors:f}),gt}if(o(i,"handleResults"),t.common.async)return Promise.all(n.map(async s=>{let f={...t,common:{...t.common,issues:[]},parent:null};return{result:await s._parseAsync({data:t.data,path:t.path,parent:f}),ctx:f}})).then(i);{let s,f=[];for(let d of n){let y={...t,common:{...t.common,issues:[]},parent:null},w=d._parseSync({data:t.data,path:t.path,parent:y});if(w.status==="valid")return w;w.status==="dirty"&&!s&&(s={result:w,ctx:y}),y.common.issues.length&&f.push(y.common.issues)}if(s)return t.common.issues.push(...s.ctx.common.issues),s.result;let u=f.map(d=>new fn(d));return $e(t,{code:Oe.invalid_union,unionErrors:u}),gt}}get options(){return this._def.options}};o(ga,"ZodUnion");ga.create=(r,e)=>new ga({options:r,typeName:ot.ZodUnion,...At(e)});var Es=o(r=>r instanceof xa?Es(r.schema):r instanceof Nn?Es(r.innerType()):r instanceof wa?[r.value]:r instanceof so?r.options:r instanceof _a?Lt.objectValues(r.enum):r instanceof Ea?Es(r._def.innerType):r instanceof ma?[void 0]:r instanceof ba?[null]:r instanceof ni?[void 0,...Es(r.unwrap())]:r instanceof ao?[null,...Es(r.unwrap())]:r instanceof uu||r instanceof Ma?Es(r.unwrap()):r instanceof Aa?Es(r._def.innerType):[],"getDiscriminator"),If=class extends _t{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==je.object)return $e(t,{code:Oe.invalid_type,expected:je.object,received:t.parsedType}),gt;let n=this.discriminator,i=t.data[n],s=this.optionsMap.get(i);return s?t.common.async?s._parseAsync({data:t.data,path:t.path,parent:t}):s._parseSync({data:t.data,path:t.path,parent:t}):($e(t,{code:Oe.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,t,n){let i=new Map;for(let s of t){let f=Es(s.shape[e]);if(!f.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let u of f){if(i.has(u))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(u)}`);i.set(u,s)}}return new If({typeName:ot.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...At(n)})}};o(If,"ZodDiscriminatedUnion");function Hv(r,e){let t=da(r),n=da(e);if(r===e)return{valid:!0,data:r};if(t===je.object&&n===je.object){let i=Lt.objectKeys(e),s=Lt.objectKeys(r).filter(u=>i.indexOf(u)!==-1),f={...r,...e};for(let u of s){let d=Hv(r[u],e[u]);if(!d.valid)return{valid:!1};f[u]=d.data}return{valid:!0,data:f}}else if(t===je.array&&n===je.array){if(r.length!==e.length)return{valid:!1};let i=[];for(let s=0;s<r.length;s++){let f=r[s],u=e[s],d=Hv(f,u);if(!d.valid)return{valid:!1};i.push(d.data)}return{valid:!0,data:i}}else return t===je.date&&n===je.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}o(Hv,"mergeValues");var va=class extends _t{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),i=o((s,f)=>{if(qv(s)||qv(f))return gt;let u=Hv(s.value,f.value);return u.valid?((jv(s)||jv(f))&&t.dirty(),{status:t.value,value:u.data}):($e(n,{code:Oe.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(([s,f])=>i(s,f)):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(va,"ZodIntersection");va.create=(r,e,t)=>new va({left:r,right:e,typeName:ot.ZodIntersection,...At(t)});var ri=class extends _t{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==je.array)return $e(n,{code:Oe.invalid_type,expected:je.array,received:n.parsedType}),gt;if(n.data.length<this._def.items.length)return $e(n,{code:Oe.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),gt;!this._def.rest&&n.data.length>this._def.items.length&&($e(n,{code:Oe.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let s=[...n.data].map((f,u)=>{let d=this._def.items[u]||this._def.rest;return d?d._parse(new ti(n,f,n.path,u)):null}).filter(f=>!!f);return n.common.async?Promise.all(s).then(f=>Tr.mergeArray(t,f)):Tr.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new ri({...this._def,rest:e})}};o(ri,"ZodTuple");ri.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ri({items:r,typeName:ot.ZodTuple,rest:null,...At(e)})};var ya=class extends _t{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==je.object)return $e(n,{code:Oe.invalid_type,expected:je.object,received:n.parsedType}),gt;let i=[],s=this._def.keyType,f=this._def.valueType;for(let u in n.data)i.push({key:s._parse(new ti(n,u,n.path,u)),value:f._parse(new ti(n,n.data[u],n.path,u)),alwaysSet:u in n.data});return n.common.async?Tr.mergeObjectAsync(t,i):Tr.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof _t?new ya({keyType:e,valueType:t,typeName:ot.ZodRecord,...At(n)}):new ya({keyType:Rn.create(),valueType:e,typeName:ot.ZodRecord,...At(t)})}};o(ya,"ZodRecord");var Df=class extends _t{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==je.map)return $e(n,{code:Oe.invalid_type,expected:je.map,received:n.parsedType}),gt;let i=this._def.keyType,s=this._def.valueType,f=[...n.data.entries()].map(([u,d],y)=>({key:i._parse(new ti(n,u,n.path,[y,"key"])),value:s._parse(new ti(n,d,n.path,[y,"value"]))}));if(n.common.async){let u=new Map;return Promise.resolve().then(async()=>{for(let d of f){let y=await d.key,w=await d.value;if(y.status==="aborted"||w.status==="aborted")return gt;(y.status==="dirty"||w.status==="dirty")&&t.dirty(),u.set(y.value,w.value)}return{status:t.value,value:u}})}else{let u=new Map;for(let d of f){let y=d.key,w=d.value;if(y.status==="aborted"||w.status==="aborted")return gt;(y.status==="dirty"||w.status==="dirty")&&t.dirty(),u.set(y.value,w.value)}return{status:t.value,value:u}}}};o(Df,"ZodMap");Df.create=(r,e,t)=>new Df({valueType:e,keyType:r,typeName:ot.ZodMap,...At(t)});var Po=class extends _t{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==je.set)return $e(n,{code:Oe.invalid_type,expected:je.set,received:n.parsedType}),gt;let i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&($e(n,{code:Oe.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&($e(n,{code:Oe.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());let s=this._def.valueType;function f(d){let y=new Set;for(let w of d){if(w.status==="aborted")return gt;w.status==="dirty"&&t.dirty(),y.add(w.value)}return{status:t.value,value:y}}o(f,"finalizeSet");let u=[...n.data.values()].map((d,y)=>s._parse(new ti(n,d,n.path,y)));return n.common.async?Promise.all(u).then(d=>f(d)):f(u)}min(e,t){return new Po({...this._def,minSize:{value:e,message:Ge.toString(t)}})}max(e,t){return new Po({...this._def,maxSize:{value:e,message:Ge.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};o(Po,"ZodSet");Po.create=(r,e)=>new Po({valueType:r,minSize:null,maxSize:null,typeName:ot.ZodSet,...At(e)});var Ss=class extends _t{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==je.function)return $e(t,{code:Oe.invalid_type,expected:je.function,received:t.parsedType}),gt;function n(u,d){return Mp({data:u,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Sp(),lu].filter(y=>!!y),issueData:{code:Oe.invalid_arguments,argumentsError:d}})}o(n,"makeArgsIssue");function i(u,d){return Mp({data:u,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Sp(),lu].filter(y=>!!y),issueData:{code:Oe.invalid_return_type,returnTypeError:d}})}o(i,"makeReturnsIssue");let s={errorMap:t.common.contextualErrorMap},f=t.data;if(this._def.returns instanceof Ms){let u=this;return pn(async function(...d){let y=new fn([]),w=await u._def.args.parseAsync(d,s).catch(R=>{throw y.addIssue(n(d,R)),y}),A=await Reflect.apply(f,this,w);return await u._def.returns._def.type.parseAsync(A,s).catch(R=>{throw y.addIssue(i(A,R)),y})})}else{let u=this;return pn(function(...d){let y=u._def.args.safeParse(d,s);if(!y.success)throw new fn([n(d,y.error)]);let w=Reflect.apply(f,this,y.data),A=u._def.returns.safeParse(w,s);if(!A.success)throw new fn([i(w,A.error)]);return A.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Ss({...this._def,args:ri.create(e).rest(No.create())})}returns(e){return new Ss({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Ss({args:e||ri.create([]).rest(No.create()),returns:t||No.create(),typeName:ot.ZodFunction,...At(n)})}};o(Ss,"ZodFunction");var xa=class extends _t{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};o(xa,"ZodLazy");xa.create=(r,e)=>new xa({getter:r,typeName:ot.ZodLazy,...At(e)});var wa=class extends _t{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return $e(t,{received:t.data,code:Oe.invalid_literal,expected:this._def.value}),gt}return{status:"valid",value:e.data}}get value(){return this._def.value}};o(wa,"ZodLiteral");wa.create=(r,e)=>new wa({value:r,typeName:ot.ZodLiteral,...At(e)});function LA(r,e){return new so({values:r,typeName:ot.ZodEnum,...At(e)})}o(LA,"createZodEnum");var so=class extends _t{constructor(){super(...arguments),Zl.set(this,void 0)}_parse(e){if(typeof e.data!="string"){let t=this._getOrReturnCtx(e),n=this._def.values;return $e(t,{expected:Lt.joinValues(n),received:t.parsedType,code:Oe.invalid_type}),gt}if(Tp(this,Zl,"f")||OA(this,Zl,new Set(this._def.values),"f"),!Tp(this,Zl,"f").has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return $e(t,{received:t.data,code:Oe.invalid_enum_value,options:n}),gt}return pn(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return so.create(e,{...this._def,...t})}exclude(e,t=this._def){return so.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}};o(so,"ZodEnum");Zl=new WeakMap;so.create=LA;var _a=class extends _t{constructor(){super(...arguments),Xl.set(this,void 0)}_parse(e){let t=Lt.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==je.string&&n.parsedType!==je.number){let i=Lt.objectValues(t);return $e(n,{expected:Lt.joinValues(i),received:n.parsedType,code:Oe.invalid_type}),gt}if(Tp(this,Xl,"f")||OA(this,Xl,new Set(Lt.getValidEnumValues(this._def.values)),"f"),!Tp(this,Xl,"f").has(e.data)){let i=Lt.objectValues(t);return $e(n,{received:n.data,code:Oe.invalid_enum_value,options:i}),gt}return pn(e.data)}get enum(){return this._def.values}};o(_a,"ZodNativeEnum");Xl=new WeakMap;_a.create=(r,e)=>new _a({values:r,typeName:ot.ZodNativeEnum,...At(e)});var Ms=class extends _t{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==je.promise&&t.common.async===!1)return $e(t,{code:Oe.invalid_type,expected:je.promise,received:t.parsedType}),gt;let n=t.parsedType===je.promise?t.data:Promise.resolve(t.data);return pn(n.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}};o(Ms,"ZodPromise");Ms.create=(r,e)=>new Ms({type:r,typeName:ot.ZodPromise,...At(e)});var Nn=class extends _t{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ot.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),i=this._def.effect||null,s={addIssue:f=>{$e(n,f),f.fatal?t.abort():t.dirty()},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){let f=i.transform(n.data,s);if(n.common.async)return Promise.resolve(f).then(async u=>{if(t.value==="aborted")return gt;let d=await this._def.schema._parseAsync({data:u,path:n.path,parent:n});return d.status==="aborted"?gt:d.status==="dirty"||t.value==="dirty"?cu(d.value):d});{if(t.value==="aborted")return gt;let u=this._def.schema._parseSync({data:f,path:n.path,parent:n});return u.status==="aborted"?gt:u.status==="dirty"||t.value==="dirty"?cu(u.value):u}}if(i.type==="refinement"){let f=o(u=>{let d=i.refinement(u,s);if(n.common.async)return Promise.resolve(d);if(d 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"&&t.dirty(),f(u.value),{status:t.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"&&t.dirty(),f(u.value).then(()=>({status:t.value,value:u.value}))))}if(i.type==="transform")if(n.common.async===!1){let f=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Ql(f))return f;let u=i.transform(f.value,s);if(u instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:u}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(f=>Ql(f)?Promise.resolve(i.transform(f.value,s)).then(u=>({status:t.value,value:u})):f);Lt.assertNever(i)}};o(Nn,"ZodEffects");Nn.create=(r,e,t)=>new Nn({schema:r,typeName:ot.ZodEffects,effect:e,...At(t)});Nn.createWithPreprocess=(r,e,t)=>new Nn({schema:e,effect:{type:"preprocess",transform:r},typeName:ot.ZodEffects,...At(t)});var ni=class extends _t{_parse(e){return this._getType(e)===je.undefined?pn(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};o(ni,"ZodOptional");ni.create=(r,e)=>new ni({innerType:r,typeName:ot.ZodOptional,...At(e)});var ao=class extends _t{_parse(e){return this._getType(e)===je.null?pn(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};o(ao,"ZodNullable");ao.create=(r,e)=>new ao({innerType:r,typeName:ot.ZodNullable,...At(e)});var Ea=class extends _t{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===je.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};o(Ea,"ZodDefault");Ea.create=(r,e)=>new Ea({innerType:r,typeName:ot.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...At(e)});var Aa=class extends _t{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return eh(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new fn(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new fn(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};o(Aa,"ZodCatch");Aa.create=(r,e)=>new Aa({innerType:r,typeName:ot.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...At(e)});var Rf=class extends _t{_parse(e){if(this._getType(e)!==je.nan){let n=this._getOrReturnCtx(e);return $e(n,{code:Oe.invalid_type,expected:je.nan,received:n.parsedType}),gt}return{status:"valid",value:e.data}}};o(Rf,"ZodNaN");Rf.create=r=>new Rf({typeName:ot.ZodNaN,...At(r)});var GH=Symbol("zod_brand"),uu=class extends _t{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}};o(uu,"ZodBranded");var Sa=class extends _t{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return o(async()=>{let s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?gt:s.status==="dirty"?(t.dirty(),cu(s.value)):this._def.out._parseAsync({data:s.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"?(t.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,t){return new Sa({in:e,out:t,typeName:ot.ZodPipeline})}};o(Sa,"ZodPipeline");var Ma=class extends _t{_parse(e){let t=this._def.innerType._parse(e),n=o(i=>(Ql(i)&&(i.value=Object.freeze(i.value)),i),"freeze");return eh(t)?t.then(i=>n(i)):n(t)}unwrap(){return this._def.innerType}};o(Ma,"ZodReadonly");Ma.create=(r,e)=>new Ma({innerType:r,typeName:ot.ZodReadonly,...At(e)});function UA(r,e={},t){return r?As.create().superRefine((n,i)=>{var s,f;if(!r(n)){let u=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,d=(f=(s=u.fatal)!==null&&s!==void 0?s:t)!==null&&f!==void 0?f:!0,y=typeof u=="string"?{message:u}:u;i.addIssue({code:"custom",...y,fatal:d})}}):As.create()}o(UA,"custom");var WH={object:sr.lazycreate},ot;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(ot||(ot={}));var JH=o((r,e={message:`Input not instance of ${r.name}`})=>UA(t=>t instanceof r,e),"instanceOfType"),FA=Rn.create,$A=io.create,YH=Rf.create,ZH=oo.create,qA=pa.create,XH=Oo.create,QH=Cf.create,ez=ma.create,tz=ba.create,rz=As.create,nz=No.create,iz=Ni.create,oz=kf.create,sz=On.create,az=sr.create,fz=sr.strictCreate,cz=ga.create,uz=If.create,lz=va.create,hz=ri.create,dz=ya.create,pz=Df.create,mz=Po.create,bz=Ss.create,gz=xa.create,vz=wa.create,yz=so.create,xz=_a.create,wz=Ms.create,DA=Nn.create,_z=ni.create,Ez=ao.create,Az=Nn.createWithPreprocess,Sz=Sa.create,Mz=o(()=>FA().optional(),"ostring"),Tz=o(()=>$A().optional(),"onumber"),Cz=o(()=>qA().optional(),"oboolean"),kz={string:r=>Rn.create({...r,coerce:!0}),number:r=>io.create({...r,coerce:!0}),boolean:r=>pa.create({...r,coerce:!0}),bigint:r=>oo.create({...r,coerce:!0}),date:r=>Oo.create({...r,coerce:!0})},Iz=gt,m=Object.freeze({__proto__:null,defaultErrorMap:lu,setErrorMap:IH,getErrorMap:Sp,makeIssue:Mp,EMPTY_PATH:DH,addIssueToContext:$e,ParseStatus:Tr,INVALID:gt,DIRTY:cu,OK:pn,isAborted:qv,isDirty:jv,isValid:Ql,isAsync:eh,get util(){return Lt},get objectUtil(){return $v},ZodParsedType:je,getParsedType:da,ZodType:_t,datetimeRegex:BA,ZodString:Rn,ZodNumber:io,ZodBigInt:oo,ZodBoolean:pa,ZodDate:Oo,ZodSymbol:Cf,ZodUndefined:ma,ZodNull:ba,ZodAny:As,ZodUnknown:No,ZodNever:Ni,ZodVoid:kf,ZodArray:On,ZodObject:sr,ZodUnion:ga,ZodDiscriminatedUnion:If,ZodIntersection:va,ZodTuple:ri,ZodRecord:ya,ZodMap:Df,ZodSet:Po,ZodFunction:Ss,ZodLazy:xa,ZodLiteral:wa,ZodEnum:so,ZodNativeEnum:_a,ZodPromise:Ms,ZodEffects:Nn,ZodTransformer:Nn,ZodOptional:ni,ZodNullable:ao,ZodDefault:Ea,ZodCatch:Aa,ZodNaN:Rf,BRAND:GH,ZodBranded:uu,ZodPipeline:Sa,ZodReadonly:Ma,custom:UA,Schema:_t,ZodSchema:_t,late:WH,get ZodFirstPartyTypeKind(){return ot},coerce:kz,any:rz,array:sz,bigint:ZH,boolean:qA,date:XH,discriminatedUnion:uz,effect:DA,enum:yz,function:bz,instanceof:JH,intersection:lz,lazy:gz,literal:vz,map:pz,nan:YH,nativeEnum:xz,never:iz,null:tz,nullable:Ez,number:$A,object:az,oboolean:Cz,onumber:Tz,optional:_z,ostring:Mz,pipeline:Sz,preprocess:Az,promise:wz,record:dz,set:mz,strictObject:fz,string:FA,symbol:QH,transformer:DA,tuple:hz,undefined:ez,union:cz,unknown:nz,void:oz,NEVER:Iz,ZodIssueCode:Oe,quotelessJson:kH,ZodError:fn});var hu=Symbol("current"),Of=Symbol("previous");var th=o((r,{ref:e,refType:t,param:n,header:i,...s}={})=>({...s,...r}),"mergeOpenApi");function rh(r){if(typeof r.ZodType.prototype.openapi<"u")return;r.ZodType.prototype.openapi=function(s){let{zodOpenApi:f,...u}=this._def,d=new this.constructor({...u,zodOpenApi:{openapi:th(s,f?.openapi)}});return d._def.zodOpenApi[hu]=d,f&&(d._def.zodOpenApi[Of]=this),d};let e=r.ZodType.prototype.describe;r.ZodType.prototype.describe=function(...s){let f=e.apply(this,s),u=f._def;if(u.zodOpenApi){let d={...u.zodOpenApi};d.openapi=th({description:s[0]},d.openapi),d[Of]=this,d[hu]=f,u.zodOpenApi=d}else u.zodOpenApi={openapi:{description:s[0]},[hu]:f};return f};let t=r.ZodObject.prototype.extend;r.ZodObject.prototype.extend=function(...s){let f=t.apply(this,s),u=f._def.zodOpenApi;if(u){let d={...u};d.openapi=th({},d.openapi),d[Of]=this,f._def.zodOpenApi=d}else f._def.zodOpenApi={[Of]:this};return f};let n=r.ZodObject.prototype.omit;r.ZodObject.prototype.omit=function(...s){let f=n.apply(this,s),u=f._def.zodOpenApi;if(u){let d={...u};d.openapi=th({},d.openapi),delete d[Of],delete d[hu],f._def.zodOpenApi=d}return f};let i=r.ZodObject.prototype.pick;r.ZodObject.prototype.pick=function(...s){let f=i.apply(this,s),u=f._def.zodOpenApi;if(u){let d={...u};d.openapi=th({},d.openapi),delete d[Of],delete d[hu],f._def.zodOpenApi=d}return f}}o(rh,"extendZodWithOpenApi");rh(m);var Dz=Object.defineProperty,Rz=o((r,e)=>Dz(r,"name",{value:e,configurable:!0}),"__name"),kp=m.array(m.string().or(m.record(m.any()))),Xie=m.object({type:m.string().optional(),narrative:m.string().optional()}),Ip=m.string().or(m.object({id:m.string(),type:m.string(),caption:m.string().optional()})),Oz=m.object({type:m.string().min(1).or(m.string().array().nonempty()),latitude:m.number(),longitude:m.number()}),Nz=m.object({type:m.string().min(1).or(m.string().array().nonempty()),addressCountry:m.string().optional(),addressCountryCode:m.string().optional(),addressRegion:m.string().optional(),addressLocality:m.string().optional(),streetAddress:m.string().optional(),postOfficeBoxNumber:m.string().optional(),postalCode:m.string().optional(),geo:Oz.optional()}),Pz=m.enum(["sourcedId","systemId","productId","userName","accountId","emailAddress","nationalIdentityNumber","isbn","issn","lisSourcedId","oneRosterSourcedId","sisSourcedId","ltiContextId","ltiDeploymentId","ltiToolId","ltiPlatformId","ltiUserId","identifier"]).or(m.string()),e7=m.object({type:m.string().min(1).or(m.string().array().nonempty()),identifier:m.string(),identifierType:Pz}),nh=m.string().or(m.object({id:m.string().optional(),type:m.string().or(m.string().array().nonempty().optional()),name:m.string().optional(),url:m.string().optional(),phone:m.string().optional(),description:m.string().optional(),endorsement:m.any().array().optional(),image:Ip.optional(),email:m.string().email().optional(),address:Nz.optional(),otherIdentifier:e7.array().optional(),official:m.string().optional(),parentOrg:m.any().optional(),familyName:m.string().optional(),givenName:m.string().optional(),additionalName:m.string().optional(),patronymicName:m.string().optional(),honorificPrefix:m.string().optional(),honorificSuffix:m.string().optional(),familyNamePrefix:m.string().optional(),dateOfBirth:m.string().optional()}).catchall(m.any())),Kv=m.object({id:m.string().optional()}).catchall(m.any()),Cp=m.object({type:m.string(),id:m.string()}).catchall(m.any()),jA=m.object({id:m.string(),type:m.string()}).catchall(m.any()),HA=m.object({id:m.string().optional(),type:m.string()}).catchall(m.any()),zA=m.object({type:m.string(),id:m.string().optional()}).catchall(m.any()),KA=m.object({type:m.string().or(m.string().array().nonempty()),id:m.string().optional()}).catchall(m.any()),du=m.object({"@context":kp,id:m.string().optional(),type:m.string().array().nonempty(),issuer:nh,credentialSubject:Kv.or(Kv.array()),refreshService:HA.or(HA.array()).optional(),credentialSchema:jA.or(jA.array()).optional(),issuanceDate:m.string().optional(),expirationDate:m.string().optional(),credentialStatus:Cp.or(Cp.array()).optional(),name:m.string().optional(),description:m.string().optional(),validFrom:m.string().optional(),validUntil:m.string().optional(),status:Cp.or(Cp.array()).optional(),termsOfUse:zA.or(zA.array()).optional(),evidence:KA.or(KA.array()).optional()}).catchall(m.any()),Bo=m.object({type:m.string(),created:m.string(),challenge:m.string().optional(),domain:m.string().optional(),nonce:m.string().optional(),proofPurpose:m.string(),verificationMethod:m.string(),jws:m.string().optional()}).catchall(m.any()),Pf=du.extend({proof:Bo.or(Bo.array())}),Bz=m.object({"@context":kp,id:m.string().optional(),type:m.string().or(m.string().array().nonempty()),verifiableCredential:Pf.or(Pf.array()).optional(),holder:m.string().optional()}).catchall(m.any()),oh=Bz.extend({proof:Bo.or(Bo.array())}),Wv=m.object({kty:m.string(),crv:m.string(),x:m.string(),y:m.string().optional(),n:m.string().optional(),d:m.string().optional()}),toe=Wv.omit({d:!0}).extend({d:m.string()}),Lz=m.object({alg:m.string(),iv:m.string(),tag:m.string(),epk:Wv.partial().optional(),kid:m.string().optional(),apv:m.string().optional(),apu:m.string().optional()}),Uz=m.object({header:Lz,encrypted_key:m.string()}),Fz=m.object({protected:m.string(),iv:m.string(),ciphertext:m.string(),tag:m.string(),aad:m.string().optional(),recipients:Uz.array().optional()}),Nf=m.string().or(m.object({"@context":kp.optional(),id:m.string(),type:m.string(),controller:m.string(),publicKeyJwk:Wv.optional(),publicKeyBase58:m.string().optional(),publicKeyMultibase:m.string().optional(),blockChainAccountId:m.string().optional()}).catchall(m.any())),$z=m.object({id:m.string(),type:m.string().or(m.string().array().nonempty()),serviceEndpoint:m.any().or(m.any().array().nonempty())}).catchall(m.any()),roe=m.object({"@context":kp,id:m.string(),alsoKnownAs:m.string().optional(),controller:m.string().or(m.string().array().nonempty()).optional(),verificationMethod:Nf.array().optional(),authentication:Nf.array().optional(),assertionMethod:Nf.array().optional(),keyAgreement:Nf.array().optional(),capabilityInvocation:Nf.array().optional(),capabilityDelegation:Nf.array().optional(),publicKey:Nf.array().optional(),service:$z.array().optional(),proof:Bo.or(Bo.array()).optional()}).catchall(m.any()),qz=m.enum(["ceasn:Competency","ceterms:Credential","CFItem","CFRubric","CFRubricCriterion","CFRubricCriterionLevel","CTDL"]).or(m.string()),Dp=m.object({type:m.string().array().nonempty(),targetCode:m.string().optional(),targetDescription:m.string().optional(),targetName:m.string(),targetFramework:m.string().optional(),targetType:qz.optional(),targetUrl:m.string()}),jz=m.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"]),Hz=jz.or(m.string()),zz=m.object({id:m.string().optional(),narrative:m.string().optional()}).catchall(m.any()),Kz=m.object({id:m.string(),type:m.string().array().nonempty(),endorsementComment:m.string().optional()}),Vz=du.extend({credentialSubject:Kz,proof:Bo.or(Bo.array()).optional()}),Gz=m.object({id:m.string(),"@language":m.string().optional(),version:m.string().optional()}),Wz=m.enum(["GradePointAverage","LetterGrade","Percent","PerformanceLevel","PredictedScore","RawScore","Result","RubricCriterion","RubricCriterionLevel","RubricScore","ScaledScore","Status"]).or(m.string()),Jz=m.object({id:m.string(),type:m.string().array().nonempty(),alignment:Dp.array().optional(),description:m.string().optional(),level:m.string().optional(),name:m.string(),points:m.string().optional()}).catchall(m.any()),Yz=m.object({id:m.string(),type:m.string().array().nonempty(),alignment:Dp.array().optional(),allowedValue:m.string().array().optional(),name:m.string(),requiredLevel:m.string().optional(),requiredValue:m.string().optional(),resultType:Wz,rubricCriterionLevel:Jz.array().optional(),valueMax:m.string().optional(),valueMin:m.string().optional()}).catchall(m.any()),Zz=m.object({id:m.string().optional(),type:m.string().array().nonempty(),alignment:Dp.array().optional(),achievementType:Hz.optional(),creator:nh.optional(),creditsAvailable:m.number().optional(),criteria:zz,description:m.string(),endorsement:Vz.array().optional(),fieldOfStudy:m.string().optional(),humanCode:m.string().optional(),image:Ip.optional(),"@language":m.string().optional(),name:m.string(),otherIdentifier:e7.array().optional(),related:Gz.array().optional(),resultDescription:Yz.array().optional(),specialization:m.string().optional(),tag:m.string().array().optional(),version:m.string().optional()}).catchall(m.any()),Xz=m.object({type:m.string(),hashed:m.boolean(),identityHash:m.string(),identityType:m.string(),salt:m.string().optional()}),Qz=m.enum(["Completed","Enrolled","Failed","InProgress","OnHold","Withdrew"]),eK=m.object({type:m.string().array().nonempty(),achievedLevel:m.string().optional(),alignment:Dp.array().optional(),resultDescription:m.string().optional(),status:Qz.optional(),value:m.string().optional()}).catchall(m.any()),VA=m.object({id:m.string().optional(),type:m.string().array().nonempty(),activityEndDate:m.string().optional(),activityStartDate:m.string().optional(),creditsEarned:m.number().optional(),achievement:Zz.optional(),identifier:Xz.array().optional(),image:Ip.optional(),licenseNumber:m.string().optional(),narrative:m.string().optional(),result:eK.array().optional(),role:m.string().optional(),source:nh.optional(),term:m.string().optional()}).catchall(m.any()),tK=m.object({id:m.string().optional(),type:m.string().or(m.string().array().nonempty()),narrative:m.string().optional(),name:m.string().optional(),description:m.string().optional(),genre:m.string().optional(),audience:m.string().optional()}).catchall(m.any()),rK=du.extend({name:m.string().optional(),description:m.string().optional(),image:Ip.optional(),credentialSubject:VA.or(VA.array()),endorsement:du.array().optional(),evidence:tK.array().optional()}),ioe=rK.extend({proof:Bo.or(Bo.array())}),soe=m.object({checks:m.string().array(),warnings:m.string().array(),errors:m.string().array()}),t7=m.enum(["Success","Failed","Error"]),aoe=t7.enum,foe=m.object({check:m.string(),status:t7,message:m.string().optional(),details:m.string().optional()}),coe=m.object({title:m.string().optional(),createdAt:m.string().optional(),issuer:nh.optional(),issuee:nh.optional(),credentialSubject:Kv.optional()}),uoe=m.object({id:m.string(),uri:m.string()}).catchall(m.any()),doe=m.object({limit:m.number(),cursor:m.string().optional(),sort:m.string().optional()}),Wr=m.object({cursor:m.string().optional(),hasMore:m.boolean()}),r7=m.object({encryptedRecord:Fz,fields:m.string().array()}).catchall(m.any()),poe=Wr.extend({records:r7.array()}),nK=r7.extend({id:m.string()}),moe=Wr.extend({records:nK.array()}),GA=Rz(r=>{let e=r.match(/^\/(.*)\/([gimsuy]*)$/);if(!e)throw new Error("Invalid RegExp string format");return{pattern:e[1],flags:e[2]}},"parseRegexString"),iK=m.instanceof(RegExp).or(m.string().refine(r=>{try{return GA(r),!0}catch{return!1}},{message:"Invalid RegExp string format. Must be in format '/pattern/flags'"}).transform(r=>{let{pattern:e,flags:t}=GA(r);try{return new RegExp(e,t)}catch(n){throw new Error(`Invalid RegExp: ${n.message}`)}})),WA=m.string().or(m.object({$in:m.string().array()})).or(m.object({$regex:iK})),Et=m.union([WA,m.object({$or:WA.array()})]);rh(m);var oK=m.object({backgroundColor:m.string().optional(),backgroundImage:m.string().optional(),fadeBackgroundImage:m.boolean().optional(),repeatBackgroundImage:m.boolean().optional(),fontColor:m.string().optional(),accentColor:m.string().optional(),accentFontColor:m.string().optional(),idBackgroundImage:m.string().optional(),fadeIdBackgroundImage:m.boolean().optional(),idBackgroundColor:m.string().optional(),repeatIdBackgroundImage:m.boolean().optional()}),Lo=m.object({profileId:m.string().min(3).max(40).describe("Unique, URL-safe identifier for the profile."),displayName:m.string().default("").describe("Human-readable display name for the profile."),shortBio:m.string().default("").describe("Short bio for the profile."),bio:m.string().default("").describe("Longer bio for the profile."),did:m.string().describe("Decentralized Identifier for the profile. (auto-assigned)"),isPrivate:m.boolean().optional().describe("Whether the profile is private or not and shows up in search results."),email:m.string().optional().describe("Contact email address for the profile. (deprecated)"),image:m.string().optional().describe("Profile image URL for the profile."),heroImage:m.string().optional().describe("Hero image URL for the profile."),websiteLink:m.string().optional().describe("Website link for the profile."),isServiceProfile:m.boolean().default(!1).optional().describe("Whether the profile is a service profile or not."),type:m.string().optional().describe('Profile type: e.g. "person", "organization", "service".'),notificationsWebhook:m.string().url().startsWith("http").optional().describe("URL to send notifications to."),display:oK.optional().describe("Display settings for the profile."),highlightedCredentials:m.array(m.string()).max(5).optional().describe("Up to 5 unique boost URIs to highlight on the profile."),role:m.string().default("").optional().describe('Role of the profile: e.g. "teacher", "student".'),dob:m.string().default("").optional().describe('Date of birth of the profile: e.g. "1990-01-01".'),country:m.string().optional().describe("Country for the profile."),approved:m.boolean().optional().describe("Approval status for the profile.")}),yoe=m.object({profileId:Et,displayName:Et,shortBio:Et,bio:Et,email:Et,websiteLink:Et,isServiceProfile:m.boolean(),type:Et}).partial(),xoe=Wr.extend({records:Lo.array()}),woe=m.enum(["CONNECTED","PENDING_REQUEST_SENT","PENDING_REQUEST_RECEIVED","NOT_CONNECTED"]),n7=m.object({id:m.string(),created:m.string(),displayName:m.string().default("").optional(),shortBio:m.string().default("").optional(),bio:m.string().default("").optional(),email:m.string().optional(),image:m.string().optional(),heroImage:m.string().optional()}),_oe=Wr.extend({records:n7.extend({did:m.string()}).array()}),Eoe=m.object({id:Et,displayName:Et,shortBio:Et,bio:Et,email:Et}).partial(),Aoe=Wr.extend({records:m.object({profile:Lo,manager:n7.extend({did:m.string()}).optional()}).array()}),Soe=m.object({uri:m.string(),to:m.string(),from:m.string(),sent:m.string().datetime(),received:m.string().datetime().optional()}),i7=m.object({role:m.string(),canEdit:m.boolean(),canIssue:m.boolean(),canRevoke:m.boolean(),canManagePermissions:m.boolean(),canIssueChildren:m.string(),canCreateChildren:m.string(),canEditChildren:m.string(),canRevokeChildren:m.string(),canManageChildrenPermissions:m.string(),canManageChildrenProfiles:m.boolean().default(!1).optional(),canViewAnalytics:m.boolean()}),sK=m.object({role:Et,canEdit:m.boolean(),canIssue:m.boolean(),canRevoke:m.boolean(),canManagePermissions:m.boolean(),canIssueChildren:Et,canCreateChildren:Et,canEditChildren:Et,canRevokeChildren:Et,canManageChildrenPermissions:Et,canManageChildrenProfiles:m.boolean(),canViewAnalytics:m.boolean()}).partial(),zv=m.enum(["GRANT_PERMISSIONS","ADD_ADMIN","AUTO_CONNECT"]),aK=m.discriminatedUnion("type",[m.object({type:m.literal(zv.Values.GRANT_PERMISSIONS),data:m.object({claimUri:m.string(),targetUri:m.string(),permissions:i7.partial()})}),m.object({type:m.literal(zv.Values.ADD_ADMIN),data:m.object({claimUri:m.string(),targetUri:m.string()})}),m.object({type:m.literal(zv.Values.AUTO_CONNECT),data:m.object({claimUri:m.string(),targetUri:m.string()})})]),Moe=m.object({type:Et,data:m.object({claimUri:Et,targetUri:Et,permissions:sK})}).deepPartial(),fK=m.object({id:m.string(),createdAt:m.string(),updatedAt:m.string()}).and(aK),Toe=Wr.extend({records:fK.array()}),Vv=m.enum(["DRAFT","LIVE"]),cK=m.object({uri:m.string(),name:m.string().optional(),type:m.string().optional(),category:m.string().optional(),status:Vv.optional(),autoConnectRecipients:m.boolean().optional(),meta:m.record(m.any()).optional(),claimPermissions:i7.optional(),allowAnyoneToCreateChildren:m.boolean().optional()}),JA=m.object({uri:Et,name:Et,type:Et,category:Et,meta:m.record(Et),status:Vv.or(m.object({$in:Vv.array()})),autoConnectRecipients:m.boolean()}).partial(),Coe=m.union([m.object({$or:JA.array()}),JA]),koe=Wr.extend({records:cK.array()}),uK=m.object({to:Lo,from:m.string(),received:m.string().optional(),uri:m.string().optional()}),Ioe=Wr.extend({records:uK.array()}),lK=m.object({to:Lo,from:m.string(),received:m.string().optional(),boostUris:m.array(m.string()),credentialUris:m.array(m.string()).optional()}),Doe=Wr.extend({records:lK.array()}),Roe=m.object({endpoint:m.string(),name:m.string(),did:m.string().optional()}),Ooe=m.object({ttlSeconds:m.number().optional(),totalUses:m.number().optional()}),hK=m.object({endpoint:m.string()}),Noe=m.object({signingAuthority:hK,relationship:m.object({name:m.string().max(15).regex(/^[a-z0-9-]+$/,{message:"The input string must contain only lowercase letters, numbers, and hyphens."}),did:m.string(),isPrimary:m.boolean().optional()})}),Poe=m.object({boostUri:m.string(),signingAuthority:m.object({endpoint:m.string(),name:m.string()})}),dK=m.enum(["live","stale","withdrawn"]),pK=m.object({read:m.object({anonymize:m.boolean().optional(),credentials:m.object({categories:m.record(m.object({required:m.boolean(),defaultEnabled:m.boolean().optional()})).default({})}).default({}),personal:m.record(m.object({required:m.boolean(),defaultEnabled:m.boolean().optional()})).default({})}).default({}),write:m.object({credentials:m.object({categories:m.record(m.object({required:m.boolean(),defaultEnabled:m.boolean().optional()})).default({})}).default({}),personal:m.record(m.object({required:m.boolean(),defaultEnabled:m.boolean().optional()})).default({})}).default({})}),o7=m.object({contract:pK,owner:Lo,name:m.string(),subtitle:m.string().optional(),description:m.string().optional(),reasonForAccessing:m.string().optional(),image:m.string().optional(),uri:m.string(),needsGuardianConsent:m.boolean().optional(),redirectUrl:m.string().optional(),frontDoorBoostUri:m.string().optional(),createdAt:m.string(),updatedAt:m.string(),expiresAt:m.string().optional(),autoBoosts:m.string().array().optional(),writers:m.array(Lo).optional()}),Boe=Wr.extend({records:o7.omit({owner:!0}).array()}),mK=m.object({credentials:m.object({categories:m.record(m.string().array()).default({})}),personal:m.record(m.string()).default({}),date:m.string()}),Loe=Wr.extend({records:mK.array()}),bK=m.object({credentials:m.object({category:m.string(),uri:m.string()}).array(),personal:m.record(m.string()).default({}),date:m.string(),contractUri:m.string()}),Uoe=Wr.extend({records:bK.array()}),s7=m.object({sharing:m.boolean().optional(),shared:m.string().array().optional(),shareAll:m.boolean().optional(),shareUntil:m.string().optional()}),a7=m.object({read:m.object({anonymize:m.boolean().optional(),credentials:m.object({shareAll:m.boolean().optional(),sharing:m.boolean().optional(),categories:m.record(s7).default({})}).default({}),personal:m.record(m.string()).default({})}).default({}),write:m.object({credentials:m.object({categories:m.record(m.boolean()).default({})}).default({}),personal:m.record(m.boolean()).default({})}).default({}),deniedWriters:m.array(m.string()).optional()}),Foe=Wr.extend({records:m.object({expiresAt:m.string().optional(),oneTime:m.boolean().optional(),terms:a7,contract:o7,uri:m.string(),consenter:Lo,status:dK}).array()}),$oe=m.object({read:m.object({anonymize:m.boolean().optional(),credentials:m.object({categories:m.record(m.object({required:m.boolean().optional()})).optional()}).optional(),personal:m.record(m.object({required:m.boolean().optional()})).optional()}).optional(),write:m.object({credentials:m.object({categories:m.record(m.object({required:m.boolean().optional()})).optional()}).optional(),personal:m.record(m.object({required:m.boolean().optional()})).optional()}).optional()}),qoe=m.object({anonymize:m.boolean().optional(),credentials:m.object({categories:m.record(m.boolean()).optional()}).optional(),personal:m.record(m.boolean()).optional()}),joe=m.object({credentials:m.object({categories:m.record(m.boolean()).optional()}).optional(),personal:m.record(m.boolean()).optional(),id:Et.optional()}),gK=m.object({read:m.object({anonymize:m.boolean().optional(),credentials:m.object({shareAll:m.boolean().optional(),sharing:m.boolean().optional(),categories:m.record(s7.optional()).optional()}).optional(),personal:m.record(m.string()).optional()}).optional(),write:m.object({credentials:m.object({categories:m.record(m.boolean()).optional()}).optional(),personal:m.record(m.boolean()).optional()}).optional()}),Gv=m.enum(["consent","update","sync","withdraw","write"]),Hoe=m.object({terms:gK.optional(),action:Gv.or(Gv.array()).optional(),date:m.object({$gt:m.string()}).or(m.object({$lt:m.string()})).or(m.object({$eq:m.string()})).optional(),expiresAt:m.object({$gt:m.string()}).or(m.object({$lt:m.string()})).or(m.object({$eq:m.string()})).optional(),oneTime:m.boolean().optional()}),f7=m.object({expiresAt:m.string().optional(),oneTime:m.boolean().optional(),terms:a7.optional(),id:m.string(),action:Gv,date:m.string(),uris:m.string().array().optional()}),zoe=Wr.extend({records:f7.array()}),YA=m.object({id:Et,name:Et,description:Et,sourceURI:Et,status:Et}).partial(),Koe=m.union([m.object({$or:YA.array()}),YA]),vK=m.object({credentialUri:m.string(),termsUri:m.string(),contractUri:m.string(),boostUri:m.string(),category:m.string().optional(),date:m.string()}),Voe=Wr.extend({records:vK.array()}),yK=m.enum(["CONNECTION_REQUEST","CONNECTION_ACCEPTED","CREDENTIAL_RECEIVED","CREDENTIAL_ACCEPTED","BOOST_RECEIVED","BOOST_ACCEPTED","PRESENTATION_REQUEST","PRESENTATION_RECEIVED","CONSENT_FLOW_TRANSACTION","ISSUANCE_CLAIMED","ISSUANCE_DELIVERED","ISSUANCE_ERROR","PROFILE_PARENT_APPROVED"]),xK=m.object({title:m.string().optional(),body:m.string().optional()}),wK=m.object({type:m.string(),value:m.string()}),Rp=m.enum(["PENDING","ISSUED","EXPIRED","DELIVERED","CLAIMED"]),_K=m.object({issuanceId:m.string(),status:Rp,recipient:m.object({contactMethod:wK.optional(),learnCardId:m.string().optional()}),timestamp:m.string().datetime().optional()}),EK=m.object({vcUris:m.array(m.string()).optional(),vpUris:m.array(m.string()).optional(),transaction:f7.optional(),inbox:_K.optional()}),Goe=m.object({type:yK,to:Lo.partial().and(m.object({did:m.string()})),from:Lo.partial().and(m.object({did:m.string()})),message:xK.optional(),data:EK.optional(),sent:m.string().datetime().optional(),webhookUrl:m.string().optional()}),AK="auth-grant:",Woe=m.object({id:m.string(),name:m.string(),description:m.string().optional(),challenge:m.string().startsWith(AK).min(10,{message:"Challenge is too short"}).max(100,{message:"Challenge is too long"}),status:m.enum(["revoked","active"],{required_error:"Status is required",invalid_type_error:"Status must be either active or revoked"}),scope:m.string(),createdAt:m.string().datetime({message:"createdAt must be a valid ISO 8601 datetime string"}),expiresAt:m.string().datetime({message:"expiresAt must be a valid ISO 8601 datetime string"}).nullish().optional()}),Joe=m.object({id:m.string()}).catchall(m.any()),SK=m.enum(["active","revoked"]),Yoe=m.object({id:Et,name:Et,description:Et,status:SK}).partial(),ZA=m.object({id:m.string(),isVerified:m.boolean(),verifiedAt:m.string().optional(),isPrimary:m.boolean(),createdAt:m.string()}),Zoe=m.discriminatedUnion("type",[m.object({type:m.literal("email"),value:m.string().email()}).merge(ZA),m.object({type:m.literal("phone"),value:m.string()}).merge(ZA)]),XA=m.object({isVerified:m.boolean().optional(),isPrimary:m.boolean().optional()}),Xoe=m.discriminatedUnion("type",[m.object({type:m.literal("email"),value:m.string().email()}).merge(XA),m.object({type:m.literal("phone"),value:m.string()}).merge(XA)]),c7=m.discriminatedUnion("type",[m.object({type:m.literal("email"),value:m.string().email()}),m.object({type:m.literal("phone"),value:m.string()})]),MK=m.object({value:m.string(),type:m.enum(["email","phone"])}),Qoe=m.object({token:m.string()}),ese=m.object({contactMethodId:m.string()}),tse=m.object({contactMethod:MK,otpChallenge:m.string()}),rse=m.object({sessionJwt:m.string()}),TK=m.object({id:m.string(),credential:m.string(),isSigned:m.boolean(),currentStatus:Rp,isAccepted:m.boolean().optional(),expiresAt:m.string(),createdAt:m.string(),issuerDid:m.string(),webhookUrl:m.string().optional(),signingAuthority:m.object({endpoint:m.string().optional(),name:m.string().optional()}).optional()}),nse=m.object({hasMore:m.boolean(),records:m.array(TK),cursor:m.string().optional()}),ise=m.object({currentStatus:Rp,id:m.string(),isSigned:m.boolean(),isAccepted:m.boolean().optional(),issuerDid:m.string()}).partial(),CK=m.object({endpoint:m.string().url(),name:m.string()}),ose=m.object({recipient:c7.describe("The recipient of the credential"),credential:Pf.passthrough().or(oh.passthrough()).or(du.passthrough()).describe("The credential to issue. If not signed, the users default signing authority will be used, or the specified signing authority in the configuration."),configuration:m.object({signingAuthority:CK.optional().describe("The signing authority to use for the credential. If not provided, the users default signing authority will be used if the credential is not signed."),webhookUrl:m.string().url().optional().describe("The webhook URL to receive credential issuance events."),expiresInDays:m.number().min(1).max(365).optional().describe("The number of days the credential will be valid for."),delivery:m.object({suppress:m.boolean().optional().default(!1).describe("Whether to suppress delivery of the credential to the recipient. If true, the email/sms will not be sent to the recipient. Useful if you would like to manually send claim link to your users."),template:m.object({id:m.enum(["universal-inbox-claim"]).optional().describe("The template ID to use for the credential delivery. If not provided, the default template will be used."),model:m.object({issuer:m.object({name:m.string().optional().describe('The name of the organization (e.g., "State University").'),logoUrl:m.string().url().optional().describe("The URL of the organization's logo.")}).optional(),credential:m.object({name:m.string().optional().describe('The name of the credential (e.g., "Bachelor of Science").'),type:m.string().optional().describe('The type of the credential (e.g., "degree", "certificate").')}).optional(),recipient:m.object({name:m.string().optional().describe('The name of the recipient (e.g., "John Doe").')}).optional()}).describe("The template model to use for the credential delivery. Injects via template variables into email/sms templates. If not provided, the default template will be used.")}).optional().describe("The template to use for the credential delivery. If not provided, the default template will be used.")}).optional().describe("Configuration for the credential delivery i.e. email or SMS. When credentials are sent to a user who has a verified email or phone associated with their account, delivery is skipped, and the credential will be sent using in-app notifications. If not provided, the default configuration will be used.")}).optional().describe("Configuration for the credential issuance. If not provided, the default configuration will be used.")}),sse=m.object({issuanceId:m.string(),status:Rp,recipient:c7,claimUrl:m.string().url().optional(),recipientDid:m.string().optional()}),ase=m.object({credential:Pf.passthrough().or(oh.passthrough()).or(du.passthrough()).describe("The credential to issue."),configuration:m.object({publishableKey:m.string(),signingAuthorityName:m.string().optional()}).optional()}),Jv=m.union([m.string().regex(/^(?:(?:[a-zA-Z0-9-]{1,63}\.)+[a-zA-Z]{2,63}|localhost|\d{1,3}(?:\.\d{1,3}){3})(?::\d{1,5})?$/,{message:"Must be a valid domain (incl. subdomains), localhost, or IPv4, optionally with port"}),m.string().regex(/^https?:\/\/(?:(?:[a-zA-Z0-9-]{1,63}\.)+[a-zA-Z]{2,63}|localhost|\d{1,3}(?:\.\d{1,3}){3})(?::\d{1,5})?$/,{message:"Must be a valid http(s) origin"})]),kK=m.object({id:m.string(),name:m.string(),description:m.string().optional(),publishableKey:m.string(),whitelistedDomains:m.array(Jv).default([])}),fse=m.object({name:m.string(),description:m.string().optional(),whitelistedDomains:m.array(Jv).default([])}),cse=m.object({name:m.string().optional(),description:m.string().optional(),whitelistedDomains:m.array(Jv).optional(),rotatePublishableKey:m.boolean().optional()}),use=m.object({id:Et,name:Et,description:Et}).partial(),lse=Wr.extend({records:kK.array()}),hse=m.object({token:m.string(),contactMethodId:m.string(),autoVerifyContactMethod:m.boolean().optional().default(!1),createdAt:m.string(),expiresAt:m.string(),used:m.boolean()}),dse=m.object({id:m.string(),name:m.string().min(1),slug:m.string().min(1),createdAt:m.string().optional(),updatedAt:m.string().optional()}),ih=m.enum(["active","archived"]),u7=m.object({id:m.string(),statement:m.string(),description:m.string().optional(),code:m.string().optional(),icon:m.string().optional(),type:m.string().default("skill"),status:ih.default("active"),frameworkId:m.string().optional(),createdAt:m.string().optional(),updatedAt:m.string().optional()}),QA=m.object({id:Et,statement:Et,description:Et,code:Et,type:Et,status:ih.or(m.object({$in:ih.array()}))}).partial(),pse=m.union([m.object({$or:QA.array()}),QA]),Yv=m.enum(["active","archived"]),l7=m.object({id:m.string(),name:m.string(),description:m.string().optional(),image:m.string().optional(),sourceURI:m.string().url().optional(),status:Yv.default("active"),createdAt:m.string().optional(),updatedAt:m.string().optional()}),mse=Wr.extend({records:l7.array()}),Zv=u7.extend({children:m.array(m.lazy(()=>Zv)),hasChildren:m.boolean(),childrenCursor:m.string().nullable().optional()}).openapi({ref:"SkillTreeNode"}),IK=m.object({hasMore:m.boolean(),cursor:m.string().nullable(),records:m.array(Zv)}),pu=m.lazy(()=>m.object({id:m.string().optional(),statement:m.string(),description:m.string().optional(),code:m.string().optional(),icon:m.string().optional(),type:m.string().optional(),status:ih.optional(),children:m.array(pu).optional()})).openapi({ref:"SkillTreeNodeInput"}),bse=m.object({frameworkId:m.string()}),DK=m.object({id:m.string().optional(),name:m.string().min(1),description:m.string().optional(),image:m.string().optional(),sourceURI:m.string().url().optional(),status:Yv.optional(),skills:m.array(pu).optional(),boostUris:m.array(m.string()).optional()}),gse=m.object({id:m.string(),name:m.string().min(1).optional(),description:m.string().optional(),image:m.string().optional(),sourceURI:m.string().url().optional(),status:Yv.optional()}).refine(r=>r.name!==void 0||r.description!==void 0||r.image!==void 0||r.sourceURI!==void 0||r.status!==void 0,{message:"At least one field must be provided to update",path:["name"]}),vse=m.object({id:m.string()}),yse=m.object({frameworks:m.array(DK.extend({skills:m.array(pu).optional()})).min(1)}),xse=m.object({frameworkId:m.string(),profileId:m.string()}),wse=m.object({frameworkId:m.string()}),_se=Lo.array(),Ese=m.object({id:m.string()}),Ase=m.object({slug:m.string().min(1),name:m.string().min(1)}),Sse=m.object({frameworkId:m.string(),skill:pu,parentId:m.string().nullable().optional()}),Mse=m.object({frameworkId:m.string(),id:m.string(),statement:m.string().optional(),description:m.string().optional(),code:m.string().optional(),icon:m.string().optional(),type:m.string().optional(),status:ih.optional()}).refine(r=>r.statement!==void 0||r.description!==void 0||r.code!==void 0||r.icon!==void 0||r.type!==void 0||r.status!==void 0,{message:"At least one field must be provided to update a skill",path:["statement"]}),RK=m.enum(["recursive","reparent"]),Tse=m.object({frameworkId:m.string(),id:m.string(),strategy:RK.optional().default("reparent")}),Cse=m.object({frameworkId:m.string(),skills:m.array(pu).min(1),parentId:m.string().nullable().optional()}),kse=m.object({frameworkId:m.string(),skills:m.array(pu).min(0)}),Ise=m.object({created:m.number().int().min(0),updated:m.number().int().min(0),deleted:m.number().int().min(0),unchanged:m.number().int().min(0),total:m.number().int().min(0)}),Dse=m.object({frameworkId:m.string(),skillId:m.string().optional(),recursive:m.boolean().optional().default(!1),onlyCountCompetencies:m.boolean().optional().default(!1)}),Rse=m.object({count:m.number().int().min(0)}),Ose=m.object({frameworkId:m.string()}),Nse=m.object({skills:m.array(Zv)}),Pse=m.object({frameworkId:m.string(),skillId:m.string()}),Bse=m.object({path:m.array(u7)}),Lse=m.object({framework:l7,skills:IK});var Op=o(r=>`lc:ceramic:${r}`,"streamIdToCeramicURI");var Xv=m.string().refine(r=>r.split(":").length===3&&r.split(":")[0]==="lc","URI must be of the form lc:${storage}:${url}").refine(r=>r.split(":")[1]==="ceramic","URI must use storage type ceramic (i.e. must be lc:ceramic:${streamID})");var h7={ceramicEndpoint:"https://ceramic-node.welibrary.io:7007",defaultContentFamily:"SuperSkills"};var Np=o(async(r,{ceramicEndpoint:e,defaultContentFamily:t}=h7)=>{let n=new Yl(e),i=o(async(R,I,B,Y)=>r.invoke.didResolver(R,Y),"learnCardResolver"),s={...I_.getResolver(),web:i},f=new hf({resolver:s});n.did=f;let u=r.invoke.getKey(),d=new Sl(h_(u));n.did.setProvider(d),await n.did.authenticate();let y=new Hl({ceramic:n}),w=o(async(R,I={},B={},Y)=>{if(!R)throw new Error("content is required");if(I.controllers||(I.controllers=[n.did.id]),I.family||(I.family=t),"pin"in B||(B.pin=!0),Y?.encrypt){r.debug?.("learnCard.store.Ceramic.upload.publishContentToCeramic - encrypt enabled",Y);let J=Y?.recipients||[];Y?.controllersCanDecrypt&&(J=[...J,...I.controllers]),R=await n?.did?.createDagJWE(R,d7.default.uniq(J))}return r.debug?.("learnCard.store.Ceramic.upload.publishContentToCeramic - content to upload",R,I,B),(await ei.create(n,R,I,B)).id.toString()},"publishContentToCeramic"),A=o(async R=>{let I=(await y.load(R))?.content;if(r.debug?.("learnCard.read.get.readContentFromCeramic",I),I?.ciphertext)try{return await f.decryptDagJWE(I)}catch(B){throw r.debug?.("learnCard.read.get.readContentFromCeramic - Could not decrypt credential - DID not authorized.",B),new Error("Could not decrypt credential - DID not authorized.")}return I},"readContentFromCeramic"),O=o(async(R,I)=>(await Pf.or(oh).parseAsync(R),Op(await w(R,{},{},I))),"uploadCredential");return{name:"Ceramic",displayName:"Ceramic",description:"Uploads/resolves credentials using the Ceramic Network (https://ceramic.network/)",store:{upload:async(R,I)=>(R.debug?.("learnCard.store.Ceramic.upload"),O(I)),uploadEncrypted:async(R,I,B)=>(R.debug?.("learnCard.store.Ceramic.uploadEncrypted"),O(I,{encrypt:!0,controllersCanDecrypt:!0,...B?{recipients:B.recipients}:{}}))},read:{get:async(R,I)=>{if(R.debug?.("learnCard.read.Ceramic.get"),!I)return;let B=await Xv.spa(I);if(!B.success)return;let Y=B.data.split(":")[2];try{return await Pf.or(oh).parseAsync(await A(Y))}catch(P){R.debug?.(P);return}}},methods:{publishContentToCeramic:async(R,I,B)=>Op(await w(I,{},{},B)),readContentFromCeramic:async(R,I)=>A(I),getCeramicClient:()=>n,getDIDObject:()=>n.did}}},"getCeramicPlugin");var OK=Np;
|
|
822
|
+
`):"",this.name="UnsubscriptionError",this.errors=t},"UnsubscriptionErrorImpl")});function wf(r,e){if(r){var t=r.indexOf(e);0<=t&&r.splice(t,1)}}o(wf,"arrRemove");var ua=function(){function r(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return o(r,"Subscription"),r.prototype.unsubscribe=function(){var e,t,n,i,s;if(!this.closed){this.closed=!0;var f=this._parentage;if(f)if(this._parentage=null,Array.isArray(f))try{for(var u=ys(f),d=u.next();!d.done;d=u.next()){var y=d.value;y.remove(this)}}catch(B){e={error:B}}finally{try{d&&!d.done&&(t=u.return)&&t.call(u)}finally{if(e)throw e.error}}else f.remove(this);var w=this.initialTeardown;if(Ct(w))try{w()}catch(B){s=B instanceof X0?B.errors:[B]}var A=this._finalizers;if(A){this._finalizers=null;try{for(var O=ys(A),R=O.next();!R.done;R=O.next()){var I=R.value;try{UE(I)}catch(B){s=s??[],B instanceof X0?s=to(to([],Xn(s)),Xn(B.errors)):s.push(B)}}}catch(B){n={error:B}}finally{try{R&&!R.done&&(i=O.return)&&i.call(O)}finally{if(n)throw n.error}}}if(s)throw new X0(s)}},r.prototype.add=function(e){var t;if(e&&e!==this)if(this.closed)UE(e);else{if(e instanceof r){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(t=this._finalizers)!==null&&t!==void 0?t:[]).push(e)}},r.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},r.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},r.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&wf(t,e)},r.prototype.remove=function(e){var t=this._finalizers;t&&wf(t,e),e instanceof r&&e._removeParent(this)},r.EMPTY=function(){var e=new r;return e.closed=!0,e}(),r}();var av=ua.EMPTY;function Q0(r){return r instanceof ua||r&&"closed"in r&&Ct(r.remove)&&Ct(r.add)&&Ct(r.unsubscribe)}o(Q0,"isSubscription");function UE(r){Ct(r)?r():r.unsubscribe()}o(UE,"execFinalizer");var ro={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1};var Xc={setTimeout:function(r,e){for(var t=[],n=2;n<arguments.length;n++)t[n-2]=arguments[n];var i=Xc.delegate;return i?.setTimeout?i.setTimeout.apply(i,to([r,e],Xn(t))):setTimeout.apply(void 0,to([r,e],Xn(t)))},clearTimeout:function(r){var e=Xc.delegate;return(e?.clearTimeout||clearTimeout)(r)},delegate:void 0};function ep(r){Xc.setTimeout(function(){var e=ro.onUnhandledError;if(e)e(r);else throw r})}o(ep,"reportUnhandledError");function fv(){}o(fv,"noop");var FE=function(){return cv("C",void 0,void 0)}();function $E(r){return cv("E",void 0,r)}o($E,"errorNotification");function qE(r){return cv("N",r,void 0)}o(qE,"nextNotification");function cv(r,e,t){return{kind:r,value:e,error:t}}o(cv,"createNotification");var _f=null;function Qc(r){if(ro.useDeprecatedSynchronousErrorHandling){var e=!_f;if(e&&(_f={errorThrown:!1,error:null}),r(),e){var t=_f,n=t.errorThrown,i=t.error;if(_f=null,n)throw i}}else r()}o(Qc,"errorContext");function jE(r){ro.useDeprecatedSynchronousErrorHandling&&_f&&(_f.errorThrown=!0,_f.error=r)}o(jE,"captureError");var Nl=function(r){on(e,r);function e(t){var n=r.call(this)||this;return n.isStopped=!1,t?(n.destination=t,Q0(t)&&t.add(n)):n.destination=Cq,n}return o(e,"Subscriber"),e.create=function(t,n,i){return new rp(t,n,i)},e.prototype.next=function(t){this.isStopped?lv(qE(t),this):this._next(t)},e.prototype.error=function(t){this.isStopped?lv($E(t),this):(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped?lv(FE,this):(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,r.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(ua);var Sq=Function.prototype.bind;function uv(r,e){return Sq.call(r,e)}o(uv,"bind");var Mq=function(){function r(e){this.partialObserver=e}return o(r,"ConsumerObserver"),r.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(n){tp(n)}},r.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(n){tp(n)}else tp(e)},r.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(t){tp(t)}},r}(),rp=function(r){on(e,r);function e(t,n,i){var s=r.call(this)||this,f;if(Ct(t)||!t)f={next:t??void 0,error:n??void 0,complete:i??void 0};else{var u;s&&ro.useDeprecatedNextContext?(u=Object.create(t),u.unsubscribe=function(){return s.unsubscribe()},f={next:t.next&&uv(t.next,u),error:t.error&&uv(t.error,u),complete:t.complete&&uv(t.complete,u)}):f=t}return s.destination=new Mq(f),s}return o(e,"SafeSubscriber"),e}(Nl);function tp(r){ro.useDeprecatedSynchronousErrorHandling?jE(r):ep(r)}o(tp,"handleUnhandledError");function Tq(r){throw r}o(Tq,"defaultErrorHandler");function lv(r,e){var t=ro.onStoppedNotification;t&&Xc.setTimeout(function(){return t(r,e)})}o(lv,"handleStoppedNotification");var Cq={closed:!0,next:fv,error:Tq,complete:fv};var eu=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function tu(r){return r}o(tu,"identity");function HE(r){return r.length===0?tu:r.length===1?r[0]:o(function(t){return r.reduce(function(n,i){return i(n)},t)},"piped")}o(HE,"pipeFromArray");var Yt=function(){function r(e){e&&(this._subscribe=e)}return o(r,"Observable"),r.prototype.lift=function(e){var t=new r;return t.source=this,t.operator=e,t},r.prototype.subscribe=function(e,t,n){var i=this,s=Iq(e)?e:new rp(e,t,n);return Qc(function(){var f=i,u=f.operator,d=f.source;s.add(u?u.call(s,d):d?i._subscribe(s):i._trySubscribe(s))}),s},r.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},r.prototype.forEach=function(e,t){var n=this;return t=zE(t),new t(function(i,s){var f=new rp({next:function(u){try{e(u)}catch(d){s(d),f.unsubscribe()}},error:s,complete:i});n.subscribe(f)})},r.prototype._subscribe=function(e){var t;return(t=this.source)===null||t===void 0?void 0:t.subscribe(e)},r.prototype[eu]=function(){return this},r.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return HE(e)(this)},r.prototype.toPromise=function(e){var t=this;return e=zE(e),new e(function(n,i){var s;t.subscribe(function(f){return s=f},function(f){return i(f)},function(){return n(s)})})},r.create=function(e){return new r(e)},r}();function zE(r){var e;return(e=r??ro.Promise)!==null&&e!==void 0?e:Promise}o(zE,"getPromiseCtor");function kq(r){return r&&Ct(r.next)&&Ct(r.error)&&Ct(r.complete)}o(kq,"isObserver");function Iq(r){return r&&r instanceof Nl||kq(r)&&Q0(r)}o(Iq,"isSubscriber");function Dq(r){return Ct(r?.lift)}o(Dq,"hasLift");function Lr(r){return function(e){if(Dq(e))return e.lift(function(t){try{return r(t,this)}catch(n){this.error(n)}});throw new TypeError("Unable to lift unknown Observable type")}}o(Lr,"operate");function Ur(r,e,t,n,i){return new Rq(r,e,t,n,i)}o(Ur,"createOperatorSubscriber");var Rq=function(r){on(e,r);function e(t,n,i,s,f,u){var d=r.call(this,t)||this;return d.onFinalize=f,d.shouldUnsubscribe=u,d._next=n?function(y){try{n(y)}catch(w){t.error(w)}}:r.prototype._next,d._error=s?function(y){try{s(y)}catch(w){t.error(w)}finally{this.unsubscribe()}}:r.prototype._error,d._complete=i?function(){try{i()}catch(y){t.error(y)}finally{this.unsubscribe()}}:r.prototype._complete,d}return o(e,"OperatorSubscriber"),e.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;r.prototype.unsubscribe.call(this),!n&&((t=this.onFinalize)===null||t===void 0||t.call(this))}},e}(Nl);var KE=Zc(function(r){return o(function(){r(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"},"ObjectUnsubscribedErrorImpl")});var hv=function(r){on(e,r);function e(){var t=r.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return o(e,"Subject"),e.prototype.lift=function(t){var n=new VE(this,this);return n.operator=t,n},e.prototype._throwIfClosed=function(){if(this.closed)throw new KE},e.prototype.next=function(t){var n=this;Qc(function(){var i,s;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var f=ys(n.currentObservers),u=f.next();!u.done;u=f.next()){var d=u.value;d.next(t)}}catch(y){i={error:y}}finally{try{u&&!u.done&&(s=f.return)&&s.call(f)}finally{if(i)throw i.error}}}})},e.prototype.error=function(t){var n=this;Qc(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=t;for(var i=n.observers;i.length;)i.shift().error(t)}})},e.prototype.complete=function(){var t=this;Qc(function(){if(t._throwIfClosed(),!t.isStopped){t.isStopped=!0;for(var n=t.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 t;return((t=this.observers)===null||t===void 0?void 0:t.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(t){return this._throwIfClosed(),r.prototype._trySubscribe.call(this,t)},e.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},e.prototype._innerSubscribe=function(t){var n=this,i=this,s=i.hasError,f=i.isStopped,u=i.observers;return s||f?av:(this.currentObservers=null,u.push(t),new ua(function(){n.currentObservers=null,wf(u,t)}))},e.prototype._checkFinalizedStatuses=function(t){var n=this,i=n.hasError,s=n.thrownError,f=n.isStopped;i?t.error(s):f&&t.complete()},e.prototype.asObservable=function(){var t=new Yt;return t.source=this,t},e.create=function(t,n){return new VE(t,n)},e}(Yt);var VE=function(r){on(e,r);function e(t,n){var i=r.call(this)||this;return i.destination=t,i.source=n,i}return o(e,"AnonymousSubject"),e.prototype.next=function(t){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.next)===null||i===void 0||i.call(n,t)},e.prototype.error=function(t){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.error)===null||i===void 0||i.call(n,t)},e.prototype.complete=function(){var t,n;(n=(t=this.destination)===null||t===void 0?void 0:t.complete)===null||n===void 0||n.call(t)},e.prototype._subscribe=function(t){var n,i;return(i=(n=this.source)===null||n===void 0?void 0:n.subscribe(t))!==null&&i!==void 0?i:av},e}(hv);var dv=function(r){on(e,r);function e(t){var n=r.call(this)||this;return n._value=t,n}return o(e,"BehaviorSubject"),Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),e.prototype._subscribe=function(t){var n=r.prototype._subscribe.call(this,t);return!n.closed&&t.next(this._value),n},e.prototype.getValue=function(){var t=this,n=t.hasError,i=t.thrownError,s=t._value;if(n)throw i;return this._throwIfClosed(),s},e.prototype.next=function(t){r.prototype.next.call(this,this._value=t)},e}(hv);var pv={now:function(){return(pv.delegate||Date).now()},delegate:void 0};var GE=function(r){on(e,r);function e(t,n){return r.call(this)||this}return o(e,"Action"),e.prototype.schedule=function(t,n){return n===void 0&&(n=0),this},e}(ua);var Pl={setInterval:function(r,e){for(var t=[],n=2;n<arguments.length;n++)t[n-2]=arguments[n];var i=Pl.delegate;return i?.setInterval?i.setInterval.apply(i,to([r,e],Xn(t))):setInterval.apply(void 0,to([r,e],Xn(t)))},clearInterval:function(r){var e=Pl.delegate;return(e?.clearInterval||clearInterval)(r)},delegate:void 0};var WE=function(r){on(e,r);function e(t,n){var i=r.call(this,t,n)||this;return i.scheduler=t,i.work=n,i.pending=!1,i}return o(e,"AsyncAction"),e.prototype.schedule=function(t,n){var i;if(n===void 0&&(n=0),this.closed)return this;this.state=t;var s=this.id,f=this.scheduler;return s!=null&&(this.id=this.recycleAsyncId(f,s,n)),this.pending=!0,this.delay=n,this.id=(i=this.id)!==null&&i!==void 0?i:this.requestAsyncId(f,this.id,n),this},e.prototype.requestAsyncId=function(t,n,i){return i===void 0&&(i=0),Pl.setInterval(t.flush.bind(t,this),i)},e.prototype.recycleAsyncId=function(t,n,i){if(i===void 0&&(i=0),i!=null&&this.delay===i&&this.pending===!1)return n;n!=null&&Pl.clearInterval(n)},e.prototype.execute=function(t,n){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var i=this._execute(t,n);if(i)return i;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(t,n){var i=!1,s;try{this.work(t)}catch(f){i=!0,s=f||new Error("Scheduled action threw falsy error")}if(i)return this.unsubscribe(),s},e.prototype.unsubscribe=function(){if(!this.closed){var t=this,n=t.id,i=t.scheduler,s=i.actions;this.work=this.state=this.scheduler=null,this.pending=!1,wf(s,this),n!=null&&(this.id=this.recycleAsyncId(i,n,null)),this.delay=null,r.prototype.unsubscribe.call(this)}},e}(GE);var mv=function(){function r(e,t){t===void 0&&(t=r.now),this.schedulerActionCtor=e,this.now=t}return o(r,"Scheduler"),r.prototype.schedule=function(e,t,n){return t===void 0&&(t=0),new this.schedulerActionCtor(this,e).schedule(n,t)},r.now=pv.now,r}();var JE=function(r){on(e,r);function e(t,n){n===void 0&&(n=mv.now);var i=r.call(this,t,n)||this;return i.actions=[],i._active=!1,i}return o(e,"AsyncScheduler"),e.prototype.flush=function(t){var n=this.actions;if(this._active){n.push(t);return}var i;this._active=!0;do if(i=t.execute(t.state,t.delay))break;while(t=n.shift());if(this._active=!1,i){for(;t=n.shift();)t.unsubscribe();throw i}},e}(mv);var Oq=new JE(WE),YE=Oq;var np=new Yt(function(r){return r.complete()});function ip(r){return r&&Ct(r.schedule)}o(ip,"isScheduler");function ZE(r){return r[r.length-1]}o(ZE,"last");function XE(r){return ip(ZE(r))?r.pop():void 0}o(XE,"popScheduler");function QE(r,e){return typeof ZE(r)=="number"?r.pop():e}o(QE,"popNumber");var ru=o(function(r){return r&&typeof r.length=="number"&&typeof r!="function"},"isArrayLike");function op(r){return Ct(r?.then)}o(op,"isPromise");function sp(r){return Ct(r[eu])}o(sp,"isInteropObservable");function ap(r){return Symbol.asyncIterator&&Ct(r?.[Symbol.asyncIterator])}o(ap,"isAsyncIterable");function fp(r){return new TypeError("You provided "+(r!==null&&typeof r=="object"?"an invalid object":"'"+r+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}o(fp,"createInvalidObservableTypeError");function Nq(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}o(Nq,"getSymbolIterator");var cp=Nq();function up(r){return Ct(r?.[cp])}o(up,"isIterable");function lp(r){return BE(this,arguments,o(function(){var t,n,i,s;return Z0(this,function(f){switch(f.label){case 0:t=r.getReader(),f.label=1;case 1:f.trys.push([1,,9,10]),f.label=2;case 2:return[4,xf(t.read())];case 3:return n=f.sent(),i=n.value,s=n.done,s?[4,xf(void 0)]:[3,5];case 4:return[2,f.sent()];case 5:return[4,xf(i)];case 6:return[4,f.sent()];case 7:return f.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}})},"readableStreamLikeToAsyncGenerator_1"))}o(lp,"readableStreamLikeToAsyncGenerator");function hp(r){return Ct(r?.getReader)}o(hp,"isReadableStreamLike");function sn(r){if(r instanceof Yt)return r;if(r!=null){if(sp(r))return Pq(r);if(ru(r))return Bq(r);if(op(r))return Lq(r);if(ap(r))return e9(r);if(up(r))return Uq(r);if(hp(r))return Fq(r)}throw fp(r)}o(sn,"innerFrom");function Pq(r){return new Yt(function(e){var t=r[eu]();if(Ct(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}o(Pq,"fromInteropObservable");function Bq(r){return new Yt(function(e){for(var t=0;t<r.length&&!e.closed;t++)e.next(r[t]);e.complete()})}o(Bq,"fromArrayLike");function Lq(r){return new Yt(function(e){r.then(function(t){e.closed||(e.next(t),e.complete())},function(t){return e.error(t)}).then(null,ep)})}o(Lq,"fromPromise");function Uq(r){return new Yt(function(e){var t,n;try{for(var i=ys(r),s=i.next();!s.done;s=i.next()){var f=s.value;if(e.next(f),e.closed)return}}catch(u){t={error:u}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}e.complete()})}o(Uq,"fromIterable");function e9(r){return new Yt(function(e){$q(r,e).catch(function(t){return e.error(t)})})}o(e9,"fromAsyncIterable");function Fq(r){return e9(lp(r))}o(Fq,"fromReadableStreamLike");function $q(r,e){var t,n,i,s;return PE(this,void 0,void 0,function(){var f,u;return Z0(this,function(d){switch(d.label){case 0:d.trys.push([0,5,6,11]),t=LE(r),d.label=1;case 1:return[4,t.next()];case 2:if(n=d.sent(),!!n.done)return[3,4];if(f=n.value,e.next(f),e.closed)return[2];d.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return u=d.sent(),i={error:u},[3,11];case 6:return d.trys.push([6,,9,10]),n&&!n.done&&(s=t.return)?[4,s.call(t)]:[3,8];case 7:d.sent(),d.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($q,"process");function Oi(r,e,t,n,i){n===void 0&&(n=0),i===void 0&&(i=!1);var s=e.schedule(function(){t(),i?r.add(this.schedule(null,n)):this.unsubscribe()},n);if(r.add(s),!i)return s}o(Oi,"executeSchedule");function dp(r,e){return e===void 0&&(e=0),Lr(function(t,n){t.subscribe(Ur(n,function(i){return Oi(n,r,function(){return n.next(i)},e)},function(){return Oi(n,r,function(){return n.complete()},e)},function(i){return Oi(n,r,function(){return n.error(i)},e)}))})}o(dp,"observeOn");function pp(r,e){return e===void 0&&(e=0),Lr(function(t,n){n.add(r.schedule(function(){return t.subscribe(n)},e))})}o(pp,"subscribeOn");function t9(r,e){return sn(r).pipe(pp(e),dp(e))}o(t9,"scheduleObservable");function r9(r,e){return sn(r).pipe(pp(e),dp(e))}o(r9,"schedulePromise");function n9(r,e){return new Yt(function(t){var n=0;return e.schedule(function(){n===r.length?t.complete():(t.next(r[n++]),t.closed||this.schedule())})})}o(n9,"scheduleArray");function i9(r,e){return new Yt(function(t){var n;return Oi(t,e,function(){n=r[cp](),Oi(t,e,function(){var i,s,f;try{i=n.next(),s=i.value,f=i.done}catch(u){t.error(u);return}f?t.complete():t.next(s)},0,!0)}),function(){return Ct(n?.return)&&n.return()}})}o(i9,"scheduleIterable");function mp(r,e){if(!r)throw new Error("Iterable cannot be null");return new Yt(function(t){Oi(t,e,function(){var n=r[Symbol.asyncIterator]();Oi(t,e,function(){n.next().then(function(i){i.done?t.complete():t.next(i.value)})},0,!0)})})}o(mp,"scheduleAsyncIterable");function o9(r,e){return mp(lp(r),e)}o(o9,"scheduleReadableStreamLike");function s9(r,e){if(r!=null){if(sp(r))return t9(r,e);if(ru(r))return n9(r,e);if(op(r))return r9(r,e);if(ap(r))return mp(r,e);if(up(r))return i9(r,e);if(hp(r))return o9(r,e)}throw fp(r)}o(s9,"scheduled");function a9(r,e){return e?s9(r,e):sn(r)}o(a9,"from");var bp=Zc(function(r){return o(function(){r(this),this.name="EmptyError",this.message="no elements in sequence"},"EmptyErrorImpl")});function f9(r){return r instanceof Date&&!isNaN(r)}o(f9,"isValidDate");function gp(r,e){return Lr(function(t,n){var i=0;t.subscribe(Ur(n,function(s){n.next(r.call(e,s,i++))}))})}o(gp,"map");var qq=Array.isArray;function jq(r,e){return qq(e)?r.apply(void 0,to([],Xn(e))):r(e)}o(jq,"callOrApply");function c9(r){return gp(function(e){return jq(r,e)})}o(c9,"mapOneOrManyArgs");function u9(r,e,t,n,i,s,f,u){var d=[],y=0,w=0,A=!1,O=o(function(){A&&!d.length&&!y&&e.complete()},"checkComplete"),R=o(function(B){return y<n?I(B):d.push(B)},"outerNext"),I=o(function(B){s&&e.next(B),y++;var Y=!1;sn(t(B,w++)).subscribe(Ur(e,function(P){i?.(P),s?R(P):e.next(P)},function(){Y=!0},void 0,function(){if(Y)try{y--;for(var P=o(function(){var J=d.shift();f?Oi(e,f,function(){return I(J)}):I(J)},"_loop_1");d.length&&y<n;)P();O()}catch(J){e.error(J)}}))},"doInnerSub");return r.subscribe(Ur(e,R,function(){A=!0,O()})),function(){u?.()}}o(u9,"mergeInternals");function Bl(r,e,t){return t===void 0&&(t=1/0),Ct(e)?Bl(function(n,i){return gp(function(s,f){return e(n,s,i,f)})(sn(r(n,i)))},t):(typeof e=="number"&&(t=e),Lr(function(n,i){return u9(n,i,r,t)}))}o(Bl,"mergeMap");function l9(r){return r===void 0&&(r=1/0),Bl(tu,r)}o(l9,"mergeAll");var Hq=["addListener","removeListener"],zq=["addEventListener","removeEventListener"],Kq=["on","off"];function Ll(r,e,t,n){if(Ct(t)&&(n=t,t=void 0),n)return Ll(r,e,t).pipe(c9(n));var i=Xn(Wq(r)?zq.map(function(u){return function(d){return r[u](e,d,t)}}):Vq(r)?Hq.map(h9(r,e)):Gq(r)?Kq.map(h9(r,e)):[],2),s=i[0],f=i[1];if(!s&&ru(r))return Bl(function(u){return Ll(u,e,t)})(sn(r));if(!s)throw new TypeError("Invalid event target");return new Yt(function(u){var d=o(function(){for(var y=[],w=0;w<arguments.length;w++)y[w]=arguments[w];return u.next(1<y.length?y:y[0])},"handler");return s(d),function(){return f(d)}})}o(Ll,"fromEvent");function h9(r,e){return function(t){return function(n){return r[t](e,n)}}}o(h9,"toCommonHandlerRegistry");function Vq(r){return Ct(r.addListener)&&Ct(r.removeListener)}o(Vq,"isNodeStyleEventEmitter");function Gq(r){return Ct(r.on)&&Ct(r.off)}o(Gq,"isJQueryStyleEventEmitter");function Wq(r){return Ct(r.addEventListener)&&Ct(r.removeEventListener)}o(Wq,"isEventTarget");function Ul(r,e,t){r===void 0&&(r=0),t===void 0&&(t=YE);var n=-1;return e!=null&&(ip(e)?t=e:n=e),new Yt(function(i){var s=f9(r)?+r-t.now():r;s<0&&(s=0);var f=0;return t.schedule(function(){i.closed||(i.next(f++),0<=n?this.schedule(void 0,n):i.complete())},s)})}o(Ul,"timer");function bv(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];var t=XE(r),n=QE(r,1/0),i=r;return i.length?i.length===1?sn(i[0]):l9(n)(a9(i,t)):np}o(bv,"merge");function d9(r,e){return Lr(function(t,n){var i=0;t.subscribe(Ur(n,function(s){return r.call(e,s,i++)&&n.next(s)}))})}o(d9,"filter");function p9(r){return Lr(function(e,t){var n=!1;e.subscribe(Ur(t,function(i){n=!0,t.next(i)},function(){n||t.next(r),t.complete()}))})}o(p9,"defaultIfEmpty");function m9(r){return r<=0?function(){return np}:Lr(function(e,t){var n=0;e.subscribe(Ur(t,function(i){++n<=r&&(t.next(i),r<=n&&t.complete())}))})}o(m9,"take");function b9(r){return r===void 0&&(r=Jq),Lr(function(e,t){var n=!1;e.subscribe(Ur(t,function(i){n=!0,t.next(i)},function(){return n?t.complete():t.error(r())}))})}o(b9,"throwIfEmpty");function Jq(){return new bp}o(Jq,"defaultErrorFactory");function gv(r,e){var t=arguments.length>=2;return function(n){return n.pipe(r?d9(function(i,s){return r(i,s,n)}):tu,m9(1),t?p9(e):b9(function(){return new bp}))}}o(gv,"first");function vv(r,e){return Lr(function(t,n){var i=e??{},s=i.leading,f=s===void 0?!0:s,u=i.trailing,d=u===void 0?!1:u,y=!1,w=null,A=null,O=!1,R=o(function(){A?.unsubscribe(),A=null,d&&(Y(),O&&n.complete())},"endThrottling"),I=o(function(){A=null,O&&n.complete()},"cleanupThrottling"),B=o(function(P){return A=sn(r(P)).subscribe(Ur(n,R,I))},"startThrottle"),Y=o(function(){if(y){y=!1;var P=w;w=null,n.next(P),!O&&B(P)}},"send");t.subscribe(Ur(n,function(P){y=!0,w=P,!(A&&!A.closed)&&(f?Y():B(P))},function(){O=!0,!(d&&y&&A&&!A.closed)&&n.complete()}))})}o(vv,"throttle");var g9;(function(r){r[r.GENESIS=0]="GENESIS",r[r.PARTIAL=1]="PARTIAL",r[r.SIGNED=2]="SIGNED"})(g9||(g9={}));var Fl;(function(r){r[r.NOT_REQUESTED=0]="NOT_REQUESTED",r[r.PENDING=1]="PENDING",r[r.PROCESSING=2]="PROCESSING",r[r.ANCHORED=3]="ANCHORED",r[r.FAILED=4]="FAILED"})(Fl||(Fl={}));var xv;(function(r){r[r.GENESIS=0]="GENESIS",r[r.SIGNED=1]="SIGNED",r[r.ANCHOR=2]="ANCHOR"})(xv||(xv={}));var xs=class extends Yt{constructor(e,t){super(n=>{e.subscribe(n)}),this.state$=e,this._context=t}get id(){return new it(this.state$.value.type,this.state$.value.log[0].cid)}get api(){return this._context.api}get content(){let{next:e,content:t}=this.state$.value;return(0,yv.default)(e?.content??t)}get tip(){return this.state$.value.log[this.state$.value.log.length-1].cid}get commitId(){return Bt.make(this.id,this.tip)}get allCommitIds(){return this.state$.value.log.map(({cid:e})=>Bt.make(this.id,e))}get anchorCommitIds(){return this.state$.value.log.filter(({type:e})=>e===xv.ANCHOR).map(({cid:e})=>Bt.make(this.id,e))}get state(){return(0,yv.default)(this.state$.value)}async sync(e={}){e={sync:_r.PREFER_CACHE,...e};let t=await this.api.loadStream(this.id,e);this.state$.next(t.state)}async requestAnchor(){return this.api.requestAnchor(this.id)}};o(xs,"Stream");function nu(){return r=>{}}o(nu,"StreamStatic");var _9=Ft(y9(),1);function x9(r){let e=new AbortController;if(r.length===0)throw Error("Need abort signals to create a merged abort signal");return r.some(t=>t.aborted)?(e.abort(),e.signal):(bv(...r.map(t=>Ll(t,"abort"))).pipe(gv()).subscribe(()=>{e.abort()}),e.signal)}o(x9,"mergeAbortSignals");var $l=class{constructor(e){let t=new AbortController;if(this.signal=t.signal,e<=0){t.abort();return}this._subscription=Ul(e).subscribe(()=>{t.abort()})}clear(){this._subscription?.unsubscribe()}};o($l,"TimedAbortSignal");async function w9(r,e){let t=new AbortController,n=o(()=>{t.abort()},"onAbort");return r.addEventListener("abort",n),r.aborted&&t.abort(),e(t.signal).finally(()=>{r.removeEventListener("abort",n)})}o(w9,"abortable");var Yq=60*1e3*3;async function Vr(r,e={}){e.body&&Object.assign(e,{body:JSON.stringify(e.body),headers:{...e.headers,"Content-Type":"application/json"}});let t=e.timeout||Yq,n=new $l(t),i=e.signal?x9([e.signal,n.signal]):n.signal,s=await w9(i,f=>(0,_9.default)(String(r),{...e,signal:f})).finally(()=>n.clear());if(!s.ok){let f=await s.text();throw new Error(`HTTP request to '${r}' failed with status '${s.statusText}': ${f}`)}return s.json()}o(Vr,"fetchJson");var ql=Ft(Vc(),1);ji();function ws(r){let e=Ye.asCID(r);if(e)return e;if(typeof r=="string")return Ye.parse(r);if(r instanceof Uint8Array)return Ye.decode(r);throw new Error(`${r} cannot be converted to a CID`)}o(ws,"toCID");var E9=0,Qt=class{static streamIdFromState(e){return new it(e.type,e.log[0].cid)}static serializeCommit(e){let t=(0,ql.default)(e);return Qt.isSignedCommitContainer(t)?(t.jws.link=t.jws.link.toString(),t.linkedBlock=Rt(t.linkedBlock,"base64"),t.cacaoBlock&&(t.cacaoBlock=Rt(t.cacaoBlock,"base64")),t):(Qt.isSignedCommit(e)&&(t.link=t.link.toString()),Qt.isAnchorCommit(e)&&(t.proof=t.proof.toString()),t.id&&(t.id=t.id.toString()),t.prev&&(t.prev=t.prev.toString()),e.header?.model&&(t.header.model=Rt(e.header.model,"base64")),t)}static deserializeCommit(e){let t=(0,ql.default)(e);return Qt.isSignedCommitContainer(t)?(t.jws.link=ws(t.jws.link),t.linkedBlock=$t(t.linkedBlock,"base64"),t.cacaoBlock&&(t.cacaoBlock=$t(t.cacaoBlock,"base64")),t):(Qt.isSignedCommit(t)&&(t.link=ws(t.link)),Qt.isAnchorCommit(t)&&(t.proof=ws(t.proof)),t.id&&(t.id=ws(t.id)),t.prev&&(t.prev=ws(t.prev)),t.header?.model&&(t.header.model=$t(t.header.model,"base64")),t)}static serializeState(e){let t=(0,ql.default)(e);return t.log=t.log.map(n=>({...n,cid:n.cid.toString()})),t.anchorStatus!=null&&(t.anchorStatus=Fl[t.anchorStatus]),t.anchorProof!=null&&(t.anchorProof.txHash=t.anchorProof.txHash.toString(),t.anchorProof.root=t.anchorProof.root.toString()),e.metadata?.model&&(t.metadata.model=e.metadata.model.toString()),e.next?.metadata?.model&&(t.next.metadata.model=e.next.metadata.model.toString()),e.metadata?.unique&&e.type!=E9&&(t.metadata.unique=Rt(t.metadata.unique,"base64")),t.doctype=In.nameByCode(t.type),t}static deserializeState(e){if(!e)return null;let t=(0,ql.default)(e);return t.doctype&&(t.type=In.codeByName(t.doctype),delete t.doctype),t.log=t.log.map(n=>({...n,cid:ws(n.cid)})),t.anchorProof&&(t.anchorProof.txHash=ws(t.anchorProof.txHash),t.anchorProof.root=ws(t.anchorProof.root)),t.anchorStatus&&(t.anchorStatus=Fl[t.anchorStatus]),e.metadata?.model&&(t.metadata.model=it.fromString(e.metadata.model)),e.next?.metadata?.model&&(t.next.metadata.model=it.fromString(e.next.metadata.model)),e.metadata?.unique&&e.type!=E9&&(t.metadata.unique=$t(e.metadata.unique,"base64")),t}static statesEqual(e,t){return JSON.stringify(Qt.serializeState(e))===JSON.stringify(Qt.serializeState(t))}static isStateSupersetOf(e,t){if(e.log.length<t.log.length)return!1;for(let n in t.log)if(!e.log[n].cid.equals(t.log[n].cid))return!1;return!(e.log.length===t.log.length&&e.anchorStatus!=t.anchorStatus)}static assertCommitLinksToState(e,t){let n=this.streamIdFromState(e);if(t.id&&!t.id.equals(e.log[0].cid))throw new Error(`Invalid genesis CID in commit for StreamID ${n.toString()}. Found: ${t.id}, expected ${e.log[0].cid}`);let i=e.log[e.log.length-1].cid;if(!t.prev.equals(i))throw new Error(`Commit doesn't properly point to previous commit in log. Expected ${i}, found 'prev' ${t.prev}`)}static async convertCommitToSignedCommitContainer(e,t){if(Qt.isSignedCommit(e)){let n=await t.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(Qt,"StreamUtils");var jl=class extends dv{next(e){let t=this.value;Qt.statesEqual(t,e)||super.next(e)}};o(jl,"StreamStateSubject");var Zq=function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var u=r.length-1;u>=0;u--)(f=r[u])&&(s=(i<3?f(s):i>3?f(e,t,s):f(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},Qn,wv={anchor:!0,publish:!0,pin:!0,sync:_r.PREFER_CACHE},Xq={sync:_r.PREFER_CACHE},A9={anchor:!0,publish:!0,throwOnInvalidCommit:!0};function _v(r,e){if(typeof r?.schema=="string")try{Bt.fromString(r.schema)}catch{throw new Error("Schema must be a CommitID")}let t={controllers:r?.controllers,family:r?.family,schema:r?.schema?.toString(),tags:r?.tags};if(e)r?.deterministic||(t.unique=Rt((0,T9.randomBytes)(12),"base64")),r?.forbidControllerChange&&(t.forbidControllerChange=!0);else{if(r?.deterministic!==void 0||r?.unique!==void 0)throw new Error("Cannot change 'deterministic' or 'unique' properties on existing Streams");if(r?.forbidControllerChange!==void 0)throw new Error("Cannot change 'forbidControllerChange' property on existing Streams")}return Object.keys(t).forEach(n=>t[n]===void 0&&delete t[n]),t}o(_v,"headerFromMetadata");async function S9(r){if(!r.did)throw new Error("No DID provided");return r.did.authenticated||(await r.did.authenticate(),r.loggerProvider&&r.loggerProvider.getDiagnosticsLogger().imp(`Now authenticated as DID ${r.did.id}`)),r.did}o(S9,"getAuthenticatedDID");async function Ev(){throw new Error("Historical stream commits cannot be modified. Load the stream without specifying a commit to make updates.")}o(Ev,"throwReadOnlyError");var ei=Qn=o(class extends xs{constructor(){super(...arguments),this._isReadOnly=!1}get content(){return super.content}get metadata(){let{next:e,metadata:t}=this.state$.value;return(0,M9.default)(e?.metadata??t)}get controllers(){return this.metadata.controllers}static async create(e,t,n,i={}){i={...wv,...i},!n?.deterministic&&i.syncTimeoutSeconds==null&&(i.syncTimeoutSeconds=0);let s=i.asDID?{did:i.asDID}:e,f=await Qn.makeGenesis(s,t,n);return e.createStreamFromGenesis(Qn.STREAM_TYPE_ID,f,i)}static async createFromGenesis(e,t,n={}){n={...wv,...n},t.header?.unique&&n.syncTimeoutSeconds==null&&(n.syncTimeoutSeconds=0);let i=t.data?await Qn._signDagJWS(e,t):t;return e.createStreamFromGenesis(Qn.STREAM_TYPE_ID,i,n)}static async deterministic(e,t,n={}){if(n={...wv,...n},t={...t,deterministic:!0},t.family==null&&t.tags==null)throw new Error("Family and/or tags are required when creating a deterministic tile document");let i=await Qn.makeGenesis(e,null,t);return e.createStreamFromGenesis(Qn.STREAM_TYPE_ID,i,n)}static async load(e,t,n={}){n={...Xq,...n};let i=dn.from(t);if(i.type!=Qn.STREAM_TYPE_ID)throw new Error(`StreamID ${i.toString()} does not refer to a '${Qn.STREAM_TYPE_NAME}' stream, but to a ${i.typeName}`);return e.loadStream(i,n)}async update(e,t,n={}){n={...A9,...n};let i=n.asDID?{did:n.asDID}:this.api,s=await this.makeCommit(i,e,t),f=await this.api.applyCommit(this.id,s,n);this.state$.next(f.state)}async patch(e,t={}){t={...A9,...t};let i={header:_v(this.metadata,!1),data:e,prev:this.tip,id:this.id.cid},s=await Qn._signDagJWS(this.api,i),f=await this.api.applyCommit(this.id,s,t);this.state$.next(f.state)}makeReadOnly(){this.update=Ev,this.patch=Ev,this.sync=Ev,this._isReadOnly=!0}get isReadOnly(){return this._isReadOnly}async makeCommit(e,t,n){let i=await this._makeRawCommit(t,n);return Qn._signDagJWS(e,i)}async _makeRawCommit(e,t){t||(t={});let n=_v(t,!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=U0.compare(this.content,e),s=this.state.log[0];return{header:n,data:i,prev:this.tip,id:s.cid}}static async makeGenesis(e,t,n){if(n||(n={}),!n.controllers||n.controllers.length===0)if(e.did){let f=await S9(e);n.controllers=[f.hasParent?f.parent:f.id]}else throw new Error("No controllers specified");if(n.controllers?.length!==1)throw new Error("Exactly one controller must be specified");let i=_v(n,!0);if(n?.deterministic&&t)throw new Error("Initial content must be null when creating a deterministic Tile document");if(t==null){let f={header:i};return rf(f),f}let s={data:t,header:i};return Qn._signDagJWS(e,s)}static async _signDagJWS(e,t){return(await S9(e)).createDagJWS(t)}},"TileDocument");ei.STREAM_TYPE_NAME="tile";ei.STREAM_TYPE_ID=0;ei=Qn=Zq([nu()],ei);var N9=Ft(I9(),1);function fj(r,e){if(e.has(r))throw new TypeError("Cannot initialize the same private elements twice on an object")}o(fj,"_checkPrivateRedeclaration");function cj(r,e){return e.get?e.get.call(r):e.value}o(cj,"_classApplyDescriptorGet");function uj(r,e,t){if(e.set)e.set.call(r,t);else{if(!e.writable)throw new TypeError("attempted to set read only private field");e.value=t}}o(uj,"_classApplyDescriptorSet");function O9(r,e,t){if(!e.has(r))throw new TypeError("attempted to "+t+" private field on non-instance");return e.get(r)}o(O9,"_classExtractFieldDescriptor");function Tv(r,e){var t=O9(r,e,"get");return cj(r,t)}o(Tv,"_classPrivateFieldGet");function D9(r,e,t){fj(r,e),e.set(r,t)}o(D9,"_classPrivateFieldInit");function R9(r,e,t){var n=O9(r,e,"set");return uj(r,n,t),t}o(R9,"_classPrivateFieldSet");function lj(r){return typeof r=="string"||Bt.isInstance(r)||it.isInstance(r)?{streamId:r}:{streamId:r.streamId,genesis:r.genesis}}o(lj,"keyToQuery");function Cv(r){return typeof r=="string"?dn.from(r).toString():Bt.isInstance(r)||it.isInstance(r)?r.toString():r.streamId.toString()}o(Cv,"keyToString");async function hj(r){let e=await ei.makeGenesis({},null,{...r,deterministic:!0}),t=await it.fromGenesis("tile",e);return{genesis:e,streamId:t}}o(hj,"getDeterministicQuery");var dj=o(()=>Promise.resolve([]),"tempBatchLoadFn"),xp=new WeakMap,kv=new WeakMap,Hl=class extends N9.default{cache(e){if(!Tv(this,kv))return!1;let t=e.id.toString();return this.clear(t).prime(t,e),!0}async create(e,t,n){let i=await ei.create(Tv(this,xp),e,t,n);return this.cache(i),i}async deterministic(e,t){let n=await hj(e);try{return await super.load(n)}catch{let s=await ei.createFromGenesis(Tv(this,xp),n.genesis,t);return this.cache(s),s}}async load(e){return await super.load(e)}async update(e,t,n,i){let s=Cv(e);this.clear(s);let f=await this.load({streamId:s});return await f.update(t,n,i),f}constructor(e){super(dj,{cache:!0,cacheKeyFn:Cv,cacheMap:e.cache!=null&&typeof e.cache!="boolean"?e.cache:void 0}),D9(this,xp,{writable:!0,value:void 0}),D9(this,kv,{writable:!0,value:void 0}),this._batchLoadFn=async t=>{e.cache||this.clearAll();let n=await e.ceramic.multiQuery(t.map(lj),e.multiqueryTimeout);return t.map(i=>{let s=Cv(i),f=n[s];return f||new Error(`Failed to load stream: ${s}`)})},R9(this,xp,e.ceramic),R9(this,kv,!!e.cache)}};o(Hl,"TileLoader");function Iv(r){return typeof r=="string"?it.fromString(r):r}o(Iv,"typeStreamID");function P9(r,e){let t=new URL(r);for(let[n,i]of Object.entries(e))it.isInstance(i)?t.searchParams.set(n,i.toString()):typeof i=="object"?t.searchParams.set(n,JSON.stringify(i)):t.searchParams.set(n,i);return t}o(P9,"serializeObjectToSearchParams");function Dv(r){let e={};for(let[t,n]of Object.entries(r))it.isInstance(n)?e[t]=n.toString():e[t]=n;return e}o(Dv,"serializeObjectForHttpPost");var an=class extends Yt{constructor(e,t,n){super(i=>{this.state$.observers.length===0&&(this.periodicSubscription=Ul(0,n).pipe(vv(()=>this._syncState(this.id,{sync:_r.PREFER_CACHE}))).subscribe()),this.state$.subscribe(i).add(()=>{this.state$.observers.length===0&&this.periodicSubscription?.unsubscribe()})}),this.state$=new jl(e),this._apiUrl=new URL(t)}get value(){return this.state$.value}get state(){return this.state$.value}next(e){this.state$.next(e)}async _syncState(e,t){let n=await an._load(e,this._apiUrl,t);this.state$.next(Qt.deserializeState(n))}get id(){return new it(this.state$.value.type,this.state$.value.log[0].cid)}static async createFromGenesis(e,t,n,i,s){let f=new URL("./streams",e),{state:u}=await Vr(f,{method:"post",body:{type:t,genesis:Qt.serializeCommit(n),opts:i}});return new an(Qt.deserializeState(u),e,s)}static async applyCommit(e,t,n,i,s){let f=new URL("./commits",e),{state:u}=await Vr(f,{method:"post",body:{streamId:t.toString(),commit:Qt.serializeCommit(n),opts:i}});return new an(Qt.deserializeState(u),e,s)}static async _load(e,t,n){let i=P9(new URL(`./streams/${e}`,t),n),{state:s}=await Vr(i);return s}static async load(e,t,n,i){let s=await an._load(e,t,i);return new an(Qt.deserializeState(s),t,n)}static async loadStreamCommits(e,t){let n=new URL(`./commits/${e}`,t),{commits:i}=await Vr(n);return i.map(s=>({cid:s.cid,value:Qt.deserializeCommit(s.value)}))}complete(){this.state$.complete()}};o(an,"Document");var Ef;(function(r){r[r.PREFER_CACHE=0]="PREFER_CACHE",r[r.SYNC_ALWAYS=1]="SYNC_ALWAYS",r[r.NEVER_SYNC=2]="NEVER_SYNC",r[r.SYNC_ON_ERROR=3]="SYNC_ON_ERROR"})(Ef||(Ef={}));var Rv=Ft(Vc(),1);var B9;(function(r){r[r.GENESIS=0]="GENESIS",r[r.PARTIAL=1]="PARTIAL",r[r.SIGNED=2]="SIGNED"})(B9||(B9={}));var Ov;(function(r){r[r.GENESIS=0]="GENESIS",r[r.SIGNED=1]="SIGNED",r[r.ANCHOR=2]="ANCHOR"})(Ov||(Ov={}));var zl=class extends Yt{constructor(e,t){super(n=>{e.subscribe(n)}),this.state$=e,this._context=t}get id(){return new it(this.state$.value.type,this.state$.value.log[0].cid)}get api(){return this._context.api}get content(){let{next:e,content:t}=this.state$.value;return(0,Rv.default)(e?.content??t)}get tip(){return this.state$.value.log[this.state$.value.log.length-1].cid}get commitId(){return Bt.make(this.id,this.tip)}get allCommitIds(){return this.state$.value.log.map(({cid:e})=>Bt.make(this.id,e))}get anchorCommitIds(){return this.state$.value.log.filter(({type:e})=>e===Ov.ANCHOR).map(({cid:e})=>Bt.make(this.id,e))}get state(){return(0,Rv.default)(this.state$.value)}async sync(e={}){e={sync:Ef.PREFER_CACHE,...e};let t=await this.api.loadStream(this.id,e);this.state$.next(t.state)}async requestAnchor(){return this.api.requestAnchor(this.id)}};o(zl,"Stream");function L9(){return r=>{}}o(L9,"StreamStatic");function U9(r){if(typeof r=="string"&&r.includes("@")){let[e,t]=r.split("@");if(!e||!t)throw new Error("Invalid accountId provided");return new na({address:e,chainId:t})}return new na(r)}o(U9,"normalizeAccountId");var pj="(?:%[0-9a-fA-F]{2})",F9=`(?:[a-zA-Z0-9._-]|${pj})`,mj="([a-z0-9]+)",bj=`((?:${F9}*:)*(${F9}+))`,$9="[a-zA-Z0-9_.:%-]",gj=`;${$9}+=${$9}*`,vj=`((${gj})*)`,yj="(/[^#?]*)?",xj="([?][^#]*)?",wj="(#.*)?",_j=new RegExp(`^did:${mj}:${bj}${vj}${yj}${xj}${wj}$`);function q9(r){if(r===""||!r)return null;let e=r.match(_j);if(e){let t={did:`did:${e[1]}:${e[2]}`,method:e[1],id:e[2],didUrl:r};if(e[4]){let n=e[4].slice(1).split(";");t.params={};for(let i of n){let s=i.split("=");t.params[s[0]]=s[1]}}return e[6]&&(t.path=e[6]),e[7]&&(t.query=e[7].slice(1)),e[8]&&(t.fragment=e[8].slice(1)),t}return null}o(q9,"parse");var H9=Ft(Vc(),1);var Ej=function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var u=r.length-1;u>=0;u--)(f=r[u])&&(s=(i<3?f(s):i>3?f(e,t,s):f(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},Af,Nv=o(()=>{throw new Error("Historical stream commits cannot be modified. Load the stream without specifying a commit to make updates.")},"throwReadOnlyError"),j9={anchor:!1,publish:!0,sync:Ef.PREFER_CACHE},Pv={anchor:!0,publish:!0},Aj={sync:Ef.PREFER_CACHE},Sf=Af=o(class extends zl{constructor(){super(...arguments),this._isReadOnly=!1}get did(){return this.content}get metadata(){let{next:e,metadata:t}=this.state$.value;return(0,H9.default)(e?.metadata??t)}get controllers(){return this.metadata.controllers}static async fromAccount(e,t,n={}){n={...j9,...n};let i=U9(t),s=Af.makeGenesis(i);return Af.fromGenesis(e,s,n)}static async fromGenesis(e,t,n={}){return n={...j9,...n},e.createStreamFromGenesis(Af.STREAM_TYPE_ID,t,n)}async setDid(e,t,n={}){n={...Pv,...n};let i=typeof e=="string"?e.trim():e.id;if(q9(i)?.did!==i)throw new Error(`DID is not valid: '${i}'`);let f=await t.createLink(i);return this.setDidProof(f,n)}async setDidProof(e,t={}){t={...Pv,...t};let n=this.makeCommit(e),i=await this.api.applyCommit(this.id,n,t);this.state$.next(i.state)}async clearDid(e,t={}){t={...Pv,...t};let n=await e.createLink("");return this.setDidProof(n,t)}static async load(e,t,n={}){n={...Aj,...n};let i=dn.from(t);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=Nv,this.setDid=Nv,this.sync=Nv,this._isReadOnly=!0}get isReadOnly(){return this._isReadOnly}},"Caip10Link");Sf.STREAM_TYPE_NAME="caip10-link";Sf.STREAM_TYPE_ID=1;Sf=Af=Ej([L9()],Sf);ji();Fa();var SA=Ft(EA(),1);var gH=function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var u=r.length-1;u>=0;u--)(f=r[u])&&(s=(i<3?f(s):i>3?f(e,t,s):f(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},Ro,vH={sync:_r.PREFER_CACHE};async function AA(r){if(r.did==null)throw new Error("No DID provided");r.did.authenticated||(await r.did.authenticate(),r.loggerProvider&&r.loggerProvider.getDiagnosticsLogger().imp(`Now authenticated as DID ${r.did.id}`))}o(AA,"_ensureAuthenticated");async function yH(){throw new Error("Historical stream commits cannot be modified. Load the stream without specifying a commit to make updates.")}o(yH,"throwReadOnlyError");var ha=Ro=o(class extends xs{constructor(){super(...arguments),this._isReadOnly=!1}get content(){return super.content}get metadata(){return{controller:this.state$.value.metadata.controllers[0],model:Ro.MODEL}}static async create(e,t,n){Ro.assertComplete(t);let i={publish:!0,anchor:!0,pin:!0,sync:_r.NEVER_SYNC,throwOnInvalidCommit:!0},s=await Ro._makeGenesis(e,t,n);return await e.createStreamFromGenesis(Ro.STREAM_TYPE_ID,s,i)}static assertComplete(e,t){if(!e.name)throw t?new Error(`Model with StreamID ${t.toString()} is missing a 'name' field`):new Error("Model is missing a 'name' field");if(!e.schema)throw t?new Error(`Model ${e.name} (${t.toString()}) is missing a 'schema' field`):new Error(`Model ${e.name} is missing a 'schema' field`);if(!e.accountRelation)throw t?new Error(`Model ${e.name} (${t.toString()}) is missing a 'accountRelation' field`):new Error(`Model ${e.name} is missing a 'accountRelation' field`)}static async load(e,t,n={}){n={...vH,...n};let i=dn.from(t);if(i.type!=Ro.STREAM_TYPE_ID)throw new Error(`StreamID ${i.toString()} does not refer to a '${Ro.STREAM_TYPE_NAME}' stream, but to a ${i.typeName}`);return await e.loadStream(i,n)}static async _makeGenesis(e,t,n){let i=await this._makeRawGenesis(e,t,n);return Ro._signDagJWS(e,i)}static async _makeRawGenesis(e,t,n){if(t==null)throw new Error("Genesis content cannot be null");if(!n||!n.controller)if(e.did)await AA(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:Ro.MODEL.bytes};return{data:t,header:i}}makeReadOnly(){this.sync=yH,this._isReadOnly=!0}get isReadOnly(){return this._isReadOnly}static async _signDagJWS(e,t){return await AA(e),e.did.createDagJWS(t)}},"Model");ha.STREAM_TYPE_NAME="model";ha.STREAM_TYPE_ID=2;ha.MODEL=function(){let r=rf("model-v1"),e=SA.default.encode(r,"identity"),t=ts(Mc,e),n=Ye.createV1(Mc,t);return new it("UNLOADABLE",n)}();ha=Ro=gH([nu()],ha);var CA=Ft(Ga(),1);var xH=function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var u=r.length-1;u>=0;u--)(f=r[u])&&(s=(i<3?f(s):i>3?f(e,t,s):f(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},no,wH={anchor:!0,publish:!0,pin:!0,sync:_r.NEVER_SYNC,syncTimeoutSeconds:0},_H={anchor:!1,publish:!1,pin:!0,sync:_r.PREFER_CACHE},EH={sync:_r.PREFER_CACHE},MA={anchor:!0,publish:!0,throwOnInvalidCommit:!0};async function TA(r){if(r.did==null)throw new Error("No DID provided");r.did.authenticated||(await r.did.authenticate(),r.loggerProvider&&r.loggerProvider.getDiagnosticsLogger().imp(`Now authenticated as DID ${r.did.id}`))}o(TA,"_ensureAuthenticated");async function Uv(){throw new Error("Historical stream commits cannot be modified. Load the stream without specifying a commit to make updates.")}o(Uv,"throwReadOnlyError");var Tf=no=o(class extends xs{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,t,n,i={}){i={...wH,...i};let s=i.asDID?{did:i.asDID}:e,f=await no._makeGenesis(s,t,n);return e.createStreamFromGenesis(no.STREAM_TYPE_ID,f,i)}static async single(e,t,n={}){n={..._H,...n};let i=n.asDID?{did:n.asDID}:e;t={...t,deterministic:!0};let s=await no._makeGenesis(i,null,t);return e.createStreamFromGenesis(no.STREAM_TYPE_ID,s,n)}static async load(e,t,n={}){n={...EH,...n};let i=dn.from(t);if(i.type!=no.STREAM_TYPE_ID)throw new Error(`StreamID ${i.toString()} does not refer to a '${no.STREAM_TYPE_NAME}' stream, but to a ${i.typeName}`);return e.loadStream(i,n)}async replace(e,t={}){t={...MA,...t};let n=t.asDID?{did:t.asDID}:this.api,i=await this._makeCommit(n,e),s=await this.api.applyCommit(this.id,i,t);this.state$.next(s.state)}async patch(e,t={}){t={...MA,...t};let n={data:e,prev:this.tip,id:this.id.cid},i=await no._signDagJWS(this.api,n),s=await this.api.applyCommit(this.id,i,t);this.state$.next(s.state)}makeReadOnly(){this.replace=Uv,this.patch=Uv,this.sync=Uv,this._isReadOnly=!0}get isReadOnly(){return this._isReadOnly}_makeCommit(e,t){let n=this._makeRawCommit(t);return no._signDagJWS(e,n)}_makeRawCommit(e){return{data:U0.compare(this.content,e||{}),prev:this.tip,id:this.state.log[0].cid}}static async _makeGenesis(e,t,n){let i=await this._makeRawGenesis(e,t,n);return n.deterministic?(rf(i),i):no._signDagJWS(e,i)}static async _makeRawGenesis(e,t,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 TA(e),i=e.did.hasParent?e.did.parent:e.did.id;else throw new Error("No controller specified");let s={controllers:[i],model:n.model.bytes};return n.deterministic||(s.unique=(0,CA.randomBytes)(12)),{data:t,header:s}}static async _signDagJWS(e,t){return await TA(e),e.did.createDagJWS(t)}},"ModelInstanceDocument");Tf.STREAM_TYPE_NAME="MID";Tf.STREAM_TYPE_ID=3;Tf=no=xH([nu()],Tf);var Gl=class{constructor(e){this._apiUrl=e}async add(e,t){let n={};t&&(n.force=!0);let i=new URL(`./pins/${e}`,this._apiUrl);await Vr(i,{method:"post",body:n})}async rm(e,t){let n=new URL(`./pins/${e}`,this._apiUrl);await Vr(n,{method:"delete",body:{opts:t}})}async ls(e){let t=new URL("./pins",this._apiUrl);e&&(t=new URL(`./pins/${e.toString()}`,this._apiUrl));let n=await Vr(t),{pinnedStreamIds:i}=n;return{[Symbol.asyncIterator](){let s=0;return{next(){return s===i.length?Promise.resolve({value:null,done:!0}):Promise.resolve({value:i[s++],done:!1})}}}}}};o(Gl,"RemotePinApi");var Wl=class{constructor(e){this._fetchJson=Vr,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:Dv(e)})).count}async query(e){let t=await this._fetchJson(this._collectionURL,{method:"POST",body:Dv(e)});return{edges:t.edges.map(i=>({cursor:i.cursor,node:Qt.deserializeState(i.node)})),pageInfo:t.pageInfo}}};o(Wl,"RemoteIndexApi");var Jl=class{constructor(e,t){this._apiUrl=e,this._getDidFn=t,this._fetchJson=Vr,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,t,n){let i=n?{models:n.map(f=>f.toString())}:void 0,s=await e.createJWS({code:t,requestPath:this.getModelsUrl().pathname,requestBody:i});return`${s.signatures[0].protected}.${s.payload}.${s.signatures[0].signature}`}async generateCode(){return(await this._fetchJson(this.getCodeUrl())).code}async startIndexingModels(e){let t=await this.generateCode();await this._fetchJson(this.getModelsUrl(),{method:"post",body:{jws:await this.buildJWS(this._getDidFn(),t,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=>it.fromString(n))}async stopIndexingModels(e){let t=await this.generateCode();await this._fetchJson(this.getModelsUrl(),{method:"delete",body:{jws:await this.buildJWS(this._getDidFn(),t,e)}})}};o(Jl,"RemoteAdminApi");var AH="/api/v0/",SH="http://localhost:7007",MH={syncInterval:5e3},TH={anchor:!0,publish:!0,sync:_r.PREFER_CACHE},CH={anchor:!0,publish:!0,sync:_r.PREFER_CACHE},kA={sync:_r.PREFER_CACHE},Yl=class{constructor(e=SH,t={}){this._config={...MH,...t},this._apiUrl=new URL(AH,e),this._streamCache=new Map,this.context={api:this},this.pin=new Gl(this._apiUrl),this.index=new Wl(this._apiUrl);let n=(()=>this.did).bind(this);this.admin=new Jl(this._apiUrl,n),this._streamConstructors={[Sf.STREAM_TYPE_ID]:Sf,[ha.STREAM_TYPE_ID]:ha,[Tf.STREAM_TYPE_ID]:Tf,[ei.STREAM_TYPE_ID]:ei}}get did(){return this.context.did}set did(e){this.context.did=e}async createStreamFromGenesis(e,t,n={}){n={...CH,...n};let i=await an.createFromGenesis(this._apiUrl,e,t,n,this._config.syncInterval),s=this._streamCache.get(i.id.toString());return s?(Qt.statesEqual(i.state,s.state)||s.next(i.state),this.buildStreamFromDocument(s)):(this._streamCache.set(i.id.toString(),i),this.buildStreamFromDocument(i))}async loadStream(e,t={}){t={...kA,...t};let n=dn.from(e),i=this._streamCache.get(n.baseID.toString());return i?await i._syncState(n,t):(i=await an.load(n,this._apiUrl,this._config.syncInterval,t),this._streamCache.set(i.id.toString(),i)),this.buildStreamFromDocument(i)}async multiQuery(e,t){let n=e.map(f=>({...f,streamId:typeof f.streamId=="string"?f.streamId:f.streamId.toString()})),i=new URL("./multiqueries",this._apiUrl),s=await Vr(i,{method:"post",body:{queries:n,timeout:t}});return Object.entries(s).reduce((f,u)=>{let[d,y]=u,w=Qt.deserializeState(y),A=new an(w,this._apiUrl,this._config.syncInterval);return f[d]=this.buildStreamFromDocument(A),f},{})}loadStreamCommits(e){let t=Iv(e);return an.loadStreamCommits(t,this._apiUrl)}async applyCommit(e,t,n={}){n={...TH,...n};let i=Iv(e),s=await an.applyCommit(this._apiUrl,i,t,n,this._config.syncInterval),f=this._streamCache.get(i.toString());return f?(f.next(s.state),this.buildStreamFromDocument(s)):(this._streamCache.set(i.toString(),s),this.buildStreamFromDocument(s))}async requestAnchor(e,t={}){t={...kA,...t};let{anchorStatus:n}=await Vr(`${this._apiUrl}/streams/${e.toString()}/anchor`,{method:"post",body:{opts:t}});return n}addStreamHandler(e){this._streamConstructors[e.name]=e.stream_constructor}buildStreamFromState(e){let t=new an(e,this._apiUrl,this._config.syncInterval);return this.buildStreamFromDocument(t)}buildStreamFromDocument(e){let t=e.state.type,n=this._streamConstructors[t];if(!n)throw new Error(`Failed to find constructor for stream ${t}`);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 Vr(this._apiUrl+"/node/chains");return this._supportedChains=e,e}async close(){Array.from(this._streamCache).map(([,e])=>{e.complete()}),this._streamCache.clear()}};o(Yl,"CeramicClient");var Lt;(function(r){r.assertEqual=i=>i;function e(i){}o(e,"assertIs"),r.assertIs=e;function t(i){throw new Error}o(t,"assertNever"),r.assertNever=t,r.arrayToEnum=i=>{let s={};for(let f of i)s[f]=f;return s},r.getValidEnumValues=i=>{let s=r.objectKeys(i).filter(u=>typeof i[i[u]]!="number"),f={};for(let u of s)f[u]=i[u];return r.objectValues(f)},r.objectValues=i=>r.objectKeys(i).map(function(s){return i[s]}),r.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let s=[];for(let f in i)Object.prototype.hasOwnProperty.call(i,f)&&s.push(f);return s},r.find=(i,s)=>{for(let f of i)if(s(f))return f},r.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,s=" | "){return i.map(f=>typeof f=="string"?`'${f}'`:f).join(s)}o(n,"joinValues"),r.joinValues=n,r.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(Lt||(Lt={}));var $v;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})($v||($v={}));var je=Lt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),da=o(r=>{switch(typeof r){case"undefined":return je.undefined;case"string":return je.string;case"number":return isNaN(r)?je.nan:je.number;case"boolean":return je.boolean;case"function":return je.function;case"bigint":return je.bigint;case"symbol":return je.symbol;case"object":return Array.isArray(r)?je.array:r===null?je.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?je.promise:typeof Map<"u"&&r instanceof Map?je.map:typeof Set<"u"&&r instanceof Set?je.set:typeof Date<"u"&&r instanceof Date?je.date:je.object;default:return je.unknown}},"getParsedType"),Oe=Lt.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"]),kH=o(r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:"),"quotelessJson"),fn=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 t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){let t=e||function(s){return s.message},n={_errors:[]},i=o(s=>{for(let f of s.issues)if(f.code==="invalid_union")f.unionErrors.map(i);else if(f.code==="invalid_return_type")i(f.returnTypeError);else if(f.code==="invalid_arguments")i(f.argumentsError);else if(f.path.length===0)n._errors.push(t(f));else{let u=n,d=0;for(;d<f.path.length;){let y=f.path[d];d===f.path.length-1?(u[y]=u[y]||{_errors:[]},u[y]._errors.push(t(f))):u[y]=u[y]||{_errors:[]},u=u[y],d++}}},"processError");return i(this),n}static assert(e){if(!(e instanceof fn))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Lt.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){let t={},n=[];for(let i of this.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};o(fn,"ZodError");fn.create=r=>new fn(r);var lu=o((r,e)=>{let t;switch(r.code){case Oe.invalid_type:r.received===je.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case Oe.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Lt.jsonStringifyReplacer)}`;break;case Oe.unrecognized_keys:t=`Unrecognized key(s) in object: ${Lt.joinValues(r.keys,", ")}`;break;case Oe.invalid_union:t="Invalid input";break;case Oe.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Lt.joinValues(r.options)}`;break;case Oe.invalid_enum_value:t=`Invalid enum value. Expected ${Lt.joinValues(r.options)}, received '${r.received}'`;break;case Oe.invalid_arguments:t="Invalid function arguments";break;case Oe.invalid_return_type:t="Invalid function return type";break;case Oe.invalid_date:t="Invalid date";break;case Oe.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:Lt.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case Oe.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case Oe.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case Oe.custom:t="Invalid input";break;case Oe.invalid_intersection_types:t="Intersection results could not be merged";break;case Oe.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case Oe.not_finite:t="Number must be finite";break;default:t=e.defaultError,Lt.assertNever(r)}return{message:t}},"errorMap"),RA=lu;function IH(r){RA=r}o(IH,"setErrorMap");function Sp(){return RA}o(Sp,"getErrorMap");var Mp=o(r=>{let{data:e,path:t,errorMaps:n,issueData:i}=r,s=[...t,...i.path||[]],f={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let u="",d=n.filter(y=>!!y).slice().reverse();for(let y of d)u=y(f,{data:e,defaultError:u}).message;return{...i,path:s,message:u}},"makeIssue"),DH=[];function $e(r,e){let t=Sp(),n=Mp({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===lu?void 0:lu].filter(i=>!!i)});r.common.issues.push(n)}o($e,"addIssueToContext");var Tr=class{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){let n=[];for(let i of t){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,t){let n=[];for(let i of t){let s=await i.key,f=await i.value;n.push({key:s,value:f})}return Tr.mergeObjectSync(e,n)}static mergeObjectSync(e,t){let n={};for(let i of t){let{key:s,value:f}=i;if(s.status==="aborted"||f.status==="aborted")return gt;s.status==="dirty"&&e.dirty(),f.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof f.value<"u"||i.alwaysSet)&&(n[s.value]=f.value)}return{status:e.value,value:n}}};o(Tr,"ParseStatus");var gt=Object.freeze({status:"aborted"}),cu=o(r=>({status:"dirty",value:r}),"DIRTY"),pn=o(r=>({status:"valid",value:r}),"OK"),qv=o(r=>r.status==="aborted","isAborted"),jv=o(r=>r.status==="dirty","isDirty"),Ql=o(r=>r.status==="valid","isValid"),eh=o(r=>typeof Promise<"u"&&r instanceof Promise,"isAsync");function Tp(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)}o(Tp,"__classPrivateFieldGet");function OA(r,e,t,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"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t}o(OA,"__classPrivateFieldSet");var Ge;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e?.message})(Ge||(Ge={}));var Zl,Xl,ti=class{constructor(e,t,n,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}};o(ti,"ParseInputLazyPath");var IA=o((r,e)=>{if(Ql(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new fn(r.common.issues);return this._error=t,this._error}}},"handleResult");function At(r){if(!r)return{};let{errorMap:e,invalid_type_error:t,required_error:n,description:i}=r;if(e&&(t||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((f,u)=>{var d,y;let{message:w}=r;return f.code==="invalid_enum_value"?{message:w??u.defaultError}:typeof u.data>"u"?{message:(d=w??n)!==null&&d!==void 0?d:u.defaultError}:f.code!=="invalid_type"?{message:u.defaultError}:{message:(y=w??t)!==null&&y!==void 0?y:u.defaultError}},"customMap"),description:i}}o(At,"processCreateParams");var _t=class{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return da(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:da(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Tr,ctx:{common:e.parent.common,data:e.data,parsedType:da(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(eh(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;let i={common:{issues:[],async:(n=t?.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:da(e)},s=this._parseSync({data:e,path:i.path,parent:i});return IA(i,s)}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:da(e)},i=this._parse({data:e,path:n.path,parent:n}),s=await(eh(i)?i:Promise.resolve(i));return IA(n,s)}refine(e,t){let n=o(i=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(i):t,"getIssueProperties");return this._refinement((i,s)=>{let f=e(i),u=o(()=>s.addIssue({code:Oe.custom,...n(i)}),"setError");return typeof Promise<"u"&&f instanceof Promise?f.then(d=>d?!0:(u(),!1)):f?!0:(u(),!1)})}refinement(e,t){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof t=="function"?t(n,i):t),!1))}_refinement(e){return new Nn({schema:this,typeName:ot.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return ni.create(this,this._def)}nullable(){return ao.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return On.create(this,this._def)}promise(){return Ms.create(this,this._def)}or(e){return ga.create([this,e],this._def)}and(e){return va.create(this,e,this._def)}transform(e){return new Nn({...At(this._def),schema:this,typeName:ot.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e=="function"?e:()=>e;return new Ea({...At(this._def),innerType:this,defaultValue:t,typeName:ot.ZodDefault})}brand(){return new uu({typeName:ot.ZodBranded,type:this,...At(this._def)})}catch(e){let t=typeof e=="function"?e:()=>e;return new Aa({...At(this._def),innerType:this,catchValue:t,typeName:ot.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Sa.create(this,e)}readonly(){return Ma.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};o(_t,"ZodType");var RH=/^c[^\s-]{8,}$/i,OH=/^[0-9a-z]+$/,NH=/^[0-9A-HJKMNP-TV-Z]{26}$/,PH=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,BH=/^[a-z0-9_-]{21}$/i,LH=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,UH=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,FH="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Fv,$H=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,qH=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,jH=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,NA="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",HH=new RegExp(`^${NA}$`);function PA(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}o(PA,"timeRegexSource");function zH(r){return new RegExp(`^${PA(r)}$`)}o(zH,"timeRegex");function BA(r){let e=`${NA}T${PA(r)}`,t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}o(BA,"datetimeRegex");function KH(r,e){return!!((e==="v4"||!e)&&$H.test(r)||(e==="v6"||!e)&&qH.test(r))}o(KH,"isValidIP");var Rn=class extends _t{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==je.string){let s=this._getOrReturnCtx(e);return $e(s,{code:Oe.invalid_type,expected:je.string,received:s.parsedType}),gt}let n=new Tr,i;for(let s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(i=this._getOrReturnCtx(e,i),$e(i,{code:Oe.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="max")e.data.length>s.value&&(i=this._getOrReturnCtx(e,i),$e(i,{code:Oe.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="length"){let f=e.data.length>s.value,u=e.data.length<s.value;(f||u)&&(i=this._getOrReturnCtx(e,i),f?$e(i,{code:Oe.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):u&&$e(i,{code:Oe.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")UH.test(e.data)||(i=this._getOrReturnCtx(e,i),$e(i,{validation:"email",code:Oe.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")Fv||(Fv=new RegExp(FH,"u")),Fv.test(e.data)||(i=this._getOrReturnCtx(e,i),$e(i,{validation:"emoji",code:Oe.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")PH.test(e.data)||(i=this._getOrReturnCtx(e,i),$e(i,{validation:"uuid",code:Oe.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")BH.test(e.data)||(i=this._getOrReturnCtx(e,i),$e(i,{validation:"nanoid",code:Oe.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")RH.test(e.data)||(i=this._getOrReturnCtx(e,i),$e(i,{validation:"cuid",code:Oe.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")OH.test(e.data)||(i=this._getOrReturnCtx(e,i),$e(i,{validation:"cuid2",code:Oe.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")NH.test(e.data)||(i=this._getOrReturnCtx(e,i),$e(i,{validation:"ulid",code:Oe.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),$e(i,{validation:"url",code:Oe.invalid_string,message:s.message}),n.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),$e(i,{validation:"regex",code:Oe.invalid_string,message:s.message}),n.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(e,i),$e(i,{code:Oe.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),n.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(i=this._getOrReturnCtx(e,i),$e(i,{code:Oe.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(i=this._getOrReturnCtx(e,i),$e(i,{code:Oe.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?BA(s).test(e.data)||(i=this._getOrReturnCtx(e,i),$e(i,{code:Oe.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?HH.test(e.data)||(i=this._getOrReturnCtx(e,i),$e(i,{code:Oe.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?zH(s).test(e.data)||(i=this._getOrReturnCtx(e,i),$e(i,{code:Oe.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?LH.test(e.data)||(i=this._getOrReturnCtx(e,i),$e(i,{validation:"duration",code:Oe.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?KH(e.data,s.version)||(i=this._getOrReturnCtx(e,i),$e(i,{validation:"ip",code:Oe.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?jH.test(e.data)||(i=this._getOrReturnCtx(e,i),$e(i,{validation:"base64",code:Oe.invalid_string,message:s.message}),n.dirty()):Lt.assertNever(s);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(i=>e.test(i),{validation:t,code:Oe.invalid_string,...Ge.errToObj(n)})}_addCheck(e){return new Rn({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Ge.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Ge.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Ge.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Ge.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Ge.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Ge.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Ge.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Ge.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Ge.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Ge.errToObj(e)})}datetime(e){var t,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:(t=e?.offset)!==null&&t!==void 0?t:!1,local:(n=e?.local)!==null&&n!==void 0?n:!1,...Ge.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...Ge.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...Ge.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Ge.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...Ge.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Ge.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Ge.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Ge.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Ge.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Ge.errToObj(t)})}nonempty(e){return this.min(1,Ge.errToObj(e))}trim(){return new Rn({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Rn({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Rn({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get minLength(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};o(Rn,"ZodString");Rn.create=r=>{var e;return new Rn({checks:[],typeName:ot.ZodString,coerce:(e=r?.coerce)!==null&&e!==void 0?e:!1,...At(r)})};function VH(r,e){let t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=t>n?t:n,s=parseInt(r.toFixed(i).replace(".","")),f=parseInt(e.toFixed(i).replace(".",""));return s%f/Math.pow(10,i)}o(VH,"floatSafeRemainder");var io=class extends _t{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)!==je.number){let s=this._getOrReturnCtx(e);return $e(s,{code:Oe.invalid_type,expected:je.number,received:s.parsedType}),gt}let n,i=new Tr;for(let s of this._def.checks)s.kind==="int"?Lt.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),$e(n,{code:Oe.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),$e(n,{code:Oe.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),$e(n,{code:Oe.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?VH(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),$e(n,{code:Oe.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),$e(n,{code:Oe.not_finite,message:s.message}),i.dirty()):Lt.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Ge.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Ge.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Ge.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Ge.toString(t))}setLimit(e,t,n,i){return new io({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Ge.toString(i)}]})}_addCheck(e){return new io({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Ge.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Ge.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Ge.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Ge.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Ge.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Ge.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Ge.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Ge.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Ge.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Lt.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}};o(io,"ZodNumber");io.create=r=>new io({checks:[],typeName:ot.ZodNumber,coerce:r?.coerce||!1,...At(r)});var oo=class extends _t{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==je.bigint){let s=this._getOrReturnCtx(e);return $e(s,{code:Oe.invalid_type,expected:je.bigint,received:s.parsedType}),gt}let n,i=new Tr;for(let s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),$e(n,{code:Oe.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),$e(n,{code:Oe.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),$e(n,{code:Oe.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):Lt.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Ge.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Ge.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Ge.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Ge.toString(t))}setLimit(e,t,n,i){return new oo({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Ge.toString(i)}]})}_addCheck(e){return new oo({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Ge.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Ge.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Ge.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Ge.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Ge.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};o(oo,"ZodBigInt");oo.create=r=>{var e;return new oo({checks:[],typeName:ot.ZodBigInt,coerce:(e=r?.coerce)!==null&&e!==void 0?e:!1,...At(r)})};var pa=class extends _t{_parse(e){if(this._def.coerce&&(e.data=Boolean(e.data)),this._getType(e)!==je.boolean){let n=this._getOrReturnCtx(e);return $e(n,{code:Oe.invalid_type,expected:je.boolean,received:n.parsedType}),gt}return pn(e.data)}};o(pa,"ZodBoolean");pa.create=r=>new pa({typeName:ot.ZodBoolean,coerce:r?.coerce||!1,...At(r)});var Oo=class extends _t{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==je.date){let s=this._getOrReturnCtx(e);return $e(s,{code:Oe.invalid_type,expected:je.date,received:s.parsedType}),gt}if(isNaN(e.data.getTime())){let s=this._getOrReturnCtx(e);return $e(s,{code:Oe.invalid_date}),gt}let n=new Tr,i;for(let s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(i=this._getOrReturnCtx(e,i),$e(i,{code:Oe.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),n.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(i=this._getOrReturnCtx(e,i),$e(i,{code:Oe.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):Lt.assertNever(s);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Oo({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Ge.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Ge.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};o(Oo,"ZodDate");Oo.create=r=>new Oo({checks:[],coerce:r?.coerce||!1,typeName:ot.ZodDate,...At(r)});var Cf=class extends _t{_parse(e){if(this._getType(e)!==je.symbol){let n=this._getOrReturnCtx(e);return $e(n,{code:Oe.invalid_type,expected:je.symbol,received:n.parsedType}),gt}return pn(e.data)}};o(Cf,"ZodSymbol");Cf.create=r=>new Cf({typeName:ot.ZodSymbol,...At(r)});var ma=class extends _t{_parse(e){if(this._getType(e)!==je.undefined){let n=this._getOrReturnCtx(e);return $e(n,{code:Oe.invalid_type,expected:je.undefined,received:n.parsedType}),gt}return pn(e.data)}};o(ma,"ZodUndefined");ma.create=r=>new ma({typeName:ot.ZodUndefined,...At(r)});var ba=class extends _t{_parse(e){if(this._getType(e)!==je.null){let n=this._getOrReturnCtx(e);return $e(n,{code:Oe.invalid_type,expected:je.null,received:n.parsedType}),gt}return pn(e.data)}};o(ba,"ZodNull");ba.create=r=>new ba({typeName:ot.ZodNull,...At(r)});var As=class extends _t{constructor(){super(...arguments),this._any=!0}_parse(e){return pn(e.data)}};o(As,"ZodAny");As.create=r=>new As({typeName:ot.ZodAny,...At(r)});var No=class extends _t{constructor(){super(...arguments),this._unknown=!0}_parse(e){return pn(e.data)}};o(No,"ZodUnknown");No.create=r=>new No({typeName:ot.ZodUnknown,...At(r)});var Ni=class extends _t{_parse(e){let t=this._getOrReturnCtx(e);return $e(t,{code:Oe.invalid_type,expected:je.never,received:t.parsedType}),gt}};o(Ni,"ZodNever");Ni.create=r=>new Ni({typeName:ot.ZodNever,...At(r)});var kf=class extends _t{_parse(e){if(this._getType(e)!==je.undefined){let n=this._getOrReturnCtx(e);return $e(n,{code:Oe.invalid_type,expected:je.void,received:n.parsedType}),gt}return pn(e.data)}};o(kf,"ZodVoid");kf.create=r=>new kf({typeName:ot.ZodVoid,...At(r)});var On=class extends _t{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),i=this._def;if(t.parsedType!==je.array)return $e(t,{code:Oe.invalid_type,expected:je.array,received:t.parsedType}),gt;if(i.exactLength!==null){let f=t.data.length>i.exactLength.value,u=t.data.length<i.exactLength.value;(f||u)&&($e(t,{code:f?Oe.too_big:Oe.too_small,minimum:u?i.exactLength.value:void 0,maximum:f?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&t.data.length<i.minLength.value&&($e(t,{code:Oe.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&t.data.length>i.maxLength.value&&($e(t,{code:Oe.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((f,u)=>i.type._parseAsync(new ti(t,f,t.path,u)))).then(f=>Tr.mergeArray(n,f));let s=[...t.data].map((f,u)=>i.type._parseSync(new ti(t,f,t.path,u)));return Tr.mergeArray(n,s)}get element(){return this._def.type}min(e,t){return new On({...this._def,minLength:{value:e,message:Ge.toString(t)}})}max(e,t){return new On({...this._def,maxLength:{value:e,message:Ge.toString(t)}})}length(e,t){return new On({...this._def,exactLength:{value:e,message:Ge.toString(t)}})}nonempty(e){return this.min(1,e)}};o(On,"ZodArray");On.create=(r,e)=>new On({type:r,minLength:null,maxLength:null,exactLength:null,typeName:ot.ZodArray,...At(e)});function fu(r){if(r instanceof sr){let e={};for(let t in r.shape){let n=r.shape[t];e[t]=ni.create(fu(n))}return new sr({...r._def,shape:()=>e})}else return r instanceof On?new On({...r._def,type:fu(r.element)}):r instanceof ni?ni.create(fu(r.unwrap())):r instanceof ao?ao.create(fu(r.unwrap())):r instanceof ri?ri.create(r.items.map(e=>fu(e))):r}o(fu,"deepPartialify");var sr=class extends _t{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=Lt.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==je.object){let y=this._getOrReturnCtx(e);return $e(y,{code:Oe.invalid_type,expected:je.object,received:y.parsedType}),gt}let{status:n,ctx:i}=this._processInputParams(e),{shape:s,keys:f}=this._getCached(),u=[];if(!(this._def.catchall instanceof Ni&&this._def.unknownKeys==="strip"))for(let y in i.data)f.includes(y)||u.push(y);let d=[];for(let y of f){let w=s[y],A=i.data[y];d.push({key:{status:"valid",value:y},value:w._parse(new ti(i,A,i.path,y)),alwaysSet:y in i.data})}if(this._def.catchall instanceof Ni){let y=this._def.unknownKeys;if(y==="passthrough")for(let w of u)d.push({key:{status:"valid",value:w},value:{status:"valid",value:i.data[w]}});else if(y==="strict")u.length>0&&($e(i,{code:Oe.unrecognized_keys,keys:u}),n.dirty());else if(y!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let y=this._def.catchall;for(let w of u){let A=i.data[w];d.push({key:{status:"valid",value:w},value:y._parse(new ti(i,A,i.path,w)),alwaysSet:w in i.data})}}return i.common.async?Promise.resolve().then(async()=>{let y=[];for(let w of d){let A=await w.key,O=await w.value;y.push({key:A,value:O,alwaysSet:w.alwaysSet})}return y}).then(y=>Tr.mergeObjectSync(n,y)):Tr.mergeObjectSync(n,d)}get shape(){return this._def.shape()}strict(e){return Ge.errToObj,new sr({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var i,s,f,u;let d=(f=(s=(i=this._def).errorMap)===null||s===void 0?void 0:s.call(i,t,n).message)!==null&&f!==void 0?f:n.defaultError;return t.code==="unrecognized_keys"?{message:(u=Ge.errToObj(e).message)!==null&&u!==void 0?u:d}:{message:d}}}:{}})}strip(){return new sr({...this._def,unknownKeys:"strip"})}passthrough(){return new sr({...this._def,unknownKeys:"passthrough"})}extend(e){return new sr({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new sr({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:ot.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new sr({...this._def,catchall:e})}pick(e){let t={};return Lt.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new sr({...this._def,shape:()=>t})}omit(e){let t={};return Lt.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new sr({...this._def,shape:()=>t})}deepPartial(){return fu(this)}partial(e){let t={};return Lt.objectKeys(this.shape).forEach(n=>{let i=this.shape[n];e&&!e[n]?t[n]=i:t[n]=i.optional()}),new sr({...this._def,shape:()=>t})}required(e){let t={};return Lt.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof ni;)s=s._def.innerType;t[n]=s}}),new sr({...this._def,shape:()=>t})}keyof(){return LA(Lt.objectKeys(this.shape))}};o(sr,"ZodObject");sr.create=(r,e)=>new sr({shape:()=>r,unknownKeys:"strip",catchall:Ni.create(),typeName:ot.ZodObject,...At(e)});sr.strictCreate=(r,e)=>new sr({shape:()=>r,unknownKeys:"strict",catchall:Ni.create(),typeName:ot.ZodObject,...At(e)});sr.lazycreate=(r,e)=>new sr({shape:r,unknownKeys:"strip",catchall:Ni.create(),typeName:ot.ZodObject,...At(e)});var ga=class extends _t{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function i(s){for(let u of s)if(u.result.status==="valid")return u.result;for(let u of s)if(u.result.status==="dirty")return t.common.issues.push(...u.ctx.common.issues),u.result;let f=s.map(u=>new fn(u.ctx.common.issues));return $e(t,{code:Oe.invalid_union,unionErrors:f}),gt}if(o(i,"handleResults"),t.common.async)return Promise.all(n.map(async s=>{let f={...t,common:{...t.common,issues:[]},parent:null};return{result:await s._parseAsync({data:t.data,path:t.path,parent:f}),ctx:f}})).then(i);{let s,f=[];for(let d of n){let y={...t,common:{...t.common,issues:[]},parent:null},w=d._parseSync({data:t.data,path:t.path,parent:y});if(w.status==="valid")return w;w.status==="dirty"&&!s&&(s={result:w,ctx:y}),y.common.issues.length&&f.push(y.common.issues)}if(s)return t.common.issues.push(...s.ctx.common.issues),s.result;let u=f.map(d=>new fn(d));return $e(t,{code:Oe.invalid_union,unionErrors:u}),gt}}get options(){return this._def.options}};o(ga,"ZodUnion");ga.create=(r,e)=>new ga({options:r,typeName:ot.ZodUnion,...At(e)});var Es=o(r=>r instanceof xa?Es(r.schema):r instanceof Nn?Es(r.innerType()):r instanceof wa?[r.value]:r instanceof so?r.options:r instanceof _a?Lt.objectValues(r.enum):r instanceof Ea?Es(r._def.innerType):r instanceof ma?[void 0]:r instanceof ba?[null]:r instanceof ni?[void 0,...Es(r.unwrap())]:r instanceof ao?[null,...Es(r.unwrap())]:r instanceof uu||r instanceof Ma?Es(r.unwrap()):r instanceof Aa?Es(r._def.innerType):[],"getDiscriminator"),If=class extends _t{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==je.object)return $e(t,{code:Oe.invalid_type,expected:je.object,received:t.parsedType}),gt;let n=this.discriminator,i=t.data[n],s=this.optionsMap.get(i);return s?t.common.async?s._parseAsync({data:t.data,path:t.path,parent:t}):s._parseSync({data:t.data,path:t.path,parent:t}):($e(t,{code:Oe.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,t,n){let i=new Map;for(let s of t){let f=Es(s.shape[e]);if(!f.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let u of f){if(i.has(u))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(u)}`);i.set(u,s)}}return new If({typeName:ot.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...At(n)})}};o(If,"ZodDiscriminatedUnion");function Hv(r,e){let t=da(r),n=da(e);if(r===e)return{valid:!0,data:r};if(t===je.object&&n===je.object){let i=Lt.objectKeys(e),s=Lt.objectKeys(r).filter(u=>i.indexOf(u)!==-1),f={...r,...e};for(let u of s){let d=Hv(r[u],e[u]);if(!d.valid)return{valid:!1};f[u]=d.data}return{valid:!0,data:f}}else if(t===je.array&&n===je.array){if(r.length!==e.length)return{valid:!1};let i=[];for(let s=0;s<r.length;s++){let f=r[s],u=e[s],d=Hv(f,u);if(!d.valid)return{valid:!1};i.push(d.data)}return{valid:!0,data:i}}else return t===je.date&&n===je.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}o(Hv,"mergeValues");var va=class extends _t{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),i=o((s,f)=>{if(qv(s)||qv(f))return gt;let u=Hv(s.value,f.value);return u.valid?((jv(s)||jv(f))&&t.dirty(),{status:t.value,value:u.data}):($e(n,{code:Oe.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(([s,f])=>i(s,f)):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(va,"ZodIntersection");va.create=(r,e,t)=>new va({left:r,right:e,typeName:ot.ZodIntersection,...At(t)});var ri=class extends _t{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==je.array)return $e(n,{code:Oe.invalid_type,expected:je.array,received:n.parsedType}),gt;if(n.data.length<this._def.items.length)return $e(n,{code:Oe.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),gt;!this._def.rest&&n.data.length>this._def.items.length&&($e(n,{code:Oe.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let s=[...n.data].map((f,u)=>{let d=this._def.items[u]||this._def.rest;return d?d._parse(new ti(n,f,n.path,u)):null}).filter(f=>!!f);return n.common.async?Promise.all(s).then(f=>Tr.mergeArray(t,f)):Tr.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new ri({...this._def,rest:e})}};o(ri,"ZodTuple");ri.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ri({items:r,typeName:ot.ZodTuple,rest:null,...At(e)})};var ya=class extends _t{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==je.object)return $e(n,{code:Oe.invalid_type,expected:je.object,received:n.parsedType}),gt;let i=[],s=this._def.keyType,f=this._def.valueType;for(let u in n.data)i.push({key:s._parse(new ti(n,u,n.path,u)),value:f._parse(new ti(n,n.data[u],n.path,u)),alwaysSet:u in n.data});return n.common.async?Tr.mergeObjectAsync(t,i):Tr.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof _t?new ya({keyType:e,valueType:t,typeName:ot.ZodRecord,...At(n)}):new ya({keyType:Rn.create(),valueType:e,typeName:ot.ZodRecord,...At(t)})}};o(ya,"ZodRecord");var Df=class extends _t{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==je.map)return $e(n,{code:Oe.invalid_type,expected:je.map,received:n.parsedType}),gt;let i=this._def.keyType,s=this._def.valueType,f=[...n.data.entries()].map(([u,d],y)=>({key:i._parse(new ti(n,u,n.path,[y,"key"])),value:s._parse(new ti(n,d,n.path,[y,"value"]))}));if(n.common.async){let u=new Map;return Promise.resolve().then(async()=>{for(let d of f){let y=await d.key,w=await d.value;if(y.status==="aborted"||w.status==="aborted")return gt;(y.status==="dirty"||w.status==="dirty")&&t.dirty(),u.set(y.value,w.value)}return{status:t.value,value:u}})}else{let u=new Map;for(let d of f){let y=d.key,w=d.value;if(y.status==="aborted"||w.status==="aborted")return gt;(y.status==="dirty"||w.status==="dirty")&&t.dirty(),u.set(y.value,w.value)}return{status:t.value,value:u}}}};o(Df,"ZodMap");Df.create=(r,e,t)=>new Df({valueType:e,keyType:r,typeName:ot.ZodMap,...At(t)});var Po=class extends _t{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==je.set)return $e(n,{code:Oe.invalid_type,expected:je.set,received:n.parsedType}),gt;let i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&($e(n,{code:Oe.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&($e(n,{code:Oe.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());let s=this._def.valueType;function f(d){let y=new Set;for(let w of d){if(w.status==="aborted")return gt;w.status==="dirty"&&t.dirty(),y.add(w.value)}return{status:t.value,value:y}}o(f,"finalizeSet");let u=[...n.data.values()].map((d,y)=>s._parse(new ti(n,d,n.path,y)));return n.common.async?Promise.all(u).then(d=>f(d)):f(u)}min(e,t){return new Po({...this._def,minSize:{value:e,message:Ge.toString(t)}})}max(e,t){return new Po({...this._def,maxSize:{value:e,message:Ge.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};o(Po,"ZodSet");Po.create=(r,e)=>new Po({valueType:r,minSize:null,maxSize:null,typeName:ot.ZodSet,...At(e)});var Ss=class extends _t{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==je.function)return $e(t,{code:Oe.invalid_type,expected:je.function,received:t.parsedType}),gt;function n(u,d){return Mp({data:u,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Sp(),lu].filter(y=>!!y),issueData:{code:Oe.invalid_arguments,argumentsError:d}})}o(n,"makeArgsIssue");function i(u,d){return Mp({data:u,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Sp(),lu].filter(y=>!!y),issueData:{code:Oe.invalid_return_type,returnTypeError:d}})}o(i,"makeReturnsIssue");let s={errorMap:t.common.contextualErrorMap},f=t.data;if(this._def.returns instanceof Ms){let u=this;return pn(async function(...d){let y=new fn([]),w=await u._def.args.parseAsync(d,s).catch(R=>{throw y.addIssue(n(d,R)),y}),A=await Reflect.apply(f,this,w);return await u._def.returns._def.type.parseAsync(A,s).catch(R=>{throw y.addIssue(i(A,R)),y})})}else{let u=this;return pn(function(...d){let y=u._def.args.safeParse(d,s);if(!y.success)throw new fn([n(d,y.error)]);let w=Reflect.apply(f,this,y.data),A=u._def.returns.safeParse(w,s);if(!A.success)throw new fn([i(w,A.error)]);return A.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Ss({...this._def,args:ri.create(e).rest(No.create())})}returns(e){return new Ss({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Ss({args:e||ri.create([]).rest(No.create()),returns:t||No.create(),typeName:ot.ZodFunction,...At(n)})}};o(Ss,"ZodFunction");var xa=class extends _t{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};o(xa,"ZodLazy");xa.create=(r,e)=>new xa({getter:r,typeName:ot.ZodLazy,...At(e)});var wa=class extends _t{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return $e(t,{received:t.data,code:Oe.invalid_literal,expected:this._def.value}),gt}return{status:"valid",value:e.data}}get value(){return this._def.value}};o(wa,"ZodLiteral");wa.create=(r,e)=>new wa({value:r,typeName:ot.ZodLiteral,...At(e)});function LA(r,e){return new so({values:r,typeName:ot.ZodEnum,...At(e)})}o(LA,"createZodEnum");var so=class extends _t{constructor(){super(...arguments),Zl.set(this,void 0)}_parse(e){if(typeof e.data!="string"){let t=this._getOrReturnCtx(e),n=this._def.values;return $e(t,{expected:Lt.joinValues(n),received:t.parsedType,code:Oe.invalid_type}),gt}if(Tp(this,Zl,"f")||OA(this,Zl,new Set(this._def.values),"f"),!Tp(this,Zl,"f").has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return $e(t,{received:t.data,code:Oe.invalid_enum_value,options:n}),gt}return pn(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return so.create(e,{...this._def,...t})}exclude(e,t=this._def){return so.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}};o(so,"ZodEnum");Zl=new WeakMap;so.create=LA;var _a=class extends _t{constructor(){super(...arguments),Xl.set(this,void 0)}_parse(e){let t=Lt.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==je.string&&n.parsedType!==je.number){let i=Lt.objectValues(t);return $e(n,{expected:Lt.joinValues(i),received:n.parsedType,code:Oe.invalid_type}),gt}if(Tp(this,Xl,"f")||OA(this,Xl,new Set(Lt.getValidEnumValues(this._def.values)),"f"),!Tp(this,Xl,"f").has(e.data)){let i=Lt.objectValues(t);return $e(n,{received:n.data,code:Oe.invalid_enum_value,options:i}),gt}return pn(e.data)}get enum(){return this._def.values}};o(_a,"ZodNativeEnum");Xl=new WeakMap;_a.create=(r,e)=>new _a({values:r,typeName:ot.ZodNativeEnum,...At(e)});var Ms=class extends _t{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==je.promise&&t.common.async===!1)return $e(t,{code:Oe.invalid_type,expected:je.promise,received:t.parsedType}),gt;let n=t.parsedType===je.promise?t.data:Promise.resolve(t.data);return pn(n.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}};o(Ms,"ZodPromise");Ms.create=(r,e)=>new Ms({type:r,typeName:ot.ZodPromise,...At(e)});var Nn=class extends _t{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ot.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),i=this._def.effect||null,s={addIssue:f=>{$e(n,f),f.fatal?t.abort():t.dirty()},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){let f=i.transform(n.data,s);if(n.common.async)return Promise.resolve(f).then(async u=>{if(t.value==="aborted")return gt;let d=await this._def.schema._parseAsync({data:u,path:n.path,parent:n});return d.status==="aborted"?gt:d.status==="dirty"||t.value==="dirty"?cu(d.value):d});{if(t.value==="aborted")return gt;let u=this._def.schema._parseSync({data:f,path:n.path,parent:n});return u.status==="aborted"?gt:u.status==="dirty"||t.value==="dirty"?cu(u.value):u}}if(i.type==="refinement"){let f=o(u=>{let d=i.refinement(u,s);if(n.common.async)return Promise.resolve(d);if(d 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"&&t.dirty(),f(u.value),{status:t.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"&&t.dirty(),f(u.value).then(()=>({status:t.value,value:u.value}))))}if(i.type==="transform")if(n.common.async===!1){let f=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Ql(f))return f;let u=i.transform(f.value,s);if(u instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:u}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(f=>Ql(f)?Promise.resolve(i.transform(f.value,s)).then(u=>({status:t.value,value:u})):f);Lt.assertNever(i)}};o(Nn,"ZodEffects");Nn.create=(r,e,t)=>new Nn({schema:r,typeName:ot.ZodEffects,effect:e,...At(t)});Nn.createWithPreprocess=(r,e,t)=>new Nn({schema:e,effect:{type:"preprocess",transform:r},typeName:ot.ZodEffects,...At(t)});var ni=class extends _t{_parse(e){return this._getType(e)===je.undefined?pn(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};o(ni,"ZodOptional");ni.create=(r,e)=>new ni({innerType:r,typeName:ot.ZodOptional,...At(e)});var ao=class extends _t{_parse(e){return this._getType(e)===je.null?pn(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};o(ao,"ZodNullable");ao.create=(r,e)=>new ao({innerType:r,typeName:ot.ZodNullable,...At(e)});var Ea=class extends _t{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===je.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};o(Ea,"ZodDefault");Ea.create=(r,e)=>new Ea({innerType:r,typeName:ot.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...At(e)});var Aa=class extends _t{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return eh(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new fn(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new fn(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};o(Aa,"ZodCatch");Aa.create=(r,e)=>new Aa({innerType:r,typeName:ot.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...At(e)});var Rf=class extends _t{_parse(e){if(this._getType(e)!==je.nan){let n=this._getOrReturnCtx(e);return $e(n,{code:Oe.invalid_type,expected:je.nan,received:n.parsedType}),gt}return{status:"valid",value:e.data}}};o(Rf,"ZodNaN");Rf.create=r=>new Rf({typeName:ot.ZodNaN,...At(r)});var GH=Symbol("zod_brand"),uu=class extends _t{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}};o(uu,"ZodBranded");var Sa=class extends _t{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return o(async()=>{let s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?gt:s.status==="dirty"?(t.dirty(),cu(s.value)):this._def.out._parseAsync({data:s.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"?(t.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,t){return new Sa({in:e,out:t,typeName:ot.ZodPipeline})}};o(Sa,"ZodPipeline");var Ma=class extends _t{_parse(e){let t=this._def.innerType._parse(e),n=o(i=>(Ql(i)&&(i.value=Object.freeze(i.value)),i),"freeze");return eh(t)?t.then(i=>n(i)):n(t)}unwrap(){return this._def.innerType}};o(Ma,"ZodReadonly");Ma.create=(r,e)=>new Ma({innerType:r,typeName:ot.ZodReadonly,...At(e)});function UA(r,e={},t){return r?As.create().superRefine((n,i)=>{var s,f;if(!r(n)){let u=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,d=(f=(s=u.fatal)!==null&&s!==void 0?s:t)!==null&&f!==void 0?f:!0,y=typeof u=="string"?{message:u}:u;i.addIssue({code:"custom",...y,fatal:d})}}):As.create()}o(UA,"custom");var WH={object:sr.lazycreate},ot;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(ot||(ot={}));var JH=o((r,e={message:`Input not instance of ${r.name}`})=>UA(t=>t instanceof r,e),"instanceOfType"),FA=Rn.create,$A=io.create,YH=Rf.create,ZH=oo.create,qA=pa.create,XH=Oo.create,QH=Cf.create,ez=ma.create,tz=ba.create,rz=As.create,nz=No.create,iz=Ni.create,oz=kf.create,sz=On.create,az=sr.create,fz=sr.strictCreate,cz=ga.create,uz=If.create,lz=va.create,hz=ri.create,dz=ya.create,pz=Df.create,mz=Po.create,bz=Ss.create,gz=xa.create,vz=wa.create,yz=so.create,xz=_a.create,wz=Ms.create,DA=Nn.create,_z=ni.create,Ez=ao.create,Az=Nn.createWithPreprocess,Sz=Sa.create,Mz=o(()=>FA().optional(),"ostring"),Tz=o(()=>$A().optional(),"onumber"),Cz=o(()=>qA().optional(),"oboolean"),kz={string:r=>Rn.create({...r,coerce:!0}),number:r=>io.create({...r,coerce:!0}),boolean:r=>pa.create({...r,coerce:!0}),bigint:r=>oo.create({...r,coerce:!0}),date:r=>Oo.create({...r,coerce:!0})},Iz=gt,m=Object.freeze({__proto__:null,defaultErrorMap:lu,setErrorMap:IH,getErrorMap:Sp,makeIssue:Mp,EMPTY_PATH:DH,addIssueToContext:$e,ParseStatus:Tr,INVALID:gt,DIRTY:cu,OK:pn,isAborted:qv,isDirty:jv,isValid:Ql,isAsync:eh,get util(){return Lt},get objectUtil(){return $v},ZodParsedType:je,getParsedType:da,ZodType:_t,datetimeRegex:BA,ZodString:Rn,ZodNumber:io,ZodBigInt:oo,ZodBoolean:pa,ZodDate:Oo,ZodSymbol:Cf,ZodUndefined:ma,ZodNull:ba,ZodAny:As,ZodUnknown:No,ZodNever:Ni,ZodVoid:kf,ZodArray:On,ZodObject:sr,ZodUnion:ga,ZodDiscriminatedUnion:If,ZodIntersection:va,ZodTuple:ri,ZodRecord:ya,ZodMap:Df,ZodSet:Po,ZodFunction:Ss,ZodLazy:xa,ZodLiteral:wa,ZodEnum:so,ZodNativeEnum:_a,ZodPromise:Ms,ZodEffects:Nn,ZodTransformer:Nn,ZodOptional:ni,ZodNullable:ao,ZodDefault:Ea,ZodCatch:Aa,ZodNaN:Rf,BRAND:GH,ZodBranded:uu,ZodPipeline:Sa,ZodReadonly:Ma,custom:UA,Schema:_t,ZodSchema:_t,late:WH,get ZodFirstPartyTypeKind(){return ot},coerce:kz,any:rz,array:sz,bigint:ZH,boolean:qA,date:XH,discriminatedUnion:uz,effect:DA,enum:yz,function:bz,instanceof:JH,intersection:lz,lazy:gz,literal:vz,map:pz,nan:YH,nativeEnum:xz,never:iz,null:tz,nullable:Ez,number:$A,object:az,oboolean:Cz,onumber:Tz,optional:_z,ostring:Mz,pipeline:Sz,preprocess:Az,promise:wz,record:dz,set:mz,strictObject:fz,string:FA,symbol:QH,transformer:DA,tuple:hz,undefined:ez,union:cz,unknown:nz,void:oz,NEVER:Iz,ZodIssueCode:Oe,quotelessJson:kH,ZodError:fn});var hu=Symbol("current"),Of=Symbol("previous");var th=o((r,{ref:e,refType:t,param:n,header:i,...s}={})=>({...s,...r}),"mergeOpenApi");function rh(r){if(typeof r.ZodType.prototype.openapi<"u")return;r.ZodType.prototype.openapi=function(s){let{zodOpenApi:f,...u}=this._def,d=new this.constructor({...u,zodOpenApi:{openapi:th(s,f?.openapi)}});return d._def.zodOpenApi[hu]=d,f&&(d._def.zodOpenApi[Of]=this),d};let e=r.ZodType.prototype.describe;r.ZodType.prototype.describe=function(...s){let f=e.apply(this,s),u=f._def;if(u.zodOpenApi){let d={...u.zodOpenApi};d.openapi=th({description:s[0]},d.openapi),d[Of]=this,d[hu]=f,u.zodOpenApi=d}else u.zodOpenApi={openapi:{description:s[0]},[hu]:f};return f};let t=r.ZodObject.prototype.extend;r.ZodObject.prototype.extend=function(...s){let f=t.apply(this,s),u=f._def.zodOpenApi;if(u){let d={...u};d.openapi=th({},d.openapi),d[Of]=this,f._def.zodOpenApi=d}else f._def.zodOpenApi={[Of]:this};return f};let n=r.ZodObject.prototype.omit;r.ZodObject.prototype.omit=function(...s){let f=n.apply(this,s),u=f._def.zodOpenApi;if(u){let d={...u};d.openapi=th({},d.openapi),delete d[Of],delete d[hu],f._def.zodOpenApi=d}return f};let i=r.ZodObject.prototype.pick;r.ZodObject.prototype.pick=function(...s){let f=i.apply(this,s),u=f._def.zodOpenApi;if(u){let d={...u};d.openapi=th({},d.openapi),delete d[Of],delete d[hu],f._def.zodOpenApi=d}return f}}o(rh,"extendZodWithOpenApi");rh(m);var Dz=Object.defineProperty,Rz=o((r,e)=>Dz(r,"name",{value:e,configurable:!0}),"__name"),kp=m.array(m.string().or(m.record(m.any()))),Xie=m.object({type:m.string().optional(),narrative:m.string().optional()}),Ip=m.string().or(m.object({id:m.string(),type:m.string(),caption:m.string().optional()})),Oz=m.object({type:m.string().min(1).or(m.string().array().nonempty()),latitude:m.number(),longitude:m.number()}),Nz=m.object({type:m.string().min(1).or(m.string().array().nonempty()),addressCountry:m.string().optional(),addressCountryCode:m.string().optional(),addressRegion:m.string().optional(),addressLocality:m.string().optional(),streetAddress:m.string().optional(),postOfficeBoxNumber:m.string().optional(),postalCode:m.string().optional(),geo:Oz.optional()}),Pz=m.enum(["sourcedId","systemId","productId","userName","accountId","emailAddress","nationalIdentityNumber","isbn","issn","lisSourcedId","oneRosterSourcedId","sisSourcedId","ltiContextId","ltiDeploymentId","ltiToolId","ltiPlatformId","ltiUserId","identifier"]).or(m.string()),e7=m.object({type:m.string().min(1).or(m.string().array().nonempty()),identifier:m.string(),identifierType:Pz}),nh=m.string().or(m.object({id:m.string().optional(),type:m.string().or(m.string().array().nonempty().optional()),name:m.string().optional(),url:m.string().optional(),phone:m.string().optional(),description:m.string().optional(),endorsement:m.any().array().optional(),image:Ip.optional(),email:m.string().email().optional(),address:Nz.optional(),otherIdentifier:e7.array().optional(),official:m.string().optional(),parentOrg:m.any().optional(),familyName:m.string().optional(),givenName:m.string().optional(),additionalName:m.string().optional(),patronymicName:m.string().optional(),honorificPrefix:m.string().optional(),honorificSuffix:m.string().optional(),familyNamePrefix:m.string().optional(),dateOfBirth:m.string().optional()}).catchall(m.any())),Kv=m.object({id:m.string().optional()}).catchall(m.any()),Cp=m.object({type:m.string(),id:m.string()}).catchall(m.any()),jA=m.object({id:m.string(),type:m.string()}).catchall(m.any()),HA=m.object({id:m.string().optional(),type:m.string()}).catchall(m.any()),zA=m.object({type:m.string(),id:m.string().optional()}).catchall(m.any()),KA=m.object({type:m.string().or(m.string().array().nonempty()),id:m.string().optional()}).catchall(m.any()),du=m.object({"@context":kp,id:m.string().optional(),type:m.string().array().nonempty(),issuer:nh,credentialSubject:Kv.or(Kv.array()),refreshService:HA.or(HA.array()).optional(),credentialSchema:jA.or(jA.array()).optional(),issuanceDate:m.string().optional(),expirationDate:m.string().optional(),credentialStatus:Cp.or(Cp.array()).optional(),name:m.string().optional(),description:m.string().optional(),validFrom:m.string().optional(),validUntil:m.string().optional(),status:Cp.or(Cp.array()).optional(),termsOfUse:zA.or(zA.array()).optional(),evidence:KA.or(KA.array()).optional()}).catchall(m.any()),Bo=m.object({type:m.string(),created:m.string(),challenge:m.string().optional(),domain:m.string().optional(),nonce:m.string().optional(),proofPurpose:m.string(),verificationMethod:m.string(),jws:m.string().optional()}).catchall(m.any()),Pf=du.extend({proof:Bo.or(Bo.array())}),Bz=m.object({"@context":kp,id:m.string().optional(),type:m.string().or(m.string().array().nonempty()),verifiableCredential:Pf.or(Pf.array()).optional(),holder:m.string().optional()}).catchall(m.any()),oh=Bz.extend({proof:Bo.or(Bo.array())}),Wv=m.object({kty:m.string(),crv:m.string(),x:m.string(),y:m.string().optional(),n:m.string().optional(),d:m.string().optional()}),toe=Wv.omit({d:!0}).extend({d:m.string()}),Lz=m.object({alg:m.string(),iv:m.string(),tag:m.string(),epk:Wv.partial().optional(),kid:m.string().optional(),apv:m.string().optional(),apu:m.string().optional()}),Uz=m.object({header:Lz,encrypted_key:m.string()}),Fz=m.object({protected:m.string(),iv:m.string(),ciphertext:m.string(),tag:m.string(),aad:m.string().optional(),recipients:Uz.array().optional()}),Nf=m.string().or(m.object({"@context":kp.optional(),id:m.string(),type:m.string(),controller:m.string(),publicKeyJwk:Wv.optional(),publicKeyBase58:m.string().optional(),publicKeyMultibase:m.string().optional(),blockChainAccountId:m.string().optional()}).catchall(m.any())),$z=m.object({id:m.string(),type:m.string().or(m.string().array().nonempty()),serviceEndpoint:m.any().or(m.any().array().nonempty())}).catchall(m.any()),roe=m.object({"@context":kp,id:m.string(),alsoKnownAs:m.string().optional(),controller:m.string().or(m.string().array().nonempty()).optional(),verificationMethod:Nf.array().optional(),authentication:Nf.array().optional(),assertionMethod:Nf.array().optional(),keyAgreement:Nf.array().optional(),capabilityInvocation:Nf.array().optional(),capabilityDelegation:Nf.array().optional(),publicKey:Nf.array().optional(),service:$z.array().optional(),proof:Bo.or(Bo.array()).optional()}).catchall(m.any()),qz=m.enum(["ceasn:Competency","ceterms:Credential","CFItem","CFRubric","CFRubricCriterion","CFRubricCriterionLevel","CTDL"]).or(m.string()),Dp=m.object({type:m.string().array().nonempty(),targetCode:m.string().optional(),targetDescription:m.string().optional(),targetName:m.string(),targetFramework:m.string().optional(),targetType:qz.optional(),targetUrl:m.string()}),jz=m.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"]),Hz=jz.or(m.string()),zz=m.object({id:m.string().optional(),narrative:m.string().optional()}).catchall(m.any()),Kz=m.object({id:m.string(),type:m.string().array().nonempty(),endorsementComment:m.string().optional()}),Vz=du.extend({credentialSubject:Kz,proof:Bo.or(Bo.array()).optional()}),Gz=m.object({id:m.string(),"@language":m.string().optional(),version:m.string().optional()}),Wz=m.enum(["GradePointAverage","LetterGrade","Percent","PerformanceLevel","PredictedScore","RawScore","Result","RubricCriterion","RubricCriterionLevel","RubricScore","ScaledScore","Status"]).or(m.string()),Jz=m.object({id:m.string(),type:m.string().array().nonempty(),alignment:Dp.array().optional(),description:m.string().optional(),level:m.string().optional(),name:m.string(),points:m.string().optional()}).catchall(m.any()),Yz=m.object({id:m.string(),type:m.string().array().nonempty(),alignment:Dp.array().optional(),allowedValue:m.string().array().optional(),name:m.string(),requiredLevel:m.string().optional(),requiredValue:m.string().optional(),resultType:Wz,rubricCriterionLevel:Jz.array().optional(),valueMax:m.string().optional(),valueMin:m.string().optional()}).catchall(m.any()),Zz=m.object({id:m.string().optional(),type:m.string().array().nonempty(),alignment:Dp.array().optional(),achievementType:Hz.optional(),creator:nh.optional(),creditsAvailable:m.number().optional(),criteria:zz,description:m.string(),endorsement:Vz.array().optional(),fieldOfStudy:m.string().optional(),humanCode:m.string().optional(),image:Ip.optional(),"@language":m.string().optional(),name:m.string(),otherIdentifier:e7.array().optional(),related:Gz.array().optional(),resultDescription:Yz.array().optional(),specialization:m.string().optional(),tag:m.string().array().optional(),version:m.string().optional()}).catchall(m.any()),Xz=m.object({type:m.string(),hashed:m.boolean(),identityHash:m.string(),identityType:m.string(),salt:m.string().optional()}),Qz=m.enum(["Completed","Enrolled","Failed","InProgress","OnHold","Withdrew"]),eK=m.object({type:m.string().array().nonempty(),achievedLevel:m.string().optional(),alignment:Dp.array().optional(),resultDescription:m.string().optional(),status:Qz.optional(),value:m.string().optional()}).catchall(m.any()),VA=m.object({id:m.string().optional(),type:m.string().array().nonempty(),activityEndDate:m.string().optional(),activityStartDate:m.string().optional(),creditsEarned:m.number().optional(),achievement:Zz.optional(),identifier:Xz.array().optional(),image:Ip.optional(),licenseNumber:m.string().optional(),narrative:m.string().optional(),result:eK.array().optional(),role:m.string().optional(),source:nh.optional(),term:m.string().optional()}).catchall(m.any()),tK=m.object({id:m.string().optional(),type:m.string().or(m.string().array().nonempty()),narrative:m.string().optional(),name:m.string().optional(),description:m.string().optional(),genre:m.string().optional(),audience:m.string().optional()}).catchall(m.any()),rK=du.extend({name:m.string().optional(),description:m.string().optional(),image:Ip.optional(),credentialSubject:VA.or(VA.array()),endorsement:du.array().optional(),evidence:tK.array().optional()}),ioe=rK.extend({proof:Bo.or(Bo.array())}),soe=m.object({checks:m.string().array(),warnings:m.string().array(),errors:m.string().array()}),t7=m.enum(["Success","Failed","Error"]),aoe=t7.enum,foe=m.object({check:m.string(),status:t7,message:m.string().optional(),details:m.string().optional()}),coe=m.object({title:m.string().optional(),createdAt:m.string().optional(),issuer:nh.optional(),issuee:nh.optional(),credentialSubject:Kv.optional()}),uoe=m.object({id:m.string(),uri:m.string()}).catchall(m.any()),doe=m.object({limit:m.number(),cursor:m.string().optional(),sort:m.string().optional()}),Wr=m.object({cursor:m.string().optional(),hasMore:m.boolean()}),r7=m.object({encryptedRecord:Fz,fields:m.string().array()}).catchall(m.any()),poe=Wr.extend({records:r7.array()}),nK=r7.extend({id:m.string()}),moe=Wr.extend({records:nK.array()}),GA=Rz(r=>{let e=r.match(/^\/(.*)\/([gimsuy]*)$/);if(!e)throw new Error("Invalid RegExp string format");return{pattern:e[1],flags:e[2]}},"parseRegexString"),iK=m.instanceof(RegExp).or(m.string().refine(r=>{try{return GA(r),!0}catch{return!1}},{message:"Invalid RegExp string format. Must be in format '/pattern/flags'"}).transform(r=>{let{pattern:e,flags:t}=GA(r);try{return new RegExp(e,t)}catch(n){throw new Error(`Invalid RegExp: ${n.message}`)}})),WA=m.string().or(m.object({$in:m.string().array()})).or(m.object({$regex:iK})),Et=m.union([WA,m.object({$or:WA.array()})]);rh(m);var oK=m.object({backgroundColor:m.string().optional(),backgroundImage:m.string().optional(),fadeBackgroundImage:m.boolean().optional(),repeatBackgroundImage:m.boolean().optional(),fontColor:m.string().optional(),accentColor:m.string().optional(),accentFontColor:m.string().optional(),idBackgroundImage:m.string().optional(),fadeIdBackgroundImage:m.boolean().optional(),idBackgroundColor:m.string().optional(),repeatIdBackgroundImage:m.boolean().optional()}),Lo=m.object({profileId:m.string().min(3).max(40).describe("Unique, URL-safe identifier for the profile."),displayName:m.string().default("").describe("Human-readable display name for the profile."),shortBio:m.string().default("").describe("Short bio for the profile."),bio:m.string().default("").describe("Longer bio for the profile."),did:m.string().describe("Decentralized Identifier for the profile. (auto-assigned)"),isPrivate:m.boolean().optional().describe("Whether the profile is private or not and shows up in search results."),email:m.string().optional().describe("Contact email address for the profile. (deprecated)"),image:m.string().optional().describe("Profile image URL for the profile."),heroImage:m.string().optional().describe("Hero image URL for the profile."),websiteLink:m.string().optional().describe("Website link for the profile."),isServiceProfile:m.boolean().default(!1).optional().describe("Whether the profile is a service profile or not."),type:m.string().optional().describe('Profile type: e.g. "person", "organization", "service".'),notificationsWebhook:m.string().url().startsWith("http").optional().describe("URL to send notifications to."),display:oK.optional().describe("Display settings for the profile."),highlightedCredentials:m.array(m.string()).max(5).optional().describe("Up to 5 unique boost URIs to highlight on the profile."),role:m.string().default("").optional().describe('Role of the profile: e.g. "teacher", "student".'),dob:m.string().default("").optional().describe('Date of birth of the profile: e.g. "1990-01-01".'),country:m.string().optional().describe("Country for the profile."),approved:m.boolean().optional().describe("Approval status for the profile.")}),yoe=m.object({profileId:Et,displayName:Et,shortBio:Et,bio:Et,email:Et,websiteLink:Et,isServiceProfile:m.boolean(),type:Et}).partial(),xoe=Wr.extend({records:Lo.array()}),woe=m.enum(["CONNECTED","PENDING_REQUEST_SENT","PENDING_REQUEST_RECEIVED","NOT_CONNECTED"]),n7=m.object({id:m.string(),created:m.string(),displayName:m.string().default("").optional(),shortBio:m.string().default("").optional(),bio:m.string().default("").optional(),email:m.string().optional(),image:m.string().optional(),heroImage:m.string().optional()}),_oe=Wr.extend({records:n7.extend({did:m.string()}).array()}),Eoe=m.object({id:Et,displayName:Et,shortBio:Et,bio:Et,email:Et}).partial(),Aoe=Wr.extend({records:m.object({profile:Lo,manager:n7.extend({did:m.string()}).optional()}).array()}),Soe=m.object({uri:m.string(),to:m.string(),from:m.string(),sent:m.string().datetime(),received:m.string().datetime().optional(),metadata:m.record(m.unknown()).optional()}),i7=m.object({role:m.string(),canEdit:m.boolean(),canIssue:m.boolean(),canRevoke:m.boolean(),canManagePermissions:m.boolean(),canIssueChildren:m.string(),canCreateChildren:m.string(),canEditChildren:m.string(),canRevokeChildren:m.string(),canManageChildrenPermissions:m.string(),canManageChildrenProfiles:m.boolean().default(!1).optional(),canViewAnalytics:m.boolean()}),sK=m.object({role:Et,canEdit:m.boolean(),canIssue:m.boolean(),canRevoke:m.boolean(),canManagePermissions:m.boolean(),canIssueChildren:Et,canCreateChildren:Et,canEditChildren:Et,canRevokeChildren:Et,canManageChildrenPermissions:Et,canManageChildrenProfiles:m.boolean(),canViewAnalytics:m.boolean()}).partial(),zv=m.enum(["GRANT_PERMISSIONS","ADD_ADMIN","AUTO_CONNECT"]),aK=m.discriminatedUnion("type",[m.object({type:m.literal(zv.Values.GRANT_PERMISSIONS),data:m.object({claimUri:m.string(),targetUri:m.string(),permissions:i7.partial()})}),m.object({type:m.literal(zv.Values.ADD_ADMIN),data:m.object({claimUri:m.string(),targetUri:m.string()})}),m.object({type:m.literal(zv.Values.AUTO_CONNECT),data:m.object({claimUri:m.string(),targetUri:m.string()})})]),Moe=m.object({type:Et,data:m.object({claimUri:Et,targetUri:Et,permissions:sK})}).deepPartial(),fK=m.object({id:m.string(),createdAt:m.string(),updatedAt:m.string()}).and(aK),Toe=Wr.extend({records:fK.array()}),Vv=m.enum(["DRAFT","LIVE"]),cK=m.object({uri:m.string(),name:m.string().optional(),type:m.string().optional(),category:m.string().optional(),status:Vv.optional(),autoConnectRecipients:m.boolean().optional(),meta:m.record(m.any()).optional(),claimPermissions:i7.optional(),allowAnyoneToCreateChildren:m.boolean().optional()}),JA=m.object({uri:Et,name:Et,type:Et,category:Et,meta:m.record(Et),status:Vv.or(m.object({$in:Vv.array()})),autoConnectRecipients:m.boolean()}).partial(),Coe=m.union([m.object({$or:JA.array()}),JA]),koe=Wr.extend({records:cK.array()}),uK=m.object({to:Lo,from:m.string(),received:m.string().optional(),uri:m.string().optional()}),Ioe=Wr.extend({records:uK.array()}),lK=m.object({to:Lo,from:m.string(),received:m.string().optional(),boostUris:m.array(m.string()),credentialUris:m.array(m.string()).optional()}),Doe=Wr.extend({records:lK.array()}),Roe=m.object({endpoint:m.string(),name:m.string(),did:m.string().optional()}),Ooe=m.object({ttlSeconds:m.number().optional(),totalUses:m.number().optional()}),hK=m.object({endpoint:m.string()}),Noe=m.object({signingAuthority:hK,relationship:m.object({name:m.string().max(15).regex(/^[a-z0-9-]+$/,{message:"The input string must contain only lowercase letters, numbers, and hyphens."}),did:m.string(),isPrimary:m.boolean().optional()})}),Poe=m.object({boostUri:m.string(),signingAuthority:m.object({endpoint:m.string(),name:m.string()})}),dK=m.enum(["live","stale","withdrawn"]),pK=m.object({read:m.object({anonymize:m.boolean().optional(),credentials:m.object({categories:m.record(m.object({required:m.boolean(),defaultEnabled:m.boolean().optional()})).default({})}).default({}),personal:m.record(m.object({required:m.boolean(),defaultEnabled:m.boolean().optional()})).default({})}).default({}),write:m.object({credentials:m.object({categories:m.record(m.object({required:m.boolean(),defaultEnabled:m.boolean().optional()})).default({})}).default({}),personal:m.record(m.object({required:m.boolean(),defaultEnabled:m.boolean().optional()})).default({})}).default({})}),o7=m.object({contract:pK,owner:Lo,name:m.string(),subtitle:m.string().optional(),description:m.string().optional(),reasonForAccessing:m.string().optional(),image:m.string().optional(),uri:m.string(),needsGuardianConsent:m.boolean().optional(),redirectUrl:m.string().optional(),frontDoorBoostUri:m.string().optional(),createdAt:m.string(),updatedAt:m.string(),expiresAt:m.string().optional(),autoBoosts:m.string().array().optional(),writers:m.array(Lo).optional()}),Boe=Wr.extend({records:o7.omit({owner:!0}).array()}),mK=m.object({credentials:m.object({categories:m.record(m.string().array()).default({})}),personal:m.record(m.string()).default({}),date:m.string()}),Loe=Wr.extend({records:mK.array()}),bK=m.object({credentials:m.object({category:m.string(),uri:m.string()}).array(),personal:m.record(m.string()).default({}),date:m.string(),contractUri:m.string()}),Uoe=Wr.extend({records:bK.array()}),s7=m.object({sharing:m.boolean().optional(),shared:m.string().array().optional(),shareAll:m.boolean().optional(),shareUntil:m.string().optional()}),a7=m.object({read:m.object({anonymize:m.boolean().optional(),credentials:m.object({shareAll:m.boolean().optional(),sharing:m.boolean().optional(),categories:m.record(s7).default({})}).default({}),personal:m.record(m.string()).default({})}).default({}),write:m.object({credentials:m.object({categories:m.record(m.boolean()).default({})}).default({}),personal:m.record(m.boolean()).default({})}).default({}),deniedWriters:m.array(m.string()).optional()}),Foe=Wr.extend({records:m.object({expiresAt:m.string().optional(),oneTime:m.boolean().optional(),terms:a7,contract:o7,uri:m.string(),consenter:Lo,status:dK}).array()}),$oe=m.object({read:m.object({anonymize:m.boolean().optional(),credentials:m.object({categories:m.record(m.object({required:m.boolean().optional()})).optional()}).optional(),personal:m.record(m.object({required:m.boolean().optional()})).optional()}).optional(),write:m.object({credentials:m.object({categories:m.record(m.object({required:m.boolean().optional()})).optional()}).optional(),personal:m.record(m.object({required:m.boolean().optional()})).optional()}).optional()}),qoe=m.object({anonymize:m.boolean().optional(),credentials:m.object({categories:m.record(m.boolean()).optional()}).optional(),personal:m.record(m.boolean()).optional()}),joe=m.object({credentials:m.object({categories:m.record(m.boolean()).optional()}).optional(),personal:m.record(m.boolean()).optional(),id:Et.optional()}),gK=m.object({read:m.object({anonymize:m.boolean().optional(),credentials:m.object({shareAll:m.boolean().optional(),sharing:m.boolean().optional(),categories:m.record(s7.optional()).optional()}).optional(),personal:m.record(m.string()).optional()}).optional(),write:m.object({credentials:m.object({categories:m.record(m.boolean()).optional()}).optional(),personal:m.record(m.boolean()).optional()}).optional()}),Gv=m.enum(["consent","update","sync","withdraw","write"]),Hoe=m.object({terms:gK.optional(),action:Gv.or(Gv.array()).optional(),date:m.object({$gt:m.string()}).or(m.object({$lt:m.string()})).or(m.object({$eq:m.string()})).optional(),expiresAt:m.object({$gt:m.string()}).or(m.object({$lt:m.string()})).or(m.object({$eq:m.string()})).optional(),oneTime:m.boolean().optional()}),f7=m.object({expiresAt:m.string().optional(),oneTime:m.boolean().optional(),terms:a7.optional(),id:m.string(),action:Gv,date:m.string(),uris:m.string().array().optional()}),zoe=Wr.extend({records:f7.array()}),YA=m.object({id:Et,name:Et,description:Et,sourceURI:Et,status:Et}).partial(),Koe=m.union([m.object({$or:YA.array()}),YA]),vK=m.object({credentialUri:m.string(),termsUri:m.string(),contractUri:m.string(),boostUri:m.string(),category:m.string().optional(),date:m.string()}),Voe=Wr.extend({records:vK.array()}),yK=m.enum(["CONNECTION_REQUEST","CONNECTION_ACCEPTED","CREDENTIAL_RECEIVED","CREDENTIAL_ACCEPTED","BOOST_RECEIVED","BOOST_ACCEPTED","PRESENTATION_REQUEST","PRESENTATION_RECEIVED","CONSENT_FLOW_TRANSACTION","ISSUANCE_CLAIMED","ISSUANCE_DELIVERED","ISSUANCE_ERROR","PROFILE_PARENT_APPROVED"]),xK=m.object({title:m.string().optional(),body:m.string().optional()}),wK=m.object({type:m.string(),value:m.string()}),Rp=m.enum(["PENDING","ISSUED","EXPIRED","DELIVERED","CLAIMED"]),_K=m.object({issuanceId:m.string(),status:Rp,recipient:m.object({contactMethod:wK.optional(),learnCardId:m.string().optional()}),timestamp:m.string().datetime().optional()}),EK=m.object({vcUris:m.array(m.string()).optional(),vpUris:m.array(m.string()).optional(),transaction:f7.optional(),inbox:_K.optional(),metadata:m.record(m.unknown()).optional()}).passthrough(),Goe=m.object({type:yK,to:Lo.partial().and(m.object({did:m.string()})),from:Lo.partial().and(m.object({did:m.string()})),message:xK.optional(),data:EK.optional(),sent:m.string().datetime().optional(),webhookUrl:m.string().optional()}),AK="auth-grant:",Woe=m.object({id:m.string(),name:m.string(),description:m.string().optional(),challenge:m.string().startsWith(AK).min(10,{message:"Challenge is too short"}).max(100,{message:"Challenge is too long"}),status:m.enum(["revoked","active"],{required_error:"Status is required",invalid_type_error:"Status must be either active or revoked"}),scope:m.string(),createdAt:m.string().datetime({message:"createdAt must be a valid ISO 8601 datetime string"}),expiresAt:m.string().datetime({message:"expiresAt must be a valid ISO 8601 datetime string"}).nullish().optional()}),Joe=m.object({id:m.string()}).catchall(m.any()),SK=m.enum(["active","revoked"]),Yoe=m.object({id:Et,name:Et,description:Et,status:SK}).partial(),ZA=m.object({id:m.string(),isVerified:m.boolean(),verifiedAt:m.string().optional(),isPrimary:m.boolean(),createdAt:m.string()}),Zoe=m.discriminatedUnion("type",[m.object({type:m.literal("email"),value:m.string().email()}).merge(ZA),m.object({type:m.literal("phone"),value:m.string()}).merge(ZA)]),XA=m.object({isVerified:m.boolean().optional(),isPrimary:m.boolean().optional()}),Xoe=m.discriminatedUnion("type",[m.object({type:m.literal("email"),value:m.string().email()}).merge(XA),m.object({type:m.literal("phone"),value:m.string()}).merge(XA)]),c7=m.discriminatedUnion("type",[m.object({type:m.literal("email"),value:m.string().email()}),m.object({type:m.literal("phone"),value:m.string()})]),MK=m.object({value:m.string(),type:m.enum(["email","phone"])}),Qoe=m.object({token:m.string()}),ese=m.object({contactMethodId:m.string()}),tse=m.object({contactMethod:MK,otpChallenge:m.string()}),rse=m.object({sessionJwt:m.string()}),TK=m.object({id:m.string(),credential:m.string(),isSigned:m.boolean(),currentStatus:Rp,isAccepted:m.boolean().optional(),expiresAt:m.string(),createdAt:m.string(),issuerDid:m.string(),webhookUrl:m.string().optional(),signingAuthority:m.object({endpoint:m.string().optional(),name:m.string().optional()}).optional()}),nse=m.object({hasMore:m.boolean(),records:m.array(TK),cursor:m.string().optional()}),ise=m.object({currentStatus:Rp,id:m.string(),isSigned:m.boolean(),isAccepted:m.boolean().optional(),issuerDid:m.string()}).partial(),CK=m.object({endpoint:m.string().url(),name:m.string()}),ose=m.object({recipient:c7.describe("The recipient of the credential"),credential:Pf.passthrough().or(oh.passthrough()).or(du.passthrough()).describe("The credential to issue. If not signed, the users default signing authority will be used, or the specified signing authority in the configuration."),configuration:m.object({signingAuthority:CK.optional().describe("The signing authority to use for the credential. If not provided, the users default signing authority will be used if the credential is not signed."),webhookUrl:m.string().url().optional().describe("The webhook URL to receive credential issuance events."),expiresInDays:m.number().min(1).max(365).optional().describe("The number of days the credential will be valid for."),delivery:m.object({suppress:m.boolean().optional().default(!1).describe("Whether to suppress delivery of the credential to the recipient. If true, the email/sms will not be sent to the recipient. Useful if you would like to manually send claim link to your users."),template:m.object({id:m.enum(["universal-inbox-claim"]).optional().describe("The template ID to use for the credential delivery. If not provided, the default template will be used."),model:m.object({issuer:m.object({name:m.string().optional().describe('The name of the organization (e.g., "State University").'),logoUrl:m.string().url().optional().describe("The URL of the organization's logo.")}).optional(),credential:m.object({name:m.string().optional().describe('The name of the credential (e.g., "Bachelor of Science").'),type:m.string().optional().describe('The type of the credential (e.g., "degree", "certificate").')}).optional(),recipient:m.object({name:m.string().optional().describe('The name of the recipient (e.g., "John Doe").')}).optional()}).describe("The template model to use for the credential delivery. Injects via template variables into email/sms templates. If not provided, the default template will be used.")}).optional().describe("The template to use for the credential delivery. If not provided, the default template will be used.")}).optional().describe("Configuration for the credential delivery i.e. email or SMS. When credentials are sent to a user who has a verified email or phone associated with their account, delivery is skipped, and the credential will be sent using in-app notifications. If not provided, the default configuration will be used.")}).optional().describe("Configuration for the credential issuance. If not provided, the default configuration will be used.")}),sse=m.object({issuanceId:m.string(),status:Rp,recipient:c7,claimUrl:m.string().url().optional(),recipientDid:m.string().optional()}),ase=m.object({credential:Pf.passthrough().or(oh.passthrough()).or(du.passthrough()).describe("The credential to issue."),configuration:m.object({publishableKey:m.string(),signingAuthorityName:m.string().optional()}).optional()}),Jv=m.union([m.string().regex(/^(?:(?:[a-zA-Z0-9-]{1,63}\.)+[a-zA-Z]{2,63}|localhost|\d{1,3}(?:\.\d{1,3}){3})(?::\d{1,5})?$/,{message:"Must be a valid domain (incl. subdomains), localhost, or IPv4, optionally with port"}),m.string().regex(/^https?:\/\/(?:(?:[a-zA-Z0-9-]{1,63}\.)+[a-zA-Z]{2,63}|localhost|\d{1,3}(?:\.\d{1,3}){3})(?::\d{1,5})?$/,{message:"Must be a valid http(s) origin"})]),kK=m.object({id:m.string(),name:m.string(),description:m.string().optional(),publishableKey:m.string(),whitelistedDomains:m.array(Jv).default([])}),fse=m.object({name:m.string(),description:m.string().optional(),whitelistedDomains:m.array(Jv).default([])}),cse=m.object({name:m.string().optional(),description:m.string().optional(),whitelistedDomains:m.array(Jv).optional(),rotatePublishableKey:m.boolean().optional()}),use=m.object({id:Et,name:Et,description:Et}).partial(),lse=Wr.extend({records:kK.array()}),hse=m.object({token:m.string(),contactMethodId:m.string(),autoVerifyContactMethod:m.boolean().optional().default(!1),createdAt:m.string(),expiresAt:m.string(),used:m.boolean()}),dse=m.object({id:m.string(),name:m.string().min(1),slug:m.string().min(1),createdAt:m.string().optional(),updatedAt:m.string().optional()}),ih=m.enum(["active","archived"]),u7=m.object({id:m.string(),statement:m.string(),description:m.string().optional(),code:m.string().optional(),icon:m.string().optional(),type:m.string().default("skill"),status:ih.default("active"),frameworkId:m.string().optional(),createdAt:m.string().optional(),updatedAt:m.string().optional()}),QA=m.object({id:Et,statement:Et,description:Et,code:Et,type:Et,status:ih.or(m.object({$in:ih.array()}))}).partial(),pse=m.union([m.object({$or:QA.array()}),QA]),Yv=m.enum(["active","archived"]),l7=m.object({id:m.string(),name:m.string(),description:m.string().optional(),image:m.string().optional(),sourceURI:m.string().url().optional(),status:Yv.default("active"),createdAt:m.string().optional(),updatedAt:m.string().optional()}),mse=Wr.extend({records:l7.array()}),Zv=u7.extend({children:m.array(m.lazy(()=>Zv)),hasChildren:m.boolean(),childrenCursor:m.string().nullable().optional()}).openapi({ref:"SkillTreeNode"}),IK=m.object({hasMore:m.boolean(),cursor:m.string().nullable(),records:m.array(Zv)}),pu=m.lazy(()=>m.object({id:m.string().optional(),statement:m.string(),description:m.string().optional(),code:m.string().optional(),icon:m.string().optional(),type:m.string().optional(),status:ih.optional(),children:m.array(pu).optional()})).openapi({ref:"SkillTreeNodeInput"}),bse=m.object({frameworkId:m.string()}),DK=m.object({id:m.string().optional(),name:m.string().min(1),description:m.string().optional(),image:m.string().optional(),sourceURI:m.string().url().optional(),status:Yv.optional(),skills:m.array(pu).optional(),boostUris:m.array(m.string()).optional()}),gse=m.object({id:m.string(),name:m.string().min(1).optional(),description:m.string().optional(),image:m.string().optional(),sourceURI:m.string().url().optional(),status:Yv.optional()}).refine(r=>r.name!==void 0||r.description!==void 0||r.image!==void 0||r.sourceURI!==void 0||r.status!==void 0,{message:"At least one field must be provided to update",path:["name"]}),vse=m.object({id:m.string()}),yse=m.object({frameworks:m.array(DK.extend({skills:m.array(pu).optional()})).min(1)}),xse=m.object({frameworkId:m.string(),profileId:m.string()}),wse=m.object({frameworkId:m.string()}),_se=Lo.array(),Ese=m.object({id:m.string()}),Ase=m.object({slug:m.string().min(1),name:m.string().min(1)}),Sse=m.object({frameworkId:m.string(),skill:pu,parentId:m.string().nullable().optional()}),Mse=m.object({frameworkId:m.string(),id:m.string(),statement:m.string().optional(),description:m.string().optional(),code:m.string().optional(),icon:m.string().optional(),type:m.string().optional(),status:ih.optional()}).refine(r=>r.statement!==void 0||r.description!==void 0||r.code!==void 0||r.icon!==void 0||r.type!==void 0||r.status!==void 0,{message:"At least one field must be provided to update a skill",path:["statement"]}),RK=m.enum(["recursive","reparent"]),Tse=m.object({frameworkId:m.string(),id:m.string(),strategy:RK.optional().default("reparent")}),Cse=m.object({frameworkId:m.string(),skills:m.array(pu).min(1),parentId:m.string().nullable().optional()}),kse=m.object({frameworkId:m.string(),skills:m.array(pu).min(0)}),Ise=m.object({created:m.number().int().min(0),updated:m.number().int().min(0),deleted:m.number().int().min(0),unchanged:m.number().int().min(0),total:m.number().int().min(0)}),Dse=m.object({frameworkId:m.string(),skillId:m.string().optional(),recursive:m.boolean().optional().default(!1),onlyCountCompetencies:m.boolean().optional().default(!1)}),Rse=m.object({count:m.number().int().min(0)}),Ose=m.object({frameworkId:m.string()}),Nse=m.object({skills:m.array(Zv)}),Pse=m.object({frameworkId:m.string(),skillId:m.string()}),Bse=m.object({path:m.array(u7)}),Lse=m.object({framework:l7,skills:IK});var Op=o(r=>`lc:ceramic:${r}`,"streamIdToCeramicURI");var Xv=m.string().refine(r=>r.split(":").length===3&&r.split(":")[0]==="lc","URI must be of the form lc:${storage}:${url}").refine(r=>r.split(":")[1]==="ceramic","URI must use storage type ceramic (i.e. must be lc:ceramic:${streamID})");var h7={ceramicEndpoint:"https://ceramic-node.welibrary.io:7007",defaultContentFamily:"SuperSkills"};var Np=o(async(r,{ceramicEndpoint:e,defaultContentFamily:t}=h7)=>{let n=new Yl(e),i=o(async(R,I,B,Y)=>r.invoke.didResolver(R,Y),"learnCardResolver"),s={...I_.getResolver(),web:i},f=new hf({resolver:s});n.did=f;let u=r.invoke.getKey(),d=new Sl(h_(u));n.did.setProvider(d),await n.did.authenticate();let y=new Hl({ceramic:n}),w=o(async(R,I={},B={},Y)=>{if(!R)throw new Error("content is required");if(I.controllers||(I.controllers=[n.did.id]),I.family||(I.family=t),"pin"in B||(B.pin=!0),Y?.encrypt){r.debug?.("learnCard.store.Ceramic.upload.publishContentToCeramic - encrypt enabled",Y);let J=Y?.recipients||[];Y?.controllersCanDecrypt&&(J=[...J,...I.controllers]),R=await n?.did?.createDagJWE(R,d7.default.uniq(J))}return r.debug?.("learnCard.store.Ceramic.upload.publishContentToCeramic - content to upload",R,I,B),(await ei.create(n,R,I,B)).id.toString()},"publishContentToCeramic"),A=o(async R=>{let I=(await y.load(R))?.content;if(r.debug?.("learnCard.read.get.readContentFromCeramic",I),I?.ciphertext)try{return await f.decryptDagJWE(I)}catch(B){throw r.debug?.("learnCard.read.get.readContentFromCeramic - Could not decrypt credential - DID not authorized.",B),new Error("Could not decrypt credential - DID not authorized.")}return I},"readContentFromCeramic"),O=o(async(R,I)=>(await Pf.or(oh).parseAsync(R),Op(await w(R,{},{},I))),"uploadCredential");return{name:"Ceramic",displayName:"Ceramic",description:"Uploads/resolves credentials using the Ceramic Network (https://ceramic.network/)",store:{upload:async(R,I)=>(R.debug?.("learnCard.store.Ceramic.upload"),O(I)),uploadEncrypted:async(R,I,B)=>(R.debug?.("learnCard.store.Ceramic.uploadEncrypted"),O(I,{encrypt:!0,controllersCanDecrypt:!0,...B?{recipients:B.recipients}:{}}))},read:{get:async(R,I)=>{if(R.debug?.("learnCard.read.Ceramic.get"),!I)return;let B=await Xv.spa(I);if(!B.success)return;let Y=B.data.split(":")[2];try{return await Pf.or(oh).parseAsync(await A(Y))}catch(P){R.debug?.(P);return}}},methods:{publishContentToCeramic:async(R,I,B)=>Op(await w(I,{},{},B)),readContentFromCeramic:async(R,I)=>A(I),getCeramicClient:()=>n,getDIDObject:()=>n.did}}},"getCeramicPlugin");var OK=Np;
|
|
823
823
|
/*!
|
|
824
824
|
* The buffer module from node.js, for the browser.
|
|
825
825
|
*
|