@emasoft/svg-matrix 1.2.0 → 1.2.1

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,7 +1,8 @@
1
+ /*! svg-matrix v1.2.1 | MIT License | https://github.com/Emasoft/svg-matrix */
1
2
  var rJ=Object.defineProperty;var vJ=(J,K)=>{for(var $ in K)rJ(J,$,{get:K[$],enumerable:!0,configurable:!0,set:(Q)=>K[$]=()=>Q})};/*!
2
3
  * decimal.js v10.6.0
3
4
  * An arbitrary-precision Decimal type for JavaScript.
4
5
  * https://github.com/MikeMcl/decimal.js
5
6
  * Copyright (c) 2025 Michael Mclaughlin <M8ch88l@gmail.com>
6
7
  * MIT Licence
7
- */var i=9000000000000000,x=1e9,TJ="0123456789abcdef",XJ="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",UJ="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",OJ={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-i,maxE:i,crypto:!1},yJ,n,O=!0,RJ="[DecimalError] ",o=RJ+"Invalid argument: ",cJ=RJ+"Precision limit exceeded",lJ=RJ+"crypto unavailable",dJ="[object Decimal]",C=Math.floor,f=Math.pow,JK=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,KK=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,$K=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,nJ=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,c=1e7,I=7,QK=9007199254740991,HK=XJ.length-1,EJ=UJ.length-1,G={toStringTag:dJ};G.absoluteValue=G.abs=function(){var J=new this.constructor(this);if(J.s<0)J.s=1;return N(J)};G.ceil=function(){return N(new this.constructor(this),this.e+1,2)};G.clampedTo=G.clamp=function(J,K){var $,Q=this,H=Q.constructor;if(J=new H(J),K=new H(K),!J.s||!K.s)return new H(NaN);if(J.gt(K))throw Error(o+K);return $=Q.cmp(J),$<0?J:Q.cmp(K)>0?K:new H(Q)};G.comparedTo=G.cmp=function(J){var K,$,Q,H,Y=this,W=Y.d,F=(J=new Y.constructor(J)).d,U=Y.s,Z=J.s;if(!W||!F)return!U||!Z?NaN:U!==Z?U:W===F?0:!W^U<0?1:-1;if(!W[0]||!F[0])return W[0]?U:F[0]?-Z:0;if(U!==Z)return U;if(Y.e!==J.e)return Y.e>J.e^U<0?1:-1;Q=W.length,H=F.length;for(K=0,$=Q<H?Q:H;K<$;++K)if(W[K]!==F[K])return W[K]>F[K]^U<0?1:-1;return Q===H?0:Q>H^U<0?1:-1};G.cosine=G.cos=function(){var J,K,$=this,Q=$.constructor;if(!$.d)return new Q(NaN);if(!$.d[0])return new Q(1);return J=Q.precision,K=Q.rounding,Q.precision=J+Math.max($.e,$.sd())+I,Q.rounding=1,$=YK(Q,aJ(Q,$)),Q.precision=J,Q.rounding=K,N(n==2||n==3?$.neg():$,J,K,!0)};G.cubeRoot=G.cbrt=function(){var J,K,$,Q,H,Y,W,F,U,Z,q=this,R=q.constructor;if(!q.isFinite()||q.isZero())return new R(q);if(O=!1,Y=q.s*f(q.s*q,0.3333333333333333),!Y||Math.abs(Y)==1/0){if($=k(q.d),J=q.e,Y=(J-$.length+1)%3)$+=Y==1||Y==-2?"0":"00";if(Y=f($,0.3333333333333333),J=C((J+1)/3)-(J%3==(J<0?-1:2)),Y==1/0)$="5e"+J;else $=Y.toExponential(),$=$.slice(0,$.indexOf("e")+1)+J;Q=new R($),Q.s=q.s}else Q=new R(Y.toString());W=(J=R.precision)+3;for(;;)if(F=Q,U=F.times(F).times(F),Z=U.plus(q),Q=w(Z.plus(q).times(F),Z.plus(U),W+2,1),k(F.d).slice(0,W)===($=k(Q.d)).slice(0,W))if($=$.slice(W-3,W+1),$=="9999"||!H&&$=="4999"){if(!H){if(N(F,J+1,0),F.times(F).times(F).eq(q)){Q=F;break}}W+=4,H=1}else{if(!+$||!+$.slice(1)&&$.charAt(0)=="5")N(Q,J+1,1),K=!Q.times(Q).times(Q).eq(q);break}return O=!0,N(Q,J,R.rounding,K)};G.decimalPlaces=G.dp=function(){var J,K=this.d,$=NaN;if(K){if(J=K.length-1,$=(J-C(this.e/I))*I,J=K[J],J)for(;J%10==0;J/=10)$--;if($<0)$=0}return $};G.dividedBy=G.div=function(J){return w(this,new this.constructor(J))};G.dividedToIntegerBy=G.divToInt=function(J){var K=this,$=K.constructor;return N(w(K,new $(J),0,1,1),$.precision,$.rounding)};G.equals=G.eq=function(J){return this.cmp(J)===0};G.floor=function(){return N(new this.constructor(this),this.e+1,3)};G.greaterThan=G.gt=function(J){return this.cmp(J)>0};G.greaterThanOrEqualTo=G.gte=function(J){var K=this.cmp(J);return K==1||K===0};G.hyperbolicCosine=G.cosh=function(){var J,K,$,Q,H,Y=this,W=Y.constructor,F=new W(1);if(!Y.isFinite())return new W(Y.s?1/0:NaN);if(Y.isZero())return F;if($=W.precision,Q=W.rounding,W.precision=$+Math.max(Y.e,Y.sd())+4,W.rounding=1,H=Y.d.length,H<32)J=Math.ceil(H/3),K=(1/GJ(4,J)).toString();else J=16,K="2.3283064365386962890625e-10";Y=t(W,1,Y.times(K),new W(1),!0);var U,Z=J,q=new W(8);for(;Z--;)U=Y.times(Y),Y=F.minus(U.times(q.minus(U.times(q))));return N(Y,W.precision=$,W.rounding=Q,!0)};G.hyperbolicSine=G.sinh=function(){var J,K,$,Q,H=this,Y=H.constructor;if(!H.isFinite()||H.isZero())return new Y(H);if(K=Y.precision,$=Y.rounding,Y.precision=K+Math.max(H.e,H.sd())+4,Y.rounding=1,Q=H.d.length,Q<3)H=t(Y,2,H,H,!0);else{J=1.4*Math.sqrt(Q),J=J>16?16:J|0,H=H.times(1/GJ(5,J)),H=t(Y,2,H,H,!0);var W,F=new Y(5),U=new Y(16),Z=new Y(20);for(;J--;)W=H.times(H),H=H.times(F.plus(W.times(U.times(W).plus(Z))))}return Y.precision=K,Y.rounding=$,N(H,K,$,!0)};G.hyperbolicTangent=G.tanh=function(){var J,K,$=this,Q=$.constructor;if(!$.isFinite())return new Q($.s);if($.isZero())return new Q($);return J=Q.precision,K=Q.rounding,Q.precision=J+7,Q.rounding=1,w($.sinh(),$.cosh(),Q.precision=J,Q.rounding=K)};G.inverseCosine=G.acos=function(){var J=this,K=J.constructor,$=J.abs().cmp(1),Q=K.precision,H=K.rounding;if($!==-1)return $===0?J.isNeg()?l(K,Q,H):new K(0):new K(NaN);if(J.isZero())return l(K,Q+4,H).times(0.5);return K.precision=Q+6,K.rounding=1,J=new K(1).minus(J).div(J.plus(1)).sqrt().atan(),K.precision=Q,K.rounding=H,J.times(2)};G.inverseHyperbolicCosine=G.acosh=function(){var J,K,$=this,Q=$.constructor;if($.lte(1))return new Q($.eq(1)?0:NaN);if(!$.isFinite())return new Q($);return J=Q.precision,K=Q.rounding,Q.precision=J+Math.max(Math.abs($.e),$.sd())+4,Q.rounding=1,O=!1,$=$.times($).minus(1).sqrt().plus($),O=!0,Q.precision=J,Q.rounding=K,$.ln()};G.inverseHyperbolicSine=G.asinh=function(){var J,K,$=this,Q=$.constructor;if(!$.isFinite()||$.isZero())return new Q($);return J=Q.precision,K=Q.rounding,Q.precision=J+2*Math.max(Math.abs($.e),$.sd())+6,Q.rounding=1,O=!1,$=$.times($).plus(1).sqrt().plus($),O=!0,Q.precision=J,Q.rounding=K,$.ln()};G.inverseHyperbolicTangent=G.atanh=function(){var J,K,$,Q,H=this,Y=H.constructor;if(!H.isFinite())return new Y(NaN);if(H.e>=0)return new Y(H.abs().eq(1)?H.s/0:H.isZero()?H:NaN);if(J=Y.precision,K=Y.rounding,Q=H.sd(),Math.max(Q,J)<2*-H.e-1)return N(new Y(H),J,K,!0);return Y.precision=$=Q-H.e,H=w(H.plus(1),new Y(1).minus(H),$+J,1),Y.precision=J+4,Y.rounding=1,H=H.ln(),Y.precision=J,Y.rounding=K,H.times(0.5)};G.inverseSine=G.asin=function(){var J,K,$,Q,H=this,Y=H.constructor;if(H.isZero())return new Y(H);if(K=H.abs().cmp(1),$=Y.precision,Q=Y.rounding,K!==-1){if(K===0)return J=l(Y,$+4,Q).times(0.5),J.s=H.s,J;return new Y(NaN)}return Y.precision=$+6,Y.rounding=1,H=H.div(new Y(1).minus(H.times(H)).sqrt().plus(1)).atan(),Y.precision=$,Y.rounding=Q,H.times(2)};G.inverseTangent=G.atan=function(){var J,K,$,Q,H,Y,W,F,U,Z=this,q=Z.constructor,R=q.precision,V=q.rounding;if(!Z.isFinite()){if(!Z.s)return new q(NaN);if(R+4<=EJ)return W=l(q,R+4,V).times(0.5),W.s=Z.s,W}else if(Z.isZero())return new q(Z);else if(Z.abs().eq(1)&&R+4<=EJ)return W=l(q,R+4,V).times(0.25),W.s=Z.s,W;q.precision=F=R+10,q.rounding=1,$=Math.min(28,F/I+2|0);for(J=$;J;--J)Z=Z.div(Z.times(Z).plus(1).sqrt().plus(1));O=!1,K=Math.ceil(F/I),Q=1,U=Z.times(Z),W=new q(Z),H=Z;for(;J!==-1;)if(H=H.times(U),Y=W.minus(H.div(Q+=2)),H=H.times(U),W=Y.plus(H.div(Q+=2)),W.d[K]!==void 0)for(J=K;W.d[J]===Y.d[J]&&J--;);if($)W=W.times(2<<$-1);return O=!0,N(W,q.precision=R,q.rounding=V,!0)};G.isFinite=function(){return!!this.d};G.isInteger=G.isInt=function(){return!!this.d&&C(this.e/I)>this.d.length-2};G.isNaN=function(){return!this.s};G.isNegative=G.isNeg=function(){return this.s<0};G.isPositive=G.isPos=function(){return this.s>0};G.isZero=function(){return!!this.d&&this.d[0]===0};G.lessThan=G.lt=function(J){return this.cmp(J)<0};G.lessThanOrEqualTo=G.lte=function(J){return this.cmp(J)<1};G.logarithm=G.log=function(J){var K,$,Q,H,Y,W,F,U,Z=this,q=Z.constructor,R=q.precision,V=q.rounding,z=5;if(J==null)J=new q(10),K=!0;else{if(J=new q(J),$=J.d,J.s<0||!$||!$[0]||J.eq(1))return new q(NaN);K=J.eq(10)}if($=Z.d,Z.s<0||!$||!$[0]||Z.eq(1))return new q($&&!$[0]?-1/0:Z.s!=1?NaN:$?0:1/0);if(K)if($.length>1)Y=!0;else{for(H=$[0];H%10===0;)H/=10;Y=H!==1}if(O=!1,F=R+z,W=s(Z,F),Q=K?qJ(q,F+10):s(J,F),U=w(W,Q,F,1),JJ(U.d,H=R,V))do if(F+=10,W=s(Z,F),Q=K?qJ(q,F+10):s(J,F),U=w(W,Q,F,1),!Y){if(+k(U.d).slice(H+1,H+15)+1==100000000000000)U=N(U,R+1,0);break}while(JJ(U.d,H+=10,V));return O=!0,N(U,R,V)};G.minus=G.sub=function(J){var K,$,Q,H,Y,W,F,U,Z,q,R,V,z=this,T=z.constructor;if(J=new T(J),!z.d||!J.d){if(!z.s||!J.s)J=new T(NaN);else if(z.d)J.s=-J.s;else J=new T(J.d||z.s!==J.s?z:NaN);return J}if(z.s!=J.s)return J.s=-J.s,z.plus(J);if(Z=z.d,V=J.d,F=T.precision,U=T.rounding,!Z[0]||!V[0]){if(V[0])J.s=-J.s;else if(Z[0])J=new T(z);else return new T(U===3?-0:0);return O?N(J,F,U):J}if($=C(J.e/I),q=C(z.e/I),Z=Z.slice(),Y=q-$,Y){if(R=Y<0,R)K=Z,Y=-Y,W=V.length;else K=V,$=q,W=Z.length;if(Q=Math.max(Math.ceil(F/I),W)+2,Y>Q)Y=Q,K.length=1;K.reverse();for(Q=Y;Q--;)K.push(0);K.reverse()}else{if(Q=Z.length,W=V.length,R=Q<W,R)W=Q;for(Q=0;Q<W;Q++)if(Z[Q]!=V[Q]){R=Z[Q]<V[Q];break}Y=0}if(R)K=Z,Z=V,V=K,J.s=-J.s;W=Z.length;for(Q=V.length-W;Q>0;--Q)Z[W++]=0;for(Q=V.length;Q>Y;){if(Z[--Q]<V[Q]){for(H=Q;H&&Z[--H]===0;)Z[H]=c-1;--Z[H],Z[Q]+=c}Z[Q]-=V[Q]}for(;Z[--W]===0;)Z.pop();for(;Z[0]===0;Z.shift())--$;if(!Z[0])return new T(U===3?-0:0);return J.d=Z,J.e=VJ(Z,$),O?N(J,F,U):J};G.modulo=G.mod=function(J){var K,$=this,Q=$.constructor;if(J=new Q(J),!$.d||!J.s||J.d&&!J.d[0])return new Q(NaN);if(!J.d||$.d&&!$.d[0])return N(new Q($),Q.precision,Q.rounding);if(O=!1,Q.modulo==9)K=w($,J.abs(),0,3,1),K.s*=J.s;else K=w($,J,0,Q.modulo,1);return K=K.times(J),O=!0,$.minus(K)};G.naturalExponential=G.exp=function(){return AJ(this)};G.naturalLogarithm=G.ln=function(){return s(this)};G.negated=G.neg=function(){var J=new this.constructor(this);return J.s=-J.s,N(J)};G.plus=G.add=function(J){var K,$,Q,H,Y,W,F,U,Z,q,R=this,V=R.constructor;if(J=new V(J),!R.d||!J.d){if(!R.s||!J.s)J=new V(NaN);else if(!R.d)J=new V(J.d||R.s===J.s?R:NaN);return J}if(R.s!=J.s)return J.s=-J.s,R.minus(J);if(Z=R.d,q=J.d,F=V.precision,U=V.rounding,!Z[0]||!q[0]){if(!q[0])J=new V(R);return O?N(J,F,U):J}if(Y=C(R.e/I),Q=C(J.e/I),Z=Z.slice(),H=Y-Q,H){if(H<0)$=Z,H=-H,W=q.length;else $=q,Q=Y,W=Z.length;if(Y=Math.ceil(F/I),W=Y>W?Y+1:W+1,H>W)H=W,$.length=1;$.reverse();for(;H--;)$.push(0);$.reverse()}if(W=Z.length,H=q.length,W-H<0)H=W,$=q,q=Z,Z=$;for(K=0;H;)K=(Z[--H]=Z[H]+q[H]+K)/c|0,Z[H]%=c;if(K)Z.unshift(K),++Q;for(W=Z.length;Z[--W]==0;)Z.pop();return J.d=Z,J.e=VJ(Z,Q),O?N(J,F,U):J};G.precision=G.sd=function(J){var K,$=this;if(J!==void 0&&J!==!!J&&J!==1&&J!==0)throw Error(o+J);if($.d){if(K=mJ($.d),J&&$.e+1>K)K=$.e+1}else K=NaN;return K};G.round=function(){var J=this,K=J.constructor;return N(new K(J),J.e+1,K.rounding)};G.sine=G.sin=function(){var J,K,$=this,Q=$.constructor;if(!$.isFinite())return new Q(NaN);if($.isZero())return new Q($);return J=Q.precision,K=Q.rounding,Q.precision=J+Math.max($.e,$.sd())+I,Q.rounding=1,$=FK(Q,aJ(Q,$)),Q.precision=J,Q.rounding=K,N(n>2?$.neg():$,J,K,!0)};G.squareRoot=G.sqrt=function(){var J,K,$,Q,H,Y,W=this,F=W.d,U=W.e,Z=W.s,q=W.constructor;if(Z!==1||!F||!F[0])return new q(!Z||Z<0&&(!F||F[0])?NaN:F?W:1/0);if(O=!1,Z=Math.sqrt(+W),Z==0||Z==1/0){if(K=k(F),(K.length+U)%2==0)K+="0";if(Z=Math.sqrt(K),U=C((U+1)/2)-(U<0||U%2),Z==1/0)K="5e"+U;else K=Z.toExponential(),K=K.slice(0,K.indexOf("e")+1)+U;Q=new q(K)}else Q=new q(Z.toString());$=(U=q.precision)+3;for(;;)if(Y=Q,Q=Y.plus(w(W,Y,$+2,1)).times(0.5),k(Y.d).slice(0,$)===(K=k(Q.d)).slice(0,$))if(K=K.slice($-3,$+1),K=="9999"||!H&&K=="4999"){if(!H){if(N(Y,U+1,0),Y.times(Y).eq(W)){Q=Y;break}}$+=4,H=1}else{if(!+K||!+K.slice(1)&&K.charAt(0)=="5")N(Q,U+1,1),J=!Q.times(Q).eq(W);break}return O=!0,N(Q,U,q.rounding,J)};G.tangent=G.tan=function(){var J,K,$=this,Q=$.constructor;if(!$.isFinite())return new Q(NaN);if($.isZero())return new Q($);return J=Q.precision,K=Q.rounding,Q.precision=J+10,Q.rounding=1,$=$.sin(),$.s=1,$=w($,new Q(1).minus($.times($)).sqrt(),J+10,0),Q.precision=J,Q.rounding=K,N(n==2||n==4?$.neg():$,J,K,!0)};G.times=G.mul=function(J){var K,$,Q,H,Y,W,F,U,Z,q=this,R=q.constructor,V=q.d,z=(J=new R(J)).d;if(J.s*=q.s,!V||!V[0]||!z||!z[0])return new R(!J.s||V&&!V[0]&&!z||z&&!z[0]&&!V?NaN:!V||!z?J.s/0:J.s*0);if($=C(q.e/I)+C(J.e/I),U=V.length,Z=z.length,U<Z)Y=V,V=z,z=Y,W=U,U=Z,Z=W;Y=[],W=U+Z;for(Q=W;Q--;)Y.push(0);for(Q=Z;--Q>=0;){K=0;for(H=U+Q;H>Q;)F=Y[H]+z[Q]*V[H-Q-1]+K,Y[H--]=F%c|0,K=F/c|0;Y[H]=(Y[H]+K)%c|0}for(;!Y[--W];)Y.pop();if(K)++$;else Y.shift();return J.d=Y,J.e=VJ(Y,$),O?N(J,R.precision,R.rounding):J};G.toBinary=function(J,K){return wJ(this,2,J,K)};G.toDecimalPlaces=G.toDP=function(J,K){var $=this,Q=$.constructor;if($=new Q($),J===void 0)return $;if(v(J,0,x),K===void 0)K=Q.rounding;else v(K,0,8);return N($,J+$.e+1,K)};G.toExponential=function(J,K){var $,Q=this,H=Q.constructor;if(J===void 0)$=d(Q,!0);else{if(v(J,0,x),K===void 0)K=H.rounding;else v(K,0,8);Q=N(new H(Q),J+1,K),$=d(Q,!0,J+1)}return Q.isNeg()&&!Q.isZero()?"-"+$:$};G.toFixed=function(J,K){var $,Q,H=this,Y=H.constructor;if(J===void 0)$=d(H);else{if(v(J,0,x),K===void 0)K=Y.rounding;else v(K,0,8);Q=N(new Y(H),J+H.e+1,K),$=d(Q,!1,J+Q.e+1)}return H.isNeg()&&!H.isZero()?"-"+$:$};G.toFraction=function(J){var K,$,Q,H,Y,W,F,U,Z,q,R,V,z=this,T=z.d,B=z.constructor;if(!T)return new B(z);if(Z=$=new B(1),Q=U=new B(0),K=new B(Q),Y=K.e=mJ(T)-z.e-1,W=Y%I,K.d[0]=f(10,W<0?I+W:W),J==null)J=Y>0?K:Z;else{if(F=new B(J),!F.isInt()||F.lt(Z))throw Error(o+F);J=F.gt(K)?Y>0?K:Z:F}O=!1,F=new B(k(T)),q=B.precision,B.precision=Y=T.length*I*2;for(;;){if(R=w(F,K,0,1,1),H=$.plus(R.times(Q)),H.cmp(J)==1)break;$=Q,Q=H,H=Z,Z=U.plus(R.times(H)),U=H,H=K,K=F.minus(R.times(H)),F=H}return H=w(J.minus($),Q,0,1,1),U=U.plus(H.times(Z)),$=$.plus(H.times(Q)),U.s=Z.s=z.s,V=w(Z,Q,Y,1).minus(z).abs().cmp(w(U,$,Y,1).minus(z).abs())<1?[Z,Q]:[U,$],B.precision=q,O=!0,V};G.toHexadecimal=G.toHex=function(J,K){return wJ(this,16,J,K)};G.toNearest=function(J,K){var $=this,Q=$.constructor;if($=new Q($),J==null){if(!$.d)return $;J=new Q(1),K=Q.rounding}else{if(J=new Q(J),K===void 0)K=Q.rounding;else v(K,0,8);if(!$.d)return J.s?$:J;if(!J.d){if(J.s)J.s=$.s;return J}}if(J.d[0])O=!1,$=w($,J,0,K,1).times(J),O=!0,N($);else J.s=$.s,$=J;return $};G.toNumber=function(){return+this};G.toOctal=function(J,K){return wJ(this,8,J,K)};G.toPower=G.pow=function(J){var K,$,Q,H,Y,W,F=this,U=F.constructor,Z=+(J=new U(J));if(!F.d||!J.d||!F.d[0]||!J.d[0])return new U(f(+F,Z));if(F=new U(F),F.eq(1))return F;if(Q=U.precision,Y=U.rounding,J.eq(1))return N(F,Q,Y);if(K=C(J.e/I),K>=J.d.length-1&&($=Z<0?-Z:Z)<=QK)return H=sJ(U,F,$,Q),J.s<0?new U(1).div(H):N(H,Q,Y);if(W=F.s,W<0){if(K<J.d.length-1)return new U(NaN);if((J.d[K]&1)==0)W=1;if(F.e==0&&F.d[0]==1&&F.d.length==1)return F.s=W,F}if($=f(+F,Z),K=$==0||!isFinite($)?C(Z*(Math.log("0."+k(F.d))/Math.LN10+F.e+1)):new U($+"").e,K>U.maxE+1||K<U.minE-1)return new U(K>0?W/0:0);if(O=!1,U.rounding=F.s=1,$=Math.min(12,(K+"").length),H=AJ(J.times(s(F,Q+$)),Q),H.d){if(H=N(H,Q+5,1),JJ(H.d,Q,Y)){if(K=Q+10,H=N(AJ(J.times(s(F,K+$)),K),K+5,1),+k(H.d).slice(Q+1,Q+15)+1==100000000000000)H=N(H,Q+1,0)}}return H.s=W,O=!0,U.rounding=Y,N(H,Q,Y)};G.toPrecision=function(J,K){var $,Q=this,H=Q.constructor;if(J===void 0)$=d(Q,Q.e<=H.toExpNeg||Q.e>=H.toExpPos);else{if(v(J,1,x),K===void 0)K=H.rounding;else v(K,0,8);Q=N(new H(Q),J,K),$=d(Q,J<=Q.e||Q.e<=H.toExpNeg,J)}return Q.isNeg()&&!Q.isZero()?"-"+$:$};G.toSignificantDigits=G.toSD=function(J,K){var $=this,Q=$.constructor;if(J===void 0)J=Q.precision,K=Q.rounding;else if(v(J,1,x),K===void 0)K=Q.rounding;else v(K,0,8);return N(new Q($),J,K)};G.toString=function(){var J=this,K=J.constructor,$=d(J,J.e<=K.toExpNeg||J.e>=K.toExpPos);return J.isNeg()&&!J.isZero()?"-"+$:$};G.truncated=G.trunc=function(){return N(new this.constructor(this),this.e+1,1)};G.valueOf=G.toJSON=function(){var J=this,K=J.constructor,$=d(J,J.e<=K.toExpNeg||J.e>=K.toExpPos);return J.isNeg()?"-"+$:$};function k(J){var K,$,Q,H=J.length-1,Y="",W=J[0];if(H>0){Y+=W;for(K=1;K<H;K++){if(Q=J[K]+"",$=I-Q.length,$)Y+=m($);Y+=Q}if(W=J[K],Q=W+"",$=I-Q.length,$)Y+=m($)}else if(W===0)return"0";for(;W%10===0;)W/=10;return Y+W}function v(J,K,$){if(J!==~~J||J<K||J>$)throw Error(o+J)}function JJ(J,K,$,Q){var H,Y,W,F;for(Y=J[0];Y>=10;Y/=10)--K;if(--K<0)K+=I,H=0;else H=Math.ceil((K+1)/I),K%=I;if(Y=f(10,I-K),F=J[H]%Y|0,Q==null)if(K<3){if(K==0)F=F/100|0;else if(K==1)F=F/10|0;W=$<4&&F==99999||$>3&&F==49999||F==50000||F==0}else W=($<4&&F+1==Y||$>3&&F+1==Y/2)&&(J[H+1]/Y/100|0)==f(10,K-2)-1||(F==Y/2||F==0)&&(J[H+1]/Y/100|0)==0;else if(K<4){if(K==0)F=F/1000|0;else if(K==1)F=F/100|0;else if(K==2)F=F/10|0;W=(Q||$<4)&&F==9999||!Q&&$>3&&F==4999}else W=((Q||$<4)&&F+1==Y||!Q&&$>3&&F+1==Y/2)&&(J[H+1]/Y/1000|0)==f(10,K-3)-1;return W}function FJ(J,K,$){var Q,H=[0],Y,W=0,F=J.length;for(;W<F;){for(Y=H.length;Y--;)H[Y]*=K;H[0]+=TJ.indexOf(J.charAt(W++));for(Q=0;Q<H.length;Q++)if(H[Q]>$-1){if(H[Q+1]===void 0)H[Q+1]=0;H[Q+1]+=H[Q]/$|0,H[Q]%=$}}return H.reverse()}function YK(J,K){var $,Q,H;if(K.isZero())return K;if(Q=K.d.length,Q<32)$=Math.ceil(Q/3),H=(1/GJ(4,$)).toString();else $=16,H="2.3283064365386962890625e-10";J.precision+=$,K=t(J,1,K.times(H),new J(1));for(var Y=$;Y--;){var W=K.times(K);K=W.times(W).minus(W).times(8).plus(1)}return J.precision-=$,K}var w=function(){function J(Q,H,Y){var W,F=0,U=Q.length;for(Q=Q.slice();U--;)W=Q[U]*H+F,Q[U]=W%Y|0,F=W/Y|0;if(F)Q.unshift(F);return Q}function K(Q,H,Y,W){var F,U;if(Y!=W)U=Y>W?1:-1;else for(F=U=0;F<Y;F++)if(Q[F]!=H[F]){U=Q[F]>H[F]?1:-1;break}return U}function $(Q,H,Y,W){var F=0;for(;Y--;)Q[Y]-=F,F=Q[Y]<H[Y]?1:0,Q[Y]=F*W+Q[Y]-H[Y];for(;!Q[0]&&Q.length>1;)Q.shift()}return function(Q,H,Y,W,F,U){var Z,q,R,V,z,T,B,L,M,p,E,b,a,D,IJ,HJ,r,_J,y,YJ,WJ=Q.constructor,BJ=Q.s==H.s?1:-1,g=Q.d,S=H.d;if(!g||!g[0]||!S||!S[0])return new WJ(!Q.s||!H.s||(g?S&&g[0]==S[0]:!S)?NaN:g&&g[0]==0||!S?BJ*0:BJ/0);if(U)z=1,q=Q.e-H.e;else U=c,z=I,q=C(Q.e/z)-C(H.e/z);y=S.length,r=g.length,M=new WJ(BJ),p=M.d=[];for(R=0;S[R]==(g[R]||0);R++);if(S[R]>(g[R]||0))q--;if(Y==null)D=Y=WJ.precision,W=WJ.rounding;else if(F)D=Y+(Q.e-H.e)+1;else D=Y;if(D<0)p.push(1),T=!0;else{if(D=D/z+2|0,R=0,y==1){V=0,S=S[0],D++;for(;(R<r||V)&&D--;R++)IJ=V*U+(g[R]||0),p[R]=IJ/S|0,V=IJ%S|0;T=V||R<r}else{if(V=U/(S[0]+1)|0,V>1)S=J(S,V,U),g=J(g,V,U),y=S.length,r=g.length;HJ=y,E=g.slice(0,y),b=E.length;for(;b<y;)E[b++]=0;if(YJ=S.slice(),YJ.unshift(0),_J=S[0],S[1]>=U/2)++_J;do{if(V=0,Z=K(S,E,y,b),Z<0){if(a=E[0],y!=b)a=a*U+(E[1]||0);if(V=a/_J|0,V>1){if(V>=U)V=U-1;if(B=J(S,V,U),L=B.length,b=E.length,Z=K(B,E,L,b),Z==1)V--,$(B,y<L?YJ:S,L,U)}else{if(V==0)Z=V=1;B=S.slice()}if(L=B.length,L<b)B.unshift(0);if($(E,B,b,U),Z==-1){if(b=E.length,Z=K(S,E,y,b),Z<1)V++,$(E,y<b?YJ:S,b,U)}b=E.length}else if(Z===0)V++,E=[0];if(p[R++]=V,Z&&E[0])E[b++]=g[HJ]||0;else E=[g[HJ]],b=1}while((HJ++<r||E[0]!==void 0)&&D--);T=E[0]!==void 0}if(!p[0])p.shift()}if(z==1)M.e=q,yJ=T;else{for(R=1,V=p[0];V>=10;V/=10)R++;M.e=R+q*z-1,N(M,F?Y+M.e+1:Y,W,T)}return M}}();function N(J,K,$,Q){var H,Y,W,F,U,Z,q,R,V,z=J.constructor;J:if(K!=null){if(R=J.d,!R)return J;for(H=1,F=R[0];F>=10;F/=10)H++;if(Y=K-H,Y<0)Y+=I,W=K,q=R[V=0],U=q/f(10,H-W-1)%10|0;else if(V=Math.ceil((Y+1)/I),F=R.length,V>=F)if(Q){for(;F++<=V;)R.push(0);q=U=0,H=1,Y%=I,W=Y-I+1}else break J;else{q=F=R[V];for(H=1;F>=10;F/=10)H++;Y%=I,W=Y-I+H,U=W<0?0:q/f(10,H-W-1)%10|0}if(Q=Q||K<0||R[V+1]!==void 0||(W<0?q:q%f(10,H-W-1)),Z=$<4?(U||Q)&&($==0||$==(J.s<0?3:2)):U>5||U==5&&($==4||Q||$==6&&(Y>0?W>0?q/f(10,H-W):0:R[V-1])%10&1||$==(J.s<0?8:7)),K<1||!R[0]){if(R.length=0,Z)K-=J.e+1,R[0]=f(10,(I-K%I)%I),J.e=-K||0;else R[0]=J.e=0;return J}if(Y==0)R.length=V,F=1,V--;else R.length=V+1,F=f(10,I-Y),R[V]=W>0?(q/f(10,H-W)%f(10,W)|0)*F:0;if(Z)for(;;)if(V==0){for(Y=1,W=R[0];W>=10;W/=10)Y++;W=R[0]+=F;for(F=1;W>=10;W/=10)F++;if(Y!=F){if(J.e++,R[0]==c)R[0]=1}break}else{if(R[V]+=F,R[V]!=c)break;R[V--]=0,F=1}for(Y=R.length;R[--Y]===0;)R.pop()}if(O){if(J.e>z.maxE)J.d=null,J.e=NaN;else if(J.e<z.minE)J.e=0,J.d=[0]}return J}function d(J,K,$){if(!J.isFinite())return xJ(J);var Q,H=J.e,Y=k(J.d),W=Y.length;if(K){if($&&(Q=$-W)>0)Y=Y.charAt(0)+"."+Y.slice(1)+m(Q);else if(W>1)Y=Y.charAt(0)+"."+Y.slice(1);Y=Y+(J.e<0?"e":"e+")+J.e}else if(H<0){if(Y="0."+m(-H-1)+Y,$&&(Q=$-W)>0)Y+=m(Q)}else if(H>=W){if(Y+=m(H+1-W),$&&(Q=$-H-1)>0)Y=Y+"."+m(Q)}else{if((Q=H+1)<W)Y=Y.slice(0,Q)+"."+Y.slice(Q);if($&&(Q=$-W)>0){if(H+1===W)Y+=".";Y+=m(Q)}}return Y}function VJ(J,K){var $=J[0];for(K*=I;$>=10;$/=10)K++;return K}function qJ(J,K,$){if(K>HK){if(O=!0,$)J.precision=$;throw Error(cJ)}return N(new J(XJ),K,1,!0)}function l(J,K,$){if(K>EJ)throw Error(cJ);return N(new J(UJ),K,$,!0)}function mJ(J){var K=J.length-1,$=K*I+1;if(K=J[K],K){for(;K%10==0;K/=10)$--;for(K=J[0];K>=10;K/=10)$++}return $}function m(J){var K="";for(;J--;)K+="0";return K}function sJ(J,K,$,Q){var H,Y=new J(1),W=Math.ceil(Q/I+4);O=!1;for(;;){if($%2){if(Y=Y.times(K),pJ(Y.d,W))H=!0}if($=C($/2),$===0){if($=Y.d.length-1,H&&Y.d[$]===0)++Y.d[$];break}K=K.times(K),pJ(K.d,W)}return O=!0,Y}function uJ(J){return J.d[J.d.length-1]&1}function oJ(J,K,$){var Q,H,Y=new J(K[0]),W=0;for(;++W<K.length;){if(H=new J(K[W]),!H.s){Y=H;break}if(Q=Y.cmp(H),Q===$||Q===0&&Y.s===$)Y=H}return Y}function AJ(J,K){var $,Q,H,Y,W,F,U,Z=0,q=0,R=0,V=J.constructor,z=V.rounding,T=V.precision;if(!J.d||!J.d[0]||J.e>17)return new V(J.d?!J.d[0]?1:J.s<0?0:1/0:J.s?J.s<0?0:J:NaN);if(K==null)O=!1,U=T;else U=K;F=new V(0.03125);while(J.e>-2)J=J.times(F),R+=5;Q=Math.log(f(2,R))/Math.LN10*2+5|0,U+=Q,$=Y=W=new V(1),V.precision=U;for(;;){if(Y=N(Y.times(J),U,1),$=$.times(++q),F=W.plus(w(Y,$,U,1)),k(F.d).slice(0,U)===k(W.d).slice(0,U)){H=R;while(H--)W=N(W.times(W),U,1);if(K==null)if(Z<3&&JJ(W.d,U-Q,z,Z))V.precision=U+=10,$=Y=F=new V(1),q=0,Z++;else return N(W,V.precision=T,z,O=!0);else return V.precision=T,W}W=F}}function s(J,K){var $,Q,H,Y,W,F,U,Z,q,R,V,z=1,T=10,B=J,L=B.d,M=B.constructor,p=M.rounding,E=M.precision;if(B.s<0||!L||!L[0]||!B.e&&L[0]==1&&L.length==1)return new M(L&&!L[0]?-1/0:B.s!=1?NaN:L?0:B);if(K==null)O=!1,q=E;else q=K;if(M.precision=q+=T,$=k(L),Q=$.charAt(0),Math.abs(Y=B.e)<1500000000000000){while(Q<7&&Q!=1||Q==1&&$.charAt(1)>3)B=B.times(J),$=k(B.d),Q=$.charAt(0),z++;if(Y=B.e,Q>1)B=new M("0."+$),Y++;else B=new M(Q+"."+$.slice(1))}else return Z=qJ(M,q+2,E).times(Y+""),B=s(new M(Q+"."+$.slice(1)),q-T).plus(Z),M.precision=E,K==null?N(B,E,p,O=!0):B;R=B,U=W=B=w(B.minus(1),B.plus(1),q,1),V=N(B.times(B),q,1),H=3;for(;;){if(W=N(W.times(V),q,1),Z=U.plus(w(W,new M(H),q,1)),k(Z.d).slice(0,q)===k(U.d).slice(0,q)){if(U=U.times(2),Y!==0)U=U.plus(qJ(M,q+2,E).times(Y+""));if(U=w(U,new M(z),q,1),K==null)if(JJ(U.d,q-T,p,F))M.precision=q+=T,Z=W=B=w(R.minus(1),R.plus(1),q,1),V=N(B.times(B),q,1),H=F=1;else return N(U,M.precision=E,p,O=!0);else return M.precision=E,U}U=Z,H+=2}}function xJ(J){return String(J.s*J.s/0)}function ZJ(J,K){var $,Q,H;if(($=K.indexOf("."))>-1)K=K.replace(".","");if((Q=K.search(/e/i))>0){if($<0)$=Q;$+=+K.slice(Q+1),K=K.substring(0,Q)}else if($<0)$=K.length;for(Q=0;K.charCodeAt(Q)===48;Q++);for(H=K.length;K.charCodeAt(H-1)===48;--H);if(K=K.slice(Q,H),K){if(H-=Q,J.e=$=$-Q-1,J.d=[],Q=($+1)%I,$<0)Q+=I;if(Q<H){if(Q)J.d.push(+K.slice(0,Q));for(H-=I;Q<H;)J.d.push(+K.slice(Q,Q+=I));K=K.slice(Q),Q=I-K.length}else Q-=H;for(;Q--;)K+="0";if(J.d.push(+K),O){if(J.e>J.constructor.maxE)J.d=null,J.e=NaN;else if(J.e<J.constructor.minE)J.e=0,J.d=[0]}}else J.e=0,J.d=[0];return J}function WK(J,K){var $,Q,H,Y,W,F,U,Z,q;if(K.indexOf("_")>-1){if(K=K.replace(/(\d)_(?=\d)/g,"$1"),nJ.test(K))return ZJ(J,K)}else if(K==="Infinity"||K==="NaN"){if(!+K)J.s=NaN;return J.e=NaN,J.d=null,J}if(KK.test(K))$=16,K=K.toLowerCase();else if(JK.test(K))$=2;else if($K.test(K))$=8;else throw Error(o+K);if(Y=K.search(/p/i),Y>0)U=+K.slice(Y+1),K=K.substring(2,Y);else K=K.slice(2);if(Y=K.indexOf("."),W=Y>=0,Q=J.constructor,W)K=K.replace(".",""),F=K.length,Y=F-Y,H=sJ(Q,new Q($),Y,Y*2);Z=FJ(K,$,c),q=Z.length-1;for(Y=q;Z[Y]===0;--Y)Z.pop();if(Y<0)return new Q(J.s*0);if(J.e=VJ(Z,q),J.d=Z,O=!1,W)J=w(J,H,F*4);if(U)J=J.times(Math.abs(U)<54?f(2,U):KJ.pow(2,U));return O=!0,J}function FK(J,K){var $,Q=K.d.length;if(Q<3)return K.isZero()?K:t(J,2,K,K);$=1.4*Math.sqrt(Q),$=$>16?16:$|0,K=K.times(1/GJ(5,$)),K=t(J,2,K,K);var H,Y=new J(5),W=new J(16),F=new J(20);for(;$--;)H=K.times(K),K=K.times(Y.plus(H.times(W.times(H).minus(F))));return K}function t(J,K,$,Q,H){var Y,W,F,U,Z=1,q=J.precision,R=Math.ceil(q/I);O=!1,U=$.times($),F=new J(Q);for(;;){if(W=w(F.times(U),new J(K++*K++),q,1),F=H?Q.plus(W):Q.minus(W),Q=w(W.times(U),new J(K++*K++),q,1),W=F.plus(Q),W.d[R]!==void 0){for(Y=R;W.d[Y]===F.d[Y]&&Y--;);if(Y==-1)break}Y=F,F=Q,Q=W,W=Y,Z++}return O=!0,W.d.length=R+1,W}function GJ(J,K){var $=J;while(--K)$*=J;return $}function aJ(J,K){var $,Q=K.s<0,H=l(J,J.precision,1),Y=H.times(0.5);if(K=K.abs(),K.lte(Y))return n=Q?4:1,K;if($=K.divToInt(H),$.isZero())n=Q?3:2;else{if(K=K.minus($.times(H)),K.lte(Y))return n=uJ($)?Q?2:3:Q?4:1,K;n=uJ($)?Q?1:4:Q?3:2}return K.minus(H).abs()}function wJ(J,K,$,Q){var H,Y,W,F,U,Z,q,R,V,z=J.constructor,T=$!==void 0;if(T)if(v($,1,x),Q===void 0)Q=z.rounding;else v(Q,0,8);else $=z.precision,Q=z.rounding;if(!J.isFinite())q=xJ(J);else{if(q=d(J),W=q.indexOf("."),T){if(H=2,K==16)$=$*4-3;else if(K==8)$=$*3-2}else H=K;if(W>=0)q=q.replace(".",""),V=new z(1),V.e=q.length-W,V.d=FJ(d(V),10,H),V.e=V.d.length;R=FJ(q,10,H),Y=U=R.length;for(;R[--U]==0;)R.pop();if(!R[0])q=T?"0p+0":"0";else{if(W<0)Y--;else J=new z(J),J.d=R,J.e=Y,J=w(J,V,$,Q,0,H),R=J.d,Y=J.e,Z=yJ;if(W=R[$],F=H/2,Z=Z||R[$+1]!==void 0,Z=Q<4?(W!==void 0||Z)&&(Q===0||Q===(J.s<0?3:2)):W>F||W===F&&(Q===4||Z||Q===6&&R[$-1]&1||Q===(J.s<0?8:7)),R.length=$,Z){for(;++R[--$]>H-1;)if(R[$]=0,!$)++Y,R.unshift(1)}for(U=R.length;!R[U-1];--U);for(W=0,q="";W<U;W++)q+=TJ.charAt(R[W]);if(T){if(U>1)if(K==16||K==8){W=K==16?4:3;for(--U;U%W;U++)q+="0";R=FJ(q,H,K);for(U=R.length;!R[U-1];--U);for(W=1,q="1.";W<U;W++)q+=TJ.charAt(R[W])}else q=q.charAt(0)+"."+q.slice(1);q=q+(Y<0?"p":"p+")+Y}else if(Y<0){for(;++Y;)q="0"+q;q="0."+q}else if(++Y>U)for(Y-=U;Y--;)q+="0";else if(Y<U)q=q.slice(0,Y)+"."+q.slice(Y)}q=(K==16?"0x":K==2?"0b":K==8?"0o":"")+q}return J.s<0?"-"+q:q}function pJ(J,K){if(J.length>K)return J.length=K,!0}function ZK(J){return new this(J).abs()}function XK(J){return new this(J).acos()}function UK(J){return new this(J).acosh()}function qK(J,K){return new this(J).plus(K)}function RK(J){return new this(J).asin()}function VK(J){return new this(J).asinh()}function GK(J){return new this(J).atan()}function zK(J){return new this(J).atanh()}function NK(J,K){J=new this(J),K=new this(K);var $,Q=this.precision,H=this.rounding,Y=Q+4;if(!J.s||!K.s)$=new this(NaN);else if(!J.d&&!K.d)$=l(this,Y,1).times(K.s>0?0.25:0.75),$.s=J.s;else if(!K.d||J.isZero())$=K.s<0?l(this,Q,H):new this(0),$.s=J.s;else if(!J.d||K.isZero())$=l(this,Y,1).times(0.5),$.s=J.s;else if(K.s<0)this.precision=Y,this.rounding=1,$=this.atan(w(J,K,Y,1)),K=l(this,Y,1),this.precision=Q,this.rounding=H,$=J.s<0?$.minus(K):$.plus(K);else $=this.atan(w(J,K,Y,1));return $}function IK(J){return new this(J).cbrt()}function _K(J){return N(J=new this(J),J.e+1,2)}function BK(J,K,$){return new this(J).clamp(K,$)}function TK(J){if(!J||typeof J!=="object")throw Error(RJ+"Object expected");var K,$,Q,H=J.defaults===!0,Y=["precision",1,x,"rounding",0,8,"toExpNeg",-i,0,"toExpPos",0,i,"maxE",0,i,"minE",-i,0,"modulo",0,9];for(K=0;K<Y.length;K+=3){if($=Y[K],H)this[$]=OJ[$];if((Q=J[$])!==void 0)if(C(Q)===Q&&Q>=Y[K+1]&&Q<=Y[K+2])this[$]=Q;else throw Error(o+$+": "+Q)}if($="crypto",H)this[$]=OJ[$];if((Q=J[$])!==void 0)if(Q===!0||Q===!1||Q===0||Q===1)if(Q)if(typeof crypto!="undefined"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[$]=!0;else throw Error(lJ);else this[$]=!1;else throw Error(o+$+": "+Q);return this}function OK(J){return new this(J).cos()}function EK(J){return new this(J).cosh()}function iJ(J){var K,$,Q;function H(Y){var W,F,U,Z=this;if(!(Z instanceof H))return new H(Y);if(Z.constructor=H,DJ(Y)){if(Z.s=Y.s,O)if(!Y.d||Y.e>H.maxE)Z.e=NaN,Z.d=null;else if(Y.e<H.minE)Z.e=0,Z.d=[0];else Z.e=Y.e,Z.d=Y.d.slice();else Z.e=Y.e,Z.d=Y.d?Y.d.slice():Y.d;return}if(U=typeof Y,U==="number"){if(Y===0){Z.s=1/Y<0?-1:1,Z.e=0,Z.d=[0];return}if(Y<0)Y=-Y,Z.s=-1;else Z.s=1;if(Y===~~Y&&Y<1e7){for(W=0,F=Y;F>=10;F/=10)W++;if(O)if(W>H.maxE)Z.e=NaN,Z.d=null;else if(W<H.minE)Z.e=0,Z.d=[0];else Z.e=W,Z.d=[Y];else Z.e=W,Z.d=[Y];return}if(Y*0!==0){if(!Y)Z.s=NaN;Z.e=NaN,Z.d=null;return}return ZJ(Z,Y.toString())}if(U==="string"){if((F=Y.charCodeAt(0))===45)Y=Y.slice(1),Z.s=-1;else{if(F===43)Y=Y.slice(1);Z.s=1}return nJ.test(Y)?ZJ(Z,Y):WK(Z,Y)}if(U==="bigint"){if(Y<0)Y=-Y,Z.s=-1;else Z.s=1;return ZJ(Z,Y.toString())}throw Error(o+Y)}if(H.prototype=G,H.ROUND_UP=0,H.ROUND_DOWN=1,H.ROUND_CEIL=2,H.ROUND_FLOOR=3,H.ROUND_HALF_UP=4,H.ROUND_HALF_DOWN=5,H.ROUND_HALF_EVEN=6,H.ROUND_HALF_CEIL=7,H.ROUND_HALF_FLOOR=8,H.EUCLID=9,H.config=H.set=TK,H.clone=iJ,H.isDecimal=DJ,H.abs=ZK,H.acos=XK,H.acosh=UK,H.add=qK,H.asin=RK,H.asinh=VK,H.atan=GK,H.atanh=zK,H.atan2=NK,H.cbrt=IK,H.ceil=_K,H.clamp=BK,H.cos=OK,H.cosh=EK,H.div=AK,H.exp=wK,H.floor=SK,H.hypot=MK,H.ln=PK,H.log=fK,H.log10=bK,H.log2=jK,H.max=LK,H.min=kK,H.mod=gK,H.mul=CK,H.pow=hK,H.random=vK,H.round=uK,H.sign=pK,H.sin=DK,H.sinh=yK,H.sqrt=cK,H.sub=lK,H.sum=dK,H.tan=nK,H.tanh=mK,H.trunc=sK,J===void 0)J={};if(J){if(J.defaults!==!0){Q=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"];for(K=0;K<Q.length;)if(!J.hasOwnProperty($=Q[K++]))J[$]=this[$]}}return H.config(J),H}function AK(J,K){return new this(J).div(K)}function wK(J){return new this(J).exp()}function SK(J){return N(J=new this(J),J.e+1,3)}function MK(){var J,K,$=new this(0);O=!1;for(J=0;J<arguments.length;)if(K=new this(arguments[J++]),!K.d){if(K.s)return O=!0,new this(1/0);$=K}else if($.d)$=$.plus(K.times(K));return O=!0,$.sqrt()}function DJ(J){return J instanceof KJ||J&&J.toStringTag===dJ||!1}function PK(J){return new this(J).ln()}function fK(J,K){return new this(J).log(K)}function jK(J){return new this(J).log(2)}function bK(J){return new this(J).log(10)}function LK(){return oJ(this,arguments,-1)}function kK(){return oJ(this,arguments,1)}function gK(J,K){return new this(J).mod(K)}function CK(J,K){return new this(J).mul(K)}function hK(J,K){return new this(J).pow(K)}function vK(J){var K,$,Q,H,Y=0,W=new this(1),F=[];if(J===void 0)J=this.precision;else v(J,1,x);if(Q=Math.ceil(J/I),!this.crypto)for(;Y<Q;)F[Y++]=Math.random()*1e7|0;else if(crypto.getRandomValues){K=crypto.getRandomValues(new Uint32Array(Q));for(;Y<Q;)if(H=K[Y],H>=4290000000)K[Y]=crypto.getRandomValues(new Uint32Array(1))[0];else F[Y++]=H%1e7}else if(crypto.randomBytes){K=crypto.randomBytes(Q*=4);for(;Y<Q;)if(H=K[Y]+(K[Y+1]<<8)+(K[Y+2]<<16)+((K[Y+3]&127)<<24),H>=2140000000)crypto.randomBytes(4).copy(K,Y);else F.push(H%1e7),Y+=4;Y=Q/4}else throw Error(lJ);if(Q=F[--Y],J%=I,Q&&J)H=f(10,I-J),F[Y]=(Q/H|0)*H;for(;F[Y]===0;Y--)F.pop();if(Y<0)$=0,F=[0];else{$=-1;for(;F[0]===0;$-=I)F.shift();for(Q=1,H=F[0];H>=10;H/=10)Q++;if(Q<I)$-=I-Q}return W.e=$,W.d=F,W}function uK(J){return N(J=new this(J),J.e+1,this.rounding)}function pK(J){return J=new this(J),J.d?J.d[0]?J.s:0*J.s:J.s||NaN}function DK(J){return new this(J).sin()}function yK(J){return new this(J).sinh()}function cK(J){return new this(J).sqrt()}function lK(J,K){return new this(J).sub(K)}function dK(){var J=0,K=arguments,$=new this(K[J]);O=!1;for(;$.s&&++J<K.length;)$=$.plus(K[J]);return O=!0,N($,this.precision,this.rounding)}function nK(J){return new this(J).tan()}function mK(J){return new this(J).tanh()}function sK(J){return N(J=new this(J),J.e+1,1)}G[Symbol.for("nodejs.util.inspect.custom")]=G.toString;G[Symbol.toStringTag]="Decimal";var KJ=G.constructor=iJ(OJ);XJ=new KJ(XJ);UJ=new KJ(UJ);var X=KJ;var SJ=(J)=>{if(J===null||J===void 0)throw new Error(`Cannot convert ${J===null?"null":"undefined"} to Decimal`);if(J instanceof X)return J;try{return new X(J)}catch(K){throw new Error(`Invalid numeric value: ${K.message}`)}};class A{constructor(J){if(!Array.isArray(J))throw new Error("Vector requires array");if(J.length===0)throw new Error("Vector requires at least one component");try{this.data=J.map((K,$)=>{if(K===null||K===void 0)throw new Error(`Vector component at index ${$} is ${K===null?"null":"undefined"}`);return SJ(K)})}catch(K){throw new Error(`Vector constructor failed: ${K.message}`)}this.length=this.data.length}static from(J){if(J===null||J===void 0)throw new Error(`Vector.from: argument is ${J===null?"null":"undefined"}`);return new A(J)}clone(){return new A(this.data.map((J)=>new X(J)))}toArray(){return this.data.slice()}toNumberArray(){return this.data.map((J)=>J.toNumber())}toStringArray(){return this.data.map((J)=>J.toString())}add(J){if(!J||!(J instanceof A))throw new Error("add: argument must be a Vector");if(this.length!==J.length)throw new Error(`add: dimension mismatch (${this.length} vs ${J.length})`);return new A(this.data.map((K,$)=>K.plus(J.data[$])))}sub(J){if(!J||!(J instanceof A))throw new Error("sub: argument must be a Vector");if(this.length!==J.length)throw new Error(`sub: dimension mismatch (${this.length} vs ${J.length})`);return new A(this.data.map((K,$)=>K.minus(J.data[$])))}scale(J){if(J===null||J===void 0)throw new Error(`scale: scalar is ${J===null?"null":"undefined"}`);let K;try{K=SJ(J)}catch($){throw new Error(`scale: invalid scalar - ${$.message}`)}return new A(this.data.map(($)=>$.mul(K)))}negate(){return new A(this.data.map((J)=>J.negated()))}dot(J){if(!J||!(J instanceof A))throw new Error("dot: argument must be a Vector");if(this.length!==J.length)throw new Error(`dot: dimension mismatch (${this.length} vs ${J.length})`);return this.data.reduce((K,$,Q)=>K.plus($.mul(J.data[Q])),new X(0))}outer(J){if(!J||!(J instanceof A))throw new Error("outer: argument must be a Vector");if(this.length===0||J.length===0)throw new Error("outer: cannot compute outer product with empty vector");let K=this.length,$=J.length;return Array.from({length:K},(H,Y)=>Array.from({length:$},(W,F)=>this.data[Y].mul(J.data[F])))}cross(J){if(!J||!(J instanceof A))throw new Error("cross: argument must be a Vector");if(this.length!==3||J.length!==3)throw new Error(`cross: requires 3D vectors (got ${this.length}D and ${J.length}D)`);let[K,$,Q]=this.data,[H,Y,W]=J.data;return new A([$.mul(W).minus(Q.mul(Y)),Q.mul(H).minus(K.mul(W)),K.mul(Y).minus($.mul(H))])}norm(){let J=new X(0);for(let K of this.data)J=J.plus(K.mul(K));return J.sqrt()}normalize(){let J=this.norm();if(J.isZero())throw new Error("Cannot normalize zero vector");return this.scale(new X(1).div(J))}angleBetween(J){if(!J||!(J instanceof A))throw new Error("angleBetween: argument must be a Vector");if(this.length!==J.length)throw new Error(`angleBetween: dimension mismatch (${this.length} vs ${J.length})`);let K=this.dot(J),$=this.norm(),Q=J.norm();if($.isZero()||Q.isZero())throw new Error("angleBetween: angle with zero vector is undefined");let Y=K.div($.mul(Q)).toNumber(),W=Math.min(1,Math.max(-1,Y));return new X(Math.acos(W))}projectOnto(J){if(!J||!(J instanceof A))throw new Error("projectOnto: argument must be a Vector");if(this.length!==J.length)throw new Error(`projectOnto: dimension mismatch (${this.length} vs ${J.length})`);let K=J.dot(J);if(K.isZero())throw new Error("projectOnto: cannot project onto zero vector");let $=this.dot(J).div(K);return J.scale($)}orthogonal(){if(this.norm().isZero())throw new Error("orthogonal: cannot find orthogonal vector to zero vector");if(this.length===2)return new A([this.data[1].negated(),this.data[0]]);for(let K=0;K<this.length;K++){let $=Array.from({length:this.length},(F,U)=>new X(U===K?1:0)),Q=new A($),H=Q.projectOnto(this),Y=Q.sub(H);if(!Y.norm().isZero())return Y.normalize()}throw new Error("orthogonal: unable to find orthogonal vector (degenerate case)")}isOrthogonalTo(J){if(!J||!(J instanceof A))throw new Error("isOrthogonalTo: argument must be a Vector");if(this.length!==J.length)throw new Error(`isOrthogonalTo: dimension mismatch (${this.length} vs ${J.length})`);return this.dot(J).isZero()}distance(J){if(!J||!(J instanceof A))throw new Error("distance: argument must be a Vector");if(this.length!==J.length)throw new Error(`distance: dimension mismatch (${this.length} vs ${J.length})`);return this.sub(J).norm()}equals(J,K=0){if(!(J instanceof A))return!1;if(J.length!==this.length)return!1;if(K===null)throw new Error("equals: tolerance cannot be null");let $;try{if($=SJ(K),$.isNaN())throw new Error("equals: tolerance cannot be NaN");if($.isNegative())throw new Error("equals: tolerance must be non-negative")}catch(Q){throw new Error(`equals: invalid tolerance - ${Q.message}`)}for(let Q=0;Q<this.length;Q++)if(this.data[Q].minus(J.data[Q]).abs().greaterThan($))return!1;return!0}}var e=(J)=>{if(J==null)throw new Error("Cannot convert null or undefined to Decimal");return J instanceof X?J:new X(J)};class _{constructor(J){if(!Array.isArray(J)||J.length===0)throw new Error("Matrix requires non-empty 2D array");if(!Array.isArray(J[0])||J[0].length===0)throw new Error("Matrix rows must be non-empty arrays");let K=J[0].length;for(let $ of J)if(!Array.isArray($)||$.length!==K)throw new Error("All rows must have same length");this.data=J.map(($)=>$.map((Q)=>e(Q))),this.rows=J.length,this.cols=K}static from(J){return new _(J)}static zeros(J,K){if(!Number.isInteger(J)||J<=0)throw new Error("rows must be a positive integer");if(!Number.isInteger(K)||K<=0)throw new Error("cols must be a positive integer");let $=Array.from({length:J},()=>Array.from({length:K},()=>new X(0)));return new _($)}static identity(J){if(!Number.isInteger(J)||J<=0)throw new Error("size must be a positive integer");let K=Array.from({length:J},($,Q)=>Array.from({length:J},(H,Y)=>Q===Y?new X(1):new X(0)));return new _(K)}clone(){return new _(this.data.map((J)=>J.map((K)=>new X(K))))}toArrayOfStrings(){return this.data.map((J)=>J.map((K)=>K.toString()))}toNumberArray(){return this.data.map((J)=>J.map((K)=>K.toNumber()))}isSquare(){return this.rows===this.cols}applyToVector(J){let K;if(J instanceof A)K=J;else if(Array.isArray(J))K=A.from(J);else throw new Error("applyToVector expects Vector or array");if(this.cols!==K.length)throw new Error("shape mismatch: matrix cols must equal vector length");let $=[];for(let Q=0;Q<this.rows;Q++){let H=new X(0);for(let Y=0;Y<this.cols;Y++)H=H.plus(this.data[Q][Y].mul(K.data[Y]));$.push(H)}return new A($)}add(J){if(J instanceof _){if(this.rows!==J.rows||this.cols!==J.cols)throw new Error("shape mismatch: matrices must have same dimensions");return new _(this.data.map((K,$)=>K.map((Q,H)=>Q.plus(J.data[$][H]))))}else{let K=e(J);return new _(this.data.map(($)=>$.map((Q)=>Q.plus(K))))}}sub(J){if(J instanceof _){if(this.rows!==J.rows||this.cols!==J.cols)throw new Error("shape mismatch: matrices must have same dimensions");return new _(this.data.map((K,$)=>K.map((Q,H)=>Q.minus(J.data[$][H]))))}else{let K=e(J);return new _(this.data.map(($)=>$.map((Q)=>Q.minus(K))))}}mul(J){if(J instanceof _){if(this.cols!==J.rows)throw new Error("shape mismatch: A.cols must equal B.rows for matrix multiplication");let K=Array.from({length:this.rows},()=>Array.from({length:J.cols},()=>new X(0)));for(let $=0;$<this.rows;$++)for(let Q=0;Q<this.cols;Q++){let H=this.data[$][Q];if(H.isZero())continue;for(let Y=0;Y<J.cols;Y++)K[$][Y]=K[$][Y].plus(H.mul(J.data[Q][Y]))}return new _(K)}else{let K=e(J);return new _(this.data.map(($)=>$.map((Q)=>Q.mul(K))))}}div(J){let K=e(J);if(K.isZero())throw new Error("Cannot divide by zero");return new _(this.data.map(($)=>$.map((Q)=>Q.div(K))))}negate(){return new _(this.data.map((J)=>J.map((K)=>K.negated())))}transpose(){let J=Array.from({length:this.cols},(K,$)=>Array.from({length:this.rows},(Q,H)=>new X(this.data[H][$])));return new _(J)}trace(){if(!this.isSquare())throw new Error("Trace only defined for square matrices");let J=new X(0);for(let K=0;K<this.rows;K++)J=J.plus(this.data[K][K]);return J}equals(J,K=0){if(!(J instanceof _))return!1;if(this.rows!==J.rows||this.cols!==J.cols)return!1;let $=e(K);if($.isNegative()||!$.isFinite())throw new Error("tolerance must be non-negative and finite");for(let Q=0;Q<this.rows;Q++)for(let H=0;H<this.cols;H++)if(this.data[Q][H].minus(J.data[Q][H]).abs().greaterThan($))return!1;return!0}lu(){if(!this.isSquare())throw new Error("LU decomposition requires square matrix");let J=this.rows,K=this.data.map((W)=>W.map((F)=>new X(F))),$=Array.from({length:J},(W,F)=>F),Q=Array.from({length:J},()=>Array.from({length:J},()=>new X(0)));for(let W=0;W<J;W++)Q[W][W]=new X(1);for(let W=0;W<J;W++){let F=W,U=K[W][W].abs();for(let Z=W+1;Z<J;Z++){let q=K[Z][W].abs();if(q.greaterThan(U))U=q,F=Z}if(K[F][W].isZero())throw new Error("Singular matrix: LU decomposition failed");if(F!==W){let Z=K[W];K[W]=K[F],K[F]=Z;let q=$[W];$[W]=$[F],$[F]=q;for(let R=0;R<W;R++){let V=Q[W][R];Q[W][R]=Q[F][R],Q[F][R]=V}}for(let Z=W+1;Z<J;Z++){let q=K[Z][W].div(K[W][W]);Q[Z][W]=q;for(let R=W;R<J;R++)K[Z][R]=K[Z][R].minus(q.mul(K[W][R]))}}let H=Array.from({length:J},(W,F)=>Array.from({length:J},(U,Z)=>Z<F?new X(0):K[F][Z])),Y=_.zeros(J,J);for(let W=0;W<J;W++)Y.data[W][$[W]]=new X(1);return{L:new _(Q),U:new _(H),P:Y}}determinant(){if(!this.isSquare())throw new Error("Determinant only defined for square matrices");let J=this.rows,{L:K,U:$,P:Q}=this.lu(),H=new X(1);for(let F=0;F<J;F++)H=H.mul($.data[F][F]);let Y=[];for(let F=0;F<J;F++)for(let U=0;U<J;U++)if(Q.data[F][U].equals(1))Y.push(U);let W=0;for(let F=0;F<Y.length;F++)for(let U=F+1;U<Y.length;U++)if(Y[F]>Y[U])W++;if(W%2===1)H=H.negated();return H}inverse(){if(!this.isSquare())throw new Error("Inverse only defined for square matrices");let J=this.rows,K=Array.from({length:J},(Q,H)=>Array.from({length:2*J},(Y,W)=>W<J?new X(this.data[H][W]):W-J===H?new X(1):new X(0)));for(let Q=0;Q<J;Q++){let H=Q,Y=K[Q][Q].abs();for(let F=Q+1;F<J;F++){let U=K[F][Q].abs();if(U.greaterThan(Y))Y=U,H=F}if(K[H][Q].isZero())throw new Error("Singular matrix: inverse does not exist");if(H!==Q){let F=K[Q];K[Q]=K[H],K[H]=F}let W=K[Q][Q];for(let F=0;F<2*J;F++)K[Q][F]=K[Q][F].div(W);for(let F=0;F<J;F++){if(F===Q)continue;let U=K[F][Q];if(U.isZero())continue;for(let Z=0;Z<2*J;Z++)K[F][Z]=K[F][Z].minus(U.mul(K[Q][Z]))}}let $=K.map((Q)=>Q.slice(J));return new _($)}solve(J){let K;if(J instanceof A)K=J;else if(Array.isArray(J))K=A.from(J);else throw new Error("b must be Vector or array");if(!this.isSquare())throw new Error("solve() only implemented for square matrices");let $=this.rows;if(K.length!==$)throw new Error("dimension mismatch: b length must equal matrix rows");let Q=Array.from({length:$},(Y,W)=>Array.from({length:$+1},(F,U)=>new X(U<$?this.data[W][U]:K.data[W])));for(let Y=0;Y<$;Y++){let W=Y,F=Q[Y][Y].abs();for(let U=Y+1;U<$;U++){let Z=Q[U][Y].abs();if(Z.greaterThan(F))F=Z,W=U}if(Q[W][Y].isZero())throw new Error("Singular matrix: no unique solution");if(W!==Y){let U=Q[Y];Q[Y]=Q[W],Q[W]=U}for(let U=Y+1;U<$;U++){let Z=Q[U][Y].div(Q[Y][Y]);if(Z.isZero())continue;for(let q=Y;q<$+1;q++)Q[U][q]=Q[U][q].minus(Z.mul(Q[Y][q]))}}let H=Array.from({length:$},()=>new X(0));for(let Y=$-1;Y>=0;Y--){if(Q[Y][Y].isZero())throw new Error("Zero diagonal element in back substitution: system is singular");let W=new X(0);for(let F=Y+1;F<$;F++)W=W.plus(Q[Y][F].mul(H[F]));H[Y]=Q[Y][$].minus(W).div(Q[Y][Y])}return new A(H)}qr(){let J=this.rows,K=this.cols,$=this.data.map((Y)=>Y.map((W)=>new X(W))),Q=_.identity(J).data;for(let Y=0;Y<Math.min(J,K);Y++){let W=[];for(let R=Y;R<J;R++)W.push($[R][Y]);let F=new X(0);for(let R of W)F=F.plus(R.mul(R));if(F=F.sqrt(),F.isZero())continue;let U=W[0].isNegative()?new X(-1):new X(1),Z=W.slice();Z[0]=Z[0].plus(U.mul(F));let q=new X(0);for(let R of Z)q=q.plus(R.mul(R));if(q=q.sqrt(),q.isZero())continue;for(let R=0;R<Z.length;R++)Z[R]=Z[R].div(q);for(let R=Y;R<K;R++){let V=new X(0);for(let z=0;z<Z.length;z++)V=V.plus(Z[z].mul($[Y+z][R]));for(let z=0;z<Z.length;z++)$[Y+z][R]=$[Y+z][R].minus(new X(2).mul(Z[z]).mul(V))}for(let R=0;R<J;R++){let V=new X(0);for(let z=0;z<Z.length;z++)V=V.plus(Z[z].mul(Q[Y+z][R]));for(let z=0;z<Z.length;z++)Q[Y+z][R]=Q[Y+z][R].minus(new X(2).mul(Z[z]).mul(V))}}let H=Array.from({length:J},(Y,W)=>Array.from({length:K},(F,U)=>W<=U?$[W][U]:new X(0)));return{Q:new _(Q).transpose(),R:new _(H)}}exp(J={}){let K=this.rows;if(!this.isSquare())throw new Error("Matrix exponential requires square matrix");let $=_.identity(K),Q=J.maxIter||120;if(!Number.isInteger(Q)||Q<=0)throw new Error("maxIter must be a positive integer");let H=new X(J.tolerance||"1e-40");if(H.isNegative()||H.isZero()||!H.isFinite())throw new Error("tolerance must be positive and finite");let W=((R)=>{let V=new X(0);for(let z=0;z<R.rows;z++){let T=new X(0);for(let B=0;B<R.cols;B++)T=T.plus(R.data[z][B].abs());if(T.greaterThan(V))V=T}return V})(this),F=0;if(W.greaterThan(new X(1))){let R=W.toNumber();if(!isFinite(R))throw new Error("Matrix norm too large for exponential computation");if(F=Math.max(0,Math.ceil(Math.log2(R))),F>50)throw new Error(`Matrix norm too large: requires ${F} scaling steps (max 50 allowed)`)}let U=this;if(F>0)U=this.mul(new X(1).div(new X(2).pow(F)));let Z=$.clone(),q=$.clone();for(let R=1;R<Q;R++){Z=Z.mul(U).mul(new X(1).div(R)),q=q.add(Z);let V=new X(0);for(let z=0;z<Z.rows;z++)for(let T=0;T<Z.cols;T++)V=V.plus(Z.data[z][T].abs());if(V.lessThan(H))break}for(let R=0;R<F;R++)q=q.mul(q);return q}}var jJ={};vJ(jJ,{translation:()=>$J,stretchAlongAxis:()=>xK,skew:()=>PJ,scale:()=>MJ,rotateAroundPoint:()=>oK,rotate:()=>zJ,reflectY:()=>iK,reflectX:()=>aK,reflectOrigin:()=>tK,applyTransform:()=>fJ});var u=(J)=>{if(J instanceof X){if(!J.isFinite())throw new Error(`Value must be finite (got ${J.toString()})`);return J}try{let K=new X(J);if(!K.isFinite())throw new Error(`Value must be finite (got ${J})`);return K}catch(K){throw new Error(`Invalid numeric value: "${J}" (${K.message})`)}};function h(J,K){if(J===void 0||J===null)throw new Error(`${K} is required`);if(typeof J!=="number"&&typeof J!=="string"&&!(J instanceof X))throw new Error(`${K} must be a number, string, or Decimal`);if(typeof J==="number"&&!isFinite(J))throw new Error(`${K} must be a finite number (got ${J})`);if(J instanceof X&&!J.isFinite())throw new Error(`${K} must be a finite Decimal (got ${J.toString()})`)}function $J(J,K){return h(J,"tx"),h(K,"ty"),_.from([[new X(1),new X(0),u(J)],[new X(0),new X(1),u(K)],[new X(0),new X(0),new X(1)]])}function MJ(J,K=null){if(h(J,"sx"),K!==null)h(K,"sy");let $=K===null?J:K,Q=u(J),H=u($);if(Q.isZero()||H.isZero())throw new Error("Scale factors cannot be zero (creates singular matrix)");return _.from([[Q,new X(0),new X(0)],[new X(0),H,new X(0)],[new X(0),new X(0),new X(1)]])}function zJ(J){h(J,"theta");let $=u(J).toNumber(),Q=Math.PI,H=$-2*Q*Math.floor(($+Q)/(2*Q));if(!isFinite(H))throw new Error(`Angle normalization failed for theta=${J} (too large or invalid)`);let Y=new X(Math.cos(H)),W=new X(Math.sin(H));if(!Y.isFinite()||!W.isFinite())throw new Error(`Trigonometric computation failed for theta=${J} (produced non-finite values)`);return _.from([[Y,W.negated(),new X(0)],[W,Y,new X(0)],[new X(0),new X(0),new X(1)]])}function oK(J,K,$){h(J,"theta"),h(K,"px"),h($,"py");let Q=u(K),H=u($);return $J(Q,H).mul(zJ(J)).mul($J(Q.negated(),H.negated()))}function PJ(J,K){h(J,"ax"),h(K,"ay");let $=u(J),Q=u(K);if(new X(1).minus($.mul(Q)).lessThanOrEqualTo(0))throw new Error(`Skew parameters create singular or orientation-inverting matrix (ax*ay = ${$.mul(Q).toString()}, must be < 1)`);return _.from([[new X(1),$,new X(0)],[Q,new X(1),new X(0)],[new X(0),new X(0),new X(1)]])}function xK(J,K,$){h(J,"ux"),h(K,"uy"),h($,"k");let Q=u(J),H=u(K),Y=u($);if(Y.isZero())throw new Error("Stretch factor k cannot be zero (creates singular matrix)");let W=Q.mul(Q).plus(H.mul(H));if(W.isZero())throw new Error("Axis vector (ux, uy) cannot be zero");let F=W.minus(1).abs(),U=new X(0.000001);if(F.greaterThan(U))throw new Error(`Axis vector (ux, uy) must be normalized (||u|| = 1). Current magnitude squared: ${W.toString()}, expected: 1. Use normalized vector: (${Q.div(W.sqrt()).toString()}, ${H.div(W.sqrt()).toString()})`);let Z=new X(1),q=Y.minus(Z),R=Z.plus(q.mul(Q.mul(Q))),V=q.mul(Q.mul(H)),z=q.mul(H.mul(Q)),T=Z.plus(q.mul(H.mul(H)));return _.from([[R,V,new X(0)],[z,T,new X(0)],[new X(0),new X(0),new X(1)]])}function fJ(J,K,$){if(!J||typeof J.mul!=="function")throw new Error("applyTransform: first argument must be a Matrix");if(!J.data||!Array.isArray(J.data)||J.data.length!==3||!J.data[0]||J.data[0].length!==3||!J.data[1]||J.data[1].length!==3||!J.data[2]||J.data[2].length!==3)throw new Error("applyTransform: matrix must be 3x3");h(K,"x"),h($,"y");let Q=_.from([[u(K)],[u($)],[new X(1)]]),H=J.mul(Q);if(!H||!H.data||!Array.isArray(H.data)||H.data.length!==3||!H.data[0]||!H.data[0][0]||!H.data[1]||!H.data[1][0]||!H.data[2]||!H.data[2][0])throw new Error("applyTransform: matrix multiplication produced invalid result");let Y=H.data[0][0],W=H.data[1][0],F=H.data[2][0];if(F.isZero())throw new Error("applyTransform: perspective division by zero (invalid transformation matrix)");return[Y.div(F),W.div(F)]}function aK(){return _.from([[new X(1),new X(0),new X(0)],[new X(0),new X(-1),new X(0)],[new X(0),new X(0),new X(1)]])}function iK(){return _.from([[new X(-1),new X(0),new X(0)],[new X(0),new X(1),new X(0)],[new X(0),new X(0),new X(1)]])}function tK(){return _.from([[new X(-1),new X(0),new X(0)],[new X(0),new X(-1),new X(0)],[new X(0),new X(0),new X(1)]])}var hJ={};vJ(hJ,{translation:()=>QJ,scale:()=>bJ,rotateZ:()=>gJ,rotateY:()=>kJ,rotateX:()=>LJ,rotateAroundPoint:()=>eK,rotateAroundAxis:()=>tJ,reflectYZ:()=>K$,reflectXZ:()=>J$,reflectXY:()=>rK,reflectOrigin:()=>$$,applyTransform:()=>CJ});var j=(J)=>{if(J instanceof X)return J;try{let K=new X(J);if(!K.isFinite())throw new Error(`Value must be finite, got ${J}`);return K}catch(K){throw new Error(`Invalid numeric value: ${J}`)}};function P(J,K){if(J===void 0||J===null)throw new Error(`${K} is required`);if(typeof J!=="number"&&typeof J!=="string"&&!(J instanceof X))throw new Error(`${K} must be a number, string, or Decimal`)}function NJ(J){let K=J.toNumber();if(!Number.isFinite(K))throw new Error(`Angle must be finite, got ${J}`);if(Math.abs(K)<=6.283185307179586)return K;let $=6.283185307179586,Q=K%$;if(Q>$)Q-=$;else if(Q<-$)Q+=$;return Q}function QJ(J,K,$){return P(J,"tx"),P(K,"ty"),P($,"tz"),_.from([[new X(1),new X(0),new X(0),j(J)],[new X(0),new X(1),new X(0),j(K)],[new X(0),new X(0),new X(1),j($)],[new X(0),new X(0),new X(0),new X(1)]])}function bJ(J,K=null,$=null){if(P(J,"sx"),K!==null)P(K,"sy");if($!==null)P($,"sz");let Q=K===null?J:K,H=$===null?J:$,Y=j(J),W=j(Q),F=j(H);if(Y.isZero()||W.isZero()||F.isZero());return _.from([[Y,new X(0),new X(0),new X(0)],[new X(0),W,new X(0),new X(0)],[new X(0),new X(0),F,new X(0)],[new X(0),new X(0),new X(0),new X(1)]])}function LJ(J){P(J,"theta");let K=j(J),$=NJ(K),Q=new X(Math.cos($)),H=new X(Math.sin($));return _.from([[new X(1),new X(0),new X(0),new X(0)],[new X(0),Q,H.negated(),new X(0)],[new X(0),H,Q,new X(0)],[new X(0),new X(0),new X(0),new X(1)]])}function kJ(J){P(J,"theta");let K=j(J),$=NJ(K),Q=new X(Math.cos($)),H=new X(Math.sin($));return _.from([[Q,new X(0),H,new X(0)],[new X(0),new X(1),new X(0),new X(0)],[H.negated(),new X(0),Q,new X(0)],[new X(0),new X(0),new X(0),new X(1)]])}function gJ(J){P(J,"theta");let K=j(J),$=NJ(K),Q=new X(Math.cos($)),H=new X(Math.sin($));return _.from([[Q,H.negated(),new X(0),new X(0)],[H,Q,new X(0),new X(0)],[new X(0),new X(0),new X(1),new X(0)],[new X(0),new X(0),new X(0),new X(1)]])}function tJ(J,K,$,Q){P(J,"ux"),P(K,"uy"),P($,"uz"),P(Q,"theta");let H=[j(J),j(K),j($)],Y=H[0].mul(H[0]).plus(H[1].mul(H[1])).plus(H[2].mul(H[2])).sqrt();if(Y.isZero())throw new Error("Rotation axis cannot be zero vector (ux=0, uy=0, uz=0)");H[0]=H[0].div(Y),H[1]=H[1].div(Y),H[2]=H[2].div(Y);let W=j(Q),F=NJ(W),U=new X(Math.cos(F)),Z=new X(Math.sin(F)),q=new X(1),R=H[0].mul(H[0]),V=H[1].mul(H[1]),z=H[2].mul(H[2]),T=R.plus(U.mul(q.minus(R))),B=H[0].mul(H[1]).mul(q.minus(U)).minus(H[2].mul(Z)),L=H[0].mul(H[2]).mul(q.minus(U)).plus(H[1].mul(Z)),M=H[1].mul(H[0]).mul(q.minus(U)).plus(H[2].mul(Z)),p=V.plus(U.mul(q.minus(V))),E=H[1].mul(H[2]).mul(q.minus(U)).minus(H[0].mul(Z)),b=H[2].mul(H[0]).mul(q.minus(U)).minus(H[1].mul(Z)),a=H[2].mul(H[1]).mul(q.minus(U)).plus(H[0].mul(Z)),D=z.plus(U.mul(q.minus(z)));return _.from([[T,B,L,new X(0)],[M,p,E,new X(0)],[b,a,D,new X(0)],[new X(0),new X(0),new X(0),new X(1)]])}function eK(J,K,$,Q,H,Y,W){P(J,"ux"),P(K,"uy"),P($,"uz"),P(Q,"theta"),P(H,"px"),P(Y,"py"),P(W,"pz");let F=j(H),U=j(Y),Z=j(W);return QJ(F,U,Z).mul(tJ(J,K,$,Q)).mul(QJ(F.negated(),U.negated(),Z.negated()))}function CJ(J,K,$,Q){if(!(J instanceof _))throw new Error("M must be a Matrix instance");if(J.rows!==4||J.cols!==4)throw new Error(`M must be a 4x4 matrix, got ${J.rows}x${J.cols}`);P(K,"x"),P($,"y"),P(Q,"z");let H=_.from([[j(K)],[j($)],[j(Q)],[new X(1)]]),Y=J.mul(H),W=Y.data[0][0],F=Y.data[1][0],U=Y.data[2][0],Z=Y.data[3][0];if(Z.isZero())throw new Error("Perspective division by zero: transformation results in point at infinity");return[W.div(Z),F.div(Z),U.div(Z)]}function rK(){return _.from([[new X(1),new X(0),new X(0),new X(0)],[new X(0),new X(1),new X(0),new X(0)],[new X(0),new X(0),new X(-1),new X(0)],[new X(0),new X(0),new X(0),new X(1)]])}function J$(){return _.from([[new X(1),new X(0),new X(0),new X(0)],[new X(0),new X(-1),new X(0),new X(0)],[new X(0),new X(0),new X(1),new X(0)],[new X(0),new X(0),new X(0),new X(1)]])}function K$(){return _.from([[new X(-1),new X(0),new X(0),new X(0)],[new X(0),new X(1),new X(0),new X(0)],[new X(0),new X(0),new X(1),new X(0)],[new X(0),new X(0),new X(0),new X(1)]])}function $$(){return _.from([[new X(-1),new X(0),new X(0),new X(0)],[new X(0),new X(-1),new X(0),new X(0)],[new X(0),new X(0),new X(-1),new X(0)],[new X(0),new X(0),new X(0),new X(1)]])}X.set({precision:80});var Q$="1.2.0";var H$=$J,Y$=zJ,W$=MJ,F$=PJ,Z$=fJ,X$=QJ,U$=LJ,q$=kJ,R$=gJ,V$=bJ,G$=CJ,eJ={VERSION:Q$,Decimal:X,Matrix:_,Vector:A,Transforms2D:jJ,Transforms3D:hJ,translate2D:H$,rotate2D:Y$,scale2D:W$,skew2D:F$,applyTransform2D:Z$,translate3D:X$,rotateX:U$,rotateY:q$,rotateZ:R$,scale3D:V$,applyTransform3D:G$},b$=eJ;if(typeof window!=="undefined")window.SVGMatrixLib=eJ;export{X$ as translate3D,H$ as translate2D,F$ as skew2D,V$ as scale3D,W$ as scale2D,R$ as rotateZ,q$ as rotateY,U$ as rotateX,Y$ as rotate2D,b$ as default,G$ as applyTransform3D,Z$ as applyTransform2D,A as Vector,Q$ as VERSION,hJ as Transforms3D,jJ as Transforms2D,_ as Matrix,X as Decimal};
8
+ */var i=9000000000000000,x=1e9,TJ="0123456789abcdef",XJ="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",UJ="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",OJ={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-i,maxE:i,crypto:!1},yJ,n,O=!0,RJ="[DecimalError] ",o=RJ+"Invalid argument: ",cJ=RJ+"Precision limit exceeded",lJ=RJ+"crypto unavailable",dJ="[object Decimal]",C=Math.floor,f=Math.pow,JK=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,KK=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,$K=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,nJ=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,c=1e7,I=7,QK=9007199254740991,HK=XJ.length-1,EJ=UJ.length-1,G={toStringTag:dJ};G.absoluteValue=G.abs=function(){var J=new this.constructor(this);if(J.s<0)J.s=1;return N(J)};G.ceil=function(){return N(new this.constructor(this),this.e+1,2)};G.clampedTo=G.clamp=function(J,K){var $,Q=this,H=Q.constructor;if(J=new H(J),K=new H(K),!J.s||!K.s)return new H(NaN);if(J.gt(K))throw Error(o+K);return $=Q.cmp(J),$<0?J:Q.cmp(K)>0?K:new H(Q)};G.comparedTo=G.cmp=function(J){var K,$,Q,H,Y=this,W=Y.d,F=(J=new Y.constructor(J)).d,U=Y.s,Z=J.s;if(!W||!F)return!U||!Z?NaN:U!==Z?U:W===F?0:!W^U<0?1:-1;if(!W[0]||!F[0])return W[0]?U:F[0]?-Z:0;if(U!==Z)return U;if(Y.e!==J.e)return Y.e>J.e^U<0?1:-1;Q=W.length,H=F.length;for(K=0,$=Q<H?Q:H;K<$;++K)if(W[K]!==F[K])return W[K]>F[K]^U<0?1:-1;return Q===H?0:Q>H^U<0?1:-1};G.cosine=G.cos=function(){var J,K,$=this,Q=$.constructor;if(!$.d)return new Q(NaN);if(!$.d[0])return new Q(1);return J=Q.precision,K=Q.rounding,Q.precision=J+Math.max($.e,$.sd())+I,Q.rounding=1,$=YK(Q,aJ(Q,$)),Q.precision=J,Q.rounding=K,N(n==2||n==3?$.neg():$,J,K,!0)};G.cubeRoot=G.cbrt=function(){var J,K,$,Q,H,Y,W,F,U,Z,q=this,R=q.constructor;if(!q.isFinite()||q.isZero())return new R(q);if(O=!1,Y=q.s*f(q.s*q,0.3333333333333333),!Y||Math.abs(Y)==1/0){if($=k(q.d),J=q.e,Y=(J-$.length+1)%3)$+=Y==1||Y==-2?"0":"00";if(Y=f($,0.3333333333333333),J=C((J+1)/3)-(J%3==(J<0?-1:2)),Y==1/0)$="5e"+J;else $=Y.toExponential(),$=$.slice(0,$.indexOf("e")+1)+J;Q=new R($),Q.s=q.s}else Q=new R(Y.toString());W=(J=R.precision)+3;for(;;)if(F=Q,U=F.times(F).times(F),Z=U.plus(q),Q=w(Z.plus(q).times(F),Z.plus(U),W+2,1),k(F.d).slice(0,W)===($=k(Q.d)).slice(0,W))if($=$.slice(W-3,W+1),$=="9999"||!H&&$=="4999"){if(!H){if(N(F,J+1,0),F.times(F).times(F).eq(q)){Q=F;break}}W+=4,H=1}else{if(!+$||!+$.slice(1)&&$.charAt(0)=="5")N(Q,J+1,1),K=!Q.times(Q).times(Q).eq(q);break}return O=!0,N(Q,J,R.rounding,K)};G.decimalPlaces=G.dp=function(){var J,K=this.d,$=NaN;if(K){if(J=K.length-1,$=(J-C(this.e/I))*I,J=K[J],J)for(;J%10==0;J/=10)$--;if($<0)$=0}return $};G.dividedBy=G.div=function(J){return w(this,new this.constructor(J))};G.dividedToIntegerBy=G.divToInt=function(J){var K=this,$=K.constructor;return N(w(K,new $(J),0,1,1),$.precision,$.rounding)};G.equals=G.eq=function(J){return this.cmp(J)===0};G.floor=function(){return N(new this.constructor(this),this.e+1,3)};G.greaterThan=G.gt=function(J){return this.cmp(J)>0};G.greaterThanOrEqualTo=G.gte=function(J){var K=this.cmp(J);return K==1||K===0};G.hyperbolicCosine=G.cosh=function(){var J,K,$,Q,H,Y=this,W=Y.constructor,F=new W(1);if(!Y.isFinite())return new W(Y.s?1/0:NaN);if(Y.isZero())return F;if($=W.precision,Q=W.rounding,W.precision=$+Math.max(Y.e,Y.sd())+4,W.rounding=1,H=Y.d.length,H<32)J=Math.ceil(H/3),K=(1/GJ(4,J)).toString();else J=16,K="2.3283064365386962890625e-10";Y=t(W,1,Y.times(K),new W(1),!0);var U,Z=J,q=new W(8);for(;Z--;)U=Y.times(Y),Y=F.minus(U.times(q.minus(U.times(q))));return N(Y,W.precision=$,W.rounding=Q,!0)};G.hyperbolicSine=G.sinh=function(){var J,K,$,Q,H=this,Y=H.constructor;if(!H.isFinite()||H.isZero())return new Y(H);if(K=Y.precision,$=Y.rounding,Y.precision=K+Math.max(H.e,H.sd())+4,Y.rounding=1,Q=H.d.length,Q<3)H=t(Y,2,H,H,!0);else{J=1.4*Math.sqrt(Q),J=J>16?16:J|0,H=H.times(1/GJ(5,J)),H=t(Y,2,H,H,!0);var W,F=new Y(5),U=new Y(16),Z=new Y(20);for(;J--;)W=H.times(H),H=H.times(F.plus(W.times(U.times(W).plus(Z))))}return Y.precision=K,Y.rounding=$,N(H,K,$,!0)};G.hyperbolicTangent=G.tanh=function(){var J,K,$=this,Q=$.constructor;if(!$.isFinite())return new Q($.s);if($.isZero())return new Q($);return J=Q.precision,K=Q.rounding,Q.precision=J+7,Q.rounding=1,w($.sinh(),$.cosh(),Q.precision=J,Q.rounding=K)};G.inverseCosine=G.acos=function(){var J=this,K=J.constructor,$=J.abs().cmp(1),Q=K.precision,H=K.rounding;if($!==-1)return $===0?J.isNeg()?l(K,Q,H):new K(0):new K(NaN);if(J.isZero())return l(K,Q+4,H).times(0.5);return K.precision=Q+6,K.rounding=1,J=new K(1).minus(J).div(J.plus(1)).sqrt().atan(),K.precision=Q,K.rounding=H,J.times(2)};G.inverseHyperbolicCosine=G.acosh=function(){var J,K,$=this,Q=$.constructor;if($.lte(1))return new Q($.eq(1)?0:NaN);if(!$.isFinite())return new Q($);return J=Q.precision,K=Q.rounding,Q.precision=J+Math.max(Math.abs($.e),$.sd())+4,Q.rounding=1,O=!1,$=$.times($).minus(1).sqrt().plus($),O=!0,Q.precision=J,Q.rounding=K,$.ln()};G.inverseHyperbolicSine=G.asinh=function(){var J,K,$=this,Q=$.constructor;if(!$.isFinite()||$.isZero())return new Q($);return J=Q.precision,K=Q.rounding,Q.precision=J+2*Math.max(Math.abs($.e),$.sd())+6,Q.rounding=1,O=!1,$=$.times($).plus(1).sqrt().plus($),O=!0,Q.precision=J,Q.rounding=K,$.ln()};G.inverseHyperbolicTangent=G.atanh=function(){var J,K,$,Q,H=this,Y=H.constructor;if(!H.isFinite())return new Y(NaN);if(H.e>=0)return new Y(H.abs().eq(1)?H.s/0:H.isZero()?H:NaN);if(J=Y.precision,K=Y.rounding,Q=H.sd(),Math.max(Q,J)<2*-H.e-1)return N(new Y(H),J,K,!0);return Y.precision=$=Q-H.e,H=w(H.plus(1),new Y(1).minus(H),$+J,1),Y.precision=J+4,Y.rounding=1,H=H.ln(),Y.precision=J,Y.rounding=K,H.times(0.5)};G.inverseSine=G.asin=function(){var J,K,$,Q,H=this,Y=H.constructor;if(H.isZero())return new Y(H);if(K=H.abs().cmp(1),$=Y.precision,Q=Y.rounding,K!==-1){if(K===0)return J=l(Y,$+4,Q).times(0.5),J.s=H.s,J;return new Y(NaN)}return Y.precision=$+6,Y.rounding=1,H=H.div(new Y(1).minus(H.times(H)).sqrt().plus(1)).atan(),Y.precision=$,Y.rounding=Q,H.times(2)};G.inverseTangent=G.atan=function(){var J,K,$,Q,H,Y,W,F,U,Z=this,q=Z.constructor,R=q.precision,V=q.rounding;if(!Z.isFinite()){if(!Z.s)return new q(NaN);if(R+4<=EJ)return W=l(q,R+4,V).times(0.5),W.s=Z.s,W}else if(Z.isZero())return new q(Z);else if(Z.abs().eq(1)&&R+4<=EJ)return W=l(q,R+4,V).times(0.25),W.s=Z.s,W;q.precision=F=R+10,q.rounding=1,$=Math.min(28,F/I+2|0);for(J=$;J;--J)Z=Z.div(Z.times(Z).plus(1).sqrt().plus(1));O=!1,K=Math.ceil(F/I),Q=1,U=Z.times(Z),W=new q(Z),H=Z;for(;J!==-1;)if(H=H.times(U),Y=W.minus(H.div(Q+=2)),H=H.times(U),W=Y.plus(H.div(Q+=2)),W.d[K]!==void 0)for(J=K;W.d[J]===Y.d[J]&&J--;);if($)W=W.times(2<<$-1);return O=!0,N(W,q.precision=R,q.rounding=V,!0)};G.isFinite=function(){return!!this.d};G.isInteger=G.isInt=function(){return!!this.d&&C(this.e/I)>this.d.length-2};G.isNaN=function(){return!this.s};G.isNegative=G.isNeg=function(){return this.s<0};G.isPositive=G.isPos=function(){return this.s>0};G.isZero=function(){return!!this.d&&this.d[0]===0};G.lessThan=G.lt=function(J){return this.cmp(J)<0};G.lessThanOrEqualTo=G.lte=function(J){return this.cmp(J)<1};G.logarithm=G.log=function(J){var K,$,Q,H,Y,W,F,U,Z=this,q=Z.constructor,R=q.precision,V=q.rounding,z=5;if(J==null)J=new q(10),K=!0;else{if(J=new q(J),$=J.d,J.s<0||!$||!$[0]||J.eq(1))return new q(NaN);K=J.eq(10)}if($=Z.d,Z.s<0||!$||!$[0]||Z.eq(1))return new q($&&!$[0]?-1/0:Z.s!=1?NaN:$?0:1/0);if(K)if($.length>1)Y=!0;else{for(H=$[0];H%10===0;)H/=10;Y=H!==1}if(O=!1,F=R+z,W=s(Z,F),Q=K?qJ(q,F+10):s(J,F),U=w(W,Q,F,1),JJ(U.d,H=R,V))do if(F+=10,W=s(Z,F),Q=K?qJ(q,F+10):s(J,F),U=w(W,Q,F,1),!Y){if(+k(U.d).slice(H+1,H+15)+1==100000000000000)U=N(U,R+1,0);break}while(JJ(U.d,H+=10,V));return O=!0,N(U,R,V)};G.minus=G.sub=function(J){var K,$,Q,H,Y,W,F,U,Z,q,R,V,z=this,T=z.constructor;if(J=new T(J),!z.d||!J.d){if(!z.s||!J.s)J=new T(NaN);else if(z.d)J.s=-J.s;else J=new T(J.d||z.s!==J.s?z:NaN);return J}if(z.s!=J.s)return J.s=-J.s,z.plus(J);if(Z=z.d,V=J.d,F=T.precision,U=T.rounding,!Z[0]||!V[0]){if(V[0])J.s=-J.s;else if(Z[0])J=new T(z);else return new T(U===3?-0:0);return O?N(J,F,U):J}if($=C(J.e/I),q=C(z.e/I),Z=Z.slice(),Y=q-$,Y){if(R=Y<0,R)K=Z,Y=-Y,W=V.length;else K=V,$=q,W=Z.length;if(Q=Math.max(Math.ceil(F/I),W)+2,Y>Q)Y=Q,K.length=1;K.reverse();for(Q=Y;Q--;)K.push(0);K.reverse()}else{if(Q=Z.length,W=V.length,R=Q<W,R)W=Q;for(Q=0;Q<W;Q++)if(Z[Q]!=V[Q]){R=Z[Q]<V[Q];break}Y=0}if(R)K=Z,Z=V,V=K,J.s=-J.s;W=Z.length;for(Q=V.length-W;Q>0;--Q)Z[W++]=0;for(Q=V.length;Q>Y;){if(Z[--Q]<V[Q]){for(H=Q;H&&Z[--H]===0;)Z[H]=c-1;--Z[H],Z[Q]+=c}Z[Q]-=V[Q]}for(;Z[--W]===0;)Z.pop();for(;Z[0]===0;Z.shift())--$;if(!Z[0])return new T(U===3?-0:0);return J.d=Z,J.e=VJ(Z,$),O?N(J,F,U):J};G.modulo=G.mod=function(J){var K,$=this,Q=$.constructor;if(J=new Q(J),!$.d||!J.s||J.d&&!J.d[0])return new Q(NaN);if(!J.d||$.d&&!$.d[0])return N(new Q($),Q.precision,Q.rounding);if(O=!1,Q.modulo==9)K=w($,J.abs(),0,3,1),K.s*=J.s;else K=w($,J,0,Q.modulo,1);return K=K.times(J),O=!0,$.minus(K)};G.naturalExponential=G.exp=function(){return AJ(this)};G.naturalLogarithm=G.ln=function(){return s(this)};G.negated=G.neg=function(){var J=new this.constructor(this);return J.s=-J.s,N(J)};G.plus=G.add=function(J){var K,$,Q,H,Y,W,F,U,Z,q,R=this,V=R.constructor;if(J=new V(J),!R.d||!J.d){if(!R.s||!J.s)J=new V(NaN);else if(!R.d)J=new V(J.d||R.s===J.s?R:NaN);return J}if(R.s!=J.s)return J.s=-J.s,R.minus(J);if(Z=R.d,q=J.d,F=V.precision,U=V.rounding,!Z[0]||!q[0]){if(!q[0])J=new V(R);return O?N(J,F,U):J}if(Y=C(R.e/I),Q=C(J.e/I),Z=Z.slice(),H=Y-Q,H){if(H<0)$=Z,H=-H,W=q.length;else $=q,Q=Y,W=Z.length;if(Y=Math.ceil(F/I),W=Y>W?Y+1:W+1,H>W)H=W,$.length=1;$.reverse();for(;H--;)$.push(0);$.reverse()}if(W=Z.length,H=q.length,W-H<0)H=W,$=q,q=Z,Z=$;for(K=0;H;)K=(Z[--H]=Z[H]+q[H]+K)/c|0,Z[H]%=c;if(K)Z.unshift(K),++Q;for(W=Z.length;Z[--W]==0;)Z.pop();return J.d=Z,J.e=VJ(Z,Q),O?N(J,F,U):J};G.precision=G.sd=function(J){var K,$=this;if(J!==void 0&&J!==!!J&&J!==1&&J!==0)throw Error(o+J);if($.d){if(K=mJ($.d),J&&$.e+1>K)K=$.e+1}else K=NaN;return K};G.round=function(){var J=this,K=J.constructor;return N(new K(J),J.e+1,K.rounding)};G.sine=G.sin=function(){var J,K,$=this,Q=$.constructor;if(!$.isFinite())return new Q(NaN);if($.isZero())return new Q($);return J=Q.precision,K=Q.rounding,Q.precision=J+Math.max($.e,$.sd())+I,Q.rounding=1,$=FK(Q,aJ(Q,$)),Q.precision=J,Q.rounding=K,N(n>2?$.neg():$,J,K,!0)};G.squareRoot=G.sqrt=function(){var J,K,$,Q,H,Y,W=this,F=W.d,U=W.e,Z=W.s,q=W.constructor;if(Z!==1||!F||!F[0])return new q(!Z||Z<0&&(!F||F[0])?NaN:F?W:1/0);if(O=!1,Z=Math.sqrt(+W),Z==0||Z==1/0){if(K=k(F),(K.length+U)%2==0)K+="0";if(Z=Math.sqrt(K),U=C((U+1)/2)-(U<0||U%2),Z==1/0)K="5e"+U;else K=Z.toExponential(),K=K.slice(0,K.indexOf("e")+1)+U;Q=new q(K)}else Q=new q(Z.toString());$=(U=q.precision)+3;for(;;)if(Y=Q,Q=Y.plus(w(W,Y,$+2,1)).times(0.5),k(Y.d).slice(0,$)===(K=k(Q.d)).slice(0,$))if(K=K.slice($-3,$+1),K=="9999"||!H&&K=="4999"){if(!H){if(N(Y,U+1,0),Y.times(Y).eq(W)){Q=Y;break}}$+=4,H=1}else{if(!+K||!+K.slice(1)&&K.charAt(0)=="5")N(Q,U+1,1),J=!Q.times(Q).eq(W);break}return O=!0,N(Q,U,q.rounding,J)};G.tangent=G.tan=function(){var J,K,$=this,Q=$.constructor;if(!$.isFinite())return new Q(NaN);if($.isZero())return new Q($);return J=Q.precision,K=Q.rounding,Q.precision=J+10,Q.rounding=1,$=$.sin(),$.s=1,$=w($,new Q(1).minus($.times($)).sqrt(),J+10,0),Q.precision=J,Q.rounding=K,N(n==2||n==4?$.neg():$,J,K,!0)};G.times=G.mul=function(J){var K,$,Q,H,Y,W,F,U,Z,q=this,R=q.constructor,V=q.d,z=(J=new R(J)).d;if(J.s*=q.s,!V||!V[0]||!z||!z[0])return new R(!J.s||V&&!V[0]&&!z||z&&!z[0]&&!V?NaN:!V||!z?J.s/0:J.s*0);if($=C(q.e/I)+C(J.e/I),U=V.length,Z=z.length,U<Z)Y=V,V=z,z=Y,W=U,U=Z,Z=W;Y=[],W=U+Z;for(Q=W;Q--;)Y.push(0);for(Q=Z;--Q>=0;){K=0;for(H=U+Q;H>Q;)F=Y[H]+z[Q]*V[H-Q-1]+K,Y[H--]=F%c|0,K=F/c|0;Y[H]=(Y[H]+K)%c|0}for(;!Y[--W];)Y.pop();if(K)++$;else Y.shift();return J.d=Y,J.e=VJ(Y,$),O?N(J,R.precision,R.rounding):J};G.toBinary=function(J,K){return wJ(this,2,J,K)};G.toDecimalPlaces=G.toDP=function(J,K){var $=this,Q=$.constructor;if($=new Q($),J===void 0)return $;if(v(J,0,x),K===void 0)K=Q.rounding;else v(K,0,8);return N($,J+$.e+1,K)};G.toExponential=function(J,K){var $,Q=this,H=Q.constructor;if(J===void 0)$=d(Q,!0);else{if(v(J,0,x),K===void 0)K=H.rounding;else v(K,0,8);Q=N(new H(Q),J+1,K),$=d(Q,!0,J+1)}return Q.isNeg()&&!Q.isZero()?"-"+$:$};G.toFixed=function(J,K){var $,Q,H=this,Y=H.constructor;if(J===void 0)$=d(H);else{if(v(J,0,x),K===void 0)K=Y.rounding;else v(K,0,8);Q=N(new Y(H),J+H.e+1,K),$=d(Q,!1,J+Q.e+1)}return H.isNeg()&&!H.isZero()?"-"+$:$};G.toFraction=function(J){var K,$,Q,H,Y,W,F,U,Z,q,R,V,z=this,T=z.d,B=z.constructor;if(!T)return new B(z);if(Z=$=new B(1),Q=U=new B(0),K=new B(Q),Y=K.e=mJ(T)-z.e-1,W=Y%I,K.d[0]=f(10,W<0?I+W:W),J==null)J=Y>0?K:Z;else{if(F=new B(J),!F.isInt()||F.lt(Z))throw Error(o+F);J=F.gt(K)?Y>0?K:Z:F}O=!1,F=new B(k(T)),q=B.precision,B.precision=Y=T.length*I*2;for(;;){if(R=w(F,K,0,1,1),H=$.plus(R.times(Q)),H.cmp(J)==1)break;$=Q,Q=H,H=Z,Z=U.plus(R.times(H)),U=H,H=K,K=F.minus(R.times(H)),F=H}return H=w(J.minus($),Q,0,1,1),U=U.plus(H.times(Z)),$=$.plus(H.times(Q)),U.s=Z.s=z.s,V=w(Z,Q,Y,1).minus(z).abs().cmp(w(U,$,Y,1).minus(z).abs())<1?[Z,Q]:[U,$],B.precision=q,O=!0,V};G.toHexadecimal=G.toHex=function(J,K){return wJ(this,16,J,K)};G.toNearest=function(J,K){var $=this,Q=$.constructor;if($=new Q($),J==null){if(!$.d)return $;J=new Q(1),K=Q.rounding}else{if(J=new Q(J),K===void 0)K=Q.rounding;else v(K,0,8);if(!$.d)return J.s?$:J;if(!J.d){if(J.s)J.s=$.s;return J}}if(J.d[0])O=!1,$=w($,J,0,K,1).times(J),O=!0,N($);else J.s=$.s,$=J;return $};G.toNumber=function(){return+this};G.toOctal=function(J,K){return wJ(this,8,J,K)};G.toPower=G.pow=function(J){var K,$,Q,H,Y,W,F=this,U=F.constructor,Z=+(J=new U(J));if(!F.d||!J.d||!F.d[0]||!J.d[0])return new U(f(+F,Z));if(F=new U(F),F.eq(1))return F;if(Q=U.precision,Y=U.rounding,J.eq(1))return N(F,Q,Y);if(K=C(J.e/I),K>=J.d.length-1&&($=Z<0?-Z:Z)<=QK)return H=sJ(U,F,$,Q),J.s<0?new U(1).div(H):N(H,Q,Y);if(W=F.s,W<0){if(K<J.d.length-1)return new U(NaN);if((J.d[K]&1)==0)W=1;if(F.e==0&&F.d[0]==1&&F.d.length==1)return F.s=W,F}if($=f(+F,Z),K=$==0||!isFinite($)?C(Z*(Math.log("0."+k(F.d))/Math.LN10+F.e+1)):new U($+"").e,K>U.maxE+1||K<U.minE-1)return new U(K>0?W/0:0);if(O=!1,U.rounding=F.s=1,$=Math.min(12,(K+"").length),H=AJ(J.times(s(F,Q+$)),Q),H.d){if(H=N(H,Q+5,1),JJ(H.d,Q,Y)){if(K=Q+10,H=N(AJ(J.times(s(F,K+$)),K),K+5,1),+k(H.d).slice(Q+1,Q+15)+1==100000000000000)H=N(H,Q+1,0)}}return H.s=W,O=!0,U.rounding=Y,N(H,Q,Y)};G.toPrecision=function(J,K){var $,Q=this,H=Q.constructor;if(J===void 0)$=d(Q,Q.e<=H.toExpNeg||Q.e>=H.toExpPos);else{if(v(J,1,x),K===void 0)K=H.rounding;else v(K,0,8);Q=N(new H(Q),J,K),$=d(Q,J<=Q.e||Q.e<=H.toExpNeg,J)}return Q.isNeg()&&!Q.isZero()?"-"+$:$};G.toSignificantDigits=G.toSD=function(J,K){var $=this,Q=$.constructor;if(J===void 0)J=Q.precision,K=Q.rounding;else if(v(J,1,x),K===void 0)K=Q.rounding;else v(K,0,8);return N(new Q($),J,K)};G.toString=function(){var J=this,K=J.constructor,$=d(J,J.e<=K.toExpNeg||J.e>=K.toExpPos);return J.isNeg()&&!J.isZero()?"-"+$:$};G.truncated=G.trunc=function(){return N(new this.constructor(this),this.e+1,1)};G.valueOf=G.toJSON=function(){var J=this,K=J.constructor,$=d(J,J.e<=K.toExpNeg||J.e>=K.toExpPos);return J.isNeg()?"-"+$:$};function k(J){var K,$,Q,H=J.length-1,Y="",W=J[0];if(H>0){Y+=W;for(K=1;K<H;K++){if(Q=J[K]+"",$=I-Q.length,$)Y+=m($);Y+=Q}if(W=J[K],Q=W+"",$=I-Q.length,$)Y+=m($)}else if(W===0)return"0";for(;W%10===0;)W/=10;return Y+W}function v(J,K,$){if(J!==~~J||J<K||J>$)throw Error(o+J)}function JJ(J,K,$,Q){var H,Y,W,F;for(Y=J[0];Y>=10;Y/=10)--K;if(--K<0)K+=I,H=0;else H=Math.ceil((K+1)/I),K%=I;if(Y=f(10,I-K),F=J[H]%Y|0,Q==null)if(K<3){if(K==0)F=F/100|0;else if(K==1)F=F/10|0;W=$<4&&F==99999||$>3&&F==49999||F==50000||F==0}else W=($<4&&F+1==Y||$>3&&F+1==Y/2)&&(J[H+1]/Y/100|0)==f(10,K-2)-1||(F==Y/2||F==0)&&(J[H+1]/Y/100|0)==0;else if(K<4){if(K==0)F=F/1000|0;else if(K==1)F=F/100|0;else if(K==2)F=F/10|0;W=(Q||$<4)&&F==9999||!Q&&$>3&&F==4999}else W=((Q||$<4)&&F+1==Y||!Q&&$>3&&F+1==Y/2)&&(J[H+1]/Y/1000|0)==f(10,K-3)-1;return W}function FJ(J,K,$){var Q,H=[0],Y,W=0,F=J.length;for(;W<F;){for(Y=H.length;Y--;)H[Y]*=K;H[0]+=TJ.indexOf(J.charAt(W++));for(Q=0;Q<H.length;Q++)if(H[Q]>$-1){if(H[Q+1]===void 0)H[Q+1]=0;H[Q+1]+=H[Q]/$|0,H[Q]%=$}}return H.reverse()}function YK(J,K){var $,Q,H;if(K.isZero())return K;if(Q=K.d.length,Q<32)$=Math.ceil(Q/3),H=(1/GJ(4,$)).toString();else $=16,H="2.3283064365386962890625e-10";J.precision+=$,K=t(J,1,K.times(H),new J(1));for(var Y=$;Y--;){var W=K.times(K);K=W.times(W).minus(W).times(8).plus(1)}return J.precision-=$,K}var w=function(){function J(Q,H,Y){var W,F=0,U=Q.length;for(Q=Q.slice();U--;)W=Q[U]*H+F,Q[U]=W%Y|0,F=W/Y|0;if(F)Q.unshift(F);return Q}function K(Q,H,Y,W){var F,U;if(Y!=W)U=Y>W?1:-1;else for(F=U=0;F<Y;F++)if(Q[F]!=H[F]){U=Q[F]>H[F]?1:-1;break}return U}function $(Q,H,Y,W){var F=0;for(;Y--;)Q[Y]-=F,F=Q[Y]<H[Y]?1:0,Q[Y]=F*W+Q[Y]-H[Y];for(;!Q[0]&&Q.length>1;)Q.shift()}return function(Q,H,Y,W,F,U){var Z,q,R,V,z,T,B,L,M,p,E,b,a,D,IJ,HJ,r,_J,y,YJ,WJ=Q.constructor,BJ=Q.s==H.s?1:-1,g=Q.d,S=H.d;if(!g||!g[0]||!S||!S[0])return new WJ(!Q.s||!H.s||(g?S&&g[0]==S[0]:!S)?NaN:g&&g[0]==0||!S?BJ*0:BJ/0);if(U)z=1,q=Q.e-H.e;else U=c,z=I,q=C(Q.e/z)-C(H.e/z);y=S.length,r=g.length,M=new WJ(BJ),p=M.d=[];for(R=0;S[R]==(g[R]||0);R++);if(S[R]>(g[R]||0))q--;if(Y==null)D=Y=WJ.precision,W=WJ.rounding;else if(F)D=Y+(Q.e-H.e)+1;else D=Y;if(D<0)p.push(1),T=!0;else{if(D=D/z+2|0,R=0,y==1){V=0,S=S[0],D++;for(;(R<r||V)&&D--;R++)IJ=V*U+(g[R]||0),p[R]=IJ/S|0,V=IJ%S|0;T=V||R<r}else{if(V=U/(S[0]+1)|0,V>1)S=J(S,V,U),g=J(g,V,U),y=S.length,r=g.length;HJ=y,E=g.slice(0,y),b=E.length;for(;b<y;)E[b++]=0;if(YJ=S.slice(),YJ.unshift(0),_J=S[0],S[1]>=U/2)++_J;do{if(V=0,Z=K(S,E,y,b),Z<0){if(a=E[0],y!=b)a=a*U+(E[1]||0);if(V=a/_J|0,V>1){if(V>=U)V=U-1;if(B=J(S,V,U),L=B.length,b=E.length,Z=K(B,E,L,b),Z==1)V--,$(B,y<L?YJ:S,L,U)}else{if(V==0)Z=V=1;B=S.slice()}if(L=B.length,L<b)B.unshift(0);if($(E,B,b,U),Z==-1){if(b=E.length,Z=K(S,E,y,b),Z<1)V++,$(E,y<b?YJ:S,b,U)}b=E.length}else if(Z===0)V++,E=[0];if(p[R++]=V,Z&&E[0])E[b++]=g[HJ]||0;else E=[g[HJ]],b=1}while((HJ++<r||E[0]!==void 0)&&D--);T=E[0]!==void 0}if(!p[0])p.shift()}if(z==1)M.e=q,yJ=T;else{for(R=1,V=p[0];V>=10;V/=10)R++;M.e=R+q*z-1,N(M,F?Y+M.e+1:Y,W,T)}return M}}();function N(J,K,$,Q){var H,Y,W,F,U,Z,q,R,V,z=J.constructor;J:if(K!=null){if(R=J.d,!R)return J;for(H=1,F=R[0];F>=10;F/=10)H++;if(Y=K-H,Y<0)Y+=I,W=K,q=R[V=0],U=q/f(10,H-W-1)%10|0;else if(V=Math.ceil((Y+1)/I),F=R.length,V>=F)if(Q){for(;F++<=V;)R.push(0);q=U=0,H=1,Y%=I,W=Y-I+1}else break J;else{q=F=R[V];for(H=1;F>=10;F/=10)H++;Y%=I,W=Y-I+H,U=W<0?0:q/f(10,H-W-1)%10|0}if(Q=Q||K<0||R[V+1]!==void 0||(W<0?q:q%f(10,H-W-1)),Z=$<4?(U||Q)&&($==0||$==(J.s<0?3:2)):U>5||U==5&&($==4||Q||$==6&&(Y>0?W>0?q/f(10,H-W):0:R[V-1])%10&1||$==(J.s<0?8:7)),K<1||!R[0]){if(R.length=0,Z)K-=J.e+1,R[0]=f(10,(I-K%I)%I),J.e=-K||0;else R[0]=J.e=0;return J}if(Y==0)R.length=V,F=1,V--;else R.length=V+1,F=f(10,I-Y),R[V]=W>0?(q/f(10,H-W)%f(10,W)|0)*F:0;if(Z)for(;;)if(V==0){for(Y=1,W=R[0];W>=10;W/=10)Y++;W=R[0]+=F;for(F=1;W>=10;W/=10)F++;if(Y!=F){if(J.e++,R[0]==c)R[0]=1}break}else{if(R[V]+=F,R[V]!=c)break;R[V--]=0,F=1}for(Y=R.length;R[--Y]===0;)R.pop()}if(O){if(J.e>z.maxE)J.d=null,J.e=NaN;else if(J.e<z.minE)J.e=0,J.d=[0]}return J}function d(J,K,$){if(!J.isFinite())return xJ(J);var Q,H=J.e,Y=k(J.d),W=Y.length;if(K){if($&&(Q=$-W)>0)Y=Y.charAt(0)+"."+Y.slice(1)+m(Q);else if(W>1)Y=Y.charAt(0)+"."+Y.slice(1);Y=Y+(J.e<0?"e":"e+")+J.e}else if(H<0){if(Y="0."+m(-H-1)+Y,$&&(Q=$-W)>0)Y+=m(Q)}else if(H>=W){if(Y+=m(H+1-W),$&&(Q=$-H-1)>0)Y=Y+"."+m(Q)}else{if((Q=H+1)<W)Y=Y.slice(0,Q)+"."+Y.slice(Q);if($&&(Q=$-W)>0){if(H+1===W)Y+=".";Y+=m(Q)}}return Y}function VJ(J,K){var $=J[0];for(K*=I;$>=10;$/=10)K++;return K}function qJ(J,K,$){if(K>HK){if(O=!0,$)J.precision=$;throw Error(cJ)}return N(new J(XJ),K,1,!0)}function l(J,K,$){if(K>EJ)throw Error(cJ);return N(new J(UJ),K,$,!0)}function mJ(J){var K=J.length-1,$=K*I+1;if(K=J[K],K){for(;K%10==0;K/=10)$--;for(K=J[0];K>=10;K/=10)$++}return $}function m(J){var K="";for(;J--;)K+="0";return K}function sJ(J,K,$,Q){var H,Y=new J(1),W=Math.ceil(Q/I+4);O=!1;for(;;){if($%2){if(Y=Y.times(K),pJ(Y.d,W))H=!0}if($=C($/2),$===0){if($=Y.d.length-1,H&&Y.d[$]===0)++Y.d[$];break}K=K.times(K),pJ(K.d,W)}return O=!0,Y}function uJ(J){return J.d[J.d.length-1]&1}function oJ(J,K,$){var Q,H,Y=new J(K[0]),W=0;for(;++W<K.length;){if(H=new J(K[W]),!H.s){Y=H;break}if(Q=Y.cmp(H),Q===$||Q===0&&Y.s===$)Y=H}return Y}function AJ(J,K){var $,Q,H,Y,W,F,U,Z=0,q=0,R=0,V=J.constructor,z=V.rounding,T=V.precision;if(!J.d||!J.d[0]||J.e>17)return new V(J.d?!J.d[0]?1:J.s<0?0:1/0:J.s?J.s<0?0:J:NaN);if(K==null)O=!1,U=T;else U=K;F=new V(0.03125);while(J.e>-2)J=J.times(F),R+=5;Q=Math.log(f(2,R))/Math.LN10*2+5|0,U+=Q,$=Y=W=new V(1),V.precision=U;for(;;){if(Y=N(Y.times(J),U,1),$=$.times(++q),F=W.plus(w(Y,$,U,1)),k(F.d).slice(0,U)===k(W.d).slice(0,U)){H=R;while(H--)W=N(W.times(W),U,1);if(K==null)if(Z<3&&JJ(W.d,U-Q,z,Z))V.precision=U+=10,$=Y=F=new V(1),q=0,Z++;else return N(W,V.precision=T,z,O=!0);else return V.precision=T,W}W=F}}function s(J,K){var $,Q,H,Y,W,F,U,Z,q,R,V,z=1,T=10,B=J,L=B.d,M=B.constructor,p=M.rounding,E=M.precision;if(B.s<0||!L||!L[0]||!B.e&&L[0]==1&&L.length==1)return new M(L&&!L[0]?-1/0:B.s!=1?NaN:L?0:B);if(K==null)O=!1,q=E;else q=K;if(M.precision=q+=T,$=k(L),Q=$.charAt(0),Math.abs(Y=B.e)<1500000000000000){while(Q<7&&Q!=1||Q==1&&$.charAt(1)>3)B=B.times(J),$=k(B.d),Q=$.charAt(0),z++;if(Y=B.e,Q>1)B=new M("0."+$),Y++;else B=new M(Q+"."+$.slice(1))}else return Z=qJ(M,q+2,E).times(Y+""),B=s(new M(Q+"."+$.slice(1)),q-T).plus(Z),M.precision=E,K==null?N(B,E,p,O=!0):B;R=B,U=W=B=w(B.minus(1),B.plus(1),q,1),V=N(B.times(B),q,1),H=3;for(;;){if(W=N(W.times(V),q,1),Z=U.plus(w(W,new M(H),q,1)),k(Z.d).slice(0,q)===k(U.d).slice(0,q)){if(U=U.times(2),Y!==0)U=U.plus(qJ(M,q+2,E).times(Y+""));if(U=w(U,new M(z),q,1),K==null)if(JJ(U.d,q-T,p,F))M.precision=q+=T,Z=W=B=w(R.minus(1),R.plus(1),q,1),V=N(B.times(B),q,1),H=F=1;else return N(U,M.precision=E,p,O=!0);else return M.precision=E,U}U=Z,H+=2}}function xJ(J){return String(J.s*J.s/0)}function ZJ(J,K){var $,Q,H;if(($=K.indexOf("."))>-1)K=K.replace(".","");if((Q=K.search(/e/i))>0){if($<0)$=Q;$+=+K.slice(Q+1),K=K.substring(0,Q)}else if($<0)$=K.length;for(Q=0;K.charCodeAt(Q)===48;Q++);for(H=K.length;K.charCodeAt(H-1)===48;--H);if(K=K.slice(Q,H),K){if(H-=Q,J.e=$=$-Q-1,J.d=[],Q=($+1)%I,$<0)Q+=I;if(Q<H){if(Q)J.d.push(+K.slice(0,Q));for(H-=I;Q<H;)J.d.push(+K.slice(Q,Q+=I));K=K.slice(Q),Q=I-K.length}else Q-=H;for(;Q--;)K+="0";if(J.d.push(+K),O){if(J.e>J.constructor.maxE)J.d=null,J.e=NaN;else if(J.e<J.constructor.minE)J.e=0,J.d=[0]}}else J.e=0,J.d=[0];return J}function WK(J,K){var $,Q,H,Y,W,F,U,Z,q;if(K.indexOf("_")>-1){if(K=K.replace(/(\d)_(?=\d)/g,"$1"),nJ.test(K))return ZJ(J,K)}else if(K==="Infinity"||K==="NaN"){if(!+K)J.s=NaN;return J.e=NaN,J.d=null,J}if(KK.test(K))$=16,K=K.toLowerCase();else if(JK.test(K))$=2;else if($K.test(K))$=8;else throw Error(o+K);if(Y=K.search(/p/i),Y>0)U=+K.slice(Y+1),K=K.substring(2,Y);else K=K.slice(2);if(Y=K.indexOf("."),W=Y>=0,Q=J.constructor,W)K=K.replace(".",""),F=K.length,Y=F-Y,H=sJ(Q,new Q($),Y,Y*2);Z=FJ(K,$,c),q=Z.length-1;for(Y=q;Z[Y]===0;--Y)Z.pop();if(Y<0)return new Q(J.s*0);if(J.e=VJ(Z,q),J.d=Z,O=!1,W)J=w(J,H,F*4);if(U)J=J.times(Math.abs(U)<54?f(2,U):KJ.pow(2,U));return O=!0,J}function FK(J,K){var $,Q=K.d.length;if(Q<3)return K.isZero()?K:t(J,2,K,K);$=1.4*Math.sqrt(Q),$=$>16?16:$|0,K=K.times(1/GJ(5,$)),K=t(J,2,K,K);var H,Y=new J(5),W=new J(16),F=new J(20);for(;$--;)H=K.times(K),K=K.times(Y.plus(H.times(W.times(H).minus(F))));return K}function t(J,K,$,Q,H){var Y,W,F,U,Z=1,q=J.precision,R=Math.ceil(q/I);O=!1,U=$.times($),F=new J(Q);for(;;){if(W=w(F.times(U),new J(K++*K++),q,1),F=H?Q.plus(W):Q.minus(W),Q=w(W.times(U),new J(K++*K++),q,1),W=F.plus(Q),W.d[R]!==void 0){for(Y=R;W.d[Y]===F.d[Y]&&Y--;);if(Y==-1)break}Y=F,F=Q,Q=W,W=Y,Z++}return O=!0,W.d.length=R+1,W}function GJ(J,K){var $=J;while(--K)$*=J;return $}function aJ(J,K){var $,Q=K.s<0,H=l(J,J.precision,1),Y=H.times(0.5);if(K=K.abs(),K.lte(Y))return n=Q?4:1,K;if($=K.divToInt(H),$.isZero())n=Q?3:2;else{if(K=K.minus($.times(H)),K.lte(Y))return n=uJ($)?Q?2:3:Q?4:1,K;n=uJ($)?Q?1:4:Q?3:2}return K.minus(H).abs()}function wJ(J,K,$,Q){var H,Y,W,F,U,Z,q,R,V,z=J.constructor,T=$!==void 0;if(T)if(v($,1,x),Q===void 0)Q=z.rounding;else v(Q,0,8);else $=z.precision,Q=z.rounding;if(!J.isFinite())q=xJ(J);else{if(q=d(J),W=q.indexOf("."),T){if(H=2,K==16)$=$*4-3;else if(K==8)$=$*3-2}else H=K;if(W>=0)q=q.replace(".",""),V=new z(1),V.e=q.length-W,V.d=FJ(d(V),10,H),V.e=V.d.length;R=FJ(q,10,H),Y=U=R.length;for(;R[--U]==0;)R.pop();if(!R[0])q=T?"0p+0":"0";else{if(W<0)Y--;else J=new z(J),J.d=R,J.e=Y,J=w(J,V,$,Q,0,H),R=J.d,Y=J.e,Z=yJ;if(W=R[$],F=H/2,Z=Z||R[$+1]!==void 0,Z=Q<4?(W!==void 0||Z)&&(Q===0||Q===(J.s<0?3:2)):W>F||W===F&&(Q===4||Z||Q===6&&R[$-1]&1||Q===(J.s<0?8:7)),R.length=$,Z){for(;++R[--$]>H-1;)if(R[$]=0,!$)++Y,R.unshift(1)}for(U=R.length;!R[U-1];--U);for(W=0,q="";W<U;W++)q+=TJ.charAt(R[W]);if(T){if(U>1)if(K==16||K==8){W=K==16?4:3;for(--U;U%W;U++)q+="0";R=FJ(q,H,K);for(U=R.length;!R[U-1];--U);for(W=1,q="1.";W<U;W++)q+=TJ.charAt(R[W])}else q=q.charAt(0)+"."+q.slice(1);q=q+(Y<0?"p":"p+")+Y}else if(Y<0){for(;++Y;)q="0"+q;q="0."+q}else if(++Y>U)for(Y-=U;Y--;)q+="0";else if(Y<U)q=q.slice(0,Y)+"."+q.slice(Y)}q=(K==16?"0x":K==2?"0b":K==8?"0o":"")+q}return J.s<0?"-"+q:q}function pJ(J,K){if(J.length>K)return J.length=K,!0}function ZK(J){return new this(J).abs()}function XK(J){return new this(J).acos()}function UK(J){return new this(J).acosh()}function qK(J,K){return new this(J).plus(K)}function RK(J){return new this(J).asin()}function VK(J){return new this(J).asinh()}function GK(J){return new this(J).atan()}function zK(J){return new this(J).atanh()}function NK(J,K){J=new this(J),K=new this(K);var $,Q=this.precision,H=this.rounding,Y=Q+4;if(!J.s||!K.s)$=new this(NaN);else if(!J.d&&!K.d)$=l(this,Y,1).times(K.s>0?0.25:0.75),$.s=J.s;else if(!K.d||J.isZero())$=K.s<0?l(this,Q,H):new this(0),$.s=J.s;else if(!J.d||K.isZero())$=l(this,Y,1).times(0.5),$.s=J.s;else if(K.s<0)this.precision=Y,this.rounding=1,$=this.atan(w(J,K,Y,1)),K=l(this,Y,1),this.precision=Q,this.rounding=H,$=J.s<0?$.minus(K):$.plus(K);else $=this.atan(w(J,K,Y,1));return $}function IK(J){return new this(J).cbrt()}function _K(J){return N(J=new this(J),J.e+1,2)}function BK(J,K,$){return new this(J).clamp(K,$)}function TK(J){if(!J||typeof J!=="object")throw Error(RJ+"Object expected");var K,$,Q,H=J.defaults===!0,Y=["precision",1,x,"rounding",0,8,"toExpNeg",-i,0,"toExpPos",0,i,"maxE",0,i,"minE",-i,0,"modulo",0,9];for(K=0;K<Y.length;K+=3){if($=Y[K],H)this[$]=OJ[$];if((Q=J[$])!==void 0)if(C(Q)===Q&&Q>=Y[K+1]&&Q<=Y[K+2])this[$]=Q;else throw Error(o+$+": "+Q)}if($="crypto",H)this[$]=OJ[$];if((Q=J[$])!==void 0)if(Q===!0||Q===!1||Q===0||Q===1)if(Q)if(typeof crypto!="undefined"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[$]=!0;else throw Error(lJ);else this[$]=!1;else throw Error(o+$+": "+Q);return this}function OK(J){return new this(J).cos()}function EK(J){return new this(J).cosh()}function iJ(J){var K,$,Q;function H(Y){var W,F,U,Z=this;if(!(Z instanceof H))return new H(Y);if(Z.constructor=H,DJ(Y)){if(Z.s=Y.s,O)if(!Y.d||Y.e>H.maxE)Z.e=NaN,Z.d=null;else if(Y.e<H.minE)Z.e=0,Z.d=[0];else Z.e=Y.e,Z.d=Y.d.slice();else Z.e=Y.e,Z.d=Y.d?Y.d.slice():Y.d;return}if(U=typeof Y,U==="number"){if(Y===0){Z.s=1/Y<0?-1:1,Z.e=0,Z.d=[0];return}if(Y<0)Y=-Y,Z.s=-1;else Z.s=1;if(Y===~~Y&&Y<1e7){for(W=0,F=Y;F>=10;F/=10)W++;if(O)if(W>H.maxE)Z.e=NaN,Z.d=null;else if(W<H.minE)Z.e=0,Z.d=[0];else Z.e=W,Z.d=[Y];else Z.e=W,Z.d=[Y];return}if(Y*0!==0){if(!Y)Z.s=NaN;Z.e=NaN,Z.d=null;return}return ZJ(Z,Y.toString())}if(U==="string"){if((F=Y.charCodeAt(0))===45)Y=Y.slice(1),Z.s=-1;else{if(F===43)Y=Y.slice(1);Z.s=1}return nJ.test(Y)?ZJ(Z,Y):WK(Z,Y)}if(U==="bigint"){if(Y<0)Y=-Y,Z.s=-1;else Z.s=1;return ZJ(Z,Y.toString())}throw Error(o+Y)}if(H.prototype=G,H.ROUND_UP=0,H.ROUND_DOWN=1,H.ROUND_CEIL=2,H.ROUND_FLOOR=3,H.ROUND_HALF_UP=4,H.ROUND_HALF_DOWN=5,H.ROUND_HALF_EVEN=6,H.ROUND_HALF_CEIL=7,H.ROUND_HALF_FLOOR=8,H.EUCLID=9,H.config=H.set=TK,H.clone=iJ,H.isDecimal=DJ,H.abs=ZK,H.acos=XK,H.acosh=UK,H.add=qK,H.asin=RK,H.asinh=VK,H.atan=GK,H.atanh=zK,H.atan2=NK,H.cbrt=IK,H.ceil=_K,H.clamp=BK,H.cos=OK,H.cosh=EK,H.div=AK,H.exp=wK,H.floor=SK,H.hypot=MK,H.ln=PK,H.log=fK,H.log10=bK,H.log2=jK,H.max=LK,H.min=kK,H.mod=gK,H.mul=CK,H.pow=hK,H.random=vK,H.round=uK,H.sign=pK,H.sin=DK,H.sinh=yK,H.sqrt=cK,H.sub=lK,H.sum=dK,H.tan=nK,H.tanh=mK,H.trunc=sK,J===void 0)J={};if(J){if(J.defaults!==!0){Q=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"];for(K=0;K<Q.length;)if(!J.hasOwnProperty($=Q[K++]))J[$]=this[$]}}return H.config(J),H}function AK(J,K){return new this(J).div(K)}function wK(J){return new this(J).exp()}function SK(J){return N(J=new this(J),J.e+1,3)}function MK(){var J,K,$=new this(0);O=!1;for(J=0;J<arguments.length;)if(K=new this(arguments[J++]),!K.d){if(K.s)return O=!0,new this(1/0);$=K}else if($.d)$=$.plus(K.times(K));return O=!0,$.sqrt()}function DJ(J){return J instanceof KJ||J&&J.toStringTag===dJ||!1}function PK(J){return new this(J).ln()}function fK(J,K){return new this(J).log(K)}function jK(J){return new this(J).log(2)}function bK(J){return new this(J).log(10)}function LK(){return oJ(this,arguments,-1)}function kK(){return oJ(this,arguments,1)}function gK(J,K){return new this(J).mod(K)}function CK(J,K){return new this(J).mul(K)}function hK(J,K){return new this(J).pow(K)}function vK(J){var K,$,Q,H,Y=0,W=new this(1),F=[];if(J===void 0)J=this.precision;else v(J,1,x);if(Q=Math.ceil(J/I),!this.crypto)for(;Y<Q;)F[Y++]=Math.random()*1e7|0;else if(crypto.getRandomValues){K=crypto.getRandomValues(new Uint32Array(Q));for(;Y<Q;)if(H=K[Y],H>=4290000000)K[Y]=crypto.getRandomValues(new Uint32Array(1))[0];else F[Y++]=H%1e7}else if(crypto.randomBytes){K=crypto.randomBytes(Q*=4);for(;Y<Q;)if(H=K[Y]+(K[Y+1]<<8)+(K[Y+2]<<16)+((K[Y+3]&127)<<24),H>=2140000000)crypto.randomBytes(4).copy(K,Y);else F.push(H%1e7),Y+=4;Y=Q/4}else throw Error(lJ);if(Q=F[--Y],J%=I,Q&&J)H=f(10,I-J),F[Y]=(Q/H|0)*H;for(;F[Y]===0;Y--)F.pop();if(Y<0)$=0,F=[0];else{$=-1;for(;F[0]===0;$-=I)F.shift();for(Q=1,H=F[0];H>=10;H/=10)Q++;if(Q<I)$-=I-Q}return W.e=$,W.d=F,W}function uK(J){return N(J=new this(J),J.e+1,this.rounding)}function pK(J){return J=new this(J),J.d?J.d[0]?J.s:0*J.s:J.s||NaN}function DK(J){return new this(J).sin()}function yK(J){return new this(J).sinh()}function cK(J){return new this(J).sqrt()}function lK(J,K){return new this(J).sub(K)}function dK(){var J=0,K=arguments,$=new this(K[J]);O=!1;for(;$.s&&++J<K.length;)$=$.plus(K[J]);return O=!0,N($,this.precision,this.rounding)}function nK(J){return new this(J).tan()}function mK(J){return new this(J).tanh()}function sK(J){return N(J=new this(J),J.e+1,1)}G[Symbol.for("nodejs.util.inspect.custom")]=G.toString;G[Symbol.toStringTag]="Decimal";var KJ=G.constructor=iJ(OJ);XJ=new KJ(XJ);UJ=new KJ(UJ);var X=KJ;var SJ=(J)=>{if(J===null||J===void 0)throw new Error(`Cannot convert ${J===null?"null":"undefined"} to Decimal`);if(J instanceof X)return J;try{return new X(J)}catch(K){throw new Error(`Invalid numeric value: ${K.message}`)}};class A{constructor(J){if(!Array.isArray(J))throw new Error("Vector requires array");if(J.length===0)throw new Error("Vector requires at least one component");try{this.data=J.map((K,$)=>{if(K===null||K===void 0)throw new Error(`Vector component at index ${$} is ${K===null?"null":"undefined"}`);return SJ(K)})}catch(K){throw new Error(`Vector constructor failed: ${K.message}`)}this.length=this.data.length}static from(J){if(J===null||J===void 0)throw new Error(`Vector.from: argument is ${J===null?"null":"undefined"}`);return new A(J)}clone(){return new A(this.data.map((J)=>new X(J)))}toArray(){return this.data.slice()}toNumberArray(){return this.data.map((J)=>J.toNumber())}toStringArray(){return this.data.map((J)=>J.toString())}add(J){if(!J||!(J instanceof A))throw new Error("add: argument must be a Vector");if(this.length!==J.length)throw new Error(`add: dimension mismatch (${this.length} vs ${J.length})`);return new A(this.data.map((K,$)=>K.plus(J.data[$])))}sub(J){if(!J||!(J instanceof A))throw new Error("sub: argument must be a Vector");if(this.length!==J.length)throw new Error(`sub: dimension mismatch (${this.length} vs ${J.length})`);return new A(this.data.map((K,$)=>K.minus(J.data[$])))}scale(J){if(J===null||J===void 0)throw new Error(`scale: scalar is ${J===null?"null":"undefined"}`);let K;try{K=SJ(J)}catch($){throw new Error(`scale: invalid scalar - ${$.message}`)}return new A(this.data.map(($)=>$.mul(K)))}negate(){return new A(this.data.map((J)=>J.negated()))}dot(J){if(!J||!(J instanceof A))throw new Error("dot: argument must be a Vector");if(this.length!==J.length)throw new Error(`dot: dimension mismatch (${this.length} vs ${J.length})`);return this.data.reduce((K,$,Q)=>K.plus($.mul(J.data[Q])),new X(0))}outer(J){if(!J||!(J instanceof A))throw new Error("outer: argument must be a Vector");if(this.length===0||J.length===0)throw new Error("outer: cannot compute outer product with empty vector");let K=this.length,$=J.length;return Array.from({length:K},(H,Y)=>Array.from({length:$},(W,F)=>this.data[Y].mul(J.data[F])))}cross(J){if(!J||!(J instanceof A))throw new Error("cross: argument must be a Vector");if(this.length!==3||J.length!==3)throw new Error(`cross: requires 3D vectors (got ${this.length}D and ${J.length}D)`);let[K,$,Q]=this.data,[H,Y,W]=J.data;return new A([$.mul(W).minus(Q.mul(Y)),Q.mul(H).minus(K.mul(W)),K.mul(Y).minus($.mul(H))])}norm(){let J=new X(0);for(let K of this.data)J=J.plus(K.mul(K));return J.sqrt()}normalize(){let J=this.norm();if(J.isZero())throw new Error("Cannot normalize zero vector");return this.scale(new X(1).div(J))}angleBetween(J){if(!J||!(J instanceof A))throw new Error("angleBetween: argument must be a Vector");if(this.length!==J.length)throw new Error(`angleBetween: dimension mismatch (${this.length} vs ${J.length})`);let K=this.dot(J),$=this.norm(),Q=J.norm();if($.isZero()||Q.isZero())throw new Error("angleBetween: angle with zero vector is undefined");let Y=K.div($.mul(Q)).toNumber(),W=Math.min(1,Math.max(-1,Y));return new X(Math.acos(W))}projectOnto(J){if(!J||!(J instanceof A))throw new Error("projectOnto: argument must be a Vector");if(this.length!==J.length)throw new Error(`projectOnto: dimension mismatch (${this.length} vs ${J.length})`);let K=J.dot(J);if(K.isZero())throw new Error("projectOnto: cannot project onto zero vector");let $=this.dot(J).div(K);return J.scale($)}orthogonal(){if(this.norm().isZero())throw new Error("orthogonal: cannot find orthogonal vector to zero vector");if(this.length===2)return new A([this.data[1].negated(),this.data[0]]);for(let K=0;K<this.length;K++){let $=Array.from({length:this.length},(F,U)=>new X(U===K?1:0)),Q=new A($),H=Q.projectOnto(this),Y=Q.sub(H);if(!Y.norm().isZero())return Y.normalize()}throw new Error("orthogonal: unable to find orthogonal vector (degenerate case)")}isOrthogonalTo(J){if(!J||!(J instanceof A))throw new Error("isOrthogonalTo: argument must be a Vector");if(this.length!==J.length)throw new Error(`isOrthogonalTo: dimension mismatch (${this.length} vs ${J.length})`);return this.dot(J).isZero()}distance(J){if(!J||!(J instanceof A))throw new Error("distance: argument must be a Vector");if(this.length!==J.length)throw new Error(`distance: dimension mismatch (${this.length} vs ${J.length})`);return this.sub(J).norm()}equals(J,K=0){if(!(J instanceof A))return!1;if(J.length!==this.length)return!1;if(K===null)throw new Error("equals: tolerance cannot be null");let $;try{if($=SJ(K),$.isNaN())throw new Error("equals: tolerance cannot be NaN");if($.isNegative())throw new Error("equals: tolerance must be non-negative")}catch(Q){throw new Error(`equals: invalid tolerance - ${Q.message}`)}for(let Q=0;Q<this.length;Q++)if(this.data[Q].minus(J.data[Q]).abs().greaterThan($))return!1;return!0}}var e=(J)=>{if(J==null)throw new Error("Cannot convert null or undefined to Decimal");return J instanceof X?J:new X(J)};class _{constructor(J){if(!Array.isArray(J)||J.length===0)throw new Error("Matrix requires non-empty 2D array");if(!Array.isArray(J[0])||J[0].length===0)throw new Error("Matrix rows must be non-empty arrays");let K=J[0].length;for(let $ of J)if(!Array.isArray($)||$.length!==K)throw new Error("All rows must have same length");this.data=J.map(($)=>$.map((Q)=>e(Q))),this.rows=J.length,this.cols=K}static from(J){return new _(J)}static zeros(J,K){if(!Number.isInteger(J)||J<=0)throw new Error("rows must be a positive integer");if(!Number.isInteger(K)||K<=0)throw new Error("cols must be a positive integer");let $=Array.from({length:J},()=>Array.from({length:K},()=>new X(0)));return new _($)}static identity(J){if(!Number.isInteger(J)||J<=0)throw new Error("size must be a positive integer");let K=Array.from({length:J},($,Q)=>Array.from({length:J},(H,Y)=>Q===Y?new X(1):new X(0)));return new _(K)}clone(){return new _(this.data.map((J)=>J.map((K)=>new X(K))))}toArrayOfStrings(){return this.data.map((J)=>J.map((K)=>K.toString()))}toNumberArray(){return this.data.map((J)=>J.map((K)=>K.toNumber()))}isSquare(){return this.rows===this.cols}applyToVector(J){let K;if(J instanceof A)K=J;else if(Array.isArray(J))K=A.from(J);else throw new Error("applyToVector expects Vector or array");if(this.cols!==K.length)throw new Error("shape mismatch: matrix cols must equal vector length");let $=[];for(let Q=0;Q<this.rows;Q++){let H=new X(0);for(let Y=0;Y<this.cols;Y++)H=H.plus(this.data[Q][Y].mul(K.data[Y]));$.push(H)}return new A($)}add(J){if(J instanceof _){if(this.rows!==J.rows||this.cols!==J.cols)throw new Error("shape mismatch: matrices must have same dimensions");return new _(this.data.map((K,$)=>K.map((Q,H)=>Q.plus(J.data[$][H]))))}else{let K=e(J);return new _(this.data.map(($)=>$.map((Q)=>Q.plus(K))))}}sub(J){if(J instanceof _){if(this.rows!==J.rows||this.cols!==J.cols)throw new Error("shape mismatch: matrices must have same dimensions");return new _(this.data.map((K,$)=>K.map((Q,H)=>Q.minus(J.data[$][H]))))}else{let K=e(J);return new _(this.data.map(($)=>$.map((Q)=>Q.minus(K))))}}mul(J){if(J instanceof _){if(this.cols!==J.rows)throw new Error("shape mismatch: A.cols must equal B.rows for matrix multiplication");let K=Array.from({length:this.rows},()=>Array.from({length:J.cols},()=>new X(0)));for(let $=0;$<this.rows;$++)for(let Q=0;Q<this.cols;Q++){let H=this.data[$][Q];if(H.isZero())continue;for(let Y=0;Y<J.cols;Y++)K[$][Y]=K[$][Y].plus(H.mul(J.data[Q][Y]))}return new _(K)}else{let K=e(J);return new _(this.data.map(($)=>$.map((Q)=>Q.mul(K))))}}div(J){let K=e(J);if(K.isZero())throw new Error("Cannot divide by zero");return new _(this.data.map(($)=>$.map((Q)=>Q.div(K))))}negate(){return new _(this.data.map((J)=>J.map((K)=>K.negated())))}transpose(){let J=Array.from({length:this.cols},(K,$)=>Array.from({length:this.rows},(Q,H)=>new X(this.data[H][$])));return new _(J)}trace(){if(!this.isSquare())throw new Error("Trace only defined for square matrices");let J=new X(0);for(let K=0;K<this.rows;K++)J=J.plus(this.data[K][K]);return J}equals(J,K=0){if(!(J instanceof _))return!1;if(this.rows!==J.rows||this.cols!==J.cols)return!1;let $=e(K);if($.isNegative()||!$.isFinite())throw new Error("tolerance must be non-negative and finite");for(let Q=0;Q<this.rows;Q++)for(let H=0;H<this.cols;H++)if(this.data[Q][H].minus(J.data[Q][H]).abs().greaterThan($))return!1;return!0}lu(){if(!this.isSquare())throw new Error("LU decomposition requires square matrix");let J=this.rows,K=this.data.map((W)=>W.map((F)=>new X(F))),$=Array.from({length:J},(W,F)=>F),Q=Array.from({length:J},()=>Array.from({length:J},()=>new X(0)));for(let W=0;W<J;W++)Q[W][W]=new X(1);for(let W=0;W<J;W++){let F=W,U=K[W][W].abs();for(let Z=W+1;Z<J;Z++){let q=K[Z][W].abs();if(q.greaterThan(U))U=q,F=Z}if(K[F][W].isZero())throw new Error("Singular matrix: LU decomposition failed");if(F!==W){let Z=K[W];K[W]=K[F],K[F]=Z;let q=$[W];$[W]=$[F],$[F]=q;for(let R=0;R<W;R++){let V=Q[W][R];Q[W][R]=Q[F][R],Q[F][R]=V}}for(let Z=W+1;Z<J;Z++){let q=K[Z][W].div(K[W][W]);Q[Z][W]=q;for(let R=W;R<J;R++)K[Z][R]=K[Z][R].minus(q.mul(K[W][R]))}}let H=Array.from({length:J},(W,F)=>Array.from({length:J},(U,Z)=>Z<F?new X(0):K[F][Z])),Y=_.zeros(J,J);for(let W=0;W<J;W++)Y.data[W][$[W]]=new X(1);return{L:new _(Q),U:new _(H),P:Y}}determinant(){if(!this.isSquare())throw new Error("Determinant only defined for square matrices");let J=this.rows,{L:K,U:$,P:Q}=this.lu(),H=new X(1);for(let F=0;F<J;F++)H=H.mul($.data[F][F]);let Y=[];for(let F=0;F<J;F++)for(let U=0;U<J;U++)if(Q.data[F][U].equals(1))Y.push(U);let W=0;for(let F=0;F<Y.length;F++)for(let U=F+1;U<Y.length;U++)if(Y[F]>Y[U])W++;if(W%2===1)H=H.negated();return H}inverse(){if(!this.isSquare())throw new Error("Inverse only defined for square matrices");let J=this.rows,K=Array.from({length:J},(Q,H)=>Array.from({length:2*J},(Y,W)=>W<J?new X(this.data[H][W]):W-J===H?new X(1):new X(0)));for(let Q=0;Q<J;Q++){let H=Q,Y=K[Q][Q].abs();for(let F=Q+1;F<J;F++){let U=K[F][Q].abs();if(U.greaterThan(Y))Y=U,H=F}if(K[H][Q].isZero())throw new Error("Singular matrix: inverse does not exist");if(H!==Q){let F=K[Q];K[Q]=K[H],K[H]=F}let W=K[Q][Q];for(let F=0;F<2*J;F++)K[Q][F]=K[Q][F].div(W);for(let F=0;F<J;F++){if(F===Q)continue;let U=K[F][Q];if(U.isZero())continue;for(let Z=0;Z<2*J;Z++)K[F][Z]=K[F][Z].minus(U.mul(K[Q][Z]))}}let $=K.map((Q)=>Q.slice(J));return new _($)}solve(J){let K;if(J instanceof A)K=J;else if(Array.isArray(J))K=A.from(J);else throw new Error("b must be Vector or array");if(!this.isSquare())throw new Error("solve() only implemented for square matrices");let $=this.rows;if(K.length!==$)throw new Error("dimension mismatch: b length must equal matrix rows");let Q=Array.from({length:$},(Y,W)=>Array.from({length:$+1},(F,U)=>new X(U<$?this.data[W][U]:K.data[W])));for(let Y=0;Y<$;Y++){let W=Y,F=Q[Y][Y].abs();for(let U=Y+1;U<$;U++){let Z=Q[U][Y].abs();if(Z.greaterThan(F))F=Z,W=U}if(Q[W][Y].isZero())throw new Error("Singular matrix: no unique solution");if(W!==Y){let U=Q[Y];Q[Y]=Q[W],Q[W]=U}for(let U=Y+1;U<$;U++){let Z=Q[U][Y].div(Q[Y][Y]);if(Z.isZero())continue;for(let q=Y;q<$+1;q++)Q[U][q]=Q[U][q].minus(Z.mul(Q[Y][q]))}}let H=Array.from({length:$},()=>new X(0));for(let Y=$-1;Y>=0;Y--){if(Q[Y][Y].isZero())throw new Error("Zero diagonal element in back substitution: system is singular");let W=new X(0);for(let F=Y+1;F<$;F++)W=W.plus(Q[Y][F].mul(H[F]));H[Y]=Q[Y][$].minus(W).div(Q[Y][Y])}return new A(H)}qr(){let J=this.rows,K=this.cols,$=this.data.map((Y)=>Y.map((W)=>new X(W))),Q=_.identity(J).data;for(let Y=0;Y<Math.min(J,K);Y++){let W=[];for(let R=Y;R<J;R++)W.push($[R][Y]);let F=new X(0);for(let R of W)F=F.plus(R.mul(R));if(F=F.sqrt(),F.isZero())continue;let U=W[0].isNegative()?new X(-1):new X(1),Z=W.slice();Z[0]=Z[0].plus(U.mul(F));let q=new X(0);for(let R of Z)q=q.plus(R.mul(R));if(q=q.sqrt(),q.isZero())continue;for(let R=0;R<Z.length;R++)Z[R]=Z[R].div(q);for(let R=Y;R<K;R++){let V=new X(0);for(let z=0;z<Z.length;z++)V=V.plus(Z[z].mul($[Y+z][R]));for(let z=0;z<Z.length;z++)$[Y+z][R]=$[Y+z][R].minus(new X(2).mul(Z[z]).mul(V))}for(let R=0;R<J;R++){let V=new X(0);for(let z=0;z<Z.length;z++)V=V.plus(Z[z].mul(Q[Y+z][R]));for(let z=0;z<Z.length;z++)Q[Y+z][R]=Q[Y+z][R].minus(new X(2).mul(Z[z]).mul(V))}}let H=Array.from({length:J},(Y,W)=>Array.from({length:K},(F,U)=>W<=U?$[W][U]:new X(0)));return{Q:new _(Q).transpose(),R:new _(H)}}exp(J={}){let K=this.rows;if(!this.isSquare())throw new Error("Matrix exponential requires square matrix");let $=_.identity(K),Q=J.maxIter||120;if(!Number.isInteger(Q)||Q<=0)throw new Error("maxIter must be a positive integer");let H=new X(J.tolerance||"1e-40");if(H.isNegative()||H.isZero()||!H.isFinite())throw new Error("tolerance must be positive and finite");let W=((R)=>{let V=new X(0);for(let z=0;z<R.rows;z++){let T=new X(0);for(let B=0;B<R.cols;B++)T=T.plus(R.data[z][B].abs());if(T.greaterThan(V))V=T}return V})(this),F=0;if(W.greaterThan(new X(1))){let R=W.toNumber();if(!isFinite(R))throw new Error("Matrix norm too large for exponential computation");if(F=Math.max(0,Math.ceil(Math.log2(R))),F>50)throw new Error(`Matrix norm too large: requires ${F} scaling steps (max 50 allowed)`)}let U=this;if(F>0)U=this.mul(new X(1).div(new X(2).pow(F)));let Z=$.clone(),q=$.clone();for(let R=1;R<Q;R++){Z=Z.mul(U).mul(new X(1).div(R)),q=q.add(Z);let V=new X(0);for(let z=0;z<Z.rows;z++)for(let T=0;T<Z.cols;T++)V=V.plus(Z.data[z][T].abs());if(V.lessThan(H))break}for(let R=0;R<F;R++)q=q.mul(q);return q}}var jJ={};vJ(jJ,{translation:()=>$J,stretchAlongAxis:()=>xK,skew:()=>PJ,scale:()=>MJ,rotateAroundPoint:()=>oK,rotate:()=>zJ,reflectY:()=>iK,reflectX:()=>aK,reflectOrigin:()=>tK,applyTransform:()=>fJ});var u=(J)=>{if(J instanceof X){if(!J.isFinite())throw new Error(`Value must be finite (got ${J.toString()})`);return J}try{let K=new X(J);if(!K.isFinite())throw new Error(`Value must be finite (got ${J})`);return K}catch(K){throw new Error(`Invalid numeric value: "${J}" (${K.message})`)}};function h(J,K){if(J===void 0||J===null)throw new Error(`${K} is required`);if(typeof J!=="number"&&typeof J!=="string"&&!(J instanceof X))throw new Error(`${K} must be a number, string, or Decimal`);if(typeof J==="number"&&!isFinite(J))throw new Error(`${K} must be a finite number (got ${J})`);if(J instanceof X&&!J.isFinite())throw new Error(`${K} must be a finite Decimal (got ${J.toString()})`)}function $J(J,K){return h(J,"tx"),h(K,"ty"),_.from([[new X(1),new X(0),u(J)],[new X(0),new X(1),u(K)],[new X(0),new X(0),new X(1)]])}function MJ(J,K=null){if(h(J,"sx"),K!==null)h(K,"sy");let $=K===null?J:K,Q=u(J),H=u($);if(Q.isZero()||H.isZero())throw new Error("Scale factors cannot be zero (creates singular matrix)");return _.from([[Q,new X(0),new X(0)],[new X(0),H,new X(0)],[new X(0),new X(0),new X(1)]])}function zJ(J){h(J,"theta");let $=u(J).toNumber(),Q=Math.PI,H=$-2*Q*Math.floor(($+Q)/(2*Q));if(!isFinite(H))throw new Error(`Angle normalization failed for theta=${J} (too large or invalid)`);let Y=new X(Math.cos(H)),W=new X(Math.sin(H));if(!Y.isFinite()||!W.isFinite())throw new Error(`Trigonometric computation failed for theta=${J} (produced non-finite values)`);return _.from([[Y,W.negated(),new X(0)],[W,Y,new X(0)],[new X(0),new X(0),new X(1)]])}function oK(J,K,$){h(J,"theta"),h(K,"px"),h($,"py");let Q=u(K),H=u($);return $J(Q,H).mul(zJ(J)).mul($J(Q.negated(),H.negated()))}function PJ(J,K){h(J,"ax"),h(K,"ay");let $=u(J),Q=u(K);if(new X(1).minus($.mul(Q)).lessThanOrEqualTo(0))throw new Error(`Skew parameters create singular or orientation-inverting matrix (ax*ay = ${$.mul(Q).toString()}, must be < 1)`);return _.from([[new X(1),$,new X(0)],[Q,new X(1),new X(0)],[new X(0),new X(0),new X(1)]])}function xK(J,K,$){h(J,"ux"),h(K,"uy"),h($,"k");let Q=u(J),H=u(K),Y=u($);if(Y.isZero())throw new Error("Stretch factor k cannot be zero (creates singular matrix)");let W=Q.mul(Q).plus(H.mul(H));if(W.isZero())throw new Error("Axis vector (ux, uy) cannot be zero");let F=W.minus(1).abs(),U=new X(0.000001);if(F.greaterThan(U))throw new Error(`Axis vector (ux, uy) must be normalized (||u|| = 1). Current magnitude squared: ${W.toString()}, expected: 1. Use normalized vector: (${Q.div(W.sqrt()).toString()}, ${H.div(W.sqrt()).toString()})`);let Z=new X(1),q=Y.minus(Z),R=Z.plus(q.mul(Q.mul(Q))),V=q.mul(Q.mul(H)),z=q.mul(H.mul(Q)),T=Z.plus(q.mul(H.mul(H)));return _.from([[R,V,new X(0)],[z,T,new X(0)],[new X(0),new X(0),new X(1)]])}function fJ(J,K,$){if(!J||typeof J.mul!=="function")throw new Error("applyTransform: first argument must be a Matrix");if(!J.data||!Array.isArray(J.data)||J.data.length!==3||!J.data[0]||J.data[0].length!==3||!J.data[1]||J.data[1].length!==3||!J.data[2]||J.data[2].length!==3)throw new Error("applyTransform: matrix must be 3x3");h(K,"x"),h($,"y");let Q=_.from([[u(K)],[u($)],[new X(1)]]),H=J.mul(Q);if(!H||!H.data||!Array.isArray(H.data)||H.data.length!==3||!H.data[0]||!H.data[0][0]||!H.data[1]||!H.data[1][0]||!H.data[2]||!H.data[2][0])throw new Error("applyTransform: matrix multiplication produced invalid result");let Y=H.data[0][0],W=H.data[1][0],F=H.data[2][0];if(F.isZero())throw new Error("applyTransform: perspective division by zero (invalid transformation matrix)");return[Y.div(F),W.div(F)]}function aK(){return _.from([[new X(1),new X(0),new X(0)],[new X(0),new X(-1),new X(0)],[new X(0),new X(0),new X(1)]])}function iK(){return _.from([[new X(-1),new X(0),new X(0)],[new X(0),new X(1),new X(0)],[new X(0),new X(0),new X(1)]])}function tK(){return _.from([[new X(-1),new X(0),new X(0)],[new X(0),new X(-1),new X(0)],[new X(0),new X(0),new X(1)]])}var hJ={};vJ(hJ,{translation:()=>QJ,scale:()=>bJ,rotateZ:()=>gJ,rotateY:()=>kJ,rotateX:()=>LJ,rotateAroundPoint:()=>eK,rotateAroundAxis:()=>tJ,reflectYZ:()=>K$,reflectXZ:()=>J$,reflectXY:()=>rK,reflectOrigin:()=>$$,applyTransform:()=>CJ});var j=(J)=>{if(J instanceof X)return J;try{let K=new X(J);if(!K.isFinite())throw new Error(`Value must be finite, got ${J}`);return K}catch(K){throw new Error(`Invalid numeric value: ${J}`)}};function P(J,K){if(J===void 0||J===null)throw new Error(`${K} is required`);if(typeof J!=="number"&&typeof J!=="string"&&!(J instanceof X))throw new Error(`${K} must be a number, string, or Decimal`)}function NJ(J){let K=J.toNumber();if(!Number.isFinite(K))throw new Error(`Angle must be finite, got ${J}`);if(Math.abs(K)<=6.283185307179586)return K;let $=6.283185307179586,Q=K%$;if(Q>$)Q-=$;else if(Q<-$)Q+=$;return Q}function QJ(J,K,$){return P(J,"tx"),P(K,"ty"),P($,"tz"),_.from([[new X(1),new X(0),new X(0),j(J)],[new X(0),new X(1),new X(0),j(K)],[new X(0),new X(0),new X(1),j($)],[new X(0),new X(0),new X(0),new X(1)]])}function bJ(J,K=null,$=null){if(P(J,"sx"),K!==null)P(K,"sy");if($!==null)P($,"sz");let Q=K===null?J:K,H=$===null?J:$,Y=j(J),W=j(Q),F=j(H);if(Y.isZero()||W.isZero()||F.isZero());return _.from([[Y,new X(0),new X(0),new X(0)],[new X(0),W,new X(0),new X(0)],[new X(0),new X(0),F,new X(0)],[new X(0),new X(0),new X(0),new X(1)]])}function LJ(J){P(J,"theta");let K=j(J),$=NJ(K),Q=new X(Math.cos($)),H=new X(Math.sin($));return _.from([[new X(1),new X(0),new X(0),new X(0)],[new X(0),Q,H.negated(),new X(0)],[new X(0),H,Q,new X(0)],[new X(0),new X(0),new X(0),new X(1)]])}function kJ(J){P(J,"theta");let K=j(J),$=NJ(K),Q=new X(Math.cos($)),H=new X(Math.sin($));return _.from([[Q,new X(0),H,new X(0)],[new X(0),new X(1),new X(0),new X(0)],[H.negated(),new X(0),Q,new X(0)],[new X(0),new X(0),new X(0),new X(1)]])}function gJ(J){P(J,"theta");let K=j(J),$=NJ(K),Q=new X(Math.cos($)),H=new X(Math.sin($));return _.from([[Q,H.negated(),new X(0),new X(0)],[H,Q,new X(0),new X(0)],[new X(0),new X(0),new X(1),new X(0)],[new X(0),new X(0),new X(0),new X(1)]])}function tJ(J,K,$,Q){P(J,"ux"),P(K,"uy"),P($,"uz"),P(Q,"theta");let H=[j(J),j(K),j($)],Y=H[0].mul(H[0]).plus(H[1].mul(H[1])).plus(H[2].mul(H[2])).sqrt();if(Y.isZero())throw new Error("Rotation axis cannot be zero vector (ux=0, uy=0, uz=0)");H[0]=H[0].div(Y),H[1]=H[1].div(Y),H[2]=H[2].div(Y);let W=j(Q),F=NJ(W),U=new X(Math.cos(F)),Z=new X(Math.sin(F)),q=new X(1),R=H[0].mul(H[0]),V=H[1].mul(H[1]),z=H[2].mul(H[2]),T=R.plus(U.mul(q.minus(R))),B=H[0].mul(H[1]).mul(q.minus(U)).minus(H[2].mul(Z)),L=H[0].mul(H[2]).mul(q.minus(U)).plus(H[1].mul(Z)),M=H[1].mul(H[0]).mul(q.minus(U)).plus(H[2].mul(Z)),p=V.plus(U.mul(q.minus(V))),E=H[1].mul(H[2]).mul(q.minus(U)).minus(H[0].mul(Z)),b=H[2].mul(H[0]).mul(q.minus(U)).minus(H[1].mul(Z)),a=H[2].mul(H[1]).mul(q.minus(U)).plus(H[0].mul(Z)),D=z.plus(U.mul(q.minus(z)));return _.from([[T,B,L,new X(0)],[M,p,E,new X(0)],[b,a,D,new X(0)],[new X(0),new X(0),new X(0),new X(1)]])}function eK(J,K,$,Q,H,Y,W){P(J,"ux"),P(K,"uy"),P($,"uz"),P(Q,"theta"),P(H,"px"),P(Y,"py"),P(W,"pz");let F=j(H),U=j(Y),Z=j(W);return QJ(F,U,Z).mul(tJ(J,K,$,Q)).mul(QJ(F.negated(),U.negated(),Z.negated()))}function CJ(J,K,$,Q){if(!(J instanceof _))throw new Error("M must be a Matrix instance");if(J.rows!==4||J.cols!==4)throw new Error(`M must be a 4x4 matrix, got ${J.rows}x${J.cols}`);P(K,"x"),P($,"y"),P(Q,"z");let H=_.from([[j(K)],[j($)],[j(Q)],[new X(1)]]),Y=J.mul(H),W=Y.data[0][0],F=Y.data[1][0],U=Y.data[2][0],Z=Y.data[3][0];if(Z.isZero())throw new Error("Perspective division by zero: transformation results in point at infinity");return[W.div(Z),F.div(Z),U.div(Z)]}function rK(){return _.from([[new X(1),new X(0),new X(0),new X(0)],[new X(0),new X(1),new X(0),new X(0)],[new X(0),new X(0),new X(-1),new X(0)],[new X(0),new X(0),new X(0),new X(1)]])}function J$(){return _.from([[new X(1),new X(0),new X(0),new X(0)],[new X(0),new X(-1),new X(0),new X(0)],[new X(0),new X(0),new X(1),new X(0)],[new X(0),new X(0),new X(0),new X(1)]])}function K$(){return _.from([[new X(-1),new X(0),new X(0),new X(0)],[new X(0),new X(1),new X(0),new X(0)],[new X(0),new X(0),new X(1),new X(0)],[new X(0),new X(0),new X(0),new X(1)]])}function $$(){return _.from([[new X(-1),new X(0),new X(0),new X(0)],[new X(0),new X(-1),new X(0),new X(0)],[new X(0),new X(0),new X(-1),new X(0)],[new X(0),new X(0),new X(0),new X(1)]])}X.set({precision:80});var Q$="1.2.1";var H$=$J,Y$=zJ,W$=MJ,F$=PJ,Z$=fJ,X$=QJ,U$=LJ,q$=kJ,R$=gJ,V$=bJ,G$=CJ,eJ={VERSION:Q$,Decimal:X,Matrix:_,Vector:A,Transforms2D:jJ,Transforms3D:hJ,translate2D:H$,rotate2D:Y$,scale2D:W$,skew2D:F$,applyTransform2D:Z$,translate3D:X$,rotateX:U$,rotateY:q$,rotateZ:R$,scale3D:V$,applyTransform3D:G$},b$=eJ;if(typeof window!=="undefined")window.SVGMatrixLib=eJ;export{X$ as translate3D,H$ as translate2D,F$ as skew2D,V$ as scale3D,W$ as scale2D,R$ as rotateZ,q$ as rotateY,U$ as rotateX,Y$ as rotate2D,b$ as default,G$ as applyTransform3D,Z$ as applyTransform2D,A as Vector,Q$ as VERSION,hJ as Transforms3D,jJ as Transforms2D,_ as Matrix,X as Decimal};
@@ -1,3 +1,4 @@
1
+ /*! svg-matrix v1.2.1 | MIT License | https://github.com/Emasoft/svg-matrix */
1
2
  var cK=Object.create;var{getPrototypeOf:lK,defineProperty:E6,getOwnPropertyNames:Y8,getOwnPropertyDescriptor:nK}=Object,X8=Object.prototype.hasOwnProperty;var Z6=($,J,Z)=>{Z=$!=null?cK(lK($)):{};let K=J||!$||!$.__esModule?E6(Z,"default",{value:$,enumerable:!0}):Z;for(let Q of Y8($))if(!X8.call(K,Q))E6(K,Q,{get:()=>$[Q],enumerable:!0});return K},O8=new WeakMap,sK=($)=>{var J=O8.get($),Z;if(J)return J;if(J=E6({},"__esModule",{value:!0}),$&&typeof $==="object"||typeof $==="function")Y8($).map((K)=>!X8.call(J,K)&&E6(J,K,{get:()=>$[K],enumerable:!(Z=nK($,K))||Z.enumerable}));return O8.set($,J),J};var x$=($,J)=>{for(var Z in J)E6($,Z,{get:J[Z],enumerable:!0,configurable:!0,set:(K)=>J[Z]=()=>K})};var oK=($,J)=>()=>($&&(J=$($=0)),J);var f7=(($)=>typeof require!=="undefined"?require:typeof Proxy!=="undefined"?new Proxy($,{get:(J,Z)=>(typeof require!=="undefined"?require:J)[Z]}):$)(function($){if(typeof require!=="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+$+'" is not supported')});var I6={};x$(I6,{win32:()=>i9,toNamespacedPath:()=>_z,sep:()=>Xz,resolve:()=>qz,relative:()=>Fz,posix:()=>$6,parse:()=>Yz,normalize:()=>Wz,join:()=>Gz,isAbsolute:()=>jz,format:()=>Oz,extname:()=>Mz,dirname:()=>Uz,delimiter:()=>kz,default:()=>zz,basename:()=>Vz});var rH,Y5,aH,tH,eH,$z,Jz=($,J)=>()=>(J||$((J={exports:{}}).exports,J),J.exports),Kz=($,J,Z,K)=>{if(J&&typeof J=="object"||typeof J=="function")for(let Q of tH(J))!$z.call($,Q)&&Q!==Z&&Y5($,Q,{get:()=>J[Q],enumerable:!(K=aH(J,Q))||K.enumerable});return $},Zz=($,J,Z)=>(Z=$!=null?rH(eH($)):{},Kz(J||!$||!$.__esModule?Y5(Z,"default",{value:$,enumerable:!0}):Z,$)),Qz,X5,m0,Hz,O5=function($){return $},k5=function(){throw new Error("Not implemented")},$6,i9,zz,qz,Wz,jz,Gz,Fz,_z,Uz,Vz,Mz,Oz,Yz,Xz,kz;var C6=oK(()=>{rH=Object.create,Y5=Object.defineProperty,aH=Object.getOwnPropertyDescriptor,tH=Object.getOwnPropertyNames,eH=Object.getPrototypeOf,$z=Object.prototype.hasOwnProperty,Qz=Jz(($,J)=>{function Z(z){if(typeof z!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(z))}function K(z,q){for(var W="",j=0,G=-1,F=0,_,U=0;U<=z.length;++U){if(U<z.length)_=z.charCodeAt(U);else{if(_===47)break;_=47}if(_===47){if(!(G===U-1||F===1))if(G!==U-1&&F===2){if(W.length<2||j!==2||W.charCodeAt(W.length-1)!==46||W.charCodeAt(W.length-2)!==46){if(W.length>2){var O=W.lastIndexOf("/");if(O!==W.length-1){O===-1?(W="",j=0):(W=W.slice(0,O),j=W.length-1-W.lastIndexOf("/")),G=U,F=0;continue}}else if(W.length===2||W.length===1){W="",j=0,G=U,F=0;continue}}q&&(W.length>0?W+="/..":W="..",j=2)}else W.length>0?W+="/"+z.slice(G+1,U):W=z.slice(G+1,U),j=U-G-1;G=U,F=0}else _===46&&F!==-1?++F:F=-1}return W}function Q(z,q){var W=q.dir||q.root,j=q.base||(q.name||"")+(q.ext||"");return W?W===q.root?W+j:W+z+j:j}var H={resolve:function(){for(var z="",q=!1,W,j=arguments.length-1;j>=-1&&!q;j--){var G;j>=0?G=arguments[j]:(W===void 0&&(W=process.cwd()),G=W),Z(G),G.length!==0&&(z=G+"/"+z,q=G.charCodeAt(0)===47)}return z=K(z,!q),q?z.length>0?"/"+z:"/":z.length>0?z:"."},normalize:function(z){if(Z(z),z.length===0)return".";var q=z.charCodeAt(0)===47,W=z.charCodeAt(z.length-1)===47;return z=K(z,!q),z.length===0&&!q&&(z="."),z.length>0&&W&&(z+="/"),q?"/"+z:z},isAbsolute:function(z){return Z(z),z.length>0&&z.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var z,q=0;q<arguments.length;++q){var W=arguments[q];Z(W),W.length>0&&(z===void 0?z=W:z+="/"+W)}return z===void 0?".":H.normalize(z)},relative:function(z,q){if(Z(z),Z(q),z===q||(z=H.resolve(z),q=H.resolve(q),z===q))return"";for(var W=1;W<z.length&&z.charCodeAt(W)===47;++W);for(var j=z.length,G=j-W,F=1;F<q.length&&q.charCodeAt(F)===47;++F);for(var _=q.length,U=_-F,O=G<U?G:U,V=-1,M=0;M<=O;++M){if(M===O){if(U>O){if(q.charCodeAt(F+M)===47)return q.slice(F+M+1);if(M===0)return q.slice(F+M)}else G>O&&(z.charCodeAt(W+M)===47?V=M:M===0&&(V=0));break}var Y=z.charCodeAt(W+M),X=q.charCodeAt(F+M);if(Y!==X)break;Y===47&&(V=M)}var w="";for(M=W+V+1;M<=j;++M)(M===j||z.charCodeAt(M)===47)&&(w.length===0?w+="..":w+="/..");return w.length>0?w+q.slice(F+V):(F+=V,q.charCodeAt(F)===47&&++F,q.slice(F))},_makeLong:function(z){return z},dirname:function(z){if(Z(z),z.length===0)return".";for(var q=z.charCodeAt(0),W=q===47,j=-1,G=!0,F=z.length-1;F>=1;--F)if(q=z.charCodeAt(F),q===47){if(!G){j=F;break}}else G=!1;return j===-1?W?"/":".":W&&j===1?"//":z.slice(0,j)},basename:function(z,q){if(q!==void 0&&typeof q!="string")throw new TypeError('"ext" argument must be a string');Z(z);var W=0,j=-1,G=!0,F;if(q!==void 0&&q.length>0&&q.length<=z.length){if(q.length===z.length&&q===z)return"";var _=q.length-1,U=-1;for(F=z.length-1;F>=0;--F){var O=z.charCodeAt(F);if(O===47){if(!G){W=F+1;break}}else U===-1&&(G=!1,U=F+1),_>=0&&(O===q.charCodeAt(_)?--_===-1&&(j=F):(_=-1,j=U))}return W===j?j=U:j===-1&&(j=z.length),z.slice(W,j)}else{for(F=z.length-1;F>=0;--F)if(z.charCodeAt(F)===47){if(!G){W=F+1;break}}else j===-1&&(G=!1,j=F+1);return j===-1?"":z.slice(W,j)}},extname:function(z){Z(z);for(var q=-1,W=0,j=-1,G=!0,F=0,_=z.length-1;_>=0;--_){var U=z.charCodeAt(_);if(U===47){if(!G){W=_+1;break}continue}j===-1&&(G=!1,j=_+1),U===46?q===-1?q=_:F!==1&&(F=1):q!==-1&&(F=-1)}return q===-1||j===-1||F===0||F===1&&q===j-1&&q===W+1?"":z.slice(q,j)},format:function(z){if(z===null||typeof z!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof z);return Q("/",z)},parse:function(z){Z(z);var q={root:"",dir:"",base:"",ext:"",name:""};if(z.length===0)return q;var W=z.charCodeAt(0),j=W===47,G;j?(q.root="/",G=1):G=0;for(var F=-1,_=0,U=-1,O=!0,V=z.length-1,M=0;V>=G;--V){if(W=z.charCodeAt(V),W===47){if(!O){_=V+1;break}continue}U===-1&&(O=!1,U=V+1),W===46?F===-1?F=V:M!==1&&(M=1):F!==-1&&(M=-1)}return F===-1||U===-1||M===0||M===1&&F===U-1&&F===_+1?U!==-1&&(_===0&&j?q.base=q.name=z.slice(1,U):q.base=q.name=z.slice(_,U)):(_===0&&j?(q.name=z.slice(1,F),q.base=z.slice(1,U)):(q.name=z.slice(_,F),q.base=z.slice(_,U)),q.ext=z.slice(F,U)),_>0?q.dir=z.slice(0,_-1):j&&(q.dir="/"),q},sep:"/",delimiter:":",win32:null,posix:null};H.posix=H,J.exports=H}),X5=Zz(Qz()),m0=X5,Hz=X5;m0.parse??=k5;Hz.parse??=k5;$6={resolve:m0.resolve.bind(m0),normalize:m0.normalize.bind(m0),isAbsolute:m0.isAbsolute.bind(m0),join:m0.join.bind(m0),relative:m0.relative.bind(m0),toNamespacedPath:O5,dirname:m0.dirname.bind(m0),basename:m0.basename.bind(m0),extname:m0.extname.bind(m0),format:m0.format.bind(m0),parse:m0.parse.bind(m0),sep:"/",delimiter:":",win32:void 0,posix:void 0,_makeLong:O5},i9={sep:"\\",delimiter:";",win32:void 0,...$6,posix:$6};$6.win32=i9.win32=i9;$6.posix=$6;zz=$6,{resolve:qz,normalize:Wz,isAbsolute:jz,join:Gz,relative:Fz,toNamespacedPath:_z,dirname:Uz,basename:Vz,extname:Mz,format:Oz,parse:Yz,sep:Xz,delimiter:kz}=$6});var F8={};x$(F8,{validateXML:()=>EK,validateSVGAsync:()=>nz,validateSVG:()=>TK,straightCurves:()=>m9,sortDefsChildren:()=>QK,sortAttrs:()=>ZK,simplifyPaths:()=>uK,simplifyPath:()=>DK,saveOutput:()=>b5,reusePaths:()=>HK,removeXlink:()=>WK,removeXMLProcInst:()=>x5,removeXMLNS:()=>l5,removeViewBox:()=>c5,removeUselessDefs:()=>y5,removeUselessCommands:()=>c9,removeUnknownsAndDefaults:()=>D5,removeTitle:()=>m5,removeStyleElement:()=>qK,removeScriptElement:()=>s5,removeRasterImages:()=>n5,removeOffCanvasPath:()=>zK,removeNonInheritableGroupAttrs:()=>h5,removeMetadata:()=>h$,removeLeadingZero:()=>D9,removeHiddenElements:()=>S$,removeEmptyText:()=>u5,removeEmptyContainers:()=>v$,removeEmptyAttrs:()=>p5,removeElementsByAttr:()=>MK,removeEditorsNSData:()=>Q8,removeDoctype:()=>g5,removeDimensions:()=>_K,removeDesc:()=>d5,removeComments:()=>D$,removeAttrs:()=>VK,removeAttributesBySelector:()=>UK,printHierarchicalMatrix:()=>gz,presetNone:()=>W8,presetDefault:()=>q8,prefixIds:()=>FK,optimizePaths:()=>yK,optimizeAnimationTiming:()=>hK,optimize:()=>YK,negativeExtraSpace:()=>h9,moveGroupAttrsToElems:()=>$K,moveElemsAttrsToGroup:()=>JK,minifyStyles:()=>z8,mergePaths:()=>e5,measureDistance:()=>AK,loadInput:()=>a6,lineShorthands:()=>g9,inlineStyles:()=>KK,imageToPath:()=>CK,generateOutput:()=>t6,generateFullCompatibilityMatrix:()=>uz,generateFlexibleSVGTable:()=>bK,generateCompatibilityMatrixSVG:()=>xz,generateCompatibilityMatrixFlexible:()=>mz,formatPrecision:()=>T5,floatPrecision:()=>p9,flattenUseElements:()=>IK,flattenPatterns:()=>BK,flattenMasks:()=>LK,flattenGradients:()=>wK,flattenFilters:()=>NK,flattenClipPaths:()=>kK,flattenAll:()=>vK,fixInvalidSVG:()=>fK,exportEmbeddedResources:()=>mK,escapeXml:()=>Pz,embedExternalDependencies:()=>G8,detectOutputTarget:()=>K8,detectInputType:()=>r6,detectCollisions:()=>PK,default:()=>Wq,decomposeTransform:()=>gK,createOperation:()=>G0,createConfig:()=>XK,convertTransform:()=>r5,convertToZ:()=>x9,convertToRelative:()=>y9,convertToAbsolute:()=>u9,convertStyleToAttrs:()=>H8,convertShapesToPath:()=>o5,convertQuadraticToSmooth:()=>n9,convertPathData:()=>i5,convertEllipseToCircle:()=>a5,convertCubicToSmooth:()=>s9,convertCubicToQuadratic:()=>l9,convertColors:()=>y$,collapseRepeated:()=>d9,collapseGroups:()=>t5,cleanupNumericValues:()=>f$,cleanupListOfValues:()=>f5,cleanupIds:()=>Z8,cleanupEnableBackground:()=>v5,cleanupAttributes:()=>S5,arcShorthands:()=>o9,applyPreset:()=>OK,analyzeCompatibilityMatrix:()=>yz,analyzeCompatibility:()=>fz,addClassesToSVGElement:()=>GK,addAttributesToSVGElement:()=>jK,ValidationSeverity:()=>A0,PRECISION_LEVELS:()=>E5,OutputTarget:()=>F7,OutputFormat:()=>_7,MAX_PRECISION:()=>i6,InputType:()=>D0,DEFAULT_PRECISION:()=>E$});/*!
2
3
  * decimal.js v10.6.0
3
4
  * An arbitrary-precision Decimal type for JavaScript.
@@ -489,4 +490,4 @@ ${z}
489
490
  // ===== END EMBEDDED RESOURCES INTERCEPTOR =====
490
491
 
491
492
  `}function Kq($){let J=new Map,Z=(Q,H)=>{if(!Q||!H)return;let z=Q.replace(/['"]/g,"").trim().split(",")[0].trim();if(!J.has(z))J.set(z,new Set);let q=J.get(z);for(let W of H)q.add(W)},K=(Q)=>{if(!Q)return;let z=(Q.getAttribute?.("style")||"").match(/font-family:\s*([^;]+)/i),q=z?z[1]:null,W=Q.getAttribute?.("font-family"),j=Q.getAttribute?.("face"),G=q||W||j,F="";if(Q.childNodes){for(let _ of Q.childNodes)if(_.nodeType===3)F+=_.nodeValue||""}if(G&&F.trim())Z(G,F);if(Q.tagName==="text"||Q.tagName==="tspan"){let _=G;if(!_&&Q.parentNode){let O=(Q.parentNode.getAttribute?.("style")||"").match(/font-family:\s*([^;]+)/i);_=O?O[1]:Q.parentNode.getAttribute?.("font-family")}if(_&&F.trim())Z(_,F)}if(Q.children)for(let _ of Q.children)K(_)};return K($),J}function Zq($){let J=[...$].sort().join("");return encodeURIComponent(J)}function Qq($){return $&&($.includes("fonts.googleapis.com")||$.includes("fonts.gstatic.com"))}function Hq($){try{let Z=new URL($).searchParams.get("family");if(Z)return Z.split(":")[0].replace(/\+/g," ")}catch(J){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${J.message}`);let Z=$.match(/family=([^&:]+)/);if(Z)return Z[1].replace(/\+/g," ")}return null}function zq($,J){if(!J)return $;try{let Z=new URL($);return Z.searchParams.set("text",decodeURIComponent(J)),Z.toString()}catch(Z){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${Z.message}`);let K=$.includes("?")?"&":"?";return`${$}${K}text=${J}`}}var G8=G0(async($,J={})=>{let{basePath:Z="",embedImages:K=!0,embedExternalSVGs:Q=!0,externalSVGMode:H="extract",embedCSS:z=!0,embedFonts:q=!0,embedScripts:W=!0,embedAudio:j=!1,subsetFonts:G=!0,verbose:F=!1,recursive:_=!0,maxRecursionDepth:U=10,timeout:O=30000,onMissingResource:V="warn",onProgress:M=null,idPrefix:Y="ext_",_visitedURLs:X=null}=J,w=X||new Set,R=[],I=new Map,f=0,u=(h)=>{if(!h||!h.attributes)return;let E=["http://www.inkscape.org/namespaces/inkscape","http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd","http://ns.adobe.com/AdobeIllustrator/","http://ns.adobe.com/AdobeSVGViewerExtensions/","http://www.bohemiancoding.com/sketch/ns","http://www.figma.com/figma/ns","http://www.serif.com/","http://www.vecta.io/nano"],d=["http://www.w3.org/2000/svg","http://www.w3.org/1999/xlink","http://www.w3.org/XML/1998/namespace","http://www.w3.org/2000/xmlns/"],c=h.attributes;for(let p=0;p<c.length;p++){let N=c[p];if(N.name.startsWith("xmlns:")){let y=N.name.substring(6),B=N.value;if(E.some((e)=>B.startsWith(e))||!d.includes(B))I.set(y,B)}}},m=(h,E)=>{let d=`Failed to fetch resource: ${h} - ${E.message}`;if(V==="fail")throw new Error(d);else if(V==="warn")R.push(d),console.warn("embedExternalDependencies:",d);return null};if(K){let E=[...$.getElementsByTagName("image")];if(M)M("images",0,E.length);for(let d=0;d<E.length;d++){let c=E[d],p=c.getAttribute("href")||c.getAttribute("xlink:href");if(!p||!A5(p))continue;try{let N=x7(p,Z),{content:y,contentType:B}=await m7(N,"binary",O),e=o6(y,B.split(";")[0]);if(c.getAttribute("href"))c.setAttribute("href",e);if(c.getAttribute("xlink:href"))c.setAttribute("xlink:href",e)}catch(N){m(p,N)}if(M)M("images",d+1,E.length)}}if(Q){let E=[...$.getElementsByTagName("use")];if(M)M("externalSVGs",0,E.length);let d=$.querySelector("defs");if(!d){let c=$.documentElement||$;if(!c){if(R.push("Cannot add defs: document has no root SVG element"),M)M("externalSVGs",E.length,E.length)}else if(d=new B0("defs",{},[]),typeof c.insertBefore==="function"&&c.firstChild)c.insertBefore(d,c.firstChild);else if(typeof c.appendChild==="function")c.appendChild(d);else if(c.children&&Array.isArray(c.children))c.children.unshift(d),d.parentNode=c}if(d)for(let c=0;c<E.length;c++){let p=E[c],N=p.getAttribute("href")||p.getAttribute("xlink:href");if(!N||!A5(N))continue;let{path:y,fragment:B}=az(N);if(!y)continue;let e=x7(y,Z);if(w.has(e)){R.push(`Circular reference detected: ${e}`);continue}w.add(e);try{let{content:r}=await m7(e,"text",O),s=d0(r);if(!s){m(y,new Error("Failed to parse SVG"));continue}let z0=s.documentElement||s;if(u(z0),_&&U>0)await G8(s,{...J,basePath:e,maxRecursionDepth:U-1,_visitedURLs:w});f++;let T=`${Y}${f}_`;if(H==="extract"&&B){let P=s.getElementById(B);if(P){let t=P.clone?P.clone():JSON.parse(JSON.stringify(P));$8(t,T),d.children.push(t);let $0=T+B;if(p.getAttribute("href"))p.setAttribute("href","#"+$0);if(p.getAttribute("xlink:href"))p.setAttribute("xlink:href","#"+$0)}else m(N,new Error(`Fragment #${B} not found in ${y}`))}else{let P=s.documentElement||s;$8(P,T);let t=T+"svg";P.setAttribute("id",t),d.children.push(P);let $0=B?"#"+T+B:"#"+t;if(p.getAttribute("href"))p.setAttribute("href",$0);if(p.getAttribute("xlink:href"))p.setAttribute("xlink:href",$0)}}catch(r){m(y,r)}if(M)M("externalSVGs",c+1,E.length)}}if(z||q){let E=[...$.getElementsByTagName("style")];if(M)M("stylesheets",0,E.length);let d=G?Kq($):null;for(let c=0;c<E.length;c++){let p=E[c],N=p.textContent||"";if(z){let{imports:y}=a9(N);for(let B of y.reverse())try{let e=B.url;if(d&&Qq(e)){let P=Hq(e);if(P&&d.has(P)){let t=Zq(d.get(P));if(e=zq(e,t),F)console.log(`Font subsetting: ${P} -> ${d.get(P).size} chars`)}}let r=x7(e,Z),{content:s}=await m7(r,"text",O),z0=s,T=a9(s).imports;if(T.length>0)for(let P of T.reverse())try{let t=x7(P.url,r),$0=await m7(t,"text",O);z0=z0.substring(0,P.index)+$0.content+z0.substring(P.index+P.fullMatch.length)}catch(t){m(P.url,t)}N=N.substring(0,B.index)+z0+N.substring(B.index+B.fullMatch.length)}catch(e){m(B.url,e)}}if(z||q){let{urls:y}=a9(N);for(let B of y.reverse()){let e=b$(B.url),r=e.startsWith("font/")||e.includes("fontobject");if(r&&!q)continue;if(!r&&!z)continue;try{let s=x7(B.url,Z),{content:z0,contentType:T}=await m7(s,"binary",O),t=`url("${o6(z0,T.split(";")[0])}")`;N=N.substring(0,B.index)+t+N.substring(B.index+B.fullMatch.length)}catch(s){m(B.url,s)}}}if(p.textContent=N,M)M("stylesheets",c+1,E.length)}}if(W){let E=[...$.getElementsByTagName("script")];if(M)M("scripts",0,E.length);for(let d=0;d<E.length;d++){let c=E[d],p=c.getAttribute("src")||c.getAttribute("href")||c.getAttribute("xlink:href");if(!p)continue;if(p.startsWith("data:"))continue;try{let N=x7(p,Z),{content:y}=await m7(N,"text",O);c.removeAttribute("src"),c.removeAttribute("href"),c.removeAttribute("xlink:href"),xK(c,y,$)}catch(N){m(p,N)}if(M)M("scripts",d+1,E.length)}}if(j){let E=[...$.getElementsByTagName("audio")];if(M)M("audio",0,E.length);for(let d=0;d<E.length;d++){let c=E[d],p=c.getAttribute("src");if(p&&!p.startsWith("data:"))try{let y=x7(p,Z),{content:B,contentType:e}=await m7(y,"binary",O),r=e.split(";")[0]||"audio/mpeg",s=o6(B,r);c.setAttribute("src",s)}catch(y){m(p,y)}let N=c.getElementsByTagName("source");for(let y of N){let B=y.getAttribute("src");if(B&&!B.startsWith("data:"))try{let e=x7(B,Z),{content:r,contentType:s}=await m7(e,"binary",O),z0=s.split(";")[0]||y.getAttribute("type")||"audio/mpeg",T=o6(r,z0);y.setAttribute("src",T)}catch(e){m(B,e)}}if(M)M("audio",d+1,E.length)}}if(W){let h=[],E=$.getElementsByTagName("script");for(let N of E)if(N.textContent)h.push(N.textContent);let d=$.getElementsByTagName("style");for(let N of d)if(N.textContent)h.push(N.textContent);let c=$.getElementsByTagName("foreignObject");for(let N of c){let y=N.textContent||"";if(y)h.push(y)}let p=new Set;for(let N of h){let y=$q(N);for(let B of y)p.add(B)}if(p.size>0){let N=new Map;if(M)M("resources",0,p.size);let y=0;for(let B of p){try{let e=x7(B,Z),{content:r,contentType:s}=await m7(e,"binary",O),z0=s.split(";")[0]||b$(B),T=o6(r,z0);if(N.set(B,T),F){let P=(r.length/1024).toFixed(1);console.log(`Embedded resource: ${B} (${P} KB)`)}}catch(e){m(B,e)}if(y++,M)M("resources",y,p.size)}if(N.size>0){let B=Jq(N),e=E[0];if(e){let r=e.textContent||"";if(B.includes("<")||B.includes("&")||r.includes("<")||r.includes("&"))e.setAttribute("data-cdata-pending","true");e.textContent=B+r}else{let r=$.createElement("script");r.setAttribute("type","text/javascript"),r.setAttribute("data-cdata-pending","true"),r.textContent=B;let s=$.documentElement||$;if(s.firstChild)s.insertBefore(r,s.firstChild);else s.appendChild(r)}if(F)console.log(`Injected resource interceptor for ${N.size} embedded resources`)}}}let S=$.documentElement||$;if(!S.getAttribute("xmlns"))S.setAttribute("xmlns","http://www.w3.org/2000/svg");if(N7($).includes("xlink:")&&!S.getAttribute("xmlns:xlink"))S.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink");for(let[h,E]of I){let d=`xmlns:${h}`;if(!S.getAttribute(d))S.setAttribute(d,E)}if(R.length>0)$._embedWarnings=R;return $}),qq={"image/png":".png","image/jpeg":".jpg","image/gif":".gif","image/webp":".webp","image/svg+xml":".svg","image/bmp":".bmp","image/x-icon":".ico","image/tiff":".tiff","audio/mpeg":".mp3","audio/wav":".wav","audio/ogg":".ogg","audio/webm":".webm","audio/aac":".aac","audio/flac":".flac","video/mp4":".mp4","video/webm":".webm","video/ogg":".ogv","video/quicktime":".mov","application/javascript":".js","text/javascript":".js","text/css":".css","font/woff":".woff","font/woff2":".woff2","font/ttf":".ttf","font/otf":".otf","application/font-woff":".woff","application/font-woff2":".woff2","application/x-font-ttf":".ttf","application/x-font-opentype":".otf"};function W6($){if(!$||!$.startsWith("data:"))return null;let J=$.match(/^data:([^;,]+)?(?:;([^,]+))?,(.*)$/);if(!J)return null;let Z=J[1]||"application/octet-stream",K=J[2]||"",Q=J[3]||"";return{mimeType:Z,encoding:K,data:Q}}function j6($){if($.encoding==="base64")return Buffer.from($.data,"base64");try{return decodeURIComponent($.data)}catch(J){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${J.message}`);return $.data}}function J6($,J,Z,K=null){let Q=qq[J]||".bin";if(K){let z=K.replace(/[^a-zA-Z0-9._-]/g,"_");return`${$}_${z}`}let H="resource";if(J.startsWith("image/"))H="image";else if(J.startsWith("audio/"))H="audio";else if(J.startsWith("video/"))H="video";else if(J.startsWith("font/")||J.includes("font"))H="font";else if(J.includes("javascript"))H="script";else if(J.includes("css"))H="style";return`${$}_${H}_${String(Z).padStart(3,"0")}${Q}`}async function mK($,J={}){let Z=r6($),K=await a6($,Z),Q=J.outputFormat||(Z===D0.DOM_ELEMENT?_7.DOM_ELEMENT:_7.SVG_STRING),{outputDir:H=null,filenamePrefix:z="resource",extractImages:q=!0,extractFonts:W=!0,extractScripts:j=!0,extractStyles:G=!0,extractAudio:F=!0,extractVideo:_=!0,elementIds:U=null,restoreGoogleFonts:O=!0,dryRun:V=!1,extractOnly:M=!1,onProgress:Y=null}=J,X=[],w=[],R=0,I=U?new Set(Array.isArray(U)?U:[U]):null,f=(S)=>{if(!I)return!0;let x=S;while(x&&x.getAttribute){let h=x.getAttribute("id");if(h&&I.has(h))return!0;x=x.parentNode}return!1},u=async(S,x,h)=>{let E=0;if(typeof Buffer!=="undefined"&&Buffer.isBuffer(x))E=x.length;else if(typeof Buffer!=="undefined")E=Buffer.byteLength(x,"utf8");else if(typeof Blob!=="undefined")E=new Blob([x]).size;else E=x.length||0;let d={filename:S,path:H?`${H}/${S}`:S,mimeType:h,size:E};if(!V&&H)try{let c=await import("node:fs/promises"),p=await Promise.resolve().then(() => (C6(),I6));await c.mkdir(H,{recursive:!0});let N=p.join(H,S);if(typeof Buffer!=="undefined"&&Buffer.isBuffer(x))await c.writeFile(N,x);else await c.writeFile(N,x,"utf8");d.path=N,X.push(d)}catch(c){w.push(`Failed to save ${S}: ${c.message}`),d.error=c.message}else X.push(d);return d};if(q){let x=[...K.getElementsByTagName("image")];if(Y)Y("images",0,x.length);for(let h=0;h<x.length;h++){let E=x[h];if(!f(E))continue;let d=E.getAttribute("href")||E.getAttribute("xlink:href");if(!d||!d.startsWith("data:"))continue;let c=W6(d);if(!c)continue;if(!c.mimeType.startsWith("image/"))continue;R++;let p=J6(z,c.mimeType,R),N=j6(c),y=await u(p,N,c.mimeType);if(y.type="image",y.elementId=E.getAttribute("id"),!M){let B=`./${p}`;if(E.getAttribute("href"))E.setAttribute("href",B);if(E.getAttribute("xlink:href"))E.setAttribute("xlink:href",B)}if(Y)Y("images",h+1,x.length)}}if(F){let x=[...K.getElementsByTagName("audio")];if(Y)Y("audio",0,x.length);for(let h=0;h<x.length;h++){let E=x[h];if(!f(E))continue;let d=E.getAttribute("src");if(d&&d.startsWith("data:")){let p=W6(d);if(p&&p.mimeType.startsWith("audio/")){R++;let N=J6(z,p.mimeType,R),y=j6(p),B=await u(N,y,p.mimeType);if(B.type="audio",B.elementId=E.getAttribute("id"),!M)E.setAttribute("src",`./${N}`)}}let c=E.getElementsByTagName("source");for(let p of c){let N=p.getAttribute("src");if(N&&N.startsWith("data:")){let y=W6(N);if(y&&y.mimeType.startsWith("audio/")){R++;let B=J6(z,y.mimeType,R),e=j6(y),r=await u(B,e,y.mimeType);if(r.type="audio",!M)p.setAttribute("src",`./${B}`)}}}if(Y)Y("audio",h+1,x.length)}}if(_){let x=[...K.getElementsByTagName("video")];if(Y)Y("video",0,x.length);for(let h=0;h<x.length;h++){let E=x[h];if(!f(E))continue;let d=E.getAttribute("src");if(d&&d.startsWith("data:")){let p=W6(d);if(p&&p.mimeType.startsWith("video/")){R++;let N=J6(z,p.mimeType,R),y=j6(p),B=await u(N,y,p.mimeType);if(B.type="video",B.elementId=E.getAttribute("id"),!M)E.setAttribute("src",`./${N}`)}}let c=E.getElementsByTagName("source");for(let p of c){let N=p.getAttribute("src");if(N&&N.startsWith("data:")){let y=W6(N);if(y&&y.mimeType.startsWith("video/")){R++;let B=J6(z,y.mimeType,R),e=j6(y),r=await u(B,e,y.mimeType);if(r.type="video",!M)p.setAttribute("src",`./${B}`)}}}if(Y)Y("video",h+1,x.length)}}if(j){let x=[...K.getElementsByTagName("script")];if(Y)Y("scripts",0,x.length);for(let h=0;h<x.length;h++){let E=x[h];if(!f(E))continue;let d=E.getAttribute("href")||E.getAttribute("xlink:href");if(d&&!d.startsWith("data:"))continue;let c="";if(d&&d.startsWith("data:")){let y=W6(d);if(y){let B=j6(y);c=typeof B==="string"?B:B.toString("utf8")}}else if(c=E.textContent||"",E.firstChild&&E.firstChild.nodeType===4)c=E.firstChild.nodeValue||"";if(!c.trim())continue;R++;let p=J6(z,"application/javascript",R),N=await u(p,c,"application/javascript");if(N.type="script",N.elementId=E.getAttribute("id"),!M){let y=0;while(E.firstChild&&y++<1e4){let B=E.firstChild;if(E.removeChild(B),E.firstChild===B)break}if(y>=1e4)console.error("Safety limit reached removing script children: 10000 iterations");E.setAttribute("href",`./${p}`)}if(Y)Y("scripts",h+1,x.length)}}if(G||W){let x=[...K.getElementsByTagName("style")];if(Y)Y("styles",0,x.length);for(let h=0;h<x.length;h++){let E=x[h];if(!f(E))continue;let d=E.textContent||"";if(E.firstChild&&E.firstChild.nodeType===4)d=E.firstChild.nodeValue||"";if(!d.trim())continue;let c=!1;if(W){let p=/@font-face\s*\{[^}]*\}/gi,N=d.match(p)||[];for(let y of N){let B=y.match(/src:\s*url\(["']?(data:[^"')]+)["']?\)/);if(B){let e=B[1],r=W6(e);if(r){R++;let s=J6(z,r.mimeType,R),z0=j6(r),T=await u(s,z0,r.mimeType);T.type="font";let P=y.match(/font-family:\s*["']?([^"';]+)["']?/);if(P)T.fontFamily=P[1].trim();if(!M)d=d.replace(e,`./${s}`),c=!0}}}if(O){let y=[],B=/font-family:\s*["']?([^"';,]+)/gi,e;while((e=B.exec(d))!==null){let r=e[1].trim();if(["Roboto","Open Sans","Lato","Montserrat","Oswald","Raleway","Poppins","Source Sans Pro","Ubuntu","Playfair Display","Merriweather","Nunito","PT Sans","Rubik","Work Sans","DM Serif Display","Monofett","Dokdo","Orbitron","Notable","Fira Mono","Fira Code","Inter","Noto Sans","Noto Serif"].some((z0)=>r.toLowerCase().includes(z0.toLowerCase())))y.push(r)}if(y.length>0&&!M){let r=[...new Set(y)],s=`@import url('https://fonts.googleapis.com/css2?family=${r.map((z0)=>z0.replace(/\s+/g,"+")).join("&family=")}&display=swap');
492
- `;if(!d.includes("fonts.googleapis.com"))d=s+d,c=!0,w.push(`Restored Google Fonts import for: ${r.join(", ")}`)}}}if(G&&d.trim()){R++;let p=J6(z,"text/css",R),N=await u(p,d,"text/css");if(N.type="stylesheet",N.elementId=E.getAttribute("id"),!M){let y=0;while(E.firstChild&&y++<1e4){let B=E.firstChild;if(E.removeChild(B),E.firstChild===B)break}if(y>=1e4)console.error("Safety limit reached removing style children: 10000 iterations");E.textContent=`@import url('./${p}');`,c=!0}}else if(c&&!M){let p=0;while(E.firstChild&&p++<1e4){let N=E.firstChild;if(E.removeChild(N),E.firstChild===N)break}if(p>=1e4)console.error("Safety limit reached updating style children: 10000 iterations");xK(E,d,K)}if(Y)Y("styles",h+1,x.length)}}if(!M){if(K._exportedResources=X,w.length>0)K._exportWarnings=w}return{doc:M?null:t6(K,Q,J),extractedFiles:X,warnings:w,summary:{totalExtracted:X.length,images:X.filter((S)=>S.type==="image").length,audio:X.filter((S)=>S.type==="audio").length,video:X.filter((S)=>S.type==="video").length,scripts:X.filter((S)=>S.type==="script").length,fonts:X.filter((S)=>S.type==="font").length,stylesheets:X.filter((S)=>S.type==="stylesheet").length,totalSize:X.reduce((S,x)=>S+x.size,0)}}}var Wq={MAX_PRECISION:i6,DEFAULT_PRECISION:E$,PRECISION_LEVELS:E5,formatPrecision:T5,InputType:D0,OutputFormat:_7,OutputTarget:F7,detectInputType:r6,detectOutputTarget:K8,loadInput:a6,generateOutput:t6,saveOutput:b5,createOperation:G0,cleanupIds:Z8,cleanupNumericValues:f$,cleanupListOfValues:f5,cleanupAttributes:S5,cleanupEnableBackground:v5,removeUnknownsAndDefaults:D5,removeNonInheritableGroupAttrs:h5,removeUselessDefs:y5,removeHiddenElements:S$,removeEmptyText:u5,removeEmptyContainers:v$,removeDoctype:g5,removeXMLProcInst:x5,removeComments:D$,removeMetadata:h$,removeTitle:m5,removeDesc:d5,removeEditorsNSData:Q8,removeEmptyAttrs:p5,removeViewBox:c5,removeXMLNS:l5,removeRasterImages:n5,removeScriptElement:s5,convertShapesToPath:o5,convertPathData:i5,convertTransform:r5,convertColors:y$,convertStyleToAttrs:H8,convertEllipseToCircle:a5,collapseGroups:t5,mergePaths:e5,moveGroupAttrsToElems:$K,moveElemsAttrsToGroup:JK,minifyStyles:z8,inlineStyles:KK,sortAttrs:ZK,sortDefsChildren:QK,reusePaths:HK,removeOffCanvasPath:zK,removeStyleElement:qK,removeXlink:WK,addAttributesToSVGElement:jK,addClassesToSVGElement:GK,prefixIds:FK,removeDimensions:_K,removeAttributesBySelector:UK,removeAttrs:VK,removeElementsByAttr:MK,presetDefault:q8,presetNone:W8,applyPreset:OK,optimize:YK,createConfig:XK,flattenClipPaths:kK,flattenMasks:LK,flattenGradients:wK,flattenPatterns:BK,flattenFilters:NK,flattenUseElements:IK,imageToPath:CK,detectCollisions:PK,measureDistance:AK,validateXML:EK,validateSVG:TK,fixInvalidSVG:fK,ValidationSeverity:A0,flattenAll:vK,simplifyPath:DK,decomposeTransform:gK,optimizeAnimationTiming:hK,optimizePaths:yK,simplifyPaths:uK,embedExternalDependencies:G8,exportEmbeddedResources:mK,convertPathDataAdvanced:E9,parsePathCommands:l0,serializePathCommands:n0,formatPathNumber:T7,douglasPeucker:n6,visvalingamWhyatt:T9,simplifyPolyline:b9,simplifyPolylinePath:S9,isPurePolyline:f9,optimizeKeySplines:N9,optimizeKeyTimes:I9,optimizeAnimationValues:B$,formatSplineValue:l6,parseKeySplines:N$,serializeKeySplines:R9,isLinearSpline:I$,areAllSplinesLinear:F5,identifyStandardEasing:B9,STANDARD_EASINGS:w9,removeLeadingZero:D9,negativeExtraSpace:h9,convertToRelative:y9,convertToAbsolute:u9,lineShorthands:g9,convertToZ:x9,straightCurves:m9,collapseRepeated:d9,floatPrecision:p9,removeUselessCommands:c9,convertCubicToQuadratic:l9,convertQuadraticToSmooth:n9,convertCubicToSmooth:s9,arcShorthands:o9};var jq="1.2.0",dK={VERSION:jq,...F8},K4=dK;if(typeof window!=="undefined")window.SVGToolbox=dK;export{EK as validateXML,nz as validateSVGAsync,TK as validateSVG,m9 as straightCurves,QK as sortDefsChildren,ZK as sortAttrs,uK as simplifyPaths,DK as simplifyPath,b5 as saveOutput,HK as reusePaths,WK as removeXlink,x5 as removeXMLProcInst,l5 as removeXMLNS,c5 as removeViewBox,y5 as removeUselessDefs,c9 as removeUselessCommands,D5 as removeUnknownsAndDefaults,m5 as removeTitle,qK as removeStyleElement,s5 as removeScriptElement,n5 as removeRasterImages,zK as removeOffCanvasPath,h5 as removeNonInheritableGroupAttrs,h$ as removeMetadata,D9 as removeLeadingZero,S$ as removeHiddenElements,u5 as removeEmptyText,v$ as removeEmptyContainers,p5 as removeEmptyAttrs,MK as removeElementsByAttr,Q8 as removeEditorsNSData,g5 as removeDoctype,_K as removeDimensions,d5 as removeDesc,D$ as removeComments,VK as removeAttrs,UK as removeAttributesBySelector,gz as printHierarchicalMatrix,W8 as presetNone,q8 as presetDefault,FK as prefixIds,yK as optimizePaths,hK as optimizeAnimationTiming,YK as optimize,h9 as negativeExtraSpace,$K as moveGroupAttrsToElems,JK as moveElemsAttrsToGroup,z8 as minifyStyles,e5 as mergePaths,AK as measureDistance,a6 as loadInput,g9 as lineShorthands,KK as inlineStyles,CK as imageToPath,t6 as generateOutput,uz as generateFullCompatibilityMatrix,bK as generateFlexibleSVGTable,xz as generateCompatibilityMatrixSVG,mz as generateCompatibilityMatrixFlexible,T5 as formatPrecision,p9 as floatPrecision,IK as flattenUseElements,BK as flattenPatterns,LK as flattenMasks,wK as flattenGradients,NK as flattenFilters,kK as flattenClipPaths,vK as flattenAll,fK as fixInvalidSVG,mK as exportEmbeddedResources,Pz as escapeXml,G8 as embedExternalDependencies,K8 as detectOutputTarget,r6 as detectInputType,PK as detectCollisions,K4 as default,gK as decomposeTransform,G0 as createOperation,XK as createConfig,r5 as convertTransform,x9 as convertToZ,y9 as convertToRelative,u9 as convertToAbsolute,H8 as convertStyleToAttrs,o5 as convertShapesToPath,n9 as convertQuadraticToSmooth,i5 as convertPathData,a5 as convertEllipseToCircle,s9 as convertCubicToSmooth,l9 as convertCubicToQuadratic,y$ as convertColors,d9 as collapseRepeated,t5 as collapseGroups,f$ as cleanupNumericValues,f5 as cleanupListOfValues,Z8 as cleanupIds,v5 as cleanupEnableBackground,S5 as cleanupAttributes,o9 as arcShorthands,OK as applyPreset,yz as analyzeCompatibilityMatrix,fz as analyzeCompatibility,GK as addClassesToSVGElement,jK as addAttributesToSVGElement,A0 as ValidationSeverity,jq as VERSION,E5 as PRECISION_LEVELS,F7 as OutputTarget,_7 as OutputFormat,i6 as MAX_PRECISION,D0 as InputType,E$ as DEFAULT_PRECISION};
493
+ `;if(!d.includes("fonts.googleapis.com"))d=s+d,c=!0,w.push(`Restored Google Fonts import for: ${r.join(", ")}`)}}}if(G&&d.trim()){R++;let p=J6(z,"text/css",R),N=await u(p,d,"text/css");if(N.type="stylesheet",N.elementId=E.getAttribute("id"),!M){let y=0;while(E.firstChild&&y++<1e4){let B=E.firstChild;if(E.removeChild(B),E.firstChild===B)break}if(y>=1e4)console.error("Safety limit reached removing style children: 10000 iterations");E.textContent=`@import url('./${p}');`,c=!0}}else if(c&&!M){let p=0;while(E.firstChild&&p++<1e4){let N=E.firstChild;if(E.removeChild(N),E.firstChild===N)break}if(p>=1e4)console.error("Safety limit reached updating style children: 10000 iterations");xK(E,d,K)}if(Y)Y("styles",h+1,x.length)}}if(!M){if(K._exportedResources=X,w.length>0)K._exportWarnings=w}return{doc:M?null:t6(K,Q,J),extractedFiles:X,warnings:w,summary:{totalExtracted:X.length,images:X.filter((S)=>S.type==="image").length,audio:X.filter((S)=>S.type==="audio").length,video:X.filter((S)=>S.type==="video").length,scripts:X.filter((S)=>S.type==="script").length,fonts:X.filter((S)=>S.type==="font").length,stylesheets:X.filter((S)=>S.type==="stylesheet").length,totalSize:X.reduce((S,x)=>S+x.size,0)}}}var Wq={MAX_PRECISION:i6,DEFAULT_PRECISION:E$,PRECISION_LEVELS:E5,formatPrecision:T5,InputType:D0,OutputFormat:_7,OutputTarget:F7,detectInputType:r6,detectOutputTarget:K8,loadInput:a6,generateOutput:t6,saveOutput:b5,createOperation:G0,cleanupIds:Z8,cleanupNumericValues:f$,cleanupListOfValues:f5,cleanupAttributes:S5,cleanupEnableBackground:v5,removeUnknownsAndDefaults:D5,removeNonInheritableGroupAttrs:h5,removeUselessDefs:y5,removeHiddenElements:S$,removeEmptyText:u5,removeEmptyContainers:v$,removeDoctype:g5,removeXMLProcInst:x5,removeComments:D$,removeMetadata:h$,removeTitle:m5,removeDesc:d5,removeEditorsNSData:Q8,removeEmptyAttrs:p5,removeViewBox:c5,removeXMLNS:l5,removeRasterImages:n5,removeScriptElement:s5,convertShapesToPath:o5,convertPathData:i5,convertTransform:r5,convertColors:y$,convertStyleToAttrs:H8,convertEllipseToCircle:a5,collapseGroups:t5,mergePaths:e5,moveGroupAttrsToElems:$K,moveElemsAttrsToGroup:JK,minifyStyles:z8,inlineStyles:KK,sortAttrs:ZK,sortDefsChildren:QK,reusePaths:HK,removeOffCanvasPath:zK,removeStyleElement:qK,removeXlink:WK,addAttributesToSVGElement:jK,addClassesToSVGElement:GK,prefixIds:FK,removeDimensions:_K,removeAttributesBySelector:UK,removeAttrs:VK,removeElementsByAttr:MK,presetDefault:q8,presetNone:W8,applyPreset:OK,optimize:YK,createConfig:XK,flattenClipPaths:kK,flattenMasks:LK,flattenGradients:wK,flattenPatterns:BK,flattenFilters:NK,flattenUseElements:IK,imageToPath:CK,detectCollisions:PK,measureDistance:AK,validateXML:EK,validateSVG:TK,fixInvalidSVG:fK,ValidationSeverity:A0,flattenAll:vK,simplifyPath:DK,decomposeTransform:gK,optimizeAnimationTiming:hK,optimizePaths:yK,simplifyPaths:uK,embedExternalDependencies:G8,exportEmbeddedResources:mK,convertPathDataAdvanced:E9,parsePathCommands:l0,serializePathCommands:n0,formatPathNumber:T7,douglasPeucker:n6,visvalingamWhyatt:T9,simplifyPolyline:b9,simplifyPolylinePath:S9,isPurePolyline:f9,optimizeKeySplines:N9,optimizeKeyTimes:I9,optimizeAnimationValues:B$,formatSplineValue:l6,parseKeySplines:N$,serializeKeySplines:R9,isLinearSpline:I$,areAllSplinesLinear:F5,identifyStandardEasing:B9,STANDARD_EASINGS:w9,removeLeadingZero:D9,negativeExtraSpace:h9,convertToRelative:y9,convertToAbsolute:u9,lineShorthands:g9,convertToZ:x9,straightCurves:m9,collapseRepeated:d9,floatPrecision:p9,removeUselessCommands:c9,convertCubicToQuadratic:l9,convertQuadraticToSmooth:n9,convertCubicToSmooth:s9,arcShorthands:o9};var jq="1.2.1",dK={VERSION:jq,...F8},K4=dK;if(typeof window!=="undefined")window.SVGToolbox=dK;export{EK as validateXML,nz as validateSVGAsync,TK as validateSVG,m9 as straightCurves,QK as sortDefsChildren,ZK as sortAttrs,uK as simplifyPaths,DK as simplifyPath,b5 as saveOutput,HK as reusePaths,WK as removeXlink,x5 as removeXMLProcInst,l5 as removeXMLNS,c5 as removeViewBox,y5 as removeUselessDefs,c9 as removeUselessCommands,D5 as removeUnknownsAndDefaults,m5 as removeTitle,qK as removeStyleElement,s5 as removeScriptElement,n5 as removeRasterImages,zK as removeOffCanvasPath,h5 as removeNonInheritableGroupAttrs,h$ as removeMetadata,D9 as removeLeadingZero,S$ as removeHiddenElements,u5 as removeEmptyText,v$ as removeEmptyContainers,p5 as removeEmptyAttrs,MK as removeElementsByAttr,Q8 as removeEditorsNSData,g5 as removeDoctype,_K as removeDimensions,d5 as removeDesc,D$ as removeComments,VK as removeAttrs,UK as removeAttributesBySelector,gz as printHierarchicalMatrix,W8 as presetNone,q8 as presetDefault,FK as prefixIds,yK as optimizePaths,hK as optimizeAnimationTiming,YK as optimize,h9 as negativeExtraSpace,$K as moveGroupAttrsToElems,JK as moveElemsAttrsToGroup,z8 as minifyStyles,e5 as mergePaths,AK as measureDistance,a6 as loadInput,g9 as lineShorthands,KK as inlineStyles,CK as imageToPath,t6 as generateOutput,uz as generateFullCompatibilityMatrix,bK as generateFlexibleSVGTable,xz as generateCompatibilityMatrixSVG,mz as generateCompatibilityMatrixFlexible,T5 as formatPrecision,p9 as floatPrecision,IK as flattenUseElements,BK as flattenPatterns,LK as flattenMasks,wK as flattenGradients,NK as flattenFilters,kK as flattenClipPaths,vK as flattenAll,fK as fixInvalidSVG,mK as exportEmbeddedResources,Pz as escapeXml,G8 as embedExternalDependencies,K8 as detectOutputTarget,r6 as detectInputType,PK as detectCollisions,K4 as default,gK as decomposeTransform,G0 as createOperation,XK as createConfig,r5 as convertTransform,x9 as convertToZ,y9 as convertToRelative,u9 as convertToAbsolute,H8 as convertStyleToAttrs,o5 as convertShapesToPath,n9 as convertQuadraticToSmooth,i5 as convertPathData,a5 as convertEllipseToCircle,s9 as convertCubicToSmooth,l9 as convertCubicToQuadratic,y$ as convertColors,d9 as collapseRepeated,t5 as collapseGroups,f$ as cleanupNumericValues,f5 as cleanupListOfValues,Z8 as cleanupIds,v5 as cleanupEnableBackground,S5 as cleanupAttributes,o9 as arcShorthands,OK as applyPreset,yz as analyzeCompatibilityMatrix,fz as analyzeCompatibility,GK as addClassesToSVGElement,jK as addAttributesToSVGElement,A0 as ValidationSeverity,jq as VERSION,E5 as PRECISION_LEVELS,F7 as OutputTarget,_7 as OutputFormat,i6 as MAX_PRECISION,D0 as InputType,E$ as DEFAULT_PRECISION};
package/dist/svgm.min.js CHANGED
@@ -1,3 +1,4 @@
1
+ /*! svg-matrix v1.2.1 | MIT License | https://github.com/Emasoft/svg-matrix */
1
2
  var bK=Object.create;var{getPrototypeOf:fK,defineProperty:u$,getOwnPropertyNames:sJ,getOwnPropertyDescriptor:SK}=Object,oJ=Object.prototype.hasOwnProperty;var i7=($,J,Z)=>{Z=$!=null?bK(fK($)):{};let K=J||!$||!$.__esModule?u$(Z,"default",{value:$,enumerable:!0}):Z;for(let Q of sJ($))if(!oJ.call(K,Q))u$(K,Q,{get:()=>$[Q],enumerable:!0});return K},lJ=new WeakMap,vK=($)=>{var J=lJ.get($),Z;if(J)return J;if(J=u$({},"__esModule",{value:!0}),$&&typeof $==="object"||typeof $==="function")sJ($).map((K)=>!oJ.call(J,K)&&u$(J,K,{get:()=>$[K],enumerable:!(Z=SK($,K))||Z.enumerable}));return lJ.set($,J),J};var x7=($,J)=>{for(var Z in J)u$($,Z,{get:J[Z],enumerable:!0,configurable:!0,set:(K)=>J[Z]=()=>K})};var iJ=($,J)=>()=>($&&(J=$($=0)),J);var T7=(($)=>typeof require!=="undefined"?require:typeof Proxy!=="undefined"?new Proxy($,{get:(J,Z)=>(typeof require!=="undefined"?require:J)[Z]}):$)(function($){if(typeof require!=="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+$+'" is not supported')});var V$={};x7(V$,{win32:()=>_J,toNamespacedPath:()=>VW,sep:()=>wW,resolve:()=>jW,relative:()=>UW,posix:()=>H$,parse:()=>kW,normalize:()=>GW,join:()=>_W,isAbsolute:()=>FW,format:()=>XW,extname:()=>MW,dirname:()=>OW,delimiter:()=>LW,default:()=>zW,basename:()=>YW});var tH,s5,eH,$W,JW,ZW,KW=($,J)=>()=>(J||$((J={exports:{}}).exports,J),J.exports),QW=($,J,Z,K)=>{if(J&&typeof J=="object"||typeof J=="function")for(let Q of $W(J))!ZW.call($,Q)&&Q!==Z&&s5($,Q,{get:()=>J[Q],enumerable:!(K=eH(J,Q))||K.enumerable});return $},qW=($,J,Z)=>(Z=$!=null?tH(JW($)):{},QW(J||!$||!$.__esModule?s5(Z,"default",{value:$,enumerable:!0}):Z,$)),HW,o5,p0,WW,l5=function($){return $},i5=function(){throw new Error("Not implemented")},H$,_J,zW,jW,GW,FW,_W,UW,VW,OW,YW,MW,XW,kW,wW,LW;var O$=iJ(()=>{tH=Object.create,s5=Object.defineProperty,eH=Object.getOwnPropertyDescriptor,$W=Object.getOwnPropertyNames,JW=Object.getPrototypeOf,ZW=Object.prototype.hasOwnProperty,HW=KW(($,J)=>{function Z(H){if(typeof H!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(H))}function K(H,W){for(var z="",j=0,G=-1,F=0,_,U=0;U<=H.length;++U){if(U<H.length)_=H.charCodeAt(U);else{if(_===47)break;_=47}if(_===47){if(!(G===U-1||F===1))if(G!==U-1&&F===2){if(z.length<2||j!==2||z.charCodeAt(z.length-1)!==46||z.charCodeAt(z.length-2)!==46){if(z.length>2){var M=z.lastIndexOf("/");if(M!==z.length-1){M===-1?(z="",j=0):(z=z.slice(0,M),j=z.length-1-z.lastIndexOf("/")),G=U,F=0;continue}}else if(z.length===2||z.length===1){z="",j=0,G=U,F=0;continue}}W&&(z.length>0?z+="/..":z="..",j=2)}else z.length>0?z+="/"+H.slice(G+1,U):z=H.slice(G+1,U),j=U-G-1;G=U,F=0}else _===46&&F!==-1?++F:F=-1}return z}function Q(H,W){var z=W.dir||W.root,j=W.base||(W.name||"")+(W.ext||"");return z?z===W.root?z+j:z+H+j:j}var q={resolve:function(){for(var H="",W=!1,z,j=arguments.length-1;j>=-1&&!W;j--){var G;j>=0?G=arguments[j]:(z===void 0&&(z=process.cwd()),G=z),Z(G),G.length!==0&&(H=G+"/"+H,W=G.charCodeAt(0)===47)}return H=K(H,!W),W?H.length>0?"/"+H:"/":H.length>0?H:"."},normalize:function(H){if(Z(H),H.length===0)return".";var W=H.charCodeAt(0)===47,z=H.charCodeAt(H.length-1)===47;return H=K(H,!W),H.length===0&&!W&&(H="."),H.length>0&&z&&(H+="/"),W?"/"+H:H},isAbsolute:function(H){return Z(H),H.length>0&&H.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var H,W=0;W<arguments.length;++W){var z=arguments[W];Z(z),z.length>0&&(H===void 0?H=z:H+="/"+z)}return H===void 0?".":q.normalize(H)},relative:function(H,W){if(Z(H),Z(W),H===W||(H=q.resolve(H),W=q.resolve(W),H===W))return"";for(var z=1;z<H.length&&H.charCodeAt(z)===47;++z);for(var j=H.length,G=j-z,F=1;F<W.length&&W.charCodeAt(F)===47;++F);for(var _=W.length,U=_-F,M=G<U?G:U,V=-1,Y=0;Y<=M;++Y){if(Y===M){if(U>M){if(W.charCodeAt(F+Y)===47)return W.slice(F+Y+1);if(Y===0)return W.slice(F+Y)}else G>M&&(H.charCodeAt(z+Y)===47?V=Y:Y===0&&(V=0));break}var X=H.charCodeAt(z+Y),k=W.charCodeAt(F+Y);if(X!==k)break;X===47&&(V=Y)}var w="";for(Y=z+V+1;Y<=j;++Y)(Y===j||H.charCodeAt(Y)===47)&&(w.length===0?w+="..":w+="/..");return w.length>0?w+W.slice(F+V):(F+=V,W.charCodeAt(F)===47&&++F,W.slice(F))},_makeLong:function(H){return H},dirname:function(H){if(Z(H),H.length===0)return".";for(var W=H.charCodeAt(0),z=W===47,j=-1,G=!0,F=H.length-1;F>=1;--F)if(W=H.charCodeAt(F),W===47){if(!G){j=F;break}}else G=!1;return j===-1?z?"/":".":z&&j===1?"//":H.slice(0,j)},basename:function(H,W){if(W!==void 0&&typeof W!="string")throw new TypeError('"ext" argument must be a string');Z(H);var z=0,j=-1,G=!0,F;if(W!==void 0&&W.length>0&&W.length<=H.length){if(W.length===H.length&&W===H)return"";var _=W.length-1,U=-1;for(F=H.length-1;F>=0;--F){var M=H.charCodeAt(F);if(M===47){if(!G){z=F+1;break}}else U===-1&&(G=!1,U=F+1),_>=0&&(M===W.charCodeAt(_)?--_===-1&&(j=F):(_=-1,j=U))}return z===j?j=U:j===-1&&(j=H.length),H.slice(z,j)}else{for(F=H.length-1;F>=0;--F)if(H.charCodeAt(F)===47){if(!G){z=F+1;break}}else j===-1&&(G=!1,j=F+1);return j===-1?"":H.slice(z,j)}},extname:function(H){Z(H);for(var W=-1,z=0,j=-1,G=!0,F=0,_=H.length-1;_>=0;--_){var U=H.charCodeAt(_);if(U===47){if(!G){z=_+1;break}continue}j===-1&&(G=!1,j=_+1),U===46?W===-1?W=_:F!==1&&(F=1):W!==-1&&(F=-1)}return W===-1||j===-1||F===0||F===1&&W===j-1&&W===z+1?"":H.slice(W,j)},format:function(H){if(H===null||typeof H!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof H);return Q("/",H)},parse:function(H){Z(H);var W={root:"",dir:"",base:"",ext:"",name:""};if(H.length===0)return W;var z=H.charCodeAt(0),j=z===47,G;j?(W.root="/",G=1):G=0;for(var F=-1,_=0,U=-1,M=!0,V=H.length-1,Y=0;V>=G;--V){if(z=H.charCodeAt(V),z===47){if(!M){_=V+1;break}continue}U===-1&&(M=!1,U=V+1),z===46?F===-1?F=V:Y!==1&&(Y=1):F!==-1&&(Y=-1)}return F===-1||U===-1||Y===0||Y===1&&F===U-1&&F===_+1?U!==-1&&(_===0&&j?W.base=W.name=H.slice(1,U):W.base=W.name=H.slice(_,U)):(_===0&&j?(W.name=H.slice(1,F),W.base=H.slice(1,U)):(W.name=H.slice(_,F),W.base=H.slice(_,U)),W.ext=H.slice(F,U)),_>0?W.dir=H.slice(0,_-1):j&&(W.dir="/"),W},sep:"/",delimiter:":",win32:null,posix:null};q.posix=q,J.exports=q}),o5=qW(HW()),p0=o5,WW=o5;p0.parse??=i5;WW.parse??=i5;H$={resolve:p0.resolve.bind(p0),normalize:p0.normalize.bind(p0),isAbsolute:p0.isAbsolute.bind(p0),join:p0.join.bind(p0),relative:p0.relative.bind(p0),toNamespacedPath:l5,dirname:p0.dirname.bind(p0),basename:p0.basename.bind(p0),extname:p0.extname.bind(p0),format:p0.format.bind(p0),parse:p0.parse.bind(p0),sep:"/",delimiter:":",win32:void 0,posix:void 0,_makeLong:l5},_J={sep:"\\",delimiter:";",win32:void 0,...H$,posix:H$};H$.win32=_J.win32=_J;H$.posix=H$;zW=H$,{resolve:jW,normalize:GW,isAbsolute:FW,join:_W,relative:UW,toNamespacedPath:VW,dirname:OW,basename:YW,extname:MW,format:XW,parse:kW,sep:wW,delimiter:LW}=H$});var CK={};x7(CK,{resolveObject:()=>IK,resolve:()=>NK,parse:()=>h$,format:()=>BK,default:()=>wz,Url:()=>X7,URLSearchParams:()=>LK,URL:()=>bJ});function fJ($){return typeof $=="string"}function RK($){return typeof $=="object"&&$!==null}function Q9($){return $===null}function Fz($){return $==null}function X7(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}function h$($,J,Z){if($&&RK($)&&$ instanceof X7)return $;var K=new X7;return K.parse($,J,Z),K}function BK($){return fJ($)&&($=h$($)),$ instanceof X7?$.format():X7.prototype.format.call($)}function NK($,J){return h$($,!1,!0).resolve(J)}function IK($,J){return $?h$($,!1,!0).resolveObject(J):J}var bJ,LK,_z,Uz,Vz,Oz,Yz,AJ,XK,kK,Mz=255,wK,Xz,kz,EJ,D$,TJ,wz;var PK=iJ(()=>{({URL:bJ,URLSearchParams:LK}=globalThis);_z=/^([a-z0-9.+-]+:)/i,Uz=/:[0-9]*$/,Vz=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,Oz=["<",">",'"',"`"," ","\r",`
2
3
  `,"\t"],Yz=["{","}","|","\\","^","`"].concat(Oz),AJ=["'"].concat(Yz),XK=["%","/","?",";","#"].concat(AJ),kK=["/","?","#"],wK=/^[+a-z0-9A-Z_-]{0,63}$/,Xz=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,kz={javascript:!0,"javascript:":!0},EJ={javascript:!0,"javascript:":!0},D$={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},TJ={parse($){var J=decodeURIComponent;return($+"").replace(/\+/g," ").split("&").filter(Boolean).reduce(function(Z,K,Q){var q=K.split("="),H=J(q[0]||""),W=J(q[1]||""),z=Z[H];return Z[H]=z===void 0?W:[].concat(z,W),Z},{})},stringify($){var J=encodeURIComponent;return Object.keys($||{}).reduce(function(Z,K){return[].concat($[K]).forEach(function(Q){Z.push(J(K)+"="+J(Q))}),Z},[]).join("&").replace(/\s/g,"+")}};X7.prototype.parse=function($,J,Z){if(!fJ($))throw new TypeError("Parameter 'url' must be a string, not "+typeof $);var K=$.indexOf("?"),Q=K!==-1&&K<$.indexOf("#")?"?":"#",q=$.split(Q),H=/\\/g;q[0]=q[0].replace(H,"/"),$=q.join(Q);var W=$;if(W=W.trim(),!Z&&$.split("#").length===1){var z=Vz.exec(W);if(z)return this.path=W,this.href=W,this.pathname=z[1],z[2]?(this.search=z[2],J?this.query=TJ.parse(this.search.substr(1)):this.query=this.search.substr(1)):J&&(this.search="",this.query={}),this}var j=_z.exec(W);if(j){j=j[0];var G=j.toLowerCase();this.protocol=G,W=W.substr(j.length)}if(Z||j||W.match(/^\/\/[^@\/]+@[^@\/]+/)){var F=W.substr(0,2)==="//";F&&!(j&&EJ[j])&&(W=W.substr(2),this.slashes=!0)}if(!EJ[j]&&(F||j&&!D$[j])){for(var _=-1,U=0;U<kK.length;U++){var M=W.indexOf(kK[U]);M!==-1&&(_===-1||M<_)&&(_=M)}var V,Y;_===-1?Y=W.lastIndexOf("@"):Y=W.lastIndexOf("@",_),Y!==-1&&(V=W.slice(0,Y),W=W.slice(Y+1),this.auth=decodeURIComponent(V)),_=-1;for(var U=0;U<XK.length;U++){var M=W.indexOf(XK[U]);M!==-1&&(_===-1||M<_)&&(_=M)}_===-1&&(_=W.length),this.host=W.slice(0,_),W=W.slice(_),this.parseHost(),this.hostname=this.hostname||"";var X=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!X)for(var k=this.hostname.split(/\./),U=0,w=k.length;U<w;U++){var R=k[U];if(!!R&&!R.match(wK)){for(var I="",P=0,u=R.length;P<u;P++)R.charCodeAt(P)>127?I+="x":I+=R[P];if(!I.match(wK)){var g=k.slice(0,U),b=k.slice(U+1),h=R.match(Xz);h&&(g.push(h[1]),b.unshift(h[2])),b.length&&(W="/"+b.join(".")+W),this.hostname=g.join(".");break}}}this.hostname.length>Mz?this.hostname="":this.hostname=this.hostname.toLowerCase(),X||(this.hostname=new bJ(`https://${this.hostname}`).hostname);var v=this.port?":"+this.port:"",E=this.hostname||"";this.host=E+v,this.href+=this.host,X&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),W[0]!=="/"&&(W="/"+W))}if(!kz[G])for(var U=0,w=AJ.length;U<w;U++){var m=AJ[U];if(W.indexOf(m)!==-1){var c=encodeURIComponent(m);c===m&&(c=escape(m)),W=W.split(m).join(c)}}var d=W.indexOf("#");d!==-1&&(this.hash=W.substr(d),W=W.slice(0,d));var N=W.indexOf("?");if(N!==-1?(this.search=W.substr(N),this.query=W.substr(N+1),J&&(this.query=TJ.parse(this.query)),W=W.slice(0,N)):J&&(this.search="",this.query={}),W&&(this.pathname=W),D$[G]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var v=this.pathname||"",y=this.search||"";this.path=v+y}return this.href=this.format(),this};X7.prototype.format=function(){var $=this.auth||"";$&&($=encodeURIComponent($),$=$.replace(/%3A/i,":"),$+="@");var J=this.protocol||"",Z=this.pathname||"",K=this.hash||"",Q=!1,q="";this.host?Q=$+this.host:this.hostname&&(Q=$+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]"),this.port&&(Q+=":"+this.port)),this.query&&RK(this.query)&&Object.keys(this.query).length&&(q=TJ.stringify(this.query));var H=this.search||q&&"?"+q||"";return J&&J.substr(-1)!==":"&&(J+=":"),this.slashes||(!J||D$[J])&&Q!==!1?(Q="//"+(Q||""),Z&&Z.charAt(0)!=="/"&&(Z="/"+Z)):Q||(Q=""),K&&K.charAt(0)!=="#"&&(K="#"+K),H&&H.charAt(0)!=="?"&&(H="?"+H),Z=Z.replace(/[?#]/g,function(W){return encodeURIComponent(W)}),H=H.replace("#","%23"),J+Q+Z+H+K};X7.prototype.resolve=function($){return this.resolveObject(h$($,!1,!0)).format()};X7.prototype.resolveObject=function($){if(fJ($)){var J=new X7;J.parse($,!1,!0),$=J}for(var Z=new X7,K=Object.keys(this),Q=0;Q<K.length;Q++){var q=K[Q];Z[q]=this[q]}if(Z.hash=$.hash,$.href==="")return Z.href=Z.format(),Z;if($.slashes&&!$.protocol){for(var H=Object.keys($),W=0;W<H.length;W++){var z=H[W];z!=="protocol"&&(Z[z]=$[z])}return D$[Z.protocol]&&Z.hostname&&!Z.pathname&&(Z.path=Z.pathname="/"),Z.href=Z.format(),Z}if($.protocol&&$.protocol!==Z.protocol){if(!D$[$.protocol]){for(var j=Object.keys($),G=0;G<j.length;G++){var F=j[G];Z[F]=$[F]}return Z.href=Z.format(),Z}if(Z.protocol=$.protocol,!$.host&&!EJ[$.protocol]){for(var w=($.pathname||"").split("/");w.length&&!($.host=w.shift()););$.host||($.host=""),$.hostname||($.hostname=""),w[0]!==""&&w.unshift(""),w.length<2&&w.unshift(""),Z.pathname=w.join("/")}else Z.pathname=$.pathname;if(Z.search=$.search,Z.query=$.query,Z.host=$.host||"",Z.auth=$.auth,Z.hostname=$.hostname||$.host,Z.port=$.port,Z.pathname||Z.search){var _=Z.pathname||"",U=Z.search||"";Z.path=_+U}return Z.slashes=Z.slashes||$.slashes,Z.href=Z.format(),Z}var M=Z.pathname&&Z.pathname.charAt(0)==="/",V=$.host||$.pathname&&$.pathname.charAt(0)==="/",Y=V||M||Z.host&&$.pathname,X=Y,k=Z.pathname&&Z.pathname.split("/")||[],w=$.pathname&&$.pathname.split("/")||[],R=Z.protocol&&!D$[Z.protocol];if(R&&(Z.hostname="",Z.port=null,Z.host&&(k[0]===""?k[0]=Z.host:k.unshift(Z.host)),Z.host="",$.protocol&&($.hostname=null,$.port=null,$.host&&(w[0]===""?w[0]=$.host:w.unshift($.host)),$.host=null),Y=Y&&(w[0]===""||k[0]==="")),V)Z.host=$.host||$.host===""?$.host:Z.host,Z.hostname=$.hostname||$.hostname===""?$.hostname:Z.hostname,Z.search=$.search,Z.query=$.query,k=w;else if(w.length)k||(k=[]),k.pop(),k=k.concat(w),Z.search=$.search,Z.query=$.query;else if(!Fz($.search)){if(R){Z.hostname=Z.host=k.shift();var I=Z.host&&Z.host.indexOf("@")>0?Z.host.split("@"):!1;I&&(Z.auth=I.shift(),Z.host=Z.hostname=I.shift())}return Z.search=$.search,Z.query=$.query,(!Q9(Z.pathname)||!Q9(Z.search))&&(Z.path=(Z.pathname?Z.pathname:"")+(Z.search?Z.search:"")),Z.href=Z.format(),Z}if(!k.length)return Z.pathname=null,Z.search?Z.path="/"+Z.search:Z.path=null,Z.href=Z.format(),Z;for(var P=k.slice(-1)[0],u=(Z.host||$.host||k.length>1)&&(P==="."||P==="..")||P==="",g=0,b=k.length;b>=0;b--)P=k[b],P==="."?k.splice(b,1):P===".."?(k.splice(b,1),g++):g&&(k.splice(b,1),g--);if(!Y&&!X)for(;g--;g)k.unshift("..");Y&&k[0]!==""&&(!k[0]||k[0].charAt(0)!=="/")&&k.unshift(""),u&&k.join("/").substr(-1)!=="/"&&k.push("");var h=k[0]===""||k[0]&&k[0].charAt(0)==="/";if(R){Z.hostname=Z.host=h?"":k.length?k.shift():"";var I=Z.host&&Z.host.indexOf("@")>0?Z.host.split("@"):!1;I&&(Z.auth=I.shift(),Z.host=Z.hostname=I.shift())}return Y=Y||Z.host&&k.length,Y&&!h&&k.unshift(""),k.length?Z.pathname=k.join("/"):(Z.pathname=null,Z.path=null),(!Q9(Z.pathname)||!Q9(Z.search))&&(Z.path=(Z.pathname?Z.pathname:"")+(Z.search?Z.search:"")),Z.auth=$.auth||Z.auth,Z.slashes=Z.slashes||$.slashes,Z.href=Z.format(),Z};X7.prototype.parseHost=function(){var $=this.host,J=Uz.exec($);J&&(J=J[0],J!==":"&&(this.port=J.substr(1)),$=$.substr(0,$.length-J.length)),$&&(this.hostname=$)};wz={parse:h$,resolve:NK,resolveObject:IK,format:BK,Url:X7,URL:bJ,URLSearchParams:LK}});/*!
3
4
  * decimal.js v10.6.0
@@ -495,4 +496,4 @@ ${H}
495
496
  // <![CDATA[
496
497
  ${K}
497
498
  // ]]>
498
- `,H=new w0("script",{type:"text/javascript",id:"svg-matrix-polyfill"},[],q);if(!Array.isArray(Q.children))Q.children=[];if(Q.children.length>0){let W=0;for(let z=0;z<Q.children.length;z++)if(Q.children[z]?.tagName==="defs")W=z+1;Q.children.splice(W,0,H)}else Q.children.push(H);return $}function Pz($){if(!$)return $;let J=(Z)=>{if(!Z||!Z.children||!Array.isArray(Z.children))return;Z.children=Z.children.filter((K)=>{if(K?.tagName==="script"){if(K.getAttribute?.("id")==="svg-matrix-polyfill")return!1;if((K.textContent||"").includes("SVG 2.0 Polyfills - Generated by svg-matrix"))return!1}return!0});for(let K of Z.children)if(K)J(K)};return J($),$}O.set({precision:80});var Az="1.2.0";var{parseSVG:Ij,serializeSVG:Cj}=T9,{detectSVG2Features:Pj,injectPolyfills:Aj,setPolyfillMinification:Ej,setPolyfillContent:Tj}=mJ;async function Ez($,J={}){let{loadInput:Z,saveOutput:K,optimize:Q}=K9,q=w$($),H=await Z($,q),W=await Q(H,{precision:J.precision||6,...J});if(J.output)return K(W,J.output,J);return K(W,null,J)}var EK={VERSION:Az,Decimal:O,Matrix:W0,Vector:S0,Transforms2D:L7,Transforms3D:O9,GeometryToPath:n$,...K9,parseSVG:u0,serializeSVG:K7,detectSVG2Features:j6,injectPolyfills:xJ,setPolyfillMinification:uJ,setPolyfillContent:gJ,process:Ez},Sj=EK;if(typeof window!=="undefined")window.SVGM=EK;export{qK as validateXML,oW as validateSVGAsync,HK as validateSVG,QJ as straightCurves,vZ as sortDefsChildren,SZ as sortAttrs,VK as simplifyPaths,FK as simplifyPath,Ej as setPolyfillMinification,Tj as setPolyfillContent,Cj as serializeSVG,WZ as saveOutput,DZ as reusePaths,uZ as removeXlink,YZ as removeXMLProcInst,LZ as removeXMLNS,wZ as removeViewBox,UZ as removeUselessDefs,WJ as removeUselessCommands,FZ as removeUnknownsAndDefaults,MZ as removeTitle,yZ as removeStyleElement,BZ as removeScriptElement,RZ as removeRasterImages,hZ as removeOffCanvasPath,_Z as removeNonInheritableGroupAttrs,J9 as removeMetadata,t9 as removeLeadingZero,t6 as removeHiddenElements,VZ as removeEmptyText,e6 as removeEmptyContainers,kZ as removeEmptyAttrs,nZ as removeElementsByAttr,LJ as removeEditorsNSData,OZ as removeDoctype,dZ as removeDimensions,XZ as removeDesc,$9 as removeComments,cZ as removeAttrs,pZ as removeAttributesBySelector,Ez as process,mW as printHierarchicalMatrix,IJ as presetNone,NJ as presetDefault,mZ as prefixIds,Ij as parseSVG,UK as optimizePaths,_K as optimizeAnimationTiming,sZ as optimize,e9 as negativeExtraSpace,TZ as moveGroupAttrsToElems,bZ as moveElemsAttrsToGroup,BJ as minifyStyles,EZ as mergePaths,QK as measureDistance,W6 as loadInput,ZJ as lineShorthands,fZ as inlineStyles,Aj as injectPolyfills,ZK as imageToPath,z6 as generateOutput,xW as generateFullCompatibilityMatrix,WK as generateFlexibleSVGTable,dW as generateCompatibilityMatrixSVG,pW as generateCompatibilityMatrixFlexible,HZ as formatPrecision,HJ as floatPrecision,JK as flattenUseElements,eZ as flattenPatterns,rZ as flattenMasks,aZ as flattenGradients,$K as flattenFilters,iZ as flattenClipPaths,GK as flattenAll,zK as fixInvalidSVG,MK as exportEmbeddedResources,EW as escapeXml,PJ as embedExternalDependencies,Pj as detectSVG2Features,kJ as detectOutputTarget,w$ as detectInputType,KK as detectCollisions,Sj as default,OK as decomposeTransform,F0 as createOperation,oZ as createConfig,CZ as convertTransform,KJ as convertToZ,$J as convertToRelative,JJ as convertToAbsolute,RJ as convertStyleToAttrs,NZ as convertShapesToPath,jJ as convertQuadraticToSmooth,IZ as convertPathData,PZ as convertEllipseToCircle,GJ as convertCubicToSmooth,zJ as convertCubicToQuadratic,Z9 as convertColors,qJ as collapseRepeated,AZ as collapseGroups,a6 as cleanupNumericValues,zZ as cleanupListOfValues,wJ as cleanupIds,GZ as cleanupEnableBackground,jZ as cleanupAttributes,FJ as arcShorthands,lZ as applyPreset,gW as analyzeCompatibilityMatrix,vW as analyzeCompatibility,xZ as addClassesToSVGElement,gZ as addAttributesToSVGElement,S0 as Vector,A0 as ValidationSeverity,Az as VERSION,O9 as Transforms3D,L7 as Transforms2D,qZ as PRECISION_LEVELS,Y7 as OutputTarget,M7 as OutputFormat,W0 as Matrix,H6 as MAX_PRECISION,D0 as InputType,n$ as GeometryToPath,O as Decimal,o6 as DEFAULT_PRECISION};
499
+ `,H=new w0("script",{type:"text/javascript",id:"svg-matrix-polyfill"},[],q);if(!Array.isArray(Q.children))Q.children=[];if(Q.children.length>0){let W=0;for(let z=0;z<Q.children.length;z++)if(Q.children[z]?.tagName==="defs")W=z+1;Q.children.splice(W,0,H)}else Q.children.push(H);return $}function Pz($){if(!$)return $;let J=(Z)=>{if(!Z||!Z.children||!Array.isArray(Z.children))return;Z.children=Z.children.filter((K)=>{if(K?.tagName==="script"){if(K.getAttribute?.("id")==="svg-matrix-polyfill")return!1;if((K.textContent||"").includes("SVG 2.0 Polyfills - Generated by svg-matrix"))return!1}return!0});for(let K of Z.children)if(K)J(K)};return J($),$}O.set({precision:80});var Az="1.2.1";var{parseSVG:Ij,serializeSVG:Cj}=T9,{detectSVG2Features:Pj,injectPolyfills:Aj,setPolyfillMinification:Ej,setPolyfillContent:Tj}=mJ;async function Ez($,J={}){let{loadInput:Z,saveOutput:K,optimize:Q}=K9,q=w$($),H=await Z($,q),W=await Q(H,{precision:J.precision||6,...J});if(J.output)return K(W,J.output,J);return K(W,null,J)}var EK={VERSION:Az,Decimal:O,Matrix:W0,Vector:S0,Transforms2D:L7,Transforms3D:O9,GeometryToPath:n$,...K9,parseSVG:u0,serializeSVG:K7,detectSVG2Features:j6,injectPolyfills:xJ,setPolyfillMinification:uJ,setPolyfillContent:gJ,process:Ez},Sj=EK;if(typeof window!=="undefined")window.SVGM=EK;export{qK as validateXML,oW as validateSVGAsync,HK as validateSVG,QJ as straightCurves,vZ as sortDefsChildren,SZ as sortAttrs,VK as simplifyPaths,FK as simplifyPath,Ej as setPolyfillMinification,Tj as setPolyfillContent,Cj as serializeSVG,WZ as saveOutput,DZ as reusePaths,uZ as removeXlink,YZ as removeXMLProcInst,LZ as removeXMLNS,wZ as removeViewBox,UZ as removeUselessDefs,WJ as removeUselessCommands,FZ as removeUnknownsAndDefaults,MZ as removeTitle,yZ as removeStyleElement,BZ as removeScriptElement,RZ as removeRasterImages,hZ as removeOffCanvasPath,_Z as removeNonInheritableGroupAttrs,J9 as removeMetadata,t9 as removeLeadingZero,t6 as removeHiddenElements,VZ as removeEmptyText,e6 as removeEmptyContainers,kZ as removeEmptyAttrs,nZ as removeElementsByAttr,LJ as removeEditorsNSData,OZ as removeDoctype,dZ as removeDimensions,XZ as removeDesc,$9 as removeComments,cZ as removeAttrs,pZ as removeAttributesBySelector,Ez as process,mW as printHierarchicalMatrix,IJ as presetNone,NJ as presetDefault,mZ as prefixIds,Ij as parseSVG,UK as optimizePaths,_K as optimizeAnimationTiming,sZ as optimize,e9 as negativeExtraSpace,TZ as moveGroupAttrsToElems,bZ as moveElemsAttrsToGroup,BJ as minifyStyles,EZ as mergePaths,QK as measureDistance,W6 as loadInput,ZJ as lineShorthands,fZ as inlineStyles,Aj as injectPolyfills,ZK as imageToPath,z6 as generateOutput,xW as generateFullCompatibilityMatrix,WK as generateFlexibleSVGTable,dW as generateCompatibilityMatrixSVG,pW as generateCompatibilityMatrixFlexible,HZ as formatPrecision,HJ as floatPrecision,JK as flattenUseElements,eZ as flattenPatterns,rZ as flattenMasks,aZ as flattenGradients,$K as flattenFilters,iZ as flattenClipPaths,GK as flattenAll,zK as fixInvalidSVG,MK as exportEmbeddedResources,EW as escapeXml,PJ as embedExternalDependencies,Pj as detectSVG2Features,kJ as detectOutputTarget,w$ as detectInputType,KK as detectCollisions,Sj as default,OK as decomposeTransform,F0 as createOperation,oZ as createConfig,CZ as convertTransform,KJ as convertToZ,$J as convertToRelative,JJ as convertToAbsolute,RJ as convertStyleToAttrs,NZ as convertShapesToPath,jJ as convertQuadraticToSmooth,IZ as convertPathData,PZ as convertEllipseToCircle,GJ as convertCubicToSmooth,zJ as convertCubicToQuadratic,Z9 as convertColors,qJ as collapseRepeated,AZ as collapseGroups,a6 as cleanupNumericValues,zZ as cleanupListOfValues,wJ as cleanupIds,GZ as cleanupEnableBackground,jZ as cleanupAttributes,FJ as arcShorthands,lZ as applyPreset,gW as analyzeCompatibilityMatrix,vW as analyzeCompatibility,xZ as addClassesToSVGElement,gZ as addAttributesToSVGElement,S0 as Vector,A0 as ValidationSeverity,Az as VERSION,O9 as Transforms3D,L7 as Transforms2D,qZ as PRECISION_LEVELS,Y7 as OutputTarget,M7 as OutputFormat,W0 as Matrix,H6 as MAX_PRECISION,D0 as InputType,n$ as GeometryToPath,O as Decimal,o6 as DEFAULT_PRECISION};
package/dist/version.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
- "version": "1.2.0",
3
- "buildTime": "2025-12-31T23:29:02.390Z",
2
+ "version": "1.2.1",
3
+ "buildTime": "2026-01-01T23:13:01.462Z",
4
4
  "files": [
5
5
  {
6
6
  "name": "svg-matrix.min.js",
7
- "size": 56106
7
+ "size": 56185
8
8
  },
9
9
  {
10
10
  "name": "svg-toolbox.min.js",
11
- "size": 577198
11
+ "size": 577277
12
12
  },
13
13
  {
14
14
  "name": "svgm.min.js",
15
- "size": 602581
15
+ "size": 602660
16
16
  }
17
17
  ]
18
18
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emasoft/svg-matrix",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Arbitrary-precision matrix, vector and affine transformation library for JavaScript using decimal.js",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/index.js CHANGED
@@ -5,7 +5,7 @@
5
5
  * SVG path conversion, and 2D/3D affine transformations using Decimal.js.
6
6
  *
7
7
  * @module @emasoft/svg-matrix
8
- * @version 1.2.0
8
+ * @version 1.2.1
9
9
  * @license MIT
10
10
  *
11
11
  * @example
@@ -135,7 +135,7 @@ Decimal.set({ precision: 80 });
135
135
  * Library version
136
136
  * @constant {string}
137
137
  */
138
- export const VERSION = '1.2.0';
138
+ export const VERSION = '1.2.1';
139
139
 
140
140
  /**
141
141
  * Default precision for path output (decimal places)
@@ -5,7 +5,7 @@
5
5
  * Works in both Node.js and browser environments.
6
6
  *
7
7
  * @module svg-matrix-lib
8
- * @version 1.2.0
8
+ * @version 1.2.1
9
9
  * @license MIT
10
10
  *
11
11
  * @example Browser usage:
@@ -32,7 +32,7 @@ Decimal.set({ precision: 80 });
32
32
  /**
33
33
  * Library version
34
34
  */
35
- export const VERSION = "1.2.0";
35
+ export const VERSION = "1.2.1";
36
36
 
37
37
  // Export core classes
38
38
  export { Decimal, Matrix, Vector };
@@ -5,7 +5,7 @@
5
5
  * Provides 69+ operations for cleaning, optimizing, and transforming SVG files.
6
6
  *
7
7
  * @module svg-toolbox-lib
8
- * @version 1.2.0
8
+ * @version 1.2.1
9
9
  * @license MIT
10
10
  *
11
11
  * @example Browser usage:
@@ -34,7 +34,7 @@ import * as SVGToolboxModule from "./svg-toolbox.js";
34
34
  /**
35
35
  * Library version
36
36
  */
37
- export const VERSION = "1.2.0";
37
+ export const VERSION = "1.2.1";
38
38
 
39
39
  /**
40
40
  * Default export for browser global (window.SVGToolbox)
package/src/svgm-lib.js CHANGED
@@ -5,7 +5,7 @@
5
5
  * comprehensive SVG manipulation (SVGToolbox). Works in Node.js and browser.
6
6
  *
7
7
  * @module svgm-lib
8
- * @version 1.2.0
8
+ * @version 1.2.1
9
9
  * @license MIT
10
10
  *
11
11
  * @example Browser usage:
@@ -49,7 +49,7 @@ Decimal.set({ precision: 80 });
49
49
  /**
50
50
  * Library version
51
51
  */
52
- export const VERSION = "1.2.0";
52
+ export const VERSION = "1.2.1";
53
53
 
54
54
  // Export math classes
55
55
  export { Decimal, Matrix, Vector };