@vicin/sigil 2.2.1 → 3.0.0

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.
@@ -1,2381 +1,6 @@
1
- (function (exports) {
2
- 'use strict';
1
+ (function(exports){'use strict';var xt=Object.defineProperty;var Et=(i,r,h)=>r in i?xt(i,r,{enumerable:true,configurable:true,writable:true,value:h}):i[r]=h;var q=(i,r,h)=>Et(i,typeof r!="symbol"?r+"":r,h);var ae={labelValidation:null,skipLabelInheritanceCheck:false,autofillLabels:true},_t=i=>{if("autofillLabels"in i){if(typeof i.autofillLabels!="boolean")throw new Error("'updateSigilOptions.autofillLabels' must be boolean");ae.autofillLabels=i.autofillLabels;}if("skipLabelInheritanceCheck"in i){if(typeof i.skipLabelInheritanceCheck!="boolean")throw new Error("'updateSigilOptions.skipLabelInheritanceCheck' must be boolean");ae.skipLabelInheritanceCheck=i.skipLabelInheritanceCheck;}if("labelValidation"in i){let r=i.labelValidation;if(r!==null&&typeof r!="function"&&!(r instanceof RegExp))throw new Error("'updateSigilOptions.labelValidation' must be null, function or RegExp");ae.labelValidation=r!=null?r:null;}},yt=/^@[\w-]+(?:\/[\w-]+)*\.[A-Z][A-Za-z0-9]*$/;var Ne=Symbol.for("@vicin/sigil.__SIGIL__"),Te=Symbol.for("@vicin/sigil.__SIGIL_BASE__"),Be=Symbol.for("@vicin/sigil.__DECORATED__"),Ce=Symbol.for("@vicin/sigil.__INHERITANCE_CHECKED__"),Q=Symbol.for("@vicin/sigil.__LABEL__"),pe=Symbol.for("@vicin/sigil.__EFFECTIVE_LABEL__"),H=Symbol.for("@vicin/sigil.__LABEL_LINEAGE__"),ie=Symbol.for("@vicin/sigil.__LABEL_SET__");var xe=BigInt(4294967295),We=BigInt(32);function Lt(i,r=false){return r?{h:Number(i&xe),l:Number(i>>We&xe)}:{h:Number(i>>We&xe)|0,l:Number(i&xe)|0}}function Ke(i,r=false){let h=i.length,S=new Uint32Array(h),d=new Uint32Array(h);for(let _=0;_<h;_++){let{h:p,l:x}=Lt(i[_],r);[S[_],d[_]]=[p,x];}return [S,d]}var Ye=(i,r,h)=>i<<h|r>>>32-h,Ze=(i,r,h)=>r<<h|i>>>32-h,Je=(i,r,h)=>r<<h-32|i>>>64-h,Qe=(i,r,h)=>i<<h-32|r>>>64-h;function mt(i){return i instanceof Uint8Array||ArrayBuffer.isView(i)&&i.constructor.name==="Uint8Array"}function ve(i,r=""){if(!Number.isSafeInteger(i)||i<0){let h=r&&`"${r}" `;throw new Error(`${h}expected integer >= 0, got ${i}`)}}function Ee(i,r,h=""){let S=mt(i),d=i==null?void 0:i.length,_=r!==void 0;if(!S||_){let p=h&&`"${h}" `,x="",O=S?`length=${d}`:`type=${typeof i}`;throw new Error(p+"expected Uint8Array"+x+", got "+O)}return i}function De(i,r=true){if(i.destroyed)throw new Error("Hash instance has been destroyed");if(r&&i.finished)throw new Error("Hash#digest() has already been called")}function et(i,r){Ee(i,void 0,"digestInto() output");let h=r.outputLen;if(i.length<h)throw new Error('"digestInto() output" expected to be of length >='+h)}function tt(i){return new Uint32Array(i.buffer,i.byteOffset,Math.floor(i.byteLength/4))}function Re(...i){for(let r=0;r<i.length;r++)i[r].fill(0);}var Ot=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function bt(i){return i<<24&4278190080|i<<8&16711680|i>>>8&65280|i>>>24&255}function It(i){for(let r=0;r<i.length;r++)i[r]=bt(i[r]);return i}var Pe=Ot?i=>i:It;function it(i,r={}){let h=(d,_)=>i(_).update(d).digest(),S=i(void 0);return h.outputLen=S.outputLen,h.blockLen=S.blockLen,h.create=d=>i(d),Object.assign(h,r),Object.freeze(h)}var nt=i=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,i])});var At=BigInt(0),de=BigInt(1),kt=BigInt(2),Nt=BigInt(7),Tt=BigInt(256),Bt=BigInt(113),st=[],ct=[],lt=[];for(let i=0,r=de,h=1,S=0;i<24;i++){[h,S]=[S,(2*h+3*S)%5],st.push(2*(5*S+h)),ct.push((i+1)*(i+2)/2%64);let d=At;for(let _=0;_<7;_++)r=(r<<de^(r>>Nt)*Bt)%Tt,r&kt&&(d^=de<<(de<<BigInt(_))-de);lt.push(d);}var ft=Ke(lt,true),Ct=ft[0],vt=ft[1],rt=(i,r,h)=>h>32?Je(i,r,h):Ye(i,r,h),ot=(i,r,h)=>h>32?Qe(i,r,h):Ze(i,r,h);function Dt(i,r=24){let h=new Uint32Array(10);for(let S=24-r;S<24;S++){for(let p=0;p<10;p++)h[p]=i[p]^i[p+10]^i[p+20]^i[p+30]^i[p+40];for(let p=0;p<10;p+=2){let x=(p+8)%10,O=(p+2)%10,m=h[O],N=h[O+1],D=rt(m,N,1)^h[x],V=ot(m,N,1)^h[x+1];for(let Z=0;Z<50;Z+=10)i[p+Z]^=D,i[p+Z+1]^=V;}let d=i[2],_=i[3];for(let p=0;p<24;p++){let x=ct[p],O=rt(d,_,x),m=ot(d,_,x),N=st[p];d=i[N],_=i[N+1],i[N]=O,i[N+1]=m;}for(let p=0;p<50;p+=10){for(let x=0;x<10;x++)h[x]=i[p+x];for(let x=0;x<10;x++)i[p+x]^=~h[(x+2)%10]&h[(x+4)%10];}i[0]^=Ct[S],i[1]^=vt[S];}Re(h);}var Ue=class i{constructor(r,h,S,d=false,_=24){q(this,"state");q(this,"pos",0);q(this,"posOut",0);q(this,"finished",false);q(this,"state32");q(this,"destroyed",false);q(this,"blockLen");q(this,"suffix");q(this,"outputLen");q(this,"enableXOF",false);q(this,"rounds");if(this.blockLen=r,this.suffix=h,this.outputLen=S,this.enableXOF=d,this.rounds=_,ve(S,"outputLen"),!(0<r&&r<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=tt(this.state);}clone(){return this._cloneInto()}keccak(){Pe(this.state32),Dt(this.state32,this.rounds),Pe(this.state32),this.posOut=0,this.pos=0;}update(r){De(this),Ee(r);let{blockLen:h,state:S}=this,d=r.length;for(let _=0;_<d;){let p=Math.min(h-this.pos,d-_);for(let x=0;x<p;x++)S[this.pos++]^=r[_++];this.pos===h&&this.keccak();}return this}finish(){if(this.finished)return;this.finished=true;let{state:r,suffix:h,pos:S,blockLen:d}=this;r[S]^=h,(h&128)!==0&&S===d-1&&this.keccak(),r[d-1]^=128,this.keccak();}writeInto(r){De(this,false),Ee(r),this.finish();let h=this.state,{blockLen:S}=this;for(let d=0,_=r.length;d<_;){this.posOut>=S&&this.keccak();let p=Math.min(S-this.posOut,_-d);r.set(h.subarray(this.posOut,this.posOut+p),d),this.posOut+=p,d+=p;}return r}xofInto(r){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(r)}xof(r){return ve(r),this.xofInto(new Uint8Array(r))}digestInto(r){if(et(r,this),this.finished)throw new Error("digest() was already called");return this.writeInto(r),this.destroy(),r}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=true,Re(this.state);}_cloneInto(r){let{blockLen:h,suffix:S,outputLen:d,rounds:_,enableXOF:p}=this;return r||(r=new i(h,S,d,p,_)),r.state32.set(this.state32),r.pos=this.pos,r.posOut=this.posOut,r.finished=this.finished,r.rounds=_,r.suffix=S,r.outputLen=d,r.enableXOF=p,r.destroyed=this.destroyed,r}},Rt=(i,r,h,S={})=>it(()=>new Ue(r,i,h),S);var at=Rt(6,72,64,nt(10));var Pt=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,Fe=Math.ceil,z=Math.floor,M="[BigNumber Error] ",ut=M+"Number primitive has more than 15 significant digits: ",Y=1e14,b=14,He=9007199254740991,Me=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],se=1e7,P=1e9;function ht(i){var r,h,S,d=E.prototype={constructor:E,toString:null,valueOf:null},_=new E(1),p=20,x=4,O=-7,m=21,N=-1e7,D=1e7,V=false,Z=1,oe=0,me={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},fe="0123456789abcdefghijklmnopqrstuvwxyz",Oe=true;function E(e,t){var n,a,s,l,g,o,c,u,f=this;if(!(f instanceof E))return new E(e,t);if(t==null){if(e&&e._isBigNumber===true){f.s=e.s,!e.c||e.e>D?f.c=f.e=null:e.e<N?f.c=[f.e=0]:(f.e=e.e,f.c=e.c.slice());return}if((o=typeof e=="number")&&e*0==0){if(f.s=1/e<0?(e=-e,-1):1,e===~~e){for(l=0,g=e;g>=10;g/=10,l++);l>D?f.c=f.e=null:(f.e=l,f.c=[e]);return}u=String(e);}else {if(!Pt.test(u=String(e)))return S(f,u,o);f.s=u.charCodeAt(0)==45?(u=u.slice(1),-1):1;}(l=u.indexOf("."))>-1&&(u=u.replace(".","")),(g=u.search(/e/i))>0?(l<0&&(l=g),l+=+u.slice(g+1),u=u.substring(0,g)):l<0&&(l=u.length);}else {if(B(t,2,fe.length,"Base"),t==10&&Oe)return f=new E(e),G(f,p+f.e+1,x);if(u=String(e),o=typeof e=="number"){if(e*0!=0)return S(f,u,o,t);if(f.s=1/e<0?(u=u.slice(1),-1):1,E.DEBUG&&u.replace(/^0\.0*|\./,"").length>15)throw Error(ut+e)}else f.s=u.charCodeAt(0)===45?(u=u.slice(1),-1):1;for(n=fe.slice(0,t),l=g=0,c=u.length;g<c;g++)if(n.indexOf(a=u.charAt(g))<0){if(a=="."){if(g>l){l=c;continue}}else if(!s&&(u==u.toUpperCase()&&(u=u.toLowerCase())||u==u.toLowerCase()&&(u=u.toUpperCase()))){s=true,g=-1,l=0;continue}return S(f,String(e),o,t)}o=false,u=h(u,t,10,f.s),(l=u.indexOf("."))>-1?u=u.replace(".",""):l=u.length;}for(g=0;u.charCodeAt(g)===48;g++);for(c=u.length;u.charCodeAt(--c)===48;);if(u=u.slice(g,++c)){if(c-=g,o&&E.DEBUG&&c>15&&(e>He||e!==z(e)))throw Error(ut+f.s*e);if((l=l-g-1)>D)f.c=f.e=null;else if(l<N)f.c=[f.e=0];else {if(f.e=l,f.c=[],g=(l+1)%b,l<0&&(g+=b),g<c){for(g&&f.c.push(+u.slice(0,g)),c-=b;g<c;)f.c.push(+u.slice(g,g+=b));g=b-(u=u.slice(g)).length;}else g-=c;for(;g--;u+="0");f.c.push(+u);}}else f.c=[f.e=0];}E.clone=ht,E.ROUND_UP=0,E.ROUND_DOWN=1,E.ROUND_CEIL=2,E.ROUND_FLOOR=3,E.ROUND_HALF_UP=4,E.ROUND_HALF_DOWN=5,E.ROUND_HALF_EVEN=6,E.ROUND_HALF_CEIL=7,E.ROUND_HALF_FLOOR=8,E.EUCLID=9,E.config=E.set=function(e){var t,n;if(e!=null)if(typeof e=="object"){if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(n=e[t],B(n,0,P,t),p=n),e.hasOwnProperty(t="ROUNDING_MODE")&&(n=e[t],B(n,0,8,t),x=n),e.hasOwnProperty(t="EXPONENTIAL_AT")&&(n=e[t],n&&n.pop?(B(n[0],-P,0,t),B(n[1],0,P,t),O=n[0],m=n[1]):(B(n,-P,P,t),O=-(m=n<0?-n:n))),e.hasOwnProperty(t="RANGE"))if(n=e[t],n&&n.pop)B(n[0],-P,-1,t),B(n[1],1,P,t),N=n[0],D=n[1];else if(B(n,-P,P,t),n)N=-(D=n<0?-n:n);else throw Error(M+t+" cannot be zero: "+n);if(e.hasOwnProperty(t="CRYPTO"))if(n=e[t],n===!!n)if(n)if(typeof crypto!="undefined"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))V=n;else throw V=!n,Error(M+"crypto unavailable");else V=n;else throw Error(M+t+" not true or false: "+n);if(e.hasOwnProperty(t="MODULO_MODE")&&(n=e[t],B(n,0,9,t),Z=n),e.hasOwnProperty(t="POW_PRECISION")&&(n=e[t],B(n,0,P,t),oe=n),e.hasOwnProperty(t="FORMAT"))if(n=e[t],typeof n=="object")me=n;else throw Error(M+t+" not an object: "+n);if(e.hasOwnProperty(t="ALPHABET"))if(n=e[t],typeof n=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(n))Oe=n.slice(0,10)=="0123456789",fe=n;else throw Error(M+t+" invalid: "+n)}else throw Error(M+"Object expected: "+e);return {DECIMAL_PLACES:p,ROUNDING_MODE:x,EXPONENTIAL_AT:[O,m],RANGE:[N,D],CRYPTO:V,MODULO_MODE:Z,POW_PRECISION:oe,FORMAT:me,ALPHABET:fe}},E.isBigNumber=function(e){if(!e||e._isBigNumber!==true)return false;if(!E.DEBUG)return true;var t,n,a=e.c,s=e.e,l=e.s;e:if({}.toString.call(a)=="[object Array]"){if((l===1||l===-1)&&s>=-P&&s<=P&&s===z(s)){if(a[0]===0){if(s===0&&a.length===1)return true;break e}if(t=(s+1)%b,t<1&&(t+=b),String(a[0]).length==t){for(t=0;t<a.length;t++)if(n=a[t],n<0||n>=Y||n!==z(n))break e;if(n!==0)return true}}}else if(a===null&&s===null&&(l===null||l===1||l===-1))return true;throw Error(M+"Invalid BigNumber: "+e)},E.maximum=E.max=function(){return ze(arguments,-1)},E.minimum=E.min=function(){return ze(arguments,1)},E.random=(function(){var e=9007199254740992,t=Math.random()*e&2097151?function(){return z(Math.random()*e)}:function(){return (Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(n){var a,s,l,g,o,c=0,u=[],f=new E(_);if(n==null?n=p:B(n,0,P),g=Fe(n/b),V)if(crypto.getRandomValues){for(a=crypto.getRandomValues(new Uint32Array(g*=2));c<g;)o=a[c]*131072+(a[c+1]>>>11),o>=9e15?(s=crypto.getRandomValues(new Uint32Array(2)),a[c]=s[0],a[c+1]=s[1]):(u.push(o%1e14),c+=2);c=g/2;}else if(crypto.randomBytes){for(a=crypto.randomBytes(g*=7);c<g;)o=(a[c]&31)*281474976710656+a[c+1]*1099511627776+a[c+2]*4294967296+a[c+3]*16777216+(a[c+4]<<16)+(a[c+5]<<8)+a[c+6],o>=9e15?crypto.randomBytes(7).copy(a,c):(u.push(o%1e14),c+=7);c=g/7;}else throw V=false,Error(M+"crypto unavailable");if(!V)for(;c<g;)o=t(),o<9e15&&(u[c++]=o%1e14);for(g=u[--c],n%=b,g&&n&&(o=Me[b-n],u[c]=z(g/o)*o);u[c]===0;u.pop(),c--);if(c<0)u=[l=0];else {for(l=-1;u[0]===0;u.splice(0,1),l-=b);for(c=1,o=u[0];o>=10;o/=10,c++);c<b&&(l-=b-c);}return f.e=l,f.c=u,f}})(),E.sum=function(){for(var e=1,t=arguments,n=new E(t[0]);e<t.length;)n=n.plus(t[e++]);return n},h=(function(){var e="0123456789";function t(n,a,s,l){for(var g,o=[0],c,u=0,f=n.length;u<f;){for(c=o.length;c--;o[c]*=a);for(o[0]+=l.indexOf(n.charAt(u++)),g=0;g<o.length;g++)o[g]>s-1&&(o[g+1]==null&&(o[g+1]=0),o[g+1]+=o[g]/s|0,o[g]%=s);}return o.reverse()}return function(n,a,s,l,g){var o,c,u,f,w,y,L,A,C=n.indexOf("."),R=p,I=x;for(C>=0&&(f=oe,oe=0,n=n.replace(".",""),A=new E(a),y=A.pow(n.length-C),oe=f,A.c=t(ne(X(y.c),y.e,"0"),10,s,e),A.e=A.c.length),L=t(n,a,s,g?(o=fe,e):(o=e,fe)),u=f=L.length;L[--f]==0;L.pop());if(!L[0])return o.charAt(0);if(C<0?--u:(y.c=L,y.e=u,y.s=l,y=r(y,A,R,I,s),L=y.c,w=y.r,u=y.e),c=u+R+1,C=L[c],f=s/2,w=w||c<0||L[c+1]!=null,w=I<4?(C!=null||w)&&(I==0||I==(y.s<0?3:2)):C>f||C==f&&(I==4||w||I==6&&L[c-1]&1||I==(y.s<0?8:7)),c<1||!L[0])n=w?ne(o.charAt(1),-R,o.charAt(0)):o.charAt(0);else {if(L.length=c,w)for(--s;++L[--c]>s;)L[c]=0,c||(++u,L=[1].concat(L));for(f=L.length;!L[--f];);for(C=0,n="";C<=f;n+=o.charAt(L[C++]));n=ne(n,u,o.charAt(0));}return n}})(),r=(function(){function e(a,s,l){var g,o,c,u,f=0,w=a.length,y=s%se,L=s/se|0;for(a=a.slice();w--;)c=a[w]%se,u=a[w]/se|0,g=L*c+u*y,o=y*c+g%se*se+f,f=(o/l|0)+(g/se|0)+L*u,a[w]=o%l;return f&&(a=[f].concat(a)),a}function t(a,s,l,g){var o,c;if(l!=g)c=l>g?1:-1;else for(o=c=0;o<l;o++)if(a[o]!=s[o]){c=a[o]>s[o]?1:-1;break}return c}function n(a,s,l,g){for(var o=0;l--;)a[l]-=o,o=a[l]<s[l]?1:0,a[l]=o*g+a[l]-s[l];for(;!a[0]&&a.length>1;a.splice(0,1));}return function(a,s,l,g,o){var c,u,f,w,y,L,A,C,R,I,k,U,Se,Ae,ke,J,ge,j=a.s==s.s?1:-1,F=a.c,v=s.c;if(!F||!F[0]||!v||!v[0])return new E(!a.s||!s.s||(F?v&&F[0]==v[0]:!v)?NaN:F&&F[0]==0||!v?j*0:j/0);for(C=new E(j),R=C.c=[],u=a.e-s.e,j=l+u+1,o||(o=Y,u=W(a.e/b)-W(s.e/b),j=j/b|0),f=0;v[f]==(F[f]||0);f++);if(v[f]>(F[f]||0)&&u--,j<0)R.push(1),w=true;else {for(Ae=F.length,J=v.length,f=0,j+=2,y=z(o/(v[0]+1)),y>1&&(v=e(v,y,o),F=e(F,y,o),J=v.length,Ae=F.length),Se=J,I=F.slice(0,J),k=I.length;k<J;I[k++]=0);ge=v.slice(),ge=[0].concat(ge),ke=v[0],v[1]>=o/2&&ke++;do{if(y=0,c=t(v,I,J,k),c<0){if(U=I[0],J!=k&&(U=U*o+(I[1]||0)),y=z(U/ke),y>1)for(y>=o&&(y=o-1),L=e(v,y,o),A=L.length,k=I.length;t(L,I,A,k)==1;)y--,n(L,J<A?ge:v,A,o),A=L.length,c=1;else y==0&&(c=y=1),L=v.slice(),A=L.length;if(A<k&&(L=[0].concat(L)),n(I,L,k,o),k=I.length,c==-1)for(;t(v,I,J,k)<1;)y++,n(I,J<k?ge:v,k,o),k=I.length;}else c===0&&(y++,I=[0]);R[f++]=y,I[0]?I[k++]=F[Se]||0:(I=[F[Se]],k=1);}while((Se++<Ae||I[0]!=null)&&j--);w=I[0]!=null,R[0]||R.splice(0,1);}if(o==Y){for(f=1,j=R[0];j>=10;j/=10,f++);G(C,l+(C.e=f+u*b-1)+1,g,w);}else C.e=u,C.r=+w;return C}})();function be(e,t,n,a){var s,l,g,o,c;if(n==null?n=x:B(n,0,8),!e.c)return e.toString();if(s=e.c[0],g=e.e,t==null)c=X(e.c),c=a==1||a==2&&(g<=O||g>=m)?ye(c,g):ne(c,g,"0");else if(e=G(new E(e),t,n),l=e.e,c=X(e.c),o=c.length,a==1||a==2&&(t<=l||l<=O)){for(;o<t;c+="0",o++);c=ye(c,l);}else if(t-=g+(a===2&&l>g),c=ne(c,l,"0"),l+1>o){if(--t>0)for(c+=".";t--;c+="0");}else if(t+=l-o,t>0)for(l+1==o&&(c+=".");t--;c+="0");return e.s<0&&s?"-"+c:c}function ze(e,t){for(var n,a,s=1,l=new E(e[0]);s<e.length;s++)a=new E(e[s]),(!a.s||(n=ue(l,a))===t||n===0&&l.s===t)&&(l=a);return l}function Ie(e,t,n){for(var a=1,s=t.length;!t[--s];t.pop());for(s=t[0];s>=10;s/=10,a++);return (n=a+n*b-1)>D?e.c=e.e=null:n<N?e.c=[e.e=0]:(e.e=n,e.c=t),e}S=(function(){var e=/^(-?)0([xbo])(?=\w[\w.]*$)/i,t=/^([^.]+)\.$/,n=/^\.([^.]+)$/,a=/^-?(Infinity|NaN)$/,s=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(l,g,o,c){var u,f=o?g:g.replace(s,"");if(a.test(f))l.s=isNaN(f)?null:f<0?-1:1;else {if(!o&&(f=f.replace(e,function(w,y,L){return u=(L=L.toLowerCase())=="x"?16:L=="b"?2:8,!c||c==u?y:w}),c&&(u=c,f=f.replace(t,"$1").replace(n,"0.$1")),g!=f))return new E(f,u);if(E.DEBUG)throw Error(M+"Not a"+(c?" base "+c:"")+" number: "+g);l.s=null;}l.c=l.e=null;}})();function G(e,t,n,a){var s,l,g,o,c,u,f,w=e.c,y=Me;if(w){e:{for(s=1,o=w[0];o>=10;o/=10,s++);if(l=t-s,l<0)l+=b,g=t,c=w[u=0],f=z(c/y[s-g-1]%10);else if(u=Fe((l+1)/b),u>=w.length)if(a){for(;w.length<=u;w.push(0));c=f=0,s=1,l%=b,g=l-b+1;}else break e;else {for(c=o=w[u],s=1;o>=10;o/=10,s++);l%=b,g=l-b+s,f=g<0?0:z(c/y[s-g-1]%10);}if(a=a||t<0||w[u+1]!=null||(g<0?c:c%y[s-g-1]),a=n<4?(f||a)&&(n==0||n==(e.s<0?3:2)):f>5||f==5&&(n==4||a||n==6&&(l>0?g>0?c/y[s-g]:0:w[u-1])%10&1||n==(e.s<0?8:7)),t<1||!w[0])return w.length=0,a?(t-=e.e+1,w[0]=y[(b-t%b)%b],e.e=-t||0):w[0]=e.e=0,e;if(l==0?(w.length=u,o=1,u--):(w.length=u+1,o=y[b-l],w[u]=g>0?z(c/y[s-g]%y[g])*o:0),a)for(;;)if(u==0){for(l=1,g=w[0];g>=10;g/=10,l++);for(g=w[0]+=o,o=1;g>=10;g/=10,o++);l!=o&&(e.e++,w[0]==Y&&(w[0]=1));break}else {if(w[u]+=o,w[u]!=Y)break;w[u--]=0,o=1;}for(l=w.length;w[--l]===0;w.pop());}e.e>D?e.c=e.e=null:e.e<N&&(e.c=[e.e=0]);}return e}function te(e){var t,n=e.e;return n===null?e.toString():(t=X(e.c),t=n<=O||n>=m?ye(t,n):ne(t,n,"0"),e.s<0?"-"+t:t)}return d.absoluteValue=d.abs=function(){var e=new E(this);return e.s<0&&(e.s=1),e},d.comparedTo=function(e,t){return ue(this,new E(e,t))},d.decimalPlaces=d.dp=function(e,t){var n,a,s,l=this;if(e!=null)return B(e,0,P),t==null?t=x:B(t,0,8),G(new E(l),e+l.e+1,t);if(!(n=l.c))return null;if(a=((s=n.length-1)-W(this.e/b))*b,s=n[s])for(;s%10==0;s/=10,a--);return a<0&&(a=0),a},d.dividedBy=d.div=function(e,t){return r(this,new E(e,t),p,x)},d.dividedToIntegerBy=d.idiv=function(e,t){return r(this,new E(e,t),0,1)},d.exponentiatedBy=d.pow=function(e,t){var n,a,s,l,g,o,c,u,f,w=this;if(e=new E(e),e.c&&!e.isInteger())throw Error(M+"Exponent not an integer: "+te(e));if(t!=null&&(t=new E(t)),o=e.e>14,!w.c||!w.c[0]||w.c[0]==1&&!w.e&&w.c.length==1||!e.c||!e.c[0])return f=new E(Math.pow(+te(w),o?e.s*(2-_e(e)):+te(e))),t?f.mod(t):f;if(c=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new E(NaN);a=!c&&w.isInteger()&&t.isInteger(),a&&(w=w.mod(t));}else {if(e.e>9&&(w.e>0||w.e<-1||(w.e==0?w.c[0]>1||o&&w.c[1]>=24e7:w.c[0]<8e13||o&&w.c[0]<=9999975e7)))return l=w.s<0&&_e(e)?-0:0,w.e>-1&&(l=1/l),new E(c?1/l:l);oe&&(l=Fe(oe/b+2));}for(o?(n=new E(.5),c&&(e.s=1),u=_e(e)):(s=Math.abs(+te(e)),u=s%2),f=new E(_);;){if(u){if(f=f.times(w),!f.c)break;l?f.c.length>l&&(f.c.length=l):a&&(f=f.mod(t));}if(s){if(s=z(s/2),s===0)break;u=s%2;}else if(e=e.times(n),G(e,e.e+1,1),e.e>14)u=_e(e);else {if(s=+te(e),s===0)break;u=s%2;}w=w.times(w),l?w.c&&w.c.length>l&&(w.c.length=l):a&&(w=w.mod(t));}return a?f:(c&&(f=_.div(f)),t?f.mod(t):l?G(f,oe,x,g):f)},d.integerValue=function(e){var t=new E(this);return e==null?e=x:B(e,0,8),G(t,t.e+1,e)},d.isEqualTo=d.eq=function(e,t){return ue(this,new E(e,t))===0},d.isFinite=function(){return !!this.c},d.isGreaterThan=d.gt=function(e,t){return ue(this,new E(e,t))>0},d.isGreaterThanOrEqualTo=d.gte=function(e,t){return (t=ue(this,new E(e,t)))===1||t===0},d.isInteger=function(){return !!this.c&&W(this.e/b)>this.c.length-2},d.isLessThan=d.lt=function(e,t){return ue(this,new E(e,t))<0},d.isLessThanOrEqualTo=d.lte=function(e,t){return (t=ue(this,new E(e,t)))===-1||t===0},d.isNaN=function(){return !this.s},d.isNegative=function(){return this.s<0},d.isPositive=function(){return this.s>0},d.isZero=function(){return !!this.c&&this.c[0]==0},d.minus=function(e,t){var n,a,s,l,g=this,o=g.s;if(e=new E(e,t),t=e.s,!o||!t)return new E(NaN);if(o!=t)return e.s=-t,g.plus(e);var c=g.e/b,u=e.e/b,f=g.c,w=e.c;if(!c||!u){if(!f||!w)return f?(e.s=-t,e):new E(w?g:NaN);if(!f[0]||!w[0])return w[0]?(e.s=-t,e):new E(f[0]?g:x==3?-0:0)}if(c=W(c),u=W(u),f=f.slice(),o=c-u){for((l=o<0)?(o=-o,s=f):(u=c,s=w),s.reverse(),t=o;t--;s.push(0));s.reverse();}else for(a=(l=(o=f.length)<(t=w.length))?o:t,o=t=0;t<a;t++)if(f[t]!=w[t]){l=f[t]<w[t];break}if(l&&(s=f,f=w,w=s,e.s=-e.s),t=(a=w.length)-(n=f.length),t>0)for(;t--;f[n++]=0);for(t=Y-1;a>o;){if(f[--a]<w[a]){for(n=a;n&&!f[--n];f[n]=t);--f[n],f[a]+=Y;}f[a]-=w[a];}for(;f[0]==0;f.splice(0,1),--u);return f[0]?Ie(e,f,u):(e.s=x==3?-1:1,e.c=[e.e=0],e)},d.modulo=d.mod=function(e,t){var n,a,s=this;return e=new E(e,t),!s.c||!e.s||e.c&&!e.c[0]?new E(NaN):!e.c||s.c&&!s.c[0]?new E(s):(Z==9?(a=e.s,e.s=1,n=r(s,e,0,3),e.s=a,n.s*=a):n=r(s,e,0,Z),e=s.minus(n.times(e)),!e.c[0]&&Z==1&&(e.s=s.s),e)},d.multipliedBy=d.times=function(e,t){var n,a,s,l,g,o,c,u,f,w,y,L,A,C,R,I=this,k=I.c,U=(e=new E(e,t)).c;if(!k||!U||!k[0]||!U[0])return !I.s||!e.s||k&&!k[0]&&!U||U&&!U[0]&&!k?e.c=e.e=e.s=null:(e.s*=I.s,!k||!U?e.c=e.e=null:(e.c=[0],e.e=0)),e;for(a=W(I.e/b)+W(e.e/b),e.s*=I.s,c=k.length,w=U.length,c<w&&(A=k,k=U,U=A,s=c,c=w,w=s),s=c+w,A=[];s--;A.push(0));for(C=Y,R=se,s=w;--s>=0;){for(n=0,y=U[s]%R,L=U[s]/R|0,g=c,l=s+g;l>s;)u=k[--g]%R,f=k[g]/R|0,o=L*u+f*y,u=y*u+o%R*R+A[l]+n,n=(u/C|0)+(o/R|0)+L*f,A[l--]=u%C;A[l]=n;}return n?++a:A.splice(0,1),Ie(e,A,a)},d.negated=function(){var e=new E(this);return e.s=-e.s||null,e},d.plus=function(e,t){var n,a=this,s=a.s;if(e=new E(e,t),t=e.s,!s||!t)return new E(NaN);if(s!=t)return e.s=-t,a.minus(e);var l=a.e/b,g=e.e/b,o=a.c,c=e.c;if(!l||!g){if(!o||!c)return new E(s/0);if(!o[0]||!c[0])return c[0]?e:new E(o[0]?a:s*0)}if(l=W(l),g=W(g),o=o.slice(),s=l-g){for(s>0?(g=l,n=c):(s=-s,n=o),n.reverse();s--;n.push(0));n.reverse();}for(s=o.length,t=c.length,s-t<0&&(n=c,c=o,o=n,t=s),s=0;t;)s=(o[--t]=o[t]+c[t]+s)/Y|0,o[t]=Y===o[t]?0:o[t]%Y;return s&&(o=[s].concat(o),++g),Ie(e,o,g)},d.precision=d.sd=function(e,t){var n,a,s,l=this;if(e!=null&&e!==!!e)return B(e,1,P),t==null?t=x:B(t,0,8),G(new E(l),e,t);if(!(n=l.c))return null;if(s=n.length-1,a=s*b+1,s=n[s]){for(;s%10==0;s/=10,a--);for(s=n[0];s>=10;s/=10,a++);}return e&&l.e+1>a&&(a=l.e+1),a},d.shiftedBy=function(e){return B(e,-He,He),this.times("1e"+e)},d.squareRoot=d.sqrt=function(){var e,t,n,a,s,l=this,g=l.c,o=l.s,c=l.e,u=p+4,f=new E("0.5");if(o!==1||!g||!g[0])return new E(!o||o<0&&(!g||g[0])?NaN:g?l:1/0);if(o=Math.sqrt(+te(l)),o==0||o==1/0?(t=X(g),(t.length+c)%2==0&&(t+="0"),o=Math.sqrt(+t),c=W((c+1)/2)-(c<0||c%2),o==1/0?t="5e"+c:(t=o.toExponential(),t=t.slice(0,t.indexOf("e")+1)+c),n=new E(t)):n=new E(o+""),n.c[0]){for(c=n.e,o=c+u,o<3&&(o=0);;)if(s=n,n=f.times(s.plus(r(l,s,u,1))),X(s.c).slice(0,o)===(t=X(n.c)).slice(0,o))if(n.e<c&&--o,t=t.slice(o-3,o+1),t=="9999"||!a&&t=="4999"){if(!a&&(G(s,s.e+p+2,0),s.times(s).eq(l))){n=s;break}u+=4,o+=4,a=1;}else {(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(G(n,n.e+p+2,1),e=!n.times(n).eq(l));break}}return G(n,n.e+p+1,x,e)},d.toExponential=function(e,t){return e!=null&&(B(e,0,P),e++),be(this,e,t,1)},d.toFixed=function(e,t){return e!=null&&(B(e,0,P),e=e+this.e+1),be(this,e,t)},d.toFormat=function(e,t,n){var a,s=this;if(n==null)e!=null&&t&&typeof t=="object"?(n=t,t=null):e&&typeof e=="object"?(n=e,e=t=null):n=me;else if(typeof n!="object")throw Error(M+"Argument not an object: "+n);if(a=s.toFixed(e,t),s.c){var l,g=a.split("."),o=+n.groupSize,c=+n.secondaryGroupSize,u=n.groupSeparator||"",f=g[0],w=g[1],y=s.s<0,L=y?f.slice(1):f,A=L.length;if(c&&(l=o,o=c,c=l,A-=l),o>0&&A>0){for(l=A%o||o,f=L.substr(0,l);l<A;l+=o)f+=u+L.substr(l,o);c>0&&(f+=u+L.slice(l)),y&&(f="-"+f);}a=w?f+(n.decimalSeparator||"")+((c=+n.fractionGroupSize)?w.replace(new RegExp("\\d{"+c+"}\\B","g"),"$&"+(n.fractionGroupSeparator||"")):w):f;}return (n.prefix||"")+a+(n.suffix||"")},d.toFraction=function(e){var t,n,a,s,l,g,o,c,u,f,w,y,L=this,A=L.c;if(e!=null&&(o=new E(e),!o.isInteger()&&(o.c||o.s!==1)||o.lt(_)))throw Error(M+"Argument "+(o.isInteger()?"out of range: ":"not an integer: ")+te(o));if(!A)return new E(L);for(t=new E(_),u=n=new E(_),a=c=new E(_),y=X(A),l=t.e=y.length-L.e-1,t.c[0]=Me[(g=l%b)<0?b+g:g],e=!e||o.comparedTo(t)>0?l>0?t:u:o,g=D,D=1/0,o=new E(y),c.c[0]=0;f=r(o,t,0,1),s=n.plus(f.times(a)),s.comparedTo(e)!=1;)n=a,a=s,u=c.plus(f.times(s=u)),c=s,t=o.minus(f.times(s=t)),o=s;return s=r(e.minus(n),a,0,1),c=c.plus(s.times(u)),n=n.plus(s.times(a)),c.s=u.s=L.s,l=l*2,w=r(u,a,l,x).minus(L).abs().comparedTo(r(c,n,l,x).minus(L).abs())<1?[u,a]:[c,n],D=g,w},d.toNumber=function(){return +te(this)},d.toPrecision=function(e,t){return e!=null&&B(e,1,P),be(this,e,t,2)},d.toString=function(e){var t,n=this,a=n.s,s=n.e;return s===null?a?(t="Infinity",a<0&&(t="-"+t)):t="NaN":(e==null?t=s<=O||s>=m?ye(X(n.c),s):ne(X(n.c),s,"0"):e===10&&Oe?(n=G(new E(n),p+s+1,x),t=ne(X(n.c),n.e,"0")):(B(e,2,fe.length,"Base"),t=h(ne(X(n.c),s,"0"),10,e,a,true)),a<0&&n.c[0]&&(t="-"+t)),t},d.valueOf=d.toJSON=function(){return te(this)},d._isBigNumber=true,d[Symbol.toStringTag]="BigNumber",d[Symbol.for("nodejs.util.inspect.custom")]=d.valueOf,i!=null&&E.set(i),E}function W(i){var r=i|0;return i>0||i===r?r:r-1}function X(i){for(var r,h,S=1,d=i.length,_=i[0]+"";S<d;){for(r=i[S++]+"",h=b-r.length;h--;r="0"+r);_+=r;}for(d=_.length;_.charCodeAt(--d)===48;);return _.slice(0,d+1||1)}function ue(i,r){var h,S,d=i.c,_=r.c,p=i.s,x=r.s,O=i.e,m=r.e;if(!p||!x)return null;if(h=d&&!d[0],S=_&&!_[0],h||S)return h?S?0:-x:p;if(p!=x)return p;if(h=p<0,S=O==m,!d||!_)return S?0:!d^h?1:-1;if(!S)return O>m^h?1:-1;for(x=(O=d.length)<(m=_.length)?O:m,p=0;p<x;p++)if(d[p]!=_[p])return d[p]>_[p]^h?1:-1;return O==m?0:O>m^h?1:-1}function B(i,r,h,S){if(i<r||i>h||i!==z(i))throw Error(M+(S||"Argument")+(typeof i=="number"?i<r||i>h?" out of range: ":" not an integer: ":" not a primitive number: ")+String(i))}function _e(i){var r=i.c.length-1;return W(i.e/b)==r&&i.c[r]%2!=0}function ye(i,r){return (i.length>1?i.charAt(0)+"."+i.slice(1):i)+(r<0?"e":"e+")+r}function ne(i,r,h){var S,d;if(r<0){for(d=h+".";++r;d+=h);i=d+i;}else if(S=i.length,++r>S){for(d=h,r-=S;--r;d+=h);i+=d;}else r<S&&(i=i.slice(0,r)+"."+i.slice(r));return i}var Ut=ht(),gt=Ut;var Ft=24,we=32,Ht=()=>typeof globalThis!="undefined"&&globalThis.crypto&&typeof globalThis.crypto.getRandomValues=="function"?()=>{let i=new Uint32Array(1);return globalThis.crypto.getRandomValues(i),i[0]/4294967296}:Math.random,$e=Ht(),Ve=(i=4,r=$e)=>{let h="";for(;h.length<i;)h=h+Math.floor(r()*36).toString(36);return h};function Mt(i){let r=new gt(0);for(let h of i.values())r=r.multipliedBy(256).plus(h);return r}var dt=(i="")=>{let r=new TextEncoder;return Mt(at(r.encode(i))).toString(36).slice(1)},pt=Array.from({length:26},(i,r)=>String.fromCharCode(r+97)),Vt=i=>pt[Math.floor(i()*pt.length)],$t=({globalObj:i=typeof global!="undefined"?global:typeof window!="undefined"?window:{},random:r=$e}={})=>{let h=Object.keys(i).toString(),S=h.length?h+Ve(we,r):Ve(we,r);return dt(S).substring(0,we)},Gt=i=>()=>i++,jt=476782367,wt=({random:i=$e,counter:r=Gt(Math.floor(i()*jt)),length:h=Ft,fingerprint:S=$t({random:i})}={})=>{if(h>we)throw new Error(`Length must be between 2 and ${we}. Received: ${h}`);return function(){let _=Vt(i),p=Date.now().toString(36),x=r().toString(36),O=Ve(h,i),m=`${p+O+x+S}`;return `${_+dt(m).substring(1,h)}`}},Ge=qt(wt);function qt(i){let r;return ()=>(r||(r=i()),r())}function ce(i,r,h){if(process.env.NODE_ENV!=="production"&&Xe(i))throw new Error(`Constructor ${i} is already decorated. if you are using 'withSigilTyped()' & '@WithSigil()' at the same time remove one of them.`);Object.defineProperty(i,Q,{value:r,configurable:true,enumerable:false,writable:false}),h!=null&&h.isInheritanceCheck||Object.defineProperty(i,pe,{value:r,configurable:true,enumerable:false,writable:false});let S=Object.getPrototypeOf(i),d=S&&S[H]?S[H]:[],_=h!=null&&h.isMixin&&r!=="Sigil"?["Sigil",...d,r]:[...d,r];Object.defineProperty(i,H,{value:_,configurable:true,enumerable:false,writable:false}),Object.defineProperty(i,ie,{value:new Set(_),configurable:true,enumerable:false,writable:false}),h!=null&&h.isInheritanceCheck||Xt(i);}function $(i,r){var _,p;if(re(i)||((_=r==null?void 0:r.skipLabelInheritanceCheck)!=null?_:ae.skipLabelInheritanceCheck))return;let h=[i],S=Object.getPrototypeOf(i);for(;ee(S);)h.push(S),S=Object.getPrototypeOf(S);let d=new Map;for(let x=h.length-1;x>=0;x--){let O=h[x];if(!O)continue;let m=O[Q];if(d.has(m)){if(process.env.NODE_ENV!=="production"&&(Xe(O)||!((p=r==null?void 0:r.autofillLabels)!=null?p:ae.autofillLabels)))throw new Error(`[Sigil Error] Class "${O.name}" re-uses Sigil label "${m}" from ancestor "${d.get(m)}". Each Sigil subclass must use a unique label. Did you forget to use "WithSigil(newLabel)" on the subclass?`);m=le(),ce(O,m,{isInheritanceCheck:true});}d.set(m,O.name);}zt(i);}function he(i,r){var S;let h=(S=r==null?void 0:r.labelValidation)!=null?S:ae.labelValidation;if(h){let d;if(h instanceof RegExp?d=h.test(i):d=h(i),process.env.NODE_ENV!=="production"&&!d)throw new Error(`[Sigil] Invalid identity label "${i}". Make sure that supplied label matches validation regex or function.`)}}function le(){return `@Sigil.auto-${Ge()}`}function je(i){Object.defineProperty(i,Ne,{value:true,configurable:false,enumerable:false,writable:false});}function qe(i){Object.defineProperty(i,Te,{value:true,configurable:false,enumerable:false,writable:false});}function Xt(i){Object.defineProperty(i,Be,{value:true,configurable:false,enumerable:false,writable:false});}function zt(i){Object.defineProperty(i,Ce,{value:true,configurable:false,enumerable:false,writable:false});}function ee(i){return typeof i=="function"&&i[Ne]===true}function K(i){if(!i||typeof i!="object")return false;let r=T(i);return ee(r)}function St(i){return Object.hasOwn(i,Te)}function Wt(i){if(!i||typeof i!="object")return false;let r=T(i);return St(r)}function Xe(i){return Object.hasOwn(i,Be)}function re(i){return Object.hasOwn(i,Ce)}function T(i){var r,h,S;return !i||typeof i!="object"?null:(S=(h=i.constructor)!=null?h:(r=Object.getPrototypeOf(i))==null?void 0:r.constructor)!=null?S:null}function Le(i,r,h){if(ee(i))throw new Error(`[Sigil Error] 'Sigilify(${r})' already sigilified.`);let S;r?(he(r,h),S=r):S=le();class d extends i{static get SigilLabel(){return re(this)||$(this),this[Q]}static get SigilEffectiveLabel(){return this[pe]}static get SigilLabelLineage(){var p;return re(this)||$(this),[...(p=this[H])!=null?p:[]]}static get SigilLabelSet(){re(this)||$(this);let p=new Set;for(let x of this[ie])p.add(x);return p}constructor(...p){super(...p),Object.getPrototypeOf(this)!==new.target.prototype&&Object.setPrototypeOf(this,new.target.prototype);let x=T(this);if(!x){if(process.env.NODE_ENV!=="production")throw new Error(`[Sigil Error] 'Sigilify(${r})' instance without constructor`);return}$(x);}static isSigilified(p){return K(p)}static isOfType(p){var m;if(!K(p))return false;let x=(m=T(p))==null?void 0:m[ie],O=this[Q];return !!x&&x.has(O)}static isOfTypeStrict(p){var m;if(!K(p))return false;let x=(m=T(p))==null?void 0:m[H],O=this[H];return !!x&&O.every((N,D)=>N===x[D])}isOfType(p){var m;if(!K(p))return false;let x=(m=T(p))==null?void 0:m[ie],O=T(this)[Q];return !!x&&x.has(O)}isOfTypeStrict(p){var m,N;if(!K(p))return false;let x=(m=T(p))==null?void 0:m[H],O=(N=T(this))==null?void 0:N[H];return !!x&&O.every((D,V)=>D===x[V])}getSigilLabel(){let p=T(this);if(!p){if(process.env.NODE_ENV!=="production")throw new Error("[Sigil Error] Sigil class instance without constructor");return "@Sigil.unknown"}return p.SigilLabel}getSigilEffectiveLabel(){let p=T(this);if(!p){if(process.env.NODE_ENV!=="production")throw new Error("[Sigil Error] Sigil class instance without constructor");return "@Sigil.unknown"}return p.SigilEffectiveLabel}getSigilLabelLineage(){let p=T(this);if(!p){if(process.env.NODE_ENV!=="production")throw new Error("[Sigil Error] Sigil class instance without constructor");return ["@Sigil.unknown"]}return p.SigilLabelLineage}getSigilLabelSet(){let p=T(this);if(!p){if(process.env.NODE_ENV!=="production")throw new Error("[Sigil Error] Sigil class instance without constructor");return new Set(["@Sigil.unknown"])}return p.SigilLabelSet}}return ce(d,S,{isMixin:true}),je(d),qe(d),d}function Kt(i,r,h){if(ee(i))throw new Error(`[Sigil Error] 'Sigilify(${r})' already sigilified.`);let S;r?(he(r,h),S=r):S=le();class d extends i{static get SigilLabel(){return re(this)||$(this),this[Q]}static get SigilEffectiveLabel(){return this[pe]}static get SigilLabelLineage(){var p;return re(this)||$(this),[...(p=this[H])!=null?p:[]]}static get SigilLabelSet(){re(this)||$(this);let p=new Set;for(let x of this[ie])p.add(x);return p}constructor(...p){super(...p),Object.getPrototypeOf(this)!==new.target.prototype&&Object.setPrototypeOf(this,new.target.prototype);let x=T(this);if(!x){if(process.env.NODE_ENV!=="production")throw new Error(`[Sigil Error] 'Sigilify(${r})' instance without constructor`);return}$(x);}static isSigilified(p){return K(p)}static isOfType(p){var m;if(!K(p))return false;let x=(m=T(p))==null?void 0:m[ie],O=this[Q];return !!x&&x.has(O)}static isOfTypeStrict(p){var m;if(!K(p))return false;let x=(m=T(p))==null?void 0:m[H],O=this[H];return !!x&&O.every((N,D)=>N===x[D])}isOfType(p){var m;if(!K(p))return false;let x=(m=T(p))==null?void 0:m[ie],O=T(this)[Q];return !!x&&x.has(O)}isOfTypeStrict(p){var m,N;if(!K(p))return false;let x=(m=T(p))==null?void 0:m[H],O=(N=T(this))==null?void 0:N[H];return !!x&&O.every((D,V)=>D===x[V])}getSigilLabel(){let p=T(this);if(!p){if(process.env.NODE_ENV!=="production")throw new Error("[Sigil Error] Sigil class instance without constructor");return "@Sigil.unknown"}return p.SigilLabel}getSigilEffectiveLabel(){let p=T(this);if(!p){if(process.env.NODE_ENV!=="production")throw new Error("[Sigil Error] Sigil class instance without constructor");return "@Sigil.unknown"}return p.SigilEffectiveLabel}getSigilLabelLineage(){let p=T(this);if(!p){if(process.env.NODE_ENV!=="production")throw new Error("[Sigil Error] Sigil class instance without constructor");return ["@Sigil.unknown"]}return p.SigilLabelLineage}getSigilLabelSet(){let p=T(this);if(!p){if(process.env.NODE_ENV!=="production")throw new Error("[Sigil Error] Sigil class instance without constructor");return new Set(["@Sigil.unknown"])}return p.SigilLabelSet}}return ce(d,S,{isMixin:true}),je(d),qe(d),d}var Yt=Le(class{},"Sigil"),Zt=Le(Error,"SigilError");function Jt(i,r){let h;return i?(he(i,r),h=i):h=le(),function(S,d){if(d.kind==="class"){if(!ee(S))throw new Error(`[Sigil Error] 'WithSigil' decorator accept only Sigil classes but used on class ${S.name}`);ce(S,h),$(S,r);}}}function Qt(i,r,h){var _;if(!ee(i))throw new Error(`[Sigil Error] 'withSigil' HOF accept only Sigil classes but used on class ${(_=i==null?void 0:i.name)!=null?_:"unknown"}`);let S;r?(he(r,h),S=r):S=le();let d=i;return ce(d,S),$(d,h),i}/*! Bundled license information:
3
2
 
4
- var __defProp = Object.defineProperty;
5
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
-
8
- // src/core/options.ts
9
- var OPTIONS = {
10
- labelValidation: null,
11
- skipLabelInheritanceCheck: false,
12
- autofillLabels: true
13
- };
14
- var updateSigilOptions = (opts) => {
15
- if ("autofillLabels" in opts) {
16
- if (typeof opts.autofillLabels !== "boolean")
17
- throw new Error("'updateSigilOptions.autofillLabels' must be boolean");
18
- OPTIONS.autofillLabels = opts.autofillLabels;
19
- }
20
- if ("skipLabelInheritanceCheck" in opts) {
21
- if (typeof opts.skipLabelInheritanceCheck !== "boolean")
22
- throw new Error("'updateSigilOptions.skipLabelInheritanceCheck' must be boolean");
23
- OPTIONS.skipLabelInheritanceCheck = opts.skipLabelInheritanceCheck;
24
- }
25
- if ("labelValidation" in opts) {
26
- const val = opts.labelValidation;
27
- if (val !== null && typeof val !== "function" && !(val instanceof RegExp))
28
- throw new Error("'updateSigilOptions.labelValidation' must be null, function or RegExp");
29
- OPTIONS.labelValidation = val != null ? val : null;
30
- }
31
- };
32
- var DEFAULT_LABEL_REGEX = /^@[\w-]+(?:\/[\w-]+)*\.[A-Z][A-Za-z0-9]*$/;
33
-
34
- // src/core/symbols.ts
35
- var __SIGIL__ = /* @__PURE__ */ Symbol.for("@Sigil.__SIGIL__");
36
- var __SIGIL_BASE__ = /* @__PURE__ */ Symbol.for("@Sigil.__SIGIL_BASE__");
37
- var __DECORATED__ = /* @__PURE__ */ Symbol.for("@Sigil.__DECORATED__");
38
- var __INHERITANCE_CHECKED__ = /* @__PURE__ */ Symbol.for("@Sigil.__INHERITANCE_CHECKED__");
39
- var __LABEL__ = /* @__PURE__ */ Symbol.for("@Sigil.__LABEL__");
40
- var __EFFECTIVE_LABEL__ = /* @__PURE__ */ Symbol.for("@Sigil.__EFFECTIVE_LABEL__");
41
- var __LABEL_LINEAGE__ = /* @__PURE__ */ Symbol.for("@Sigil.__LABEL_LINEAGE__");
42
- var __LABEL_SET__ = /* @__PURE__ */ Symbol.for("@Sigil.__LABEL_SET__");
43
-
44
- // node_modules/@noble/hashes/_u64.js
45
- var U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
46
- var _32n = /* @__PURE__ */ BigInt(32);
47
- function fromBig(n, le = false) {
48
- if (le)
49
- return { h: Number(n & U32_MASK64), l: Number(n >> _32n & U32_MASK64) };
50
- return { h: Number(n >> _32n & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };
51
- }
52
- function split(lst, le = false) {
53
- const len = lst.length;
54
- let Ah = new Uint32Array(len);
55
- let Al = new Uint32Array(len);
56
- for (let i = 0; i < len; i++) {
57
- const { h, l } = fromBig(lst[i], le);
58
- [Ah[i], Al[i]] = [h, l];
59
- }
60
- return [Ah, Al];
61
- }
62
- var rotlSH = (h, l, s) => h << s | l >>> 32 - s;
63
- var rotlSL = (h, l, s) => l << s | h >>> 32 - s;
64
- var rotlBH = (h, l, s) => l << s - 32 | h >>> 64 - s;
65
- var rotlBL = (h, l, s) => h << s - 32 | l >>> 64 - s;
66
-
67
- // node_modules/@noble/hashes/utils.js
68
- function isBytes(a) {
69
- return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
70
- }
71
- function anumber(n, title = "") {
72
- if (!Number.isSafeInteger(n) || n < 0) {
73
- const prefix = title && `"${title}" `;
74
- throw new Error(`${prefix}expected integer >= 0, got ${n}`);
75
- }
76
- }
77
- function abytes(value, length, title = "") {
78
- const bytes = isBytes(value);
79
- const len = value == null ? void 0 : value.length;
80
- const needsLen = length !== void 0;
81
- if (!bytes || needsLen) {
82
- const prefix = title && `"${title}" `;
83
- const ofLen = "";
84
- const got = bytes ? `length=${len}` : `type=${typeof value}`;
85
- throw new Error(prefix + "expected Uint8Array" + ofLen + ", got " + got);
86
- }
87
- return value;
88
- }
89
- function aexists(instance, checkFinished = true) {
90
- if (instance.destroyed)
91
- throw new Error("Hash instance has been destroyed");
92
- if (checkFinished && instance.finished)
93
- throw new Error("Hash#digest() has already been called");
94
- }
95
- function aoutput(out, instance) {
96
- abytes(out, void 0, "digestInto() output");
97
- const min = instance.outputLen;
98
- if (out.length < min) {
99
- throw new Error('"digestInto() output" expected to be of length >=' + min);
100
- }
101
- }
102
- function u32(arr) {
103
- return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
104
- }
105
- function clean(...arrays) {
106
- for (let i = 0; i < arrays.length; i++) {
107
- arrays[i].fill(0);
108
- }
109
- }
110
- var isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68)();
111
- function byteSwap(word) {
112
- return word << 24 & 4278190080 | word << 8 & 16711680 | word >>> 8 & 65280 | word >>> 24 & 255;
113
- }
114
- function byteSwap32(arr) {
115
- for (let i = 0; i < arr.length; i++) {
116
- arr[i] = byteSwap(arr[i]);
117
- }
118
- return arr;
119
- }
120
- var swap32IfBE = isLE ? (u) => u : byteSwap32;
121
- function createHasher(hashCons, info = {}) {
122
- const hashC = (msg, opts) => hashCons(opts).update(msg).digest();
123
- const tmp = hashCons(void 0);
124
- hashC.outputLen = tmp.outputLen;
125
- hashC.blockLen = tmp.blockLen;
126
- hashC.create = (opts) => hashCons(opts);
127
- Object.assign(hashC, info);
128
- return Object.freeze(hashC);
129
- }
130
- var oidNist = (suffix) => ({
131
- oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, suffix])
132
- });
133
-
134
- // node_modules/@noble/hashes/sha3.js
135
- var _0n = BigInt(0);
136
- var _1n = BigInt(1);
137
- var _2n = BigInt(2);
138
- var _7n = BigInt(7);
139
- var _256n = BigInt(256);
140
- var _0x71n = BigInt(113);
141
- var SHA3_PI = [];
142
- var SHA3_ROTL = [];
143
- var _SHA3_IOTA = [];
144
- for (let round = 0, R = _1n, x = 1, y = 0; round < 24; round++) {
145
- [x, y] = [y, (2 * x + 3 * y) % 5];
146
- SHA3_PI.push(2 * (5 * y + x));
147
- SHA3_ROTL.push((round + 1) * (round + 2) / 2 % 64);
148
- let t = _0n;
149
- for (let j = 0; j < 7; j++) {
150
- R = (R << _1n ^ (R >> _7n) * _0x71n) % _256n;
151
- if (R & _2n)
152
- t ^= _1n << (_1n << BigInt(j)) - _1n;
153
- }
154
- _SHA3_IOTA.push(t);
155
- }
156
- var IOTAS = split(_SHA3_IOTA, true);
157
- var SHA3_IOTA_H = IOTAS[0];
158
- var SHA3_IOTA_L = IOTAS[1];
159
- var rotlH = (h, l, s) => s > 32 ? rotlBH(h, l, s) : rotlSH(h, l, s);
160
- var rotlL = (h, l, s) => s > 32 ? rotlBL(h, l, s) : rotlSL(h, l, s);
161
- function keccakP(s, rounds = 24) {
162
- const B = new Uint32Array(5 * 2);
163
- for (let round = 24 - rounds; round < 24; round++) {
164
- for (let x = 0; x < 10; x++)
165
- B[x] = s[x] ^ s[x + 10] ^ s[x + 20] ^ s[x + 30] ^ s[x + 40];
166
- for (let x = 0; x < 10; x += 2) {
167
- const idx1 = (x + 8) % 10;
168
- const idx0 = (x + 2) % 10;
169
- const B0 = B[idx0];
170
- const B1 = B[idx0 + 1];
171
- const Th = rotlH(B0, B1, 1) ^ B[idx1];
172
- const Tl = rotlL(B0, B1, 1) ^ B[idx1 + 1];
173
- for (let y = 0; y < 50; y += 10) {
174
- s[x + y] ^= Th;
175
- s[x + y + 1] ^= Tl;
176
- }
177
- }
178
- let curH = s[2];
179
- let curL = s[3];
180
- for (let t = 0; t < 24; t++) {
181
- const shift = SHA3_ROTL[t];
182
- const Th = rotlH(curH, curL, shift);
183
- const Tl = rotlL(curH, curL, shift);
184
- const PI = SHA3_PI[t];
185
- curH = s[PI];
186
- curL = s[PI + 1];
187
- s[PI] = Th;
188
- s[PI + 1] = Tl;
189
- }
190
- for (let y = 0; y < 50; y += 10) {
191
- for (let x = 0; x < 10; x++)
192
- B[x] = s[y + x];
193
- for (let x = 0; x < 10; x++)
194
- s[y + x] ^= ~B[(x + 2) % 10] & B[(x + 4) % 10];
195
- }
196
- s[0] ^= SHA3_IOTA_H[round];
197
- s[1] ^= SHA3_IOTA_L[round];
198
- }
199
- clean(B);
200
- }
201
- var Keccak = class _Keccak {
202
- // NOTE: we accept arguments in bytes instead of bits here.
203
- constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) {
204
- __publicField(this, "state");
205
- __publicField(this, "pos", 0);
206
- __publicField(this, "posOut", 0);
207
- __publicField(this, "finished", false);
208
- __publicField(this, "state32");
209
- __publicField(this, "destroyed", false);
210
- __publicField(this, "blockLen");
211
- __publicField(this, "suffix");
212
- __publicField(this, "outputLen");
213
- __publicField(this, "enableXOF", false);
214
- __publicField(this, "rounds");
215
- this.blockLen = blockLen;
216
- this.suffix = suffix;
217
- this.outputLen = outputLen;
218
- this.enableXOF = enableXOF;
219
- this.rounds = rounds;
220
- anumber(outputLen, "outputLen");
221
- if (!(0 < blockLen && blockLen < 200))
222
- throw new Error("only keccak-f1600 function is supported");
223
- this.state = new Uint8Array(200);
224
- this.state32 = u32(this.state);
225
- }
226
- clone() {
227
- return this._cloneInto();
228
- }
229
- keccak() {
230
- swap32IfBE(this.state32);
231
- keccakP(this.state32, this.rounds);
232
- swap32IfBE(this.state32);
233
- this.posOut = 0;
234
- this.pos = 0;
235
- }
236
- update(data) {
237
- aexists(this);
238
- abytes(data);
239
- const { blockLen, state } = this;
240
- const len = data.length;
241
- for (let pos = 0; pos < len; ) {
242
- const take = Math.min(blockLen - this.pos, len - pos);
243
- for (let i = 0; i < take; i++)
244
- state[this.pos++] ^= data[pos++];
245
- if (this.pos === blockLen)
246
- this.keccak();
247
- }
248
- return this;
249
- }
250
- finish() {
251
- if (this.finished)
252
- return;
253
- this.finished = true;
254
- const { state, suffix, pos, blockLen } = this;
255
- state[pos] ^= suffix;
256
- if ((suffix & 128) !== 0 && pos === blockLen - 1)
257
- this.keccak();
258
- state[blockLen - 1] ^= 128;
259
- this.keccak();
260
- }
261
- writeInto(out) {
262
- aexists(this, false);
263
- abytes(out);
264
- this.finish();
265
- const bufferOut = this.state;
266
- const { blockLen } = this;
267
- for (let pos = 0, len = out.length; pos < len; ) {
268
- if (this.posOut >= blockLen)
269
- this.keccak();
270
- const take = Math.min(blockLen - this.posOut, len - pos);
271
- out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos);
272
- this.posOut += take;
273
- pos += take;
274
- }
275
- return out;
276
- }
277
- xofInto(out) {
278
- if (!this.enableXOF)
279
- throw new Error("XOF is not possible for this instance");
280
- return this.writeInto(out);
281
- }
282
- xof(bytes) {
283
- anumber(bytes);
284
- return this.xofInto(new Uint8Array(bytes));
285
- }
286
- digestInto(out) {
287
- aoutput(out, this);
288
- if (this.finished)
289
- throw new Error("digest() was already called");
290
- this.writeInto(out);
291
- this.destroy();
292
- return out;
293
- }
294
- digest() {
295
- return this.digestInto(new Uint8Array(this.outputLen));
296
- }
297
- destroy() {
298
- this.destroyed = true;
299
- clean(this.state);
300
- }
301
- _cloneInto(to) {
302
- const { blockLen, suffix, outputLen, rounds, enableXOF } = this;
303
- to || (to = new _Keccak(blockLen, suffix, outputLen, enableXOF, rounds));
304
- to.state32.set(this.state32);
305
- to.pos = this.pos;
306
- to.posOut = this.posOut;
307
- to.finished = this.finished;
308
- to.rounds = rounds;
309
- to.suffix = suffix;
310
- to.outputLen = outputLen;
311
- to.enableXOF = enableXOF;
312
- to.destroyed = this.destroyed;
313
- return to;
314
- }
315
- };
316
- var genKeccak = (suffix, blockLen, outputLen, info = {}) => createHasher(() => new Keccak(blockLen, suffix, outputLen), info);
317
- var sha3_512 = /* @__PURE__ */ genKeccak(
318
- 6,
319
- 72,
320
- 64,
321
- /* @__PURE__ */ oidNist(10)
322
- );
323
-
324
- // node_modules/bignumber.js/bignumber.mjs
325
- var isNumeric = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i;
326
- var mathceil = Math.ceil;
327
- var mathfloor = Math.floor;
328
- var bignumberError = "[BigNumber Error] ";
329
- var tooManyDigits = bignumberError + "Number primitive has more than 15 significant digits: ";
330
- var BASE = 1e14;
331
- var LOG_BASE = 14;
332
- var MAX_SAFE_INTEGER = 9007199254740991;
333
- var POWS_TEN = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13];
334
- var SQRT_BASE = 1e7;
335
- var MAX = 1e9;
336
- function clone(configObject) {
337
- var div, convertBase, parseNumeric, P = BigNumber2.prototype = { constructor: BigNumber2, toString: null, valueOf: null }, ONE = new BigNumber2(1), DECIMAL_PLACES = 20, ROUNDING_MODE = 4, TO_EXP_NEG = -7, TO_EXP_POS = 21, MIN_EXP = -1e7, MAX_EXP = 1e7, CRYPTO = false, MODULO_MODE = 1, POW_PRECISION = 0, FORMAT = {
338
- prefix: "",
339
- groupSize: 3,
340
- secondaryGroupSize: 0,
341
- groupSeparator: ",",
342
- decimalSeparator: ".",
343
- fractionGroupSize: 0,
344
- fractionGroupSeparator: "\xA0",
345
- // non-breaking space
346
- suffix: ""
347
- }, ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyz", alphabetHasNormalDecimalDigits = true;
348
- function BigNumber2(v, b) {
349
- var alphabet2, c, caseChanged, e, i, isNum, len, str, x = this;
350
- if (!(x instanceof BigNumber2)) return new BigNumber2(v, b);
351
- if (b == null) {
352
- if (v && v._isBigNumber === true) {
353
- x.s = v.s;
354
- if (!v.c || v.e > MAX_EXP) {
355
- x.c = x.e = null;
356
- } else if (v.e < MIN_EXP) {
357
- x.c = [x.e = 0];
358
- } else {
359
- x.e = v.e;
360
- x.c = v.c.slice();
361
- }
362
- return;
363
- }
364
- if ((isNum = typeof v == "number") && v * 0 == 0) {
365
- x.s = 1 / v < 0 ? (v = -v, -1) : 1;
366
- if (v === ~~v) {
367
- for (e = 0, i = v; i >= 10; i /= 10, e++) ;
368
- if (e > MAX_EXP) {
369
- x.c = x.e = null;
370
- } else {
371
- x.e = e;
372
- x.c = [v];
373
- }
374
- return;
375
- }
376
- str = String(v);
377
- } else {
378
- if (!isNumeric.test(str = String(v))) return parseNumeric(x, str, isNum);
379
- x.s = str.charCodeAt(0) == 45 ? (str = str.slice(1), -1) : 1;
380
- }
381
- if ((e = str.indexOf(".")) > -1) str = str.replace(".", "");
382
- if ((i = str.search(/e/i)) > 0) {
383
- if (e < 0) e = i;
384
- e += +str.slice(i + 1);
385
- str = str.substring(0, i);
386
- } else if (e < 0) {
387
- e = str.length;
388
- }
389
- } else {
390
- intCheck(b, 2, ALPHABET.length, "Base");
391
- if (b == 10 && alphabetHasNormalDecimalDigits) {
392
- x = new BigNumber2(v);
393
- return round(x, DECIMAL_PLACES + x.e + 1, ROUNDING_MODE);
394
- }
395
- str = String(v);
396
- if (isNum = typeof v == "number") {
397
- if (v * 0 != 0) return parseNumeric(x, str, isNum, b);
398
- x.s = 1 / v < 0 ? (str = str.slice(1), -1) : 1;
399
- if (BigNumber2.DEBUG && str.replace(/^0\.0*|\./, "").length > 15) {
400
- throw Error(tooManyDigits + v);
401
- }
402
- } else {
403
- x.s = str.charCodeAt(0) === 45 ? (str = str.slice(1), -1) : 1;
404
- }
405
- alphabet2 = ALPHABET.slice(0, b);
406
- e = i = 0;
407
- for (len = str.length; i < len; i++) {
408
- if (alphabet2.indexOf(c = str.charAt(i)) < 0) {
409
- if (c == ".") {
410
- if (i > e) {
411
- e = len;
412
- continue;
413
- }
414
- } else if (!caseChanged) {
415
- if (str == str.toUpperCase() && (str = str.toLowerCase()) || str == str.toLowerCase() && (str = str.toUpperCase())) {
416
- caseChanged = true;
417
- i = -1;
418
- e = 0;
419
- continue;
420
- }
421
- }
422
- return parseNumeric(x, String(v), isNum, b);
423
- }
424
- }
425
- isNum = false;
426
- str = convertBase(str, b, 10, x.s);
427
- if ((e = str.indexOf(".")) > -1) str = str.replace(".", "");
428
- else e = str.length;
429
- }
430
- for (i = 0; str.charCodeAt(i) === 48; i++) ;
431
- for (len = str.length; str.charCodeAt(--len) === 48; ) ;
432
- if (str = str.slice(i, ++len)) {
433
- len -= i;
434
- if (isNum && BigNumber2.DEBUG && len > 15 && (v > MAX_SAFE_INTEGER || v !== mathfloor(v))) {
435
- throw Error(tooManyDigits + x.s * v);
436
- }
437
- if ((e = e - i - 1) > MAX_EXP) {
438
- x.c = x.e = null;
439
- } else if (e < MIN_EXP) {
440
- x.c = [x.e = 0];
441
- } else {
442
- x.e = e;
443
- x.c = [];
444
- i = (e + 1) % LOG_BASE;
445
- if (e < 0) i += LOG_BASE;
446
- if (i < len) {
447
- if (i) x.c.push(+str.slice(0, i));
448
- for (len -= LOG_BASE; i < len; ) {
449
- x.c.push(+str.slice(i, i += LOG_BASE));
450
- }
451
- i = LOG_BASE - (str = str.slice(i)).length;
452
- } else {
453
- i -= len;
454
- }
455
- for (; i--; str += "0") ;
456
- x.c.push(+str);
457
- }
458
- } else {
459
- x.c = [x.e = 0];
460
- }
461
- }
462
- BigNumber2.clone = clone;
463
- BigNumber2.ROUND_UP = 0;
464
- BigNumber2.ROUND_DOWN = 1;
465
- BigNumber2.ROUND_CEIL = 2;
466
- BigNumber2.ROUND_FLOOR = 3;
467
- BigNumber2.ROUND_HALF_UP = 4;
468
- BigNumber2.ROUND_HALF_DOWN = 5;
469
- BigNumber2.ROUND_HALF_EVEN = 6;
470
- BigNumber2.ROUND_HALF_CEIL = 7;
471
- BigNumber2.ROUND_HALF_FLOOR = 8;
472
- BigNumber2.EUCLID = 9;
473
- BigNumber2.config = BigNumber2.set = function(obj) {
474
- var p, v;
475
- if (obj != null) {
476
- if (typeof obj == "object") {
477
- if (obj.hasOwnProperty(p = "DECIMAL_PLACES")) {
478
- v = obj[p];
479
- intCheck(v, 0, MAX, p);
480
- DECIMAL_PLACES = v;
481
- }
482
- if (obj.hasOwnProperty(p = "ROUNDING_MODE")) {
483
- v = obj[p];
484
- intCheck(v, 0, 8, p);
485
- ROUNDING_MODE = v;
486
- }
487
- if (obj.hasOwnProperty(p = "EXPONENTIAL_AT")) {
488
- v = obj[p];
489
- if (v && v.pop) {
490
- intCheck(v[0], -MAX, 0, p);
491
- intCheck(v[1], 0, MAX, p);
492
- TO_EXP_NEG = v[0];
493
- TO_EXP_POS = v[1];
494
- } else {
495
- intCheck(v, -MAX, MAX, p);
496
- TO_EXP_NEG = -(TO_EXP_POS = v < 0 ? -v : v);
497
- }
498
- }
499
- if (obj.hasOwnProperty(p = "RANGE")) {
500
- v = obj[p];
501
- if (v && v.pop) {
502
- intCheck(v[0], -MAX, -1, p);
503
- intCheck(v[1], 1, MAX, p);
504
- MIN_EXP = v[0];
505
- MAX_EXP = v[1];
506
- } else {
507
- intCheck(v, -MAX, MAX, p);
508
- if (v) {
509
- MIN_EXP = -(MAX_EXP = v < 0 ? -v : v);
510
- } else {
511
- throw Error(bignumberError + p + " cannot be zero: " + v);
512
- }
513
- }
514
- }
515
- if (obj.hasOwnProperty(p = "CRYPTO")) {
516
- v = obj[p];
517
- if (v === !!v) {
518
- if (v) {
519
- if (typeof crypto != "undefined" && crypto && (crypto.getRandomValues || crypto.randomBytes)) {
520
- CRYPTO = v;
521
- } else {
522
- CRYPTO = !v;
523
- throw Error(bignumberError + "crypto unavailable");
524
- }
525
- } else {
526
- CRYPTO = v;
527
- }
528
- } else {
529
- throw Error(bignumberError + p + " not true or false: " + v);
530
- }
531
- }
532
- if (obj.hasOwnProperty(p = "MODULO_MODE")) {
533
- v = obj[p];
534
- intCheck(v, 0, 9, p);
535
- MODULO_MODE = v;
536
- }
537
- if (obj.hasOwnProperty(p = "POW_PRECISION")) {
538
- v = obj[p];
539
- intCheck(v, 0, MAX, p);
540
- POW_PRECISION = v;
541
- }
542
- if (obj.hasOwnProperty(p = "FORMAT")) {
543
- v = obj[p];
544
- if (typeof v == "object") FORMAT = v;
545
- else throw Error(bignumberError + p + " not an object: " + v);
546
- }
547
- if (obj.hasOwnProperty(p = "ALPHABET")) {
548
- v = obj[p];
549
- if (typeof v == "string" && !/^.?$|[+\-.\s]|(.).*\1/.test(v)) {
550
- alphabetHasNormalDecimalDigits = v.slice(0, 10) == "0123456789";
551
- ALPHABET = v;
552
- } else {
553
- throw Error(bignumberError + p + " invalid: " + v);
554
- }
555
- }
556
- } else {
557
- throw Error(bignumberError + "Object expected: " + obj);
558
- }
559
- }
560
- return {
561
- DECIMAL_PLACES,
562
- ROUNDING_MODE,
563
- EXPONENTIAL_AT: [TO_EXP_NEG, TO_EXP_POS],
564
- RANGE: [MIN_EXP, MAX_EXP],
565
- CRYPTO,
566
- MODULO_MODE,
567
- POW_PRECISION,
568
- FORMAT,
569
- ALPHABET
570
- };
571
- };
572
- BigNumber2.isBigNumber = function(v) {
573
- if (!v || v._isBigNumber !== true) return false;
574
- if (!BigNumber2.DEBUG) return true;
575
- var i, n, c = v.c, e = v.e, s = v.s;
576
- out: if ({}.toString.call(c) == "[object Array]") {
577
- if ((s === 1 || s === -1) && e >= -MAX && e <= MAX && e === mathfloor(e)) {
578
- if (c[0] === 0) {
579
- if (e === 0 && c.length === 1) return true;
580
- break out;
581
- }
582
- i = (e + 1) % LOG_BASE;
583
- if (i < 1) i += LOG_BASE;
584
- if (String(c[0]).length == i) {
585
- for (i = 0; i < c.length; i++) {
586
- n = c[i];
587
- if (n < 0 || n >= BASE || n !== mathfloor(n)) break out;
588
- }
589
- if (n !== 0) return true;
590
- }
591
- }
592
- } else if (c === null && e === null && (s === null || s === 1 || s === -1)) {
593
- return true;
594
- }
595
- throw Error(bignumberError + "Invalid BigNumber: " + v);
596
- };
597
- BigNumber2.maximum = BigNumber2.max = function() {
598
- return maxOrMin(arguments, -1);
599
- };
600
- BigNumber2.minimum = BigNumber2.min = function() {
601
- return maxOrMin(arguments, 1);
602
- };
603
- BigNumber2.random = (function() {
604
- var pow2_53 = 9007199254740992;
605
- var random53bitInt = Math.random() * pow2_53 & 2097151 ? function() {
606
- return mathfloor(Math.random() * pow2_53);
607
- } : function() {
608
- return (Math.random() * 1073741824 | 0) * 8388608 + (Math.random() * 8388608 | 0);
609
- };
610
- return function(dp) {
611
- var a, b, e, k, v, i = 0, c = [], rand = new BigNumber2(ONE);
612
- if (dp == null) dp = DECIMAL_PLACES;
613
- else intCheck(dp, 0, MAX);
614
- k = mathceil(dp / LOG_BASE);
615
- if (CRYPTO) {
616
- if (crypto.getRandomValues) {
617
- a = crypto.getRandomValues(new Uint32Array(k *= 2));
618
- for (; i < k; ) {
619
- v = a[i] * 131072 + (a[i + 1] >>> 11);
620
- if (v >= 9e15) {
621
- b = crypto.getRandomValues(new Uint32Array(2));
622
- a[i] = b[0];
623
- a[i + 1] = b[1];
624
- } else {
625
- c.push(v % 1e14);
626
- i += 2;
627
- }
628
- }
629
- i = k / 2;
630
- } else if (crypto.randomBytes) {
631
- a = crypto.randomBytes(k *= 7);
632
- for (; i < k; ) {
633
- v = (a[i] & 31) * 281474976710656 + a[i + 1] * 1099511627776 + a[i + 2] * 4294967296 + a[i + 3] * 16777216 + (a[i + 4] << 16) + (a[i + 5] << 8) + a[i + 6];
634
- if (v >= 9e15) {
635
- crypto.randomBytes(7).copy(a, i);
636
- } else {
637
- c.push(v % 1e14);
638
- i += 7;
639
- }
640
- }
641
- i = k / 7;
642
- } else {
643
- CRYPTO = false;
644
- throw Error(bignumberError + "crypto unavailable");
645
- }
646
- }
647
- if (!CRYPTO) {
648
- for (; i < k; ) {
649
- v = random53bitInt();
650
- if (v < 9e15) c[i++] = v % 1e14;
651
- }
652
- }
653
- k = c[--i];
654
- dp %= LOG_BASE;
655
- if (k && dp) {
656
- v = POWS_TEN[LOG_BASE - dp];
657
- c[i] = mathfloor(k / v) * v;
658
- }
659
- for (; c[i] === 0; c.pop(), i--) ;
660
- if (i < 0) {
661
- c = [e = 0];
662
- } else {
663
- for (e = -1; c[0] === 0; c.splice(0, 1), e -= LOG_BASE) ;
664
- for (i = 1, v = c[0]; v >= 10; v /= 10, i++) ;
665
- if (i < LOG_BASE) e -= LOG_BASE - i;
666
- }
667
- rand.e = e;
668
- rand.c = c;
669
- return rand;
670
- };
671
- })();
672
- BigNumber2.sum = function() {
673
- var i = 1, args = arguments, sum = new BigNumber2(args[0]);
674
- for (; i < args.length; ) sum = sum.plus(args[i++]);
675
- return sum;
676
- };
677
- convertBase = /* @__PURE__ */ (function() {
678
- var decimal = "0123456789";
679
- function toBaseOut(str, baseIn, baseOut, alphabet2) {
680
- var j, arr = [0], arrL, i = 0, len = str.length;
681
- for (; i < len; ) {
682
- for (arrL = arr.length; arrL--; arr[arrL] *= baseIn) ;
683
- arr[0] += alphabet2.indexOf(str.charAt(i++));
684
- for (j = 0; j < arr.length; j++) {
685
- if (arr[j] > baseOut - 1) {
686
- if (arr[j + 1] == null) arr[j + 1] = 0;
687
- arr[j + 1] += arr[j] / baseOut | 0;
688
- arr[j] %= baseOut;
689
- }
690
- }
691
- }
692
- return arr.reverse();
693
- }
694
- return function(str, baseIn, baseOut, sign, callerIsToString) {
695
- var alphabet2, d, e, k, r, x, xc, y, i = str.indexOf("."), dp = DECIMAL_PLACES, rm = ROUNDING_MODE;
696
- if (i >= 0) {
697
- k = POW_PRECISION;
698
- POW_PRECISION = 0;
699
- str = str.replace(".", "");
700
- y = new BigNumber2(baseIn);
701
- x = y.pow(str.length - i);
702
- POW_PRECISION = k;
703
- y.c = toBaseOut(
704
- toFixedPoint(coeffToString(x.c), x.e, "0"),
705
- 10,
706
- baseOut,
707
- decimal
708
- );
709
- y.e = y.c.length;
710
- }
711
- xc = toBaseOut(str, baseIn, baseOut, callerIsToString ? (alphabet2 = ALPHABET, decimal) : (alphabet2 = decimal, ALPHABET));
712
- e = k = xc.length;
713
- for (; xc[--k] == 0; xc.pop()) ;
714
- if (!xc[0]) return alphabet2.charAt(0);
715
- if (i < 0) {
716
- --e;
717
- } else {
718
- x.c = xc;
719
- x.e = e;
720
- x.s = sign;
721
- x = div(x, y, dp, rm, baseOut);
722
- xc = x.c;
723
- r = x.r;
724
- e = x.e;
725
- }
726
- d = e + dp + 1;
727
- i = xc[d];
728
- k = baseOut / 2;
729
- r = r || d < 0 || xc[d + 1] != null;
730
- r = rm < 4 ? (i != null || r) && (rm == 0 || rm == (x.s < 0 ? 3 : 2)) : i > k || i == k && (rm == 4 || r || rm == 6 && xc[d - 1] & 1 || rm == (x.s < 0 ? 8 : 7));
731
- if (d < 1 || !xc[0]) {
732
- str = r ? toFixedPoint(alphabet2.charAt(1), -dp, alphabet2.charAt(0)) : alphabet2.charAt(0);
733
- } else {
734
- xc.length = d;
735
- if (r) {
736
- for (--baseOut; ++xc[--d] > baseOut; ) {
737
- xc[d] = 0;
738
- if (!d) {
739
- ++e;
740
- xc = [1].concat(xc);
741
- }
742
- }
743
- }
744
- for (k = xc.length; !xc[--k]; ) ;
745
- for (i = 0, str = ""; i <= k; str += alphabet2.charAt(xc[i++])) ;
746
- str = toFixedPoint(str, e, alphabet2.charAt(0));
747
- }
748
- return str;
749
- };
750
- })();
751
- div = /* @__PURE__ */ (function() {
752
- function multiply(x, k, base) {
753
- var m, temp, xlo, xhi, carry = 0, i = x.length, klo = k % SQRT_BASE, khi = k / SQRT_BASE | 0;
754
- for (x = x.slice(); i--; ) {
755
- xlo = x[i] % SQRT_BASE;
756
- xhi = x[i] / SQRT_BASE | 0;
757
- m = khi * xlo + xhi * klo;
758
- temp = klo * xlo + m % SQRT_BASE * SQRT_BASE + carry;
759
- carry = (temp / base | 0) + (m / SQRT_BASE | 0) + khi * xhi;
760
- x[i] = temp % base;
761
- }
762
- if (carry) x = [carry].concat(x);
763
- return x;
764
- }
765
- function compare2(a, b, aL, bL) {
766
- var i, cmp;
767
- if (aL != bL) {
768
- cmp = aL > bL ? 1 : -1;
769
- } else {
770
- for (i = cmp = 0; i < aL; i++) {
771
- if (a[i] != b[i]) {
772
- cmp = a[i] > b[i] ? 1 : -1;
773
- break;
774
- }
775
- }
776
- }
777
- return cmp;
778
- }
779
- function subtract(a, b, aL, base) {
780
- var i = 0;
781
- for (; aL--; ) {
782
- a[aL] -= i;
783
- i = a[aL] < b[aL] ? 1 : 0;
784
- a[aL] = i * base + a[aL] - b[aL];
785
- }
786
- for (; !a[0] && a.length > 1; a.splice(0, 1)) ;
787
- }
788
- return function(x, y, dp, rm, base) {
789
- var cmp, e, i, more, n, prod, prodL, q, qc, rem, remL, rem0, xi, xL, yc0, yL, yz, s = x.s == y.s ? 1 : -1, xc = x.c, yc = y.c;
790
- if (!xc || !xc[0] || !yc || !yc[0]) {
791
- return new BigNumber2(
792
- // Return NaN if either NaN, or both Infinity or 0.
793
- !x.s || !y.s || (xc ? yc && xc[0] == yc[0] : !yc) ? NaN : (
794
- // Return ±0 if x is ±0 or y is ±Infinity, or return ±Infinity as y is ±0.
795
- xc && xc[0] == 0 || !yc ? s * 0 : s / 0
796
- )
797
- );
798
- }
799
- q = new BigNumber2(s);
800
- qc = q.c = [];
801
- e = x.e - y.e;
802
- s = dp + e + 1;
803
- if (!base) {
804
- base = BASE;
805
- e = bitFloor(x.e / LOG_BASE) - bitFloor(y.e / LOG_BASE);
806
- s = s / LOG_BASE | 0;
807
- }
808
- for (i = 0; yc[i] == (xc[i] || 0); i++) ;
809
- if (yc[i] > (xc[i] || 0)) e--;
810
- if (s < 0) {
811
- qc.push(1);
812
- more = true;
813
- } else {
814
- xL = xc.length;
815
- yL = yc.length;
816
- i = 0;
817
- s += 2;
818
- n = mathfloor(base / (yc[0] + 1));
819
- if (n > 1) {
820
- yc = multiply(yc, n, base);
821
- xc = multiply(xc, n, base);
822
- yL = yc.length;
823
- xL = xc.length;
824
- }
825
- xi = yL;
826
- rem = xc.slice(0, yL);
827
- remL = rem.length;
828
- for (; remL < yL; rem[remL++] = 0) ;
829
- yz = yc.slice();
830
- yz = [0].concat(yz);
831
- yc0 = yc[0];
832
- if (yc[1] >= base / 2) yc0++;
833
- do {
834
- n = 0;
835
- cmp = compare2(yc, rem, yL, remL);
836
- if (cmp < 0) {
837
- rem0 = rem[0];
838
- if (yL != remL) rem0 = rem0 * base + (rem[1] || 0);
839
- n = mathfloor(rem0 / yc0);
840
- if (n > 1) {
841
- if (n >= base) n = base - 1;
842
- prod = multiply(yc, n, base);
843
- prodL = prod.length;
844
- remL = rem.length;
845
- while (compare2(prod, rem, prodL, remL) == 1) {
846
- n--;
847
- subtract(prod, yL < prodL ? yz : yc, prodL, base);
848
- prodL = prod.length;
849
- cmp = 1;
850
- }
851
- } else {
852
- if (n == 0) {
853
- cmp = n = 1;
854
- }
855
- prod = yc.slice();
856
- prodL = prod.length;
857
- }
858
- if (prodL < remL) prod = [0].concat(prod);
859
- subtract(rem, prod, remL, base);
860
- remL = rem.length;
861
- if (cmp == -1) {
862
- while (compare2(yc, rem, yL, remL) < 1) {
863
- n++;
864
- subtract(rem, yL < remL ? yz : yc, remL, base);
865
- remL = rem.length;
866
- }
867
- }
868
- } else if (cmp === 0) {
869
- n++;
870
- rem = [0];
871
- }
872
- qc[i++] = n;
873
- if (rem[0]) {
874
- rem[remL++] = xc[xi] || 0;
875
- } else {
876
- rem = [xc[xi]];
877
- remL = 1;
878
- }
879
- } while ((xi++ < xL || rem[0] != null) && s--);
880
- more = rem[0] != null;
881
- if (!qc[0]) qc.splice(0, 1);
882
- }
883
- if (base == BASE) {
884
- for (i = 1, s = qc[0]; s >= 10; s /= 10, i++) ;
885
- round(q, dp + (q.e = i + e * LOG_BASE - 1) + 1, rm, more);
886
- } else {
887
- q.e = e;
888
- q.r = +more;
889
- }
890
- return q;
891
- };
892
- })();
893
- function format(n, i, rm, id) {
894
- var c0, e, ne, len, str;
895
- if (rm == null) rm = ROUNDING_MODE;
896
- else intCheck(rm, 0, 8);
897
- if (!n.c) return n.toString();
898
- c0 = n.c[0];
899
- ne = n.e;
900
- if (i == null) {
901
- str = coeffToString(n.c);
902
- str = id == 1 || id == 2 && (ne <= TO_EXP_NEG || ne >= TO_EXP_POS) ? toExponential(str, ne) : toFixedPoint(str, ne, "0");
903
- } else {
904
- n = round(new BigNumber2(n), i, rm);
905
- e = n.e;
906
- str = coeffToString(n.c);
907
- len = str.length;
908
- if (id == 1 || id == 2 && (i <= e || e <= TO_EXP_NEG)) {
909
- for (; len < i; str += "0", len++) ;
910
- str = toExponential(str, e);
911
- } else {
912
- i -= ne + (id === 2 && e > ne);
913
- str = toFixedPoint(str, e, "0");
914
- if (e + 1 > len) {
915
- if (--i > 0) for (str += "."; i--; str += "0") ;
916
- } else {
917
- i += e - len;
918
- if (i > 0) {
919
- if (e + 1 == len) str += ".";
920
- for (; i--; str += "0") ;
921
- }
922
- }
923
- }
924
- }
925
- return n.s < 0 && c0 ? "-" + str : str;
926
- }
927
- function maxOrMin(args, n) {
928
- var k, y, i = 1, x = new BigNumber2(args[0]);
929
- for (; i < args.length; i++) {
930
- y = new BigNumber2(args[i]);
931
- if (!y.s || (k = compare(x, y)) === n || k === 0 && x.s === n) {
932
- x = y;
933
- }
934
- }
935
- return x;
936
- }
937
- function normalise(n, c, e) {
938
- var i = 1, j = c.length;
939
- for (; !c[--j]; c.pop()) ;
940
- for (j = c[0]; j >= 10; j /= 10, i++) ;
941
- if ((e = i + e * LOG_BASE - 1) > MAX_EXP) {
942
- n.c = n.e = null;
943
- } else if (e < MIN_EXP) {
944
- n.c = [n.e = 0];
945
- } else {
946
- n.e = e;
947
- n.c = c;
948
- }
949
- return n;
950
- }
951
- parseNumeric = /* @__PURE__ */ (function() {
952
- var basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i, dotAfter = /^([^.]+)\.$/, dotBefore = /^\.([^.]+)$/, isInfinityOrNaN = /^-?(Infinity|NaN)$/, whitespaceOrPlus = /^\s*\+(?=[\w.])|^\s+|\s+$/g;
953
- return function(x, str, isNum, b) {
954
- var base, s = isNum ? str : str.replace(whitespaceOrPlus, "");
955
- if (isInfinityOrNaN.test(s)) {
956
- x.s = isNaN(s) ? null : s < 0 ? -1 : 1;
957
- } else {
958
- if (!isNum) {
959
- s = s.replace(basePrefix, function(m, p1, p2) {
960
- base = (p2 = p2.toLowerCase()) == "x" ? 16 : p2 == "b" ? 2 : 8;
961
- return !b || b == base ? p1 : m;
962
- });
963
- if (b) {
964
- base = b;
965
- s = s.replace(dotAfter, "$1").replace(dotBefore, "0.$1");
966
- }
967
- if (str != s) return new BigNumber2(s, base);
968
- }
969
- if (BigNumber2.DEBUG) {
970
- throw Error(bignumberError + "Not a" + (b ? " base " + b : "") + " number: " + str);
971
- }
972
- x.s = null;
973
- }
974
- x.c = x.e = null;
975
- };
976
- })();
977
- function round(x, sd, rm, r) {
978
- var d, i, j, k, n, ni, rd, xc = x.c, pows10 = POWS_TEN;
979
- if (xc) {
980
- out: {
981
- for (d = 1, k = xc[0]; k >= 10; k /= 10, d++) ;
982
- i = sd - d;
983
- if (i < 0) {
984
- i += LOG_BASE;
985
- j = sd;
986
- n = xc[ni = 0];
987
- rd = mathfloor(n / pows10[d - j - 1] % 10);
988
- } else {
989
- ni = mathceil((i + 1) / LOG_BASE);
990
- if (ni >= xc.length) {
991
- if (r) {
992
- for (; xc.length <= ni; xc.push(0)) ;
993
- n = rd = 0;
994
- d = 1;
995
- i %= LOG_BASE;
996
- j = i - LOG_BASE + 1;
997
- } else {
998
- break out;
999
- }
1000
- } else {
1001
- n = k = xc[ni];
1002
- for (d = 1; k >= 10; k /= 10, d++) ;
1003
- i %= LOG_BASE;
1004
- j = i - LOG_BASE + d;
1005
- rd = j < 0 ? 0 : mathfloor(n / pows10[d - j - 1] % 10);
1006
- }
1007
- }
1008
- r = r || sd < 0 || // Are there any non-zero digits after the rounding digit?
1009
- // The expression n % pows10[d - j - 1] returns all digits of n to the right
1010
- // of the digit at j, e.g. if n is 908714 and j is 2, the expression gives 714.
1011
- xc[ni + 1] != null || (j < 0 ? n : n % pows10[d - j - 1]);
1012
- r = rm < 4 ? (rd || r) && (rm == 0 || rm == (x.s < 0 ? 3 : 2)) : rd > 5 || rd == 5 && (rm == 4 || r || rm == 6 && // Check whether the digit to the left of the rounding digit is odd.
1013
- (i > 0 ? j > 0 ? n / pows10[d - j] : 0 : xc[ni - 1]) % 10 & 1 || rm == (x.s < 0 ? 8 : 7));
1014
- if (sd < 1 || !xc[0]) {
1015
- xc.length = 0;
1016
- if (r) {
1017
- sd -= x.e + 1;
1018
- xc[0] = pows10[(LOG_BASE - sd % LOG_BASE) % LOG_BASE];
1019
- x.e = -sd || 0;
1020
- } else {
1021
- xc[0] = x.e = 0;
1022
- }
1023
- return x;
1024
- }
1025
- if (i == 0) {
1026
- xc.length = ni;
1027
- k = 1;
1028
- ni--;
1029
- } else {
1030
- xc.length = ni + 1;
1031
- k = pows10[LOG_BASE - i];
1032
- xc[ni] = j > 0 ? mathfloor(n / pows10[d - j] % pows10[j]) * k : 0;
1033
- }
1034
- if (r) {
1035
- for (; ; ) {
1036
- if (ni == 0) {
1037
- for (i = 1, j = xc[0]; j >= 10; j /= 10, i++) ;
1038
- j = xc[0] += k;
1039
- for (k = 1; j >= 10; j /= 10, k++) ;
1040
- if (i != k) {
1041
- x.e++;
1042
- if (xc[0] == BASE) xc[0] = 1;
1043
- }
1044
- break;
1045
- } else {
1046
- xc[ni] += k;
1047
- if (xc[ni] != BASE) break;
1048
- xc[ni--] = 0;
1049
- k = 1;
1050
- }
1051
- }
1052
- }
1053
- for (i = xc.length; xc[--i] === 0; xc.pop()) ;
1054
- }
1055
- if (x.e > MAX_EXP) {
1056
- x.c = x.e = null;
1057
- } else if (x.e < MIN_EXP) {
1058
- x.c = [x.e = 0];
1059
- }
1060
- }
1061
- return x;
1062
- }
1063
- function valueOf(n) {
1064
- var str, e = n.e;
1065
- if (e === null) return n.toString();
1066
- str = coeffToString(n.c);
1067
- str = e <= TO_EXP_NEG || e >= TO_EXP_POS ? toExponential(str, e) : toFixedPoint(str, e, "0");
1068
- return n.s < 0 ? "-" + str : str;
1069
- }
1070
- P.absoluteValue = P.abs = function() {
1071
- var x = new BigNumber2(this);
1072
- if (x.s < 0) x.s = 1;
1073
- return x;
1074
- };
1075
- P.comparedTo = function(y, b) {
1076
- return compare(this, new BigNumber2(y, b));
1077
- };
1078
- P.decimalPlaces = P.dp = function(dp, rm) {
1079
- var c, n, v, x = this;
1080
- if (dp != null) {
1081
- intCheck(dp, 0, MAX);
1082
- if (rm == null) rm = ROUNDING_MODE;
1083
- else intCheck(rm, 0, 8);
1084
- return round(new BigNumber2(x), dp + x.e + 1, rm);
1085
- }
1086
- if (!(c = x.c)) return null;
1087
- n = ((v = c.length - 1) - bitFloor(this.e / LOG_BASE)) * LOG_BASE;
1088
- if (v = c[v]) for (; v % 10 == 0; v /= 10, n--) ;
1089
- if (n < 0) n = 0;
1090
- return n;
1091
- };
1092
- P.dividedBy = P.div = function(y, b) {
1093
- return div(this, new BigNumber2(y, b), DECIMAL_PLACES, ROUNDING_MODE);
1094
- };
1095
- P.dividedToIntegerBy = P.idiv = function(y, b) {
1096
- return div(this, new BigNumber2(y, b), 0, 1);
1097
- };
1098
- P.exponentiatedBy = P.pow = function(n, m) {
1099
- var half, isModExp, i, k, more, nIsBig, nIsNeg, nIsOdd, y, x = this;
1100
- n = new BigNumber2(n);
1101
- if (n.c && !n.isInteger()) {
1102
- throw Error(bignumberError + "Exponent not an integer: " + valueOf(n));
1103
- }
1104
- if (m != null) m = new BigNumber2(m);
1105
- nIsBig = n.e > 14;
1106
- if (!x.c || !x.c[0] || x.c[0] == 1 && !x.e && x.c.length == 1 || !n.c || !n.c[0]) {
1107
- y = new BigNumber2(Math.pow(+valueOf(x), nIsBig ? n.s * (2 - isOdd(n)) : +valueOf(n)));
1108
- return m ? y.mod(m) : y;
1109
- }
1110
- nIsNeg = n.s < 0;
1111
- if (m) {
1112
- if (m.c ? !m.c[0] : !m.s) return new BigNumber2(NaN);
1113
- isModExp = !nIsNeg && x.isInteger() && m.isInteger();
1114
- if (isModExp) x = x.mod(m);
1115
- } else if (n.e > 9 && (x.e > 0 || x.e < -1 || (x.e == 0 ? x.c[0] > 1 || nIsBig && x.c[1] >= 24e7 : x.c[0] < 8e13 || nIsBig && x.c[0] <= 9999975e7))) {
1116
- k = x.s < 0 && isOdd(n) ? -0 : 0;
1117
- if (x.e > -1) k = 1 / k;
1118
- return new BigNumber2(nIsNeg ? 1 / k : k);
1119
- } else if (POW_PRECISION) {
1120
- k = mathceil(POW_PRECISION / LOG_BASE + 2);
1121
- }
1122
- if (nIsBig) {
1123
- half = new BigNumber2(0.5);
1124
- if (nIsNeg) n.s = 1;
1125
- nIsOdd = isOdd(n);
1126
- } else {
1127
- i = Math.abs(+valueOf(n));
1128
- nIsOdd = i % 2;
1129
- }
1130
- y = new BigNumber2(ONE);
1131
- for (; ; ) {
1132
- if (nIsOdd) {
1133
- y = y.times(x);
1134
- if (!y.c) break;
1135
- if (k) {
1136
- if (y.c.length > k) y.c.length = k;
1137
- } else if (isModExp) {
1138
- y = y.mod(m);
1139
- }
1140
- }
1141
- if (i) {
1142
- i = mathfloor(i / 2);
1143
- if (i === 0) break;
1144
- nIsOdd = i % 2;
1145
- } else {
1146
- n = n.times(half);
1147
- round(n, n.e + 1, 1);
1148
- if (n.e > 14) {
1149
- nIsOdd = isOdd(n);
1150
- } else {
1151
- i = +valueOf(n);
1152
- if (i === 0) break;
1153
- nIsOdd = i % 2;
1154
- }
1155
- }
1156
- x = x.times(x);
1157
- if (k) {
1158
- if (x.c && x.c.length > k) x.c.length = k;
1159
- } else if (isModExp) {
1160
- x = x.mod(m);
1161
- }
1162
- }
1163
- if (isModExp) return y;
1164
- if (nIsNeg) y = ONE.div(y);
1165
- return m ? y.mod(m) : k ? round(y, POW_PRECISION, ROUNDING_MODE, more) : y;
1166
- };
1167
- P.integerValue = function(rm) {
1168
- var n = new BigNumber2(this);
1169
- if (rm == null) rm = ROUNDING_MODE;
1170
- else intCheck(rm, 0, 8);
1171
- return round(n, n.e + 1, rm);
1172
- };
1173
- P.isEqualTo = P.eq = function(y, b) {
1174
- return compare(this, new BigNumber2(y, b)) === 0;
1175
- };
1176
- P.isFinite = function() {
1177
- return !!this.c;
1178
- };
1179
- P.isGreaterThan = P.gt = function(y, b) {
1180
- return compare(this, new BigNumber2(y, b)) > 0;
1181
- };
1182
- P.isGreaterThanOrEqualTo = P.gte = function(y, b) {
1183
- return (b = compare(this, new BigNumber2(y, b))) === 1 || b === 0;
1184
- };
1185
- P.isInteger = function() {
1186
- return !!this.c && bitFloor(this.e / LOG_BASE) > this.c.length - 2;
1187
- };
1188
- P.isLessThan = P.lt = function(y, b) {
1189
- return compare(this, new BigNumber2(y, b)) < 0;
1190
- };
1191
- P.isLessThanOrEqualTo = P.lte = function(y, b) {
1192
- return (b = compare(this, new BigNumber2(y, b))) === -1 || b === 0;
1193
- };
1194
- P.isNaN = function() {
1195
- return !this.s;
1196
- };
1197
- P.isNegative = function() {
1198
- return this.s < 0;
1199
- };
1200
- P.isPositive = function() {
1201
- return this.s > 0;
1202
- };
1203
- P.isZero = function() {
1204
- return !!this.c && this.c[0] == 0;
1205
- };
1206
- P.minus = function(y, b) {
1207
- var i, j, t, xLTy, x = this, a = x.s;
1208
- y = new BigNumber2(y, b);
1209
- b = y.s;
1210
- if (!a || !b) return new BigNumber2(NaN);
1211
- if (a != b) {
1212
- y.s = -b;
1213
- return x.plus(y);
1214
- }
1215
- var xe = x.e / LOG_BASE, ye = y.e / LOG_BASE, xc = x.c, yc = y.c;
1216
- if (!xe || !ye) {
1217
- if (!xc || !yc) return xc ? (y.s = -b, y) : new BigNumber2(yc ? x : NaN);
1218
- if (!xc[0] || !yc[0]) {
1219
- return yc[0] ? (y.s = -b, y) : new BigNumber2(xc[0] ? x : (
1220
- // IEEE 754 (2008) 6.3: n - n = -0 when rounding to -Infinity
1221
- ROUNDING_MODE == 3 ? -0 : 0
1222
- ));
1223
- }
1224
- }
1225
- xe = bitFloor(xe);
1226
- ye = bitFloor(ye);
1227
- xc = xc.slice();
1228
- if (a = xe - ye) {
1229
- if (xLTy = a < 0) {
1230
- a = -a;
1231
- t = xc;
1232
- } else {
1233
- ye = xe;
1234
- t = yc;
1235
- }
1236
- t.reverse();
1237
- for (b = a; b--; t.push(0)) ;
1238
- t.reverse();
1239
- } else {
1240
- j = (xLTy = (a = xc.length) < (b = yc.length)) ? a : b;
1241
- for (a = b = 0; b < j; b++) {
1242
- if (xc[b] != yc[b]) {
1243
- xLTy = xc[b] < yc[b];
1244
- break;
1245
- }
1246
- }
1247
- }
1248
- if (xLTy) {
1249
- t = xc;
1250
- xc = yc;
1251
- yc = t;
1252
- y.s = -y.s;
1253
- }
1254
- b = (j = yc.length) - (i = xc.length);
1255
- if (b > 0) for (; b--; xc[i++] = 0) ;
1256
- b = BASE - 1;
1257
- for (; j > a; ) {
1258
- if (xc[--j] < yc[j]) {
1259
- for (i = j; i && !xc[--i]; xc[i] = b) ;
1260
- --xc[i];
1261
- xc[j] += BASE;
1262
- }
1263
- xc[j] -= yc[j];
1264
- }
1265
- for (; xc[0] == 0; xc.splice(0, 1), --ye) ;
1266
- if (!xc[0]) {
1267
- y.s = ROUNDING_MODE == 3 ? -1 : 1;
1268
- y.c = [y.e = 0];
1269
- return y;
1270
- }
1271
- return normalise(y, xc, ye);
1272
- };
1273
- P.modulo = P.mod = function(y, b) {
1274
- var q, s, x = this;
1275
- y = new BigNumber2(y, b);
1276
- if (!x.c || !y.s || y.c && !y.c[0]) {
1277
- return new BigNumber2(NaN);
1278
- } else if (!y.c || x.c && !x.c[0]) {
1279
- return new BigNumber2(x);
1280
- }
1281
- if (MODULO_MODE == 9) {
1282
- s = y.s;
1283
- y.s = 1;
1284
- q = div(x, y, 0, 3);
1285
- y.s = s;
1286
- q.s *= s;
1287
- } else {
1288
- q = div(x, y, 0, MODULO_MODE);
1289
- }
1290
- y = x.minus(q.times(y));
1291
- if (!y.c[0] && MODULO_MODE == 1) y.s = x.s;
1292
- return y;
1293
- };
1294
- P.multipliedBy = P.times = function(y, b) {
1295
- var c, e, i, j, k, m, xcL, xlo, xhi, ycL, ylo, yhi, zc, base, sqrtBase, x = this, xc = x.c, yc = (y = new BigNumber2(y, b)).c;
1296
- if (!xc || !yc || !xc[0] || !yc[0]) {
1297
- if (!x.s || !y.s || xc && !xc[0] && !yc || yc && !yc[0] && !xc) {
1298
- y.c = y.e = y.s = null;
1299
- } else {
1300
- y.s *= x.s;
1301
- if (!xc || !yc) {
1302
- y.c = y.e = null;
1303
- } else {
1304
- y.c = [0];
1305
- y.e = 0;
1306
- }
1307
- }
1308
- return y;
1309
- }
1310
- e = bitFloor(x.e / LOG_BASE) + bitFloor(y.e / LOG_BASE);
1311
- y.s *= x.s;
1312
- xcL = xc.length;
1313
- ycL = yc.length;
1314
- if (xcL < ycL) {
1315
- zc = xc;
1316
- xc = yc;
1317
- yc = zc;
1318
- i = xcL;
1319
- xcL = ycL;
1320
- ycL = i;
1321
- }
1322
- for (i = xcL + ycL, zc = []; i--; zc.push(0)) ;
1323
- base = BASE;
1324
- sqrtBase = SQRT_BASE;
1325
- for (i = ycL; --i >= 0; ) {
1326
- c = 0;
1327
- ylo = yc[i] % sqrtBase;
1328
- yhi = yc[i] / sqrtBase | 0;
1329
- for (k = xcL, j = i + k; j > i; ) {
1330
- xlo = xc[--k] % sqrtBase;
1331
- xhi = xc[k] / sqrtBase | 0;
1332
- m = yhi * xlo + xhi * ylo;
1333
- xlo = ylo * xlo + m % sqrtBase * sqrtBase + zc[j] + c;
1334
- c = (xlo / base | 0) + (m / sqrtBase | 0) + yhi * xhi;
1335
- zc[j--] = xlo % base;
1336
- }
1337
- zc[j] = c;
1338
- }
1339
- if (c) {
1340
- ++e;
1341
- } else {
1342
- zc.splice(0, 1);
1343
- }
1344
- return normalise(y, zc, e);
1345
- };
1346
- P.negated = function() {
1347
- var x = new BigNumber2(this);
1348
- x.s = -x.s || null;
1349
- return x;
1350
- };
1351
- P.plus = function(y, b) {
1352
- var t, x = this, a = x.s;
1353
- y = new BigNumber2(y, b);
1354
- b = y.s;
1355
- if (!a || !b) return new BigNumber2(NaN);
1356
- if (a != b) {
1357
- y.s = -b;
1358
- return x.minus(y);
1359
- }
1360
- var xe = x.e / LOG_BASE, ye = y.e / LOG_BASE, xc = x.c, yc = y.c;
1361
- if (!xe || !ye) {
1362
- if (!xc || !yc) return new BigNumber2(a / 0);
1363
- if (!xc[0] || !yc[0]) return yc[0] ? y : new BigNumber2(xc[0] ? x : a * 0);
1364
- }
1365
- xe = bitFloor(xe);
1366
- ye = bitFloor(ye);
1367
- xc = xc.slice();
1368
- if (a = xe - ye) {
1369
- if (a > 0) {
1370
- ye = xe;
1371
- t = yc;
1372
- } else {
1373
- a = -a;
1374
- t = xc;
1375
- }
1376
- t.reverse();
1377
- for (; a--; t.push(0)) ;
1378
- t.reverse();
1379
- }
1380
- a = xc.length;
1381
- b = yc.length;
1382
- if (a - b < 0) {
1383
- t = yc;
1384
- yc = xc;
1385
- xc = t;
1386
- b = a;
1387
- }
1388
- for (a = 0; b; ) {
1389
- a = (xc[--b] = xc[b] + yc[b] + a) / BASE | 0;
1390
- xc[b] = BASE === xc[b] ? 0 : xc[b] % BASE;
1391
- }
1392
- if (a) {
1393
- xc = [a].concat(xc);
1394
- ++ye;
1395
- }
1396
- return normalise(y, xc, ye);
1397
- };
1398
- P.precision = P.sd = function(sd, rm) {
1399
- var c, n, v, x = this;
1400
- if (sd != null && sd !== !!sd) {
1401
- intCheck(sd, 1, MAX);
1402
- if (rm == null) rm = ROUNDING_MODE;
1403
- else intCheck(rm, 0, 8);
1404
- return round(new BigNumber2(x), sd, rm);
1405
- }
1406
- if (!(c = x.c)) return null;
1407
- v = c.length - 1;
1408
- n = v * LOG_BASE + 1;
1409
- if (v = c[v]) {
1410
- for (; v % 10 == 0; v /= 10, n--) ;
1411
- for (v = c[0]; v >= 10; v /= 10, n++) ;
1412
- }
1413
- if (sd && x.e + 1 > n) n = x.e + 1;
1414
- return n;
1415
- };
1416
- P.shiftedBy = function(k) {
1417
- intCheck(k, -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER);
1418
- return this.times("1e" + k);
1419
- };
1420
- P.squareRoot = P.sqrt = function() {
1421
- var m, n, r, rep, t, x = this, c = x.c, s = x.s, e = x.e, dp = DECIMAL_PLACES + 4, half = new BigNumber2("0.5");
1422
- if (s !== 1 || !c || !c[0]) {
1423
- return new BigNumber2(!s || s < 0 && (!c || c[0]) ? NaN : c ? x : 1 / 0);
1424
- }
1425
- s = Math.sqrt(+valueOf(x));
1426
- if (s == 0 || s == 1 / 0) {
1427
- n = coeffToString(c);
1428
- if ((n.length + e) % 2 == 0) n += "0";
1429
- s = Math.sqrt(+n);
1430
- e = bitFloor((e + 1) / 2) - (e < 0 || e % 2);
1431
- if (s == 1 / 0) {
1432
- n = "5e" + e;
1433
- } else {
1434
- n = s.toExponential();
1435
- n = n.slice(0, n.indexOf("e") + 1) + e;
1436
- }
1437
- r = new BigNumber2(n);
1438
- } else {
1439
- r = new BigNumber2(s + "");
1440
- }
1441
- if (r.c[0]) {
1442
- e = r.e;
1443
- s = e + dp;
1444
- if (s < 3) s = 0;
1445
- for (; ; ) {
1446
- t = r;
1447
- r = half.times(t.plus(div(x, t, dp, 1)));
1448
- if (coeffToString(t.c).slice(0, s) === (n = coeffToString(r.c)).slice(0, s)) {
1449
- if (r.e < e) --s;
1450
- n = n.slice(s - 3, s + 1);
1451
- if (n == "9999" || !rep && n == "4999") {
1452
- if (!rep) {
1453
- round(t, t.e + DECIMAL_PLACES + 2, 0);
1454
- if (t.times(t).eq(x)) {
1455
- r = t;
1456
- break;
1457
- }
1458
- }
1459
- dp += 4;
1460
- s += 4;
1461
- rep = 1;
1462
- } else {
1463
- if (!+n || !+n.slice(1) && n.charAt(0) == "5") {
1464
- round(r, r.e + DECIMAL_PLACES + 2, 1);
1465
- m = !r.times(r).eq(x);
1466
- }
1467
- break;
1468
- }
1469
- }
1470
- }
1471
- }
1472
- return round(r, r.e + DECIMAL_PLACES + 1, ROUNDING_MODE, m);
1473
- };
1474
- P.toExponential = function(dp, rm) {
1475
- if (dp != null) {
1476
- intCheck(dp, 0, MAX);
1477
- dp++;
1478
- }
1479
- return format(this, dp, rm, 1);
1480
- };
1481
- P.toFixed = function(dp, rm) {
1482
- if (dp != null) {
1483
- intCheck(dp, 0, MAX);
1484
- dp = dp + this.e + 1;
1485
- }
1486
- return format(this, dp, rm);
1487
- };
1488
- P.toFormat = function(dp, rm, format2) {
1489
- var str, x = this;
1490
- if (format2 == null) {
1491
- if (dp != null && rm && typeof rm == "object") {
1492
- format2 = rm;
1493
- rm = null;
1494
- } else if (dp && typeof dp == "object") {
1495
- format2 = dp;
1496
- dp = rm = null;
1497
- } else {
1498
- format2 = FORMAT;
1499
- }
1500
- } else if (typeof format2 != "object") {
1501
- throw Error(bignumberError + "Argument not an object: " + format2);
1502
- }
1503
- str = x.toFixed(dp, rm);
1504
- if (x.c) {
1505
- var i, arr = str.split("."), g1 = +format2.groupSize, g2 = +format2.secondaryGroupSize, groupSeparator = format2.groupSeparator || "", intPart = arr[0], fractionPart = arr[1], isNeg = x.s < 0, intDigits = isNeg ? intPart.slice(1) : intPart, len = intDigits.length;
1506
- if (g2) {
1507
- i = g1;
1508
- g1 = g2;
1509
- g2 = i;
1510
- len -= i;
1511
- }
1512
- if (g1 > 0 && len > 0) {
1513
- i = len % g1 || g1;
1514
- intPart = intDigits.substr(0, i);
1515
- for (; i < len; i += g1) intPart += groupSeparator + intDigits.substr(i, g1);
1516
- if (g2 > 0) intPart += groupSeparator + intDigits.slice(i);
1517
- if (isNeg) intPart = "-" + intPart;
1518
- }
1519
- str = fractionPart ? intPart + (format2.decimalSeparator || "") + ((g2 = +format2.fractionGroupSize) ? fractionPart.replace(
1520
- new RegExp("\\d{" + g2 + "}\\B", "g"),
1521
- "$&" + (format2.fractionGroupSeparator || "")
1522
- ) : fractionPart) : intPart;
1523
- }
1524
- return (format2.prefix || "") + str + (format2.suffix || "");
1525
- };
1526
- P.toFraction = function(md) {
1527
- var d, d0, d1, d2, e, exp, n, n0, n1, q, r, s, x = this, xc = x.c;
1528
- if (md != null) {
1529
- n = new BigNumber2(md);
1530
- if (!n.isInteger() && (n.c || n.s !== 1) || n.lt(ONE)) {
1531
- throw Error(bignumberError + "Argument " + (n.isInteger() ? "out of range: " : "not an integer: ") + valueOf(n));
1532
- }
1533
- }
1534
- if (!xc) return new BigNumber2(x);
1535
- d = new BigNumber2(ONE);
1536
- n1 = d0 = new BigNumber2(ONE);
1537
- d1 = n0 = new BigNumber2(ONE);
1538
- s = coeffToString(xc);
1539
- e = d.e = s.length - x.e - 1;
1540
- d.c[0] = POWS_TEN[(exp = e % LOG_BASE) < 0 ? LOG_BASE + exp : exp];
1541
- md = !md || n.comparedTo(d) > 0 ? e > 0 ? d : n1 : n;
1542
- exp = MAX_EXP;
1543
- MAX_EXP = 1 / 0;
1544
- n = new BigNumber2(s);
1545
- n0.c[0] = 0;
1546
- for (; ; ) {
1547
- q = div(n, d, 0, 1);
1548
- d2 = d0.plus(q.times(d1));
1549
- if (d2.comparedTo(md) == 1) break;
1550
- d0 = d1;
1551
- d1 = d2;
1552
- n1 = n0.plus(q.times(d2 = n1));
1553
- n0 = d2;
1554
- d = n.minus(q.times(d2 = d));
1555
- n = d2;
1556
- }
1557
- d2 = div(md.minus(d0), d1, 0, 1);
1558
- n0 = n0.plus(d2.times(n1));
1559
- d0 = d0.plus(d2.times(d1));
1560
- n0.s = n1.s = x.s;
1561
- e = e * 2;
1562
- r = div(n1, d1, e, ROUNDING_MODE).minus(x).abs().comparedTo(
1563
- div(n0, d0, e, ROUNDING_MODE).minus(x).abs()
1564
- ) < 1 ? [n1, d1] : [n0, d0];
1565
- MAX_EXP = exp;
1566
- return r;
1567
- };
1568
- P.toNumber = function() {
1569
- return +valueOf(this);
1570
- };
1571
- P.toPrecision = function(sd, rm) {
1572
- if (sd != null) intCheck(sd, 1, MAX);
1573
- return format(this, sd, rm, 2);
1574
- };
1575
- P.toString = function(b) {
1576
- var str, n = this, s = n.s, e = n.e;
1577
- if (e === null) {
1578
- if (s) {
1579
- str = "Infinity";
1580
- if (s < 0) str = "-" + str;
1581
- } else {
1582
- str = "NaN";
1583
- }
1584
- } else {
1585
- if (b == null) {
1586
- str = e <= TO_EXP_NEG || e >= TO_EXP_POS ? toExponential(coeffToString(n.c), e) : toFixedPoint(coeffToString(n.c), e, "0");
1587
- } else if (b === 10 && alphabetHasNormalDecimalDigits) {
1588
- n = round(new BigNumber2(n), DECIMAL_PLACES + e + 1, ROUNDING_MODE);
1589
- str = toFixedPoint(coeffToString(n.c), n.e, "0");
1590
- } else {
1591
- intCheck(b, 2, ALPHABET.length, "Base");
1592
- str = convertBase(toFixedPoint(coeffToString(n.c), e, "0"), 10, b, s, true);
1593
- }
1594
- if (s < 0 && n.c[0]) str = "-" + str;
1595
- }
1596
- return str;
1597
- };
1598
- P.valueOf = P.toJSON = function() {
1599
- return valueOf(this);
1600
- };
1601
- P._isBigNumber = true;
1602
- P[Symbol.toStringTag] = "BigNumber";
1603
- P[/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")] = P.valueOf;
1604
- if (configObject != null) BigNumber2.set(configObject);
1605
- return BigNumber2;
1606
- }
1607
- function bitFloor(n) {
1608
- var i = n | 0;
1609
- return n > 0 || n === i ? i : i - 1;
1610
- }
1611
- function coeffToString(a) {
1612
- var s, z, i = 1, j = a.length, r = a[0] + "";
1613
- for (; i < j; ) {
1614
- s = a[i++] + "";
1615
- z = LOG_BASE - s.length;
1616
- for (; z--; s = "0" + s) ;
1617
- r += s;
1618
- }
1619
- for (j = r.length; r.charCodeAt(--j) === 48; ) ;
1620
- return r.slice(0, j + 1 || 1);
1621
- }
1622
- function compare(x, y) {
1623
- var a, b, xc = x.c, yc = y.c, i = x.s, j = y.s, k = x.e, l = y.e;
1624
- if (!i || !j) return null;
1625
- a = xc && !xc[0];
1626
- b = yc && !yc[0];
1627
- if (a || b) return a ? b ? 0 : -j : i;
1628
- if (i != j) return i;
1629
- a = i < 0;
1630
- b = k == l;
1631
- if (!xc || !yc) return b ? 0 : !xc ^ a ? 1 : -1;
1632
- if (!b) return k > l ^ a ? 1 : -1;
1633
- j = (k = xc.length) < (l = yc.length) ? k : l;
1634
- for (i = 0; i < j; i++) if (xc[i] != yc[i]) return xc[i] > yc[i] ^ a ? 1 : -1;
1635
- return k == l ? 0 : k > l ^ a ? 1 : -1;
1636
- }
1637
- function intCheck(n, min, max, name) {
1638
- if (n < min || n > max || n !== mathfloor(n)) {
1639
- throw Error(bignumberError + (name || "Argument") + (typeof n == "number" ? n < min || n > max ? " out of range: " : " not an integer: " : " not a primitive number: ") + String(n));
1640
- }
1641
- }
1642
- function isOdd(n) {
1643
- var k = n.c.length - 1;
1644
- return bitFloor(n.e / LOG_BASE) == k && n.c[k] % 2 != 0;
1645
- }
1646
- function toExponential(str, e) {
1647
- return (str.length > 1 ? str.charAt(0) + "." + str.slice(1) : str) + (e < 0 ? "e" : "e+") + e;
1648
- }
1649
- function toFixedPoint(str, e, z) {
1650
- var len, zs;
1651
- if (e < 0) {
1652
- for (zs = z + "."; ++e; zs += z) ;
1653
- str = zs + str;
1654
- } else {
1655
- len = str.length;
1656
- if (++e > len) {
1657
- for (zs = z, e -= len; --e; zs += z) ;
1658
- str += zs;
1659
- } else if (e < len) {
1660
- str = str.slice(0, e) + "." + str.slice(e);
1661
- }
1662
- }
1663
- return str;
1664
- }
1665
- var BigNumber = clone();
1666
- var bignumber_default = BigNumber;
1667
-
1668
- // node_modules/@paralleldrive/cuid2/src/index.js
1669
- var defaultLength = 24;
1670
- var bigLength = 32;
1671
- var createRandom = () => {
1672
- if (typeof globalThis !== "undefined" && globalThis.crypto && typeof globalThis.crypto.getRandomValues === "function") {
1673
- return () => {
1674
- const buffer = new Uint32Array(1);
1675
- globalThis.crypto.getRandomValues(buffer);
1676
- return buffer[0] / 4294967296;
1677
- };
1678
- }
1679
- return Math.random;
1680
- };
1681
- var random = createRandom();
1682
- var createEntropy = (length = 4, rand = random) => {
1683
- let entropy = "";
1684
- while (entropy.length < length) {
1685
- entropy = entropy + Math.floor(rand() * 36).toString(36);
1686
- }
1687
- return entropy;
1688
- };
1689
- function bufToBigInt(buf) {
1690
- let value = new bignumber_default(0);
1691
- for (const i of buf.values()) {
1692
- value = value.multipliedBy(256).plus(i);
1693
- }
1694
- return value;
1695
- }
1696
- var hash = (input = "") => {
1697
- const encoder = new TextEncoder();
1698
- return bufToBigInt(sha3_512(encoder.encode(input))).toString(36).slice(1);
1699
- };
1700
- var alphabet = Array.from(
1701
- { length: 26 },
1702
- (x, i) => String.fromCharCode(i + 97)
1703
- );
1704
- var randomLetter = (rand) => alphabet[Math.floor(rand() * alphabet.length)];
1705
- var createFingerprint = ({
1706
- globalObj = typeof global !== "undefined" ? global : typeof window !== "undefined" ? window : {},
1707
- random: rand = random
1708
- } = {}) => {
1709
- const globals = Object.keys(globalObj).toString();
1710
- const sourceString = globals.length ? globals + createEntropy(bigLength, rand) : createEntropy(bigLength, rand);
1711
- return hash(sourceString).substring(0, bigLength);
1712
- };
1713
- var createCounter = (count) => () => {
1714
- return count++;
1715
- };
1716
- var initialCountMax = 476782367;
1717
- var init = ({
1718
- // Fallback if the user does not pass in a CSPRNG. This should be OK
1719
- // because we don't rely solely on the random number generator for entropy.
1720
- // We also use the host fingerprint, current time, and a session counter.
1721
- random: rand = random,
1722
- counter = createCounter(Math.floor(rand() * initialCountMax)),
1723
- length = defaultLength,
1724
- fingerprint = createFingerprint({ random: rand })
1725
- } = {}) => {
1726
- if (length > bigLength) {
1727
- throw new Error(
1728
- `Length must be between 2 and ${bigLength}. Received: ${length}`
1729
- );
1730
- }
1731
- return function cuid2() {
1732
- const firstLetter = randomLetter(rand);
1733
- const time = Date.now().toString(36);
1734
- const count = counter().toString(36);
1735
- const salt = createEntropy(length, rand);
1736
- const hashInput = `${time + salt + count + fingerprint}`;
1737
- return `${firstLetter + hash(hashInput).substring(1, length)}`;
1738
- };
1739
- };
1740
- var createId = lazy(init);
1741
- function lazy(fn) {
1742
- let initialized;
1743
- return () => {
1744
- if (!initialized) {
1745
- initialized = fn();
1746
- }
1747
- return initialized();
1748
- };
1749
- }
1750
-
1751
- // src/core/helpers.ts
1752
- function decorateCtor(ctor, label, runtime) {
1753
- if (process.env.NODE_ENV !== "production") {
1754
- if (isDecorated(ctor))
1755
- throw new Error(
1756
- `Constructor ${ctor} is already decorated. if you are using 'withSigilTyped()' & '@WithSigil()' at the same time remove one of them.`
1757
- );
1758
- }
1759
- Object.defineProperty(ctor, __LABEL__, {
1760
- value: label,
1761
- configurable: true,
1762
- enumerable: false,
1763
- writable: false
1764
- });
1765
- if (!(runtime == null ? void 0 : runtime.isInheritanceCheck))
1766
- Object.defineProperty(ctor, __EFFECTIVE_LABEL__, {
1767
- value: label,
1768
- configurable: true,
1769
- enumerable: false,
1770
- writable: false
1771
- });
1772
- const parent = Object.getPrototypeOf(ctor);
1773
- const parentChain = parent && parent[__LABEL_LINEAGE__] ? parent[__LABEL_LINEAGE__] : [];
1774
- const ctorChain = (runtime == null ? void 0 : runtime.isMixin) && label !== "Sigil" ? ["Sigil", ...parentChain, label] : [...parentChain, label];
1775
- Object.defineProperty(ctor, __LABEL_LINEAGE__, {
1776
- value: ctorChain,
1777
- configurable: true,
1778
- enumerable: false,
1779
- writable: false
1780
- });
1781
- Object.defineProperty(ctor, __LABEL_SET__, {
1782
- value: new Set(ctorChain),
1783
- configurable: true,
1784
- enumerable: false,
1785
- writable: false
1786
- });
1787
- if (!(runtime == null ? void 0 : runtime.isInheritanceCheck)) markDecorated(ctor);
1788
- }
1789
- function checkInheritance(ctor, opts) {
1790
- var _a, _b;
1791
- if (isInheritanceChecked(ctor) || ((_a = opts == null ? void 0 : opts.skipLabelInheritanceCheck) != null ? _a : OPTIONS.skipLabelInheritanceCheck))
1792
- return;
1793
- const ctors = [ctor];
1794
- let ancestor = Object.getPrototypeOf(ctor);
1795
- while (isSigilCtor(ancestor)) {
1796
- ctors.push(ancestor);
1797
- ancestor = Object.getPrototypeOf(ancestor);
1798
- }
1799
- const labelOwner = /* @__PURE__ */ new Map();
1800
- for (let i = ctors.length - 1; i >= 0; i--) {
1801
- const ctor2 = ctors[i];
1802
- if (!ctor2) continue;
1803
- let label = ctor2[__LABEL__];
1804
- if (labelOwner.has(label)) {
1805
- if (process.env.NODE_ENV !== "production") {
1806
- if (isDecorated(ctor2) || !((_b = opts == null ? void 0 : opts.autofillLabels) != null ? _b : OPTIONS.autofillLabels))
1807
- throw new Error(
1808
- `[Sigil Error] Class "${ctor2.name}" re-uses Sigil label "${label}" from ancestor "${labelOwner.get(label)}". Each Sigil subclass must use a unique label. Did you forget to use "WithSigil(newLabel)" on the subclass?`
1809
- );
1810
- }
1811
- label = generateRandomLabel();
1812
- decorateCtor(ctor2, label, { isInheritanceCheck: true });
1813
- }
1814
- labelOwner.set(label, ctor2.name);
1815
- }
1816
- markInheritanceChecked(ctor);
1817
- }
1818
- function verifyLabel(label, opts) {
1819
- var _a;
1820
- const labelValidation = (_a = opts == null ? void 0 : opts.labelValidation) != null ? _a : OPTIONS.labelValidation;
1821
- if (labelValidation) {
1822
- let valid;
1823
- if (labelValidation instanceof RegExp) valid = labelValidation.test(label);
1824
- else valid = labelValidation(label);
1825
- if (process.env.NODE_ENV !== "production") {
1826
- if (!valid)
1827
- throw new Error(
1828
- `[Sigil] Invalid identity label "${label}". Make sure that supplied label matches validation regex or function.`
1829
- );
1830
- }
1831
- }
1832
- }
1833
- function generateRandomLabel() {
1834
- let label = createId();
1835
- return `@Sigil.auto-${label}`;
1836
- }
1837
- function markSigil(ctor) {
1838
- Object.defineProperty(ctor, __SIGIL__, {
1839
- value: true,
1840
- configurable: false,
1841
- enumerable: false,
1842
- writable: false
1843
- });
1844
- }
1845
- function markSigilBase(ctor) {
1846
- Object.defineProperty(ctor, __SIGIL_BASE__, {
1847
- value: true,
1848
- configurable: false,
1849
- enumerable: false,
1850
- writable: false
1851
- });
1852
- }
1853
- function markDecorated(ctor) {
1854
- Object.defineProperty(ctor, __DECORATED__, {
1855
- value: true,
1856
- configurable: false,
1857
- enumerable: false,
1858
- writable: false
1859
- });
1860
- }
1861
- function markInheritanceChecked(ctor) {
1862
- Object.defineProperty(ctor, __INHERITANCE_CHECKED__, {
1863
- value: true,
1864
- configurable: false,
1865
- enumerable: false,
1866
- writable: false
1867
- });
1868
- }
1869
- function isSigilCtor(ctor) {
1870
- return typeof ctor === "function" && ctor[__SIGIL__] === true;
1871
- }
1872
- function isSigilInstance(inst) {
1873
- if (!inst || typeof inst !== "object") return false;
1874
- const ctor = getConstructor(inst);
1875
- return isSigilCtor(ctor);
1876
- }
1877
- function isSigilBaseCtor(ctor) {
1878
- return Object.hasOwn(ctor, __SIGIL_BASE__);
1879
- }
1880
- function isSigilBaseInstance(inst) {
1881
- if (!inst || typeof inst !== "object") return false;
1882
- const ctor = getConstructor(inst);
1883
- return isSigilBaseCtor(ctor);
1884
- }
1885
- function isDecorated(ctor) {
1886
- return Object.hasOwn(ctor, __DECORATED__);
1887
- }
1888
- function isInheritanceChecked(ctor) {
1889
- return Object.hasOwn(ctor, __INHERITANCE_CHECKED__);
1890
- }
1891
- function getConstructor(obj) {
1892
- var _a, _b, _c;
1893
- if (!obj || typeof obj !== "object") return null;
1894
- return (_c = (_b = obj.constructor) != null ? _b : (_a = Object.getPrototypeOf(obj)) == null ? void 0 : _a.constructor) != null ? _c : null;
1895
- }
1896
-
1897
- // src/core/mixin.ts
1898
- function Sigilify(Base, label, opts) {
1899
- if (isSigilCtor(Base)) throw new Error(`[Sigil Error] 'Sigilify(${label})' already sigilified.`);
1900
- let l;
1901
- if (label) {
1902
- verifyLabel(label, opts);
1903
- l = label;
1904
- } else l = generateRandomLabel();
1905
- class Sigilified extends Base {
1906
- /**
1907
- * Class-level identity label constant for this sigil constructor.
1908
- */
1909
- static get SigilLabel() {
1910
- if (!isInheritanceChecked(this)) checkInheritance(this);
1911
- return this[__LABEL__];
1912
- }
1913
- /**
1914
- * Class-level human-readable label constant for this sigil constructor, last passed label in 'Sigil' chain by developer.
1915
- */
1916
- static get SigilEffectiveLabel() {
1917
- return this[__EFFECTIVE_LABEL__];
1918
- }
1919
- /**
1920
- * Copy of the linearized sigil type label chain for the current constructor.
1921
- *
1922
- * Useful for debugging and performing strict lineage comparisons.
1923
- *
1924
- * @returns An array of labels representing parent → child type labels.
1925
- */
1926
- static get SigilLabelLineage() {
1927
- var _a;
1928
- if (!isInheritanceChecked(this)) checkInheritance(this);
1929
- return [...(_a = this[__LABEL_LINEAGE__]) != null ? _a : []];
1930
- }
1931
- /**
1932
- * Copy of the sigil type label set for the current constructor.
1933
- *
1934
- * Useful for quick membership checks (O(1) lookups) and debugging.
1935
- *
1936
- * @returns A Readonly Set of labels that represent the type lineage.
1937
- */
1938
- static get SigilLabelSet() {
1939
- if (!isInheritanceChecked(this)) checkInheritance(this);
1940
- const set = /* @__PURE__ */ new Set();
1941
- for (const s of this[__LABEL_SET__]) set.add(s);
1942
- return set;
1943
- }
1944
- constructor(...args) {
1945
- super(...args);
1946
- if (Object.getPrototypeOf(this) !== new.target.prototype)
1947
- Object.setPrototypeOf(this, new.target.prototype);
1948
- const ctor = getConstructor(this);
1949
- if (!ctor) {
1950
- if (process.env.NODE_ENV !== "production")
1951
- throw new Error(`[Sigil Error] 'Sigilify(${label})' instance without constructor`);
1952
- return;
1953
- }
1954
- checkInheritance(ctor);
1955
- }
1956
- /**
1957
- * Runtime predicate indicating whether `obj` is an instance produced by a sigil class.
1958
- *
1959
- * @param obj - The value to test.
1960
- * @returns `true` if `obj` is a sigil instance.
1961
- */
1962
- static isSigilified(obj) {
1963
- return isSigilInstance(obj);
1964
- }
1965
- /**
1966
- * Check whether `other` is (or inherits from) the type represented by the calling constructor.
1967
- *
1968
- * This replaces `instanceof` so that checks remain valid across bundles/realms
1969
- * and when subclassing.
1970
- *
1971
- * @typeParam T - The calling constructor type (narrowing the returned instance type).
1972
- * @param this - The constructor performing the check.
1973
- * @param other - The object to test.
1974
- * @returns `true` if `other` is an instance of this type or a subtype.
1975
- */
1976
- static isOfType(other) {
1977
- var _a;
1978
- if (!isSigilInstance(other)) return false;
1979
- const otherSet = (_a = getConstructor(other)) == null ? void 0 : _a[__LABEL_SET__];
1980
- const thisType = this[__LABEL__];
1981
- return !!otherSet && otherSet.has(thisType);
1982
- }
1983
- /**
1984
- * Strict lineage check: compares the type label lineage arrays element-by-element.
1985
- *
1986
- * @typeParam T - The calling constructor type.
1987
- * @param this - The constructor performing the check.
1988
- * @param other - The object to test.
1989
- * @returns `true` if `other` has an identical lineage up to the length of this constructor's lineage.
1990
- */
1991
- static isOfTypeStrict(other) {
1992
- var _a;
1993
- if (!isSigilInstance(other)) return false;
1994
- const otherLineage = (_a = getConstructor(other)) == null ? void 0 : _a[__LABEL_LINEAGE__];
1995
- const thisLineage = this[__LABEL_LINEAGE__];
1996
- return !!otherLineage && thisLineage.every((s, i) => s === otherLineage[i]);
1997
- }
1998
- /**
1999
- * Check whether `other` is (or inherits from) the type instance.
2000
- *
2001
- * Allows 'instanceof' like checks but in instances.
2002
- *
2003
- * @typeParam T - The instance type.
2004
- * @param this - The instance performing the check.
2005
- * @param other - The object to test.
2006
- * @returns `true` if `other` is the same instance of this type or a subtype.
2007
- */
2008
- isOfType(other) {
2009
- var _a;
2010
- if (!isSigilInstance(other)) return false;
2011
- const otherSet = (_a = getConstructor(other)) == null ? void 0 : _a[__LABEL_SET__];
2012
- const thisType = getConstructor(this)[__LABEL__];
2013
- return !!otherSet && otherSet.has(thisType);
2014
- }
2015
- /**
2016
- * Strict lineage check: compares the type label lineage arrays element-by-element.
2017
- *
2018
- * Allows 'instanceof' like checks but in instances.
2019
- *
2020
- * @typeParam T - The instance type.
2021
- * @param this - The instance performing the check.
2022
- * @param other - The object to test.
2023
- * @returns `true` if `other` has an identical lineage up to the length of this instance's lineage.
2024
- */
2025
- isOfTypeStrict(other) {
2026
- var _a, _b;
2027
- if (!isSigilInstance(other)) return false;
2028
- const otherLineage = (_a = getConstructor(other)) == null ? void 0 : _a[__LABEL_LINEAGE__];
2029
- const thisLineage = (_b = getConstructor(this)) == null ? void 0 : _b[__LABEL_LINEAGE__];
2030
- return !!otherLineage && thisLineage.every((s, i) => s === otherLineage[i]);
2031
- }
2032
- /**
2033
- * Returns the identity sigil label of this instance's constructor.
2034
- *
2035
- * @returns The label string if passed (e.g. '@scope/pkg.ClassName'), random label if not passed (e.g. '@Sigil.auto-dq62ib6jnvmmlfbjhxh2937h') or '@Sigil.unknown' if constructor is missing.
2036
- */
2037
- getSigilLabel() {
2038
- const ctor = getConstructor(this);
2039
- if (!ctor) {
2040
- if (process.env.NODE_ENV !== "production")
2041
- throw new Error(`[Sigil Error] Sigil class instance without constructor`);
2042
- return "@Sigil.unknown";
2043
- }
2044
- return ctor.SigilLabel;
2045
- }
2046
- /**
2047
- * Returns the human-readable sigil label of this instance's constructor.
2048
- *
2049
- * @returns The last passed label string (e.g. '@scope/pkg.ClassName') or '@Sigil.unknown' if constructor is missing.
2050
- */
2051
- getSigilEffectiveLabel() {
2052
- const ctor = getConstructor(this);
2053
- if (!ctor) {
2054
- if (process.env.NODE_ENV !== "production")
2055
- throw new Error(`[Sigil Error] Sigil class instance without constructor`);
2056
- return "@Sigil.unknown";
2057
- }
2058
- return ctor.SigilEffectiveLabel;
2059
- }
2060
- /**
2061
- * Returns a copy of the sigil type label lineage for this instance's constructor.
2062
- *
2063
- * @returns readonly array of labels representing the type lineage.
2064
- */
2065
- getSigilLabelLineage() {
2066
- const ctor = getConstructor(this);
2067
- if (!ctor) {
2068
- if (process.env.NODE_ENV !== "production")
2069
- throw new Error(`[Sigil Error] Sigil class instance without constructor`);
2070
- return ["@Sigil.unknown"];
2071
- }
2072
- return ctor.SigilLabelLineage;
2073
- }
2074
- /**
2075
- * Returns a readonly copy of the sigil type label set for this instance's constructor.
2076
- *
2077
- * @returns A Readonly Set of labels representing the type lineage for O(1) membership tests.
2078
- */
2079
- getSigilLabelSet() {
2080
- const ctor = getConstructor(this);
2081
- if (!ctor) {
2082
- if (process.env.NODE_ENV !== "production")
2083
- throw new Error(`[Sigil Error] Sigil class instance without constructor`);
2084
- return /* @__PURE__ */ new Set(["@Sigil.unknown"]);
2085
- }
2086
- return ctor.SigilLabelSet;
2087
- }
2088
- }
2089
- decorateCtor(Sigilified, l, { isMixin: true });
2090
- markSigil(Sigilified);
2091
- markSigilBase(Sigilified);
2092
- return Sigilified;
2093
- }
2094
- function SigilifyAbstract(Base, label, opts) {
2095
- if (isSigilCtor(Base)) throw new Error(`[Sigil Error] 'Sigilify(${label})' already sigilified.`);
2096
- let l;
2097
- if (label) {
2098
- verifyLabel(label, opts);
2099
- l = label;
2100
- } else l = generateRandomLabel();
2101
- class Sigilified extends Base {
2102
- /**
2103
- * Class-level identity label constant for this sigil constructor.
2104
- */
2105
- static get SigilLabel() {
2106
- if (!isInheritanceChecked(this)) checkInheritance(this);
2107
- return this[__LABEL__];
2108
- }
2109
- /**
2110
- * Class-level human-readable label constant for this sigil constructor, last passed label in 'Sigil' chain by developer.
2111
- */
2112
- static get SigilEffectiveLabel() {
2113
- return this[__EFFECTIVE_LABEL__];
2114
- }
2115
- /**
2116
- * Copy of the linearized sigil type label chain for the current constructor.
2117
- *
2118
- * Useful for debugging and performing strict lineage comparisons.
2119
- *
2120
- * @returns An array of labels representing parent → child type labels.
2121
- */
2122
- static get SigilLabelLineage() {
2123
- var _a;
2124
- if (!isInheritanceChecked(this)) checkInheritance(this);
2125
- return [...(_a = this[__LABEL_LINEAGE__]) != null ? _a : []];
2126
- }
2127
- /**
2128
- * Copy of the sigil type label set for the current constructor.
2129
- *
2130
- * Useful for quick membership checks (O(1) lookups) and debugging.
2131
- *
2132
- * @returns A Readonly Set of labels that represent the type lineage.
2133
- */
2134
- static get SigilLabelSet() {
2135
- if (!isInheritanceChecked(this)) checkInheritance(this);
2136
- const set = /* @__PURE__ */ new Set();
2137
- for (const s of this[__LABEL_SET__]) set.add(s);
2138
- return set;
2139
- }
2140
- constructor(...args) {
2141
- super(...args);
2142
- if (Object.getPrototypeOf(this) !== new.target.prototype)
2143
- Object.setPrototypeOf(this, new.target.prototype);
2144
- const ctor = getConstructor(this);
2145
- if (!ctor) {
2146
- if (process.env.NODE_ENV !== "production")
2147
- throw new Error(`[Sigil Error] 'Sigilify(${label})' instance without constructor`);
2148
- return;
2149
- }
2150
- checkInheritance(ctor);
2151
- }
2152
- /**
2153
- * Runtime predicate indicating whether `obj` is an instance produced by a sigil class.
2154
- *
2155
- * @param obj - The value to test.
2156
- * @returns `true` if `obj` is a sigil instance.
2157
- */
2158
- static isSigilified(obj) {
2159
- return isSigilInstance(obj);
2160
- }
2161
- /**
2162
- * Check whether `other` is (or inherits from) the type represented by the calling constructor.
2163
- *
2164
- * Implementation detail:
2165
- * - Uses the other instance's `__LABEL_SET__` for O(1) membership test.
2166
- * - O(1) and reliable as long as `OPTIONS.skipLabelInheritanceCheck` is `false`.
2167
- *
2168
- * This replaces `instanceof` so that checks remain valid across bundles/realms
2169
- * and when subclassing.
2170
- *
2171
- * @typeParam T - The calling constructor type (narrowing the returned instance type).
2172
- * @param this - The constructor performing the check.
2173
- * @param other - The object to test.
2174
- * @returns `true` if `other` is an instance of this type or a subtype.
2175
- */
2176
- static isOfType(other) {
2177
- var _a;
2178
- if (!isSigilInstance(other)) return false;
2179
- const otherSet = (_a = getConstructor(other)) == null ? void 0 : _a[__LABEL_SET__];
2180
- const thisType = this[__LABEL__];
2181
- return !!otherSet && otherSet.has(thisType);
2182
- }
2183
- /**
2184
- * Strict lineage check: compares the type label lineage arrays element-by-element.
2185
- *
2186
- * Implementation detail:
2187
- * - Works in O(n) time where n is the depth of the lineage.
2188
- * - Reliable when `OPTIONS.skipLabelInheritanceCheck` is `false`.
2189
- *
2190
- * @typeParam T - The calling constructor type.
2191
- * @param this - The constructor performing the check.
2192
- * @param other - The object to test.
2193
- * @returns `true` if `other` has an identical lineage up to the length of this constructor's lineage.
2194
- */
2195
- static isOfTypeStrict(other) {
2196
- var _a;
2197
- if (!isSigilInstance(other)) return false;
2198
- const otherLineage = (_a = getConstructor(other)) == null ? void 0 : _a[__LABEL_LINEAGE__];
2199
- const thisLineage = this[__LABEL_LINEAGE__];
2200
- return !!otherLineage && thisLineage.every((s, i) => s === otherLineage[i]);
2201
- }
2202
- /**
2203
- * Check whether `other` is (or inherits from) the type instance.
2204
- *
2205
- * Allows 'instanceof' like checks but in instances.
2206
- *
2207
- * @typeParam T - The instance type.
2208
- * @param this - The instance performing the check.
2209
- * @param other - The object to test.
2210
- * @returns `true` if `other` is the same instance of this type or a subtype.
2211
- */
2212
- isOfType(other) {
2213
- var _a;
2214
- if (!isSigilInstance(other)) return false;
2215
- const otherSet = (_a = getConstructor(other)) == null ? void 0 : _a[__LABEL_SET__];
2216
- const thisType = getConstructor(this)[__LABEL__];
2217
- return !!otherSet && otherSet.has(thisType);
2218
- }
2219
- /**
2220
- * Strict lineage check: compares the type label lineage arrays element-by-element.
2221
- *
2222
- * Allows 'instanceof' like checks but in instances.
2223
- *
2224
- * @typeParam T - The instance type.
2225
- * @param this - The instance performing the check.
2226
- * @param other - The object to test.
2227
- * @returns `true` if `other` has an identical lineage up to the length of this instance's lineage.
2228
- */
2229
- isOfTypeStrict(other) {
2230
- var _a, _b;
2231
- if (!isSigilInstance(other)) return false;
2232
- const otherLineage = (_a = getConstructor(other)) == null ? void 0 : _a[__LABEL_LINEAGE__];
2233
- const thisLineage = (_b = getConstructor(this)) == null ? void 0 : _b[__LABEL_LINEAGE__];
2234
- return !!otherLineage && thisLineage.every((s, i) => s === otherLineage[i]);
2235
- }
2236
- /**
2237
- * Returns the identity sigil label of this instance's constructor.
2238
- *
2239
- * @returns The label string if passed (e.g. '@scope/pkg.ClassName'), random label if not passed (e.g. '@Sigil.auto-dq62ib6jnvmmlfbjhxh2937h') or '@Sigil.unknown' if constructor is missing.
2240
- */
2241
- getSigilLabel() {
2242
- const ctor = getConstructor(this);
2243
- if (!ctor) {
2244
- if (process.env.NODE_ENV !== "production")
2245
- throw new Error(`[Sigil Error] Sigil class instance without constructor`);
2246
- return "@Sigil.unknown";
2247
- }
2248
- return ctor.SigilLabel;
2249
- }
2250
- /**
2251
- * Returns the human-readable sigil label of this instance's constructor.
2252
- *
2253
- * @returns The last passed label string (e.g. '@scope/pkg.ClassName') or '@Sigil.unknown' if constructor is missing.
2254
- */
2255
- getSigilEffectiveLabel() {
2256
- const ctor = getConstructor(this);
2257
- if (!ctor) {
2258
- if (process.env.NODE_ENV !== "production")
2259
- throw new Error(`[Sigil Error] Sigil class instance without constructor`);
2260
- return "@Sigil.unknown";
2261
- }
2262
- return ctor.SigilEffectiveLabel;
2263
- }
2264
- /**
2265
- * Returns a copy of the sigil type label lineage for this instance's constructor.
2266
- *
2267
- * @returns readonly array of labels representing the type lineage.
2268
- */
2269
- getSigilLabelLineage() {
2270
- const ctor = getConstructor(this);
2271
- if (!ctor) {
2272
- if (process.env.NODE_ENV !== "production")
2273
- throw new Error(`[Sigil Error] Sigil class instance without constructor`);
2274
- return ["@Sigil.unknown"];
2275
- }
2276
- return ctor.SigilLabelLineage;
2277
- }
2278
- /**
2279
- * Returns a readonly copy of the sigil type label set for this instance's constructor.
2280
- *
2281
- * @returns A Readonly Set of labels representing the type lineage for O(1) membership tests.
2282
- */
2283
- getSigilLabelSet() {
2284
- const ctor = getConstructor(this);
2285
- if (!ctor) {
2286
- if (process.env.NODE_ENV !== "production")
2287
- throw new Error(`[Sigil Error] Sigil class instance without constructor`);
2288
- return /* @__PURE__ */ new Set(["@Sigil.unknown"]);
2289
- }
2290
- return ctor.SigilLabelSet;
2291
- }
2292
- }
2293
- decorateCtor(Sigilified, l, { isMixin: true });
2294
- markSigil(Sigilified);
2295
- markSigilBase(Sigilified);
2296
- return Sigilified;
2297
- }
2298
-
2299
- // src/core/classes.ts
2300
- var Sigil = Sigilify(class {
2301
- }, "Sigil");
2302
- var SigilError = Sigilify(Error, "SigilError");
2303
-
2304
- // src/core/decorator.ts
2305
- function WithSigil(label, opts) {
2306
- let l;
2307
- if (label) {
2308
- verifyLabel(label, opts);
2309
- l = label;
2310
- } else l = generateRandomLabel();
2311
- return function(value, context) {
2312
- if (context.kind !== "class") return;
2313
- if (!isSigilCtor(value))
2314
- throw new Error(
2315
- `[Sigil Error] 'WithSigil' decorator accept only Sigil classes but used on class ${value.name}`
2316
- );
2317
- decorateCtor(value, l);
2318
- checkInheritance(value, opts);
2319
- };
2320
- }
2321
-
2322
- // src/core/hof.ts
2323
- function withSigil(Class, label, opts) {
2324
- var _a;
2325
- if (!isSigilCtor(Class))
2326
- throw new Error(
2327
- `[Sigil Error] 'withSigil' HOF accept only Sigil classes but used on class ${(_a = Class == null ? void 0 : Class.name) != null ? _a : "unknown"}`
2328
- );
2329
- let l;
2330
- if (label) {
2331
- verifyLabel(label, opts);
2332
- l = label;
2333
- } else l = generateRandomLabel();
2334
- const ctor = Class;
2335
- decorateCtor(ctor, l);
2336
- checkInheritance(ctor, opts);
2337
- return Class;
2338
- }
2339
- function withSigilTyped(Class, label, opts) {
2340
- var _a;
2341
- if (!isSigilCtor(Class))
2342
- throw new Error(
2343
- `[Sigil Error] 'withSigilTyped' HOF accept only Sigil classes but used on class ${(_a = Class == null ? void 0 : Class.name) != null ? _a : "unknown"}`
2344
- );
2345
- let l;
2346
- if (label) {
2347
- verifyLabel(label, opts);
2348
- l = label;
2349
- } else l = generateRandomLabel();
2350
- const ctor = Class;
2351
- decorateCtor(ctor, l);
2352
- checkInheritance(ctor, opts);
2353
- return Class;
2354
- }
2355
- /*! Bundled license information:
2356
-
2357
- @noble/hashes/utils.js:
2358
- (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
2359
- */
2360
-
2361
- exports.DEFAULT_LABEL_REGEX = DEFAULT_LABEL_REGEX;
2362
- exports.Sigil = Sigil;
2363
- exports.SigilError = SigilError;
2364
- exports.Sigilify = Sigilify;
2365
- exports.SigilifyAbstract = SigilifyAbstract;
2366
- exports.WithSigil = WithSigil;
2367
- exports.isDecorated = isDecorated;
2368
- exports.isInheritanceChecked = isInheritanceChecked;
2369
- exports.isSigilBaseCtor = isSigilBaseCtor;
2370
- exports.isSigilBaseInstance = isSigilBaseInstance;
2371
- exports.isSigilCtor = isSigilCtor;
2372
- exports.isSigilInstance = isSigilInstance;
2373
- exports.updateSigilOptions = updateSigilOptions;
2374
- exports.withSigil = withSigil;
2375
- exports.withSigilTyped = withSigilTyped;
2376
-
2377
- return exports;
2378
-
2379
- })({});
2380
- //# sourceMappingURL=index.global.js.map
3
+ @noble/hashes/utils.js:
4
+ (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
5
+ */exports.DEFAULT_LABEL_REGEX=yt;exports.Sigil=Yt;exports.SigilError=Zt;exports.Sigilify=Le;exports.SigilifyAbstract=Kt;exports.WithSigil=Jt;exports.isDecorated=Xe;exports.isInheritanceChecked=re;exports.isSigilBaseCtor=St;exports.isSigilBaseInstance=Wt;exports.isSigilCtor=ee;exports.isSigilInstance=K;exports.updateSigilOptions=_t;exports.withSigil=Qt;return exports;})({});//# sourceMappingURL=index.global.js.map
2381
6
  //# sourceMappingURL=index.global.js.map