@emasoft/svg-matrix 1.3.4 → 1.3.6

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,77 +1,77 @@
1
- /*! svg-matrix v1.3.4 | MIT License | https://github.com/Emasoft/svg-matrix */
2
- (()=>{var eK=Object.create;var{getPrototypeOf:$Z,defineProperty:f6,getOwnPropertyNames:CJ,getOwnPropertyDescriptor:JZ}=Object,PJ=Object.prototype.hasOwnProperty;var K6=($,J,Z)=>{Z=$!=null?eK($Z($)):{};let K=J||!$||!$.__esModule?f6(Z,"default",{value:$,enumerable:!0}):Z;for(let Q of CJ($))if(!PJ.call(K,Q))f6(K,Q,{get:()=>$[Q],enumerable:!0});return K},IJ=new WeakMap,AJ=($)=>{var J=IJ.get($),Z;if(J)return J;if(J=f6({},"__esModule",{value:!0}),$&&typeof $==="object"||typeof $==="function")CJ($).map((K)=>!PJ.call(J,K)&&f6(J,K,{get:()=>$[K],enumerable:!(Z=JZ($,K))||Z.enumerable}));return IJ.set($,J),J};var z$=($,J)=>{for(var Z in J)f6($,Z,{get:J[Z],enumerable:!0,configurable:!0,set:(K)=>J[Z]=()=>K})};var KZ=($,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 N6={};z$(N6,{win32:()=>K8,toNamespacedPath:()=>wz,sep:()=>Pz,resolve:()=>Oz,relative:()=>Lz,posix:()=>e7,parse:()=>Cz,normalize:()=>Yz,join:()=>kz,isAbsolute:()=>Xz,format:()=>Iz,extname:()=>Nz,dirname:()=>Rz,delimiter:()=>Az,default:()=>Mz,basename:()=>Bz});var Hz,PK,zz,qz,Wz,jz,Gz=($,J)=>()=>(J||$((J={exports:{}}).exports,J),J.exports),Fz=($,J,Z,K)=>{if(J&&typeof J=="object"||typeof J=="function")for(let Q of qz(J))!jz.call($,Q)&&Q!==Z&&PK($,Q,{get:()=>J[Q],enumerable:!(K=zz(J,Q))||K.enumerable});return $},_z=($,J,Z)=>(Z=$!=null?Hz(Wz($)):{},Fz(J||!$||!$.__esModule?PK(Z,"default",{value:$,enumerable:!0}):Z,$)),Uz,AK,m0,Vz,CK=function($){return $},EK=function(){throw new Error("Not implemented")},e7,K8,Mz,Oz,Yz,Xz,kz,Lz,wz,Rz,Bz,Nz,Iz,Cz,Pz,Az;var I6=KZ(()=>{Hz=Object.create,PK=Object.defineProperty,zz=Object.getOwnPropertyDescriptor,qz=Object.getOwnPropertyNames,Wz=Object.getPrototypeOf,jz=Object.prototype.hasOwnProperty,Uz=Gz(($,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}),AK=_z(Uz()),m0=AK,Vz=AK;m0.parse??=EK;Vz.parse??=EK;e7={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:CK,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:CK},K8={sep:"\\",delimiter:";",win32:void 0,...e7,posix:e7};e7.win32=K8.win32=K8;e7.posix=e7;Mz=e7,{resolve:Oz,normalize:Yz,isAbsolute:Xz,join:kz,relative:Lz,toNamespacedPath:wz,dirname:Rz,basename:Bz,extname:Nz,format:Iz,parse:Cz,sep:Pz,delimiter:Az}=e7});var Gq={};z$(Gq,{validateXML:()=>WJ,validateSVGAsync:()=>sK,validateSVG:()=>jJ,straightCurves:()=>x$,sortDefsChildren:()=>u8,sortAttrs:()=>y8,simplifyPaths:()=>OJ,simplifyPath:()=>UJ,saveOutput:()=>F8,reusePaths:()=>g8,removeXlink:()=>d8,removeXMLProcInst:()=>L8,removeXMLNS:()=>I8,removeViewBox:()=>N8,removeUselessDefs:()=>Y8,removeUselessCommands:()=>p$,removeUnknownsAndDefaults:()=>M8,removeTitle:()=>w8,removeStyleElement:()=>m8,removeScriptElement:()=>P8,removeRasterImages:()=>C8,removeOffCanvasPath:()=>x8,removeNonInheritableGroupAttrs:()=>O8,removeMetadata:()=>Z$,removeLeadingZero:()=>v$,removeHiddenElements:()=>$$,removeEmptyText:()=>X8,removeEmptyContainers:()=>J$,removeEmptyAttrs:()=>B8,removeElementsByAttr:()=>i8,removeEditorsNSData:()=>$9,removeDoctype:()=>k8,removeDimensions:()=>n8,removeDesc:()=>R8,removeComments:()=>K$,removeAttrs:()=>o8,removeAttributesBySelector:()=>s8,printHierarchicalMatrix:()=>cK,presetNone:()=>Q9,presetDefault:()=>Z9,prefixIds:()=>l8,optimizePaths:()=>MJ,optimizeAnimationTiming:()=>VJ,optimize:()=>a8,negativeExtraSpace:()=>D$,moveGroupAttrsToElems:()=>v8,moveElemsAttrsToGroup:()=>D8,minifyStyles:()=>K9,mergePaths:()=>S8,measureDistance:()=>qJ,loadInput:()=>E6,lineShorthands:()=>u$,inlineStyles:()=>h8,imageToPath:()=>HJ,generateOutput:()=>T6,generateFullCompatibilityMatrix:()=>pK,generateFlexibleSVGTable:()=>GJ,generateCompatibilityMatrixSVG:()=>lK,generateCompatibilityMatrixFlexible:()=>nK,formatPrecision:()=>G8,floatPrecision:()=>d$,flattenUseElements:()=>QJ,flattenPatterns:()=>KJ,flattenMasks:()=>$J,flattenGradients:()=>JJ,flattenFilters:()=>ZJ,flattenClipPaths:()=>e8,flattenAll:()=>_J,fixInvalidSVG:()=>FJ,exportEmbeddedResources:()=>kJ,escapeXml:()=>gK,embedExternalDependencies:()=>H9,detectOutputTarget:()=>t$,detectInputType:()=>A6,detectCollisions:()=>zJ,default:()=>Fq,decomposeTransform:()=>YJ,createOperation:()=>j0,createConfig:()=>t8,convertTransform:()=>T8,convertToZ:()=>g$,convertToRelative:()=>h$,convertToAbsolute:()=>y$,convertStyleToAttrs:()=>J9,convertShapesToPath:()=>A8,convertQuadraticToSmooth:()=>l$,convertPathData:()=>E8,convertEllipseToCircle:()=>b8,convertCubicToSmooth:()=>n$,convertCubicToQuadratic:()=>c$,convertColors:()=>Q$,collapseRepeated:()=>m$,collapseGroups:()=>f8,cleanupNumericValues:()=>e6,cleanupListOfValues:()=>_8,cleanupIds:()=>e$,cleanupEnableBackground:()=>V8,cleanupAttributes:()=>U8,arcShorthands:()=>s$,applyPreset:()=>r8,analyzeCompatibilityMatrix:()=>dK,analyzeCompatibility:()=>mK,addClassesToSVGElement:()=>c8,addAttributesToSVGElement:()=>p8,ValidationSeverity:()=>C0,VERSION:()=>rK,PRECISION_LEVELS:()=>W8,OutputTarget:()=>q7,OutputFormat:()=>W7,MAX_PRECISION:()=>P6,InputType:()=>S0,DEFAULT_PRECISION:()=>t6});var LJ={};z$(LJ,{validateXML:()=>WJ,validateSVGAsync:()=>sK,validateSVG:()=>jJ,straightCurves:()=>x$,sortDefsChildren:()=>u8,sortAttrs:()=>y8,simplifyPaths:()=>OJ,simplifyPath:()=>UJ,saveOutput:()=>F8,reusePaths:()=>g8,removeXlink:()=>d8,removeXMLProcInst:()=>L8,removeXMLNS:()=>I8,removeViewBox:()=>N8,removeUselessDefs:()=>Y8,removeUselessCommands:()=>p$,removeUnknownsAndDefaults:()=>M8,removeTitle:()=>w8,removeStyleElement:()=>m8,removeScriptElement:()=>P8,removeRasterImages:()=>C8,removeOffCanvasPath:()=>x8,removeNonInheritableGroupAttrs:()=>O8,removeMetadata:()=>Z$,removeLeadingZero:()=>v$,removeHiddenElements:()=>$$,removeEmptyText:()=>X8,removeEmptyContainers:()=>J$,removeEmptyAttrs:()=>B8,removeElementsByAttr:()=>i8,removeEditorsNSData:()=>$9,removeDoctype:()=>k8,removeDimensions:()=>n8,removeDesc:()=>R8,removeComments:()=>K$,removeAttrs:()=>o8,removeAttributesBySelector:()=>s8,printHierarchicalMatrix:()=>cK,presetNone:()=>Q9,presetDefault:()=>Z9,prefixIds:()=>l8,optimizePaths:()=>MJ,optimizeAnimationTiming:()=>VJ,optimize:()=>a8,negativeExtraSpace:()=>D$,moveGroupAttrsToElems:()=>v8,moveElemsAttrsToGroup:()=>D8,minifyStyles:()=>K9,mergePaths:()=>S8,measureDistance:()=>qJ,loadInput:()=>E6,lineShorthands:()=>u$,inlineStyles:()=>h8,imageToPath:()=>HJ,generateOutput:()=>T6,generateFullCompatibilityMatrix:()=>pK,generateFlexibleSVGTable:()=>GJ,generateCompatibilityMatrixSVG:()=>lK,generateCompatibilityMatrixFlexible:()=>nK,formatPrecision:()=>G8,floatPrecision:()=>d$,flattenUseElements:()=>QJ,flattenPatterns:()=>KJ,flattenMasks:()=>$J,flattenGradients:()=>JJ,flattenFilters:()=>ZJ,flattenClipPaths:()=>e8,flattenAll:()=>_J,fixInvalidSVG:()=>FJ,exportEmbeddedResources:()=>kJ,escapeXml:()=>gK,embedExternalDependencies:()=>H9,detectOutputTarget:()=>t$,detectInputType:()=>A6,detectCollisions:()=>zJ,default:()=>jq,decomposeTransform:()=>YJ,createOperation:()=>j0,createConfig:()=>t8,convertTransform:()=>T8,convertToZ:()=>g$,convertToRelative:()=>h$,convertToAbsolute:()=>y$,convertStyleToAttrs:()=>J9,convertShapesToPath:()=>A8,convertQuadraticToSmooth:()=>l$,convertPathData:()=>E8,convertEllipseToCircle:()=>b8,convertCubicToSmooth:()=>n$,convertCubicToQuadratic:()=>c$,convertColors:()=>Q$,collapseRepeated:()=>m$,collapseGroups:()=>f8,cleanupNumericValues:()=>e6,cleanupListOfValues:()=>_8,cleanupIds:()=>e$,cleanupEnableBackground:()=>V8,cleanupAttributes:()=>U8,arcShorthands:()=>s$,applyPreset:()=>r8,analyzeCompatibilityMatrix:()=>dK,analyzeCompatibility:()=>mK,addClassesToSVGElement:()=>c8,addAttributesToSVGElement:()=>p8,ValidationSeverity:()=>C0,PRECISION_LEVELS:()=>W8,OutputTarget:()=>q7,OutputFormat:()=>W7,MAX_PRECISION:()=>P6,InputType:()=>S0,DEFAULT_PRECISION:()=>t6});/*!
1
+ /*! svg-matrix v1.3.6 | MIT License | https://github.com/Emasoft/svg-matrix */
2
+ (()=>{var FZ=Object.create;var{getPrototypeOf:_Z,defineProperty:v6,getOwnPropertyNames:DJ,getOwnPropertyDescriptor:UZ}=Object,hJ=Object.prototype.hasOwnProperty;var Q6=($,J,Z)=>{Z=$!=null?FZ(_Z($)):{};let K=J||!$||!$.__esModule?v6(Z,"default",{value:$,enumerable:!0}):Z;for(let Q of DJ($))if(!hJ.call(K,Q))v6(K,Q,{get:()=>$[Q],enumerable:!0});return K},vJ=new WeakMap,yJ=($)=>{var J=vJ.get($),Z;if(J)return J;if(J=v6({},"__esModule",{value:!0}),$&&typeof $==="object"||typeof $==="function")DJ($).map((K)=>!hJ.call(J,K)&&v6(J,K,{get:()=>$[K],enumerable:!(Z=UZ($,K))||Z.enumerable}));return vJ.set($,J),J};var W$=($,J)=>{for(var Z in J)v6($,Z,{get:J[Z],enumerable:!0,configurable:!0,set:(K)=>J[Z]=()=>K})};var VZ=($,J)=>()=>($&&(J=$($=0)),J);var v7=(($)=>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={};W$(I6,{win32:()=>W8,toNamespacedPath:()=>yz,sep:()=>pz,resolve:()=>fz,relative:()=>hz,posix:()=>K6,parse:()=>dz,normalize:()=>Sz,join:()=>Dz,isAbsolute:()=>vz,format:()=>mz,extname:()=>xz,dirname:()=>uz,delimiter:()=>cz,default:()=>bz,basename:()=>gz});var wz,gK,Rz,Bz,Nz,Cz,Iz=($,J)=>()=>(J||$((J={exports:{}}).exports,J),J.exports),Pz=($,J,Z,K)=>{if(J&&typeof J=="object"||typeof J=="function")for(let Q of Bz(J))!Cz.call($,Q)&&Q!==Z&&gK($,Q,{get:()=>J[Q],enumerable:!(K=Rz(J,Q))||K.enumerable});return $},Az=($,J,Z)=>(Z=$!=null?wz(Nz($)):{},Pz(J||!$||!$.__esModule?gK(Z,"default",{value:$,enumerable:!0}):Z,$)),Ez,xK,d0,Tz,uK=function($){return $},mK=function(){throw new Error("Not implemented")},K6,W8,bz,fz,Sz,vz,Dz,hz,yz,uz,gz,xz,mz,dz,pz,cz;var P6=VZ(()=>{wz=Object.create,gK=Object.defineProperty,Rz=Object.getOwnPropertyDescriptor,Bz=Object.getOwnPropertyNames,Nz=Object.getPrototypeOf,Cz=Object.prototype.hasOwnProperty,Ez=Iz(($,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 j="",W=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(j.length<2||W!==2||j.charCodeAt(j.length-1)!==46||j.charCodeAt(j.length-2)!==46){if(j.length>2){var M=j.lastIndexOf("/");if(M!==j.length-1){M===-1?(j="",W=0):(j=j.slice(0,M),W=j.length-1-j.lastIndexOf("/")),G=U,F=0;continue}}else if(j.length===2||j.length===1){j="",W=0,G=U,F=0;continue}}q&&(j.length>0?j+="/..":j="..",W=2)}else j.length>0?j+="/"+z.slice(G+1,U):j=z.slice(G+1,U),W=U-G-1;G=U,F=0}else _===46&&F!==-1?++F:F=-1}return j}function Q(z,q){var j=q.dir||q.root,W=q.base||(q.name||"")+(q.ext||"");return j?j===q.root?j+W:j+z+W:W}var H={resolve:function(){for(var z="",q=!1,j,W=arguments.length-1;W>=-1&&!q;W--){var G;W>=0?G=arguments[W]:(j===void 0&&(j=process.cwd()),G=j),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,j=z.charCodeAt(z.length-1)===47;return z=K(z,!q),z.length===0&&!q&&(z="."),z.length>0&&j&&(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 j=arguments[q];Z(j),j.length>0&&(z===void 0?z=j:z+="/"+j)}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 j=1;j<z.length&&z.charCodeAt(j)===47;++j);for(var W=z.length,G=W-j,F=1;F<q.length&&q.charCodeAt(F)===47;++F);for(var _=q.length,U=_-F,M=G<U?G:U,V=-1,Y=0;Y<=M;++Y){if(Y===M){if(U>M){if(q.charCodeAt(F+Y)===47)return q.slice(F+Y+1);if(Y===0)return q.slice(F+Y)}else G>M&&(z.charCodeAt(j+Y)===47?V=Y:Y===0&&(V=0));break}var O=z.charCodeAt(j+Y),X=q.charCodeAt(F+Y);if(O!==X)break;O===47&&(V=Y)}var w="";for(Y=j+V+1;Y<=W;++Y)(Y===W||z.charCodeAt(Y)===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),j=q===47,W=-1,G=!0,F=z.length-1;F>=1;--F)if(q=z.charCodeAt(F),q===47){if(!G){W=F;break}}else G=!1;return W===-1?j?"/":".":j&&W===1?"//":z.slice(0,W)},basename:function(z,q){if(q!==void 0&&typeof q!="string")throw new TypeError('"ext" argument must be a string');Z(z);var j=0,W=-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 M=z.charCodeAt(F);if(M===47){if(!G){j=F+1;break}}else U===-1&&(G=!1,U=F+1),_>=0&&(M===q.charCodeAt(_)?--_===-1&&(W=F):(_=-1,W=U))}return j===W?W=U:W===-1&&(W=z.length),z.slice(j,W)}else{for(F=z.length-1;F>=0;--F)if(z.charCodeAt(F)===47){if(!G){j=F+1;break}}else W===-1&&(G=!1,W=F+1);return W===-1?"":z.slice(j,W)}},extname:function(z){Z(z);for(var q=-1,j=0,W=-1,G=!0,F=0,_=z.length-1;_>=0;--_){var U=z.charCodeAt(_);if(U===47){if(!G){j=_+1;break}continue}W===-1&&(G=!1,W=_+1),U===46?q===-1?q=_:F!==1&&(F=1):q!==-1&&(F=-1)}return q===-1||W===-1||F===0||F===1&&q===W-1&&q===j+1?"":z.slice(q,W)},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 j=z.charCodeAt(0),W=j===47,G;W?(q.root="/",G=1):G=0;for(var F=-1,_=0,U=-1,M=!0,V=z.length-1,Y=0;V>=G;--V){if(j=z.charCodeAt(V),j===47){if(!M){_=V+1;break}continue}U===-1&&(M=!1,U=V+1),j===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&&W?q.base=q.name=z.slice(1,U):q.base=q.name=z.slice(_,U)):(_===0&&W?(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):W&&(q.dir="/"),q},sep:"/",delimiter:":",win32:null,posix:null};H.posix=H,J.exports=H}),xK=Az(Ez()),d0=xK,Tz=xK;d0.parse??=mK;Tz.parse??=mK;K6={resolve:d0.resolve.bind(d0),normalize:d0.normalize.bind(d0),isAbsolute:d0.isAbsolute.bind(d0),join:d0.join.bind(d0),relative:d0.relative.bind(d0),toNamespacedPath:uK,dirname:d0.dirname.bind(d0),basename:d0.basename.bind(d0),extname:d0.extname.bind(d0),format:d0.format.bind(d0),parse:d0.parse.bind(d0),sep:"/",delimiter:":",win32:void 0,posix:void 0,_makeLong:uK},W8={sep:"\\",delimiter:";",win32:void 0,...K6,posix:K6};K6.win32=W8.win32=W8;K6.posix=K6;bz=K6,{resolve:fz,normalize:Sz,isAbsolute:vz,join:Dz,relative:hz,toNamespacedPath:yz,dirname:uz,basename:gz,extname:xz,format:mz,parse:dz,sep:pz,delimiter:cz}=K6});var Iq={};W$(Iq,{validateXML:()=>MJ,validateSVGAsync:()=>HZ,validateSVG:()=>OJ,straightCurves:()=>d$,sortDefsChildren:()=>l8,sortAttrs:()=>c8,simplifyPaths:()=>BJ,simplifyPath:()=>kJ,saveOutput:()=>Y8,reusePaths:()=>n8,removeXlink:()=>i8,removeXMLProcInst:()=>I8,removeXMLNS:()=>f8,removeViewBox:()=>b8,removeUselessDefs:()=>B8,removeUselessCommands:()=>l$,removeUnknownsAndDefaults:()=>w8,removeTitle:()=>P8,removeStyleElement:()=>o8,removeScriptElement:()=>v8,removeRasterImages:()=>S8,removeOffCanvasPath:()=>s8,removeNonInheritableGroupAttrs:()=>R8,removeMetadata:()=>H$,removeLeadingZero:()=>h$,removeHiddenElements:()=>K$,removeEmptyText:()=>N8,removeEmptyContainers:()=>Z$,removeEmptyAttrs:()=>E8,removeElementsByAttr:()=>KJ,removeEditorsNSData:()=>K9,removeDoctype:()=>C8,removeDimensions:()=>e8,removeDesc:()=>A8,removeComments:()=>Q$,removeAttrs:()=>JJ,removeAttributesBySelector:()=>$J,printHierarchicalMatrix:()=>KZ,presetNone:()=>z9,presetDefault:()=>H9,prefixIds:()=>t8,optimizePaths:()=>RJ,optimizeAnimationTiming:()=>wJ,optimize:()=>QJ,negativeExtraSpace:()=>y$,moveGroupAttrsToElems:()=>m8,moveElemsAttrsToGroup:()=>d8,minifyStyles:()=>Q9,mergePaths:()=>x8,measureDistance:()=>VJ,loadInput:()=>b6,lineShorthands:()=>x$,inlineStyles:()=>p8,imageToPath:()=>_J,generateOutput:()=>f6,generateFullCompatibilityMatrix:()=>JZ,generateFlexibleSVGTable:()=>YJ,generateCompatibilityMatrixSVG:()=>ZZ,generateCompatibilityMatrixFlexible:()=>QZ,formatPrecision:()=>O8,floatPrecision:()=>c$,flattenUseElements:()=>FJ,flattenPatterns:()=>jJ,flattenMasks:()=>qJ,flattenGradients:()=>WJ,flattenFilters:()=>GJ,flattenClipPaths:()=>zJ,flattenAll:()=>LJ,fixInvalidSVG:()=>XJ,exportEmbeddedResources:()=>IJ,escapeXml:()=>aK,embedExternalDependencies:()=>q9,detectOutputTarget:()=>$9,detectInputType:()=>T6,detectCollisions:()=>UJ,default:()=>Pq,decomposeTransform:()=>NJ,createOperation:()=>G0,createConfig:()=>HJ,convertTransform:()=>y8,convertToZ:()=>m$,convertToRelative:()=>u$,convertToPlainSVG:()=>T8,convertToAbsolute:()=>g$,convertStyleToAttrs:()=>Z9,convertShapesToPath:()=>D8,convertQuadraticToSmooth:()=>s$,convertPathData:()=>h8,convertEllipseToCircle:()=>u8,convertCubicToSmooth:()=>o$,convertCubicToQuadratic:()=>n$,convertColors:()=>z$,collapseRepeated:()=>p$,collapseGroups:()=>g8,cleanupNumericValues:()=>J$,cleanupListOfValues:()=>X8,cleanupIds:()=>J9,cleanupEnableBackground:()=>k8,cleanupAttributes:()=>L8,arcShorthands:()=>i$,applyPreset:()=>ZJ,analyzeCompatibilityMatrix:()=>$Z,analyzeCompatibility:()=>eK,addClassesToSVGElement:()=>a8,addAttributesToSVGElement:()=>r8,ValidationSeverity:()=>R0,VERSION:()=>WZ,PRECISION_LEVELS:()=>V8,OutputTarget:()=>j7,OutputFormat:()=>G7,MAX_PRECISION:()=>E6,InputType:()=>v0,DEFAULT_PRECISION:()=>$$});var PJ={};W$(PJ,{validateXML:()=>MJ,validateSVGAsync:()=>HZ,validateSVG:()=>OJ,straightCurves:()=>d$,sortDefsChildren:()=>l8,sortAttrs:()=>c8,simplifyPaths:()=>BJ,simplifyPath:()=>kJ,saveOutput:()=>Y8,reusePaths:()=>n8,removeXlink:()=>i8,removeXMLProcInst:()=>I8,removeXMLNS:()=>f8,removeViewBox:()=>b8,removeUselessDefs:()=>B8,removeUselessCommands:()=>l$,removeUnknownsAndDefaults:()=>w8,removeTitle:()=>P8,removeStyleElement:()=>o8,removeScriptElement:()=>v8,removeRasterImages:()=>S8,removeOffCanvasPath:()=>s8,removeNonInheritableGroupAttrs:()=>R8,removeMetadata:()=>H$,removeLeadingZero:()=>h$,removeHiddenElements:()=>K$,removeEmptyText:()=>N8,removeEmptyContainers:()=>Z$,removeEmptyAttrs:()=>E8,removeElementsByAttr:()=>KJ,removeEditorsNSData:()=>K9,removeDoctype:()=>C8,removeDimensions:()=>e8,removeDesc:()=>A8,removeComments:()=>Q$,removeAttrs:()=>JJ,removeAttributesBySelector:()=>$J,printHierarchicalMatrix:()=>KZ,presetNone:()=>z9,presetDefault:()=>H9,prefixIds:()=>t8,optimizePaths:()=>RJ,optimizeAnimationTiming:()=>wJ,optimize:()=>QJ,negativeExtraSpace:()=>y$,moveGroupAttrsToElems:()=>m8,moveElemsAttrsToGroup:()=>d8,minifyStyles:()=>Q9,mergePaths:()=>x8,measureDistance:()=>VJ,loadInput:()=>b6,lineShorthands:()=>x$,inlineStyles:()=>p8,imageToPath:()=>_J,generateOutput:()=>f6,generateFullCompatibilityMatrix:()=>JZ,generateFlexibleSVGTable:()=>YJ,generateCompatibilityMatrixSVG:()=>ZZ,generateCompatibilityMatrixFlexible:()=>QZ,formatPrecision:()=>O8,floatPrecision:()=>c$,flattenUseElements:()=>FJ,flattenPatterns:()=>jJ,flattenMasks:()=>qJ,flattenGradients:()=>WJ,flattenFilters:()=>GJ,flattenClipPaths:()=>zJ,flattenAll:()=>LJ,fixInvalidSVG:()=>XJ,exportEmbeddedResources:()=>IJ,escapeXml:()=>aK,embedExternalDependencies:()=>q9,detectOutputTarget:()=>$9,detectInputType:()=>T6,detectCollisions:()=>UJ,default:()=>Cq,decomposeTransform:()=>NJ,createOperation:()=>G0,createConfig:()=>HJ,convertTransform:()=>y8,convertToZ:()=>m$,convertToRelative:()=>u$,convertToPlainSVG:()=>T8,convertToAbsolute:()=>g$,convertStyleToAttrs:()=>Z9,convertShapesToPath:()=>D8,convertQuadraticToSmooth:()=>s$,convertPathData:()=>h8,convertEllipseToCircle:()=>u8,convertCubicToSmooth:()=>o$,convertCubicToQuadratic:()=>n$,convertColors:()=>z$,collapseRepeated:()=>p$,collapseGroups:()=>g8,cleanupNumericValues:()=>J$,cleanupListOfValues:()=>X8,cleanupIds:()=>J9,cleanupEnableBackground:()=>k8,cleanupAttributes:()=>L8,arcShorthands:()=>i$,applyPreset:()=>ZJ,analyzeCompatibilityMatrix:()=>$Z,analyzeCompatibility:()=>eK,addClassesToSVGElement:()=>a8,addAttributesToSVGElement:()=>r8,ValidationSeverity:()=>R0,PRECISION_LEVELS:()=>V8,OutputTarget:()=>j7,OutputFormat:()=>G7,MAX_PRECISION:()=>E6,InputType:()=>v0,DEFAULT_PRECISION:()=>$$});/*!
3
3
  * decimal.js v10.6.0
4
4
  * An arbitrary-precision Decimal type for JavaScript.
5
5
  * https://github.com/MikeMcl/decimal.js
6
6
  * Copyright (c) 2025 Michael Mclaughlin <M8ch88l@gmail.com>
7
7
  * MIT Licence
8
- */var U6=9000000000000000,l7=1e9,W9="0123456789abcdef",j$="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",G$="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",j9={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-U6,maxE:U6,crypto:!1},fJ,S7,A0=!0,_$="[DecimalError] ",c7=_$+"Invalid argument: ",SJ=_$+"Precision limit exceeded",vJ=_$+"crypto unavailable",DJ="[object Decimal]",a0=Math.floor,p0=Math.pow,ZZ=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,QZ=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,HZ=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,hJ=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,L7=1e7,w0=7,zZ=9007199254740991,qZ=j$.length-1,G9=G$.length-1,Z0={toStringTag:DJ};Z0.absoluteValue=Z0.abs=function(){var $=new this.constructor(this);if($.s<0)$.s=1;return Y0($)};Z0.ceil=function(){return Y0(new this.constructor(this),this.e+1,2)};Z0.clampedTo=Z0.clamp=function($,J){var Z,K=this,Q=K.constructor;if($=new Q($),J=new Q(J),!$.s||!J.s)return new Q(NaN);if($.gt(J))throw Error(c7+J);return Z=K.cmp($),Z<0?$:K.cmp(J)>0?J:new Q(K)};Z0.comparedTo=Z0.cmp=function($){var J,Z,K,Q,H=this,z=H.d,q=($=new H.constructor($)).d,W=H.s,j=$.s;if(!z||!q)return!W||!j?NaN:W!==j?W:z===q?0:!z^W<0?1:-1;if(!z[0]||!q[0])return z[0]?W:q[0]?-j:0;if(W!==j)return W;if(H.e!==$.e)return H.e>$.e^W<0?1:-1;K=z.length,Q=q.length;for(J=0,Z=K<Q?K:Q;J<Z;++J)if(z[J]!==q[J])return z[J]>q[J]^W<0?1:-1;return K===Q?0:K>Q^W<0?1:-1};Z0.cosine=Z0.cos=function(){var $,J,Z=this,K=Z.constructor;if(!Z.d)return new K(NaN);if(!Z.d[0])return new K(1);return $=K.precision,J=K.rounding,K.precision=$+Math.max(Z.e,Z.sd())+w0,K.rounding=1,Z=WZ(K,mJ(K,Z)),K.precision=$,K.rounding=J,Y0(S7==2||S7==3?Z.neg():Z,$,J,!0)};Z0.cubeRoot=Z0.cbrt=function(){var $,J,Z,K,Q,H,z,q,W,j,G=this,F=G.constructor;if(!G.isFinite()||G.isZero())return new F(G);if(A0=!1,H=G.s*p0(G.s*G,0.3333333333333333),!H||Math.abs(H)==1/0){if(Z=i0(G.d),$=G.e,H=($-Z.length+1)%3)Z+=H==1||H==-2?"0":"00";if(H=p0(Z,0.3333333333333333),$=a0(($+1)/3)-($%3==($<0?-1:2)),H==1/0)Z="5e"+$;else Z=H.toExponential(),Z=Z.slice(0,Z.indexOf("e")+1)+$;K=new F(Z),K.s=G.s}else K=new F(H.toString());z=($=F.precision)+3;for(;;)if(q=K,W=q.times(q).times(q),j=W.plus(G),K=v0(j.plus(G).times(q),j.plus(W),z+2,1),i0(q.d).slice(0,z)===(Z=i0(K.d)).slice(0,z))if(Z=Z.slice(z-3,z+1),Z=="9999"||!Q&&Z=="4999"){if(!Q){if(Y0(q,$+1,0),q.times(q).times(q).eq(G)){K=q;break}}z+=4,Q=1}else{if(!+Z||!+Z.slice(1)&&Z.charAt(0)=="5")Y0(K,$+1,1),J=!K.times(K).times(K).eq(G);break}return A0=!0,Y0(K,$,F.rounding,J)};Z0.decimalPlaces=Z0.dp=function(){var $,J=this.d,Z=NaN;if(J){if($=J.length-1,Z=($-a0(this.e/w0))*w0,$=J[$],$)for(;$%10==0;$/=10)Z--;if(Z<0)Z=0}return Z};Z0.dividedBy=Z0.div=function($){return v0(this,new this.constructor($))};Z0.dividedToIntegerBy=Z0.divToInt=function($){var J=this,Z=J.constructor;return Y0(v0(J,new Z($),0,1,1),Z.precision,Z.rounding)};Z0.equals=Z0.eq=function($){return this.cmp($)===0};Z0.floor=function(){return Y0(new this.constructor(this),this.e+1,3)};Z0.greaterThan=Z0.gt=function($){return this.cmp($)>0};Z0.greaterThanOrEqualTo=Z0.gte=function($){var J=this.cmp($);return J==1||J===0};Z0.hyperbolicCosine=Z0.cosh=function(){var $,J,Z,K,Q,H=this,z=H.constructor,q=new z(1);if(!H.isFinite())return new z(H.s?1/0:NaN);if(H.isZero())return q;if(Z=z.precision,K=z.rounding,z.precision=Z+Math.max(H.e,H.sd())+4,z.rounding=1,Q=H.d.length,Q<32)$=Math.ceil(Q/3),J=(1/V$(4,$)).toString();else $=16,J="2.3283064365386962890625e-10";H=V6(z,1,H.times(J),new z(1),!0);var W,j=$,G=new z(8);for(;j--;)W=H.times(H),H=q.minus(W.times(G.minus(W.times(G))));return Y0(H,z.precision=Z,z.rounding=K,!0)};Z0.hyperbolicSine=Z0.sinh=function(){var $,J,Z,K,Q=this,H=Q.constructor;if(!Q.isFinite()||Q.isZero())return new H(Q);if(J=H.precision,Z=H.rounding,H.precision=J+Math.max(Q.e,Q.sd())+4,H.rounding=1,K=Q.d.length,K<3)Q=V6(H,2,Q,Q,!0);else{$=1.4*Math.sqrt(K),$=$>16?16:$|0,Q=Q.times(1/V$(5,$)),Q=V6(H,2,Q,Q,!0);var z,q=new H(5),W=new H(16),j=new H(20);for(;$--;)z=Q.times(Q),Q=Q.times(q.plus(z.times(W.times(z).plus(j))))}return H.precision=J,H.rounding=Z,Y0(Q,J,Z,!0)};Z0.hyperbolicTangent=Z0.tanh=function(){var $,J,Z=this,K=Z.constructor;if(!Z.isFinite())return new K(Z.s);if(Z.isZero())return new K(Z);return $=K.precision,J=K.rounding,K.precision=$+7,K.rounding=1,v0(Z.sinh(),Z.cosh(),K.precision=$,K.rounding=J)};Z0.inverseCosine=Z0.acos=function(){var $=this,J=$.constructor,Z=$.abs().cmp(1),K=J.precision,Q=J.rounding;if(Z!==-1)return Z===0?$.isNeg()?N7(J,K,Q):new J(0):new J(NaN);if($.isZero())return N7(J,K+4,Q).times(0.5);return J.precision=K+6,J.rounding=1,$=new J(1).minus($).div($.plus(1)).sqrt().atan(),J.precision=K,J.rounding=Q,$.times(2)};Z0.inverseHyperbolicCosine=Z0.acosh=function(){var $,J,Z=this,K=Z.constructor;if(Z.lte(1))return new K(Z.eq(1)?0:NaN);if(!Z.isFinite())return new K(Z);return $=K.precision,J=K.rounding,K.precision=$+Math.max(Math.abs(Z.e),Z.sd())+4,K.rounding=1,A0=!1,Z=Z.times(Z).minus(1).sqrt().plus(Z),A0=!0,K.precision=$,K.rounding=J,Z.ln()};Z0.inverseHyperbolicSine=Z0.asinh=function(){var $,J,Z=this,K=Z.constructor;if(!Z.isFinite()||Z.isZero())return new K(Z);return $=K.precision,J=K.rounding,K.precision=$+2*Math.max(Math.abs(Z.e),Z.sd())+6,K.rounding=1,A0=!1,Z=Z.times(Z).plus(1).sqrt().plus(Z),A0=!0,K.precision=$,K.rounding=J,Z.ln()};Z0.inverseHyperbolicTangent=Z0.atanh=function(){var $,J,Z,K,Q=this,H=Q.constructor;if(!Q.isFinite())return new H(NaN);if(Q.e>=0)return new H(Q.abs().eq(1)?Q.s/0:Q.isZero()?Q:NaN);if($=H.precision,J=H.rounding,K=Q.sd(),Math.max(K,$)<2*-Q.e-1)return Y0(new H(Q),$,J,!0);return H.precision=Z=K-Q.e,Q=v0(Q.plus(1),new H(1).minus(Q),Z+$,1),H.precision=$+4,H.rounding=1,Q=Q.ln(),H.precision=$,H.rounding=J,Q.times(0.5)};Z0.inverseSine=Z0.asin=function(){var $,J,Z,K,Q=this,H=Q.constructor;if(Q.isZero())return new H(Q);if(J=Q.abs().cmp(1),Z=H.precision,K=H.rounding,J!==-1){if(J===0)return $=N7(H,Z+4,K).times(0.5),$.s=Q.s,$;return new H(NaN)}return H.precision=Z+6,H.rounding=1,Q=Q.div(new H(1).minus(Q.times(Q)).sqrt().plus(1)).atan(),H.precision=Z,H.rounding=K,Q.times(2)};Z0.inverseTangent=Z0.atan=function(){var $,J,Z,K,Q,H,z,q,W,j=this,G=j.constructor,F=G.precision,_=G.rounding;if(!j.isFinite()){if(!j.s)return new G(NaN);if(F+4<=G9)return z=N7(G,F+4,_).times(0.5),z.s=j.s,z}else if(j.isZero())return new G(j);else if(j.abs().eq(1)&&F+4<=G9)return z=N7(G,F+4,_).times(0.25),z.s=j.s,z;G.precision=q=F+10,G.rounding=1,Z=Math.min(28,q/w0+2|0);for($=Z;$;--$)j=j.div(j.times(j).plus(1).sqrt().plus(1));A0=!1,J=Math.ceil(q/w0),K=1,W=j.times(j),z=new G(j),Q=j;for(;$!==-1;)if(Q=Q.times(W),H=z.minus(Q.div(K+=2)),Q=Q.times(W),z=H.plus(Q.div(K+=2)),z.d[J]!==void 0)for($=J;z.d[$]===H.d[$]&&$--;);if(Z)z=z.times(2<<Z-1);return A0=!0,Y0(z,G.precision=F,G.rounding=_,!0)};Z0.isFinite=function(){return!!this.d};Z0.isInteger=Z0.isInt=function(){return!!this.d&&a0(this.e/w0)>this.d.length-2};Z0.isNaN=function(){return!this.s};Z0.isNegative=Z0.isNeg=function(){return this.s<0};Z0.isPositive=Z0.isPos=function(){return this.s>0};Z0.isZero=function(){return!!this.d&&this.d[0]===0};Z0.lessThan=Z0.lt=function($){return this.cmp($)<0};Z0.lessThanOrEqualTo=Z0.lte=function($){return this.cmp($)<1};Z0.logarithm=Z0.log=function($){var J,Z,K,Q,H,z,q,W,j=this,G=j.constructor,F=G.precision,_=G.rounding,U=5;if($==null)$=new G(10),J=!0;else{if($=new G($),Z=$.d,$.s<0||!Z||!Z[0]||$.eq(1))return new G(NaN);J=$.eq(10)}if(Z=j.d,j.s<0||!Z||!Z[0]||j.eq(1))return new G(Z&&!Z[0]?-1/0:j.s!=1?NaN:Z?0:1/0);if(J)if(Z.length>1)H=!0;else{for(Q=Z[0];Q%10===0;)Q/=10;H=Q!==1}if(A0=!1,q=F+U,z=p7(j,q),K=J?F$(G,q+10):p7($,q),W=v0(z,K,q,1),S6(W.d,Q=F,_))do if(q+=10,z=p7(j,q),K=J?F$(G,q+10):p7($,q),W=v0(z,K,q,1),!H){if(+i0(W.d).slice(Q+1,Q+15)+1==100000000000000)W=Y0(W,F+1,0);break}while(S6(W.d,Q+=10,_));return A0=!0,Y0(W,F,_)};Z0.minus=Z0.sub=function($){var J,Z,K,Q,H,z,q,W,j,G,F,_,U=this,O=U.constructor;if($=new O($),!U.d||!$.d){if(!U.s||!$.s)$=new O(NaN);else if(U.d)$.s=-$.s;else $=new O($.d||U.s!==$.s?U:NaN);return $}if(U.s!=$.s)return $.s=-$.s,U.plus($);if(j=U.d,_=$.d,q=O.precision,W=O.rounding,!j[0]||!_[0]){if(_[0])$.s=-$.s;else if(j[0])$=new O(U);else return new O(W===3?-0:0);return A0?Y0($,q,W):$}if(Z=a0($.e/w0),G=a0(U.e/w0),j=j.slice(),H=G-Z,H){if(F=H<0,F)J=j,H=-H,z=_.length;else J=_,Z=G,z=j.length;if(K=Math.max(Math.ceil(q/w0),z)+2,H>K)H=K,J.length=1;J.reverse();for(K=H;K--;)J.push(0);J.reverse()}else{if(K=j.length,z=_.length,F=K<z,F)z=K;for(K=0;K<z;K++)if(j[K]!=_[K]){F=j[K]<_[K];break}H=0}if(F)J=j,j=_,_=J,$.s=-$.s;z=j.length;for(K=_.length-z;K>0;--K)j[z++]=0;for(K=_.length;K>H;){if(j[--K]<_[K]){for(Q=K;Q&&j[--Q]===0;)j[Q]=L7-1;--j[Q],j[K]+=L7}j[K]-=_[K]}for(;j[--z]===0;)j.pop();for(;j[0]===0;j.shift())--Z;if(!j[0])return new O(W===3?-0:0);return $.d=j,$.e=U$(j,Z),A0?Y0($,q,W):$};Z0.modulo=Z0.mod=function($){var J,Z=this,K=Z.constructor;if($=new K($),!Z.d||!$.s||$.d&&!$.d[0])return new K(NaN);if(!$.d||Z.d&&!Z.d[0])return Y0(new K(Z),K.precision,K.rounding);if(A0=!1,K.modulo==9)J=v0(Z,$.abs(),0,3,1),J.s*=$.s;else J=v0(Z,$,0,K.modulo,1);return J=J.times($),A0=!0,Z.minus(J)};Z0.naturalExponential=Z0.exp=function(){return F9(this)};Z0.naturalLogarithm=Z0.ln=function(){return p7(this)};Z0.negated=Z0.neg=function(){var $=new this.constructor(this);return $.s=-$.s,Y0($)};Z0.plus=Z0.add=function($){var J,Z,K,Q,H,z,q,W,j,G,F=this,_=F.constructor;if($=new _($),!F.d||!$.d){if(!F.s||!$.s)$=new _(NaN);else if(!F.d)$=new _($.d||F.s===$.s?F:NaN);return $}if(F.s!=$.s)return $.s=-$.s,F.minus($);if(j=F.d,G=$.d,q=_.precision,W=_.rounding,!j[0]||!G[0]){if(!G[0])$=new _(F);return A0?Y0($,q,W):$}if(H=a0(F.e/w0),K=a0($.e/w0),j=j.slice(),Q=H-K,Q){if(Q<0)Z=j,Q=-Q,z=G.length;else Z=G,K=H,z=j.length;if(H=Math.ceil(q/w0),z=H>z?H+1:z+1,Q>z)Q=z,Z.length=1;Z.reverse();for(;Q--;)Z.push(0);Z.reverse()}if(z=j.length,Q=G.length,z-Q<0)Q=z,Z=G,G=j,j=Z;for(J=0;Q;)J=(j[--Q]=j[Q]+G[Q]+J)/L7|0,j[Q]%=L7;if(J)j.unshift(J),++K;for(z=j.length;j[--z]==0;)j.pop();return $.d=j,$.e=U$(j,K),A0?Y0($,q,W):$};Z0.precision=Z0.sd=function($){var J,Z=this;if($!==void 0&&$!==!!$&&$!==1&&$!==0)throw Error(c7+$);if(Z.d){if(J=yJ(Z.d),$&&Z.e+1>J)J=Z.e+1}else J=NaN;return J};Z0.round=function(){var $=this,J=$.constructor;return Y0(new J($),$.e+1,J.rounding)};Z0.sine=Z0.sin=function(){var $,J,Z=this,K=Z.constructor;if(!Z.isFinite())return new K(NaN);if(Z.isZero())return new K(Z);return $=K.precision,J=K.rounding,K.precision=$+Math.max(Z.e,Z.sd())+w0,K.rounding=1,Z=GZ(K,mJ(K,Z)),K.precision=$,K.rounding=J,Y0(S7>2?Z.neg():Z,$,J,!0)};Z0.squareRoot=Z0.sqrt=function(){var $,J,Z,K,Q,H,z=this,q=z.d,W=z.e,j=z.s,G=z.constructor;if(j!==1||!q||!q[0])return new G(!j||j<0&&(!q||q[0])?NaN:q?z:1/0);if(A0=!1,j=Math.sqrt(+z),j==0||j==1/0){if(J=i0(q),(J.length+W)%2==0)J+="0";if(j=Math.sqrt(J),W=a0((W+1)/2)-(W<0||W%2),j==1/0)J="5e"+W;else J=j.toExponential(),J=J.slice(0,J.indexOf("e")+1)+W;K=new G(J)}else K=new G(j.toString());Z=(W=G.precision)+3;for(;;)if(H=K,K=H.plus(v0(z,H,Z+2,1)).times(0.5),i0(H.d).slice(0,Z)===(J=i0(K.d)).slice(0,Z))if(J=J.slice(Z-3,Z+1),J=="9999"||!Q&&J=="4999"){if(!Q){if(Y0(H,W+1,0),H.times(H).eq(z)){K=H;break}}Z+=4,Q=1}else{if(!+J||!+J.slice(1)&&J.charAt(0)=="5")Y0(K,W+1,1),$=!K.times(K).eq(z);break}return A0=!0,Y0(K,W,G.rounding,$)};Z0.tangent=Z0.tan=function(){var $,J,Z=this,K=Z.constructor;if(!Z.isFinite())return new K(NaN);if(Z.isZero())return new K(Z);return $=K.precision,J=K.rounding,K.precision=$+10,K.rounding=1,Z=Z.sin(),Z.s=1,Z=v0(Z,new K(1).minus(Z.times(Z)).sqrt(),$+10,0),K.precision=$,K.rounding=J,Y0(S7==2||S7==4?Z.neg():Z,$,J,!0)};Z0.times=Z0.mul=function($){var J,Z,K,Q,H,z,q,W,j,G=this,F=G.constructor,_=G.d,U=($=new F($)).d;if($.s*=G.s,!_||!_[0]||!U||!U[0])return new F(!$.s||_&&!_[0]&&!U||U&&!U[0]&&!_?NaN:!_||!U?$.s/0:$.s*0);if(Z=a0(G.e/w0)+a0($.e/w0),W=_.length,j=U.length,W<j)H=_,_=U,U=H,z=W,W=j,j=z;H=[],z=W+j;for(K=z;K--;)H.push(0);for(K=j;--K>=0;){J=0;for(Q=W+K;Q>K;)q=H[Q]+U[K]*_[Q-K-1]+J,H[Q--]=q%L7|0,J=q/L7|0;H[Q]=(H[Q]+J)%L7|0}for(;!H[--z];)H.pop();if(J)++Z;else H.shift();return $.d=H,$.e=U$(H,Z),A0?Y0($,F.precision,F.rounding):$};Z0.toBinary=function($,J){return _9(this,2,$,J)};Z0.toDecimalPlaces=Z0.toDP=function($,J){var Z=this,K=Z.constructor;if(Z=new K(Z),$===void 0)return Z;if(J7($,0,l7),J===void 0)J=K.rounding;else J7(J,0,8);return Y0(Z,$+Z.e+1,J)};Z0.toExponential=function($,J){var Z,K=this,Q=K.constructor;if($===void 0)Z=I7(K,!0);else{if(J7($,0,l7),J===void 0)J=Q.rounding;else J7(J,0,8);K=Y0(new Q(K),$+1,J),Z=I7(K,!0,$+1)}return K.isNeg()&&!K.isZero()?"-"+Z:Z};Z0.toFixed=function($,J){var Z,K,Q=this,H=Q.constructor;if($===void 0)Z=I7(Q);else{if(J7($,0,l7),J===void 0)J=H.rounding;else J7(J,0,8);K=Y0(new H(Q),$+Q.e+1,J),Z=I7(K,!1,$+K.e+1)}return Q.isNeg()&&!Q.isZero()?"-"+Z:Z};Z0.toFraction=function($){var J,Z,K,Q,H,z,q,W,j,G,F,_,U=this,O=U.d,V=U.constructor;if(!O)return new V(U);if(j=Z=new V(1),K=W=new V(0),J=new V(K),H=J.e=yJ(O)-U.e-1,z=H%w0,J.d[0]=p0(10,z<0?w0+z:z),$==null)$=H>0?J:j;else{if(q=new V($),!q.isInt()||q.lt(j))throw Error(c7+q);$=q.gt(J)?H>0?J:j:q}A0=!1,q=new V(i0(O)),G=V.precision,V.precision=H=O.length*w0*2;for(;;){if(F=v0(q,J,0,1,1),Q=Z.plus(F.times(K)),Q.cmp($)==1)break;Z=K,K=Q,Q=j,j=W.plus(F.times(Q)),W=Q,Q=J,J=q.minus(F.times(Q)),q=Q}return Q=v0($.minus(Z),K,0,1,1),W=W.plus(Q.times(j)),Z=Z.plus(Q.times(K)),W.s=j.s=U.s,_=v0(j,K,H,1).minus(U).abs().cmp(v0(W,Z,H,1).minus(U).abs())<1?[j,K]:[W,Z],V.precision=G,A0=!0,_};Z0.toHexadecimal=Z0.toHex=function($,J){return _9(this,16,$,J)};Z0.toNearest=function($,J){var Z=this,K=Z.constructor;if(Z=new K(Z),$==null){if(!Z.d)return Z;$=new K(1),J=K.rounding}else{if($=new K($),J===void 0)J=K.rounding;else J7(J,0,8);if(!Z.d)return $.s?Z:$;if(!$.d){if($.s)$.s=Z.s;return $}}if($.d[0])A0=!1,Z=v0(Z,$,0,J,1).times($),A0=!0,Y0(Z);else $.s=Z.s,Z=$;return Z};Z0.toNumber=function(){return+this};Z0.toOctal=function($,J){return _9(this,8,$,J)};Z0.toPower=Z0.pow=function($){var J,Z,K,Q,H,z,q=this,W=q.constructor,j=+($=new W($));if(!q.d||!$.d||!q.d[0]||!$.d[0])return new W(p0(+q,j));if(q=new W(q),q.eq(1))return q;if(K=W.precision,H=W.rounding,$.eq(1))return Y0(q,K,H);if(J=a0($.e/w0),J>=$.d.length-1&&(Z=j<0?-j:j)<=zZ)return Q=uJ(W,q,Z,K),$.s<0?new W(1).div(Q):Y0(Q,K,H);if(z=q.s,z<0){if(J<$.d.length-1)return new W(NaN);if(($.d[J]&1)==0)z=1;if(q.e==0&&q.d[0]==1&&q.d.length==1)return q.s=z,q}if(Z=p0(+q,j),J=Z==0||!isFinite(Z)?a0(j*(Math.log("0."+i0(q.d))/Math.LN10+q.e+1)):new W(Z+"").e,J>W.maxE+1||J<W.minE-1)return new W(J>0?z/0:0);if(A0=!1,W.rounding=q.s=1,Z=Math.min(12,(J+"").length),Q=F9($.times(p7(q,K+Z)),K),Q.d){if(Q=Y0(Q,K+5,1),S6(Q.d,K,H)){if(J=K+10,Q=Y0(F9($.times(p7(q,J+Z)),J),J+5,1),+i0(Q.d).slice(K+1,K+15)+1==100000000000000)Q=Y0(Q,K+1,0)}}return Q.s=z,A0=!0,W.rounding=H,Y0(Q,K,H)};Z0.toPrecision=function($,J){var Z,K=this,Q=K.constructor;if($===void 0)Z=I7(K,K.e<=Q.toExpNeg||K.e>=Q.toExpPos);else{if(J7($,1,l7),J===void 0)J=Q.rounding;else J7(J,0,8);K=Y0(new Q(K),$,J),Z=I7(K,$<=K.e||K.e<=Q.toExpNeg,$)}return K.isNeg()&&!K.isZero()?"-"+Z:Z};Z0.toSignificantDigits=Z0.toSD=function($,J){var Z=this,K=Z.constructor;if($===void 0)$=K.precision,J=K.rounding;else if(J7($,1,l7),J===void 0)J=K.rounding;else J7(J,0,8);return Y0(new K(Z),$,J)};Z0.toString=function(){var $=this,J=$.constructor,Z=I7($,$.e<=J.toExpNeg||$.e>=J.toExpPos);return $.isNeg()&&!$.isZero()?"-"+Z:Z};Z0.truncated=Z0.trunc=function(){return Y0(new this.constructor(this),this.e+1,1)};Z0.valueOf=Z0.toJSON=function(){var $=this,J=$.constructor,Z=I7($,$.e<=J.toExpNeg||$.e>=J.toExpPos);return $.isNeg()?"-"+Z:Z};function i0($){var J,Z,K,Q=$.length-1,H="",z=$[0];if(Q>0){H+=z;for(J=1;J<Q;J++){if(K=$[J]+"",Z=w0-K.length,Z)H+=d7(Z);H+=K}if(z=$[J],K=z+"",Z=w0-K.length,Z)H+=d7(Z)}else if(z===0)return"0";for(;z%10===0;)z/=10;return H+z}function J7($,J,Z){if($!==~~$||$<J||$>Z)throw Error(c7+$)}function S6($,J,Z,K){var Q,H,z,q;for(H=$[0];H>=10;H/=10)--J;if(--J<0)J+=w0,Q=0;else Q=Math.ceil((J+1)/w0),J%=w0;if(H=p0(10,w0-J),q=$[Q]%H|0,K==null)if(J<3){if(J==0)q=q/100|0;else if(J==1)q=q/10|0;z=Z<4&&q==99999||Z>3&&q==49999||q==50000||q==0}else z=(Z<4&&q+1==H||Z>3&&q+1==H/2)&&($[Q+1]/H/100|0)==p0(10,J-2)-1||(q==H/2||q==0)&&($[Q+1]/H/100|0)==0;else if(J<4){if(J==0)q=q/1000|0;else if(J==1)q=q/100|0;else if(J==2)q=q/10|0;z=(K||Z<4)&&q==9999||!K&&Z>3&&q==4999}else z=((K||Z<4)&&q+1==H||!K&&Z>3&&q+1==H/2)&&($[Q+1]/H/1000|0)==p0(10,J-3)-1;return z}function q$($,J,Z){var K,Q=[0],H,z=0,q=$.length;for(;z<q;){for(H=Q.length;H--;)Q[H]*=J;Q[0]+=W9.indexOf($.charAt(z++));for(K=0;K<Q.length;K++)if(Q[K]>Z-1){if(Q[K+1]===void 0)Q[K+1]=0;Q[K+1]+=Q[K]/Z|0,Q[K]%=Z}}return Q.reverse()}function WZ($,J){var Z,K,Q;if(J.isZero())return J;if(K=J.d.length,K<32)Z=Math.ceil(K/3),Q=(1/V$(4,Z)).toString();else Z=16,Q="2.3283064365386962890625e-10";$.precision+=Z,J=V6($,1,J.times(Q),new $(1));for(var H=Z;H--;){var z=J.times(J);J=z.times(z).minus(z).times(8).plus(1)}return $.precision-=Z,J}var v0=function(){function $(K,Q,H){var z,q=0,W=K.length;for(K=K.slice();W--;)z=K[W]*Q+q,K[W]=z%H|0,q=z/H|0;if(q)K.unshift(q);return K}function J(K,Q,H,z){var q,W;if(H!=z)W=H>z?1:-1;else for(q=W=0;q<H;q++)if(K[q]!=Q[q]){W=K[q]>Q[q]?1:-1;break}return W}function Z(K,Q,H,z){var q=0;for(;H--;)K[H]-=q,q=K[H]<Q[H]?1:0,K[H]=q*z+K[H]-Q[H];for(;!K[0]&&K.length>1;)K.shift()}return function(K,Q,H,z,q,W){var j,G,F,_,U,O,V,M,Y,X,w,R,I,b,u,m,S,x,h,E,d=K.constructor,c=K.s==Q.s?1:-1,p=K.d,N=Q.d;if(!p||!p[0]||!N||!N[0])return new d(!K.s||!Q.s||(p?N&&p[0]==N[0]:!N)?NaN:p&&p[0]==0||!N?c*0:c/0);if(W)U=1,G=K.e-Q.e;else W=L7,U=w0,G=a0(K.e/U)-a0(Q.e/U);h=N.length,S=p.length,Y=new d(c),X=Y.d=[];for(F=0;N[F]==(p[F]||0);F++);if(N[F]>(p[F]||0))G--;if(H==null)b=H=d.precision,z=d.rounding;else if(q)b=H+(K.e-Q.e)+1;else b=H;if(b<0)X.push(1),O=!0;else{if(b=b/U+2|0,F=0,h==1){_=0,N=N[0],b++;for(;(F<S||_)&&b--;F++)u=_*W+(p[F]||0),X[F]=u/N|0,_=u%N|0;O=_||F<S}else{if(_=W/(N[0]+1)|0,_>1)N=$(N,_,W),p=$(p,_,W),h=N.length,S=p.length;m=h,w=p.slice(0,h),R=w.length;for(;R<h;)w[R++]=0;if(E=N.slice(),E.unshift(0),x=N[0],N[1]>=W/2)++x;do{if(_=0,j=J(N,w,h,R),j<0){if(I=w[0],h!=R)I=I*W+(w[1]||0);if(_=I/x|0,_>1){if(_>=W)_=W-1;if(V=$(N,_,W),M=V.length,R=w.length,j=J(V,w,M,R),j==1)_--,Z(V,h<M?E:N,M,W)}else{if(_==0)j=_=1;V=N.slice()}if(M=V.length,M<R)V.unshift(0);if(Z(w,V,R,W),j==-1){if(R=w.length,j=J(N,w,h,R),j<1)_++,Z(w,h<R?E:N,R,W)}R=w.length}else if(j===0)_++,w=[0];if(X[F++]=_,j&&w[0])w[R++]=p[m]||0;else w=[p[m]],R=1}while((m++<S||w[0]!==void 0)&&b--);O=w[0]!==void 0}if(!X[0])X.shift()}if(U==1)Y.e=G,fJ=O;else{for(F=1,_=X[0];_>=10;_/=10)F++;Y.e=F+G*U-1,Y0(Y,q?H+Y.e+1:H,z,O)}return Y}}();function Y0($,J,Z,K){var Q,H,z,q,W,j,G,F,_,U=$.constructor;$:if(J!=null){if(F=$.d,!F)return $;for(Q=1,q=F[0];q>=10;q/=10)Q++;if(H=J-Q,H<0)H+=w0,z=J,G=F[_=0],W=G/p0(10,Q-z-1)%10|0;else if(_=Math.ceil((H+1)/w0),q=F.length,_>=q)if(K){for(;q++<=_;)F.push(0);G=W=0,Q=1,H%=w0,z=H-w0+1}else break $;else{G=q=F[_];for(Q=1;q>=10;q/=10)Q++;H%=w0,z=H-w0+Q,W=z<0?0:G/p0(10,Q-z-1)%10|0}if(K=K||J<0||F[_+1]!==void 0||(z<0?G:G%p0(10,Q-z-1)),j=Z<4?(W||K)&&(Z==0||Z==($.s<0?3:2)):W>5||W==5&&(Z==4||K||Z==6&&(H>0?z>0?G/p0(10,Q-z):0:F[_-1])%10&1||Z==($.s<0?8:7)),J<1||!F[0]){if(F.length=0,j)J-=$.e+1,F[0]=p0(10,(w0-J%w0)%w0),$.e=-J||0;else F[0]=$.e=0;return $}if(H==0)F.length=_,q=1,_--;else F.length=_+1,q=p0(10,w0-H),F[_]=z>0?(G/p0(10,Q-z)%p0(10,z)|0)*q:0;if(j)for(;;)if(_==0){for(H=1,z=F[0];z>=10;z/=10)H++;z=F[0]+=q;for(q=1;z>=10;z/=10)q++;if(H!=q){if($.e++,F[0]==L7)F[0]=1}break}else{if(F[_]+=q,F[_]!=L7)break;F[_--]=0,q=1}for(H=F.length;F[--H]===0;)F.pop()}if(A0){if($.e>U.maxE)$.d=null,$.e=NaN;else if($.e<U.minE)$.e=0,$.d=[0]}return $}function I7($,J,Z){if(!$.isFinite())return xJ($);var K,Q=$.e,H=i0($.d),z=H.length;if(J){if(Z&&(K=Z-z)>0)H=H.charAt(0)+"."+H.slice(1)+d7(K);else if(z>1)H=H.charAt(0)+"."+H.slice(1);H=H+($.e<0?"e":"e+")+$.e}else if(Q<0){if(H="0."+d7(-Q-1)+H,Z&&(K=Z-z)>0)H+=d7(K)}else if(Q>=z){if(H+=d7(Q+1-z),Z&&(K=Z-Q-1)>0)H=H+"."+d7(K)}else{if((K=Q+1)<z)H=H.slice(0,K)+"."+H.slice(K);if(Z&&(K=Z-z)>0){if(Q+1===z)H+=".";H+=d7(K)}}return H}function U$($,J){var Z=$[0];for(J*=w0;Z>=10;Z/=10)J++;return J}function F$($,J,Z){if(J>qZ){if(A0=!0,Z)$.precision=Z;throw Error(SJ)}return Y0(new $(j$),J,1,!0)}function N7($,J,Z){if(J>G9)throw Error(SJ);return Y0(new $(G$),J,Z,!0)}function yJ($){var J=$.length-1,Z=J*w0+1;if(J=$[J],J){for(;J%10==0;J/=10)Z--;for(J=$[0];J>=10;J/=10)Z++}return Z}function d7($){var J="";for(;$--;)J+="0";return J}function uJ($,J,Z,K){var Q,H=new $(1),z=Math.ceil(K/w0+4);A0=!1;for(;;){if(Z%2){if(H=H.times(J),TJ(H.d,z))Q=!0}if(Z=a0(Z/2),Z===0){if(Z=H.d.length-1,Q&&H.d[Z]===0)++H.d[Z];break}J=J.times(J),TJ(J.d,z)}return A0=!0,H}function EJ($){return $.d[$.d.length-1]&1}function gJ($,J,Z){var K,Q,H=new $(J[0]),z=0;for(;++z<J.length;){if(Q=new $(J[z]),!Q.s){H=Q;break}if(K=H.cmp(Q),K===Z||K===0&&H.s===Z)H=Q}return H}function F9($,J){var Z,K,Q,H,z,q,W,j=0,G=0,F=0,_=$.constructor,U=_.rounding,O=_.precision;if(!$.d||!$.d[0]||$.e>17)return new _($.d?!$.d[0]?1:$.s<0?0:1/0:$.s?$.s<0?0:$:NaN);if(J==null)A0=!1,W=O;else W=J;q=new _(0.03125);while($.e>-2)$=$.times(q),F+=5;K=Math.log(p0(2,F))/Math.LN10*2+5|0,W+=K,Z=H=z=new _(1),_.precision=W;for(;;){if(H=Y0(H.times($),W,1),Z=Z.times(++G),q=z.plus(v0(H,Z,W,1)),i0(q.d).slice(0,W)===i0(z.d).slice(0,W)){Q=F;while(Q--)z=Y0(z.times(z),W,1);if(J==null)if(j<3&&S6(z.d,W-K,U,j))_.precision=W+=10,Z=H=q=new _(1),G=0,j++;else return Y0(z,_.precision=O,U,A0=!0);else return _.precision=O,z}z=q}}function p7($,J){var Z,K,Q,H,z,q,W,j,G,F,_,U=1,O=10,V=$,M=V.d,Y=V.constructor,X=Y.rounding,w=Y.precision;if(V.s<0||!M||!M[0]||!V.e&&M[0]==1&&M.length==1)return new Y(M&&!M[0]?-1/0:V.s!=1?NaN:M?0:V);if(J==null)A0=!1,G=w;else G=J;if(Y.precision=G+=O,Z=i0(M),K=Z.charAt(0),Math.abs(H=V.e)<1500000000000000){while(K<7&&K!=1||K==1&&Z.charAt(1)>3)V=V.times($),Z=i0(V.d),K=Z.charAt(0),U++;if(H=V.e,K>1)V=new Y("0."+Z),H++;else V=new Y(K+"."+Z.slice(1))}else return j=F$(Y,G+2,w).times(H+""),V=p7(new Y(K+"."+Z.slice(1)),G-O).plus(j),Y.precision=w,J==null?Y0(V,w,X,A0=!0):V;F=V,W=z=V=v0(V.minus(1),V.plus(1),G,1),_=Y0(V.times(V),G,1),Q=3;for(;;){if(z=Y0(z.times(_),G,1),j=W.plus(v0(z,new Y(Q),G,1)),i0(j.d).slice(0,G)===i0(W.d).slice(0,G)){if(W=W.times(2),H!==0)W=W.plus(F$(Y,G+2,w).times(H+""));if(W=v0(W,new Y(U),G,1),J==null)if(S6(W.d,G-O,X,q))Y.precision=G+=O,j=z=V=v0(F.minus(1),F.plus(1),G,1),_=Y0(V.times(V),G,1),Q=q=1;else return Y0(W,Y.precision=w,X,A0=!0);else return Y.precision=w,W}W=j,Q+=2}}function xJ($){return String($.s*$.s/0)}function W$($,J){var Z,K,Q;if((Z=J.indexOf("."))>-1)J=J.replace(".","");if((K=J.search(/e/i))>0){if(Z<0)Z=K;Z+=+J.slice(K+1),J=J.substring(0,K)}else if(Z<0)Z=J.length;for(K=0;J.charCodeAt(K)===48;K++);for(Q=J.length;J.charCodeAt(Q-1)===48;--Q);if(J=J.slice(K,Q),J){if(Q-=K,$.e=Z=Z-K-1,$.d=[],K=(Z+1)%w0,Z<0)K+=w0;if(K<Q){if(K)$.d.push(+J.slice(0,K));for(Q-=w0;K<Q;)$.d.push(+J.slice(K,K+=w0));J=J.slice(K),K=w0-J.length}else K-=Q;for(;K--;)J+="0";if($.d.push(+J),A0){if($.e>$.constructor.maxE)$.d=null,$.e=NaN;else if($.e<$.constructor.minE)$.e=0,$.d=[0]}}else $.e=0,$.d=[0];return $}function jZ($,J){var Z,K,Q,H,z,q,W,j,G;if(J.indexOf("_")>-1){if(J=J.replace(/(\d)_(?=\d)/g,"$1"),hJ.test(J))return W$($,J)}else if(J==="Infinity"||J==="NaN"){if(!+J)$.s=NaN;return $.e=NaN,$.d=null,$}if(QZ.test(J))Z=16,J=J.toLowerCase();else if(ZZ.test(J))Z=2;else if(HZ.test(J))Z=8;else throw Error(c7+J);if(H=J.search(/p/i),H>0)W=+J.slice(H+1),J=J.substring(2,H);else J=J.slice(2);if(H=J.indexOf("."),z=H>=0,K=$.constructor,z)J=J.replace(".",""),q=J.length,H=q-H,Q=uJ(K,new K(Z),H,H*2);j=q$(J,Z,L7),G=j.length-1;for(H=G;j[H]===0;--H)j.pop();if(H<0)return new K($.s*0);if($.e=U$(j,G),$.d=j,A0=!1,z)$=v0($,Q,q*4);if(W)$=$.times(Math.abs(W)<54?p0(2,W):v6.pow(2,W));return A0=!0,$}function GZ($,J){var Z,K=J.d.length;if(K<3)return J.isZero()?J:V6($,2,J,J);Z=1.4*Math.sqrt(K),Z=Z>16?16:Z|0,J=J.times(1/V$(5,Z)),J=V6($,2,J,J);var Q,H=new $(5),z=new $(16),q=new $(20);for(;Z--;)Q=J.times(J),J=J.times(H.plus(Q.times(z.times(Q).minus(q))));return J}function V6($,J,Z,K,Q){var H,z,q,W,j=1,G=$.precision,F=Math.ceil(G/w0);A0=!1,W=Z.times(Z),q=new $(K);for(;;){if(z=v0(q.times(W),new $(J++*J++),G,1),q=Q?K.plus(z):K.minus(z),K=v0(z.times(W),new $(J++*J++),G,1),z=q.plus(K),z.d[F]!==void 0){for(H=F;z.d[H]===q.d[H]&&H--;);if(H==-1)break}H=q,q=K,K=z,z=H,j++}return A0=!0,z.d.length=F+1,z}function V$($,J){var Z=$;while(--J)Z*=$;return Z}function mJ($,J){var Z,K=J.s<0,Q=N7($,$.precision,1),H=Q.times(0.5);if(J=J.abs(),J.lte(H))return S7=K?4:1,J;if(Z=J.divToInt(Q),Z.isZero())S7=K?3:2;else{if(J=J.minus(Z.times(Q)),J.lte(H))return S7=EJ(Z)?K?2:3:K?4:1,J;S7=EJ(Z)?K?1:4:K?3:2}return J.minus(Q).abs()}function _9($,J,Z,K){var Q,H,z,q,W,j,G,F,_,U=$.constructor,O=Z!==void 0;if(O)if(J7(Z,1,l7),K===void 0)K=U.rounding;else J7(K,0,8);else Z=U.precision,K=U.rounding;if(!$.isFinite())G=xJ($);else{if(G=I7($),z=G.indexOf("."),O){if(Q=2,J==16)Z=Z*4-3;else if(J==8)Z=Z*3-2}else Q=J;if(z>=0)G=G.replace(".",""),_=new U(1),_.e=G.length-z,_.d=q$(I7(_),10,Q),_.e=_.d.length;F=q$(G,10,Q),H=W=F.length;for(;F[--W]==0;)F.pop();if(!F[0])G=O?"0p+0":"0";else{if(z<0)H--;else $=new U($),$.d=F,$.e=H,$=v0($,_,Z,K,0,Q),F=$.d,H=$.e,j=fJ;if(z=F[Z],q=Q/2,j=j||F[Z+1]!==void 0,j=K<4?(z!==void 0||j)&&(K===0||K===($.s<0?3:2)):z>q||z===q&&(K===4||j||K===6&&F[Z-1]&1||K===($.s<0?8:7)),F.length=Z,j){for(;++F[--Z]>Q-1;)if(F[Z]=0,!Z)++H,F.unshift(1)}for(W=F.length;!F[W-1];--W);for(z=0,G="";z<W;z++)G+=W9.charAt(F[z]);if(O){if(W>1)if(J==16||J==8){z=J==16?4:3;for(--W;W%z;W++)G+="0";F=q$(G,Q,J);for(W=F.length;!F[W-1];--W);for(z=1,G="1.";z<W;z++)G+=W9.charAt(F[z])}else G=G.charAt(0)+"."+G.slice(1);G=G+(H<0?"p":"p+")+H}else if(H<0){for(;++H;)G="0"+G;G="0."+G}else if(++H>W)for(H-=W;H--;)G+="0";else if(H<W)G=G.slice(0,H)+"."+G.slice(H)}G=(J==16?"0x":J==2?"0b":J==8?"0o":"")+G}return $.s<0?"-"+G:G}function TJ($,J){if($.length>J)return $.length=J,!0}function FZ($){return new this($).abs()}function _Z($){return new this($).acos()}function UZ($){return new this($).acosh()}function VZ($,J){return new this($).plus(J)}function MZ($){return new this($).asin()}function OZ($){return new this($).asinh()}function YZ($){return new this($).atan()}function XZ($){return new this($).atanh()}function kZ($,J){$=new this($),J=new this(J);var Z,K=this.precision,Q=this.rounding,H=K+4;if(!$.s||!J.s)Z=new this(NaN);else if(!$.d&&!J.d)Z=N7(this,H,1).times(J.s>0?0.25:0.75),Z.s=$.s;else if(!J.d||$.isZero())Z=J.s<0?N7(this,K,Q):new this(0),Z.s=$.s;else if(!$.d||J.isZero())Z=N7(this,H,1).times(0.5),Z.s=$.s;else if(J.s<0)this.precision=H,this.rounding=1,Z=this.atan(v0($,J,H,1)),J=N7(this,H,1),this.precision=K,this.rounding=Q,Z=$.s<0?Z.minus(J):Z.plus(J);else Z=this.atan(v0($,J,H,1));return Z}function LZ($){return new this($).cbrt()}function wZ($){return Y0($=new this($),$.e+1,2)}function RZ($,J,Z){return new this($).clamp(J,Z)}function BZ($){if(!$||typeof $!=="object")throw Error(_$+"Object expected");var J,Z,K,Q=$.defaults===!0,H=["precision",1,l7,"rounding",0,8,"toExpNeg",-U6,0,"toExpPos",0,U6,"maxE",0,U6,"minE",-U6,0,"modulo",0,9];for(J=0;J<H.length;J+=3){if(Z=H[J],Q)this[Z]=j9[Z];if((K=$[Z])!==void 0)if(a0(K)===K&&K>=H[J+1]&&K<=H[J+2])this[Z]=K;else throw Error(c7+Z+": "+K)}if(Z="crypto",Q)this[Z]=j9[Z];if((K=$[Z])!==void 0)if(K===!0||K===!1||K===0||K===1)if(K)if(typeof crypto!="undefined"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[Z]=!0;else throw Error(vJ);else this[Z]=!1;else throw Error(c7+Z+": "+K);return this}function NZ($){return new this($).cos()}function IZ($){return new this($).cosh()}function dJ($){var J,Z,K;function Q(H){var z,q,W,j=this;if(!(j instanceof Q))return new Q(H);if(j.constructor=Q,bJ(H)){if(j.s=H.s,A0)if(!H.d||H.e>Q.maxE)j.e=NaN,j.d=null;else if(H.e<Q.minE)j.e=0,j.d=[0];else j.e=H.e,j.d=H.d.slice();else j.e=H.e,j.d=H.d?H.d.slice():H.d;return}if(W=typeof H,W==="number"){if(H===0){j.s=1/H<0?-1:1,j.e=0,j.d=[0];return}if(H<0)H=-H,j.s=-1;else j.s=1;if(H===~~H&&H<1e7){for(z=0,q=H;q>=10;q/=10)z++;if(A0)if(z>Q.maxE)j.e=NaN,j.d=null;else if(z<Q.minE)j.e=0,j.d=[0];else j.e=z,j.d=[H];else j.e=z,j.d=[H];return}if(H*0!==0){if(!H)j.s=NaN;j.e=NaN,j.d=null;return}return W$(j,H.toString())}if(W==="string"){if((q=H.charCodeAt(0))===45)H=H.slice(1),j.s=-1;else{if(q===43)H=H.slice(1);j.s=1}return hJ.test(H)?W$(j,H):jZ(j,H)}if(W==="bigint"){if(H<0)H=-H,j.s=-1;else j.s=1;return W$(j,H.toString())}throw Error(c7+H)}if(Q.prototype=Z0,Q.ROUND_UP=0,Q.ROUND_DOWN=1,Q.ROUND_CEIL=2,Q.ROUND_FLOOR=3,Q.ROUND_HALF_UP=4,Q.ROUND_HALF_DOWN=5,Q.ROUND_HALF_EVEN=6,Q.ROUND_HALF_CEIL=7,Q.ROUND_HALF_FLOOR=8,Q.EUCLID=9,Q.config=Q.set=BZ,Q.clone=dJ,Q.isDecimal=bJ,Q.abs=FZ,Q.acos=_Z,Q.acosh=UZ,Q.add=VZ,Q.asin=MZ,Q.asinh=OZ,Q.atan=YZ,Q.atanh=XZ,Q.atan2=kZ,Q.cbrt=LZ,Q.ceil=wZ,Q.clamp=RZ,Q.cos=NZ,Q.cosh=IZ,Q.div=CZ,Q.exp=PZ,Q.floor=AZ,Q.hypot=EZ,Q.ln=TZ,Q.log=bZ,Q.log10=SZ,Q.log2=fZ,Q.max=vZ,Q.min=DZ,Q.mod=hZ,Q.mul=yZ,Q.pow=uZ,Q.random=gZ,Q.round=xZ,Q.sign=mZ,Q.sin=dZ,Q.sinh=pZ,Q.sqrt=cZ,Q.sub=lZ,Q.sum=nZ,Q.tan=sZ,Q.tanh=oZ,Q.trunc=iZ,$===void 0)$={};if($){if($.defaults!==!0){K=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"];for(J=0;J<K.length;)if(!$.hasOwnProperty(Z=K[J++]))$[Z]=this[Z]}}return Q.config($),Q}function CZ($,J){return new this($).div(J)}function PZ($){return new this($).exp()}function AZ($){return Y0($=new this($),$.e+1,3)}function EZ(){var $,J,Z=new this(0);A0=!1;for($=0;$<arguments.length;)if(J=new this(arguments[$++]),!J.d){if(J.s)return A0=!0,new this(1/0);Z=J}else if(Z.d)Z=Z.plus(J.times(J));return A0=!0,Z.sqrt()}function bJ($){return $ instanceof v6||$&&$.toStringTag===DJ||!1}function TZ($){return new this($).ln()}function bZ($,J){return new this($).log(J)}function fZ($){return new this($).log(2)}function SZ($){return new this($).log(10)}function vZ(){return gJ(this,arguments,-1)}function DZ(){return gJ(this,arguments,1)}function hZ($,J){return new this($).mod(J)}function yZ($,J){return new this($).mul(J)}function uZ($,J){return new this($).pow(J)}function gZ($){var J,Z,K,Q,H=0,z=new this(1),q=[];if($===void 0)$=this.precision;else J7($,1,l7);if(K=Math.ceil($/w0),!this.crypto)for(;H<K;)q[H++]=Math.random()*1e7|0;else if(crypto.getRandomValues){J=crypto.getRandomValues(new Uint32Array(K));for(;H<K;)if(Q=J[H],Q>=4290000000)J[H]=crypto.getRandomValues(new Uint32Array(1))[0];else q[H++]=Q%1e7}else if(crypto.randomBytes){J=crypto.randomBytes(K*=4);for(;H<K;)if(Q=J[H]+(J[H+1]<<8)+(J[H+2]<<16)+((J[H+3]&127)<<24),Q>=2140000000)crypto.randomBytes(4).copy(J,H);else q.push(Q%1e7),H+=4;H=K/4}else throw Error(vJ);if(K=q[--H],$%=w0,K&&$)Q=p0(10,w0-$),q[H]=(K/Q|0)*Q;for(;q[H]===0;H--)q.pop();if(H<0)Z=0,q=[0];else{Z=-1;for(;q[0]===0;Z-=w0)q.shift();for(K=1,Q=q[0];Q>=10;Q/=10)K++;if(K<w0)Z-=w0-K}return z.e=Z,z.d=q,z}function xZ($){return Y0($=new this($),$.e+1,this.rounding)}function mZ($){return $=new this($),$.d?$.d[0]?$.s:0*$.s:$.s||NaN}function dZ($){return new this($).sin()}function pZ($){return new this($).sinh()}function cZ($){return new this($).sqrt()}function lZ($,J){return new this($).sub(J)}function nZ(){var $=0,J=arguments,Z=new this(J[$]);A0=!1;for(;Z.s&&++$<J.length;)Z=Z.plus(J[$]);return A0=!0,Y0(Z,this.precision,this.rounding)}function sZ($){return new this($).tan()}function oZ($){return new this($).tanh()}function iZ($){return Y0($=new this($),$.e+1,1)}Z0[Symbol.for("nodejs.util.inspect.custom")]=Z0.toString;Z0[Symbol.toStringTag]="Decimal";var v6=Z0.constructor=dJ(j9);j$=new v6(j$);G$=new v6(G$);var k=v6;k.set({precision:80});var Mq=new k("1e-40"),Oq=new k("1e-10");var U9=($)=>{if($===null||$===void 0)throw new Error(`Cannot convert ${$===null?"null":"undefined"} to Decimal`);if($ instanceof k)return $;try{return new k($)}catch(J){throw new Error(`Invalid numeric value: ${J.message}`)}};class D0{constructor($){if(!Array.isArray($))throw new Error("Vector requires array");if($.length===0)throw new Error("Vector requires at least one component");try{this.data=$.map((J,Z)=>{if(J===null||J===void 0)throw new Error(`Vector component at index ${Z} is ${J===null?"null":"undefined"}`);return U9(J)})}catch(J){throw new Error(`Vector constructor failed: ${J.message}`)}this.length=this.data.length}static from($){if($===null||$===void 0)throw new Error(`Vector.from: argument is ${$===null?"null":"undefined"}`);return new D0($)}clone(){return new D0(this.data.map(($)=>new k($)))}toArray(){return this.data.slice()}toNumberArray(){return this.data.map(($)=>$.toNumber())}toStringArray(){return this.data.map(($)=>$.toString())}add($){if(!$||!($ instanceof D0))throw new Error("add: argument must be a Vector");if(this.length!==$.length)throw new Error(`add: dimension mismatch (${this.length} vs ${$.length})`);return new D0(this.data.map((J,Z)=>J.plus($.data[Z])))}sub($){if(!$||!($ instanceof D0))throw new Error("sub: argument must be a Vector");if(this.length!==$.length)throw new Error(`sub: dimension mismatch (${this.length} vs ${$.length})`);return new D0(this.data.map((J,Z)=>J.minus($.data[Z])))}scale($){if($===null||$===void 0)throw new Error(`scale: scalar is ${$===null?"null":"undefined"}`);let J;try{J=U9($)}catch(Z){throw new Error(`scale: invalid scalar - ${Z.message}`)}return new D0(this.data.map((Z)=>Z.mul(J)))}negate(){return new D0(this.data.map(($)=>$.negated()))}dot($){if(!$||!($ instanceof D0))throw new Error("dot: argument must be a Vector");if(this.length!==$.length)throw new Error(`dot: dimension mismatch (${this.length} vs ${$.length})`);return this.data.reduce((J,Z,K)=>J.plus(Z.mul($.data[K])),new k(0))}outer($){if(!$||!($ instanceof D0))throw new Error("outer: argument must be a Vector");if(this.length===0||$.length===0)throw new Error("outer: cannot compute outer product with empty vector");let J=this.length,Z=$.length;return Array.from({length:J},(Q,H)=>Array.from({length:Z},(z,q)=>this.data[H].mul($.data[q])))}cross($){if(!$||!($ instanceof D0))throw new Error("cross: argument must be a Vector");if(this.length!==3||$.length!==3)throw new Error(`cross: requires 3D vectors (got ${this.length}D and ${$.length}D)`);let[J,Z,K]=this.data,[Q,H,z]=$.data;return new D0([Z.mul(z).minus(K.mul(H)),K.mul(Q).minus(J.mul(z)),J.mul(H).minus(Z.mul(Q))])}norm(){let $=new k(0);for(let J of this.data)$=$.plus(J.mul(J));return $.sqrt()}normalize(){let $=this.norm();if($.isZero())throw new Error("Cannot normalize zero vector");return this.scale(new k(1).div($))}angleBetween($){if(!$||!($ instanceof D0))throw new Error("angleBetween: argument must be a Vector");if(this.length!==$.length)throw new Error(`angleBetween: dimension mismatch (${this.length} vs ${$.length})`);let J=this.dot($),Z=this.norm(),K=$.norm();if(Z.isZero()||K.isZero())throw new Error("angleBetween: angle with zero vector is undefined");let H=J.div(Z.mul(K)).toNumber(),z=Math.min(1,Math.max(-1,H));return new k(Math.acos(z))}projectOnto($){if(!$||!($ instanceof D0))throw new Error("projectOnto: argument must be a Vector");if(this.length!==$.length)throw new Error(`projectOnto: dimension mismatch (${this.length} vs ${$.length})`);let J=$.dot($);if(J.isZero())throw new Error("projectOnto: cannot project onto zero vector");let Z=this.dot($).div(J);return $.scale(Z)}orthogonal(){if(this.norm().isZero())throw new Error("orthogonal: cannot find orthogonal vector to zero vector");if(this.length===2)return new D0([this.data[1].negated(),this.data[0]]);for(let J=0;J<this.length;J++){let Z=Array.from({length:this.length},(q,W)=>new k(W===J?1:0)),K=new D0(Z),Q=K.projectOnto(this),H=K.sub(Q);if(!H.norm().isZero())return H.normalize()}throw new Error("orthogonal: unable to find orthogonal vector (degenerate case)")}isOrthogonalTo($){if(!$||!($ instanceof D0))throw new Error("isOrthogonalTo: argument must be a Vector");if(this.length!==$.length)throw new Error(`isOrthogonalTo: dimension mismatch (${this.length} vs ${$.length})`);return this.dot($).isZero()}distance($){if(!$||!($ instanceof D0))throw new Error("distance: argument must be a Vector");if(this.length!==$.length)throw new Error(`distance: dimension mismatch (${this.length} vs ${$.length})`);return this.sub($).norm()}equals($,J=0){if(!($ instanceof D0))return!1;if($.length!==this.length)return!1;if(J===null)throw new Error("equals: tolerance cannot be null");let Z;try{if(Z=U9(J),Z.isNaN())throw new Error("equals: tolerance cannot be NaN");if(Z.isNegative())throw new Error("equals: tolerance must be non-negative")}catch(K){throw new Error(`equals: invalid tolerance - ${K.message}`)}for(let K=0;K<this.length;K++)if(this.data[K].minus($.data[K]).abs().greaterThan(Z))return!1;return!0}}var M6=($)=>{if($==null)throw new Error("Cannot convert null or undefined to Decimal");return $ instanceof k?$:new k($)};class M0{constructor($){if(!Array.isArray($)||$.length===0)throw new Error("Matrix requires non-empty 2D array");if(!Array.isArray($[0])||$[0].length===0)throw new Error("Matrix rows must be non-empty arrays");let J=$[0].length;for(let Z of $)if(!Array.isArray(Z)||Z.length!==J)throw new Error("All rows must have same length");this.data=$.map((Z)=>Z.map((K)=>M6(K))),this.rows=$.length,this.cols=J}static from($){return new M0($)}static zeros($,J){if(!Number.isInteger($)||$<=0)throw new Error("rows must be a positive integer");if(!Number.isInteger(J)||J<=0)throw new Error("cols must be a positive integer");let Z=Array.from({length:$},()=>Array.from({length:J},()=>new k(0)));return new M0(Z)}static identity($){if(!Number.isInteger($)||$<=0)throw new Error("size must be a positive integer");let J=Array.from({length:$},(Z,K)=>Array.from({length:$},(Q,H)=>K===H?new k(1):new k(0)));return new M0(J)}clone(){return new M0(this.data.map(($)=>$.map((J)=>new k(J))))}toArrayOfStrings(){return this.data.map(($)=>$.map((J)=>J.toString()))}toNumberArray(){return this.data.map(($)=>$.map((J)=>J.toNumber()))}isSquare(){return this.rows===this.cols}applyToVector($){let J;if($ instanceof D0)J=$;else if(Array.isArray($))J=D0.from($);else throw new Error("applyToVector expects Vector or array");if(this.cols!==J.length)throw new Error("shape mismatch: matrix cols must equal vector length");let Z=[];for(let K=0;K<this.rows;K++){let Q=new k(0);for(let H=0;H<this.cols;H++)Q=Q.plus(this.data[K][H].mul(J.data[H]));Z.push(Q)}return new D0(Z)}add($){if($ instanceof M0){if(this.rows!==$.rows||this.cols!==$.cols)throw new Error("shape mismatch: matrices must have same dimensions");return new M0(this.data.map((J,Z)=>J.map((K,Q)=>K.plus($.data[Z][Q]))))}else{let J=M6($);return new M0(this.data.map((Z)=>Z.map((K)=>K.plus(J))))}}sub($){if($ instanceof M0){if(this.rows!==$.rows||this.cols!==$.cols)throw new Error("shape mismatch: matrices must have same dimensions");return new M0(this.data.map((J,Z)=>J.map((K,Q)=>K.minus($.data[Z][Q]))))}else{let J=M6($);return new M0(this.data.map((Z)=>Z.map((K)=>K.minus(J))))}}mul($){if($ instanceof M0){if(this.cols!==$.rows)throw new Error("shape mismatch: A.cols must equal B.rows for matrix multiplication");let J=Array.from({length:this.rows},()=>Array.from({length:$.cols},()=>new k(0)));for(let Z=0;Z<this.rows;Z++)for(let K=0;K<this.cols;K++){let Q=this.data[Z][K];if(Q.isZero())continue;for(let H=0;H<$.cols;H++)J[Z][H]=J[Z][H].plus(Q.mul($.data[K][H]))}return new M0(J)}else{let J=M6($);return new M0(this.data.map((Z)=>Z.map((K)=>K.mul(J))))}}div($){let J=M6($);if(J.isZero())throw new Error("Cannot divide by zero");return new M0(this.data.map((Z)=>Z.map((K)=>K.div(J))))}negate(){return new M0(this.data.map(($)=>$.map((J)=>J.negated())))}transpose(){let $=Array.from({length:this.cols},(J,Z)=>Array.from({length:this.rows},(K,Q)=>new k(this.data[Q][Z])));return new M0($)}trace(){if(!this.isSquare())throw new Error("Trace only defined for square matrices");let $=new k(0);for(let J=0;J<this.rows;J++)$=$.plus(this.data[J][J]);return $}equals($,J=0){if(!($ instanceof M0))return!1;if(this.rows!==$.rows||this.cols!==$.cols)return!1;let Z=M6(J);if(Z.isNegative()||!Z.isFinite())throw new Error("tolerance must be non-negative and finite");for(let K=0;K<this.rows;K++)for(let Q=0;Q<this.cols;Q++)if(this.data[K][Q].minus($.data[K][Q]).abs().greaterThan(Z))return!1;return!0}lu(){if(!this.isSquare())throw new Error("LU decomposition requires square matrix");let $=this.rows,J=this.data.map((z)=>z.map((q)=>new k(q))),Z=Array.from({length:$},(z,q)=>q),K=Array.from({length:$},()=>Array.from({length:$},()=>new k(0)));for(let z=0;z<$;z++)K[z][z]=new k(1);for(let z=0;z<$;z++){let q=z,W=J[z][z].abs();for(let j=z+1;j<$;j++){let G=J[j][z].abs();if(G.greaterThan(W))W=G,q=j}if(J[q][z].isZero())throw new Error("Singular matrix: LU decomposition failed");if(q!==z){let j=J[z];J[z]=J[q],J[q]=j;let G=Z[z];Z[z]=Z[q],Z[q]=G;for(let F=0;F<z;F++){let _=K[z][F];K[z][F]=K[q][F],K[q][F]=_}}for(let j=z+1;j<$;j++){let G=J[j][z].div(J[z][z]);K[j][z]=G;for(let F=z;F<$;F++)J[j][F]=J[j][F].minus(G.mul(J[z][F]))}}let Q=Array.from({length:$},(z,q)=>Array.from({length:$},(W,j)=>j<q?new k(0):J[q][j])),H=M0.zeros($,$);for(let z=0;z<$;z++)H.data[z][Z[z]]=new k(1);return{L:new M0(K),U:new M0(Q),P:H}}determinant(){if(!this.isSquare())throw new Error("Determinant only defined for square matrices");let $=this.rows,{L:J,U:Z,P:K}=this.lu(),Q=new k(1);for(let q=0;q<$;q++)Q=Q.mul(Z.data[q][q]);let H=[];for(let q=0;q<$;q++)for(let W=0;W<$;W++)if(K.data[q][W].equals(1))H.push(W);let z=0;for(let q=0;q<H.length;q++)for(let W=q+1;W<H.length;W++)if(H[q]>H[W])z++;if(z%2===1)Q=Q.negated();return Q}inverse(){if(!this.isSquare())throw new Error("Inverse only defined for square matrices");let $=this.rows,J=Array.from({length:$},(K,Q)=>Array.from({length:2*$},(H,z)=>z<$?new k(this.data[Q][z]):z-$===Q?new k(1):new k(0)));for(let K=0;K<$;K++){let Q=K,H=J[K][K].abs();for(let q=K+1;q<$;q++){let W=J[q][K].abs();if(W.greaterThan(H))H=W,Q=q}if(J[Q][K].isZero())throw new Error("Singular matrix: inverse does not exist");if(Q!==K){let q=J[K];J[K]=J[Q],J[Q]=q}let z=J[K][K];for(let q=0;q<2*$;q++)J[K][q]=J[K][q].div(z);for(let q=0;q<$;q++){if(q===K)continue;let W=J[q][K];if(W.isZero())continue;for(let j=0;j<2*$;j++)J[q][j]=J[q][j].minus(W.mul(J[K][j]))}}let Z=J.map((K)=>K.slice($));return new M0(Z)}solve($){let J;if($ instanceof D0)J=$;else if(Array.isArray($))J=D0.from($);else throw new Error("b must be Vector or array");if(!this.isSquare())throw new Error("solve() only implemented for square matrices");let Z=this.rows;if(J.length!==Z)throw new Error("dimension mismatch: b length must equal matrix rows");let K=Array.from({length:Z},(H,z)=>Array.from({length:Z+1},(q,W)=>new k(W<Z?this.data[z][W]:J.data[z])));for(let H=0;H<Z;H++){let z=H,q=K[H][H].abs();for(let W=H+1;W<Z;W++){let j=K[W][H].abs();if(j.greaterThan(q))q=j,z=W}if(K[z][H].isZero())throw new Error("Singular matrix: no unique solution");if(z!==H){let W=K[H];K[H]=K[z],K[z]=W}for(let W=H+1;W<Z;W++){let j=K[W][H].div(K[H][H]);if(j.isZero())continue;for(let G=H;G<Z+1;G++)K[W][G]=K[W][G].minus(j.mul(K[H][G]))}}let Q=Array.from({length:Z},()=>new k(0));for(let H=Z-1;H>=0;H--){if(K[H][H].isZero())throw new Error("Zero diagonal element in back substitution: system is singular");let z=new k(0);for(let q=H+1;q<Z;q++)z=z.plus(K[H][q].mul(Q[q]));Q[H]=K[H][Z].minus(z).div(K[H][H])}return new D0(Q)}qr(){let $=this.rows,J=this.cols,Z=this.data.map((H)=>H.map((z)=>new k(z))),K=M0.identity($).data;for(let H=0;H<Math.min($,J);H++){let z=[];for(let F=H;F<$;F++)z.push(Z[F][H]);let q=new k(0);for(let F of z)q=q.plus(F.mul(F));if(q=q.sqrt(),q.isZero())continue;let W=z[0].isNegative()?new k(-1):new k(1),j=z.slice();j[0]=j[0].plus(W.mul(q));let G=new k(0);for(let F of j)G=G.plus(F.mul(F));if(G=G.sqrt(),G.isZero())continue;for(let F=0;F<j.length;F++)j[F]=j[F].div(G);for(let F=H;F<J;F++){let _=new k(0);for(let U=0;U<j.length;U++)_=_.plus(j[U].mul(Z[H+U][F]));for(let U=0;U<j.length;U++)Z[H+U][F]=Z[H+U][F].minus(new k(2).mul(j[U]).mul(_))}for(let F=0;F<$;F++){let _=new k(0);for(let U=0;U<j.length;U++)_=_.plus(j[U].mul(K[H+U][F]));for(let U=0;U<j.length;U++)K[H+U][F]=K[H+U][F].minus(new k(2).mul(j[U]).mul(_))}}let Q=Array.from({length:$},(H,z)=>Array.from({length:J},(q,W)=>z<=W?Z[z][W]:new k(0)));return{Q:new M0(K).transpose(),R:new M0(Q)}}exp($={}){let J=this.rows;if(!this.isSquare())throw new Error("Matrix exponential requires square matrix");let Z=M0.identity(J),K=$.maxIter||120;if(!Number.isInteger(K)||K<=0)throw new Error("maxIter must be a positive integer");let Q=new k($.tolerance||"1e-40");if(Q.isNegative()||Q.isZero()||!Q.isFinite())throw new Error("tolerance must be positive and finite");let z=((F)=>{let _=new k(0);for(let U=0;U<F.rows;U++){let O=new k(0);for(let V=0;V<F.cols;V++)O=O.plus(F.data[U][V].abs());if(O.greaterThan(_))_=O}return _})(this),q=0;if(z.greaterThan(new k(1))){let F=z.toNumber();if(!isFinite(F))throw new Error("Matrix norm too large for exponential computation");if(q=Math.max(0,Math.ceil(Math.log2(F))),q>50)throw new Error(`Matrix norm too large: requires ${q} scaling steps (max 50 allowed)`)}let W=this;if(q>0)W=this.mul(new k(1).div(new k(2).pow(q)));let j=Z.clone(),G=Z.clone();for(let F=1;F<K;F++){j=j.mul(W).mul(new k(1).div(F)),G=G.add(j);let _=new k(0);for(let U=0;U<j.rows;U++)for(let O=0;O<j.cols;O++)_=_.plus(j.data[U][O].abs());if(_.lessThan(Q))break}for(let F=0;F<q;F++)G=G.mul(G);return G}}k.set({precision:80});var y0=($)=>$ instanceof k?$:new k($),aZ=new k("1e-40"),tZ=new k("1e-30");function eZ($,J){if($==null)throw new TypeError("translationMatrix: tx parameter is required");if(J==null)throw new TypeError("translationMatrix: ty parameter is required");return M0.from([[1,0,y0($)],[0,1,y0(J)],[0,0,1]])}function $Q($){if($==null)throw new TypeError("rotationMatrix: angle parameter is required");let J=y0($),Z=k.cos(J),K=k.sin(J);return M0.from([[Z,K.neg(),0],[K,Z,0],[0,0,1]])}function JQ($,J){if($==null)throw new TypeError("scaleMatrix: sx parameter is required");if(J==null)throw new TypeError("scaleMatrix: sy parameter is required");return M0.from([[y0($),0,0],[0,y0(J),0],[0,0,1]])}function KQ($){if($==null)throw new TypeError("skewXMatrix: angle parameter is required");let J=k.tan(y0($));return M0.from([[1,J,0],[0,1,0],[0,0,1]])}function ZQ($){if($==null)throw new TypeError("skewYMatrix: angle parameter is required");let J=k.tan(y0($));return M0.from([[1,0,0],[J,1,0],[0,0,1]])}function QQ($){if(!$)throw new TypeError("extractLinearPart: matrix parameter is required");if(!$.data)throw new TypeError("extractLinearPart: matrix must have data property");if($.rows<2||$.cols<2)throw new RangeError("extractLinearPart: matrix must be at least 2x2");let J=$.data;return{a:J[0][0],b:J[1][0],c:J[0][1],d:J[1][1]}}function HQ($){if(!$)throw new TypeError("extractTranslation: matrix parameter is required");if(!$.data)throw new TypeError("extractTranslation: matrix must have data property");if($.rows<2||$.cols<3)throw new RangeError("extractTranslation: matrix must be at least 2x3");let J=$.data;return{tx:J[0][2],ty:J[1][2]}}function pJ($){if(!$)throw new TypeError("decomposeMatrix: matrix parameter is required");let{a:J,b:Z,c:K,d:Q}=QQ($),{tx:H,ty:z}=HQ($),q=J.mul(Q).minus(Z.mul(K)),W=J.mul(J).plus(Z.mul(Z)).sqrt();if(W.abs().lessThan(aZ))return{translateX:H,translateY:z,rotation:y0(0),scaleX:y0(0),scaleY:y0(0),skewX:y0(0),skewY:y0(0),verified:!1,maxError:y0("Infinity"),singular:!0};let j=q.div(W);if(j.abs().greaterThan(new k("1e40")))return{translateX:H,translateY:z,rotation:y0(0),scaleX:y0(0),scaleY:y0(0),skewX:y0(0),skewY:y0(0),verified:!1,maxError:y0("Infinity"),singular:!0};if(q.lessThan(0))W=W.neg(),j=j.neg();let G;if(W.lessThan(0))G=k.atan2(Z.neg(),J.neg());else G=k.atan2(Z,J);let F=k.cos(G),_=k.sin(G),U=J.mul(F).plus(Z.mul(_)),O=K.mul(F).plus(Q.mul(_)),V,M=new k("1e-30");if(U.abs().greaterThan(M)){let I=O.div(U);if(I.abs().greaterThan(new k("1e10")))V=y0(0);else V=k.atan(I)}else V=y0(0);let Y=y0(0),X=zQ({translateX:H,translateY:z,rotation:G,scaleX:W,scaleY:j,skewX:V,skewY:y0(0)}),w=qQ($,X),R=w.lessThan(tZ);return{translateX:H,translateY:z,rotation:G,scaleX:W,scaleY:j,skewX:V,skewY:Y,verified:R,maxError:w}}function zQ($){if(!$)throw new TypeError("composeTransform: components parameter is required");if($.translateX==null)throw new TypeError("composeTransform: components.translateX is required");if($.translateY==null)throw new TypeError("composeTransform: components.translateY is required");if($.rotation==null)throw new TypeError("composeTransform: components.rotation is required");if($.scaleX==null)throw new TypeError("composeTransform: components.scaleX is required");if($.scaleY==null)throw new TypeError("composeTransform: components.scaleY is required");if($.skewX==null)throw new TypeError("composeTransform: components.skewX is required");let{translateX:J,translateY:Z,rotation:K,scaleX:Q,scaleY:H,skewX:z,skewY:q=0}=$,W=eZ(J,Z),j=$Q(K),G=KQ(z),F=ZQ(q),_=JQ(Q,H);return W.mul(j).mul(F).mul(G).mul(_)}function qQ($,J){if(!$)throw new TypeError("matrixMaxDifference: m1 parameter is required");if(!J)throw new TypeError("matrixMaxDifference: m2 parameter is required");if(!$.data)throw new TypeError("matrixMaxDifference: m1 must have data property");if(!J.data)throw new TypeError("matrixMaxDifference: m2 must have data property");if($.rows!==J.rows||$.cols!==J.cols)throw new RangeError(`matrixMaxDifference: matrices must have same dimensions (${$.rows}x${$.cols} vs ${J.rows}x${J.cols})`);let Z=y0(0);for(let K=0;K<$.rows;K++)for(let Q=0;Q<$.cols;Q++){let H=$.data[K][Q].minus(J.data[K][Q]).abs();if(H.greaterThan(Z))Z=H}return Z}k.set({precision:80});var F7=($)=>$ instanceof k?$:new k($),g0=new k("1e-40"),cJ=100;function C7($,J){if($==null)throw new TypeError("point: x coordinate cannot be null or undefined");if(J==null)throw new TypeError("point: y coordinate cannot be null or undefined");return{x:F7($),y:F7(J)}}function jQ($,J){if(!$||$.x==null||$.y==null)throw new TypeError("vectorAdd: first vector must have x and y properties");if(!J||J.x==null||J.y==null)throw new TypeError("vectorAdd: second vector must have x and y properties");return{x:$.x.plus(J.x),y:$.y.plus(J.y)}}function x0($,J){if(!$||$.x==null||$.y==null)throw new TypeError("vectorSub: first vector must have x and y properties");if(!J||J.x==null||J.y==null)throw new TypeError("vectorSub: second vector must have x and y properties");return{x:$.x.minus(J.x),y:$.y.minus(J.y)}}function h6($){if(!$||$.x==null||$.y==null)throw new TypeError("vectorNeg: vector must have x and y properties");return{x:$.x.neg(),y:$.y.neg()}}function M9($,J){if(!$||$.x==null||$.y==null)throw new TypeError("vectorScale: vector must have x and y properties");if(J==null)throw new TypeError("vectorScale: scale factor cannot be null or undefined");let Z=F7(J);return{x:$.x.mul(Z),y:$.y.mul(Z)}}function K7($,J){if(!$||$.x==null||$.y==null)throw new TypeError("dot: first vector must have x and y properties");if(!J||J.x==null||J.y==null)throw new TypeError("dot: second vector must have x and y properties");return $.x.mul(J.x).plus($.y.mul(J.y))}function D6($,J){if(!$||$.x==null||$.y==null)throw new TypeError("cross: first vector must have x and y properties");if(!J||J.x==null||J.y==null)throw new TypeError("cross: second vector must have x and y properties");return $.x.mul(J.y).minus($.y.mul(J.x))}function G7($){if(!$||$.x==null||$.y==null)throw new TypeError("magnitudeSquared: vector must have x and y properties");return $.x.mul($.x).plus($.y.mul($.y))}function Z6($){if(!$||$.x==null||$.y==null)throw new TypeError("magnitude: vector must have x and y properties");return G7($).sqrt()}function GQ($){if(!$||$.x==null||$.y==null)throw new TypeError("normalize: vector must have x and y properties");let J=Z6($);if(J.lessThan(g0))return{x:F7(0),y:F7(0)};return{x:$.x.div(J),y:$.y.div(J)}}function n7($,J,Z){if(!$||$.x==null||$.y==null)throw new TypeError("tripleProduct: first vector must have x and y properties");if(!J||J.x==null||J.y==null)throw new TypeError("tripleProduct: second vector must have x and y properties");if(!Z||Z.x==null||Z.y==null)throw new TypeError("tripleProduct: third vector must have x and y properties");let K=K7($,Z),Q=K7(J,Z);return x0(M9(J,K),M9($,Q))}function lJ($,J){if(!Array.isArray($))throw new TypeError("supportPoint: polygon must be an array");if(!J||J.x==null||J.y==null)throw new TypeError("supportPoint: direction must have x and y properties");if($.length===0)throw new TypeError("supportPoint: polygon cannot be empty");if(!$[0]||$[0].x==null||$[0].y==null)throw new TypeError("supportPoint: polygon[0] must have x and y properties");let Z=K7($[0],J),K=$[0];for(let Q=1;Q<$.length;Q++){if(!$[Q]||$[Q].x==null||$[Q].y==null)throw new TypeError(`supportPoint: polygon[${Q}] must have x and y properties`);let H=K7($[Q],J);if(H.greaterThan(Z))Z=H,K=$[Q]}return K}function nJ($,J,Z){if(!Array.isArray($))throw new TypeError("minkowskiSupport: polygonA must be an array");if(!Array.isArray(J))throw new TypeError("minkowskiSupport: polygonB must be an array");if(!Z||Z.x==null||Z.y==null)throw new TypeError("minkowskiSupport: direction must have x and y properties");let K=lJ($,Z),Q=lJ(J,h6(Z));return x0(K,Q)}function FQ($,J){if(!Array.isArray($))throw new TypeError("processLineSimplex: simplex must be an array");if($.length!==2)throw new TypeError("processLineSimplex: simplex must have exactly 2 points");if(!J||J.x==null||J.y==null)throw new TypeError("processLineSimplex: direction must have x and y properties");if(!$[0]||$[0].x==null||$[0].y==null)throw new TypeError("processLineSimplex: simplex[0] must have x and y properties");if(!$[1]||$[1].x==null||$[1].y==null)throw new TypeError("processLineSimplex: simplex[1] must have x and y properties");let Z=$[0],K=$[1],Q=x0(K,Z),H=h6(Z),z=G7(Q);if(z.lessThan(g0)){if(G7(Z).lessThan(g0))return{contains:!0,newDirection:J};return{contains:!1,newDirection:H}}let q=n7(Q,H,Q);if(G7(q).lessThan(g0)){let W=K7(Q,H);if(W.greaterThanOrEqualTo(0)&&W.lessThanOrEqualTo(z))return{contains:!0,newDirection:J};return{contains:!1,newDirection:H}}return{contains:!1,newDirection:q}}function _Q($,J){if(!Array.isArray($))throw new TypeError("processTriangleSimplex: simplex must be an array");if($.length!==3)throw new TypeError("processTriangleSimplex: simplex must have exactly 3 points");if(!J||J.x==null||J.y==null)throw new TypeError("processTriangleSimplex: direction must have x and y properties");if(!$[0]||$[0].x==null||$[0].y==null)throw new TypeError("processTriangleSimplex: simplex[0] must have x and y properties");if(!$[1]||$[1].x==null||$[1].y==null)throw new TypeError("processTriangleSimplex: simplex[1] must have x and y properties");if(!$[2]||$[2].x==null||$[2].y==null)throw new TypeError("processTriangleSimplex: simplex[2] must have x and y properties");let Z=$[0],K=$[1],Q=$[2],H=x0(K,Z),z=x0(Q,Z),q=h6(Z),W=G7(H),j=G7(z);if(W.lessThan(g0))return{contains:!1,newDirection:n7(z,q,z),newSimplex:[Z,Q]};if(j.lessThan(g0))return{contains:!1,newDirection:n7(H,q,H),newSimplex:[Z,K]};let G=n7(z,H,H),F=n7(H,z,z);if(G7(G).lessThan(g0)&&G7(F).lessThan(g0)){let _=x0(Q,K),U=G7(_);if(U.greaterThan(W)&&U.greaterThan(j))return{contains:!1,newDirection:n7(_,h6(K),_),newSimplex:[K,Q]};else if(W.greaterThan(j))return{contains:!1,newDirection:n7(H,q,H),newSimplex:[Z,K]};else return{contains:!1,newDirection:n7(z,q,z),newSimplex:[Z,Q]}}if(K7(G,q).greaterThan(g0))return{contains:!1,newDirection:G,newSimplex:[Z,K]};if(K7(F,q).greaterThan(g0))return{contains:!1,newDirection:F,newSimplex:[Z,Q]};return{contains:!0,newDirection:J,newSimplex:$}}function iJ($,J){if(!Array.isArray($))throw new TypeError("gjkIntersects: polygonA must be an array");if(!Array.isArray(J))throw new TypeError("gjkIntersects: polygonB must be an array");if($.length===0||J.length===0)return{intersects:!1,iterations:0,simplex:[],verified:!0};if($.length===1&&J.length===1){if(!$[0]||$[0].x==null||$[0].y==null)throw new TypeError("gjkIntersects: polygonA[0] must have x and y properties");if(!J[0]||J[0].x==null||J[0].y==null)throw new TypeError("gjkIntersects: polygonB[0] must have x and y properties");return{intersects:Z6(x0($[0],J[0])).lessThan(g0),iterations:1,simplex:[],verified:!0}}let Z=x0(M$(J),M$($));if(G7(Z).lessThan(g0))Z=C7(1,0);let K=[nJ($,J,Z)];if(Z=h6(K[0]),G7(K[0]).lessThan(g0))return{intersects:!0,iterations:1,simplex:K,verified:V9($,J)};for(let Q=0;Q<cJ;Q++){let H=nJ($,J,Z);if(K7(H,Z).lessThanOrEqualTo(F7(0)))return{intersects:!1,iterations:Q+1,simplex:K,verified:!0};if(K.unshift(H),K.length===2){let z=FQ(K,Z);if(z.contains)return{intersects:!0,iterations:Q+1,simplex:K,verified:V9($,J)};Z=z.newDirection}else if(K.length===3){let z=_Q(K,Z);if(z.contains)return{intersects:!0,iterations:Q+1,simplex:z.newSimplex,verified:V9($,J)};K=z.newSimplex,Z=z.newDirection}if(G7(Z).lessThan(g0))return{intersects:!1,iterations:Q+1,simplex:K,verified:!1};Z=GQ(Z)}return{intersects:!1,iterations:cJ,simplex:K,verified:!1}}function M$($){if(!Array.isArray($))throw new TypeError("centroid: polygon must be an array");if($.length===0)throw new TypeError("centroid: polygon cannot be empty");let J=F7(0),Z=F7(0);for(let Q=0;Q<$.length;Q++){if(!$[Q]||$[Q].x==null||$[Q].y==null)throw new TypeError(`centroid: polygon[${Q}] must have x and y properties`);J=J.plus($[Q].x),Z=Z.plus($[Q].y)}let K=F7($.length);return{x:J.div(K),y:Z.div(K)}}function sJ($,J){if(!$||$.x==null||$.y==null)throw new TypeError("pointInConvexPolygon: point must have x and y properties");if(!Array.isArray(J))throw new TypeError("pointInConvexPolygon: polygon must be an array");if(J.length<3)return!1;let Z=null;for(let K=0;K<J.length;K++){let Q=J[K],H=J[(K+1)%J.length];if(!Q||Q.x==null||Q.y==null)throw new TypeError(`pointInConvexPolygon: polygon[${K}] must have x and y properties`);if(!H||H.x==null||H.y==null)throw new TypeError(`pointInConvexPolygon: polygon[${(K+1)%J.length}] must have x and y properties`);let z=x0(H,Q),q=x0($,Q),W=D6(z,q);if(W.abs().lessThan(g0))continue;let j=W.greaterThan(0);if(Z===null)Z=j;else if(Z!==j)return!1}return!0}function V9($,J){if(!Array.isArray($))throw new TypeError("verifyIntersection: polygonA must be an array");if(!Array.isArray(J))throw new TypeError("verifyIntersection: polygonB must be an array");for(let Z=0;Z<$.length;Z++){if(!$[Z]||$[Z].x==null||$[Z].y==null)throw new TypeError(`verifyIntersection: polygonA[${Z}] must have x and y properties`);if(sJ($[Z],J))return!0}for(let Z=0;Z<J.length;Z++){if(!J[Z]||J[Z].x==null||J[Z].y==null)throw new TypeError(`verifyIntersection: polygonB[${Z}] must have x and y properties`);if(sJ(J[Z],$))return!0}for(let Z=0;Z<$.length;Z++){let K=$[Z],Q=$[(Z+1)%$.length];if(!K||K.x==null||K.y==null)throw new TypeError(`verifyIntersection: polygonA[${Z}] must have x and y properties`);if(!Q||Q.x==null||Q.y==null)throw new TypeError(`verifyIntersection: polygonA[${(Z+1)%$.length}] must have x and y properties`);for(let H=0;H<J.length;H++){let z=J[H],q=J[(H+1)%J.length];if(!z||z.x==null||z.y==null)throw new TypeError(`verifyIntersection: polygonB[${H}] must have x and y properties`);if(!q||q.x==null||q.y==null)throw new TypeError(`verifyIntersection: polygonB[${(H+1)%J.length}] must have x and y properties`);if(UQ(K,Q,z,q))return!0}}return!1}function UQ($,J,Z,K){if(!$||$.x==null||$.y==null)throw new TypeError("segmentsIntersect: a1 must have x and y properties");if(!J||J.x==null||J.y==null)throw new TypeError("segmentsIntersect: a2 must have x and y properties");if(!Z||Z.x==null||Z.y==null)throw new TypeError("segmentsIntersect: b1 must have x and y properties");if(!K||K.x==null||K.y==null)throw new TypeError("segmentsIntersect: b2 must have x and y properties");let Q=x0(J,$),H=x0(K,Z),z=D6(Q,H);if(z.abs().lessThan(g0)){let G=x0(Z,$);if(D6(Q,G).abs().lessThan(g0)){let F=K7(Q,Q);if(F.lessThan(g0)){let Y=K7(H,H);if(Y.lessThan(g0))return Z6(G).lessThan(g0);let X=K7(G,H).div(Y);return X.greaterThanOrEqualTo(0)&&X.lessThanOrEqualTo(1)}let _=K7(G,Q).div(F),U=x0(K,$),O=K7(U,Q).div(F),V=k.min(_,O);return k.max(_,O).greaterThanOrEqualTo(0)&&V.lessThanOrEqualTo(1)}return!1}let q=x0(Z,$),W=D6(q,H).div(z),j=D6(q,Q).div(z);return W.greaterThanOrEqualTo(0)&&W.lessThanOrEqualTo(1)&&j.greaterThanOrEqualTo(0)&&j.lessThanOrEqualTo(1)}function VQ($,J){if(!Array.isArray($))throw new TypeError("gjkDistance: polygonA must be an array");if(!Array.isArray(J))throw new TypeError("gjkDistance: polygonB must be an array");if($.length===0)throw new TypeError("gjkDistance: polygonA cannot be empty");if(J.length===0)throw new TypeError("gjkDistance: polygonB cannot be empty");if(iJ($,J).intersects)return{distance:F7(0),closestA:M$($),closestB:M$(J),verified:!0};if(!$[0]||$[0].x==null||$[0].y==null)throw new TypeError("gjkDistance: polygonA[0] must have x and y properties");if(!J[0]||J[0].x==null||J[0].y==null)throw new TypeError("gjkDistance: polygonB[0] must have x and y properties");let K=F7(1/0),Q=$[0],H=J[0];for(let W=0;W<$.length;W++){if(!$[W]||$[W].x==null||$[W].y==null)throw new TypeError(`gjkDistance: polygonA[${W}] must have x and y properties`);for(let j=0;j<J.length;j++){if(!J[j]||J[j].x==null||J[j].y==null)throw new TypeError(`gjkDistance: polygonB[${j}] must have x and y properties`);let G=Z6(x0($[W],J[j]));if(G.lessThan(K))K=G,Q=$[W],H=J[j]}}for(let W=0;W<$.length;W++){if(!$[W]||$[W].x==null||$[W].y==null)throw new TypeError(`gjkDistance: polygonA[${W}] must have x and y properties`);for(let j=0;j<J.length;j++){let G=J[j],F=J[(j+1)%J.length];if(!G||G.x==null||G.y==null)throw new TypeError(`gjkDistance: polygonB[${j}] must have x and y properties`);if(!F||F.x==null||F.y==null)throw new TypeError(`gjkDistance: polygonB[${(j+1)%J.length}] must have x and y properties`);let _=oJ($[W],G,F),U=Z6(x0($[W],_));if(U.lessThan(K))K=U,Q=$[W],H=_}}for(let W=0;W<J.length;W++){if(!J[W]||J[W].x==null||J[W].y==null)throw new TypeError(`gjkDistance: polygonB[${W}] must have x and y properties`);for(let j=0;j<$.length;j++){let G=$[j],F=$[(j+1)%$.length];if(!G||G.x==null||G.y==null)throw new TypeError(`gjkDistance: polygonA[${j}] must have x and y properties`);if(!F||F.x==null||F.y==null)throw new TypeError(`gjkDistance: polygonA[${(j+1)%$.length}] must have x and y properties`);let _=oJ(J[W],G,F),U=Z6(x0(J[W],_));if(U.lessThan(K))K=U,Q=_,H=J[W]}}let q=Z6(x0(Q,H)).minus(K).abs().lessThan(g0);return{distance:K,closestA:Q,closestB:H,verified:q}}function oJ($,J,Z){if(!$||$.x==null||$.y==null)throw new TypeError("closestPointOnSegment: pt must have x and y properties");if(!J||J.x==null||J.y==null)throw new TypeError("closestPointOnSegment: a must have x and y properties");if(!Z||Z.x==null||Z.y==null)throw new TypeError("closestPointOnSegment: b must have x and y properties");let K=x0(Z,J),Q=x0($,J),H=G7(K);if(H.lessThan(g0))return J;let z=K7(Q,K).div(H);return z=k.max(F7(0),k.min(F7(1),z)),jQ(J,M9(K,z))}function O$($,J){if(!Array.isArray($))throw new TypeError("polygonsOverlap: polygonA must be an array");if(!Array.isArray(J))throw new TypeError("polygonsOverlap: polygonB must be an array");let Z=$.map((H,z)=>{if(!H||H.x==null||H.y==null)throw new TypeError(`polygonsOverlap: polygonA[${z}] must have x and y properties`);return C7(H.x,H.y)}),K=J.map((H,z)=>{if(!H||H.x==null||H.y==null)throw new TypeError(`polygonsOverlap: polygonB[${z}] must have x and y properties`);return C7(H.x,H.y)}),Q=iJ(Z,K);return{overlaps:Q.intersects,verified:Q.verified}}function rJ($,J){if(!Array.isArray($))throw new TypeError("polygonsDistance: polygonA must be an array");if(!Array.isArray(J))throw new TypeError("polygonsDistance: polygonB must be an array");let Z=$.map((H,z)=>{if(!H||H.x==null||H.y==null)throw new TypeError(`polygonsDistance: polygonA[${z}] must have x and y properties`);return C7(H.x,H.y)}),K=J.map((H,z)=>{if(!H||H.x==null||H.y==null)throw new TypeError(`polygonsDistance: polygonB[${z}] must have x and y properties`);return C7(H.x,H.y)}),Q=VQ(Z,K);return{distance:Q.distance,closestA:Q.closestA,closestB:Q.closestB,verified:Q.verified}}k.set({precision:80});var Cq=new k("1e-40"),Pq=new k("1e-10");k.set({precision:80});var Tq=new k("1e-40"),bq=new k("1e-30");k.set({precision:80});var W0=($)=>$ instanceof k?$:new k($),vq=new k("1e-40"),XQ=new k("1e-10");function $5($){if(typeof $!=="string")throw new Error("ViewBox must be a string");let J=$.trim().split(/[\s,]+/).filter((Z)=>Z.length>0);if(J.length!==4)throw new Error(`Invalid viewBox format: expected 4 values, got ${J.length}`);try{let Z=W0(J[0]),K=W0(J[1]),Q=W0(J[2]),H=W0(J[3]);if(Q.lessThanOrEqualTo(0)||H.lessThanOrEqualTo(0))throw new Error("ViewBox width and height must be positive");let z=`${Z.toString()} ${K.toString()} ${Q.toString()} ${H.toString()}`,q=J.join(" ");return{x:Z,y:K,width:Q,height:H,verified:z===q}}catch(Z){throw new Error(`Invalid viewBox values: ${Z.message}`)}}function kQ($,J,Z,K){if($==null||J==null||Z==null||K==null)throw new Error("createBBox: all parameters (minX, minY, maxX, maxY) must be provided");let Q=W0($),H=W0(J),z=W0(Z),q=W0(K);if(z.lessThan(Q))throw new Error(`createBBox: maxX (${z}) must be >= minX (${Q})`);if(q.lessThan(H))throw new Error(`createBBox: maxY (${q}) must be >= minY (${H})`);return{minX:Q,minY:H,maxX:z,maxY:q,width:z.minus(Q),height:q.minus(H)}}function aJ($,J,Z,K,Q,H,z,q,W=20){if($==null||J==null||Z==null||K==null||Q==null||H==null||z==null||q==null)throw new Error("sampleCubicBezier: all coordinate parameters must be provided");if(W==null||W<=0)throw new Error("sampleCubicBezier: samples must be a positive number");let j=[];for(let G=0;G<=W;G++){let F=W0(G).div(W),_=W0(1).minus(F),U=F.mul(F),O=U.mul(F),V=_.mul(_),M=V.mul(_),Y=M.mul($).plus(W0(3).mul(V).mul(F).mul(Z)).plus(W0(3).mul(_).mul(U).mul(Q)).plus(O.mul(z)),X=M.mul(J).plus(W0(3).mul(V).mul(F).mul(K)).plus(W0(3).mul(_).mul(U).mul(H)).plus(O.mul(q));j.push({x:Y,y:X})}return j}function tJ($,J,Z,K,Q,H,z=20){if($==null||J==null||Z==null||K==null||Q==null||H==null)throw new Error("sampleQuadraticBezier: all coordinate parameters must be provided");if(z==null||z<=0)throw new Error("sampleQuadraticBezier: samples must be a positive number");let q=[];for(let W=0;W<=z;W++){let j=W0(W).div(z),G=W0(1).minus(j),F=G.mul(G),_=j.mul(j),U=F.mul($).plus(W0(2).mul(G).mul(j).mul(Z)).plus(_.mul(Q)),O=F.mul(J).plus(W0(2).mul(G).mul(j).mul(K)).plus(_.mul(H));q.push({x:U,y:O})}return q}function LQ($,J,Z=XQ){if(!$||typeof $!=="object"||$.x==null||$.y==null)throw new Error("pointInBBox: pt must be an object with x and y properties");if(!J||typeof J!=="object")throw new Error("pointInBBox: bbox must be a bounding box object");if(J.minX==null||J.minY==null||J.maxX==null||J.maxY==null)throw new Error("pointInBBox: bbox must have minX, minY, maxX, maxY properties");return $.x.greaterThanOrEqualTo(J.minX.minus(Z))&&$.x.lessThanOrEqualTo(J.maxX.plus(Z))&&$.y.greaterThanOrEqualTo(J.minY.minus(Z))&&$.y.lessThanOrEqualTo(J.maxY.plus(Z))}function J5($){if(!$||$.length===0)throw new Error("pathBoundingBox: path commands array is empty");let J=W0(1/0),Z=W0(1/0),K=W0(-1/0),Q=W0(-1/0),H=W0(0),z=W0(0),q=W0(0),W=W0(0),j=W0(0),G=W0(0),F=null,_=[];for(let V of $){if(!V||typeof V!=="object"||!V.type||typeof V.type!=="string")throw new Error("pathBoundingBox: each command must be an object with a string type property");let M=V.type.toUpperCase(),Y=V.type===V.type.toLowerCase();switch(M){case"M":{if(V.x==null||V.y==null)throw new Error("pathBoundingBox: M command requires x and y properties");let X=Y?H.plus(W0(V.x)):W0(V.x),w=Y?z.plus(W0(V.y)):W0(V.y);H=X,z=w,q=H,W=z,J=k.min(J,H),Z=k.min(Z,z),K=k.max(K,H),Q=k.max(Q,z),_.push({x:H,y:z}),j=H,G=z,F="M"}break;case"L":{if(V.x==null||V.y==null)throw new Error("pathBoundingBox: L command requires x and y properties");let X=Y?H.plus(W0(V.x)):W0(V.x),w=Y?z.plus(W0(V.y)):W0(V.y);J=k.min(J,X),Z=k.min(Z,w),K=k.max(K,X),Q=k.max(Q,w),_.push({x:X,y:w}),H=X,z=w,j=H,G=z,F="L"}break;case"H":{if(V.x==null)throw new Error("pathBoundingBox: H command requires x property");let X=Y?H.plus(W0(V.x)):W0(V.x);J=k.min(J,X),K=k.max(K,X),_.push({x:X,y:z}),H=X,j=H,G=z,F="H"}break;case"V":{if(V.y==null)throw new Error("pathBoundingBox: V command requires y property");let X=Y?z.plus(W0(V.y)):W0(V.y);Z=k.min(Z,X),Q=k.max(Q,X),_.push({x:H,y:X}),z=X,j=H,G=z,F="V"}break;case"C":{if(V.x1==null||V.y1==null||V.x2==null||V.y2==null||V.x==null||V.y==null)throw new Error("pathBoundingBox: C command requires x1, y1, x2, y2, x, y properties");let X=Y?H.plus(W0(V.x1)):W0(V.x1),w=Y?z.plus(W0(V.y1)):W0(V.y1),R=Y?H.plus(W0(V.x2)):W0(V.x2),I=Y?z.plus(W0(V.y2)):W0(V.y2),b=Y?H.plus(W0(V.x)):W0(V.x),u=Y?z.plus(W0(V.y)):W0(V.y),m=aJ(H,z,X,w,R,I,b,u,20);for(let S of m)J=k.min(J,S.x),Z=k.min(Z,S.y),K=k.max(K,S.x),Q=k.max(Q,S.y),_.push(S);j=R,G=I,H=b,z=u,F="C"}break;case"S":{if(V.x2==null||V.y2==null||V.x==null||V.y==null)throw new Error("pathBoundingBox: S command requires x2, y2, x, y properties");let X=Y?H.plus(W0(V.x2)):W0(V.x2),w=Y?z.plus(W0(V.y2)):W0(V.y2),R=Y?H.plus(W0(V.x)):W0(V.x),I=Y?z.plus(W0(V.y)):W0(V.y),b,u;if(F==="C"||F==="S")b=H.mul(2).minus(j),u=z.mul(2).minus(G);else b=H,u=z;let m=aJ(H,z,b,u,X,w,R,I,20);for(let S of m)J=k.min(J,S.x),Z=k.min(Z,S.y),K=k.max(K,S.x),Q=k.max(Q,S.y),_.push(S);j=X,G=w,H=R,z=I,F="S"}break;case"Q":{if(V.x1==null||V.y1==null||V.x==null||V.y==null)throw new Error("pathBoundingBox: Q command requires x1, y1, x, y properties");let X=Y?H.plus(W0(V.x1)):W0(V.x1),w=Y?z.plus(W0(V.y1)):W0(V.y1),R=Y?H.plus(W0(V.x)):W0(V.x),I=Y?z.plus(W0(V.y)):W0(V.y),b=tJ(H,z,X,w,R,I,20);for(let u of b)J=k.min(J,u.x),Z=k.min(Z,u.y),K=k.max(K,u.x),Q=k.max(Q,u.y),_.push(u);j=X,G=w,H=R,z=I,F="Q"}break;case"T":{if(V.x==null||V.y==null)throw new Error("pathBoundingBox: T command requires x and y properties");let X=Y?H.plus(W0(V.x)):W0(V.x),w=Y?z.plus(W0(V.y)):W0(V.y),R,I;if(F==="Q"||F==="T")R=H.mul(2).minus(j),I=z.mul(2).minus(G);else R=H,I=z;let b=tJ(H,z,R,I,X,w,20);for(let u of b)J=k.min(J,u.x),Z=k.min(Z,u.y),K=k.max(K,u.x),Q=k.max(Q,u.y),_.push(u);j=R,G=I,H=X,z=w,F="T"}break;case"A":{if(V.x==null||V.y==null||V.rx==null||V.ry==null)throw new Error("pathBoundingBox: A command requires x, y, rx, ry properties");let X=Y?H.plus(W0(V.x)):W0(V.x),w=Y?z.plus(W0(V.y)):W0(V.y),R=W0(V.rx).abs(),I=W0(V.ry).abs();if(R.isZero()||I.isZero())J=k.min(J,H,X),Z=k.min(Z,z,w),K=k.max(K,H,X),Q=k.max(Q,z,w),_.push({x:H,y:z},{x:X,y:w});else{J=k.min(J,H,X,H.minus(R),X.minus(R)),Z=k.min(Z,z,w,z.minus(I),w.minus(I)),K=k.max(K,H,X,H.plus(R),X.plus(R)),Q=k.max(Q,z,w,z.plus(I),w.plus(I));let b=20;for(let u=0;u<=b;u++){let m=W0(u).div(b),S=H.plus(X.minus(H).mul(m)),x=z.plus(w.minus(z).mul(m));_.push({x:S,y:x})}}H=X,z=w,j=H,G=z,F="A"}break;case"Z":H=q,z=W,j=H,G=z,F="Z";break;default:throw new Error(`pathBoundingBox: unknown path command type: ${M}`)}}if(!J.isFinite()||!Z.isFinite()||!K.isFinite()||!Q.isFinite())throw new Error("Invalid bounding box: no valid coordinates found");let U=kQ(J,Z,K,Q),O=!0;for(let V of _)if(!LQ(V,U)){O=!1;break}return{...U,verified:O}}function eJ($){if(!$||typeof $!=="object")throw new Error("bboxToPolygon: bbox must be a bounding box object");if($.minX==null||$.minY==null||$.maxX==null||$.maxY==null)throw new Error("bboxToPolygon: bbox must have minX, minY, maxX, maxY properties");return[C7($.minX,$.minY),C7($.maxX,$.minY),C7($.maxX,$.maxY),C7($.minX,$.maxY)]}function K5($,J){if(!J||typeof J!=="object")throw new Error("bboxIntersectsViewBox: viewBox must be an object");if(J.x==null||J.y==null||J.width==null||J.height==null)throw new Error("bboxIntersectsViewBox: viewBox must have x, y, width, height properties");let Z=eJ($),K=eJ({minX:J.x,minY:J.y,maxX:J.x.plus(J.width),maxY:J.y.plus(J.height)}),Q=O$(Z,K);return{intersects:Q.overlaps,verified:Q.verified}}var e0={ID:"id",CLASS:"class",ATTRIBUTE:"attr",PSEUDO_CLASS:"pseudo-class",PSEUDO_ELEMENT:"pseudo-element",TYPE:"type",UNIVERSAL:"universal"};function RQ($){if(typeof $!=="string"||!$.trim())throw new Error("Selector must be a non-empty string");let J=$.trim(),Z=[],K=BQ(J);for(let Q of K){if(!Q.trim())continue;let H=NQ(Q.trim());Z.push(...H)}return Z}function BQ($){if(typeof $!=="string")throw new Error("Selector must be a string");let J=[],Z="",K=0,Q=0,H=!1,z=null;for(let W=0;W<$.length;W++){let j=$[W],G=W>0?$[W-1]:null;if((j==='"'||j==="'")&&G!=="\\"){if(!H)H=!0,z=j;else if(j===z)H=!1,z=null}if(!H){if(j==="["&&G!=="\\")K++;else if(j==="]"&&G!=="\\"){if(K--,K<0)throw new Error(`Unbalanced brackets at position ${W}`)}else if(j==="("&&G!=="\\")Q++;else if(j===")"&&G!=="\\"){if(Q--,Q<0)throw new Error(`Unbalanced parentheses at position ${W}`)}}if(!H&&K===0&&Q===0){if(j===">"||j==="+"||j==="~"){let F=Z.trim();if(F)J.push(F);Z="";continue}else if(j===" "){let F=Z.trim();if(F){J.push(F),Z="";continue}else continue}}Z+=j}if(H)throw new Error("Unclosed quote in selector");if(K!==0)throw new Error("Unclosed brackets in selector");if(Q!==0)throw new Error("Unclosed parentheses in selector");let q=Z.trim();if(q)J.push(q);return J}function NQ($){if(typeof $!=="string")throw new Error("Selector must be a string");let J=[],Z=0;while(Z<$.length){let K=$[Z];if(K==="#"){let Q=$.slice(Z).match(/^#([a-zA-Z_-][\w-]*)/);if(!Q)throw new Error(`Invalid ID selector at position ${Z}`);J.push({type:e0.ID,value:Q[1]}),Z+=Q[0].length}else if(K==="."){let Q=$.slice(Z).match(/^\.([a-zA-Z_-][\w-]*)/);if(!Q)throw new Error(`Invalid class selector at position ${Z}`);J.push({type:e0.CLASS,value:Q[1]}),Z+=Q[0].length}else if(K==="["){let Q=IQ($,Z);if(Q===-1)throw new Error(`Unclosed attribute selector at position ${Z}`);let H=$.slice(Z+1,Q);J.push({type:e0.ATTRIBUTE,value:H}),Z=Q+1}else if(K===":")if(Z+1<$.length&&$[Z+1]===":"){let Q=$.slice(Z).match(/^::([\w-]+)/);if(!Q)throw new Error(`Invalid pseudo-element at position ${Z}`);J.push({type:e0.PSEUDO_ELEMENT,value:Q[1]}),Z+=Q[0].length}else{let Q=$.slice(Z).match(/^:([\w-]+)/);if(!Q)throw new Error(`Invalid pseudo-class at position ${Z}`);let H=Q[1];if(Z+=Q[0].length,Z<$.length&&$[Z]==="("){let W=CQ($,Z);if(W===-1)throw new Error(`Unclosed pseudo-class function at position ${Z}`);H+=$.slice(Z,W+1),Z=W+1}let q=["before","after","first-line","first-letter"].includes(H);J.push({type:q?e0.PSEUDO_ELEMENT:e0.PSEUDO_CLASS,value:H})}else if(K==="*"){let Q=Z+1;if(Q<$.length&&$[Q]==="|"){if(Q++,Q<$.length&&$[Q]==="*")Q++}J.push({type:e0.UNIVERSAL,value:"*"}),Z=Q}else if(/[a-zA-Z]/.test(K)){let Q=$.slice(Z).match(/^([a-zA-Z][\w-]*)/);if(!Q)throw new Error(`Invalid type selector at position ${Z}`);let H=Q[1],z=Z+Q[0].length;if(z<$.length&&$[z]==="|"){z++;let q=$.slice(z).match(/^([a-zA-Z*][\w-]*)/);if(q)H=q[1],z+=q[0].length}J.push({type:e0.TYPE,value:H}),Z=z}else if(K===">"||K==="+"||K==="~"||K===" ")Z++;else throw new Error(`Unexpected character '${K}' at position ${Z}`)}return J}function IQ($,J){if(typeof $!=="string")throw new Error("str must be a string");if(typeof J!=="number"||J<0||J>=$.length)throw new Error("startIdx must be a valid index within the string");let Z=0,K=!1,Q=null;for(let H=J;H<$.length;H++){let z=$[H],q=H>0?$[H-1]:null;if((z==='"'||z==="'")&&q!=="\\"){if(!K)K=!0,Q=z;else if(z===Q)K=!1,Q=null}if(!K){if(z==="["&&q!=="\\")Z++;if(z==="]"&&q!=="\\"){if(Z--,Z===0)return H}}}return-1}function CQ($,J){if(typeof $!=="string")throw new Error("str must be a string");if(typeof J!=="number"||J<0||J>=$.length)throw new Error("startIdx must be a valid index within the string");let Z=0,K=!1,Q=null;for(let H=J;H<$.length;H++){let z=$[H],q=H>0?$[H-1]:null;if((z==='"'||z==="'")&&q!=="\\"){if(!K)K=!0,Q=z;else if(z===Q)K=!1,Q=null}if(!K){if(z==="("&&q!=="\\")Z++;if(z===")"&&q!=="\\"){if(Z--,Z===0)return H}}}return-1}function Y$($){let J=typeof $==="string"?RQ($):$;if(!Array.isArray(J))throw new Error("Selector must be a string or an array of components");let Z=0,K=0,Q=0;for(let H of J){if(!H||typeof H.type!=="string")throw new Error("Invalid component: must have a 'type' property");switch(H.type){case e0.ID:Z++;break;case e0.CLASS:case e0.ATTRIBUTE:K++;break;case e0.PSEUDO_CLASS:{let z=H.value;if(z.startsWith("where(")&&z.endsWith(")"))break;if((z.startsWith("not(")||z.startsWith("is(")||z.startsWith("has("))&&z.endsWith(")")){let q=z.match(/^(\w+)\(/)[1],W=z.slice(q.length+1,-1);if(W.trim()){let j=PQ(W),G=[0,0,0];for(let F of j)if(F.trim()){let _=Y$(F.trim());if(X$(_,G)>0)G=_}Z+=G[0],K+=G[1],Q+=G[2]}break}if((z.startsWith("nth-child(")||z.startsWith("nth-last-child("))&&z.endsWith(")")){let q=z.match(/^([\w-]+)\(/)[1],j=z.slice(q.length+1,-1).match(/\s+of\s+(.+)$/);if(j){let G=j[1].trim(),F=Y$(G);Z+=F[0],K+=F[1],Q+=F[2]}K++;break}K++;break}case e0.TYPE:case e0.PSEUDO_ELEMENT:Q++;break;case e0.UNIVERSAL:break;default:break}}return[Z,K,Q]}function PQ($){if(typeof $!=="string")throw new Error("selectorList must be a string");let J=[],Z="",K=0,Q=0,H=!1,z=null;for(let q=0;q<$.length;q++){let W=$[q],j=q>0?$[q-1]:null;if((W==='"'||W==="'")&&j!=="\\"){if(!H)H=!0,z=W;else if(W===z)H=!1,z=null}if(!H){if(W==="(")K++;if(W===")")K--;if(W==="[")Q++;if(W==="]")Q--;if(W===","&&K===0&&Q===0){J.push(Z),Z="";continue}}Z+=W}if(Z)J.push(Z);return J}function X$($,J){if(!Array.isArray($)||$.length!==3)throw new Error("spec1 must be an array of 3 numbers");if(!Array.isArray(J)||J.length!==3)throw new Error("spec2 must be an array of 3 numbers");for(let Z=0;Z<3;Z++){if(typeof $[Z]!=="number"||!Number.isFinite($[Z])||$[Z]<0)throw new Error(`spec1[${Z}] must be a non-negative finite number`);if(typeof J[Z]!=="number"||!Number.isFinite(J[Z])||J[Z]<0)throw new Error(`spec2[${Z}] must be a non-negative finite number`)}for(let Z=0;Z<3;Z++){if($[Z]<J[Z])return-1;if($[Z]>J[Z])return 1}return 0}var f0=($)=>$ instanceof k?$:new k($);function O9(){let $=new k(2),J=new k(3);return new k(4).mul($.sqrt().minus(1)).div(J)}function EQ($){if($==null)throw new Error("getKappaForArc: thetaRadians parameter is required");let J=f0($);if(!J.isFinite())throw new Error("getKappaForArc: thetaRadians must be finite");if(J.isZero()||J.isNegative())throw new Error("getKappaForArc: thetaRadians must be positive");let Z=new k(4),K=new k(3);return Z.div(K).mul(k.tan(J.div(Z)))}function Z5($,J,Z,K=8,Q=6){if($==null||J==null||Z==null)throw new Error("circleToPathDataHP: cx, cy, and r parameters are required");let H=f0(Z);if(!H.isFinite()||H.isNegative())throw new Error("circleToPathDataHP: radius must be finite and non-negative");if(H.isZero())return"";if(!Number.isFinite(K)||K<=0)throw new Error("circleToPathDataHP: arcs must be a positive number");if(!Number.isFinite(Q)||Q<0)throw new Error("circleToPathDataHP: precision must be non-negative");return Y9($,J,Z,Z,K,Q)}function Y9($,J,Z,K,Q=8,H=6){if($==null||J==null||Z==null||K==null)throw new Error("ellipseToPathDataHP: cx, cy, rx, and ry parameters are required");if(!Number.isFinite(Q)||Q<=0)throw new Error("ellipseToPathDataHP: arcs must be a positive number");if(!Number.isFinite(H)||H<0)throw new Error("ellipseToPathDataHP: precision must be non-negative");let z=Q;if(z%4!==0)z=Math.ceil(z/4)*4;let q=f0($),W=f0(J),j=f0(Z),G=f0(K);if(!j.isFinite()||j.isNegative())throw new Error("ellipseToPathDataHP: rx must be finite and non-negative");if(!G.isFinite()||G.isNegative())throw new Error("ellipseToPathDataHP: ry must be finite and non-negative");if(j.isZero()||G.isZero())return"";let F=(Y)=>Q6(Y,H),O=k.acos(-1).mul(2).div(z),V=EQ(O),M=[];for(let Y=0;Y<z;Y++){let X=O.mul(Y),w=O.mul(Y+1),R=k.cos(X),I=k.sin(X),b=k.cos(w),u=k.sin(w),m=q.plus(j.mul(R)),S=W.plus(G.mul(I)),x=q.plus(j.mul(b)),h=W.plus(G.mul(u)),E=I.neg(),d=R,c=u.neg(),p=b,N=m.plus(V.mul(j).mul(E)),y=S.plus(V.mul(G).mul(d)),B=x.minus(V.mul(j).mul(c)),e=h.minus(V.mul(G).mul(p));if(Y===0)M.push(`M${F(m)} ${F(S)}`);M.push(`C${F(N)} ${F(y)} ${F(B)} ${F(e)} ${F(x)} ${F(h)}`)}return M.push("Z"),M.join(" ")}function Q6($,J=6){if($==null)throw new Error("formatNumber: value parameter is required");if(!Number.isFinite(J)||J<0)throw new Error("formatNumber: precision must be non-negative");let Z=f0($);if(!Z.isFinite())throw new Error("formatNumber: value must be finite");let K=Z.toFixed(J);if(K.includes("."))K=K.replace(/\.?0+$/,"");return K}function X9($,J,Z,K=6){if($==null||J==null||Z==null)throw new Error("circleToPathData: cx, cy, and r parameters are required");if(!Number.isFinite(K)||K<0)throw new Error("circleToPathData: precision must be non-negative");let Q=f0($),H=f0(J),z=f0(Z);if(!z.isFinite()||z.isNegative())throw new Error("circleToPathData: radius must be finite and non-negative");if(z.isZero())return"";let q=O9().mul(z),W=Q.plus(z),j=H,G=W,F=j.minus(q),_=Q.plus(q),U=H.minus(z),O=Q,V=H.minus(z),M=Q.minus(q),Y=V,X=Q.minus(z),w=H.minus(q),R=Q.minus(z),I=H,b=R,u=H.plus(q),m=Q.minus(q),S=H.plus(z),x=Q,h=H.plus(z),E=Q.plus(q),d=h,c=W,p=H.plus(q),N=(y)=>Q6(y,K);return`M${N(W)} ${N(j)}C${N(G)} ${N(F)} ${N(_)} ${N(U)} ${N(O)} ${N(V)}C${N(M)} ${N(Y)} ${N(X)} ${N(w)} ${N(R)} ${N(I)}C${N(b)} ${N(u)} ${N(m)} ${N(S)} ${N(x)} ${N(h)}C${N(E)} ${N(d)} ${N(c)} ${N(p)} ${N(W)} ${N(j)}Z`}function k9($,J,Z,K,Q=6){if($==null||J==null||Z==null||K==null)throw new Error("ellipseToPathData: cx, cy, rx, and ry parameters are required");if(!Number.isFinite(Q)||Q<0)throw new Error("ellipseToPathData: precision must be non-negative");let H=f0($),z=f0(J),q=f0(Z),W=f0(K);if(!q.isFinite()||q.isNegative())throw new Error("ellipseToPathData: rx must be finite and non-negative");if(!W.isFinite()||W.isNegative())throw new Error("ellipseToPathData: ry must be finite and non-negative");if(q.isZero()||W.isZero())return"";let j=O9(),G=j.mul(q),F=j.mul(W),_=H.plus(q),U=z,O=_,V=U.minus(F),M=H.plus(G),Y=z.minus(W),X=H,w=z.minus(W),R=H.minus(G),I=w,b=H.minus(q),u=z.minus(F),m=H.minus(q),S=z,x=m,h=z.plus(F),E=H.minus(G),d=z.plus(W),c=H,p=z.plus(W),N=H.plus(G),y=p,B=_,e=z.plus(F),r=(s)=>Q6(s,Q);return`M${r(_)} ${r(U)}C${r(O)} ${r(V)} ${r(M)} ${r(Y)} ${r(X)} ${r(w)}C${r(R)} ${r(I)} ${r(b)} ${r(u)} ${r(m)} ${r(S)}C${r(x)} ${r(h)} ${r(E)} ${r(d)} ${r(c)} ${r(p)}C${r(N)} ${r(y)} ${r(B)} ${r(e)} ${r(_)} ${r(U)}Z`}function L9($,J,Z,K,Q=0,H=null,z=!1,q=6){if($==null||J==null||Z==null||K==null)throw new Error("rectToPathData: x, y, width, and height parameters are required");if(!Number.isFinite(q)||q<0)throw new Error("rectToPathData: precision must be non-negative");let W=f0($),j=f0(J),G=f0(Z),F=f0(K);if(!W.isFinite())throw new Error("rectToPathData: x must be finite");if(!j.isFinite())throw new Error("rectToPathData: y must be finite");if(!G.isFinite()||G.isNegative())throw new Error("rectToPathData: width must be finite and non-negative");if(!F.isFinite()||F.isNegative())throw new Error("rectToPathData: height must be finite and non-negative");if(G.isZero()||F.isZero())return"";let _=f0(Q||0),U=H!==null?f0(H):_;if(!_.isFinite()||_.isNegative())throw new Error("rectToPathData: rx must be finite and non-negative");if(!U.isFinite()||U.isNegative())throw new Error("rectToPathData: ry must be finite and non-negative");let O=G.div(2),V=F.div(2);if(_.gt(O))_=O;if(U.gt(V))U=V;let M=(E)=>Q6(E,q);if(_.isZero()||U.isZero()){let E=W.plus(G),d=j.plus(F);return`M${M(W)} ${M(j)}H${M(E)}V${M(d)}H${M(W)}Z`}let Y=W,X=W.plus(G),w=j,R=j.plus(F),I=Y.plus(_),b=X.minus(_),u=w.plus(U),m=R.minus(U);if(z)return`M${M(I)} ${M(w)}L${M(b)} ${M(w)}A${M(_)} ${M(U)} 0 0 1 ${M(X)} ${M(u)}L${M(X)} ${M(m)}A${M(_)} ${M(U)} 0 0 1 ${M(b)} ${M(R)}L${M(I)} ${M(R)}A${M(_)} ${M(U)} 0 0 1 ${M(Y)} ${M(m)}L${M(Y)} ${M(u)}A${M(_)} ${M(U)} 0 0 1 ${M(I)} ${M(w)}Z`;let S=O9(),x=S.mul(_),h=S.mul(U);return`M${M(I)} ${M(w)}L${M(b)} ${M(w)}C${M(b.plus(x))} ${M(w)} ${M(X)} ${M(u.minus(h))} ${M(X)} ${M(u)}L${M(X)} ${M(m)}C${M(X)} ${M(m.plus(h))} ${M(b.plus(x))} ${M(R)} ${M(b)} ${M(R)}L${M(I)} ${M(R)}C${M(I.minus(x))} ${M(R)} ${M(Y)} ${M(m.plus(h))} ${M(Y)} ${M(m)}L${M(Y)} ${M(u)}C${M(Y)} ${M(u.minus(h))} ${M(I.minus(x))} ${M(w)} ${M(I)} ${M(w)}Z`}function w9($,J,Z,K,Q=6){if($==null||J==null||Z==null||K==null)throw new Error("lineToPathData: x1, y1, x2, and y2 parameters are required");if(!Number.isFinite(Q)||Q<0)throw new Error("lineToPathData: precision must be non-negative");let H=f0($),z=f0(J),q=f0(Z),W=f0(K);if(!H.isFinite()||!z.isFinite()||!q.isFinite()||!W.isFinite())throw new Error("lineToPathData: all coordinates must be finite");let j=(G)=>Q6(G,Q);return`M${j(H)} ${j(z)}L${j(q)} ${j(W)}`}function TQ($){if($==null)return[];if(Array.isArray($))try{return $.map(([H,z])=>[f0(H),f0(z)])}catch(H){return[]}let J=$;if(typeof J==="object"&&J.baseVal!==void 0)J=J.baseVal;if(typeof J!=="string")if(typeof J.toString==="function")J=J.toString();else return[];let Z=[],K=J.split(/[\s,]+/).filter((H)=>H.length>0);for(let H of K)try{Z.push(f0(H))}catch(z){continue}let Q=[];for(let H=0;H<Z.length;H+=2)if(H+1<Z.length)Q.push([Z[H],Z[H+1]]);return Q}function k$($,J=6){if(!Number.isFinite(J)||J<0)throw new Error("polylineToPathData: precision must be non-negative");let Z=TQ($);if(Z.length===0)return"";let K=(q)=>Q6(q,J),[Q,H]=Z[0],z=`M${K(Q)} ${K(H)}`;for(let q=1;q<Z.length;q++){let[W,j]=Z[q];z+=`L${K(W)} ${K(j)}`}return z}function R9($,J=6){if(!Number.isFinite(J)||J<0)throw new Error("polygonToPathData: precision must be non-negative");let Z=k$($,J);return Z?Z+" Z":""}var bQ={M:2,m:2,L:2,l:2,H:1,h:1,V:1,v:1,C:6,c:6,S:4,s:4,Q:4,q:4,T:2,t:2,A:7,a:7,Z:0,z:0};function y6($){if($==null)throw new Error("parsePathData: pathData parameter is required");if(typeof $!=="string")throw new Error("parsePathData: pathData must be a string");let J=[],Z=/([MmLlHhVvCcSsQqTtAaZz])\s*([^MmLlHhVvCcSsQqTtAaZz]*)/g,K;while((K=Z.exec($))!==null){let Q=K[1],H=K[2].trim(),z=/-?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/g,q=[];if(H.length>0)for(let j of H.matchAll(z))try{q.push(f0(j[0]))}catch(G){continue}let W=bQ[Q];if(W===0||q.length===0)J.push({command:Q,args:[]});else for(let j=0;j<q.length;j+=W){let G=q.slice(j,j+W);if(G.length===W){let F=Q;if(j>0&&(Q==="M"||Q==="m"))F=Q==="M"?"L":"l";J.push({command:F,args:G})}}}return J}function B9($,J=6){if($==null)throw new Error("pathArrayToString: commands parameter is required");if(!Array.isArray($))throw new Error("pathArrayToString: commands must be an array");if(!Number.isFinite(J)||J<0)throw new Error("pathArrayToString: precision must be non-negative");return $.map((Z)=>{if(!Z||typeof Z.command!=="string"||!Array.isArray(Z.args))throw new Error("pathArrayToString: each command must have 'command' (string) and 'args' (array) properties");let{command:K,args:Q}=Z,H=Q.map((z)=>Q6(z,J)).join(" ");return H.length>0?`${K} ${H}`:K}).join(" ")}function Q5($){if($==null)throw new Error("pathToAbsolute: pathData parameter is required");let J=y6($),Z=[],K=new k(0),Q=new k(0),H=new k(0),z=new k(0),q=new k(0),W=new k(0),j="";for(let{command:G,args:F}of J){let _=G===G.toLowerCase(),U=G.toUpperCase();if(U==="M"){if(F.length<2)continue;let O=_?K.plus(F[0]):F[0],V=_?Q.plus(F[1]):F[1];K=O,Q=V,H=O,z=V,Z.push({command:"M",args:[O,V]}),j="M"}else if(U==="L"){if(F.length<2)continue;let O=_?K.plus(F[0]):F[0],V=_?Q.plus(F[1]):F[1];K=O,Q=V,Z.push({command:"L",args:[O,V]}),j="L"}else if(U==="H"){if(F.length<1)continue;let O=_?K.plus(F[0]):F[0];K=O,Z.push({command:"L",args:[O,Q]}),j="H"}else if(U==="V"){if(F.length<1)continue;let O=_?Q.plus(F[0]):F[0];Q=O,Z.push({command:"L",args:[K,O]}),j="V"}else if(U==="C"){if(F.length<6)continue;let O=_?K.plus(F[0]):F[0],V=_?Q.plus(F[1]):F[1],M=_?K.plus(F[2]):F[2],Y=_?Q.plus(F[3]):F[3],X=_?K.plus(F[4]):F[4],w=_?Q.plus(F[5]):F[5];q=M,W=Y,K=X,Q=w,Z.push({command:"C",args:[O,V,M,Y,X,w]}),j="C"}else if(U==="S"){if(F.length<4)continue;let O,V;if(j==="C"||j==="S")O=K.mul(2).minus(q),V=Q.mul(2).minus(W);else O=K,V=Q;let M=_?K.plus(F[0]):F[0],Y=_?Q.plus(F[1]):F[1],X=_?K.plus(F[2]):F[2],w=_?Q.plus(F[3]):F[3];q=M,W=Y,K=X,Q=w,Z.push({command:"C",args:[O,V,M,Y,X,w]}),j="S"}else if(U==="Q"){if(F.length<4)continue;let O=_?K.plus(F[0]):F[0],V=_?Q.plus(F[1]):F[1],M=_?K.plus(F[2]):F[2],Y=_?Q.plus(F[3]):F[3];q=O,W=V,K=M,Q=Y,Z.push({command:"Q",args:[O,V,M,Y]}),j="Q"}else if(U==="T"){if(F.length<2)continue;let O,V;if(j==="Q"||j==="T")O=K.mul(2).minus(q),V=Q.mul(2).minus(W);else O=K,V=Q;let M=_?K.plus(F[0]):F[0],Y=_?Q.plus(F[1]):F[1];q=O,W=V,K=M,Q=Y,Z.push({command:"Q",args:[O,V,M,Y]}),j="T"}else if(U==="A"){if(F.length<7)continue;let O=_?K.plus(F[5]):F[5],V=_?Q.plus(F[6]):F[6];K=O,Q=V,Z.push({command:"A",args:[F[0],F[1],F[2],F[3],F[4],O,V]}),j="A"}else if(U==="Z")K=H,Q=z,Z.push({command:"Z",args:[]}),j="Z";else Z.push({command:G,args:F}),j=G}return B9(Z)}function H5($,J=6){if($==null)throw new Error("convertElementToPath: element parameter is required");if(!Number.isFinite(J)||J<0)throw new Error("convertElementToPath: precision must be non-negative");let Z=(Q,H=0)=>{let z=$.getAttribute?$.getAttribute(Q):$[Q];return fQ(z!==void 0&&z!==null?z:H)},K=($.tagName||$.type||"").toLowerCase();if(K==="circle")return X9(Z("cx",0),Z("cy",0),Z("r",0),J);else if(K==="ellipse")return k9(Z("cx",0),Z("cy",0),Z("rx",0),Z("ry",0),J);else if(K==="rect")return L9(Z("x",0),Z("y",0),Z("width",0),Z("height",0),Z("rx",0),Z("ry",null),!1,J);else if(K==="line")return w9(Z("x1",0),Z("y1",0),Z("x2",0),Z("y2",0),J);else if(K==="polyline")return k$(Z("points",""),J);else if(K==="polygon")return R9(Z("points",""),J);return null}function fQ($){if($==null)return 0;if(typeof $==="string"){let Z=parseFloat($);return isNaN(Z)?0:Z}if(typeof $==="number")return isNaN($)?0:$;if($ instanceof k)return $.toNumber();let J=Number($);return isNaN(J)?0:J}var w7=($)=>{if($ instanceof k){if(!$.isFinite())throw new Error(`Value must be finite (got ${$.toString()})`);return $}try{let J=new k($);if(!J.isFinite())throw new Error(`Value must be finite (got ${$})`);return J}catch(J){throw new Error(`Invalid numeric value: "${$}" (${J.message})`)}};function V7($,J){if($===void 0||$===null)throw new Error(`${J} is required`);if(typeof $!=="number"&&typeof $!=="string"&&!($ instanceof k))throw new Error(`${J} must be a number, string, or Decimal`);if(typeof $==="number"&&!isFinite($))throw new Error(`${J} must be a finite number (got ${$})`);if($ instanceof k&&!$.isFinite())throw new Error(`${J} must be a finite Decimal (got ${$.toString()})`)}function o0($,J){return V7($,"tx"),V7(J,"ty"),M0.from([[new k(1),new k(0),w7($)],[new k(0),new k(1),w7(J)],[new k(0),new k(0),new k(1)]])}function M7($,J=null){if(V7($,"sx"),J!==null)V7(J,"sy");let Z=J===null?$:J,K=w7($),Q=w7(Z);if(K.isZero()||Q.isZero())throw new Error("Scale factors cannot be zero (creates singular matrix)");return M0.from([[K,new k(0),new k(0)],[new k(0),Q,new k(0)],[new k(0),new k(0),new k(1)]])}function O6($){V7($,"theta");let Z=w7($).toNumber(),K=Math.PI,Q=Z-2*K*Math.floor((Z+K)/(2*K));if(!isFinite(Q))throw new Error(`Angle normalization failed for theta=${$} (too large or invalid)`);let H=new k(Math.cos(Q)),z=new k(Math.sin(Q));if(!H.isFinite()||!z.isFinite())throw new Error(`Trigonometric computation failed for theta=${$} (produced non-finite values)`);return M0.from([[H,z.negated(),new k(0)],[z,H,new k(0)],[new k(0),new k(0),new k(1)]])}function q5($,J,Z){V7($,"theta"),V7(J,"px"),V7(Z,"py");let K=w7(J),Q=w7(Z);return o0(K,Q).mul(O6($)).mul(o0(K.negated(),Q.negated()))}function N9($,J){V7($,"ax"),V7(J,"ay");let Z=w7($),K=w7(J);if(new k(1).minus(Z.mul(K)).lessThanOrEqualTo(0))throw new Error(`Skew parameters create singular or orientation-inverting matrix (ax*ay = ${Z.mul(K).toString()}, must be < 1)`);return M0.from([[new k(1),Z,new k(0)],[K,new k(1),new k(0)],[new k(0),new k(0),new k(1)]])}function c0($,J,Z){if(!$||typeof $.mul!=="function")throw new Error("applyTransform: first argument must be a Matrix");if(!$.data||!Array.isArray($.data)||$.data.length!==3||!$.data[0]||$.data[0].length!==3||!$.data[1]||$.data[1].length!==3||!$.data[2]||$.data[2].length!==3)throw new Error("applyTransform: matrix must be 3x3");V7(J,"x"),V7(Z,"y");let K=M0.from([[w7(J)],[w7(Z)],[new k(1)]]),Q=$.mul(K);if(!Q||!Q.data||!Array.isArray(Q.data)||Q.data.length!==3||!Q.data[0]||!Q.data[0][0]||!Q.data[1]||!Q.data[1][0]||!Q.data[2]||!Q.data[2][0])throw new Error("applyTransform: matrix multiplication produced invalid result");let H=Q.data[0][0],z=Q.data[1][0],q=Q.data[2][0];if(q.isZero())throw new Error("applyTransform: perspective division by zero (invalid transformation matrix)");return[H.div(q),z.div(q)]}k.set({precision:80});function W5($,J,Z){return I9($,J,Z,Z)}function I9($,J,Z,K){let Q=(R)=>new k(R),H=Q($),z=Q(J),q=Q(Z),W=Q(K);if(!q.isFinite()||!W.isFinite()||!H.isFinite()||!z.isFinite())throw new Error("Ellipse parameters must be finite");if(q.eq(0)||W.eq(0))return console.warn("Degenerate ellipse with zero radius, returning empty path"),"";if(q.lt(0)||W.lt(0))throw new Error("Ellipse radii must be non-negative");let j=Q("0.5522847498307936"),G=q.mul(j),F=W.mul(j),_=H.plus(q),U=z,O=H,V=z.minus(W),M=H.minus(q),Y=z,X=H,w=z.plus(W);return[`M ${_.toFixed(6)} ${U.toFixed(6)}`,`C ${_.toFixed(6)} ${U.minus(F).toFixed(6)} ${O.plus(G).toFixed(6)} ${V.toFixed(6)} ${O.toFixed(6)} ${V.toFixed(6)}`,`C ${O.minus(G).toFixed(6)} ${V.toFixed(6)} ${M.toFixed(6)} ${Y.minus(F).toFixed(6)} ${M.toFixed(6)} ${Y.toFixed(6)}`,`C ${M.toFixed(6)} ${Y.plus(F).toFixed(6)} ${X.minus(G).toFixed(6)} ${w.toFixed(6)} ${X.toFixed(6)} ${w.toFixed(6)}`,`C ${X.plus(G).toFixed(6)} ${w.toFixed(6)} ${_.toFixed(6)} ${U.plus(F).toFixed(6)} ${_.toFixed(6)} ${U.toFixed(6)}`,"Z"].join(" ")}function j5($,J,Z,K,Q=0,H=null){let z=(M)=>new k(M),q=z($),W=z(J),j=z(Z),G=z(K);if(j.lte(0)||G.lte(0))throw new Error("Rectangle dimensions must be positive");if(!j.isFinite()||!G.isFinite()||!q.isFinite()||!W.isFinite())throw new Error("Rectangle parameters must be finite");let F=z(Q),_=H!==null?z(H):F;if(F.lt(0)||_.lt(0))throw new Error("Rectangle corner radii must be non-negative");let U=j.div(2),O=G.div(2);if(F.gt(U))F=U;if(_.gt(O))_=O;if(!(F.gt(0)||_.gt(0)))return[`M ${q.toFixed(6)} ${W.toFixed(6)}`,`L ${q.plus(j).toFixed(6)} ${W.toFixed(6)}`,`L ${q.plus(j).toFixed(6)} ${W.plus(G).toFixed(6)}`,`L ${q.toFixed(6)} ${W.plus(G).toFixed(6)}`,"Z"].join(" ");return[`M ${q.plus(F).toFixed(6)} ${W.toFixed(6)}`,`L ${q.plus(j).minus(F).toFixed(6)} ${W.toFixed(6)}`,`A ${F.toFixed(6)} ${_.toFixed(6)} 0 0 1 ${q.plus(j).toFixed(6)} ${W.plus(_).toFixed(6)}`,`L ${q.plus(j).toFixed(6)} ${W.plus(G).minus(_).toFixed(6)}`,`A ${F.toFixed(6)} ${_.toFixed(6)} 0 0 1 ${q.plus(j).minus(F).toFixed(6)} ${W.plus(G).toFixed(6)}`,`L ${q.plus(F).toFixed(6)} ${W.plus(G).toFixed(6)}`,`A ${F.toFixed(6)} ${_.toFixed(6)} 0 0 1 ${q.toFixed(6)} ${W.plus(G).minus(_).toFixed(6)}`,`L ${q.toFixed(6)} ${W.plus(_).toFixed(6)}`,`A ${F.toFixed(6)} ${_.toFixed(6)} 0 0 1 ${q.plus(F).toFixed(6)} ${W.toFixed(6)}`].join(" ")}function G5($,J,Z,K){let Q=(j)=>new k(j),H=Q($),z=Q(J),q=Q(Z),W=Q(K);if(!H.isFinite()||!z.isFinite()||!q.isFinite()||!W.isFinite())throw new Error("lineToPath: all parameters must be finite");return`M ${H.toFixed(6)} ${z.toFixed(6)} L ${q.toFixed(6)} ${W.toFixed(6)}`}function F5($){let J=U5($);if(J.length===0)return"";let Z=`M ${J[0][0]} ${J[0][1]}`;for(let K=1;K<J.length;K++)Z+=` L ${J[K][0]} ${J[K][1]}`;return Z+" Z"}function _5($){let J=U5($);if(J.length===0)return"";let Z=`M ${J[0][0]} ${J[0][1]}`;for(let K=1;K<J.length;K++)Z+=` L ${J[K][0]} ${J[K][1]}`;return Z}function U5($){if(!$)return[];let J;try{if(Array.isArray($))J=$.flat().map((K)=>new k(K).toFixed(6));else if(typeof $==="string")J=$.trim().split(/[\s,]+/).filter((K)=>K.length>0).map((K)=>new k(K).toFixed(6));else return console.warn("parsePointPairs: invalid input type"),[]}catch(K){return console.warn(`parsePointPairs: parse error - ${K.message}`),[]}if(J.length%2!==0)console.warn("parsePointPairs: odd number of coordinates, ignoring last value"),J=J.slice(0,-1);let Z=[];for(let K=0;K+1<J.length;K+=2)Z.push([J[K],J[K+1]]);return Z}function SQ($,J,Z,K,Q,H,z,q){let W=(Q0)=>new k(Q0),j=W("1e-16");if(!q||!q.data||!Array.isArray(q.data)||q.data.length<3)throw new Error("transformArc: invalid matrix");let G=W($),F=W(J);if(G.lte(0)||F.lte(0))return console.warn("transformArc: radii must be positive, returning degenerate arc"),{rx:0,ry:0,xAxisRotation:0,largeArcFlag:K,sweepFlag:Q,x:W(H).toNumber(),y:W(z).toNumber()};let _=K;if(typeof _!=="number"||_!==0&&_!==1)console.warn(`transformArc: largeArcFlag must be 0 or 1, got ${K}`),_=_?1:0;let U=Q;if(typeof U!=="number"||U!==0&&U!==1)console.warn(`transformArc: sweepFlag must be 0 or 1, got ${Q}`),U=U?1:0;let O=q.data[0][0],V=q.data[1][0],M=q.data[0][1],Y=q.data[1][1],X=q.data[0][2],w=q.data[1][2],R=W(H),I=W(z),b=O.mul(R).plus(M.mul(I)).plus(X),u=V.mul(R).plus(Y.mul(I)).plus(w),m=W(Z).mul(W(Math.PI)).div(180),S=k.sin(m),x=k.cos(m),h=O.mul(G).mul(x).plus(M.mul(G).mul(S)),E=V.mul(G).mul(x).plus(Y.mul(G).mul(S)),d=O.mul(F.neg()).mul(S).plus(M.mul(F).mul(x)),c=V.mul(F.neg()).mul(S).plus(Y.mul(F).mul(x)),p=h.mul(h).plus(d.mul(d)),N=E.mul(E).plus(c.mul(c)),y=h.mul(E).plus(d.mul(c)).mul(2),B=p.minus(N),e,r,s;if(y.abs().lt(j))e=W(0),r=p,s=N;else if(B.abs().lt(j))r=p.plus(y.mul("0.5")),s=p.minus(y.mul("0.5")),e=W(Math.PI).div(4);else{let Q0=W(1).plus(y.mul(y).div(B.mul(B))).sqrt();r=p.plus(N).plus(Q0.mul(B)).div(2),s=p.plus(N).minus(Q0.mul(B)).div(2),e=k.atan(y.div(B)).div(2)}if(r.lt(0))r=W(0);if(s.lt(0))s=W(0);let z0=r.sqrt(),T=s.sqrt();if(B.lte(0)){let Q0=z0;z0=T,T=Q0}if(T.gt(z0)){let Q0=z0;z0=T,T=Q0,e=e.plus(W(Math.PI).div(2))}let P=O.mul(Y).minus(V.mul(M)),t=U;if(P.lt(0))t=U?0:1;let $0=e.mul(180).div(W(Math.PI));while($0.lt(0))$0=$0.plus(180);while($0.gte(180))$0=$0.minus(180);return{rx:z0.toNumber(),ry:T.toNumber(),xAxisRotation:$0.toNumber(),largeArcFlag:_,sweepFlag:t,x:b.toNumber(),y:u.toNumber()}}function vQ($,J){if(!$||typeof $!=="string")return console.warn("parseTransformFunction: invalid function name"),M0.identity(3);if(!J||!Array.isArray(J))return console.warn("parseTransformFunction: invalid arguments array"),M0.identity(3);let Z=(K)=>new k(K);switch($.toLowerCase()){case"translate":{let K=J[0]!==void 0?J[0]:0,Q=J[1]!==void 0?J[1]:0;return o0(K,Q)}case"scale":{let K=J[0]!==void 0?J[0]:1,Q=J[1]!==void 0?J[1]:K;return M7(K,Q)}case"rotate":{let K=J[0]!==void 0?J[0]:0,Q=Z(K).mul(Z(Math.PI)).div(180);if(J.length>=3){if(J[1]===void 0||J[2]===void 0||!isFinite(J[1])||!isFinite(J[2]))return console.warn("parseTransformFunction: rotate(angle, cx, cy) has invalid cx or cy, using origin rotation"),O6(Q);let H=J[1],z=J[2];return q5(Q,H,z)}return O6(Q)}case"skewx":{let K=J[0]!==void 0?J[0]:0,Q=Z(K).mul(Z(Math.PI)).div(180),H=k.tan(Q);return N9(H,0)}case"skewy":{let K=J[0]!==void 0?J[0]:0,Q=Z(K).mul(Z(Math.PI)).div(180),H=k.tan(Q);return N9(0,H)}case"matrix":{if(J.length<6)return console.warn(`parseTransformFunction: matrix() requires 6 arguments, got ${J.length}`),M0.identity(3);let[K,Q,H,z,q,W]=J.slice(0,6).map((j)=>Z(j!==void 0?j:0));return M0.from([[K,H,q],[Q,z,W],[Z(0),Z(0),Z(1)]])}default:return console.warn(`Unknown transform function: ${$}`),M0.identity(3)}}function $7($){if(!$||$.trim()==="")return M0.identity(3);let J=/(\w+)\s*\(([^)]*)\)/g,Z,K=M0.identity(3);while((Z=J.exec($))!==null){let Q=Z[1],z=Z[2].split(/[\s,]+/).filter((W)=>W.length>0).map((W)=>{let j=parseFloat(W);if(isNaN(j))return console.warn(`parseTransformAttribute: invalid numeric argument "${W}" in ${Q}(), using 0`),0;return j}),q=vQ(Q,z);K=K.mul(q)}return K}function O7($,J,Z){if(!$||!$.data||!Array.isArray($.data))throw new Error("applyToPoint: invalid CTM matrix");let K=(z)=>new k(z);try{let z=K(J),q=K(Z);if(!z.isFinite()||!q.isFinite())throw new Error("applyToPoint: coordinates must be finite")}catch(z){throw new Error(`applyToPoint: invalid coordinates - ${z.message}`)}let[Q,H]=c0($,J,Z);return{x:Q,y:H}}function V5($,J=6){if(!$||!$.data||!Array.isArray($.data)||$.data.length<3||!Array.isArray($.data[0])||!Array.isArray($.data[1])||$.data[0].length<3||$.data[1].length<3)throw new Error("toSVGMatrix: invalid CTM matrix structure");let Z=J;if(typeof Z!=="number"||Z<0||Z>20)console.warn("toSVGMatrix: invalid precision, using default 6"),Z=6;try{let K=$.data[0][0].toFixed(Z),Q=$.data[1][0].toFixed(Z),H=$.data[0][1].toFixed(Z),z=$.data[1][1].toFixed(Z),q=$.data[0][2].toFixed(Z),W=$.data[1][2].toFixed(Z);return`matrix(${K}, ${Q}, ${H}, ${z}, ${q}, ${W})`}catch(K){throw new Error(`toSVGMatrix: invalid matrix elements - ${K.message}`)}}function Y6($,J,Z={}){if(!$||typeof $!=="string")return console.warn("transformPathData: invalid pathData (must be string)"),"";if(!J||!J.data)return console.warn("transformPathData: invalid CTM matrix"),$;let{toAbsolute:K=!0,precision:Q=6}=Z,H=Q;if(typeof H!=="number"||H<0||H>20||!isFinite(H))console.warn("transformPathData: invalid precision, using default 6"),H=6;let z=(U)=>new k(U),q=DQ($);if(q.length===0)return"";let W=[],j=z(0),G=z(0),F=z(0),_=z(0);for(let{cmd:U,args:O}of q){let V=U===U.toLowerCase();switch(U.toUpperCase()){case"M":{let Y=[];if(O.length%2!==0)console.warn(`transformPathData: M command has ${O.length} args, expected multiple of 2`);for(let X=0;X+1<O.length;X+=2){let w=z(O[X]),R=z(O[X+1]);if(V)w=w.plus(j),R=R.plus(G);let I=O7(J,w,R);if(Y.push(I.x.toFixed(H),I.y.toFixed(H)),j=w,G=R,X===0)F=w,_=R}W.push((K?"M":U)+" "+Y.join(" "));break}case"L":{let Y=[];if(O.length%2!==0)console.warn(`transformPathData: L command has ${O.length} args, expected multiple of 2`);for(let X=0;X+1<O.length;X+=2){let w=z(O[X]),R=z(O[X+1]);if(V)w=w.plus(j),R=R.plus(G);let I=O7(J,w,R);Y.push(I.x.toFixed(H),I.y.toFixed(H)),j=w,G=R}W.push((K?"L":U)+" "+Y.join(" "));break}case"H":{if(O.length<1){console.warn("transformPathData: H command requires at least 1 argument");break}for(let Y=0;Y<O.length;Y++){let X=z(O[Y]);if(V)X=X.plus(j);let R=O7(J,X,G);W.push("L "+R.x.toFixed(H)+" "+R.y.toFixed(H)),j=X}break}case"V":{if(O.length<1){console.warn("transformPathData: V command requires at least 1 argument");break}for(let Y=0;Y<O.length;Y++){let X=j,w=z(O[Y]);if(V)w=w.plus(G);let R=O7(J,X,w);W.push("L "+R.x.toFixed(H)+" "+R.y.toFixed(H)),G=w}break}case"C":{let Y=[];if(O.length%6!==0)console.warn(`transformPathData: C command has ${O.length} args, expected multiple of 6`);for(let X=0;X+5<O.length;X+=6){let w=z(O[X]),R=z(O[X+1]),I=z(O[X+2]),b=z(O[X+3]),u=z(O[X+4]),m=z(O[X+5]);if(V)w=w.plus(j),R=R.plus(G),I=I.plus(j),b=b.plus(G),u=u.plus(j),m=m.plus(G);let S=O7(J,w,R),x=O7(J,I,b),h=O7(J,u,m);Y.push(S.x.toFixed(H),S.y.toFixed(H),x.x.toFixed(H),x.y.toFixed(H),h.x.toFixed(H),h.y.toFixed(H)),j=u,G=m}W.push((K?"C":U)+" "+Y.join(" "));break}case"S":{let Y=[];if(O.length%4!==0)console.warn(`transformPathData: S command has ${O.length} args, expected multiple of 4`);for(let X=0;X+3<O.length;X+=4){let w=z(O[X]),R=z(O[X+1]),I=z(O[X+2]),b=z(O[X+3]);if(V)w=w.plus(j),R=R.plus(G),I=I.plus(j),b=b.plus(G);let u=O7(J,w,R),m=O7(J,I,b);Y.push(u.x.toFixed(H),u.y.toFixed(H),m.x.toFixed(H),m.y.toFixed(H)),j=I,G=b}W.push((K?"S":U)+" "+Y.join(" "));break}case"Q":{let Y=[];if(O.length%4!==0)console.warn(`transformPathData: Q command has ${O.length} args, expected multiple of 4`);for(let X=0;X+3<O.length;X+=4){let w=z(O[X]),R=z(O[X+1]),I=z(O[X+2]),b=z(O[X+3]);if(V)w=w.plus(j),R=R.plus(G),I=I.plus(j),b=b.plus(G);let u=O7(J,w,R),m=O7(J,I,b);Y.push(u.x.toFixed(H),u.y.toFixed(H),m.x.toFixed(H),m.y.toFixed(H)),j=I,G=b}W.push((K?"Q":U)+" "+Y.join(" "));break}case"T":{let Y=[];if(O.length%2!==0)console.warn(`transformPathData: T command has ${O.length} args, expected multiple of 2`);for(let X=0;X+1<O.length;X+=2){let w=z(O[X]),R=z(O[X+1]);if(V)w=w.plus(j),R=R.plus(G);let I=O7(J,w,R);Y.push(I.x.toFixed(H),I.y.toFixed(H)),j=w,G=R}W.push((K?"T":U)+" "+Y.join(" "));break}case"A":{let Y=[];if(O.length%7!==0)console.warn(`transformPathData: Arc command has ${O.length} args, expected multiple of 7`);for(let X=0;X+6<O.length;X+=7){let w=O[X],R=O[X+1],I=O[X+2],b=O[X+3],u=O[X+4],m=z(O[X+5]),S=z(O[X+6]);if(V)m=m.plus(j),S=S.plus(G);let x=SQ(w,R,I,b,u,m.toNumber(),S.toNumber(),J);Y.push(x.rx.toFixed(H),x.ry.toFixed(H),x.xAxisRotation.toFixed(H),x.largeArcFlag,x.sweepFlag,x.x.toFixed(H),x.y.toFixed(H)),j=m,G=S}W.push((K?"A":U)+" "+Y.join(" "));break}case"Z":{W.push("Z"),j=F,G=_;break}default:W.push(U+" "+O.join(" "))}}return W.join(" ")}function DQ($){if(!$||typeof $!=="string")return[];let J=[],Z=/([MmLlHhVvCcSsQqTtAaZz])([^MmLlHhVvCcSsQqTtAaZz]*)/g,K;while((K=Z.exec($))!==null){let Q=K[1],H=K[2].trim(),z=H.length>0?H.split(/[\s,]+/).filter((q)=>q.length>0).map((q)=>{let W=parseFloat(q);if(isNaN(W))return console.warn(`parsePathCommands: invalid number '${q}'`),0;return W}):[];J.push({cmd:Q,args:z})}return J}var A7={};z$(A7,{sign:()=>C9,segmentIntersection:()=>w$,reversePolygon:()=>T9,polygonUnion:()=>z6,polygonIntersection:()=>P7,polygonDifference:()=>w5,polygonArea:()=>u6,pointsEqual:()=>v7,pointOnSegment:()=>P9,pointInPolygon:()=>R7,point:()=>b0,lineSegmentIntersection:()=>k5,isCounterClockwise:()=>E9,isConvex:()=>f9,ensureCCW:()=>R$,dot:()=>X5,default:()=>xQ,cross:()=>D7,convexHull:()=>b9,clipPolygonSH:()=>A9,boundingBox:()=>h7,bboxIntersects:()=>g6});k.set({precision:80});var Y7=($)=>$ instanceof k?$:new k($),_7=new k("1e-40");function b0($,J){if($===null||$===void 0)throw new Error("point: x coordinate is required");if(J===null||J===void 0)throw new Error("point: y coordinate is required");return{x:Y7($),y:Y7(J)}}function v7($,J,Z=_7){if(!$||typeof $!=="object"||$.x===null||$.x===void 0||$.y===null||$.y===void 0)throw new Error("pointsEqual: p1 must be a point with x and y properties");if(!J||typeof J!=="object"||J.x===null||J.x===void 0||J.y===null||J.y===void 0)throw new Error("pointsEqual: p2 must be a point with x and y properties");if(!Z||typeof Z.abs!=="function")throw new Error("pointsEqual: tolerance must be a Decimal instance");return $.x.minus(J.x).abs().lt(Z)&&$.y.minus(J.y).abs().lt(Z)}function D7($,J,Z){if(!$||$.x===null||$.x===void 0||$.y===null||$.y===void 0)throw new Error("cross: origin point o must have x and y properties");if(!J||J.x===null||J.x===void 0||J.y===null||J.y===void 0)throw new Error("cross: point a must have x and y properties");if(!Z||Z.x===null||Z.x===void 0||Z.y===null||Z.y===void 0)throw new Error("cross: point b must have x and y properties");let K=J.x.minus($.x),Q=J.y.minus($.y),H=Z.x.minus($.x),z=Z.y.minus($.y);return K.mul(z).minus(Q.mul(H))}function X5($,J,Z){if(!$||$.x===null||$.x===void 0||$.y===null||$.y===void 0)throw new Error("dot: origin point o must have x and y properties");if(!J||J.x===null||J.x===void 0||J.y===null||J.y===void 0)throw new Error("dot: point a must have x and y properties");if(!Z||Z.x===null||Z.x===void 0||Z.y===null||Z.y===void 0)throw new Error("dot: point b must have x and y properties");let K=J.x.minus($.x),Q=J.y.minus($.y),H=Z.x.minus($.x),z=Z.y.minus($.y);return K.mul(H).plus(Q.mul(z))}function C9($){if($===null||$===void 0||typeof $.abs!=="function")throw new Error("sign: val must be a Decimal instance");if($.abs().lt(_7))return 0;return $.lt(0)?-1:1}function w$($,J,Z,K){if(!$||$.x===null||$.x===void 0||$.y===null||$.y===void 0)throw new Error("segmentIntersection: point a must have x and y properties");if(!J||J.x===null||J.x===void 0||J.y===null||J.y===void 0)throw new Error("segmentIntersection: point b must have x and y properties");if(!Z||Z.x===null||Z.x===void 0||Z.y===null||Z.y===void 0)throw new Error("segmentIntersection: point c must have x and y properties");if(!K||K.x===null||K.x===void 0||K.y===null||K.y===void 0)throw new Error("segmentIntersection: point d must have x and y properties");let Q=J.x.minus($.x),H=J.y.minus($.y),z=K.x.minus(Z.x),q=K.y.minus(Z.y),W=Q.mul(q).minus(H.mul(z));if(W.abs().lt(_7))return null;let j=Z.x.minus($.x),G=Z.y.minus($.y),F=j.mul(q).minus(G.mul(z)).div(W),_=j.mul(H).minus(G.mul(Q)).div(W),U=Y7(0),O=Y7(1);if(F.gte(U)&&F.lte(O)&&_.gte(U)&&_.lte(O))return{x:$.x.plus(Q.mul(F)),y:$.y.plus(H.mul(F)),t:F,s:_};return null}function k5($,J,Z,K){if(!$||$.x===null||$.x===void 0||$.y===null||$.y===void 0)throw new Error("lineSegmentIntersection: lineA must have x and y properties");if(!J||J.x===null||J.x===void 0||J.y===null||J.y===void 0)throw new Error("lineSegmentIntersection: lineB must have x and y properties");if(!Z||Z.x===null||Z.x===void 0||Z.y===null||Z.y===void 0)throw new Error("lineSegmentIntersection: segA must have x and y properties");if(!K||K.x===null||K.x===void 0||K.y===null||K.y===void 0)throw new Error("lineSegmentIntersection: segB must have x and y properties");let Q=J.x.minus($.x),H=J.y.minus($.y),z=K.x.minus(Z.x),q=K.y.minus(Z.y),W=Q.mul(q).minus(H.mul(z));if(W.abs().lt(_7))return null;let j=Z.x.minus($.x),G=Z.y.minus($.y),F=j.mul(H).minus(G.mul(Q)).div(W);if(F.gte(0)&&F.lte(1))return{x:Z.x.plus(z.mul(F)),y:Z.y.plus(q.mul(F)),s:F};return null}function R7($,J){if(!$||$.x===null||$.x===void 0||$.y===null||$.y===void 0)throw new Error("pointInPolygon: pt must have x and y properties");if(!Array.isArray(J))throw new Error("pointInPolygon: polygon must be an array");let Z=J.length;if(Z<3)return-1;for(let Q=0;Q<Z;Q++)if(!J[Q]||J[Q].x===null||J[Q].x===void 0||J[Q].y===null||J[Q].y===void 0)throw new Error(`pointInPolygon: polygon[${Q}] must have x and y properties`);let K=0;for(let Q=0;Q<Z;Q++){let H=J[Q],z=J[(Q+1)%Z];if(P9($,H,z))return 0;if(H.y.lte($.y)){if(z.y.gt($.y)){if(D7(H,z,$).gt(0))K++}}else if(z.y.lte($.y)){if(D7(H,z,$).lt(0))K--}}return K!==0?1:-1}function P9($,J,Z){if(!$||$.x===null||$.x===void 0||$.y===null||$.y===void 0)throw new Error("pointOnSegment: pt must have x and y properties");if(!J||J.x===null||J.x===void 0||J.y===null||J.y===void 0)throw new Error("pointOnSegment: segment point a must have x and y properties");if(!Z||Z.x===null||Z.x===void 0||Z.y===null||Z.y===void 0)throw new Error("pointOnSegment: segment point b must have x and y properties");if(D7(J,Z,$).abs().gt(_7))return!1;let Q=k.min(J.x,Z.x),H=k.max(J.x,Z.x),z=k.min(J.y,Z.y),q=k.max(J.y,Z.y);return $.x.gte(Q.minus(_7))&&$.x.lte(H.plus(_7))&&$.y.gte(z.minus(_7))&&$.y.lte(q.plus(_7))}function A9($,J){if(!Array.isArray($))throw new Error("clipPolygonSH: subject must be an array");if(!Array.isArray(J))throw new Error("clipPolygonSH: clip must be an array");if($.length<3||J.length<3)return[];for(let Q=0;Q<$.length;Q++)if(!$[Q]||$[Q].x===null||$[Q].x===void 0||$[Q].y===null||$[Q].y===void 0)throw new Error(`clipPolygonSH: subject[${Q}] must have x and y properties`);for(let Q=0;Q<J.length;Q++)if(!J[Q]||J[Q].x===null||J[Q].x===void 0||J[Q].y===null||J[Q].y===void 0)throw new Error(`clipPolygonSH: clip[${Q}] must have x and y properties`);let Z=$.map((Q)=>b0(Q.x,Q.y)),K=J.map((Q)=>b0(Q.x,Q.y));K=R$(K);for(let Q=0;Q<K.length;Q++){if(Z.length===0)return[];let H=K[Q],z=K[(Q+1)%K.length],q=Z;Z=[];for(let W=0;W<q.length;W++){let j=q[W],G=q[(W+q.length-1)%q.length],F=O5(j,H,z),_=O5(G,H,z);if(F){if(!_){let U=Y5(G,j,H,z);if(U)Z.push(U)}Z.push(j)}else if(_){let U=Y5(G,j,H,z);if(U)Z.push(U)}}}return Z}function O5($,J,Z){if(!$||$.x===null||$.x===void 0||$.y===null||$.y===void 0)throw new Error("isInsideEdge: pt must have x and y properties");if(!J||J.x===null||J.x===void 0||J.y===null||J.y===void 0)throw new Error("isInsideEdge: edgeStart must have x and y properties");if(!Z||Z.x===null||Z.x===void 0||Z.y===null||Z.y===void 0)throw new Error("isInsideEdge: edgeEnd must have x and y properties");return D7(J,Z,$).gte(0)}function Y5($,J,Z,K){if(!$||$.x===null||$.x===void 0||$.y===null||$.y===void 0)throw new Error("lineIntersection: point a must have x and y properties");if(!J||J.x===null||J.x===void 0||J.y===null||J.y===void 0)throw new Error("lineIntersection: point b must have x and y properties");if(!Z||Z.x===null||Z.x===void 0||Z.y===null||Z.y===void 0)throw new Error("lineIntersection: point c must have x and y properties");if(!K||K.x===null||K.x===void 0||K.y===null||K.y===void 0)throw new Error("lineIntersection: point d must have x and y properties");let Q=J.x.minus($.x),H=J.y.minus($.y),z=K.x.minus(Z.x),q=K.y.minus(Z.y),W=Q.mul(q).minus(H.mul(z));if(W.abs().lt(_7))return null;let j=Z.x.minus($.x),G=Z.y.minus($.y),F=j.mul(q).minus(G.mul(z)).div(W);return{x:$.x.plus(Q.mul(F)),y:$.y.plus(H.mul(F))}}function u6($){if(!Array.isArray($))throw new Error("polygonArea: polygon must be an array");let J=$.length;if(J<3)return Y7(0);for(let K=0;K<J;K++)if(!$[K]||$[K].x===null||$[K].x===void 0||$[K].y===null||$[K].y===void 0)throw new Error(`polygonArea: polygon[${K}] must have x and y properties`);let Z=Y7(0);for(let K=0;K<J;K++){let Q=$[K],H=$[(K+1)%J];Z=Z.plus(Q.x.mul(H.y).minus(H.x.mul(Q.y)))}return Z.div(2)}function E9($){if(!Array.isArray($))throw new Error("isCounterClockwise: polygon must be an array");return u6($).gt(0)}function T9($){if(!Array.isArray($))throw new Error("reversePolygon: polygon must be an array");return[...$].reverse()}function R$($){if(!Array.isArray($))throw new Error("ensureCCW: polygon must be an array");if(!E9($))return T9($);return $}function b9($){if(!Array.isArray($))throw new Error("convexHull: points must be an array");if($.length<3){for(let z=0;z<$.length;z++)if(!$[z]||$[z].x===null||$[z].x===void 0||$[z].y===null||$[z].y===void 0)throw new Error(`convexHull: points[${z}] must have x and y properties`);return $.map((z)=>b0(z.x,z.y))}for(let z=0;z<$.length;z++)if(!$[z]||$[z].x===null||$[z].x===void 0||$[z].y===null||$[z].y===void 0)throw new Error(`convexHull: points[${z}] must have x and y properties`);let J=$.map((z)=>b0(z.x,z.y)),Z=0;for(let z=1;z<J.length;z++)if(J[z].y.lt(J[Z].y)||J[z].y.eq(J[Z].y)&&J[z].x.lt(J[Z].x))Z=z;[J[0],J[Z]]=[J[Z],J[0]];let K=J[0],Q=J.slice(1).sort((z,q)=>{let W=D7(K,z,q);if(W.abs().lt(_7)){let G=z.x.minus(K.x).pow(2).plus(z.y.minus(K.y).pow(2)),F=q.x.minus(K.x).pow(2).plus(q.y.minus(K.y).pow(2)),_=G.minus(F);if(_.abs().lt(_7))return 0;return _.lt(0)?-1:1}return-C9(W)}),H=[K];for(let z of Q){while(H.length>1&&D7(H[H.length-2],H[H.length-1],z).lte(0))H.pop();H.push(z)}return H}function h7($){if(!Array.isArray($))throw new Error("boundingBox: polygon must be an array");if($.length===0)return null;if(!$[0]||$[0].x===null||$[0].x===void 0||$[0].y===null||$[0].y===void 0)throw new Error("boundingBox: polygon[0] must have x and y properties");let J=Y7($[0].x),Z=Y7($[0].y),K=Y7($[0].x),Q=Y7($[0].y);for(let H=0;H<$.length;H++){let z=$[H];if(!z||z.x===null||z.x===void 0||z.y===null||z.y===void 0)throw new Error(`boundingBox: polygon[${H}] must have x and y properties`);let q=Y7(z.x),W=Y7(z.y);if(q.lt(J))J=q;if(W.lt(Z))Z=W;if(q.gt(K))K=q;if(W.gt(Q))Q=W}return{minX:J,minY:Z,maxX:K,maxY:Q}}function g6($,J){if(!$||!J)return!1;if($.minX===null||$.minX===void 0||$.minY===null||$.minY===void 0||$.maxX===null||$.maxX===void 0||$.maxY===null||$.maxY===void 0)throw new Error("bboxIntersects: bb1 must have minX, minY, maxX, maxY properties");if(J.minX===null||J.minX===void 0||J.minY===null||J.minY===void 0||J.maxX===null||J.maxX===void 0||J.maxY===null||J.maxY===void 0)throw new Error("bboxIntersects: bb2 must have minX, minY, maxX, maxY properties");return!($.maxX.lt(J.minX)||J.maxX.lt($.minX)||$.maxY.lt(J.minY)||J.maxY.lt($.minY))}function P7($,J){if(!Array.isArray($))throw new Error("polygonIntersection: subject must be an array");if(!Array.isArray(J))throw new Error("polygonIntersection: clip must be an array");for(let z=0;z<$.length;z++)if(!$[z]||$[z].x===null||$[z].x===void 0||$[z].y===null||$[z].y===void 0)throw new Error(`polygonIntersection: subject[${z}] must have x and y properties`);for(let z=0;z<J.length;z++)if(!J[z]||J[z].x===null||J[z].x===void 0||J[z].y===null||J[z].y===void 0)throw new Error(`polygonIntersection: clip[${z}] must have x and y properties`);let Z=$.map((z)=>b0(z.x,z.y)),K=J.map((z)=>b0(z.x,z.y)),Q=h7(Z),H=h7(K);if(!g6(Q,H))return[];if(f9(K)){let z=A9(Z,R$(K));return z.length>=3?[z]:[]}return hQ(Z,K)}function f9($){if(!Array.isArray($))throw new Error("isConvex: polygon must be an array");let J=$.length;if(J<3)return!1;for(let K=0;K<J;K++)if(!$[K]||$[K].x===null||$[K].x===void 0||$[K].y===null||$[K].y===void 0)throw new Error(`isConvex: polygon[${K}] must have x and y properties`);let Z=0;for(let K=0;K<J;K++){let Q=$[K],H=$[(K+1)%J],z=$[(K+2)%J],q=D7(Q,H,z),W=q.gt(0)?1:q.lt(0)?-1:0;if(W!==0){if(Z===0)Z=W;else if(Z!==W)return!1}}return!0}function hQ($,J){if(!Array.isArray($)||!Array.isArray(J))throw new Error("generalPolygonIntersection: both arguments must be arrays");let Z=[];for(let W=0;W<$.length;W++){let j=$[W],G=$[(W+1)%$.length];for(let F=0;F<J.length;F++){let _=J[F],U=J[(F+1)%J.length],O=w$(j,G,_,U);if(O)Z.push(b0(O.x,O.y))}}let K=$.filter((W)=>R7(W,J)>=0),Q=J.filter((W)=>R7(W,$)>=0),H=[...Z,...K,...Q];if(H.length<3)return[];let z=yQ(H);if(z.length<3)return[];let q=b9(z);return q.length>=3?[q]:[]}function yQ($){if(!Array.isArray($))throw new Error("removeDuplicatePoints: points must be an array");let J=[];for(let Z of $){let K=!1;for(let Q of J)if(v7(Z,Q)){K=!0;break}if(!K)J.push(Z)}return J}function z6($,J){if(!Array.isArray($))throw new Error("polygonUnion: polygon1 must be an array");if(!Array.isArray(J))throw new Error("polygonUnion: polygon2 must be an array");for(let z=0;z<$.length;z++)if(!$[z]||$[z].x===null||$[z].x===void 0||$[z].y===null||$[z].y===void 0)throw new Error(`polygonUnion: polygon1[${z}] must have x and y properties`);for(let z=0;z<J.length;z++)if(!J[z]||J[z].x===null||J[z].x===void 0||J[z].y===null||J[z].y===void 0)throw new Error(`polygonUnion: polygon2[${z}] must have x and y properties`);let Z=$.map((z)=>b0(z.x,z.y)),K=J.map((z)=>b0(z.x,z.y)),Q=h7(Z),H=h7(K);if(!g6(Q,H))return[Z,K];return uQ(Z,K)}function uQ($,J){if(!Array.isArray($)||!Array.isArray(J))throw new Error("traceBoundaryUnion: both arguments must be arrays");let Z=L5($,J);if(Z.length===0){let V=R7($[0],J),M=R7(J[0],$);if(V>0)return[J];else if(M>0)return[$];else return[$,J]}let K=L$($,Z.map((V)=>({edgeIndex:V.edge1,t:V.t1,point:V.point,intersectionId:V.id}))),Q=L$(J,Z.map((V)=>({edgeIndex:V.edge2,t:V.t2,point:V.point,intersectionId:V.id}))),H=new Map;for(let V=0;V<K.length;V++)if(K[V].intersectionId!==void 0){if(!H.has(K[V].intersectionId))H.set(K[V].intersectionId,{});H.get(K[V].intersectionId).idx1=V}for(let V=0;V<Q.length;V++)if(Q[V].intersectionId!==void 0){if(!H.has(Q[V].intersectionId))H.set(Q[V].intersectionId,{});H.get(Q[V].intersectionId).idx2=V}let z=1,q=-1;for(let V=0;V<K.length;V++){let M=K[V];if(M.intersectionId===void 0&&R7(M,J)<0){q=V;break}}if(q===-1){z=2;for(let V=0;V<Q.length;V++){let M=Q[V];if(M.intersectionId===void 0&&R7(M,$)<0){q=V;break}}}if(q===-1){let V=u6($).abs(),M=u6(J).abs();return V.gt(M)?[$]:[J]}let W=[],j=z===1,G=q,F=new Set,_=(K.length+Q.length)*3,U=0,O=`${z}-${q}`;while(U<_){U++;let V=j?K:Q,M=j?Q:K,Y=V[G];if(W.length===0||!v7(W[W.length-1],Y))W.push(b0(Y.x,Y.y));let X=(G+1)%V.length,w=V[X];if(w.intersectionId!==void 0&&!F.has(w.intersectionId)){W.push(b0(w.x,w.y)),F.add(w.intersectionId);let I=H.get(w.intersectionId),b=j?I.idx2:I.idx1;j=!j,G=(b+1)%M.length}else G=X;if(`${j?1:2}-${G}`===O)break}if(W.length>1&&v7(W[0],W[W.length-1]))W.pop();return W.length>=3?[W]:[]}function L5($,J){if(!Array.isArray($)||!Array.isArray(J))throw new Error("findAllIntersections: both arguments must be arrays");let Z=[],K=0;for(let Q=0;Q<$.length;Q++){let H=$[Q],z=$[(Q+1)%$.length];for(let q=0;q<J.length;q++){let W=J[q],j=J[(q+1)%J.length],G=w$(H,z,W,j);if(G)Z.push({id:K++,point:b0(G.x,G.y),edge1:Q,edge2:q,t1:G.t,t2:G.s})}}return Z}function L$($,J){if(!Array.isArray($))throw new Error("augmentPolygon: polygon must be an array");if(!Array.isArray(J))throw new Error("augmentPolygon: insertions must be an array");let Z=new Map;for(let Q of J){if(!Z.has(Q.edgeIndex))Z.set(Q.edgeIndex,[]);Z.get(Q.edgeIndex).push(Q)}for(let Q of Z.values())Q.sort((H,z)=>H.t.minus(z.t).toNumber());let K=[];for(let Q=0;Q<$.length;Q++)if(K.push({...$[Q]}),Z.has(Q))for(let H of Z.get(Q))K.push({x:H.point.x,y:H.point.y,intersectionId:H.intersectionId});return K}function w5($,J){if(!Array.isArray($))throw new Error("polygonDifference: polygon1 must be an array");if(!Array.isArray(J))throw new Error("polygonDifference: polygon2 must be an array");for(let z=0;z<$.length;z++)if(!$[z]||$[z].x===null||$[z].x===void 0||$[z].y===null||$[z].y===void 0)throw new Error(`polygonDifference: polygon1[${z}] must have x and y properties`);for(let z=0;z<J.length;z++)if(!J[z]||J[z].x===null||J[z].x===void 0||J[z].y===null||J[z].y===void 0)throw new Error(`polygonDifference: polygon2[${z}] must have x and y properties`);let Z=$.map((z)=>b0(z.x,z.y)),K=J.map((z)=>b0(z.x,z.y)),Q=h7(Z),H=h7(K);if(!g6(Q,H))return[Z];return gQ(Z,K)}function gQ($,J){if(!Array.isArray($)||!Array.isArray(J))throw new Error("traceBoundaryDifference: both arguments must be arrays");let Z=L5($,J);if(Z.length===0)if(R7($[0],J)>0)return[];else return[$];let K=L$($,Z.map((U)=>({edgeIndex:U.edge1,t:U.t1,point:U.point,intersectionId:U.id}))),Q=L$(J,Z.map((U)=>({edgeIndex:U.edge2,t:U.t2,point:U.point,intersectionId:U.id}))),H=new Map;for(let U=0;U<K.length;U++)if(K[U].intersectionId!==void 0){if(!H.has(K[U].intersectionId))H.set(K[U].intersectionId,{});H.get(K[U].intersectionId).idx1=U}for(let U=0;U<Q.length;U++)if(Q[U].intersectionId!==void 0){if(!H.has(Q[U].intersectionId))H.set(Q[U].intersectionId,{});H.get(Q[U].intersectionId).idx2=U}let z=-1;for(let U=0;U<K.length;U++){let O=K[U];if(O.intersectionId===void 0&&R7(O,J)<0){z=U;break}}if(z===-1)return[];let q=[],W=!0,j=z,G=new Set,F=(K.length+Q.length)*3,_=0;while(_<F){_++;let O=(W?K:Q)[j];if(q.length===0||!v7(q[q.length-1],O))q.push(b0(O.x,O.y));let V=`${W?1:2}-${j}`;if(G.has(V))break;if(G.add(V),W){let M=(j+1)%K.length,Y=K[M];if(Y.intersectionId!==void 0){let X=K[(M+1)%K.length];if(R7(X,J)>0){let R=H.get(Y.intersectionId);q.push(b0(Y.x,Y.y)),W=!1,j=(R.idx2-1+Q.length)%Q.length}else j=M}else j=M}else{let M=(j-1+Q.length)%Q.length,Y=Q[M];if(Y.intersectionId!==void 0){let X=H.get(Y.intersectionId);q.push(b0(Y.x,Y.y)),W=!0,j=(X.idx1+1)%K.length}else j=M}if(W&&j===z)break}if(q.length>1&&v7(q[0],q[q.length-1]))q.pop();return q.length>=3?[q]:[]}var xQ={point:b0,pointsEqual:v7,cross:D7,dot:X5,sign:C9,segmentIntersection:w$,lineSegmentIntersection:k5,pointInPolygon:R7,pointOnSegment:P9,clipPolygonSH:A9,polygonArea:u6,isCounterClockwise:E9,reversePolygon:T9,ensureCCW:R$,isConvex:f9,convexHull:b9,boundingBox:h7,bboxIntersects:g6,polygonIntersection:P7,polygonUnion:z6,polygonDifference:w5,EPSILON:_7};k.set({precision:80});var B$=($)=>$ instanceof k?$:new k($),y7=new k("1e-40"),{point:s7,cross:S9,polygonIntersection:pq,polygonUnion:cq,polygonDifference:lq}=A7,o7={NONZERO:"nonzero",EVENODD:"evenodd"};function N$($,J,Z=o7.NONZERO){if(!$||typeof $!=="object")throw new Error("pointInPolygonWithRule: pt must be an object with x, y properties");if($.x===void 0||$.x===null||$.y===void 0||$.y===null)throw new Error("pointInPolygonWithRule: pt must have x and y properties");if(!Array.isArray(J))throw new Error("pointInPolygonWithRule: polygon must be an array");let K=J.length;if(K<3)return-1;let Q=0;for(let H=0;H<K;H++){let z=J[H],q=J[(H+1)%K];if(mQ($,z,q))return 0;if(z.y.lte($.y)){if(q.y.gt($.y)){if(S9(z,q,$).gt(0))Q++}}else if(q.y.lte($.y)){if(S9(z,q,$).lt(0))Q--}}if(Z===o7.EVENODD)return Math.abs(Q)%2===1?1:-1;else return Q!==0?1:-1}function mQ($,J,Z){if(!$||!J||!Z)throw new Error("pointOnSegment: pt, a, and b must be defined");if($.x===void 0||$.x===null||$.y===void 0||$.y===null||J.x===void 0||J.x===null||J.y===void 0||J.y===null||Z.x===void 0||Z.x===null||Z.y===void 0||Z.y===null)throw new Error("pointOnSegment: all points must have x and y properties");if(S9(J,Z,$).abs().gt(y7))return!1;let Q=k.min(J.x,Z.x),H=k.max(J.x,Z.x),z=k.min(J.y,Z.y),q=k.max(J.y,Z.y);return $.x.gte(Q.minus(y7))&&$.x.lte(H.plus(y7))&&$.y.gte(z.minus(y7))&&$.y.lte(q.plus(y7))}function dQ($,J,Z={}){if(!Array.isArray($))throw new Error("offsetPolygon: polygon must be an array");if(J===void 0||J===null)throw new Error("offsetPolygon: distance must be defined");if(!Z||typeof Z!=="object")throw new Error("offsetPolygon: options must be an object");let K=B$(J);if(K.lte(0))throw new Error("offsetPolygon: distance must be positive");let Q=Z.linejoin||"miter",H=B$(Z.miterLimit||4);if($.length<3)return{outer:[],inner:[]};let z=$.length,q=[],W=[];for(let j=0;j<z;j++){let G=$[(j-1+z)%z],F=$[j],_=$[(j+1)%z],U=F.x.minus(G.x),O=F.y.minus(G.y),V=_.x.minus(F.x),M=_.y.minus(F.y),Y=U.pow(2).plus(O.pow(2)).sqrt(),X=V.pow(2).plus(M.pow(2)).sqrt();if(Y.lt(y7)||X.lt(y7))continue;let w=O.div(Y),R=U.neg().div(Y),I=M.div(X),b=V.neg().div(X),u=w.plus(I).div(2),m=R.plus(b).div(2),S=u.pow(2).plus(m.pow(2)).sqrt();if(S.lt(y7))u=w,m=R;else u=u.div(S),m=m.div(S);let x=w.times(I).plus(R.times(b)),h=B$(1).minus(x).div(2).sqrt(),E=K;if(h.gt(y7)){let d=K.div(h);if(Q==="miter"&&d.lte(K.times(H)))E=d;else if(Q==="bevel"||d.gt(K.times(H))){let c=s7(F.x.plus(w.times(K)),F.y.plus(R.times(K))),p=s7(F.x.plus(I.times(K)),F.y.plus(b.times(K)));q.push(c,p);let N=s7(F.x.minus(w.times(K)),F.y.minus(R.times(K))),y=s7(F.x.minus(I.times(K)),F.y.minus(b.times(K)));W.push(N,y);continue}else if(Q==="round"){let c=Math.atan2(R.toNumber(),w.toNumber()),N=Math.atan2(b.toNumber(),I.toNumber())-c;if(N<-Math.PI)N+=2*Math.PI;if(N>Math.PI)N-=2*Math.PI;let y=Math.max(2,Math.ceil(Math.abs(N)/(Math.PI/8)));for(let B=0;B<=y;B++){let e=c+N*(B/y);q.push(s7(F.x.plus(K.times(Math.cos(e))),F.y.plus(K.times(Math.sin(e))))),W.push(s7(F.x.minus(K.times(Math.cos(e))),F.y.minus(K.times(Math.sin(e)))))}continue}}q.push(s7(F.x.plus(u.times(E)),F.y.plus(m.times(E)))),W.push(s7(F.x.minus(u.times(E)),F.y.minus(m.times(E))))}return{outer:q,inner:W.reverse()}}function v9($,J){if(!Array.isArray($))throw new Error("strokeToFilledPolygon: polygon must be an array");if(!J||typeof J!=="object")throw new Error("strokeToFilledPolygon: strokeProps must be an object");if(J.width===void 0||J.width===null)throw new Error("strokeToFilledPolygon: strokeProps must have width property");let Z=B$(J.width).div(2);if(Z.lte(0))throw new Error("strokeToFilledPolygon: width must be positive");return dQ($,Z,J).outer}k.set({precision:80});var E7=($)=>$ instanceof k?$:new k($),pQ={fill:"black","fill-rule":"nonzero","fill-opacity":1,stroke:"none","stroke-width":1,"stroke-linecap":"butt","stroke-linejoin":"miter","stroke-miterlimit":4,"stroke-dasharray":"none","stroke-dashoffset":0,"stroke-opacity":1,"marker-start":"none","marker-mid":"none","marker-end":"none","paint-order":"normal","clip-path":"none","clip-rule":"nonzero",mask:"none","mask-type":"luminance",opacity:1,transform:"none","vector-effect":"none",filter:"none"};class I${constructor($,J={},Z=null){if(!$)throw new Error("SVGRenderingContext: element parameter is required");if(J!==null&&typeof J!=="object")throw new Error("SVGRenderingContext: inherited must be an object or null");this.element=$,this.defsMap=Z||new Map,this.properties=this._extractProperties($,J||{}),this.dashArray=this._parseDashArray(this.properties["stroke-dasharray"]),this.dashOffset=E7(this.properties["stroke-dashoffset"]||0),this.markers={start:this._parseMarkerRef(this.properties["marker-start"]),mid:this._parseMarkerRef(this.properties["marker-mid"]),end:this._parseMarkerRef(this.properties["marker-end"])},this.hasFill=this.properties.fill!=="none"&&this.properties["fill-opacity"]>0,this.hasStroke=this.properties.stroke!=="none"&&E7(this.properties["stroke-width"]).gt(0)&&this.properties["stroke-opacity"]>0,this.hasMarkers=this.markers.start||this.markers.mid||this.markers.end}_extractProperties($,J){if(J!==null&&typeof J!=="object")throw new Error("_extractProperties: inherited must be an object or null");let Z={...pQ,...J||{}};if($&&$.getAttributeNames)for(let Q of $.getAttributeNames()){let H=$.getAttribute(Q);if(H!==null&&H!==void 0)Z[Q]=H}if(Z.style){let Q=this._parseStyleAttribute(Z.style);Object.assign(Z,Q)}let K=["stroke-width","stroke-miterlimit","stroke-dashoffset","opacity","fill-opacity","stroke-opacity"];for(let Q of K)if(typeof Z[Q]==="string"){let H=parseFloat(Z[Q]);if(!isNaN(H))Z[Q]=H}return Z}_parseStyleAttribute($){let J={};if(!$)return J;let Z=$.split(";");for(let K of Z){if(!K.includes(":"))continue;let[Q,H]=K.split(":").map((z)=>z.trim());if(Q&&H)J[Q]=H}return J}_parseDashArray($){if(!$||$==="none")return null;let J=$.toString().split(/[\s,]+/).filter((K)=>K),Z=[];for(let K of J){let Q=parseFloat(K);if(isNaN(Q)||!isFinite(Q))throw new Error(`_parseDashArray: invalid dash value '${K}'`);if(Q<0)throw new Error(`_parseDashArray: dash values must be non-negative, got ${Q}`);Z.push(E7(Q))}if(Z.length===0)return null;if(Z.length%2===1)return[...Z,...Z];return Z}_parseMarkerRef($){if(!$||$==="none")return null;let J=$.match(/url\(#?([^)]+)\)/);return J?J[1]:null}get fillRule(){return this.properties["fill-rule"]||"nonzero"}get clipRule(){return this.properties["clip-rule"]||"nonzero"}get strokeWidth(){return E7(this.properties["stroke-width"]||0)}get strokeLinecap(){return this.properties["stroke-linecap"]||"butt"}get strokeLinejoin(){return this.properties["stroke-linejoin"]||"miter"}get strokeMiterlimit(){return E7(this.properties["stroke-miterlimit"]||4)}getStrokeExtent(){if(!this.hasStroke)return E7(0);let $=this.strokeWidth.div(2),J=$;if(this.strokeLinejoin==="miter")J=$.times(this.strokeMiterlimit);if(this.strokeLinecap==="square"){let Z=$.times(2);if(Z.gt(J))J=Z}return J}expandBBoxForStroke($){if(!$||typeof $!=="object")throw new Error("expandBBoxForStroke: bbox must be an object");if(!("x"in $)||!("y"in $)||!("width"in $)||!("height"in $))throw new Error("expandBBoxForStroke: bbox must have x, y, width, height properties");if(typeof $.x.minus!=="function"||typeof $.y.minus!=="function"||typeof $.width.plus!=="function"||typeof $.height.plus!=="function")throw new Error("expandBBoxForStroke: bbox properties must be Decimal instances");if(!this.hasStroke)return $;let J=this.getStrokeExtent();return{x:$.x.minus(J),y:$.y.minus(J),width:$.width.plus(J.times(2)),height:$.height.plus(J.times(2))}}expandBBoxForMarkers($,J=null){if(!$||typeof $!=="object")throw new Error("expandBBoxForMarkers: bbox must be an object");if(!("x"in $)||!("y"in $)||!("width"in $)||!("height"in $))throw new Error("expandBBoxForMarkers: bbox must have x, y, width, height properties");if(typeof $.x.minus!=="function"||typeof $.y.minus!=="function"||typeof $.width.plus!=="function"||typeof $.height.plus!=="function")throw new Error("expandBBoxForMarkers: bbox properties must be Decimal instances");if(!this.hasMarkers)return $;let Z=E7(0);if(J){if(typeof J!=="object")throw new Error("expandBBoxForMarkers: markerSizes must be an object");let Q=[J.start,J.mid,J.end].filter((H)=>H!==null&&H!==void 0).map((H)=>{let z=typeof H==="number"?H:parseFloat(H);if(isNaN(z)||!isFinite(z))throw new Error(`expandBBoxForMarkers: invalid marker size '${H}'`);return E7(z)});if(Q.length>0)Z=k.max(...Q)}else Z=this.strokeWidth.times(3);if(Z.lte(0))return $;let K=Z.div(2);return{x:$.x.minus(K),y:$.y.minus(K),width:$.width.plus(K.times(2)),height:$.height.plus(K.times(2))}}expandBBoxForFilter($,J=null){if(!$||typeof $!=="object")throw new Error("expandBBoxForFilter: bbox must be an object");if(!("x"in $)||!("y"in $)||!("width"in $)||!("height"in $))throw new Error("expandBBoxForFilter: bbox must have x, y, width, height properties");if(typeof $.x.minus!=="function"||typeof $.y.minus!=="function"||typeof $.width.times!=="function"||typeof $.height.times!=="function")throw new Error("expandBBoxForFilter: bbox properties must be Decimal instances");let Z=this.properties.filter;if(!Z||Z==="none")return $;let K=$.width.times("0.1"),Q=$.height.times("0.1");if(J){if(typeof J!=="object")throw new Error("expandBBoxForFilter: filterDef must be an object");if(J.x!==void 0){let H=parseFloat(J.x);if(isNaN(H)||!isFinite(H))throw new Error(`expandBBoxForFilter: invalid filterDef.x value '${J.x}'`);K=E7(H).abs()}if(J.y!==void 0){let H=parseFloat(J.y);if(isNaN(H)||!isFinite(H))throw new Error(`expandBBoxForFilter: invalid filterDef.y value '${J.y}'`);Q=E7(H).abs()}}return{x:$.x.minus(K),y:$.y.minus(Q),width:$.width.plus(K.times(2)),height:$.height.plus(Q.times(2))}}getRenderedBBox($,J={}){if(!$||typeof $!=="object")throw new Error("getRenderedBBox: geometryBBox must be an object");if(!("x"in $)||!("y"in $)||!("width"in $)||!("height"in $))throw new Error("getRenderedBBox: geometryBBox must have x, y, width, height properties");if(typeof $.x.minus!=="function"||typeof $.y.minus!=="function")throw new Error("getRenderedBBox: geometryBBox properties must be Decimal instances");if(J!==null&&typeof J!=="object")throw new Error("getRenderedBBox: options must be an object or null");let Z={...$};return Z=this.expandBBoxForStroke(Z),Z=this.expandBBoxForMarkers(Z,J.markerSizes),Z=this.expandBBoxForFilter(Z,J.filterDef),Z}getFilledArea($){if(!Array.isArray($))throw new Error("getFilledArea: polygon must be an array");if($.length===0)throw new Error("getFilledArea: polygon must not be empty");let J=[];if(this.hasFill)J.push({polygon:$,fillRule:this.fillRule,type:"fill"});if(this.hasStroke){let Z=v9($,{width:this.strokeWidth.toNumber(),linecap:this.strokeLinecap,linejoin:this.strokeLinejoin,miterlimit:this.strokeMiterlimit.toNumber()});if(Z&&Z.length>0)J.push({polygon:Z,fillRule:"nonzero",type:"stroke"})}return J}isPointInRenderedArea($,J){if(!$||typeof $!=="object")throw new Error("isPointInRenderedArea: point must be an object");if($.x===void 0||$.y===void 0)throw new Error("isPointInRenderedArea: point must have x and y properties");if(!Array.isArray(J))throw new Error("isPointInRenderedArea: polygon must be an array");if(J.length===0)throw new Error("isPointInRenderedArea: polygon must not be empty");if(this.hasFill){let Z=this.fillRule==="evenodd"?o7.EVENODD:o7.NONZERO;if(N$($,J,Z)>=0)return!0}if(this.hasStroke){let Z=v9(J,{width:this.strokeWidth.toNumber(),linecap:this.strokeLinecap,linejoin:this.strokeLinejoin,miterlimit:this.strokeMiterlimit.toNumber()});if(Z&&Z.length>0){if(N$($,Z,o7.NONZERO)>=0)return!0}}return!1}canMergeWith($){if(!($ instanceof I$))throw new Error("canMergeWith: other must be an instance of SVGRenderingContext");if(this.fillRule!==$.fillRule)return{canMerge:!1,reason:"Different fill-rule"};if(this.hasStroke||$.hasStroke){if(this.hasStroke!==$.hasStroke)return{canMerge:!1,reason:"Different stroke presence"};if(!this.strokeWidth.eq($.strokeWidth))return{canMerge:!1,reason:"Different stroke-width"};if(this.strokeLinecap!==$.strokeLinecap)return{canMerge:!1,reason:"Different stroke-linecap"};if(this.strokeLinejoin!==$.strokeLinejoin)return{canMerge:!1,reason:"Different stroke-linejoin"}}if(this.hasMarkers||$.hasMarkers)return{canMerge:!1,reason:"Has markers"};if(this.properties["clip-path"]!=="none"||$.properties["clip-path"]!=="none")return{canMerge:!1,reason:"Has clip-path"};if(this.properties.mask!=="none"||$.properties.mask!=="none")return{canMerge:!1,reason:"Has mask"};if(this.properties.filter!=="none"||$.properties.filter!=="none")return{canMerge:!1,reason:"Has filter"};return{canMerge:!0,reason:null}}toSummary(){return{hasFill:this.hasFill,hasStroke:this.hasStroke,hasMarkers:this.hasMarkers,fillRule:this.fillRule,strokeWidth:this.hasStroke?this.strokeWidth.toNumber():0,strokeExtent:this.getStrokeExtent().toNumber(),linecap:this.strokeLinecap,linejoin:this.strokeLinejoin,clipPath:this.properties["clip-path"],filter:this.properties.filter}}}function x6($,J={},Z=null){if(!$)throw new Error("createRenderingContext: element parameter is required");return new I$($,J,Z)}function m6($){if(!$)throw new Error("getInheritedProperties: element parameter is required");let J={},Z=["fill","fill-rule","fill-opacity","stroke","stroke-width","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-dasharray","stroke-dashoffset","stroke-opacity","marker-start","marker-mid","marker-end","clip-rule","opacity","font-family","font-size","font-style","font-weight"];if(!$.parentNode)return J;let K=$.parentNode;while(K&&K.tagName){for(let Q of Z)if(J[Q]===void 0){let H=K.getAttribute?K.getAttribute(Q):null;if(H!==null&&H!==void 0)J[Q]=H}K=K.parentNode}return J}function I5($,J){if(!$||!J)throw new Error("setOwnerDocument: element and document are required");if(!$.children||!Array.isArray($.children))throw new Error("setOwnerDocument: element must have a children array");$.ownerDocument=J;for(let Z of $.children)if(Z instanceof B0)I5(Z,J)}function d0($){if(typeof $!=="string")throw new Error("parseSVG: input must be a string");if($.trim().length===0)throw new Error("parseSVG: input cannot be empty");let J=$.trim(),Z=P5(J,0);if(!Z.element)throw new Error("Failed to parse SVG: no root element found");let K=new C5(Z.element);return I5(Z.element,K),Z.element}class C5{constructor($=null){this.documentElement=$}createElement($){if(!$||typeof $!=="string")throw new Error("createElement: tagName must be a non-empty string");let J=new B0($);return J.ownerDocument=this,J}createElementNS($,J){if($!==null&&$!==void 0&&typeof $!=="string")throw new Error("createElementNS: namespace must be a string");return this.createElement(J)}}class B0{constructor($,J={},Z=[],K=""){if(!$||typeof $!=="string")throw new Error("SVGElement: tagName must be a non-empty string");if(J!==null&&typeof J!=="object")throw new Error("SVGElement: attributes must be an object");if(!Array.isArray(Z))throw new Error("SVGElement: children must be an array");if(typeof K!=="string")throw new Error("SVGElement: textContent must be a string");this.tagName=$,this.nodeName=$.toUpperCase(),this._attributes={...J},this.children=Z,this.childNodes=Z,this.textContent=K,this.parentNode=null,this.ownerDocument=null;for(let Q of Z)if(Q instanceof B0)Q.parentNode=this}getAttribute($){if(typeof $!=="string")throw new Error("getAttribute: name must be a string");return this._attributes[$]??null}setAttribute($,J){if(typeof $!=="string")throw new Error("setAttribute: name must be a string");if(J!==null&&J!==void 0)this._attributes[$]=String(J);else this._attributes[$]=""}hasAttribute($){if(typeof $!=="string")throw new Error("hasAttribute: name must be a string");return $ in this._attributes}removeAttribute($){if(typeof $!=="string")throw new Error("removeAttribute: name must be a string");delete this._attributes[$]}getAttributeNames(){return Object.keys(this._attributes)}getElementsByTagName($){if(typeof $!=="string")throw new Error("getElementsByTagName: tagName must be a string");if($.length===0)return[];let J=$.toLowerCase(),Z=[],K=(Q)=>{for(let H of Q.children)if(H instanceof B0){if(H.tagName.toLowerCase()===J||J==="*")Z.push(H);K(H)}};return K(this),Z}getElementById($){if(typeof $!=="string")throw new Error("getElementById: id must be a string");if($.length===0)return null;let J=(Z)=>{if(Z.getAttribute("id")===$)return Z;for(let K of Z.children)if(K instanceof B0){let Q=J(K);if(Q)return Q}return null};return J(this)}querySelector($){if(typeof $!=="string")throw new Error("querySelector: selector must be a string");return this.querySelectorAll($)[0]||null}querySelectorAll($){if(typeof $!=="string")throw new Error("querySelectorAll: selector must be a string");let J=[],Z=R5($),K=(Q)=>{for(let H of Q.children)if(H instanceof B0){if(B5(H,Z))J.push(H);K(H)}};return K(this),J}matches($){if(typeof $!=="string")throw new Error("matches: selector must be a string");let J=R5($);return B5(this,J)}cloneNode($=!0){if(typeof $!=="boolean")throw new Error("cloneNode: deep must be a boolean");let J=$?this.children.map((K)=>K instanceof B0?K.cloneNode(!0):K):[],Z=new B0(this.tagName,{...this._attributes},J,this.textContent);if(this.ownerDocument){let K=(Q,H)=>{Q.ownerDocument=H;for(let z of Q.children)if(z instanceof B0)K(z,H)};K(Z,this.ownerDocument)}return Z}appendChild($){if($===null||$===void 0)throw new Error("appendChild: child cannot be null or undefined");if($ instanceof B0&&$.parentNode)$.parentNode.removeChild($);if($ instanceof B0)$.parentNode=this;return this.children.push($),this.childNodes=this.children,$}removeChild($){if($===null||$===void 0)throw new Error("removeChild: child cannot be null or undefined");let J=this.children.indexOf($);if(J>=0){if(this.children.splice(J,1),this.childNodes=this.children,$ instanceof B0)$.parentNode=null}return $}insertBefore($,J){if($===null||$===void 0)throw new Error("insertBefore: newChild cannot be null or undefined");if(J===null||J===void 0)throw new Error("insertBefore: refChild cannot be null or undefined");if($ instanceof B0&&$.parentNode)$.parentNode.removeChild($);let Z=this.children.indexOf(J);if(Z>=0){if($ instanceof B0)$.parentNode=this;this.children.splice(Z,0,$),this.childNodes=this.children}else this.appendChild($);return $}replaceChild($,J){if($===null||$===void 0)throw new Error("replaceChild: newChild cannot be null or undefined");if(J===null||J===void 0)throw new Error("replaceChild: oldChild cannot be null or undefined");if($ instanceof B0&&$.parentNode)$.parentNode.removeChild($);let Z=this.children.indexOf(J);if(Z>=0){if(J instanceof B0)J.parentNode=null;if($ instanceof B0)$.parentNode=this;this.children[Z]=$,this.childNodes=this.children}return J}get style(){let $=this.getAttribute("style")||"",J={};if($.length===0)return J;return $.split(";").forEach((Z)=>{let K=Z.indexOf(":");if(K>0){let Q=Z.slice(0,K).trim(),H=Z.slice(K+1).trim();if(Q&&H)J[Q]=H}}),J}get firstChild(){return this.children[0]||null}get lastChild(){return this.children[this.children.length-1]||null}get nextSibling(){if(!this.parentNode)return null;let $=this.parentNode.children,J=$.indexOf(this);return $[J+1]||null}get previousSibling(){if(!this.parentNode)return null;let $=this.parentNode.children,J=$.indexOf(this);return J>0?$[J-1]:null}serialize($=0,J=!1){if(typeof $!=="number"||!Number.isFinite($)||$<0)throw new Error("serialize: indent must be a non-negative finite number");if(typeof J!=="boolean")throw new Error("serialize: minify must be a boolean");let Z=J?"":" ".repeat($),K=this._attributes["data-cdata-pending"]==="true",Q=Object.entries(this._attributes).filter(([j])=>j!=="data-cdata-pending").map(([j,G])=>`${j}="${cQ(G)}"`).join(" "),H=Q?" "+Q:"";if(this.children.length===0&&!this.textContent)return`${Z}<${this.tagName}${H}/>`;let z=J?"":`
9
- `,q=this.children.map((j)=>j instanceof B0?j.serialize($+1,J):C$(j)).join(z),W="";if(this.textContent&&this.children.length>0)if(K)W=`<![CDATA[
8
+ */var M6=9000000000000000,o7=1e9,G9="0123456789abcdef",F$="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",_$="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",F9={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-M6,maxE:M6,crypto:!1},mJ,D7,A0=!0,V$="[DecimalError] ",s7=V$+"Invalid argument: ",dJ=V$+"Precision limit exceeded",pJ=V$+"crypto unavailable",cJ="[object Decimal]",t0=Math.floor,c0=Math.pow,MZ=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,OZ=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,YZ=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,lJ=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,w7=1e7,w0=7,XZ=9007199254740991,LZ=F$.length-1,_9=_$.length-1,Z0={toStringTag:cJ};Z0.absoluteValue=Z0.abs=function(){var $=new this.constructor(this);if($.s<0)$.s=1;return Y0($)};Z0.ceil=function(){return Y0(new this.constructor(this),this.e+1,2)};Z0.clampedTo=Z0.clamp=function($,J){var Z,K=this,Q=K.constructor;if($=new Q($),J=new Q(J),!$.s||!J.s)return new Q(NaN);if($.gt(J))throw Error(s7+J);return Z=K.cmp($),Z<0?$:K.cmp(J)>0?J:new Q(K)};Z0.comparedTo=Z0.cmp=function($){var J,Z,K,Q,H=this,z=H.d,q=($=new H.constructor($)).d,j=H.s,W=$.s;if(!z||!q)return!j||!W?NaN:j!==W?j:z===q?0:!z^j<0?1:-1;if(!z[0]||!q[0])return z[0]?j:q[0]?-W:0;if(j!==W)return j;if(H.e!==$.e)return H.e>$.e^j<0?1:-1;K=z.length,Q=q.length;for(J=0,Z=K<Q?K:Q;J<Z;++J)if(z[J]!==q[J])return z[J]>q[J]^j<0?1:-1;return K===Q?0:K>Q^j<0?1:-1};Z0.cosine=Z0.cos=function(){var $,J,Z=this,K=Z.constructor;if(!Z.d)return new K(NaN);if(!Z.d[0])return new K(1);return $=K.precision,J=K.rounding,K.precision=$+Math.max(Z.e,Z.sd())+w0,K.rounding=1,Z=kZ(K,rJ(K,Z)),K.precision=$,K.rounding=J,Y0(D7==2||D7==3?Z.neg():Z,$,J,!0)};Z0.cubeRoot=Z0.cbrt=function(){var $,J,Z,K,Q,H,z,q,j,W,G=this,F=G.constructor;if(!G.isFinite()||G.isZero())return new F(G);if(A0=!1,H=G.s*c0(G.s*G,0.3333333333333333),!H||Math.abs(H)==1/0){if(Z=r0(G.d),$=G.e,H=($-Z.length+1)%3)Z+=H==1||H==-2?"0":"00";if(H=c0(Z,0.3333333333333333),$=t0(($+1)/3)-($%3==($<0?-1:2)),H==1/0)Z="5e"+$;else Z=H.toExponential(),Z=Z.slice(0,Z.indexOf("e")+1)+$;K=new F(Z),K.s=G.s}else K=new F(H.toString());z=($=F.precision)+3;for(;;)if(q=K,j=q.times(q).times(q),W=j.plus(G),K=D0(W.plus(G).times(q),W.plus(j),z+2,1),r0(q.d).slice(0,z)===(Z=r0(K.d)).slice(0,z))if(Z=Z.slice(z-3,z+1),Z=="9999"||!Q&&Z=="4999"){if(!Q){if(Y0(q,$+1,0),q.times(q).times(q).eq(G)){K=q;break}}z+=4,Q=1}else{if(!+Z||!+Z.slice(1)&&Z.charAt(0)=="5")Y0(K,$+1,1),J=!K.times(K).times(K).eq(G);break}return A0=!0,Y0(K,$,F.rounding,J)};Z0.decimalPlaces=Z0.dp=function(){var $,J=this.d,Z=NaN;if(J){if($=J.length-1,Z=($-t0(this.e/w0))*w0,$=J[$],$)for(;$%10==0;$/=10)Z--;if(Z<0)Z=0}return Z};Z0.dividedBy=Z0.div=function($){return D0(this,new this.constructor($))};Z0.dividedToIntegerBy=Z0.divToInt=function($){var J=this,Z=J.constructor;return Y0(D0(J,new Z($),0,1,1),Z.precision,Z.rounding)};Z0.equals=Z0.eq=function($){return this.cmp($)===0};Z0.floor=function(){return Y0(new this.constructor(this),this.e+1,3)};Z0.greaterThan=Z0.gt=function($){return this.cmp($)>0};Z0.greaterThanOrEqualTo=Z0.gte=function($){var J=this.cmp($);return J==1||J===0};Z0.hyperbolicCosine=Z0.cosh=function(){var $,J,Z,K,Q,H=this,z=H.constructor,q=new z(1);if(!H.isFinite())return new z(H.s?1/0:NaN);if(H.isZero())return q;if(Z=z.precision,K=z.rounding,z.precision=Z+Math.max(H.e,H.sd())+4,z.rounding=1,Q=H.d.length,Q<32)$=Math.ceil(Q/3),J=(1/O$(4,$)).toString();else $=16,J="2.3283064365386962890625e-10";H=O6(z,1,H.times(J),new z(1),!0);var j,W=$,G=new z(8);for(;W--;)j=H.times(H),H=q.minus(j.times(G.minus(j.times(G))));return Y0(H,z.precision=Z,z.rounding=K,!0)};Z0.hyperbolicSine=Z0.sinh=function(){var $,J,Z,K,Q=this,H=Q.constructor;if(!Q.isFinite()||Q.isZero())return new H(Q);if(J=H.precision,Z=H.rounding,H.precision=J+Math.max(Q.e,Q.sd())+4,H.rounding=1,K=Q.d.length,K<3)Q=O6(H,2,Q,Q,!0);else{$=1.4*Math.sqrt(K),$=$>16?16:$|0,Q=Q.times(1/O$(5,$)),Q=O6(H,2,Q,Q,!0);var z,q=new H(5),j=new H(16),W=new H(20);for(;$--;)z=Q.times(Q),Q=Q.times(q.plus(z.times(j.times(z).plus(W))))}return H.precision=J,H.rounding=Z,Y0(Q,J,Z,!0)};Z0.hyperbolicTangent=Z0.tanh=function(){var $,J,Z=this,K=Z.constructor;if(!Z.isFinite())return new K(Z.s);if(Z.isZero())return new K(Z);return $=K.precision,J=K.rounding,K.precision=$+7,K.rounding=1,D0(Z.sinh(),Z.cosh(),K.precision=$,K.rounding=J)};Z0.inverseCosine=Z0.acos=function(){var $=this,J=$.constructor,Z=$.abs().cmp(1),K=J.precision,Q=J.rounding;if(Z!==-1)return Z===0?$.isNeg()?I7(J,K,Q):new J(0):new J(NaN);if($.isZero())return I7(J,K+4,Q).times(0.5);return J.precision=K+6,J.rounding=1,$=new J(1).minus($).div($.plus(1)).sqrt().atan(),J.precision=K,J.rounding=Q,$.times(2)};Z0.inverseHyperbolicCosine=Z0.acosh=function(){var $,J,Z=this,K=Z.constructor;if(Z.lte(1))return new K(Z.eq(1)?0:NaN);if(!Z.isFinite())return new K(Z);return $=K.precision,J=K.rounding,K.precision=$+Math.max(Math.abs(Z.e),Z.sd())+4,K.rounding=1,A0=!1,Z=Z.times(Z).minus(1).sqrt().plus(Z),A0=!0,K.precision=$,K.rounding=J,Z.ln()};Z0.inverseHyperbolicSine=Z0.asinh=function(){var $,J,Z=this,K=Z.constructor;if(!Z.isFinite()||Z.isZero())return new K(Z);return $=K.precision,J=K.rounding,K.precision=$+2*Math.max(Math.abs(Z.e),Z.sd())+6,K.rounding=1,A0=!1,Z=Z.times(Z).plus(1).sqrt().plus(Z),A0=!0,K.precision=$,K.rounding=J,Z.ln()};Z0.inverseHyperbolicTangent=Z0.atanh=function(){var $,J,Z,K,Q=this,H=Q.constructor;if(!Q.isFinite())return new H(NaN);if(Q.e>=0)return new H(Q.abs().eq(1)?Q.s/0:Q.isZero()?Q:NaN);if($=H.precision,J=H.rounding,K=Q.sd(),Math.max(K,$)<2*-Q.e-1)return Y0(new H(Q),$,J,!0);return H.precision=Z=K-Q.e,Q=D0(Q.plus(1),new H(1).minus(Q),Z+$,1),H.precision=$+4,H.rounding=1,Q=Q.ln(),H.precision=$,H.rounding=J,Q.times(0.5)};Z0.inverseSine=Z0.asin=function(){var $,J,Z,K,Q=this,H=Q.constructor;if(Q.isZero())return new H(Q);if(J=Q.abs().cmp(1),Z=H.precision,K=H.rounding,J!==-1){if(J===0)return $=I7(H,Z+4,K).times(0.5),$.s=Q.s,$;return new H(NaN)}return H.precision=Z+6,H.rounding=1,Q=Q.div(new H(1).minus(Q.times(Q)).sqrt().plus(1)).atan(),H.precision=Z,H.rounding=K,Q.times(2)};Z0.inverseTangent=Z0.atan=function(){var $,J,Z,K,Q,H,z,q,j,W=this,G=W.constructor,F=G.precision,_=G.rounding;if(!W.isFinite()){if(!W.s)return new G(NaN);if(F+4<=_9)return z=I7(G,F+4,_).times(0.5),z.s=W.s,z}else if(W.isZero())return new G(W);else if(W.abs().eq(1)&&F+4<=_9)return z=I7(G,F+4,_).times(0.25),z.s=W.s,z;G.precision=q=F+10,G.rounding=1,Z=Math.min(28,q/w0+2|0);for($=Z;$;--$)W=W.div(W.times(W).plus(1).sqrt().plus(1));A0=!1,J=Math.ceil(q/w0),K=1,j=W.times(W),z=new G(W),Q=W;for(;$!==-1;)if(Q=Q.times(j),H=z.minus(Q.div(K+=2)),Q=Q.times(j),z=H.plus(Q.div(K+=2)),z.d[J]!==void 0)for($=J;z.d[$]===H.d[$]&&$--;);if(Z)z=z.times(2<<Z-1);return A0=!0,Y0(z,G.precision=F,G.rounding=_,!0)};Z0.isFinite=function(){return!!this.d};Z0.isInteger=Z0.isInt=function(){return!!this.d&&t0(this.e/w0)>this.d.length-2};Z0.isNaN=function(){return!this.s};Z0.isNegative=Z0.isNeg=function(){return this.s<0};Z0.isPositive=Z0.isPos=function(){return this.s>0};Z0.isZero=function(){return!!this.d&&this.d[0]===0};Z0.lessThan=Z0.lt=function($){return this.cmp($)<0};Z0.lessThanOrEqualTo=Z0.lte=function($){return this.cmp($)<1};Z0.logarithm=Z0.log=function($){var J,Z,K,Q,H,z,q,j,W=this,G=W.constructor,F=G.precision,_=G.rounding,U=5;if($==null)$=new G(10),J=!0;else{if($=new G($),Z=$.d,$.s<0||!Z||!Z[0]||$.eq(1))return new G(NaN);J=$.eq(10)}if(Z=W.d,W.s<0||!Z||!Z[0]||W.eq(1))return new G(Z&&!Z[0]?-1/0:W.s!=1?NaN:Z?0:1/0);if(J)if(Z.length>1)H=!0;else{for(Q=Z[0];Q%10===0;)Q/=10;H=Q!==1}if(A0=!1,q=F+U,z=n7(W,q),K=J?U$(G,q+10):n7($,q),j=D0(z,K,q,1),D6(j.d,Q=F,_))do if(q+=10,z=n7(W,q),K=J?U$(G,q+10):n7($,q),j=D0(z,K,q,1),!H){if(+r0(j.d).slice(Q+1,Q+15)+1==100000000000000)j=Y0(j,F+1,0);break}while(D6(j.d,Q+=10,_));return A0=!0,Y0(j,F,_)};Z0.minus=Z0.sub=function($){var J,Z,K,Q,H,z,q,j,W,G,F,_,U=this,M=U.constructor;if($=new M($),!U.d||!$.d){if(!U.s||!$.s)$=new M(NaN);else if(U.d)$.s=-$.s;else $=new M($.d||U.s!==$.s?U:NaN);return $}if(U.s!=$.s)return $.s=-$.s,U.plus($);if(W=U.d,_=$.d,q=M.precision,j=M.rounding,!W[0]||!_[0]){if(_[0])$.s=-$.s;else if(W[0])$=new M(U);else return new M(j===3?-0:0);return A0?Y0($,q,j):$}if(Z=t0($.e/w0),G=t0(U.e/w0),W=W.slice(),H=G-Z,H){if(F=H<0,F)J=W,H=-H,z=_.length;else J=_,Z=G,z=W.length;if(K=Math.max(Math.ceil(q/w0),z)+2,H>K)H=K,J.length=1;J.reverse();for(K=H;K--;)J.push(0);J.reverse()}else{if(K=W.length,z=_.length,F=K<z,F)z=K;for(K=0;K<z;K++)if(W[K]!=_[K]){F=W[K]<_[K];break}H=0}if(F)J=W,W=_,_=J,$.s=-$.s;z=W.length;for(K=_.length-z;K>0;--K)W[z++]=0;for(K=_.length;K>H;){if(W[--K]<_[K]){for(Q=K;Q&&W[--Q]===0;)W[Q]=w7-1;--W[Q],W[K]+=w7}W[K]-=_[K]}for(;W[--z]===0;)W.pop();for(;W[0]===0;W.shift())--Z;if(!W[0])return new M(j===3?-0:0);return $.d=W,$.e=M$(W,Z),A0?Y0($,q,j):$};Z0.modulo=Z0.mod=function($){var J,Z=this,K=Z.constructor;if($=new K($),!Z.d||!$.s||$.d&&!$.d[0])return new K(NaN);if(!$.d||Z.d&&!Z.d[0])return Y0(new K(Z),K.precision,K.rounding);if(A0=!1,K.modulo==9)J=D0(Z,$.abs(),0,3,1),J.s*=$.s;else J=D0(Z,$,0,K.modulo,1);return J=J.times($),A0=!0,Z.minus(J)};Z0.naturalExponential=Z0.exp=function(){return U9(this)};Z0.naturalLogarithm=Z0.ln=function(){return n7(this)};Z0.negated=Z0.neg=function(){var $=new this.constructor(this);return $.s=-$.s,Y0($)};Z0.plus=Z0.add=function($){var J,Z,K,Q,H,z,q,j,W,G,F=this,_=F.constructor;if($=new _($),!F.d||!$.d){if(!F.s||!$.s)$=new _(NaN);else if(!F.d)$=new _($.d||F.s===$.s?F:NaN);return $}if(F.s!=$.s)return $.s=-$.s,F.minus($);if(W=F.d,G=$.d,q=_.precision,j=_.rounding,!W[0]||!G[0]){if(!G[0])$=new _(F);return A0?Y0($,q,j):$}if(H=t0(F.e/w0),K=t0($.e/w0),W=W.slice(),Q=H-K,Q){if(Q<0)Z=W,Q=-Q,z=G.length;else Z=G,K=H,z=W.length;if(H=Math.ceil(q/w0),z=H>z?H+1:z+1,Q>z)Q=z,Z.length=1;Z.reverse();for(;Q--;)Z.push(0);Z.reverse()}if(z=W.length,Q=G.length,z-Q<0)Q=z,Z=G,G=W,W=Z;for(J=0;Q;)J=(W[--Q]=W[Q]+G[Q]+J)/w7|0,W[Q]%=w7;if(J)W.unshift(J),++K;for(z=W.length;W[--z]==0;)W.pop();return $.d=W,$.e=M$(W,K),A0?Y0($,q,j):$};Z0.precision=Z0.sd=function($){var J,Z=this;if($!==void 0&&$!==!!$&&$!==1&&$!==0)throw Error(s7+$);if(Z.d){if(J=nJ(Z.d),$&&Z.e+1>J)J=Z.e+1}else J=NaN;return J};Z0.round=function(){var $=this,J=$.constructor;return Y0(new J($),$.e+1,J.rounding)};Z0.sine=Z0.sin=function(){var $,J,Z=this,K=Z.constructor;if(!Z.isFinite())return new K(NaN);if(Z.isZero())return new K(Z);return $=K.precision,J=K.rounding,K.precision=$+Math.max(Z.e,Z.sd())+w0,K.rounding=1,Z=RZ(K,rJ(K,Z)),K.precision=$,K.rounding=J,Y0(D7>2?Z.neg():Z,$,J,!0)};Z0.squareRoot=Z0.sqrt=function(){var $,J,Z,K,Q,H,z=this,q=z.d,j=z.e,W=z.s,G=z.constructor;if(W!==1||!q||!q[0])return new G(!W||W<0&&(!q||q[0])?NaN:q?z:1/0);if(A0=!1,W=Math.sqrt(+z),W==0||W==1/0){if(J=r0(q),(J.length+j)%2==0)J+="0";if(W=Math.sqrt(J),j=t0((j+1)/2)-(j<0||j%2),W==1/0)J="5e"+j;else J=W.toExponential(),J=J.slice(0,J.indexOf("e")+1)+j;K=new G(J)}else K=new G(W.toString());Z=(j=G.precision)+3;for(;;)if(H=K,K=H.plus(D0(z,H,Z+2,1)).times(0.5),r0(H.d).slice(0,Z)===(J=r0(K.d)).slice(0,Z))if(J=J.slice(Z-3,Z+1),J=="9999"||!Q&&J=="4999"){if(!Q){if(Y0(H,j+1,0),H.times(H).eq(z)){K=H;break}}Z+=4,Q=1}else{if(!+J||!+J.slice(1)&&J.charAt(0)=="5")Y0(K,j+1,1),$=!K.times(K).eq(z);break}return A0=!0,Y0(K,j,G.rounding,$)};Z0.tangent=Z0.tan=function(){var $,J,Z=this,K=Z.constructor;if(!Z.isFinite())return new K(NaN);if(Z.isZero())return new K(Z);return $=K.precision,J=K.rounding,K.precision=$+10,K.rounding=1,Z=Z.sin(),Z.s=1,Z=D0(Z,new K(1).minus(Z.times(Z)).sqrt(),$+10,0),K.precision=$,K.rounding=J,Y0(D7==2||D7==4?Z.neg():Z,$,J,!0)};Z0.times=Z0.mul=function($){var J,Z,K,Q,H,z,q,j,W,G=this,F=G.constructor,_=G.d,U=($=new F($)).d;if($.s*=G.s,!_||!_[0]||!U||!U[0])return new F(!$.s||_&&!_[0]&&!U||U&&!U[0]&&!_?NaN:!_||!U?$.s/0:$.s*0);if(Z=t0(G.e/w0)+t0($.e/w0),j=_.length,W=U.length,j<W)H=_,_=U,U=H,z=j,j=W,W=z;H=[],z=j+W;for(K=z;K--;)H.push(0);for(K=W;--K>=0;){J=0;for(Q=j+K;Q>K;)q=H[Q]+U[K]*_[Q-K-1]+J,H[Q--]=q%w7|0,J=q/w7|0;H[Q]=(H[Q]+J)%w7|0}for(;!H[--z];)H.pop();if(J)++Z;else H.shift();return $.d=H,$.e=M$(H,Z),A0?Y0($,F.precision,F.rounding):$};Z0.toBinary=function($,J){return V9(this,2,$,J)};Z0.toDecimalPlaces=Z0.toDP=function($,J){var Z=this,K=Z.constructor;if(Z=new K(Z),$===void 0)return Z;if(Z7($,0,o7),J===void 0)J=K.rounding;else Z7(J,0,8);return Y0(Z,$+Z.e+1,J)};Z0.toExponential=function($,J){var Z,K=this,Q=K.constructor;if($===void 0)Z=P7(K,!0);else{if(Z7($,0,o7),J===void 0)J=Q.rounding;else Z7(J,0,8);K=Y0(new Q(K),$+1,J),Z=P7(K,!0,$+1)}return K.isNeg()&&!K.isZero()?"-"+Z:Z};Z0.toFixed=function($,J){var Z,K,Q=this,H=Q.constructor;if($===void 0)Z=P7(Q);else{if(Z7($,0,o7),J===void 0)J=H.rounding;else Z7(J,0,8);K=Y0(new H(Q),$+Q.e+1,J),Z=P7(K,!1,$+K.e+1)}return Q.isNeg()&&!Q.isZero()?"-"+Z:Z};Z0.toFraction=function($){var J,Z,K,Q,H,z,q,j,W,G,F,_,U=this,M=U.d,V=U.constructor;if(!M)return new V(U);if(W=Z=new V(1),K=j=new V(0),J=new V(K),H=J.e=nJ(M)-U.e-1,z=H%w0,J.d[0]=c0(10,z<0?w0+z:z),$==null)$=H>0?J:W;else{if(q=new V($),!q.isInt()||q.lt(W))throw Error(s7+q);$=q.gt(J)?H>0?J:W:q}A0=!1,q=new V(r0(M)),G=V.precision,V.precision=H=M.length*w0*2;for(;;){if(F=D0(q,J,0,1,1),Q=Z.plus(F.times(K)),Q.cmp($)==1)break;Z=K,K=Q,Q=W,W=j.plus(F.times(Q)),j=Q,Q=J,J=q.minus(F.times(Q)),q=Q}return Q=D0($.minus(Z),K,0,1,1),j=j.plus(Q.times(W)),Z=Z.plus(Q.times(K)),j.s=W.s=U.s,_=D0(W,K,H,1).minus(U).abs().cmp(D0(j,Z,H,1).minus(U).abs())<1?[W,K]:[j,Z],V.precision=G,A0=!0,_};Z0.toHexadecimal=Z0.toHex=function($,J){return V9(this,16,$,J)};Z0.toNearest=function($,J){var Z=this,K=Z.constructor;if(Z=new K(Z),$==null){if(!Z.d)return Z;$=new K(1),J=K.rounding}else{if($=new K($),J===void 0)J=K.rounding;else Z7(J,0,8);if(!Z.d)return $.s?Z:$;if(!$.d){if($.s)$.s=Z.s;return $}}if($.d[0])A0=!1,Z=D0(Z,$,0,J,1).times($),A0=!0,Y0(Z);else $.s=Z.s,Z=$;return Z};Z0.toNumber=function(){return+this};Z0.toOctal=function($,J){return V9(this,8,$,J)};Z0.toPower=Z0.pow=function($){var J,Z,K,Q,H,z,q=this,j=q.constructor,W=+($=new j($));if(!q.d||!$.d||!q.d[0]||!$.d[0])return new j(c0(+q,W));if(q=new j(q),q.eq(1))return q;if(K=j.precision,H=j.rounding,$.eq(1))return Y0(q,K,H);if(J=t0($.e/w0),J>=$.d.length-1&&(Z=W<0?-W:W)<=XZ)return Q=sJ(j,q,Z,K),$.s<0?new j(1).div(Q):Y0(Q,K,H);if(z=q.s,z<0){if(J<$.d.length-1)return new j(NaN);if(($.d[J]&1)==0)z=1;if(q.e==0&&q.d[0]==1&&q.d.length==1)return q.s=z,q}if(Z=c0(+q,W),J=Z==0||!isFinite(Z)?t0(W*(Math.log("0."+r0(q.d))/Math.LN10+q.e+1)):new j(Z+"").e,J>j.maxE+1||J<j.minE-1)return new j(J>0?z/0:0);if(A0=!1,j.rounding=q.s=1,Z=Math.min(12,(J+"").length),Q=U9($.times(n7(q,K+Z)),K),Q.d){if(Q=Y0(Q,K+5,1),D6(Q.d,K,H)){if(J=K+10,Q=Y0(U9($.times(n7(q,J+Z)),J),J+5,1),+r0(Q.d).slice(K+1,K+15)+1==100000000000000)Q=Y0(Q,K+1,0)}}return Q.s=z,A0=!0,j.rounding=H,Y0(Q,K,H)};Z0.toPrecision=function($,J){var Z,K=this,Q=K.constructor;if($===void 0)Z=P7(K,K.e<=Q.toExpNeg||K.e>=Q.toExpPos);else{if(Z7($,1,o7),J===void 0)J=Q.rounding;else Z7(J,0,8);K=Y0(new Q(K),$,J),Z=P7(K,$<=K.e||K.e<=Q.toExpNeg,$)}return K.isNeg()&&!K.isZero()?"-"+Z:Z};Z0.toSignificantDigits=Z0.toSD=function($,J){var Z=this,K=Z.constructor;if($===void 0)$=K.precision,J=K.rounding;else if(Z7($,1,o7),J===void 0)J=K.rounding;else Z7(J,0,8);return Y0(new K(Z),$,J)};Z0.toString=function(){var $=this,J=$.constructor,Z=P7($,$.e<=J.toExpNeg||$.e>=J.toExpPos);return $.isNeg()&&!$.isZero()?"-"+Z:Z};Z0.truncated=Z0.trunc=function(){return Y0(new this.constructor(this),this.e+1,1)};Z0.valueOf=Z0.toJSON=function(){var $=this,J=$.constructor,Z=P7($,$.e<=J.toExpNeg||$.e>=J.toExpPos);return $.isNeg()?"-"+Z:Z};function r0($){var J,Z,K,Q=$.length-1,H="",z=$[0];if(Q>0){H+=z;for(J=1;J<Q;J++){if(K=$[J]+"",Z=w0-K.length,Z)H+=l7(Z);H+=K}if(z=$[J],K=z+"",Z=w0-K.length,Z)H+=l7(Z)}else if(z===0)return"0";for(;z%10===0;)z/=10;return H+z}function Z7($,J,Z){if($!==~~$||$<J||$>Z)throw Error(s7+$)}function D6($,J,Z,K){var Q,H,z,q;for(H=$[0];H>=10;H/=10)--J;if(--J<0)J+=w0,Q=0;else Q=Math.ceil((J+1)/w0),J%=w0;if(H=c0(10,w0-J),q=$[Q]%H|0,K==null)if(J<3){if(J==0)q=q/100|0;else if(J==1)q=q/10|0;z=Z<4&&q==99999||Z>3&&q==49999||q==50000||q==0}else z=(Z<4&&q+1==H||Z>3&&q+1==H/2)&&($[Q+1]/H/100|0)==c0(10,J-2)-1||(q==H/2||q==0)&&($[Q+1]/H/100|0)==0;else if(J<4){if(J==0)q=q/1000|0;else if(J==1)q=q/100|0;else if(J==2)q=q/10|0;z=(K||Z<4)&&q==9999||!K&&Z>3&&q==4999}else z=((K||Z<4)&&q+1==H||!K&&Z>3&&q+1==H/2)&&($[Q+1]/H/1000|0)==c0(10,J-3)-1;return z}function j$($,J,Z){var K,Q=[0],H,z=0,q=$.length;for(;z<q;){for(H=Q.length;H--;)Q[H]*=J;Q[0]+=G9.indexOf($.charAt(z++));for(K=0;K<Q.length;K++)if(Q[K]>Z-1){if(Q[K+1]===void 0)Q[K+1]=0;Q[K+1]+=Q[K]/Z|0,Q[K]%=Z}}return Q.reverse()}function kZ($,J){var Z,K,Q;if(J.isZero())return J;if(K=J.d.length,K<32)Z=Math.ceil(K/3),Q=(1/O$(4,Z)).toString();else Z=16,Q="2.3283064365386962890625e-10";$.precision+=Z,J=O6($,1,J.times(Q),new $(1));for(var H=Z;H--;){var z=J.times(J);J=z.times(z).minus(z).times(8).plus(1)}return $.precision-=Z,J}var D0=function(){function $(K,Q,H){var z,q=0,j=K.length;for(K=K.slice();j--;)z=K[j]*Q+q,K[j]=z%H|0,q=z/H|0;if(q)K.unshift(q);return K}function J(K,Q,H,z){var q,j;if(H!=z)j=H>z?1:-1;else for(q=j=0;q<H;q++)if(K[q]!=Q[q]){j=K[q]>Q[q]?1:-1;break}return j}function Z(K,Q,H,z){var q=0;for(;H--;)K[H]-=q,q=K[H]<Q[H]?1:0,K[H]=q*z+K[H]-Q[H];for(;!K[0]&&K.length>1;)K.shift()}return function(K,Q,H,z,q,j){var W,G,F,_,U,M,V,Y,O,X,w,R,B,I,h,m,v,x,y,T,d=K.constructor,p=K.s==Q.s?1:-1,c=K.d,C=Q.d;if(!c||!c[0]||!C||!C[0])return new d(!K.s||!Q.s||(c?C&&c[0]==C[0]:!C)?NaN:c&&c[0]==0||!C?p*0:p/0);if(j)U=1,G=K.e-Q.e;else j=w7,U=w0,G=t0(K.e/U)-t0(Q.e/U);y=C.length,v=c.length,O=new d(p),X=O.d=[];for(F=0;C[F]==(c[F]||0);F++);if(C[F]>(c[F]||0))G--;if(H==null)I=H=d.precision,z=d.rounding;else if(q)I=H+(K.e-Q.e)+1;else I=H;if(I<0)X.push(1),M=!0;else{if(I=I/U+2|0,F=0,y==1){_=0,C=C[0],I++;for(;(F<v||_)&&I--;F++)h=_*j+(c[F]||0),X[F]=h/C|0,_=h%C|0;M=_||F<v}else{if(_=j/(C[0]+1)|0,_>1)C=$(C,_,j),c=$(c,_,j),y=C.length,v=c.length;m=y,w=c.slice(0,y),R=w.length;for(;R<y;)w[R++]=0;if(T=C.slice(),T.unshift(0),x=C[0],C[1]>=j/2)++x;do{if(_=0,W=J(C,w,y,R),W<0){if(B=w[0],y!=R)B=B*j+(w[1]||0);if(_=B/x|0,_>1){if(_>=j)_=j-1;if(V=$(C,_,j),Y=V.length,R=w.length,W=J(V,w,Y,R),W==1)_--,Z(V,y<Y?T:C,Y,j)}else{if(_==0)W=_=1;V=C.slice()}if(Y=V.length,Y<R)V.unshift(0);if(Z(w,V,R,j),W==-1){if(R=w.length,W=J(C,w,y,R),W<1)_++,Z(w,y<R?T:C,R,j)}R=w.length}else if(W===0)_++,w=[0];if(X[F++]=_,W&&w[0])w[R++]=c[m]||0;else w=[c[m]],R=1}while((m++<v||w[0]!==void 0)&&I--);M=w[0]!==void 0}if(!X[0])X.shift()}if(U==1)O.e=G,mJ=M;else{for(F=1,_=X[0];_>=10;_/=10)F++;O.e=F+G*U-1,Y0(O,q?H+O.e+1:H,z,M)}return O}}();function Y0($,J,Z,K){var Q,H,z,q,j,W,G,F,_,U=$.constructor;$:if(J!=null){if(F=$.d,!F)return $;for(Q=1,q=F[0];q>=10;q/=10)Q++;if(H=J-Q,H<0)H+=w0,z=J,G=F[_=0],j=G/c0(10,Q-z-1)%10|0;else if(_=Math.ceil((H+1)/w0),q=F.length,_>=q)if(K){for(;q++<=_;)F.push(0);G=j=0,Q=1,H%=w0,z=H-w0+1}else break $;else{G=q=F[_];for(Q=1;q>=10;q/=10)Q++;H%=w0,z=H-w0+Q,j=z<0?0:G/c0(10,Q-z-1)%10|0}if(K=K||J<0||F[_+1]!==void 0||(z<0?G:G%c0(10,Q-z-1)),W=Z<4?(j||K)&&(Z==0||Z==($.s<0?3:2)):j>5||j==5&&(Z==4||K||Z==6&&(H>0?z>0?G/c0(10,Q-z):0:F[_-1])%10&1||Z==($.s<0?8:7)),J<1||!F[0]){if(F.length=0,W)J-=$.e+1,F[0]=c0(10,(w0-J%w0)%w0),$.e=-J||0;else F[0]=$.e=0;return $}if(H==0)F.length=_,q=1,_--;else F.length=_+1,q=c0(10,w0-H),F[_]=z>0?(G/c0(10,Q-z)%c0(10,z)|0)*q:0;if(W)for(;;)if(_==0){for(H=1,z=F[0];z>=10;z/=10)H++;z=F[0]+=q;for(q=1;z>=10;z/=10)q++;if(H!=q){if($.e++,F[0]==w7)F[0]=1}break}else{if(F[_]+=q,F[_]!=w7)break;F[_--]=0,q=1}for(H=F.length;F[--H]===0;)F.pop()}if(A0){if($.e>U.maxE)$.d=null,$.e=NaN;else if($.e<U.minE)$.e=0,$.d=[0]}return $}function P7($,J,Z){if(!$.isFinite())return iJ($);var K,Q=$.e,H=r0($.d),z=H.length;if(J){if(Z&&(K=Z-z)>0)H=H.charAt(0)+"."+H.slice(1)+l7(K);else if(z>1)H=H.charAt(0)+"."+H.slice(1);H=H+($.e<0?"e":"e+")+$.e}else if(Q<0){if(H="0."+l7(-Q-1)+H,Z&&(K=Z-z)>0)H+=l7(K)}else if(Q>=z){if(H+=l7(Q+1-z),Z&&(K=Z-Q-1)>0)H=H+"."+l7(K)}else{if((K=Q+1)<z)H=H.slice(0,K)+"."+H.slice(K);if(Z&&(K=Z-z)>0){if(Q+1===z)H+=".";H+=l7(K)}}return H}function M$($,J){var Z=$[0];for(J*=w0;Z>=10;Z/=10)J++;return J}function U$($,J,Z){if(J>LZ){if(A0=!0,Z)$.precision=Z;throw Error(dJ)}return Y0(new $(F$),J,1,!0)}function I7($,J,Z){if(J>_9)throw Error(dJ);return Y0(new $(_$),J,Z,!0)}function nJ($){var J=$.length-1,Z=J*w0+1;if(J=$[J],J){for(;J%10==0;J/=10)Z--;for(J=$[0];J>=10;J/=10)Z++}return Z}function l7($){var J="";for(;$--;)J+="0";return J}function sJ($,J,Z,K){var Q,H=new $(1),z=Math.ceil(K/w0+4);A0=!1;for(;;){if(Z%2){if(H=H.times(J),gJ(H.d,z))Q=!0}if(Z=t0(Z/2),Z===0){if(Z=H.d.length-1,Q&&H.d[Z]===0)++H.d[Z];break}J=J.times(J),gJ(J.d,z)}return A0=!0,H}function uJ($){return $.d[$.d.length-1]&1}function oJ($,J,Z){var K,Q,H=new $(J[0]),z=0;for(;++z<J.length;){if(Q=new $(J[z]),!Q.s){H=Q;break}if(K=H.cmp(Q),K===Z||K===0&&H.s===Z)H=Q}return H}function U9($,J){var Z,K,Q,H,z,q,j,W=0,G=0,F=0,_=$.constructor,U=_.rounding,M=_.precision;if(!$.d||!$.d[0]||$.e>17)return new _($.d?!$.d[0]?1:$.s<0?0:1/0:$.s?$.s<0?0:$:NaN);if(J==null)A0=!1,j=M;else j=J;q=new _(0.03125);while($.e>-2)$=$.times(q),F+=5;K=Math.log(c0(2,F))/Math.LN10*2+5|0,j+=K,Z=H=z=new _(1),_.precision=j;for(;;){if(H=Y0(H.times($),j,1),Z=Z.times(++G),q=z.plus(D0(H,Z,j,1)),r0(q.d).slice(0,j)===r0(z.d).slice(0,j)){Q=F;while(Q--)z=Y0(z.times(z),j,1);if(J==null)if(W<3&&D6(z.d,j-K,U,W))_.precision=j+=10,Z=H=q=new _(1),G=0,W++;else return Y0(z,_.precision=M,U,A0=!0);else return _.precision=M,z}z=q}}function n7($,J){var Z,K,Q,H,z,q,j,W,G,F,_,U=1,M=10,V=$,Y=V.d,O=V.constructor,X=O.rounding,w=O.precision;if(V.s<0||!Y||!Y[0]||!V.e&&Y[0]==1&&Y.length==1)return new O(Y&&!Y[0]?-1/0:V.s!=1?NaN:Y?0:V);if(J==null)A0=!1,G=w;else G=J;if(O.precision=G+=M,Z=r0(Y),K=Z.charAt(0),Math.abs(H=V.e)<1500000000000000){while(K<7&&K!=1||K==1&&Z.charAt(1)>3)V=V.times($),Z=r0(V.d),K=Z.charAt(0),U++;if(H=V.e,K>1)V=new O("0."+Z),H++;else V=new O(K+"."+Z.slice(1))}else return W=U$(O,G+2,w).times(H+""),V=n7(new O(K+"."+Z.slice(1)),G-M).plus(W),O.precision=w,J==null?Y0(V,w,X,A0=!0):V;F=V,j=z=V=D0(V.minus(1),V.plus(1),G,1),_=Y0(V.times(V),G,1),Q=3;for(;;){if(z=Y0(z.times(_),G,1),W=j.plus(D0(z,new O(Q),G,1)),r0(W.d).slice(0,G)===r0(j.d).slice(0,G)){if(j=j.times(2),H!==0)j=j.plus(U$(O,G+2,w).times(H+""));if(j=D0(j,new O(U),G,1),J==null)if(D6(j.d,G-M,X,q))O.precision=G+=M,W=z=V=D0(F.minus(1),F.plus(1),G,1),_=Y0(V.times(V),G,1),Q=q=1;else return Y0(j,O.precision=w,X,A0=!0);else return O.precision=w,j}j=W,Q+=2}}function iJ($){return String($.s*$.s/0)}function G$($,J){var Z,K,Q;if((Z=J.indexOf("."))>-1)J=J.replace(".","");if((K=J.search(/e/i))>0){if(Z<0)Z=K;Z+=+J.slice(K+1),J=J.substring(0,K)}else if(Z<0)Z=J.length;for(K=0;J.charCodeAt(K)===48;K++);for(Q=J.length;J.charCodeAt(Q-1)===48;--Q);if(J=J.slice(K,Q),J){if(Q-=K,$.e=Z=Z-K-1,$.d=[],K=(Z+1)%w0,Z<0)K+=w0;if(K<Q){if(K)$.d.push(+J.slice(0,K));for(Q-=w0;K<Q;)$.d.push(+J.slice(K,K+=w0));J=J.slice(K),K=w0-J.length}else K-=Q;for(;K--;)J+="0";if($.d.push(+J),A0){if($.e>$.constructor.maxE)$.d=null,$.e=NaN;else if($.e<$.constructor.minE)$.e=0,$.d=[0]}}else $.e=0,$.d=[0];return $}function wZ($,J){var Z,K,Q,H,z,q,j,W,G;if(J.indexOf("_")>-1){if(J=J.replace(/(\d)_(?=\d)/g,"$1"),lJ.test(J))return G$($,J)}else if(J==="Infinity"||J==="NaN"){if(!+J)$.s=NaN;return $.e=NaN,$.d=null,$}if(OZ.test(J))Z=16,J=J.toLowerCase();else if(MZ.test(J))Z=2;else if(YZ.test(J))Z=8;else throw Error(s7+J);if(H=J.search(/p/i),H>0)j=+J.slice(H+1),J=J.substring(2,H);else J=J.slice(2);if(H=J.indexOf("."),z=H>=0,K=$.constructor,z)J=J.replace(".",""),q=J.length,H=q-H,Q=sJ(K,new K(Z),H,H*2);W=j$(J,Z,w7),G=W.length-1;for(H=G;W[H]===0;--H)W.pop();if(H<0)return new K($.s*0);if($.e=M$(W,G),$.d=W,A0=!1,z)$=D0($,Q,q*4);if(j)$=$.times(Math.abs(j)<54?c0(2,j):h6.pow(2,j));return A0=!0,$}function RZ($,J){var Z,K=J.d.length;if(K<3)return J.isZero()?J:O6($,2,J,J);Z=1.4*Math.sqrt(K),Z=Z>16?16:Z|0,J=J.times(1/O$(5,Z)),J=O6($,2,J,J);var Q,H=new $(5),z=new $(16),q=new $(20);for(;Z--;)Q=J.times(J),J=J.times(H.plus(Q.times(z.times(Q).minus(q))));return J}function O6($,J,Z,K,Q){var H,z,q,j,W=1,G=$.precision,F=Math.ceil(G/w0);A0=!1,j=Z.times(Z),q=new $(K);for(;;){if(z=D0(q.times(j),new $(J++*J++),G,1),q=Q?K.plus(z):K.minus(z),K=D0(z.times(j),new $(J++*J++),G,1),z=q.plus(K),z.d[F]!==void 0){for(H=F;z.d[H]===q.d[H]&&H--;);if(H==-1)break}H=q,q=K,K=z,z=H,W++}return A0=!0,z.d.length=F+1,z}function O$($,J){var Z=$;while(--J)Z*=$;return Z}function rJ($,J){var Z,K=J.s<0,Q=I7($,$.precision,1),H=Q.times(0.5);if(J=J.abs(),J.lte(H))return D7=K?4:1,J;if(Z=J.divToInt(Q),Z.isZero())D7=K?3:2;else{if(J=J.minus(Z.times(Q)),J.lte(H))return D7=uJ(Z)?K?2:3:K?4:1,J;D7=uJ(Z)?K?1:4:K?3:2}return J.minus(Q).abs()}function V9($,J,Z,K){var Q,H,z,q,j,W,G,F,_,U=$.constructor,M=Z!==void 0;if(M)if(Z7(Z,1,o7),K===void 0)K=U.rounding;else Z7(K,0,8);else Z=U.precision,K=U.rounding;if(!$.isFinite())G=iJ($);else{if(G=P7($),z=G.indexOf("."),M){if(Q=2,J==16)Z=Z*4-3;else if(J==8)Z=Z*3-2}else Q=J;if(z>=0)G=G.replace(".",""),_=new U(1),_.e=G.length-z,_.d=j$(P7(_),10,Q),_.e=_.d.length;F=j$(G,10,Q),H=j=F.length;for(;F[--j]==0;)F.pop();if(!F[0])G=M?"0p+0":"0";else{if(z<0)H--;else $=new U($),$.d=F,$.e=H,$=D0($,_,Z,K,0,Q),F=$.d,H=$.e,W=mJ;if(z=F[Z],q=Q/2,W=W||F[Z+1]!==void 0,W=K<4?(z!==void 0||W)&&(K===0||K===($.s<0?3:2)):z>q||z===q&&(K===4||W||K===6&&F[Z-1]&1||K===($.s<0?8:7)),F.length=Z,W){for(;++F[--Z]>Q-1;)if(F[Z]=0,!Z)++H,F.unshift(1)}for(j=F.length;!F[j-1];--j);for(z=0,G="";z<j;z++)G+=G9.charAt(F[z]);if(M){if(j>1)if(J==16||J==8){z=J==16?4:3;for(--j;j%z;j++)G+="0";F=j$(G,Q,J);for(j=F.length;!F[j-1];--j);for(z=1,G="1.";z<j;z++)G+=G9.charAt(F[z])}else G=G.charAt(0)+"."+G.slice(1);G=G+(H<0?"p":"p+")+H}else if(H<0){for(;++H;)G="0"+G;G="0."+G}else if(++H>j)for(H-=j;H--;)G+="0";else if(H<j)G=G.slice(0,H)+"."+G.slice(H)}G=(J==16?"0x":J==2?"0b":J==8?"0o":"")+G}return $.s<0?"-"+G:G}function gJ($,J){if($.length>J)return $.length=J,!0}function BZ($){return new this($).abs()}function NZ($){return new this($).acos()}function CZ($){return new this($).acosh()}function IZ($,J){return new this($).plus(J)}function PZ($){return new this($).asin()}function AZ($){return new this($).asinh()}function EZ($){return new this($).atan()}function TZ($){return new this($).atanh()}function bZ($,J){$=new this($),J=new this(J);var Z,K=this.precision,Q=this.rounding,H=K+4;if(!$.s||!J.s)Z=new this(NaN);else if(!$.d&&!J.d)Z=I7(this,H,1).times(J.s>0?0.25:0.75),Z.s=$.s;else if(!J.d||$.isZero())Z=J.s<0?I7(this,K,Q):new this(0),Z.s=$.s;else if(!$.d||J.isZero())Z=I7(this,H,1).times(0.5),Z.s=$.s;else if(J.s<0)this.precision=H,this.rounding=1,Z=this.atan(D0($,J,H,1)),J=I7(this,H,1),this.precision=K,this.rounding=Q,Z=$.s<0?Z.minus(J):Z.plus(J);else Z=this.atan(D0($,J,H,1));return Z}function fZ($){return new this($).cbrt()}function SZ($){return Y0($=new this($),$.e+1,2)}function vZ($,J,Z){return new this($).clamp(J,Z)}function DZ($){if(!$||typeof $!=="object")throw Error(V$+"Object expected");var J,Z,K,Q=$.defaults===!0,H=["precision",1,o7,"rounding",0,8,"toExpNeg",-M6,0,"toExpPos",0,M6,"maxE",0,M6,"minE",-M6,0,"modulo",0,9];for(J=0;J<H.length;J+=3){if(Z=H[J],Q)this[Z]=F9[Z];if((K=$[Z])!==void 0)if(t0(K)===K&&K>=H[J+1]&&K<=H[J+2])this[Z]=K;else throw Error(s7+Z+": "+K)}if(Z="crypto",Q)this[Z]=F9[Z];if((K=$[Z])!==void 0)if(K===!0||K===!1||K===0||K===1)if(K)if(typeof crypto!="undefined"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[Z]=!0;else throw Error(pJ);else this[Z]=!1;else throw Error(s7+Z+": "+K);return this}function hZ($){return new this($).cos()}function yZ($){return new this($).cosh()}function aJ($){var J,Z,K;function Q(H){var z,q,j,W=this;if(!(W instanceof Q))return new Q(H);if(W.constructor=Q,xJ(H)){if(W.s=H.s,A0)if(!H.d||H.e>Q.maxE)W.e=NaN,W.d=null;else if(H.e<Q.minE)W.e=0,W.d=[0];else W.e=H.e,W.d=H.d.slice();else W.e=H.e,W.d=H.d?H.d.slice():H.d;return}if(j=typeof H,j==="number"){if(H===0){W.s=1/H<0?-1:1,W.e=0,W.d=[0];return}if(H<0)H=-H,W.s=-1;else W.s=1;if(H===~~H&&H<1e7){for(z=0,q=H;q>=10;q/=10)z++;if(A0)if(z>Q.maxE)W.e=NaN,W.d=null;else if(z<Q.minE)W.e=0,W.d=[0];else W.e=z,W.d=[H];else W.e=z,W.d=[H];return}if(H*0!==0){if(!H)W.s=NaN;W.e=NaN,W.d=null;return}return G$(W,H.toString())}if(j==="string"){if((q=H.charCodeAt(0))===45)H=H.slice(1),W.s=-1;else{if(q===43)H=H.slice(1);W.s=1}return lJ.test(H)?G$(W,H):wZ(W,H)}if(j==="bigint"){if(H<0)H=-H,W.s=-1;else W.s=1;return G$(W,H.toString())}throw Error(s7+H)}if(Q.prototype=Z0,Q.ROUND_UP=0,Q.ROUND_DOWN=1,Q.ROUND_CEIL=2,Q.ROUND_FLOOR=3,Q.ROUND_HALF_UP=4,Q.ROUND_HALF_DOWN=5,Q.ROUND_HALF_EVEN=6,Q.ROUND_HALF_CEIL=7,Q.ROUND_HALF_FLOOR=8,Q.EUCLID=9,Q.config=Q.set=DZ,Q.clone=aJ,Q.isDecimal=xJ,Q.abs=BZ,Q.acos=NZ,Q.acosh=CZ,Q.add=IZ,Q.asin=PZ,Q.asinh=AZ,Q.atan=EZ,Q.atanh=TZ,Q.atan2=bZ,Q.cbrt=fZ,Q.ceil=SZ,Q.clamp=vZ,Q.cos=hZ,Q.cosh=yZ,Q.div=uZ,Q.exp=gZ,Q.floor=xZ,Q.hypot=mZ,Q.ln=dZ,Q.log=pZ,Q.log10=lZ,Q.log2=cZ,Q.max=nZ,Q.min=sZ,Q.mod=oZ,Q.mul=iZ,Q.pow=rZ,Q.random=aZ,Q.round=tZ,Q.sign=eZ,Q.sin=$Q,Q.sinh=JQ,Q.sqrt=KQ,Q.sub=ZQ,Q.sum=QQ,Q.tan=HQ,Q.tanh=zQ,Q.trunc=qQ,$===void 0)$={};if($){if($.defaults!==!0){K=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"];for(J=0;J<K.length;)if(!$.hasOwnProperty(Z=K[J++]))$[Z]=this[Z]}}return Q.config($),Q}function uZ($,J){return new this($).div(J)}function gZ($){return new this($).exp()}function xZ($){return Y0($=new this($),$.e+1,3)}function mZ(){var $,J,Z=new this(0);A0=!1;for($=0;$<arguments.length;)if(J=new this(arguments[$++]),!J.d){if(J.s)return A0=!0,new this(1/0);Z=J}else if(Z.d)Z=Z.plus(J.times(J));return A0=!0,Z.sqrt()}function xJ($){return $ instanceof h6||$&&$.toStringTag===cJ||!1}function dZ($){return new this($).ln()}function pZ($,J){return new this($).log(J)}function cZ($){return new this($).log(2)}function lZ($){return new this($).log(10)}function nZ(){return oJ(this,arguments,-1)}function sZ(){return oJ(this,arguments,1)}function oZ($,J){return new this($).mod(J)}function iZ($,J){return new this($).mul(J)}function rZ($,J){return new this($).pow(J)}function aZ($){var J,Z,K,Q,H=0,z=new this(1),q=[];if($===void 0)$=this.precision;else Z7($,1,o7);if(K=Math.ceil($/w0),!this.crypto)for(;H<K;)q[H++]=Math.random()*1e7|0;else if(crypto.getRandomValues){J=crypto.getRandomValues(new Uint32Array(K));for(;H<K;)if(Q=J[H],Q>=4290000000)J[H]=crypto.getRandomValues(new Uint32Array(1))[0];else q[H++]=Q%1e7}else if(crypto.randomBytes){J=crypto.randomBytes(K*=4);for(;H<K;)if(Q=J[H]+(J[H+1]<<8)+(J[H+2]<<16)+((J[H+3]&127)<<24),Q>=2140000000)crypto.randomBytes(4).copy(J,H);else q.push(Q%1e7),H+=4;H=K/4}else throw Error(pJ);if(K=q[--H],$%=w0,K&&$)Q=c0(10,w0-$),q[H]=(K/Q|0)*Q;for(;q[H]===0;H--)q.pop();if(H<0)Z=0,q=[0];else{Z=-1;for(;q[0]===0;Z-=w0)q.shift();for(K=1,Q=q[0];Q>=10;Q/=10)K++;if(K<w0)Z-=w0-K}return z.e=Z,z.d=q,z}function tZ($){return Y0($=new this($),$.e+1,this.rounding)}function eZ($){return $=new this($),$.d?$.d[0]?$.s:0*$.s:$.s||NaN}function $Q($){return new this($).sin()}function JQ($){return new this($).sinh()}function KQ($){return new this($).sqrt()}function ZQ($,J){return new this($).sub(J)}function QQ(){var $=0,J=arguments,Z=new this(J[$]);A0=!1;for(;Z.s&&++$<J.length;)Z=Z.plus(J[$]);return A0=!0,Y0(Z,this.precision,this.rounding)}function HQ($){return new this($).tan()}function zQ($){return new this($).tanh()}function qQ($){return Y0($=new this($),$.e+1,1)}Z0[Symbol.for("nodejs.util.inspect.custom")]=Z0.toString;Z0[Symbol.toStringTag]="Decimal";var h6=Z0.constructor=aJ(F9);F$=new h6(F$);_$=new h6(_$);var L=h6;L.set({precision:80});var bq=new L("1e-40"),fq=new L("1e-10");var M9=($)=>{if($===null||$===void 0)throw new Error(`Cannot convert ${$===null?"null":"undefined"} to Decimal`);if($ instanceof L)return $;try{return new L($)}catch(J){throw new Error(`Invalid numeric value: ${J.message}`)}};class h0{constructor($){if(!Array.isArray($))throw new Error("Vector requires array");if($.length===0)throw new Error("Vector requires at least one component");try{this.data=$.map((J,Z)=>{if(J===null||J===void 0)throw new Error(`Vector component at index ${Z} is ${J===null?"null":"undefined"}`);return M9(J)})}catch(J){throw new Error(`Vector constructor failed: ${J.message}`)}this.length=this.data.length}static from($){if($===null||$===void 0)throw new Error(`Vector.from: argument is ${$===null?"null":"undefined"}`);return new h0($)}clone(){return new h0(this.data.map(($)=>new L($)))}toArray(){return this.data.slice()}toNumberArray(){return this.data.map(($)=>$.toNumber())}toStringArray(){return this.data.map(($)=>$.toString())}add($){if(!$||!($ instanceof h0))throw new Error("add: argument must be a Vector");if(this.length!==$.length)throw new Error(`add: dimension mismatch (${this.length} vs ${$.length})`);return new h0(this.data.map((J,Z)=>J.plus($.data[Z])))}sub($){if(!$||!($ instanceof h0))throw new Error("sub: argument must be a Vector");if(this.length!==$.length)throw new Error(`sub: dimension mismatch (${this.length} vs ${$.length})`);return new h0(this.data.map((J,Z)=>J.minus($.data[Z])))}scale($){if($===null||$===void 0)throw new Error(`scale: scalar is ${$===null?"null":"undefined"}`);let J;try{J=M9($)}catch(Z){throw new Error(`scale: invalid scalar - ${Z.message}`)}return new h0(this.data.map((Z)=>Z.mul(J)))}negate(){return new h0(this.data.map(($)=>$.negated()))}dot($){if(!$||!($ instanceof h0))throw new Error("dot: argument must be a Vector");if(this.length!==$.length)throw new Error(`dot: dimension mismatch (${this.length} vs ${$.length})`);return this.data.reduce((J,Z,K)=>J.plus(Z.mul($.data[K])),new L(0))}outer($){if(!$||!($ instanceof h0))throw new Error("outer: argument must be a Vector");if(this.length===0||$.length===0)throw new Error("outer: cannot compute outer product with empty vector");let J=this.length,Z=$.length;return Array.from({length:J},(Q,H)=>Array.from({length:Z},(z,q)=>this.data[H].mul($.data[q])))}cross($){if(!$||!($ instanceof h0))throw new Error("cross: argument must be a Vector");if(this.length!==3||$.length!==3)throw new Error(`cross: requires 3D vectors (got ${this.length}D and ${$.length}D)`);let[J,Z,K]=this.data,[Q,H,z]=$.data;return new h0([Z.mul(z).minus(K.mul(H)),K.mul(Q).minus(J.mul(z)),J.mul(H).minus(Z.mul(Q))])}norm(){let $=new L(0);for(let J of this.data)$=$.plus(J.mul(J));return $.sqrt()}normalize(){let $=this.norm();if($.isZero())throw new Error("Cannot normalize zero vector");return this.scale(new L(1).div($))}angleBetween($){if(!$||!($ instanceof h0))throw new Error("angleBetween: argument must be a Vector");if(this.length!==$.length)throw new Error(`angleBetween: dimension mismatch (${this.length} vs ${$.length})`);let J=this.dot($),Z=this.norm(),K=$.norm();if(Z.isZero()||K.isZero())throw new Error("angleBetween: angle with zero vector is undefined");let H=J.div(Z.mul(K)).toNumber(),z=Math.min(1,Math.max(-1,H));return new L(Math.acos(z))}projectOnto($){if(!$||!($ instanceof h0))throw new Error("projectOnto: argument must be a Vector");if(this.length!==$.length)throw new Error(`projectOnto: dimension mismatch (${this.length} vs ${$.length})`);let J=$.dot($);if(J.isZero())throw new Error("projectOnto: cannot project onto zero vector");let Z=this.dot($).div(J);return $.scale(Z)}orthogonal(){if(this.norm().isZero())throw new Error("orthogonal: cannot find orthogonal vector to zero vector");if(this.length===2)return new h0([this.data[1].negated(),this.data[0]]);for(let J=0;J<this.length;J++){let Z=Array.from({length:this.length},(q,j)=>new L(j===J?1:0)),K=new h0(Z),Q=K.projectOnto(this),H=K.sub(Q);if(!H.norm().isZero())return H.normalize()}throw new Error("orthogonal: unable to find orthogonal vector (degenerate case)")}isOrthogonalTo($){if(!$||!($ instanceof h0))throw new Error("isOrthogonalTo: argument must be a Vector");if(this.length!==$.length)throw new Error(`isOrthogonalTo: dimension mismatch (${this.length} vs ${$.length})`);return this.dot($).isZero()}distance($){if(!$||!($ instanceof h0))throw new Error("distance: argument must be a Vector");if(this.length!==$.length)throw new Error(`distance: dimension mismatch (${this.length} vs ${$.length})`);return this.sub($).norm()}equals($,J=0){if(!($ instanceof h0))return!1;if($.length!==this.length)return!1;if(J===null)throw new Error("equals: tolerance cannot be null");let Z;try{if(Z=M9(J),Z.isNaN())throw new Error("equals: tolerance cannot be NaN");if(Z.isNegative())throw new Error("equals: tolerance must be non-negative")}catch(K){throw new Error(`equals: invalid tolerance - ${K.message}`)}for(let K=0;K<this.length;K++)if(this.data[K].minus($.data[K]).abs().greaterThan(Z))return!1;return!0}}var Y6=($)=>{if($==null)throw new Error("Cannot convert null or undefined to Decimal");return $ instanceof L?$:new L($)};class V0{constructor($){if(!Array.isArray($)||$.length===0)throw new Error("Matrix requires non-empty 2D array");if(!Array.isArray($[0])||$[0].length===0)throw new Error("Matrix rows must be non-empty arrays");let J=$[0].length;for(let Z of $)if(!Array.isArray(Z)||Z.length!==J)throw new Error("All rows must have same length");this.data=$.map((Z)=>Z.map((K)=>Y6(K))),this.rows=$.length,this.cols=J}static from($){return new V0($)}static zeros($,J){if(!Number.isInteger($)||$<=0)throw new Error("rows must be a positive integer");if(!Number.isInteger(J)||J<=0)throw new Error("cols must be a positive integer");let Z=Array.from({length:$},()=>Array.from({length:J},()=>new L(0)));return new V0(Z)}static identity($){if(!Number.isInteger($)||$<=0)throw new Error("size must be a positive integer");let J=Array.from({length:$},(Z,K)=>Array.from({length:$},(Q,H)=>K===H?new L(1):new L(0)));return new V0(J)}clone(){return new V0(this.data.map(($)=>$.map((J)=>new L(J))))}toArrayOfStrings(){return this.data.map(($)=>$.map((J)=>J.toString()))}toNumberArray(){return this.data.map(($)=>$.map((J)=>J.toNumber()))}isSquare(){return this.rows===this.cols}applyToVector($){let J;if($ instanceof h0)J=$;else if(Array.isArray($))J=h0.from($);else throw new Error("applyToVector expects Vector or array");if(this.cols!==J.length)throw new Error("shape mismatch: matrix cols must equal vector length");let Z=[];for(let K=0;K<this.rows;K++){let Q=new L(0);for(let H=0;H<this.cols;H++)Q=Q.plus(this.data[K][H].mul(J.data[H]));Z.push(Q)}return new h0(Z)}add($){if($ instanceof V0){if(this.rows!==$.rows||this.cols!==$.cols)throw new Error("shape mismatch: matrices must have same dimensions");return new V0(this.data.map((J,Z)=>J.map((K,Q)=>K.plus($.data[Z][Q]))))}else{let J=Y6($);return new V0(this.data.map((Z)=>Z.map((K)=>K.plus(J))))}}sub($){if($ instanceof V0){if(this.rows!==$.rows||this.cols!==$.cols)throw new Error("shape mismatch: matrices must have same dimensions");return new V0(this.data.map((J,Z)=>J.map((K,Q)=>K.minus($.data[Z][Q]))))}else{let J=Y6($);return new V0(this.data.map((Z)=>Z.map((K)=>K.minus(J))))}}mul($){if($ instanceof V0){if(this.cols!==$.rows)throw new Error("shape mismatch: A.cols must equal B.rows for matrix multiplication");let J=Array.from({length:this.rows},()=>Array.from({length:$.cols},()=>new L(0)));for(let Z=0;Z<this.rows;Z++)for(let K=0;K<this.cols;K++){let Q=this.data[Z][K];if(Q.isZero())continue;for(let H=0;H<$.cols;H++)J[Z][H]=J[Z][H].plus(Q.mul($.data[K][H]))}return new V0(J)}else{let J=Y6($);return new V0(this.data.map((Z)=>Z.map((K)=>K.mul(J))))}}div($){let J=Y6($);if(J.isZero())throw new Error("Cannot divide by zero");return new V0(this.data.map((Z)=>Z.map((K)=>K.div(J))))}negate(){return new V0(this.data.map(($)=>$.map((J)=>J.negated())))}transpose(){let $=Array.from({length:this.cols},(J,Z)=>Array.from({length:this.rows},(K,Q)=>new L(this.data[Q][Z])));return new V0($)}trace(){if(!this.isSquare())throw new Error("Trace only defined for square matrices");let $=new L(0);for(let J=0;J<this.rows;J++)$=$.plus(this.data[J][J]);return $}equals($,J=0){if(!($ instanceof V0))return!1;if(this.rows!==$.rows||this.cols!==$.cols)return!1;let Z=Y6(J);if(Z.isNegative()||!Z.isFinite())throw new Error("tolerance must be non-negative and finite");for(let K=0;K<this.rows;K++)for(let Q=0;Q<this.cols;Q++)if(this.data[K][Q].minus($.data[K][Q]).abs().greaterThan(Z))return!1;return!0}lu(){if(!this.isSquare())throw new Error("LU decomposition requires square matrix");let $=this.rows,J=this.data.map((z)=>z.map((q)=>new L(q))),Z=Array.from({length:$},(z,q)=>q),K=Array.from({length:$},()=>Array.from({length:$},()=>new L(0)));for(let z=0;z<$;z++)K[z][z]=new L(1);for(let z=0;z<$;z++){let q=z,j=J[z][z].abs();for(let W=z+1;W<$;W++){let G=J[W][z].abs();if(G.greaterThan(j))j=G,q=W}if(J[q][z].isZero())throw new Error("Singular matrix: LU decomposition failed");if(q!==z){let W=J[z];J[z]=J[q],J[q]=W;let G=Z[z];Z[z]=Z[q],Z[q]=G;for(let F=0;F<z;F++){let _=K[z][F];K[z][F]=K[q][F],K[q][F]=_}}for(let W=z+1;W<$;W++){let G=J[W][z].div(J[z][z]);K[W][z]=G;for(let F=z;F<$;F++)J[W][F]=J[W][F].minus(G.mul(J[z][F]))}}let Q=Array.from({length:$},(z,q)=>Array.from({length:$},(j,W)=>W<q?new L(0):J[q][W])),H=V0.zeros($,$);for(let z=0;z<$;z++)H.data[z][Z[z]]=new L(1);return{L:new V0(K),U:new V0(Q),P:H}}determinant(){if(!this.isSquare())throw new Error("Determinant only defined for square matrices");let $=this.rows,{L:J,U:Z,P:K}=this.lu(),Q=new L(1);for(let q=0;q<$;q++)Q=Q.mul(Z.data[q][q]);let H=[];for(let q=0;q<$;q++)for(let j=0;j<$;j++)if(K.data[q][j].equals(1))H.push(j);let z=0;for(let q=0;q<H.length;q++)for(let j=q+1;j<H.length;j++)if(H[q]>H[j])z++;if(z%2===1)Q=Q.negated();return Q}inverse(){if(!this.isSquare())throw new Error("Inverse only defined for square matrices");let $=this.rows,J=Array.from({length:$},(K,Q)=>Array.from({length:2*$},(H,z)=>z<$?new L(this.data[Q][z]):z-$===Q?new L(1):new L(0)));for(let K=0;K<$;K++){let Q=K,H=J[K][K].abs();for(let q=K+1;q<$;q++){let j=J[q][K].abs();if(j.greaterThan(H))H=j,Q=q}if(J[Q][K].isZero())throw new Error("Singular matrix: inverse does not exist");if(Q!==K){let q=J[K];J[K]=J[Q],J[Q]=q}let z=J[K][K];for(let q=0;q<2*$;q++)J[K][q]=J[K][q].div(z);for(let q=0;q<$;q++){if(q===K)continue;let j=J[q][K];if(j.isZero())continue;for(let W=0;W<2*$;W++)J[q][W]=J[q][W].minus(j.mul(J[K][W]))}}let Z=J.map((K)=>K.slice($));return new V0(Z)}solve($){let J;if($ instanceof h0)J=$;else if(Array.isArray($))J=h0.from($);else throw new Error("b must be Vector or array");if(!this.isSquare())throw new Error("solve() only implemented for square matrices");let Z=this.rows;if(J.length!==Z)throw new Error("dimension mismatch: b length must equal matrix rows");let K=Array.from({length:Z},(H,z)=>Array.from({length:Z+1},(q,j)=>new L(j<Z?this.data[z][j]:J.data[z])));for(let H=0;H<Z;H++){let z=H,q=K[H][H].abs();for(let j=H+1;j<Z;j++){let W=K[j][H].abs();if(W.greaterThan(q))q=W,z=j}if(K[z][H].isZero())throw new Error("Singular matrix: no unique solution");if(z!==H){let j=K[H];K[H]=K[z],K[z]=j}for(let j=H+1;j<Z;j++){let W=K[j][H].div(K[H][H]);if(W.isZero())continue;for(let G=H;G<Z+1;G++)K[j][G]=K[j][G].minus(W.mul(K[H][G]))}}let Q=Array.from({length:Z},()=>new L(0));for(let H=Z-1;H>=0;H--){if(K[H][H].isZero())throw new Error("Zero diagonal element in back substitution: system is singular");let z=new L(0);for(let q=H+1;q<Z;q++)z=z.plus(K[H][q].mul(Q[q]));Q[H]=K[H][Z].minus(z).div(K[H][H])}return new h0(Q)}qr(){let $=this.rows,J=this.cols,Z=this.data.map((H)=>H.map((z)=>new L(z))),K=V0.identity($).data;for(let H=0;H<Math.min($,J);H++){let z=[];for(let F=H;F<$;F++)z.push(Z[F][H]);let q=new L(0);for(let F of z)q=q.plus(F.mul(F));if(q=q.sqrt(),q.isZero())continue;let j=z[0].isNegative()?new L(-1):new L(1),W=z.slice();W[0]=W[0].plus(j.mul(q));let G=new L(0);for(let F of W)G=G.plus(F.mul(F));if(G=G.sqrt(),G.isZero())continue;for(let F=0;F<W.length;F++)W[F]=W[F].div(G);for(let F=H;F<J;F++){let _=new L(0);for(let U=0;U<W.length;U++)_=_.plus(W[U].mul(Z[H+U][F]));for(let U=0;U<W.length;U++)Z[H+U][F]=Z[H+U][F].minus(new L(2).mul(W[U]).mul(_))}for(let F=0;F<$;F++){let _=new L(0);for(let U=0;U<W.length;U++)_=_.plus(W[U].mul(K[H+U][F]));for(let U=0;U<W.length;U++)K[H+U][F]=K[H+U][F].minus(new L(2).mul(W[U]).mul(_))}}let Q=Array.from({length:$},(H,z)=>Array.from({length:J},(q,j)=>z<=j?Z[z][j]:new L(0)));return{Q:new V0(K).transpose(),R:new V0(Q)}}exp($={}){let J=this.rows;if(!this.isSquare())throw new Error("Matrix exponential requires square matrix");let Z=V0.identity(J),K=$.maxIter||120;if(!Number.isInteger(K)||K<=0)throw new Error("maxIter must be a positive integer");let Q=new L($.tolerance||"1e-40");if(Q.isNegative()||Q.isZero()||!Q.isFinite())throw new Error("tolerance must be positive and finite");let z=((F)=>{let _=new L(0);for(let U=0;U<F.rows;U++){let M=new L(0);for(let V=0;V<F.cols;V++)M=M.plus(F.data[U][V].abs());if(M.greaterThan(_))_=M}return _})(this),q=0;if(z.greaterThan(new L(1))){let F=z.toNumber();if(!isFinite(F))throw new Error("Matrix norm too large for exponential computation");if(q=Math.max(0,Math.ceil(Math.log2(F))),q>50)throw new Error(`Matrix norm too large: requires ${q} scaling steps (max 50 allowed)`)}let j=this;if(q>0)j=this.mul(new L(1).div(new L(2).pow(q)));let W=Z.clone(),G=Z.clone();for(let F=1;F<K;F++){W=W.mul(j).mul(new L(1).div(F)),G=G.add(W);let _=new L(0);for(let U=0;U<W.rows;U++)for(let M=0;M<W.cols;M++)_=_.plus(W.data[U][M].abs());if(_.lessThan(Q))break}for(let F=0;F<q;F++)G=G.mul(G);return G}}L.set({precision:80});var g0=($)=>$ instanceof L?$:new L($),jQ=new L("1e-40"),GQ=new L("1e-30");function FQ($,J){if($==null)throw new TypeError("translationMatrix: tx parameter is required");if(J==null)throw new TypeError("translationMatrix: ty parameter is required");return V0.from([[1,0,g0($)],[0,1,g0(J)],[0,0,1]])}function _Q($){if($==null)throw new TypeError("rotationMatrix: angle parameter is required");let J=g0($),Z=L.cos(J),K=L.sin(J);return V0.from([[Z,K.neg(),0],[K,Z,0],[0,0,1]])}function UQ($,J){if($==null)throw new TypeError("scaleMatrix: sx parameter is required");if(J==null)throw new TypeError("scaleMatrix: sy parameter is required");return V0.from([[g0($),0,0],[0,g0(J),0],[0,0,1]])}function VQ($){if($==null)throw new TypeError("skewXMatrix: angle parameter is required");let J=L.tan(g0($));return V0.from([[1,J,0],[0,1,0],[0,0,1]])}function MQ($){if($==null)throw new TypeError("skewYMatrix: angle parameter is required");let J=L.tan(g0($));return V0.from([[1,0,0],[J,1,0],[0,0,1]])}function OQ($){if(!$)throw new TypeError("extractLinearPart: matrix parameter is required");if(!$.data)throw new TypeError("extractLinearPart: matrix must have data property");if($.rows<2||$.cols<2)throw new RangeError("extractLinearPart: matrix must be at least 2x2");let J=$.data;return{a:J[0][0],b:J[1][0],c:J[0][1],d:J[1][1]}}function YQ($){if(!$)throw new TypeError("extractTranslation: matrix parameter is required");if(!$.data)throw new TypeError("extractTranslation: matrix must have data property");if($.rows<2||$.cols<3)throw new RangeError("extractTranslation: matrix must be at least 2x3");let J=$.data;return{tx:J[0][2],ty:J[1][2]}}function tJ($){if(!$)throw new TypeError("decomposeMatrix: matrix parameter is required");let{a:J,b:Z,c:K,d:Q}=OQ($),{tx:H,ty:z}=YQ($),q=J.mul(Q).minus(Z.mul(K)),j=J.mul(J).plus(Z.mul(Z)).sqrt();if(j.abs().lessThan(jQ))return{translateX:H,translateY:z,rotation:g0(0),scaleX:g0(0),scaleY:g0(0),skewX:g0(0),skewY:g0(0),verified:!1,maxError:g0("Infinity"),singular:!0};let W=q.div(j);if(W.abs().greaterThan(new L("1e40")))return{translateX:H,translateY:z,rotation:g0(0),scaleX:g0(0),scaleY:g0(0),skewX:g0(0),skewY:g0(0),verified:!1,maxError:g0("Infinity"),singular:!0};if(q.lessThan(0))j=j.neg(),W=W.neg();let G;if(j.lessThan(0))G=L.atan2(Z.neg(),J.neg());else G=L.atan2(Z,J);let F=L.cos(G),_=L.sin(G),U=J.mul(F).plus(Z.mul(_)),M=K.mul(F).plus(Q.mul(_)),V,Y=new L("1e-30");if(U.abs().greaterThan(Y)){let B=M.div(U);if(B.abs().greaterThan(new L("1e10")))V=g0(0);else V=L.atan(B)}else V=g0(0);let O=g0(0),X=XQ({translateX:H,translateY:z,rotation:G,scaleX:j,scaleY:W,skewX:V,skewY:g0(0)}),w=LQ($,X),R=w.lessThan(GQ);return{translateX:H,translateY:z,rotation:G,scaleX:j,scaleY:W,skewX:V,skewY:O,verified:R,maxError:w}}function XQ($){if(!$)throw new TypeError("composeTransform: components parameter is required");if($.translateX==null)throw new TypeError("composeTransform: components.translateX is required");if($.translateY==null)throw new TypeError("composeTransform: components.translateY is required");if($.rotation==null)throw new TypeError("composeTransform: components.rotation is required");if($.scaleX==null)throw new TypeError("composeTransform: components.scaleX is required");if($.scaleY==null)throw new TypeError("composeTransform: components.scaleY is required");if($.skewX==null)throw new TypeError("composeTransform: components.skewX is required");let{translateX:J,translateY:Z,rotation:K,scaleX:Q,scaleY:H,skewX:z,skewY:q=0}=$,j=FQ(J,Z),W=_Q(K),G=VQ(z),F=MQ(q),_=UQ(Q,H);return j.mul(W).mul(F).mul(G).mul(_)}function LQ($,J){if(!$)throw new TypeError("matrixMaxDifference: m1 parameter is required");if(!J)throw new TypeError("matrixMaxDifference: m2 parameter is required");if(!$.data)throw new TypeError("matrixMaxDifference: m1 must have data property");if(!J.data)throw new TypeError("matrixMaxDifference: m2 must have data property");if($.rows!==J.rows||$.cols!==J.cols)throw new RangeError(`matrixMaxDifference: matrices must have same dimensions (${$.rows}x${$.cols} vs ${J.rows}x${J.cols})`);let Z=g0(0);for(let K=0;K<$.rows;K++)for(let Q=0;Q<$.cols;Q++){let H=$.data[K][Q].minus(J.data[K][Q]).abs();if(H.greaterThan(Z))Z=H}return Z}L.set({precision:80});var _7=($)=>$ instanceof L?$:new L($),x0=new L("1e-40"),eJ=100;function A7($,J){if($==null)throw new TypeError("point: x coordinate cannot be null or undefined");if(J==null)throw new TypeError("point: y coordinate cannot be null or undefined");return{x:_7($),y:_7(J)}}function wQ($,J){if(!$||$.x==null||$.y==null)throw new TypeError("vectorAdd: first vector must have x and y properties");if(!J||J.x==null||J.y==null)throw new TypeError("vectorAdd: second vector must have x and y properties");return{x:$.x.plus(J.x),y:$.y.plus(J.y)}}function m0($,J){if(!$||$.x==null||$.y==null)throw new TypeError("vectorSub: first vector must have x and y properties");if(!J||J.x==null||J.y==null)throw new TypeError("vectorSub: second vector must have x and y properties");return{x:$.x.minus(J.x),y:$.y.minus(J.y)}}function u6($){if(!$||$.x==null||$.y==null)throw new TypeError("vectorNeg: vector must have x and y properties");return{x:$.x.neg(),y:$.y.neg()}}function Y9($,J){if(!$||$.x==null||$.y==null)throw new TypeError("vectorScale: vector must have x and y properties");if(J==null)throw new TypeError("vectorScale: scale factor cannot be null or undefined");let Z=_7(J);return{x:$.x.mul(Z),y:$.y.mul(Z)}}function Q7($,J){if(!$||$.x==null||$.y==null)throw new TypeError("dot: first vector must have x and y properties");if(!J||J.x==null||J.y==null)throw new TypeError("dot: second vector must have x and y properties");return $.x.mul(J.x).plus($.y.mul(J.y))}function y6($,J){if(!$||$.x==null||$.y==null)throw new TypeError("cross: first vector must have x and y properties");if(!J||J.x==null||J.y==null)throw new TypeError("cross: second vector must have x and y properties");return $.x.mul(J.y).minus($.y.mul(J.x))}function F7($){if(!$||$.x==null||$.y==null)throw new TypeError("magnitudeSquared: vector must have x and y properties");return $.x.mul($.x).plus($.y.mul($.y))}function H6($){if(!$||$.x==null||$.y==null)throw new TypeError("magnitude: vector must have x and y properties");return F7($).sqrt()}function RQ($){if(!$||$.x==null||$.y==null)throw new TypeError("normalize: vector must have x and y properties");let J=H6($);if(J.lessThan(x0))return{x:_7(0),y:_7(0)};return{x:$.x.div(J),y:$.y.div(J)}}function i7($,J,Z){if(!$||$.x==null||$.y==null)throw new TypeError("tripleProduct: first vector must have x and y properties");if(!J||J.x==null||J.y==null)throw new TypeError("tripleProduct: second vector must have x and y properties");if(!Z||Z.x==null||Z.y==null)throw new TypeError("tripleProduct: third vector must have x and y properties");let K=Q7($,Z),Q=Q7(J,Z);return m0(Y9(J,K),Y9($,Q))}function $5($,J){if(!Array.isArray($))throw new TypeError("supportPoint: polygon must be an array");if(!J||J.x==null||J.y==null)throw new TypeError("supportPoint: direction must have x and y properties");if($.length===0)throw new TypeError("supportPoint: polygon cannot be empty");if(!$[0]||$[0].x==null||$[0].y==null)throw new TypeError("supportPoint: polygon[0] must have x and y properties");let Z=Q7($[0],J),K=$[0];for(let Q=1;Q<$.length;Q++){if(!$[Q]||$[Q].x==null||$[Q].y==null)throw new TypeError(`supportPoint: polygon[${Q}] must have x and y properties`);let H=Q7($[Q],J);if(H.greaterThan(Z))Z=H,K=$[Q]}return K}function J5($,J,Z){if(!Array.isArray($))throw new TypeError("minkowskiSupport: polygonA must be an array");if(!Array.isArray(J))throw new TypeError("minkowskiSupport: polygonB must be an array");if(!Z||Z.x==null||Z.y==null)throw new TypeError("minkowskiSupport: direction must have x and y properties");let K=$5($,Z),Q=$5(J,u6(Z));return m0(K,Q)}function BQ($,J){if(!Array.isArray($))throw new TypeError("processLineSimplex: simplex must be an array");if($.length!==2)throw new TypeError("processLineSimplex: simplex must have exactly 2 points");if(!J||J.x==null||J.y==null)throw new TypeError("processLineSimplex: direction must have x and y properties");if(!$[0]||$[0].x==null||$[0].y==null)throw new TypeError("processLineSimplex: simplex[0] must have x and y properties");if(!$[1]||$[1].x==null||$[1].y==null)throw new TypeError("processLineSimplex: simplex[1] must have x and y properties");let Z=$[0],K=$[1],Q=m0(K,Z),H=u6(Z),z=F7(Q);if(z.lessThan(x0)){if(F7(Z).lessThan(x0))return{contains:!0,newDirection:J};return{contains:!1,newDirection:H}}let q=i7(Q,H,Q);if(F7(q).lessThan(x0)){let j=Q7(Q,H);if(j.greaterThanOrEqualTo(0)&&j.lessThanOrEqualTo(z))return{contains:!0,newDirection:J};return{contains:!1,newDirection:H}}return{contains:!1,newDirection:q}}function NQ($,J){if(!Array.isArray($))throw new TypeError("processTriangleSimplex: simplex must be an array");if($.length!==3)throw new TypeError("processTriangleSimplex: simplex must have exactly 3 points");if(!J||J.x==null||J.y==null)throw new TypeError("processTriangleSimplex: direction must have x and y properties");if(!$[0]||$[0].x==null||$[0].y==null)throw new TypeError("processTriangleSimplex: simplex[0] must have x and y properties");if(!$[1]||$[1].x==null||$[1].y==null)throw new TypeError("processTriangleSimplex: simplex[1] must have x and y properties");if(!$[2]||$[2].x==null||$[2].y==null)throw new TypeError("processTriangleSimplex: simplex[2] must have x and y properties");let Z=$[0],K=$[1],Q=$[2],H=m0(K,Z),z=m0(Q,Z),q=u6(Z),j=F7(H),W=F7(z);if(j.lessThan(x0))return{contains:!1,newDirection:i7(z,q,z),newSimplex:[Z,Q]};if(W.lessThan(x0))return{contains:!1,newDirection:i7(H,q,H),newSimplex:[Z,K]};let G=i7(z,H,H),F=i7(H,z,z);if(F7(G).lessThan(x0)&&F7(F).lessThan(x0)){let _=m0(Q,K),U=F7(_);if(U.greaterThan(j)&&U.greaterThan(W))return{contains:!1,newDirection:i7(_,u6(K),_),newSimplex:[K,Q]};else if(j.greaterThan(W))return{contains:!1,newDirection:i7(H,q,H),newSimplex:[Z,K]};else return{contains:!1,newDirection:i7(z,q,z),newSimplex:[Z,Q]}}if(Q7(G,q).greaterThan(x0))return{contains:!1,newDirection:G,newSimplex:[Z,K]};if(Q7(F,q).greaterThan(x0))return{contains:!1,newDirection:F,newSimplex:[Z,Q]};return{contains:!0,newDirection:J,newSimplex:$}}function Q5($,J){if(!Array.isArray($))throw new TypeError("gjkIntersects: polygonA must be an array");if(!Array.isArray(J))throw new TypeError("gjkIntersects: polygonB must be an array");if($.length===0||J.length===0)return{intersects:!1,iterations:0,simplex:[],verified:!0};if($.length===1&&J.length===1){if(!$[0]||$[0].x==null||$[0].y==null)throw new TypeError("gjkIntersects: polygonA[0] must have x and y properties");if(!J[0]||J[0].x==null||J[0].y==null)throw new TypeError("gjkIntersects: polygonB[0] must have x and y properties");return{intersects:H6(m0($[0],J[0])).lessThan(x0),iterations:1,simplex:[],verified:!0}}let Z=m0(Y$(J),Y$($));if(F7(Z).lessThan(x0))Z=A7(1,0);let K=[J5($,J,Z)];if(Z=u6(K[0]),F7(K[0]).lessThan(x0))return{intersects:!0,iterations:1,simplex:K,verified:O9($,J)};for(let Q=0;Q<eJ;Q++){let H=J5($,J,Z);if(Q7(H,Z).lessThanOrEqualTo(_7(0)))return{intersects:!1,iterations:Q+1,simplex:K,verified:!0};if(K.unshift(H),K.length===2){let z=BQ(K,Z);if(z.contains)return{intersects:!0,iterations:Q+1,simplex:K,verified:O9($,J)};Z=z.newDirection}else if(K.length===3){let z=NQ(K,Z);if(z.contains)return{intersects:!0,iterations:Q+1,simplex:z.newSimplex,verified:O9($,J)};K=z.newSimplex,Z=z.newDirection}if(F7(Z).lessThan(x0))return{intersects:!1,iterations:Q+1,simplex:K,verified:!1};Z=RQ(Z)}return{intersects:!1,iterations:eJ,simplex:K,verified:!1}}function Y$($){if(!Array.isArray($))throw new TypeError("centroid: polygon must be an array");if($.length===0)throw new TypeError("centroid: polygon cannot be empty");let J=_7(0),Z=_7(0);for(let Q=0;Q<$.length;Q++){if(!$[Q]||$[Q].x==null||$[Q].y==null)throw new TypeError(`centroid: polygon[${Q}] must have x and y properties`);J=J.plus($[Q].x),Z=Z.plus($[Q].y)}let K=_7($.length);return{x:J.div(K),y:Z.div(K)}}function K5($,J){if(!$||$.x==null||$.y==null)throw new TypeError("pointInConvexPolygon: point must have x and y properties");if(!Array.isArray(J))throw new TypeError("pointInConvexPolygon: polygon must be an array");if(J.length<3)return!1;let Z=null;for(let K=0;K<J.length;K++){let Q=J[K],H=J[(K+1)%J.length];if(!Q||Q.x==null||Q.y==null)throw new TypeError(`pointInConvexPolygon: polygon[${K}] must have x and y properties`);if(!H||H.x==null||H.y==null)throw new TypeError(`pointInConvexPolygon: polygon[${(K+1)%J.length}] must have x and y properties`);let z=m0(H,Q),q=m0($,Q),j=y6(z,q);if(j.abs().lessThan(x0))continue;let W=j.greaterThan(0);if(Z===null)Z=W;else if(Z!==W)return!1}return!0}function O9($,J){if(!Array.isArray($))throw new TypeError("verifyIntersection: polygonA must be an array");if(!Array.isArray(J))throw new TypeError("verifyIntersection: polygonB must be an array");for(let Z=0;Z<$.length;Z++){if(!$[Z]||$[Z].x==null||$[Z].y==null)throw new TypeError(`verifyIntersection: polygonA[${Z}] must have x and y properties`);if(K5($[Z],J))return!0}for(let Z=0;Z<J.length;Z++){if(!J[Z]||J[Z].x==null||J[Z].y==null)throw new TypeError(`verifyIntersection: polygonB[${Z}] must have x and y properties`);if(K5(J[Z],$))return!0}for(let Z=0;Z<$.length;Z++){let K=$[Z],Q=$[(Z+1)%$.length];if(!K||K.x==null||K.y==null)throw new TypeError(`verifyIntersection: polygonA[${Z}] must have x and y properties`);if(!Q||Q.x==null||Q.y==null)throw new TypeError(`verifyIntersection: polygonA[${(Z+1)%$.length}] must have x and y properties`);for(let H=0;H<J.length;H++){let z=J[H],q=J[(H+1)%J.length];if(!z||z.x==null||z.y==null)throw new TypeError(`verifyIntersection: polygonB[${H}] must have x and y properties`);if(!q||q.x==null||q.y==null)throw new TypeError(`verifyIntersection: polygonB[${(H+1)%J.length}] must have x and y properties`);if(CQ(K,Q,z,q))return!0}}return!1}function CQ($,J,Z,K){if(!$||$.x==null||$.y==null)throw new TypeError("segmentsIntersect: a1 must have x and y properties");if(!J||J.x==null||J.y==null)throw new TypeError("segmentsIntersect: a2 must have x and y properties");if(!Z||Z.x==null||Z.y==null)throw new TypeError("segmentsIntersect: b1 must have x and y properties");if(!K||K.x==null||K.y==null)throw new TypeError("segmentsIntersect: b2 must have x and y properties");let Q=m0(J,$),H=m0(K,Z),z=y6(Q,H);if(z.abs().lessThan(x0)){let G=m0(Z,$);if(y6(Q,G).abs().lessThan(x0)){let F=Q7(Q,Q);if(F.lessThan(x0)){let O=Q7(H,H);if(O.lessThan(x0))return H6(G).lessThan(x0);let X=Q7(G,H).div(O);return X.greaterThanOrEqualTo(0)&&X.lessThanOrEqualTo(1)}let _=Q7(G,Q).div(F),U=m0(K,$),M=Q7(U,Q).div(F),V=L.min(_,M);return L.max(_,M).greaterThanOrEqualTo(0)&&V.lessThanOrEqualTo(1)}return!1}let q=m0(Z,$),j=y6(q,H).div(z),W=y6(q,Q).div(z);return j.greaterThanOrEqualTo(0)&&j.lessThanOrEqualTo(1)&&W.greaterThanOrEqualTo(0)&&W.lessThanOrEqualTo(1)}function IQ($,J){if(!Array.isArray($))throw new TypeError("gjkDistance: polygonA must be an array");if(!Array.isArray(J))throw new TypeError("gjkDistance: polygonB must be an array");if($.length===0)throw new TypeError("gjkDistance: polygonA cannot be empty");if(J.length===0)throw new TypeError("gjkDistance: polygonB cannot be empty");if(Q5($,J).intersects)return{distance:_7(0),closestA:Y$($),closestB:Y$(J),verified:!0};if(!$[0]||$[0].x==null||$[0].y==null)throw new TypeError("gjkDistance: polygonA[0] must have x and y properties");if(!J[0]||J[0].x==null||J[0].y==null)throw new TypeError("gjkDistance: polygonB[0] must have x and y properties");let K=_7(1/0),Q=$[0],H=J[0];for(let j=0;j<$.length;j++){if(!$[j]||$[j].x==null||$[j].y==null)throw new TypeError(`gjkDistance: polygonA[${j}] must have x and y properties`);for(let W=0;W<J.length;W++){if(!J[W]||J[W].x==null||J[W].y==null)throw new TypeError(`gjkDistance: polygonB[${W}] must have x and y properties`);let G=H6(m0($[j],J[W]));if(G.lessThan(K))K=G,Q=$[j],H=J[W]}}for(let j=0;j<$.length;j++){if(!$[j]||$[j].x==null||$[j].y==null)throw new TypeError(`gjkDistance: polygonA[${j}] must have x and y properties`);for(let W=0;W<J.length;W++){let G=J[W],F=J[(W+1)%J.length];if(!G||G.x==null||G.y==null)throw new TypeError(`gjkDistance: polygonB[${W}] must have x and y properties`);if(!F||F.x==null||F.y==null)throw new TypeError(`gjkDistance: polygonB[${(W+1)%J.length}] must have x and y properties`);let _=Z5($[j],G,F),U=H6(m0($[j],_));if(U.lessThan(K))K=U,Q=$[j],H=_}}for(let j=0;j<J.length;j++){if(!J[j]||J[j].x==null||J[j].y==null)throw new TypeError(`gjkDistance: polygonB[${j}] must have x and y properties`);for(let W=0;W<$.length;W++){let G=$[W],F=$[(W+1)%$.length];if(!G||G.x==null||G.y==null)throw new TypeError(`gjkDistance: polygonA[${W}] must have x and y properties`);if(!F||F.x==null||F.y==null)throw new TypeError(`gjkDistance: polygonA[${(W+1)%$.length}] must have x and y properties`);let _=Z5(J[j],G,F),U=H6(m0(J[j],_));if(U.lessThan(K))K=U,Q=_,H=J[j]}}let q=H6(m0(Q,H)).minus(K).abs().lessThan(x0);return{distance:K,closestA:Q,closestB:H,verified:q}}function Z5($,J,Z){if(!$||$.x==null||$.y==null)throw new TypeError("closestPointOnSegment: pt must have x and y properties");if(!J||J.x==null||J.y==null)throw new TypeError("closestPointOnSegment: a must have x and y properties");if(!Z||Z.x==null||Z.y==null)throw new TypeError("closestPointOnSegment: b must have x and y properties");let K=m0(Z,J),Q=m0($,J),H=F7(K);if(H.lessThan(x0))return J;let z=Q7(Q,K).div(H);return z=L.max(_7(0),L.min(_7(1),z)),wQ(J,Y9(K,z))}function X$($,J){if(!Array.isArray($))throw new TypeError("polygonsOverlap: polygonA must be an array");if(!Array.isArray(J))throw new TypeError("polygonsOverlap: polygonB must be an array");let Z=$.map((H,z)=>{if(!H||H.x==null||H.y==null)throw new TypeError(`polygonsOverlap: polygonA[${z}] must have x and y properties`);return A7(H.x,H.y)}),K=J.map((H,z)=>{if(!H||H.x==null||H.y==null)throw new TypeError(`polygonsOverlap: polygonB[${z}] must have x and y properties`);return A7(H.x,H.y)}),Q=Q5(Z,K);return{overlaps:Q.intersects,verified:Q.verified}}function H5($,J){if(!Array.isArray($))throw new TypeError("polygonsDistance: polygonA must be an array");if(!Array.isArray(J))throw new TypeError("polygonsDistance: polygonB must be an array");let Z=$.map((H,z)=>{if(!H||H.x==null||H.y==null)throw new TypeError(`polygonsDistance: polygonA[${z}] must have x and y properties`);return A7(H.x,H.y)}),K=J.map((H,z)=>{if(!H||H.x==null||H.y==null)throw new TypeError(`polygonsDistance: polygonB[${z}] must have x and y properties`);return A7(H.x,H.y)}),Q=IQ(Z,K);return{distance:Q.distance,closestA:Q.closestA,closestB:Q.closestB,verified:Q.verified}}L.set({precision:80});var dq=new L("1e-40"),pq=new L("1e-10");L.set({precision:80});var nq=new L("1e-40"),sq=new L("1e-30");L.set({precision:80});var j0=($)=>$ instanceof L?$:new L($),rq=new L("1e-40"),TQ=new L("1e-10");function j5($){if(typeof $!=="string")throw new Error("ViewBox must be a string");let J=$.trim().split(/[\s,]+/).filter((Z)=>Z.length>0);if(J.length!==4)throw new Error(`Invalid viewBox format: expected 4 values, got ${J.length}`);try{let Z=j0(J[0]),K=j0(J[1]),Q=j0(J[2]),H=j0(J[3]);if(Q.lessThanOrEqualTo(0)||H.lessThanOrEqualTo(0))throw new Error("ViewBox width and height must be positive");let z=`${Z.toString()} ${K.toString()} ${Q.toString()} ${H.toString()}`,q=J.join(" ");return{x:Z,y:K,width:Q,height:H,verified:z===q}}catch(Z){throw new Error(`Invalid viewBox values: ${Z.message}`)}}function bQ($,J,Z,K){if($==null||J==null||Z==null||K==null)throw new Error("createBBox: all parameters (minX, minY, maxX, maxY) must be provided");let Q=j0($),H=j0(J),z=j0(Z),q=j0(K);if(z.lessThan(Q))throw new Error(`createBBox: maxX (${z}) must be >= minX (${Q})`);if(q.lessThan(H))throw new Error(`createBBox: maxY (${q}) must be >= minY (${H})`);return{minX:Q,minY:H,maxX:z,maxY:q,width:z.minus(Q),height:q.minus(H)}}function z5($,J,Z,K,Q,H,z,q,j=20){if($==null||J==null||Z==null||K==null||Q==null||H==null||z==null||q==null)throw new Error("sampleCubicBezier: all coordinate parameters must be provided");if(j==null||j<=0)throw new Error("sampleCubicBezier: samples must be a positive number");let W=[];for(let G=0;G<=j;G++){let F=j0(G).div(j),_=j0(1).minus(F),U=F.mul(F),M=U.mul(F),V=_.mul(_),Y=V.mul(_),O=Y.mul($).plus(j0(3).mul(V).mul(F).mul(Z)).plus(j0(3).mul(_).mul(U).mul(Q)).plus(M.mul(z)),X=Y.mul(J).plus(j0(3).mul(V).mul(F).mul(K)).plus(j0(3).mul(_).mul(U).mul(H)).plus(M.mul(q));W.push({x:O,y:X})}return W}function q5($,J,Z,K,Q,H,z=20){if($==null||J==null||Z==null||K==null||Q==null||H==null)throw new Error("sampleQuadraticBezier: all coordinate parameters must be provided");if(z==null||z<=0)throw new Error("sampleQuadraticBezier: samples must be a positive number");let q=[];for(let j=0;j<=z;j++){let W=j0(j).div(z),G=j0(1).minus(W),F=G.mul(G),_=W.mul(W),U=F.mul($).plus(j0(2).mul(G).mul(W).mul(Z)).plus(_.mul(Q)),M=F.mul(J).plus(j0(2).mul(G).mul(W).mul(K)).plus(_.mul(H));q.push({x:U,y:M})}return q}function fQ($,J,Z=TQ){if(!$||typeof $!=="object"||$.x==null||$.y==null)throw new Error("pointInBBox: pt must be an object with x and y properties");if(!J||typeof J!=="object")throw new Error("pointInBBox: bbox must be a bounding box object");if(J.minX==null||J.minY==null||J.maxX==null||J.maxY==null)throw new Error("pointInBBox: bbox must have minX, minY, maxX, maxY properties");return $.x.greaterThanOrEqualTo(J.minX.minus(Z))&&$.x.lessThanOrEqualTo(J.maxX.plus(Z))&&$.y.greaterThanOrEqualTo(J.minY.minus(Z))&&$.y.lessThanOrEqualTo(J.maxY.plus(Z))}function G5($){if(!$||$.length===0)throw new Error("pathBoundingBox: path commands array is empty");let J=j0(1/0),Z=j0(1/0),K=j0(-1/0),Q=j0(-1/0),H=j0(0),z=j0(0),q=j0(0),j=j0(0),W=j0(0),G=j0(0),F=null,_=[];for(let V of $){if(!V||typeof V!=="object"||!V.type||typeof V.type!=="string")throw new Error("pathBoundingBox: each command must be an object with a string type property");let Y=V.type.toUpperCase(),O=V.type===V.type.toLowerCase();switch(Y){case"M":{if(V.x==null||V.y==null)throw new Error("pathBoundingBox: M command requires x and y properties");let X=O?H.plus(j0(V.x)):j0(V.x),w=O?z.plus(j0(V.y)):j0(V.y);H=X,z=w,q=H,j=z,J=L.min(J,H),Z=L.min(Z,z),K=L.max(K,H),Q=L.max(Q,z),_.push({x:H,y:z}),W=H,G=z,F="M"}break;case"L":{if(V.x==null||V.y==null)throw new Error("pathBoundingBox: L command requires x and y properties");let X=O?H.plus(j0(V.x)):j0(V.x),w=O?z.plus(j0(V.y)):j0(V.y);J=L.min(J,X),Z=L.min(Z,w),K=L.max(K,X),Q=L.max(Q,w),_.push({x:X,y:w}),H=X,z=w,W=H,G=z,F="L"}break;case"H":{if(V.x==null)throw new Error("pathBoundingBox: H command requires x property");let X=O?H.plus(j0(V.x)):j0(V.x);J=L.min(J,X),K=L.max(K,X),_.push({x:X,y:z}),H=X,W=H,G=z,F="H"}break;case"V":{if(V.y==null)throw new Error("pathBoundingBox: V command requires y property");let X=O?z.plus(j0(V.y)):j0(V.y);Z=L.min(Z,X),Q=L.max(Q,X),_.push({x:H,y:X}),z=X,W=H,G=z,F="V"}break;case"C":{if(V.x1==null||V.y1==null||V.x2==null||V.y2==null||V.x==null||V.y==null)throw new Error("pathBoundingBox: C command requires x1, y1, x2, y2, x, y properties");let X=O?H.plus(j0(V.x1)):j0(V.x1),w=O?z.plus(j0(V.y1)):j0(V.y1),R=O?H.plus(j0(V.x2)):j0(V.x2),B=O?z.plus(j0(V.y2)):j0(V.y2),I=O?H.plus(j0(V.x)):j0(V.x),h=O?z.plus(j0(V.y)):j0(V.y),m=z5(H,z,X,w,R,B,I,h,20);for(let v of m)J=L.min(J,v.x),Z=L.min(Z,v.y),K=L.max(K,v.x),Q=L.max(Q,v.y),_.push(v);W=R,G=B,H=I,z=h,F="C"}break;case"S":{if(V.x2==null||V.y2==null||V.x==null||V.y==null)throw new Error("pathBoundingBox: S command requires x2, y2, x, y properties");let X=O?H.plus(j0(V.x2)):j0(V.x2),w=O?z.plus(j0(V.y2)):j0(V.y2),R=O?H.plus(j0(V.x)):j0(V.x),B=O?z.plus(j0(V.y)):j0(V.y),I,h;if(F==="C"||F==="S")I=H.mul(2).minus(W),h=z.mul(2).minus(G);else I=H,h=z;let m=z5(H,z,I,h,X,w,R,B,20);for(let v of m)J=L.min(J,v.x),Z=L.min(Z,v.y),K=L.max(K,v.x),Q=L.max(Q,v.y),_.push(v);W=X,G=w,H=R,z=B,F="S"}break;case"Q":{if(V.x1==null||V.y1==null||V.x==null||V.y==null)throw new Error("pathBoundingBox: Q command requires x1, y1, x, y properties");let X=O?H.plus(j0(V.x1)):j0(V.x1),w=O?z.plus(j0(V.y1)):j0(V.y1),R=O?H.plus(j0(V.x)):j0(V.x),B=O?z.plus(j0(V.y)):j0(V.y),I=q5(H,z,X,w,R,B,20);for(let h of I)J=L.min(J,h.x),Z=L.min(Z,h.y),K=L.max(K,h.x),Q=L.max(Q,h.y),_.push(h);W=X,G=w,H=R,z=B,F="Q"}break;case"T":{if(V.x==null||V.y==null)throw new Error("pathBoundingBox: T command requires x and y properties");let X=O?H.plus(j0(V.x)):j0(V.x),w=O?z.plus(j0(V.y)):j0(V.y),R,B;if(F==="Q"||F==="T")R=H.mul(2).minus(W),B=z.mul(2).minus(G);else R=H,B=z;let I=q5(H,z,R,B,X,w,20);for(let h of I)J=L.min(J,h.x),Z=L.min(Z,h.y),K=L.max(K,h.x),Q=L.max(Q,h.y),_.push(h);W=R,G=B,H=X,z=w,F="T"}break;case"A":{if(V.x==null||V.y==null||V.rx==null||V.ry==null)throw new Error("pathBoundingBox: A command requires x, y, rx, ry properties");let X=O?H.plus(j0(V.x)):j0(V.x),w=O?z.plus(j0(V.y)):j0(V.y),R=j0(V.rx).abs(),B=j0(V.ry).abs();if(R.isZero()||B.isZero())J=L.min(J,H,X),Z=L.min(Z,z,w),K=L.max(K,H,X),Q=L.max(Q,z,w),_.push({x:H,y:z},{x:X,y:w});else{J=L.min(J,H,X,H.minus(R),X.minus(R)),Z=L.min(Z,z,w,z.minus(B),w.minus(B)),K=L.max(K,H,X,H.plus(R),X.plus(R)),Q=L.max(Q,z,w,z.plus(B),w.plus(B));let I=20;for(let h=0;h<=I;h++){let m=j0(h).div(I),v=H.plus(X.minus(H).mul(m)),x=z.plus(w.minus(z).mul(m));_.push({x:v,y:x})}}H=X,z=w,W=H,G=z,F="A"}break;case"Z":H=q,z=j,W=H,G=z,F="Z";break;default:throw new Error(`pathBoundingBox: unknown path command type: ${Y}`)}}if(!J.isFinite()||!Z.isFinite()||!K.isFinite()||!Q.isFinite())throw new Error("Invalid bounding box: no valid coordinates found");let U=bQ(J,Z,K,Q),M=!0;for(let V of _)if(!fQ(V,U)){M=!1;break}return{...U,verified:M}}function W5($){if(!$||typeof $!=="object")throw new Error("bboxToPolygon: bbox must be a bounding box object");if($.minX==null||$.minY==null||$.maxX==null||$.maxY==null)throw new Error("bboxToPolygon: bbox must have minX, minY, maxX, maxY properties");return[A7($.minX,$.minY),A7($.maxX,$.minY),A7($.maxX,$.maxY),A7($.minX,$.maxY)]}function F5($,J){if(!J||typeof J!=="object")throw new Error("bboxIntersectsViewBox: viewBox must be an object");if(J.x==null||J.y==null||J.width==null||J.height==null)throw new Error("bboxIntersectsViewBox: viewBox must have x, y, width, height properties");let Z=W5($),K=W5({minX:J.x,minY:J.y,maxX:J.x.plus(J.width),maxY:J.y.plus(J.height)}),Q=X$(Z,K);return{intersects:Q.overlaps,verified:Q.verified}}var $7={ID:"id",CLASS:"class",ATTRIBUTE:"attr",PSEUDO_CLASS:"pseudo-class",PSEUDO_ELEMENT:"pseudo-element",TYPE:"type",UNIVERSAL:"universal"};function vQ($){if(typeof $!=="string"||!$.trim())throw new Error("Selector must be a non-empty string");let J=$.trim(),Z=[],K=DQ(J);for(let Q of K){if(!Q.trim())continue;let H=hQ(Q.trim());Z.push(...H)}return Z}function DQ($){if(typeof $!=="string")throw new Error("Selector must be a string");let J=[],Z="",K=0,Q=0,H=!1,z=null;for(let j=0;j<$.length;j++){let W=$[j],G=j>0?$[j-1]:null;if((W==='"'||W==="'")&&G!=="\\"){if(!H)H=!0,z=W;else if(W===z)H=!1,z=null}if(!H){if(W==="["&&G!=="\\")K++;else if(W==="]"&&G!=="\\"){if(K--,K<0)throw new Error(`Unbalanced brackets at position ${j}`)}else if(W==="("&&G!=="\\")Q++;else if(W===")"&&G!=="\\"){if(Q--,Q<0)throw new Error(`Unbalanced parentheses at position ${j}`)}}if(!H&&K===0&&Q===0){if(W===">"||W==="+"||W==="~"){let F=Z.trim();if(F)J.push(F);Z="";continue}else if(W===" "){let F=Z.trim();if(F){J.push(F),Z="";continue}else continue}}Z+=W}if(H)throw new Error("Unclosed quote in selector");if(K!==0)throw new Error("Unclosed brackets in selector");if(Q!==0)throw new Error("Unclosed parentheses in selector");let q=Z.trim();if(q)J.push(q);return J}function hQ($){if(typeof $!=="string")throw new Error("Selector must be a string");let J=[],Z=0;while(Z<$.length){let K=$[Z];if(K==="#"){let Q=$.slice(Z).match(/^#([a-zA-Z_-][\w-]*)/);if(!Q)throw new Error(`Invalid ID selector at position ${Z}`);J.push({type:$7.ID,value:Q[1]}),Z+=Q[0].length}else if(K==="."){let Q=$.slice(Z).match(/^\.([a-zA-Z_-][\w-]*)/);if(!Q)throw new Error(`Invalid class selector at position ${Z}`);J.push({type:$7.CLASS,value:Q[1]}),Z+=Q[0].length}else if(K==="["){let Q=yQ($,Z);if(Q===-1)throw new Error(`Unclosed attribute selector at position ${Z}`);let H=$.slice(Z+1,Q);J.push({type:$7.ATTRIBUTE,value:H}),Z=Q+1}else if(K===":")if(Z+1<$.length&&$[Z+1]===":"){let Q=$.slice(Z).match(/^::([\w-]+)/);if(!Q)throw new Error(`Invalid pseudo-element at position ${Z}`);J.push({type:$7.PSEUDO_ELEMENT,value:Q[1]}),Z+=Q[0].length}else{let Q=$.slice(Z).match(/^:([\w-]+)/);if(!Q)throw new Error(`Invalid pseudo-class at position ${Z}`);let H=Q[1];if(Z+=Q[0].length,Z<$.length&&$[Z]==="("){let j=uQ($,Z);if(j===-1)throw new Error(`Unclosed pseudo-class function at position ${Z}`);H+=$.slice(Z,j+1),Z=j+1}let q=["before","after","first-line","first-letter"].includes(H);J.push({type:q?$7.PSEUDO_ELEMENT:$7.PSEUDO_CLASS,value:H})}else if(K==="*"){let Q=Z+1;if(Q<$.length&&$[Q]==="|"){if(Q++,Q<$.length&&$[Q]==="*")Q++}J.push({type:$7.UNIVERSAL,value:"*"}),Z=Q}else if(/[a-zA-Z]/.test(K)){let Q=$.slice(Z).match(/^([a-zA-Z][\w-]*)/);if(!Q)throw new Error(`Invalid type selector at position ${Z}`);let H=Q[1],z=Z+Q[0].length;if(z<$.length&&$[z]==="|"){z++;let q=$.slice(z).match(/^([a-zA-Z*][\w-]*)/);if(q)H=q[1],z+=q[0].length}J.push({type:$7.TYPE,value:H}),Z=z}else if(K===">"||K==="+"||K==="~"||K===" ")Z++;else throw new Error(`Unexpected character '${K}' at position ${Z}`)}return J}function yQ($,J){if(typeof $!=="string")throw new Error("str must be a string");if(typeof J!=="number"||J<0||J>=$.length)throw new Error("startIdx must be a valid index within the string");let Z=0,K=!1,Q=null;for(let H=J;H<$.length;H++){let z=$[H],q=H>0?$[H-1]:null;if((z==='"'||z==="'")&&q!=="\\"){if(!K)K=!0,Q=z;else if(z===Q)K=!1,Q=null}if(!K){if(z==="["&&q!=="\\")Z++;if(z==="]"&&q!=="\\"){if(Z--,Z===0)return H}}}return-1}function uQ($,J){if(typeof $!=="string")throw new Error("str must be a string");if(typeof J!=="number"||J<0||J>=$.length)throw new Error("startIdx must be a valid index within the string");let Z=0,K=!1,Q=null;for(let H=J;H<$.length;H++){let z=$[H],q=H>0?$[H-1]:null;if((z==='"'||z==="'")&&q!=="\\"){if(!K)K=!0,Q=z;else if(z===Q)K=!1,Q=null}if(!K){if(z==="("&&q!=="\\")Z++;if(z===")"&&q!=="\\"){if(Z--,Z===0)return H}}}return-1}function L$($){let J=typeof $==="string"?vQ($):$;if(!Array.isArray(J))throw new Error("Selector must be a string or an array of components");let Z=0,K=0,Q=0;for(let H of J){if(!H||typeof H.type!=="string")throw new Error("Invalid component: must have a 'type' property");switch(H.type){case $7.ID:Z++;break;case $7.CLASS:case $7.ATTRIBUTE:K++;break;case $7.PSEUDO_CLASS:{let z=H.value;if(z.startsWith("where(")&&z.endsWith(")"))break;if((z.startsWith("not(")||z.startsWith("is(")||z.startsWith("has("))&&z.endsWith(")")){let q=z.match(/^(\w+)\(/)[1],j=z.slice(q.length+1,-1);if(j.trim()){let W=gQ(j),G=[0,0,0];for(let F of W)if(F.trim()){let _=L$(F.trim());if(k$(_,G)>0)G=_}Z+=G[0],K+=G[1],Q+=G[2]}break}if((z.startsWith("nth-child(")||z.startsWith("nth-last-child("))&&z.endsWith(")")){let q=z.match(/^([\w-]+)\(/)[1],W=z.slice(q.length+1,-1).match(/\s+of\s+(.+)$/);if(W){let G=W[1].trim(),F=L$(G);Z+=F[0],K+=F[1],Q+=F[2]}K++;break}K++;break}case $7.TYPE:case $7.PSEUDO_ELEMENT:Q++;break;case $7.UNIVERSAL:break;default:break}}return[Z,K,Q]}function gQ($){if(typeof $!=="string")throw new Error("selectorList must be a string");let J=[],Z="",K=0,Q=0,H=!1,z=null;for(let q=0;q<$.length;q++){let j=$[q],W=q>0?$[q-1]:null;if((j==='"'||j==="'")&&W!=="\\"){if(!H)H=!0,z=j;else if(j===z)H=!1,z=null}if(!H){if(j==="(")K++;if(j===")")K--;if(j==="[")Q++;if(j==="]")Q--;if(j===","&&K===0&&Q===0){J.push(Z),Z="";continue}}Z+=j}if(Z)J.push(Z);return J}function k$($,J){if(!Array.isArray($)||$.length!==3)throw new Error("spec1 must be an array of 3 numbers");if(!Array.isArray(J)||J.length!==3)throw new Error("spec2 must be an array of 3 numbers");for(let Z=0;Z<3;Z++){if(typeof $[Z]!=="number"||!Number.isFinite($[Z])||$[Z]<0)throw new Error(`spec1[${Z}] must be a non-negative finite number`);if(typeof J[Z]!=="number"||!Number.isFinite(J[Z])||J[Z]<0)throw new Error(`spec2[${Z}] must be a non-negative finite number`)}for(let Z=0;Z<3;Z++){if($[Z]<J[Z])return-1;if($[Z]>J[Z])return 1}return 0}var S0=($)=>$ instanceof L?$:new L($);function X9(){let $=new L(2),J=new L(3);return new L(4).mul($.sqrt().minus(1)).div(J)}function mQ($){if($==null)throw new Error("getKappaForArc: thetaRadians parameter is required");let J=S0($);if(!J.isFinite())throw new Error("getKappaForArc: thetaRadians must be finite");if(J.isZero()||J.isNegative())throw new Error("getKappaForArc: thetaRadians must be positive");let Z=new L(4),K=new L(3);return Z.div(K).mul(L.tan(J.div(Z)))}function _5($,J,Z,K=8,Q=6){if($==null||J==null||Z==null)throw new Error("circleToPathDataHP: cx, cy, and r parameters are required");let H=S0(Z);if(!H.isFinite()||H.isNegative())throw new Error("circleToPathDataHP: radius must be finite and non-negative");if(H.isZero())return"";if(!Number.isFinite(K)||K<=0)throw new Error("circleToPathDataHP: arcs must be a positive number");if(!Number.isFinite(Q)||Q<0)throw new Error("circleToPathDataHP: precision must be non-negative");return L9($,J,Z,Z,K,Q)}function L9($,J,Z,K,Q=8,H=6){if($==null||J==null||Z==null||K==null)throw new Error("ellipseToPathDataHP: cx, cy, rx, and ry parameters are required");if(!Number.isFinite(Q)||Q<=0)throw new Error("ellipseToPathDataHP: arcs must be a positive number");if(!Number.isFinite(H)||H<0)throw new Error("ellipseToPathDataHP: precision must be non-negative");let z=Q;if(z%4!==0)z=Math.ceil(z/4)*4;let q=S0($),j=S0(J),W=S0(Z),G=S0(K);if(!W.isFinite()||W.isNegative())throw new Error("ellipseToPathDataHP: rx must be finite and non-negative");if(!G.isFinite()||G.isNegative())throw new Error("ellipseToPathDataHP: ry must be finite and non-negative");if(W.isZero()||G.isZero())return"";let F=(O)=>z6(O,H),M=L.acos(-1).mul(2).div(z),V=mQ(M),Y=[];for(let O=0;O<z;O++){let X=M.mul(O),w=M.mul(O+1),R=L.cos(X),B=L.sin(X),I=L.cos(w),h=L.sin(w),m=q.plus(W.mul(R)),v=j.plus(G.mul(B)),x=q.plus(W.mul(I)),y=j.plus(G.mul(h)),T=B.neg(),d=R,p=h.neg(),c=I,C=m.plus(V.mul(W).mul(T)),u=v.plus(V.mul(G).mul(d)),N=x.minus(V.mul(W).mul(p)),e=y.minus(V.mul(G).mul(c));if(O===0)Y.push(`M${F(m)} ${F(v)}`);Y.push(`C${F(C)} ${F(u)} ${F(N)} ${F(e)} ${F(x)} ${F(y)}`)}return Y.push("Z"),Y.join(" ")}function z6($,J=6){if($==null)throw new Error("formatNumber: value parameter is required");if(!Number.isFinite(J)||J<0)throw new Error("formatNumber: precision must be non-negative");let Z=S0($);if(!Z.isFinite())throw new Error("formatNumber: value must be finite");let K=Z.toFixed(J);if(K.includes("."))K=K.replace(/\.?0+$/,"");return K}function k9($,J,Z,K=6){if($==null||J==null||Z==null)throw new Error("circleToPathData: cx, cy, and r parameters are required");if(!Number.isFinite(K)||K<0)throw new Error("circleToPathData: precision must be non-negative");let Q=S0($),H=S0(J),z=S0(Z);if(!z.isFinite()||z.isNegative())throw new Error("circleToPathData: radius must be finite and non-negative");if(z.isZero())return"";let q=X9().mul(z),j=Q.plus(z),W=H,G=j,F=W.minus(q),_=Q.plus(q),U=H.minus(z),M=Q,V=H.minus(z),Y=Q.minus(q),O=V,X=Q.minus(z),w=H.minus(q),R=Q.minus(z),B=H,I=R,h=H.plus(q),m=Q.minus(q),v=H.plus(z),x=Q,y=H.plus(z),T=Q.plus(q),d=y,p=j,c=H.plus(q),C=(u)=>z6(u,K);return`M${C(j)} ${C(W)}C${C(G)} ${C(F)} ${C(_)} ${C(U)} ${C(M)} ${C(V)}C${C(Y)} ${C(O)} ${C(X)} ${C(w)} ${C(R)} ${C(B)}C${C(I)} ${C(h)} ${C(m)} ${C(v)} ${C(x)} ${C(y)}C${C(T)} ${C(d)} ${C(p)} ${C(c)} ${C(j)} ${C(W)}Z`}function w9($,J,Z,K,Q=6){if($==null||J==null||Z==null||K==null)throw new Error("ellipseToPathData: cx, cy, rx, and ry parameters are required");if(!Number.isFinite(Q)||Q<0)throw new Error("ellipseToPathData: precision must be non-negative");let H=S0($),z=S0(J),q=S0(Z),j=S0(K);if(!q.isFinite()||q.isNegative())throw new Error("ellipseToPathData: rx must be finite and non-negative");if(!j.isFinite()||j.isNegative())throw new Error("ellipseToPathData: ry must be finite and non-negative");if(q.isZero()||j.isZero())return"";let W=X9(),G=W.mul(q),F=W.mul(j),_=H.plus(q),U=z,M=_,V=U.minus(F),Y=H.plus(G),O=z.minus(j),X=H,w=z.minus(j),R=H.minus(G),B=w,I=H.minus(q),h=z.minus(F),m=H.minus(q),v=z,x=m,y=z.plus(F),T=H.minus(G),d=z.plus(j),p=H,c=z.plus(j),C=H.plus(G),u=c,N=_,e=z.plus(F),a=(s)=>z6(s,Q);return`M${a(_)} ${a(U)}C${a(M)} ${a(V)} ${a(Y)} ${a(O)} ${a(X)} ${a(w)}C${a(R)} ${a(B)} ${a(I)} ${a(h)} ${a(m)} ${a(v)}C${a(x)} ${a(y)} ${a(T)} ${a(d)} ${a(p)} ${a(c)}C${a(C)} ${a(u)} ${a(N)} ${a(e)} ${a(_)} ${a(U)}Z`}function R9($,J,Z,K,Q=0,H=null,z=!1,q=6){if($==null||J==null||Z==null||K==null)throw new Error("rectToPathData: x, y, width, and height parameters are required");if(!Number.isFinite(q)||q<0)throw new Error("rectToPathData: precision must be non-negative");let j=S0($),W=S0(J),G=S0(Z),F=S0(K);if(!j.isFinite())throw new Error("rectToPathData: x must be finite");if(!W.isFinite())throw new Error("rectToPathData: y must be finite");if(!G.isFinite()||G.isNegative())throw new Error("rectToPathData: width must be finite and non-negative");if(!F.isFinite()||F.isNegative())throw new Error("rectToPathData: height must be finite and non-negative");if(G.isZero()||F.isZero())return"";let _=S0(Q||0),U=H!==null?S0(H):_;if(!_.isFinite()||_.isNegative())throw new Error("rectToPathData: rx must be finite and non-negative");if(!U.isFinite()||U.isNegative())throw new Error("rectToPathData: ry must be finite and non-negative");let M=G.div(2),V=F.div(2);if(_.gt(M))_=M;if(U.gt(V))U=V;let Y=(T)=>z6(T,q);if(_.isZero()||U.isZero()){let T=j.plus(G),d=W.plus(F);return`M${Y(j)} ${Y(W)}H${Y(T)}V${Y(d)}H${Y(j)}Z`}let O=j,X=j.plus(G),w=W,R=W.plus(F),B=O.plus(_),I=X.minus(_),h=w.plus(U),m=R.minus(U);if(z)return`M${Y(B)} ${Y(w)}L${Y(I)} ${Y(w)}A${Y(_)} ${Y(U)} 0 0 1 ${Y(X)} ${Y(h)}L${Y(X)} ${Y(m)}A${Y(_)} ${Y(U)} 0 0 1 ${Y(I)} ${Y(R)}L${Y(B)} ${Y(R)}A${Y(_)} ${Y(U)} 0 0 1 ${Y(O)} ${Y(m)}L${Y(O)} ${Y(h)}A${Y(_)} ${Y(U)} 0 0 1 ${Y(B)} ${Y(w)}Z`;let v=X9(),x=v.mul(_),y=v.mul(U);return`M${Y(B)} ${Y(w)}L${Y(I)} ${Y(w)}C${Y(I.plus(x))} ${Y(w)} ${Y(X)} ${Y(h.minus(y))} ${Y(X)} ${Y(h)}L${Y(X)} ${Y(m)}C${Y(X)} ${Y(m.plus(y))} ${Y(I.plus(x))} ${Y(R)} ${Y(I)} ${Y(R)}L${Y(B)} ${Y(R)}C${Y(B.minus(x))} ${Y(R)} ${Y(O)} ${Y(m.plus(y))} ${Y(O)} ${Y(m)}L${Y(O)} ${Y(h)}C${Y(O)} ${Y(h.minus(y))} ${Y(B.minus(x))} ${Y(w)} ${Y(B)} ${Y(w)}Z`}function B9($,J,Z,K,Q=6){if($==null||J==null||Z==null||K==null)throw new Error("lineToPathData: x1, y1, x2, and y2 parameters are required");if(!Number.isFinite(Q)||Q<0)throw new Error("lineToPathData: precision must be non-negative");let H=S0($),z=S0(J),q=S0(Z),j=S0(K);if(!H.isFinite()||!z.isFinite()||!q.isFinite()||!j.isFinite())throw new Error("lineToPathData: all coordinates must be finite");let W=(G)=>z6(G,Q);return`M${W(H)} ${W(z)}L${W(q)} ${W(j)}`}function dQ($){if($==null)return[];if(Array.isArray($))try{return $.map(([H,z])=>[S0(H),S0(z)])}catch(H){return[]}let J=$;if(typeof J==="object"&&J.baseVal!==void 0)J=J.baseVal;if(typeof J!=="string")if(typeof J.toString==="function")J=J.toString();else return[];let Z=[],K=J.split(/[\s,]+/).filter((H)=>H.length>0);for(let H of K)try{Z.push(S0(H))}catch(z){continue}let Q=[];for(let H=0;H<Z.length;H+=2)if(H+1<Z.length)Q.push([Z[H],Z[H+1]]);return Q}function w$($,J=6){if(!Number.isFinite(J)||J<0)throw new Error("polylineToPathData: precision must be non-negative");let Z=dQ($);if(Z.length===0)return"";let K=(q)=>z6(q,J),[Q,H]=Z[0],z=`M${K(Q)} ${K(H)}`;for(let q=1;q<Z.length;q++){let[j,W]=Z[q];z+=`L${K(j)} ${K(W)}`}return z}function N9($,J=6){if(!Number.isFinite(J)||J<0)throw new Error("polygonToPathData: precision must be non-negative");let Z=w$($,J);return Z?Z+" Z":""}var pQ={M:2,m:2,L:2,l:2,H:1,h:1,V:1,v:1,C:6,c:6,S:4,s:4,Q:4,q:4,T:2,t:2,A:7,a:7,Z:0,z:0};function g6($){if($==null)throw new Error("parsePathData: pathData parameter is required");if(typeof $!=="string")throw new Error("parsePathData: pathData must be a string");let J=[],Z=/([MmLlHhVvCcSsQqTtAaZz])\s*([^MmLlHhVvCcSsQqTtAaZz]*)/g,K;while((K=Z.exec($))!==null){let Q=K[1],H=K[2].trim(),z=/-?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/g,q=[];if(H.length>0)for(let W of H.matchAll(z))try{q.push(S0(W[0]))}catch(G){continue}let j=pQ[Q];if(j===0||q.length===0)J.push({command:Q,args:[]});else for(let W=0;W<q.length;W+=j){let G=q.slice(W,W+j);if(G.length===j){let F=Q;if(W>0&&(Q==="M"||Q==="m"))F=Q==="M"?"L":"l";J.push({command:F,args:G})}}}return J}function C9($,J=6){if($==null)throw new Error("pathArrayToString: commands parameter is required");if(!Array.isArray($))throw new Error("pathArrayToString: commands must be an array");if(!Number.isFinite(J)||J<0)throw new Error("pathArrayToString: precision must be non-negative");return $.map((Z)=>{if(!Z||typeof Z.command!=="string"||!Array.isArray(Z.args))throw new Error("pathArrayToString: each command must have 'command' (string) and 'args' (array) properties");let{command:K,args:Q}=Z,H=Q.map((z)=>z6(z,J)).join(" ");return H.length>0?`${K} ${H}`:K}).join(" ")}function U5($){if($==null)throw new Error("pathToAbsolute: pathData parameter is required");let J=g6($),Z=[],K=new L(0),Q=new L(0),H=new L(0),z=new L(0),q=new L(0),j=new L(0),W="";for(let{command:G,args:F}of J){let _=G===G.toLowerCase(),U=G.toUpperCase();if(U==="M"){if(F.length<2)continue;let M=_?K.plus(F[0]):F[0],V=_?Q.plus(F[1]):F[1];K=M,Q=V,H=M,z=V,Z.push({command:"M",args:[M,V]}),W="M"}else if(U==="L"){if(F.length<2)continue;let M=_?K.plus(F[0]):F[0],V=_?Q.plus(F[1]):F[1];K=M,Q=V,Z.push({command:"L",args:[M,V]}),W="L"}else if(U==="H"){if(F.length<1)continue;let M=_?K.plus(F[0]):F[0];K=M,Z.push({command:"L",args:[M,Q]}),W="H"}else if(U==="V"){if(F.length<1)continue;let M=_?Q.plus(F[0]):F[0];Q=M,Z.push({command:"L",args:[K,M]}),W="V"}else if(U==="C"){if(F.length<6)continue;let M=_?K.plus(F[0]):F[0],V=_?Q.plus(F[1]):F[1],Y=_?K.plus(F[2]):F[2],O=_?Q.plus(F[3]):F[3],X=_?K.plus(F[4]):F[4],w=_?Q.plus(F[5]):F[5];q=Y,j=O,K=X,Q=w,Z.push({command:"C",args:[M,V,Y,O,X,w]}),W="C"}else if(U==="S"){if(F.length<4)continue;let M,V;if(W==="C"||W==="S")M=K.mul(2).minus(q),V=Q.mul(2).minus(j);else M=K,V=Q;let Y=_?K.plus(F[0]):F[0],O=_?Q.plus(F[1]):F[1],X=_?K.plus(F[2]):F[2],w=_?Q.plus(F[3]):F[3];q=Y,j=O,K=X,Q=w,Z.push({command:"C",args:[M,V,Y,O,X,w]}),W="S"}else if(U==="Q"){if(F.length<4)continue;let M=_?K.plus(F[0]):F[0],V=_?Q.plus(F[1]):F[1],Y=_?K.plus(F[2]):F[2],O=_?Q.plus(F[3]):F[3];q=M,j=V,K=Y,Q=O,Z.push({command:"Q",args:[M,V,Y,O]}),W="Q"}else if(U==="T"){if(F.length<2)continue;let M,V;if(W==="Q"||W==="T")M=K.mul(2).minus(q),V=Q.mul(2).minus(j);else M=K,V=Q;let Y=_?K.plus(F[0]):F[0],O=_?Q.plus(F[1]):F[1];q=M,j=V,K=Y,Q=O,Z.push({command:"Q",args:[M,V,Y,O]}),W="T"}else if(U==="A"){if(F.length<7)continue;let M=_?K.plus(F[5]):F[5],V=_?Q.plus(F[6]):F[6];K=M,Q=V,Z.push({command:"A",args:[F[0],F[1],F[2],F[3],F[4],M,V]}),W="A"}else if(U==="Z")K=H,Q=z,Z.push({command:"Z",args:[]}),W="Z";else Z.push({command:G,args:F}),W=G}return C9(Z)}function V5($,J=6){if($==null)throw new Error("convertElementToPath: element parameter is required");if(!Number.isFinite(J)||J<0)throw new Error("convertElementToPath: precision must be non-negative");let Z=(Q,H=0)=>{let z=$.getAttribute?$.getAttribute(Q):$[Q];return cQ(z!==void 0&&z!==null?z:H)},K=($.tagName||$.type||"").toLowerCase();if(K==="circle")return k9(Z("cx",0),Z("cy",0),Z("r",0),J);else if(K==="ellipse")return w9(Z("cx",0),Z("cy",0),Z("rx",0),Z("ry",0),J);else if(K==="rect")return R9(Z("x",0),Z("y",0),Z("width",0),Z("height",0),Z("rx",0),Z("ry",null),!1,J);else if(K==="line")return B9(Z("x1",0),Z("y1",0),Z("x2",0),Z("y2",0),J);else if(K==="polyline")return w$(Z("points",""),J);else if(K==="polygon")return N9(Z("points",""),J);return null}function cQ($){if($==null)return 0;if(typeof $==="string"){let Z=parseFloat($);return isNaN(Z)?0:Z}if(typeof $==="number")return isNaN($)?0:$;if($ instanceof L)return $.toNumber();let J=Number($);return isNaN(J)?0:J}var R7=($)=>{if($ instanceof L){if(!$.isFinite())throw new Error(`Value must be finite (got ${$.toString()})`);return $}try{let J=new L($);if(!J.isFinite())throw new Error(`Value must be finite (got ${$})`);return J}catch(J){throw new Error(`Invalid numeric value: "${$}" (${J.message})`)}};function M7($,J){if($===void 0||$===null)throw new Error(`${J} is required`);if(typeof $!=="number"&&typeof $!=="string"&&!($ instanceof L))throw new Error(`${J} must be a number, string, or Decimal`);if(typeof $==="number"&&!isFinite($))throw new Error(`${J} must be a finite number (got ${$})`);if($ instanceof L&&!$.isFinite())throw new Error(`${J} must be a finite Decimal (got ${$.toString()})`)}function i0($,J){return M7($,"tx"),M7(J,"ty"),V0.from([[new L(1),new L(0),R7($)],[new L(0),new L(1),R7(J)],[new L(0),new L(0),new L(1)]])}function O7($,J=null){if(M7($,"sx"),J!==null)M7(J,"sy");let Z=J===null?$:J,K=R7($),Q=R7(Z);if(K.isZero()||Q.isZero())throw new Error("Scale factors cannot be zero (creates singular matrix)");return V0.from([[K,new L(0),new L(0)],[new L(0),Q,new L(0)],[new L(0),new L(0),new L(1)]])}function X6($){M7($,"theta");let Z=R7($).toNumber(),K=Math.PI,Q=Z-2*K*Math.floor((Z+K)/(2*K));if(!isFinite(Q))throw new Error(`Angle normalization failed for theta=${$} (too large or invalid)`);let H=new L(Math.cos(Q)),z=new L(Math.sin(Q));if(!H.isFinite()||!z.isFinite())throw new Error(`Trigonometric computation failed for theta=${$} (produced non-finite values)`);return V0.from([[H,z.negated(),new L(0)],[z,H,new L(0)],[new L(0),new L(0),new L(1)]])}function O5($,J,Z){M7($,"theta"),M7(J,"px"),M7(Z,"py");let K=R7(J),Q=R7(Z);return i0(K,Q).mul(X6($)).mul(i0(K.negated(),Q.negated()))}function I9($,J){M7($,"ax"),M7(J,"ay");let Z=R7($),K=R7(J);if(new L(1).minus(Z.mul(K)).lessThanOrEqualTo(0))throw new Error(`Skew parameters create singular or orientation-inverting matrix (ax*ay = ${Z.mul(K).toString()}, must be < 1)`);return V0.from([[new L(1),Z,new L(0)],[K,new L(1),new L(0)],[new L(0),new L(0),new L(1)]])}function l0($,J,Z){if(!$||typeof $.mul!=="function")throw new Error("applyTransform: first argument must be a Matrix");if(!$.data||!Array.isArray($.data)||$.data.length!==3||!$.data[0]||$.data[0].length!==3||!$.data[1]||$.data[1].length!==3||!$.data[2]||$.data[2].length!==3)throw new Error("applyTransform: matrix must be 3x3");M7(J,"x"),M7(Z,"y");let K=V0.from([[R7(J)],[R7(Z)],[new L(1)]]),Q=$.mul(K);if(!Q||!Q.data||!Array.isArray(Q.data)||Q.data.length!==3||!Q.data[0]||!Q.data[0][0]||!Q.data[1]||!Q.data[1][0]||!Q.data[2]||!Q.data[2][0])throw new Error("applyTransform: matrix multiplication produced invalid result");let H=Q.data[0][0],z=Q.data[1][0],q=Q.data[2][0];if(q.isZero())throw new Error("applyTransform: perspective division by zero (invalid transformation matrix)");return[H.div(q),z.div(q)]}L.set({precision:80});function Y5($,J,Z){return P9($,J,Z,Z)}function P9($,J,Z,K){let Q=(R)=>new L(R),H=Q($),z=Q(J),q=Q(Z),j=Q(K);if(!q.isFinite()||!j.isFinite()||!H.isFinite()||!z.isFinite())throw new Error("Ellipse parameters must be finite");if(q.eq(0)||j.eq(0))return console.warn("Degenerate ellipse with zero radius, returning empty path"),"";if(q.lt(0)||j.lt(0))throw new Error("Ellipse radii must be non-negative");let W=Q("0.5522847498307936"),G=q.mul(W),F=j.mul(W),_=H.plus(q),U=z,M=H,V=z.minus(j),Y=H.minus(q),O=z,X=H,w=z.plus(j);return[`M ${_.toFixed(6)} ${U.toFixed(6)}`,`C ${_.toFixed(6)} ${U.minus(F).toFixed(6)} ${M.plus(G).toFixed(6)} ${V.toFixed(6)} ${M.toFixed(6)} ${V.toFixed(6)}`,`C ${M.minus(G).toFixed(6)} ${V.toFixed(6)} ${Y.toFixed(6)} ${O.minus(F).toFixed(6)} ${Y.toFixed(6)} ${O.toFixed(6)}`,`C ${Y.toFixed(6)} ${O.plus(F).toFixed(6)} ${X.minus(G).toFixed(6)} ${w.toFixed(6)} ${X.toFixed(6)} ${w.toFixed(6)}`,`C ${X.plus(G).toFixed(6)} ${w.toFixed(6)} ${_.toFixed(6)} ${U.plus(F).toFixed(6)} ${_.toFixed(6)} ${U.toFixed(6)}`,"Z"].join(" ")}function X5($,J,Z,K,Q=0,H=null){let z=(Y)=>new L(Y),q=z($),j=z(J),W=z(Z),G=z(K);if(W.lte(0)||G.lte(0))throw new Error("Rectangle dimensions must be positive");if(!W.isFinite()||!G.isFinite()||!q.isFinite()||!j.isFinite())throw new Error("Rectangle parameters must be finite");let F=z(Q),_=H!==null?z(H):F;if(F.lt(0)||_.lt(0))throw new Error("Rectangle corner radii must be non-negative");let U=W.div(2),M=G.div(2);if(F.gt(U))F=U;if(_.gt(M))_=M;if(!(F.gt(0)||_.gt(0)))return[`M ${q.toFixed(6)} ${j.toFixed(6)}`,`L ${q.plus(W).toFixed(6)} ${j.toFixed(6)}`,`L ${q.plus(W).toFixed(6)} ${j.plus(G).toFixed(6)}`,`L ${q.toFixed(6)} ${j.plus(G).toFixed(6)}`,"Z"].join(" ");return[`M ${q.plus(F).toFixed(6)} ${j.toFixed(6)}`,`L ${q.plus(W).minus(F).toFixed(6)} ${j.toFixed(6)}`,`A ${F.toFixed(6)} ${_.toFixed(6)} 0 0 1 ${q.plus(W).toFixed(6)} ${j.plus(_).toFixed(6)}`,`L ${q.plus(W).toFixed(6)} ${j.plus(G).minus(_).toFixed(6)}`,`A ${F.toFixed(6)} ${_.toFixed(6)} 0 0 1 ${q.plus(W).minus(F).toFixed(6)} ${j.plus(G).toFixed(6)}`,`L ${q.plus(F).toFixed(6)} ${j.plus(G).toFixed(6)}`,`A ${F.toFixed(6)} ${_.toFixed(6)} 0 0 1 ${q.toFixed(6)} ${j.plus(G).minus(_).toFixed(6)}`,`L ${q.toFixed(6)} ${j.plus(_).toFixed(6)}`,`A ${F.toFixed(6)} ${_.toFixed(6)} 0 0 1 ${q.plus(F).toFixed(6)} ${j.toFixed(6)}`].join(" ")}function L5($,J,Z,K){let Q=(W)=>new L(W),H=Q($),z=Q(J),q=Q(Z),j=Q(K);if(!H.isFinite()||!z.isFinite()||!q.isFinite()||!j.isFinite())throw new Error("lineToPath: all parameters must be finite");return`M ${H.toFixed(6)} ${z.toFixed(6)} L ${q.toFixed(6)} ${j.toFixed(6)}`}function k5($){let J=R5($);if(J.length===0)return"";let Z=`M ${J[0][0]} ${J[0][1]}`;for(let K=1;K<J.length;K++)Z+=` L ${J[K][0]} ${J[K][1]}`;return Z+" Z"}function w5($){let J=R5($);if(J.length===0)return"";let Z=`M ${J[0][0]} ${J[0][1]}`;for(let K=1;K<J.length;K++)Z+=` L ${J[K][0]} ${J[K][1]}`;return Z}function R5($){if(!$)return[];let J;try{if(Array.isArray($))J=$.flat().map((K)=>new L(K).toFixed(6));else if(typeof $==="string")J=$.trim().split(/[\s,]+/).filter((K)=>K.length>0).map((K)=>new L(K).toFixed(6));else return console.warn("parsePointPairs: invalid input type"),[]}catch(K){return console.warn(`parsePointPairs: parse error - ${K.message}`),[]}if(J.length%2!==0)console.warn("parsePointPairs: odd number of coordinates, ignoring last value"),J=J.slice(0,-1);let Z=[];for(let K=0;K+1<J.length;K+=2)Z.push([J[K],J[K+1]]);return Z}function lQ($,J,Z,K,Q,H,z,q){let j=(Q0)=>new L(Q0),W=j("1e-16");if(!q||!q.data||!Array.isArray(q.data)||q.data.length<3)throw new Error("transformArc: invalid matrix");let G=j($),F=j(J);if(G.lte(0)||F.lte(0))return console.warn("transformArc: radii must be positive, returning degenerate arc"),{rx:0,ry:0,xAxisRotation:0,largeArcFlag:K,sweepFlag:Q,x:j(H).toNumber(),y:j(z).toNumber()};let _=K;if(typeof _!=="number"||_!==0&&_!==1)console.warn(`transformArc: largeArcFlag must be 0 or 1, got ${K}`),_=_?1:0;let U=Q;if(typeof U!=="number"||U!==0&&U!==1)console.warn(`transformArc: sweepFlag must be 0 or 1, got ${Q}`),U=U?1:0;let M=q.data[0][0],V=q.data[1][0],Y=q.data[0][1],O=q.data[1][1],X=q.data[0][2],w=q.data[1][2],R=j(H),B=j(z),I=M.mul(R).plus(Y.mul(B)).plus(X),h=V.mul(R).plus(O.mul(B)).plus(w),m=j(Z).mul(j(Math.PI)).div(180),v=L.sin(m),x=L.cos(m),y=M.mul(G).mul(x).plus(Y.mul(G).mul(v)),T=V.mul(G).mul(x).plus(O.mul(G).mul(v)),d=M.mul(F.neg()).mul(v).plus(Y.mul(F).mul(x)),p=V.mul(F.neg()).mul(v).plus(O.mul(F).mul(x)),c=y.mul(y).plus(d.mul(d)),C=T.mul(T).plus(p.mul(p)),u=y.mul(T).plus(d.mul(p)).mul(2),N=c.minus(C),e,a,s;if(u.abs().lt(W))e=j(0),a=c,s=C;else if(N.abs().lt(W))a=c.plus(u.mul("0.5")),s=c.minus(u.mul("0.5")),e=j(Math.PI).div(4);else{let Q0=j(1).plus(u.mul(u).div(N.mul(N))).sqrt();a=c.plus(C).plus(Q0.mul(N)).div(2),s=c.plus(C).minus(Q0.mul(N)).div(2),e=L.atan(u.div(N)).div(2)}if(a.lt(0))a=j(0);if(s.lt(0))s=j(0);let H0=a.sqrt(),S=s.sqrt();if(N.lte(0)){let Q0=H0;H0=S,S=Q0}if(S.gt(H0)){let Q0=H0;H0=S,S=Q0,e=e.plus(j(Math.PI).div(2))}let E=M.mul(O).minus(V.mul(Y)),t=U;if(E.lt(0))t=U?0:1;let $0=e.mul(180).div(j(Math.PI));while($0.lt(0))$0=$0.plus(180);while($0.gte(180))$0=$0.minus(180);return{rx:H0.toNumber(),ry:S.toNumber(),xAxisRotation:$0.toNumber(),largeArcFlag:_,sweepFlag:t,x:I.toNumber(),y:h.toNumber()}}function nQ($,J){if(!$||typeof $!=="string")return console.warn("parseTransformFunction: invalid function name"),V0.identity(3);if(!J||!Array.isArray(J))return console.warn("parseTransformFunction: invalid arguments array"),V0.identity(3);let Z=(K)=>new L(K);switch($.toLowerCase()){case"translate":{let K=J[0]!==void 0?J[0]:0,Q=J[1]!==void 0?J[1]:0;return i0(K,Q)}case"scale":{let K=J[0]!==void 0?J[0]:1,Q=J[1]!==void 0?J[1]:K;return O7(K,Q)}case"rotate":{let K=J[0]!==void 0?J[0]:0,Q=Z(K).mul(Z(Math.PI)).div(180);if(J.length>=3){if(J[1]===void 0||J[2]===void 0||!isFinite(J[1])||!isFinite(J[2]))return console.warn("parseTransformFunction: rotate(angle, cx, cy) has invalid cx or cy, using origin rotation"),X6(Q);let H=J[1],z=J[2];return O5(Q,H,z)}return X6(Q)}case"skewx":{let K=J[0]!==void 0?J[0]:0,Q=Z(K).mul(Z(Math.PI)).div(180),H=L.tan(Q);return I9(H,0)}case"skewy":{let K=J[0]!==void 0?J[0]:0,Q=Z(K).mul(Z(Math.PI)).div(180),H=L.tan(Q);return I9(0,H)}case"matrix":{if(J.length<6)return console.warn(`parseTransformFunction: matrix() requires 6 arguments, got ${J.length}`),V0.identity(3);let[K,Q,H,z,q,j]=J.slice(0,6).map((W)=>Z(W!==void 0?W:0));return V0.from([[K,H,q],[Q,z,j],[Z(0),Z(0),Z(1)]])}default:return console.warn(`Unknown transform function: ${$}`),V0.identity(3)}}function J7($){if(!$||$.trim()==="")return V0.identity(3);let J=/(\w+)\s*\(([^)]*)\)/g,Z,K=V0.identity(3);while((Z=J.exec($))!==null){let Q=Z[1],z=Z[2].split(/[\s,]+/).filter((j)=>j.length>0).map((j)=>{let W=parseFloat(j);if(isNaN(W))return console.warn(`parseTransformAttribute: invalid numeric argument "${j}" in ${Q}(), using 0`),0;return W}),q=nQ(Q,z);K=K.mul(q)}return K}function Y7($,J,Z){if(!$||!$.data||!Array.isArray($.data))throw new Error("applyToPoint: invalid CTM matrix");let K=(z)=>new L(z);try{let z=K(J),q=K(Z);if(!z.isFinite()||!q.isFinite())throw new Error("applyToPoint: coordinates must be finite")}catch(z){throw new Error(`applyToPoint: invalid coordinates - ${z.message}`)}let[Q,H]=l0($,J,Z);return{x:Q,y:H}}function B5($,J=6){if(!$||!$.data||!Array.isArray($.data)||$.data.length<3||!Array.isArray($.data[0])||!Array.isArray($.data[1])||$.data[0].length<3||$.data[1].length<3)throw new Error("toSVGMatrix: invalid CTM matrix structure");let Z=J;if(typeof Z!=="number"||Z<0||Z>20)console.warn("toSVGMatrix: invalid precision, using default 6"),Z=6;try{let K=$.data[0][0].toFixed(Z),Q=$.data[1][0].toFixed(Z),H=$.data[0][1].toFixed(Z),z=$.data[1][1].toFixed(Z),q=$.data[0][2].toFixed(Z),j=$.data[1][2].toFixed(Z);return`matrix(${K}, ${Q}, ${H}, ${z}, ${q}, ${j})`}catch(K){throw new Error(`toSVGMatrix: invalid matrix elements - ${K.message}`)}}function L6($,J,Z={}){if(!$||typeof $!=="string")return console.warn("transformPathData: invalid pathData (must be string)"),"";if(!J||!J.data)return console.warn("transformPathData: invalid CTM matrix"),$;let{toAbsolute:K=!0,precision:Q=6}=Z,H=Q;if(typeof H!=="number"||H<0||H>20||!isFinite(H))console.warn("transformPathData: invalid precision, using default 6"),H=6;let z=(U)=>new L(U),q=sQ($);if(q.length===0)return"";let j=[],W=z(0),G=z(0),F=z(0),_=z(0);for(let{cmd:U,args:M}of q){let V=U===U.toLowerCase();switch(U.toUpperCase()){case"M":{let O=[];if(M.length%2!==0)console.warn(`transformPathData: M command has ${M.length} args, expected multiple of 2`);for(let X=0;X+1<M.length;X+=2){let w=z(M[X]),R=z(M[X+1]);if(V)w=w.plus(W),R=R.plus(G);let B=Y7(J,w,R);if(O.push(B.x.toFixed(H),B.y.toFixed(H)),W=w,G=R,X===0)F=w,_=R}j.push((K?"M":U)+" "+O.join(" "));break}case"L":{let O=[];if(M.length%2!==0)console.warn(`transformPathData: L command has ${M.length} args, expected multiple of 2`);for(let X=0;X+1<M.length;X+=2){let w=z(M[X]),R=z(M[X+1]);if(V)w=w.plus(W),R=R.plus(G);let B=Y7(J,w,R);O.push(B.x.toFixed(H),B.y.toFixed(H)),W=w,G=R}j.push((K?"L":U)+" "+O.join(" "));break}case"H":{if(M.length<1){console.warn("transformPathData: H command requires at least 1 argument");break}for(let O=0;O<M.length;O++){let X=z(M[O]);if(V)X=X.plus(W);let R=Y7(J,X,G);j.push("L "+R.x.toFixed(H)+" "+R.y.toFixed(H)),W=X}break}case"V":{if(M.length<1){console.warn("transformPathData: V command requires at least 1 argument");break}for(let O=0;O<M.length;O++){let X=W,w=z(M[O]);if(V)w=w.plus(G);let R=Y7(J,X,w);j.push("L "+R.x.toFixed(H)+" "+R.y.toFixed(H)),G=w}break}case"C":{let O=[];if(M.length%6!==0)console.warn(`transformPathData: C command has ${M.length} args, expected multiple of 6`);for(let X=0;X+5<M.length;X+=6){let w=z(M[X]),R=z(M[X+1]),B=z(M[X+2]),I=z(M[X+3]),h=z(M[X+4]),m=z(M[X+5]);if(V)w=w.plus(W),R=R.plus(G),B=B.plus(W),I=I.plus(G),h=h.plus(W),m=m.plus(G);let v=Y7(J,w,R),x=Y7(J,B,I),y=Y7(J,h,m);O.push(v.x.toFixed(H),v.y.toFixed(H),x.x.toFixed(H),x.y.toFixed(H),y.x.toFixed(H),y.y.toFixed(H)),W=h,G=m}j.push((K?"C":U)+" "+O.join(" "));break}case"S":{let O=[];if(M.length%4!==0)console.warn(`transformPathData: S command has ${M.length} args, expected multiple of 4`);for(let X=0;X+3<M.length;X+=4){let w=z(M[X]),R=z(M[X+1]),B=z(M[X+2]),I=z(M[X+3]);if(V)w=w.plus(W),R=R.plus(G),B=B.plus(W),I=I.plus(G);let h=Y7(J,w,R),m=Y7(J,B,I);O.push(h.x.toFixed(H),h.y.toFixed(H),m.x.toFixed(H),m.y.toFixed(H)),W=B,G=I}j.push((K?"S":U)+" "+O.join(" "));break}case"Q":{let O=[];if(M.length%4!==0)console.warn(`transformPathData: Q command has ${M.length} args, expected multiple of 4`);for(let X=0;X+3<M.length;X+=4){let w=z(M[X]),R=z(M[X+1]),B=z(M[X+2]),I=z(M[X+3]);if(V)w=w.plus(W),R=R.plus(G),B=B.plus(W),I=I.plus(G);let h=Y7(J,w,R),m=Y7(J,B,I);O.push(h.x.toFixed(H),h.y.toFixed(H),m.x.toFixed(H),m.y.toFixed(H)),W=B,G=I}j.push((K?"Q":U)+" "+O.join(" "));break}case"T":{let O=[];if(M.length%2!==0)console.warn(`transformPathData: T command has ${M.length} args, expected multiple of 2`);for(let X=0;X+1<M.length;X+=2){let w=z(M[X]),R=z(M[X+1]);if(V)w=w.plus(W),R=R.plus(G);let B=Y7(J,w,R);O.push(B.x.toFixed(H),B.y.toFixed(H)),W=w,G=R}j.push((K?"T":U)+" "+O.join(" "));break}case"A":{let O=[];if(M.length%7!==0)console.warn(`transformPathData: Arc command has ${M.length} args, expected multiple of 7`);for(let X=0;X+6<M.length;X+=7){let w=M[X],R=M[X+1],B=M[X+2],I=M[X+3],h=M[X+4],m=z(M[X+5]),v=z(M[X+6]);if(V)m=m.plus(W),v=v.plus(G);let x=lQ(w,R,B,I,h,m.toNumber(),v.toNumber(),J);O.push(x.rx.toFixed(H),x.ry.toFixed(H),x.xAxisRotation.toFixed(H),x.largeArcFlag,x.sweepFlag,x.x.toFixed(H),x.y.toFixed(H)),W=m,G=v}j.push((K?"A":U)+" "+O.join(" "));break}case"Z":{j.push("Z"),W=F,G=_;break}default:j.push(U+" "+M.join(" "))}}return j.join(" ")}function sQ($){if(!$||typeof $!=="string")return[];let J=[],Z=/([MmLlHhVvCcSsQqTtAaZz])([^MmLlHhVvCcSsQqTtAaZz]*)/g,K;while((K=Z.exec($))!==null){let Q=K[1],H=K[2].trim(),z=H.length>0?H.split(/[\s,]+/).filter((q)=>q.length>0).map((q)=>{let j=parseFloat(q);if(isNaN(j))return console.warn(`parsePathCommands: invalid number '${q}'`),0;return j}):[];J.push({cmd:Q,args:z})}return J}var T7={};W$(T7,{sign:()=>A9,segmentIntersection:()=>B$,reversePolygon:()=>f9,polygonUnion:()=>W6,polygonIntersection:()=>E7,polygonDifference:()=>T5,polygonArea:()=>x6,pointsEqual:()=>h7,pointOnSegment:()=>E9,pointInPolygon:()=>B7,point:()=>f0,lineSegmentIntersection:()=>A5,isCounterClockwise:()=>b9,isConvex:()=>v9,ensureCCW:()=>N$,dot:()=>P5,default:()=>tQ,cross:()=>y7,convexHull:()=>S9,clipPolygonSH:()=>T9,boundingBox:()=>u7,bboxIntersects:()=>m6});L.set({precision:80});var X7=($)=>$ instanceof L?$:new L($),U7=new L("1e-40");function f0($,J){if($===null||$===void 0)throw new Error("point: x coordinate is required");if(J===null||J===void 0)throw new Error("point: y coordinate is required");return{x:X7($),y:X7(J)}}function h7($,J,Z=U7){if(!$||typeof $!=="object"||$.x===null||$.x===void 0||$.y===null||$.y===void 0)throw new Error("pointsEqual: p1 must be a point with x and y properties");if(!J||typeof J!=="object"||J.x===null||J.x===void 0||J.y===null||J.y===void 0)throw new Error("pointsEqual: p2 must be a point with x and y properties");if(!Z||typeof Z.abs!=="function")throw new Error("pointsEqual: tolerance must be a Decimal instance");return $.x.minus(J.x).abs().lt(Z)&&$.y.minus(J.y).abs().lt(Z)}function y7($,J,Z){if(!$||$.x===null||$.x===void 0||$.y===null||$.y===void 0)throw new Error("cross: origin point o must have x and y properties");if(!J||J.x===null||J.x===void 0||J.y===null||J.y===void 0)throw new Error("cross: point a must have x and y properties");if(!Z||Z.x===null||Z.x===void 0||Z.y===null||Z.y===void 0)throw new Error("cross: point b must have x and y properties");let K=J.x.minus($.x),Q=J.y.minus($.y),H=Z.x.minus($.x),z=Z.y.minus($.y);return K.mul(z).minus(Q.mul(H))}function P5($,J,Z){if(!$||$.x===null||$.x===void 0||$.y===null||$.y===void 0)throw new Error("dot: origin point o must have x and y properties");if(!J||J.x===null||J.x===void 0||J.y===null||J.y===void 0)throw new Error("dot: point a must have x and y properties");if(!Z||Z.x===null||Z.x===void 0||Z.y===null||Z.y===void 0)throw new Error("dot: point b must have x and y properties");let K=J.x.minus($.x),Q=J.y.minus($.y),H=Z.x.minus($.x),z=Z.y.minus($.y);return K.mul(H).plus(Q.mul(z))}function A9($){if($===null||$===void 0||typeof $.abs!=="function")throw new Error("sign: val must be a Decimal instance");if($.abs().lt(U7))return 0;return $.lt(0)?-1:1}function B$($,J,Z,K){if(!$||$.x===null||$.x===void 0||$.y===null||$.y===void 0)throw new Error("segmentIntersection: point a must have x and y properties");if(!J||J.x===null||J.x===void 0||J.y===null||J.y===void 0)throw new Error("segmentIntersection: point b must have x and y properties");if(!Z||Z.x===null||Z.x===void 0||Z.y===null||Z.y===void 0)throw new Error("segmentIntersection: point c must have x and y properties");if(!K||K.x===null||K.x===void 0||K.y===null||K.y===void 0)throw new Error("segmentIntersection: point d must have x and y properties");let Q=J.x.minus($.x),H=J.y.minus($.y),z=K.x.minus(Z.x),q=K.y.minus(Z.y),j=Q.mul(q).minus(H.mul(z));if(j.abs().lt(U7))return null;let W=Z.x.minus($.x),G=Z.y.minus($.y),F=W.mul(q).minus(G.mul(z)).div(j),_=W.mul(H).minus(G.mul(Q)).div(j),U=X7(0),M=X7(1);if(F.gte(U)&&F.lte(M)&&_.gte(U)&&_.lte(M))return{x:$.x.plus(Q.mul(F)),y:$.y.plus(H.mul(F)),t:F,s:_};return null}function A5($,J,Z,K){if(!$||$.x===null||$.x===void 0||$.y===null||$.y===void 0)throw new Error("lineSegmentIntersection: lineA must have x and y properties");if(!J||J.x===null||J.x===void 0||J.y===null||J.y===void 0)throw new Error("lineSegmentIntersection: lineB must have x and y properties");if(!Z||Z.x===null||Z.x===void 0||Z.y===null||Z.y===void 0)throw new Error("lineSegmentIntersection: segA must have x and y properties");if(!K||K.x===null||K.x===void 0||K.y===null||K.y===void 0)throw new Error("lineSegmentIntersection: segB must have x and y properties");let Q=J.x.minus($.x),H=J.y.minus($.y),z=K.x.minus(Z.x),q=K.y.minus(Z.y),j=Q.mul(q).minus(H.mul(z));if(j.abs().lt(U7))return null;let W=Z.x.minus($.x),G=Z.y.minus($.y),F=W.mul(H).minus(G.mul(Q)).div(j);if(F.gte(0)&&F.lte(1))return{x:Z.x.plus(z.mul(F)),y:Z.y.plus(q.mul(F)),s:F};return null}function B7($,J){if(!$||$.x===null||$.x===void 0||$.y===null||$.y===void 0)throw new Error("pointInPolygon: pt must have x and y properties");if(!Array.isArray(J))throw new Error("pointInPolygon: polygon must be an array");let Z=J.length;if(Z<3)return-1;for(let Q=0;Q<Z;Q++)if(!J[Q]||J[Q].x===null||J[Q].x===void 0||J[Q].y===null||J[Q].y===void 0)throw new Error(`pointInPolygon: polygon[${Q}] must have x and y properties`);let K=0;for(let Q=0;Q<Z;Q++){let H=J[Q],z=J[(Q+1)%Z];if(E9($,H,z))return 0;if(H.y.lte($.y)){if(z.y.gt($.y)){if(y7(H,z,$).gt(0))K++}}else if(z.y.lte($.y)){if(y7(H,z,$).lt(0))K--}}return K!==0?1:-1}function E9($,J,Z){if(!$||$.x===null||$.x===void 0||$.y===null||$.y===void 0)throw new Error("pointOnSegment: pt must have x and y properties");if(!J||J.x===null||J.x===void 0||J.y===null||J.y===void 0)throw new Error("pointOnSegment: segment point a must have x and y properties");if(!Z||Z.x===null||Z.x===void 0||Z.y===null||Z.y===void 0)throw new Error("pointOnSegment: segment point b must have x and y properties");if(y7(J,Z,$).abs().gt(U7))return!1;let Q=L.min(J.x,Z.x),H=L.max(J.x,Z.x),z=L.min(J.y,Z.y),q=L.max(J.y,Z.y);return $.x.gte(Q.minus(U7))&&$.x.lte(H.plus(U7))&&$.y.gte(z.minus(U7))&&$.y.lte(q.plus(U7))}function T9($,J){if(!Array.isArray($))throw new Error("clipPolygonSH: subject must be an array");if(!Array.isArray(J))throw new Error("clipPolygonSH: clip must be an array");if($.length<3||J.length<3)return[];for(let Q=0;Q<$.length;Q++)if(!$[Q]||$[Q].x===null||$[Q].x===void 0||$[Q].y===null||$[Q].y===void 0)throw new Error(`clipPolygonSH: subject[${Q}] must have x and y properties`);for(let Q=0;Q<J.length;Q++)if(!J[Q]||J[Q].x===null||J[Q].x===void 0||J[Q].y===null||J[Q].y===void 0)throw new Error(`clipPolygonSH: clip[${Q}] must have x and y properties`);let Z=$.map((Q)=>f0(Q.x,Q.y)),K=J.map((Q)=>f0(Q.x,Q.y));K=N$(K);for(let Q=0;Q<K.length;Q++){if(Z.length===0)return[];let H=K[Q],z=K[(Q+1)%K.length],q=Z;Z=[];for(let j=0;j<q.length;j++){let W=q[j],G=q[(j+q.length-1)%q.length],F=C5(W,H,z),_=C5(G,H,z);if(F){if(!_){let U=I5(G,W,H,z);if(U)Z.push(U)}Z.push(W)}else if(_){let U=I5(G,W,H,z);if(U)Z.push(U)}}}return Z}function C5($,J,Z){if(!$||$.x===null||$.x===void 0||$.y===null||$.y===void 0)throw new Error("isInsideEdge: pt must have x and y properties");if(!J||J.x===null||J.x===void 0||J.y===null||J.y===void 0)throw new Error("isInsideEdge: edgeStart must have x and y properties");if(!Z||Z.x===null||Z.x===void 0||Z.y===null||Z.y===void 0)throw new Error("isInsideEdge: edgeEnd must have x and y properties");return y7(J,Z,$).gte(0)}function I5($,J,Z,K){if(!$||$.x===null||$.x===void 0||$.y===null||$.y===void 0)throw new Error("lineIntersection: point a must have x and y properties");if(!J||J.x===null||J.x===void 0||J.y===null||J.y===void 0)throw new Error("lineIntersection: point b must have x and y properties");if(!Z||Z.x===null||Z.x===void 0||Z.y===null||Z.y===void 0)throw new Error("lineIntersection: point c must have x and y properties");if(!K||K.x===null||K.x===void 0||K.y===null||K.y===void 0)throw new Error("lineIntersection: point d must have x and y properties");let Q=J.x.minus($.x),H=J.y.minus($.y),z=K.x.minus(Z.x),q=K.y.minus(Z.y),j=Q.mul(q).minus(H.mul(z));if(j.abs().lt(U7))return null;let W=Z.x.minus($.x),G=Z.y.minus($.y),F=W.mul(q).minus(G.mul(z)).div(j);return{x:$.x.plus(Q.mul(F)),y:$.y.plus(H.mul(F))}}function x6($){if(!Array.isArray($))throw new Error("polygonArea: polygon must be an array");let J=$.length;if(J<3)return X7(0);for(let K=0;K<J;K++)if(!$[K]||$[K].x===null||$[K].x===void 0||$[K].y===null||$[K].y===void 0)throw new Error(`polygonArea: polygon[${K}] must have x and y properties`);let Z=X7(0);for(let K=0;K<J;K++){let Q=$[K],H=$[(K+1)%J];Z=Z.plus(Q.x.mul(H.y).minus(H.x.mul(Q.y)))}return Z.div(2)}function b9($){if(!Array.isArray($))throw new Error("isCounterClockwise: polygon must be an array");return x6($).gt(0)}function f9($){if(!Array.isArray($))throw new Error("reversePolygon: polygon must be an array");return[...$].reverse()}function N$($){if(!Array.isArray($))throw new Error("ensureCCW: polygon must be an array");if(!b9($))return f9($);return $}function S9($){if(!Array.isArray($))throw new Error("convexHull: points must be an array");if($.length<3){for(let z=0;z<$.length;z++)if(!$[z]||$[z].x===null||$[z].x===void 0||$[z].y===null||$[z].y===void 0)throw new Error(`convexHull: points[${z}] must have x and y properties`);return $.map((z)=>f0(z.x,z.y))}for(let z=0;z<$.length;z++)if(!$[z]||$[z].x===null||$[z].x===void 0||$[z].y===null||$[z].y===void 0)throw new Error(`convexHull: points[${z}] must have x and y properties`);let J=$.map((z)=>f0(z.x,z.y)),Z=0;for(let z=1;z<J.length;z++)if(J[z].y.lt(J[Z].y)||J[z].y.eq(J[Z].y)&&J[z].x.lt(J[Z].x))Z=z;[J[0],J[Z]]=[J[Z],J[0]];let K=J[0],Q=J.slice(1).sort((z,q)=>{let j=y7(K,z,q);if(j.abs().lt(U7)){let G=z.x.minus(K.x).pow(2).plus(z.y.minus(K.y).pow(2)),F=q.x.minus(K.x).pow(2).plus(q.y.minus(K.y).pow(2)),_=G.minus(F);if(_.abs().lt(U7))return 0;return _.lt(0)?-1:1}return-A9(j)}),H=[K];for(let z of Q){while(H.length>1&&y7(H[H.length-2],H[H.length-1],z).lte(0))H.pop();H.push(z)}return H}function u7($){if(!Array.isArray($))throw new Error("boundingBox: polygon must be an array");if($.length===0)return null;if(!$[0]||$[0].x===null||$[0].x===void 0||$[0].y===null||$[0].y===void 0)throw new Error("boundingBox: polygon[0] must have x and y properties");let J=X7($[0].x),Z=X7($[0].y),K=X7($[0].x),Q=X7($[0].y);for(let H=0;H<$.length;H++){let z=$[H];if(!z||z.x===null||z.x===void 0||z.y===null||z.y===void 0)throw new Error(`boundingBox: polygon[${H}] must have x and y properties`);let q=X7(z.x),j=X7(z.y);if(q.lt(J))J=q;if(j.lt(Z))Z=j;if(q.gt(K))K=q;if(j.gt(Q))Q=j}return{minX:J,minY:Z,maxX:K,maxY:Q}}function m6($,J){if(!$||!J)return!1;if($.minX===null||$.minX===void 0||$.minY===null||$.minY===void 0||$.maxX===null||$.maxX===void 0||$.maxY===null||$.maxY===void 0)throw new Error("bboxIntersects: bb1 must have minX, minY, maxX, maxY properties");if(J.minX===null||J.minX===void 0||J.minY===null||J.minY===void 0||J.maxX===null||J.maxX===void 0||J.maxY===null||J.maxY===void 0)throw new Error("bboxIntersects: bb2 must have minX, minY, maxX, maxY properties");return!($.maxX.lt(J.minX)||J.maxX.lt($.minX)||$.maxY.lt(J.minY)||J.maxY.lt($.minY))}function E7($,J){if(!Array.isArray($))throw new Error("polygonIntersection: subject must be an array");if(!Array.isArray(J))throw new Error("polygonIntersection: clip must be an array");for(let z=0;z<$.length;z++)if(!$[z]||$[z].x===null||$[z].x===void 0||$[z].y===null||$[z].y===void 0)throw new Error(`polygonIntersection: subject[${z}] must have x and y properties`);for(let z=0;z<J.length;z++)if(!J[z]||J[z].x===null||J[z].x===void 0||J[z].y===null||J[z].y===void 0)throw new Error(`polygonIntersection: clip[${z}] must have x and y properties`);let Z=$.map((z)=>f0(z.x,z.y)),K=J.map((z)=>f0(z.x,z.y)),Q=u7(Z),H=u7(K);if(!m6(Q,H))return[];if(v9(K)){let z=T9(Z,N$(K));return z.length>=3?[z]:[]}return oQ(Z,K)}function v9($){if(!Array.isArray($))throw new Error("isConvex: polygon must be an array");let J=$.length;if(J<3)return!1;for(let K=0;K<J;K++)if(!$[K]||$[K].x===null||$[K].x===void 0||$[K].y===null||$[K].y===void 0)throw new Error(`isConvex: polygon[${K}] must have x and y properties`);let Z=0;for(let K=0;K<J;K++){let Q=$[K],H=$[(K+1)%J],z=$[(K+2)%J],q=y7(Q,H,z),j=q.gt(0)?1:q.lt(0)?-1:0;if(j!==0){if(Z===0)Z=j;else if(Z!==j)return!1}}return!0}function oQ($,J){if(!Array.isArray($)||!Array.isArray(J))throw new Error("generalPolygonIntersection: both arguments must be arrays");let Z=[];for(let j=0;j<$.length;j++){let W=$[j],G=$[(j+1)%$.length];for(let F=0;F<J.length;F++){let _=J[F],U=J[(F+1)%J.length],M=B$(W,G,_,U);if(M)Z.push(f0(M.x,M.y))}}let K=$.filter((j)=>B7(j,J)>=0),Q=J.filter((j)=>B7(j,$)>=0),H=[...Z,...K,...Q];if(H.length<3)return[];let z=iQ(H);if(z.length<3)return[];let q=S9(z);return q.length>=3?[q]:[]}function iQ($){if(!Array.isArray($))throw new Error("removeDuplicatePoints: points must be an array");let J=[];for(let Z of $){let K=!1;for(let Q of J)if(h7(Z,Q)){K=!0;break}if(!K)J.push(Z)}return J}function W6($,J){if(!Array.isArray($))throw new Error("polygonUnion: polygon1 must be an array");if(!Array.isArray(J))throw new Error("polygonUnion: polygon2 must be an array");for(let z=0;z<$.length;z++)if(!$[z]||$[z].x===null||$[z].x===void 0||$[z].y===null||$[z].y===void 0)throw new Error(`polygonUnion: polygon1[${z}] must have x and y properties`);for(let z=0;z<J.length;z++)if(!J[z]||J[z].x===null||J[z].x===void 0||J[z].y===null||J[z].y===void 0)throw new Error(`polygonUnion: polygon2[${z}] must have x and y properties`);let Z=$.map((z)=>f0(z.x,z.y)),K=J.map((z)=>f0(z.x,z.y)),Q=u7(Z),H=u7(K);if(!m6(Q,H))return[Z,K];return rQ(Z,K)}function rQ($,J){if(!Array.isArray($)||!Array.isArray(J))throw new Error("traceBoundaryUnion: both arguments must be arrays");let Z=E5($,J);if(Z.length===0){let V=B7($[0],J),Y=B7(J[0],$);if(V>0)return[J];else if(Y>0)return[$];else return[$,J]}let K=R$($,Z.map((V)=>({edgeIndex:V.edge1,t:V.t1,point:V.point,intersectionId:V.id}))),Q=R$(J,Z.map((V)=>({edgeIndex:V.edge2,t:V.t2,point:V.point,intersectionId:V.id}))),H=new Map;for(let V=0;V<K.length;V++)if(K[V].intersectionId!==void 0){if(!H.has(K[V].intersectionId))H.set(K[V].intersectionId,{});H.get(K[V].intersectionId).idx1=V}for(let V=0;V<Q.length;V++)if(Q[V].intersectionId!==void 0){if(!H.has(Q[V].intersectionId))H.set(Q[V].intersectionId,{});H.get(Q[V].intersectionId).idx2=V}let z=1,q=-1;for(let V=0;V<K.length;V++){let Y=K[V];if(Y.intersectionId===void 0&&B7(Y,J)<0){q=V;break}}if(q===-1){z=2;for(let V=0;V<Q.length;V++){let Y=Q[V];if(Y.intersectionId===void 0&&B7(Y,$)<0){q=V;break}}}if(q===-1){let V=x6($).abs(),Y=x6(J).abs();return V.gt(Y)?[$]:[J]}let j=[],W=z===1,G=q,F=new Set,_=(K.length+Q.length)*3,U=0,M=`${z}-${q}`;while(U<_){U++;let V=W?K:Q,Y=W?Q:K,O=V[G];if(j.length===0||!h7(j[j.length-1],O))j.push(f0(O.x,O.y));let X=(G+1)%V.length,w=V[X];if(w.intersectionId!==void 0&&!F.has(w.intersectionId)){j.push(f0(w.x,w.y)),F.add(w.intersectionId);let B=H.get(w.intersectionId),I=W?B.idx2:B.idx1;W=!W,G=(I+1)%Y.length}else G=X;if(`${W?1:2}-${G}`===M)break}if(j.length>1&&h7(j[0],j[j.length-1]))j.pop();return j.length>=3?[j]:[]}function E5($,J){if(!Array.isArray($)||!Array.isArray(J))throw new Error("findAllIntersections: both arguments must be arrays");let Z=[],K=0;for(let Q=0;Q<$.length;Q++){let H=$[Q],z=$[(Q+1)%$.length];for(let q=0;q<J.length;q++){let j=J[q],W=J[(q+1)%J.length],G=B$(H,z,j,W);if(G)Z.push({id:K++,point:f0(G.x,G.y),edge1:Q,edge2:q,t1:G.t,t2:G.s})}}return Z}function R$($,J){if(!Array.isArray($))throw new Error("augmentPolygon: polygon must be an array");if(!Array.isArray(J))throw new Error("augmentPolygon: insertions must be an array");let Z=new Map;for(let Q of J){if(!Z.has(Q.edgeIndex))Z.set(Q.edgeIndex,[]);Z.get(Q.edgeIndex).push(Q)}for(let Q of Z.values())Q.sort((H,z)=>H.t.minus(z.t).toNumber());let K=[];for(let Q=0;Q<$.length;Q++)if(K.push({...$[Q]}),Z.has(Q))for(let H of Z.get(Q))K.push({x:H.point.x,y:H.point.y,intersectionId:H.intersectionId});return K}function T5($,J){if(!Array.isArray($))throw new Error("polygonDifference: polygon1 must be an array");if(!Array.isArray(J))throw new Error("polygonDifference: polygon2 must be an array");for(let z=0;z<$.length;z++)if(!$[z]||$[z].x===null||$[z].x===void 0||$[z].y===null||$[z].y===void 0)throw new Error(`polygonDifference: polygon1[${z}] must have x and y properties`);for(let z=0;z<J.length;z++)if(!J[z]||J[z].x===null||J[z].x===void 0||J[z].y===null||J[z].y===void 0)throw new Error(`polygonDifference: polygon2[${z}] must have x and y properties`);let Z=$.map((z)=>f0(z.x,z.y)),K=J.map((z)=>f0(z.x,z.y)),Q=u7(Z),H=u7(K);if(!m6(Q,H))return[Z];return aQ(Z,K)}function aQ($,J){if(!Array.isArray($)||!Array.isArray(J))throw new Error("traceBoundaryDifference: both arguments must be arrays");let Z=E5($,J);if(Z.length===0)if(B7($[0],J)>0)return[];else return[$];let K=R$($,Z.map((U)=>({edgeIndex:U.edge1,t:U.t1,point:U.point,intersectionId:U.id}))),Q=R$(J,Z.map((U)=>({edgeIndex:U.edge2,t:U.t2,point:U.point,intersectionId:U.id}))),H=new Map;for(let U=0;U<K.length;U++)if(K[U].intersectionId!==void 0){if(!H.has(K[U].intersectionId))H.set(K[U].intersectionId,{});H.get(K[U].intersectionId).idx1=U}for(let U=0;U<Q.length;U++)if(Q[U].intersectionId!==void 0){if(!H.has(Q[U].intersectionId))H.set(Q[U].intersectionId,{});H.get(Q[U].intersectionId).idx2=U}let z=-1;for(let U=0;U<K.length;U++){let M=K[U];if(M.intersectionId===void 0&&B7(M,J)<0){z=U;break}}if(z===-1)return[];let q=[],j=!0,W=z,G=new Set,F=(K.length+Q.length)*3,_=0;while(_<F){_++;let M=(j?K:Q)[W];if(q.length===0||!h7(q[q.length-1],M))q.push(f0(M.x,M.y));let V=`${j?1:2}-${W}`;if(G.has(V))break;if(G.add(V),j){let Y=(W+1)%K.length,O=K[Y];if(O.intersectionId!==void 0){let X=K[(Y+1)%K.length];if(B7(X,J)>0){let R=H.get(O.intersectionId);q.push(f0(O.x,O.y)),j=!1,W=(R.idx2-1+Q.length)%Q.length}else W=Y}else W=Y}else{let Y=(W-1+Q.length)%Q.length,O=Q[Y];if(O.intersectionId!==void 0){let X=H.get(O.intersectionId);q.push(f0(O.x,O.y)),j=!0,W=(X.idx1+1)%K.length}else W=Y}if(j&&W===z)break}if(q.length>1&&h7(q[0],q[q.length-1]))q.pop();return q.length>=3?[q]:[]}var tQ={point:f0,pointsEqual:h7,cross:y7,dot:P5,sign:A9,segmentIntersection:B$,lineSegmentIntersection:A5,pointInPolygon:B7,pointOnSegment:E9,clipPolygonSH:T9,polygonArea:x6,isCounterClockwise:b9,reversePolygon:f9,ensureCCW:N$,isConvex:v9,convexHull:S9,boundingBox:u7,bboxIntersects:m6,polygonIntersection:E7,polygonUnion:W6,polygonDifference:T5,EPSILON:U7};L.set({precision:80});var C$=($)=>$ instanceof L?$:new L($),g7=new L("1e-40"),{point:r7,cross:D9,polygonIntersection:HW,polygonUnion:zW,polygonDifference:qW}=T7,a7={NONZERO:"nonzero",EVENODD:"evenodd"};function I$($,J,Z=a7.NONZERO){if(!$||typeof $!=="object")throw new Error("pointInPolygonWithRule: pt must be an object with x, y properties");if($.x===void 0||$.x===null||$.y===void 0||$.y===null)throw new Error("pointInPolygonWithRule: pt must have x and y properties");if(!Array.isArray(J))throw new Error("pointInPolygonWithRule: polygon must be an array");let K=J.length;if(K<3)return-1;let Q=0;for(let H=0;H<K;H++){let z=J[H],q=J[(H+1)%K];if(eQ($,z,q))return 0;if(z.y.lte($.y)){if(q.y.gt($.y)){if(D9(z,q,$).gt(0))Q++}}else if(q.y.lte($.y)){if(D9(z,q,$).lt(0))Q--}}if(Z===a7.EVENODD)return Math.abs(Q)%2===1?1:-1;else return Q!==0?1:-1}function eQ($,J,Z){if(!$||!J||!Z)throw new Error("pointOnSegment: pt, a, and b must be defined");if($.x===void 0||$.x===null||$.y===void 0||$.y===null||J.x===void 0||J.x===null||J.y===void 0||J.y===null||Z.x===void 0||Z.x===null||Z.y===void 0||Z.y===null)throw new Error("pointOnSegment: all points must have x and y properties");if(D9(J,Z,$).abs().gt(g7))return!1;let Q=L.min(J.x,Z.x),H=L.max(J.x,Z.x),z=L.min(J.y,Z.y),q=L.max(J.y,Z.y);return $.x.gte(Q.minus(g7))&&$.x.lte(H.plus(g7))&&$.y.gte(z.minus(g7))&&$.y.lte(q.plus(g7))}function $H($,J,Z={}){if(!Array.isArray($))throw new Error("offsetPolygon: polygon must be an array");if(J===void 0||J===null)throw new Error("offsetPolygon: distance must be defined");if(!Z||typeof Z!=="object")throw new Error("offsetPolygon: options must be an object");let K=C$(J);if(K.lte(0))throw new Error("offsetPolygon: distance must be positive");let Q=Z.linejoin||"miter",H=C$(Z.miterLimit||4);if($.length<3)return{outer:[],inner:[]};let z=$.length,q=[],j=[];for(let W=0;W<z;W++){let G=$[(W-1+z)%z],F=$[W],_=$[(W+1)%z],U=F.x.minus(G.x),M=F.y.minus(G.y),V=_.x.minus(F.x),Y=_.y.minus(F.y),O=U.pow(2).plus(M.pow(2)).sqrt(),X=V.pow(2).plus(Y.pow(2)).sqrt();if(O.lt(g7)||X.lt(g7))continue;let w=M.div(O),R=U.neg().div(O),B=Y.div(X),I=V.neg().div(X),h=w.plus(B).div(2),m=R.plus(I).div(2),v=h.pow(2).plus(m.pow(2)).sqrt();if(v.lt(g7))h=w,m=R;else h=h.div(v),m=m.div(v);let x=w.times(B).plus(R.times(I)),y=C$(1).minus(x).div(2).sqrt(),T=K;if(y.gt(g7)){let d=K.div(y);if(Q==="miter"&&d.lte(K.times(H)))T=d;else if(Q==="bevel"||d.gt(K.times(H))){let p=r7(F.x.plus(w.times(K)),F.y.plus(R.times(K))),c=r7(F.x.plus(B.times(K)),F.y.plus(I.times(K)));q.push(p,c);let C=r7(F.x.minus(w.times(K)),F.y.minus(R.times(K))),u=r7(F.x.minus(B.times(K)),F.y.minus(I.times(K)));j.push(C,u);continue}else if(Q==="round"){let p=Math.atan2(R.toNumber(),w.toNumber()),C=Math.atan2(I.toNumber(),B.toNumber())-p;if(C<-Math.PI)C+=2*Math.PI;if(C>Math.PI)C-=2*Math.PI;let u=Math.max(2,Math.ceil(Math.abs(C)/(Math.PI/8)));for(let N=0;N<=u;N++){let e=p+C*(N/u);q.push(r7(F.x.plus(K.times(Math.cos(e))),F.y.plus(K.times(Math.sin(e))))),j.push(r7(F.x.minus(K.times(Math.cos(e))),F.y.minus(K.times(Math.sin(e)))))}continue}}q.push(r7(F.x.plus(h.times(T)),F.y.plus(m.times(T)))),j.push(r7(F.x.minus(h.times(T)),F.y.minus(m.times(T))))}return{outer:q,inner:j.reverse()}}function h9($,J){if(!Array.isArray($))throw new Error("strokeToFilledPolygon: polygon must be an array");if(!J||typeof J!=="object")throw new Error("strokeToFilledPolygon: strokeProps must be an object");if(J.width===void 0||J.width===null)throw new Error("strokeToFilledPolygon: strokeProps must have width property");let Z=C$(J.width).div(2);if(Z.lte(0))throw new Error("strokeToFilledPolygon: width must be positive");return $H($,Z,J).outer}L.set({precision:80});var b7=($)=>$ instanceof L?$:new L($),JH={fill:"black","fill-rule":"nonzero","fill-opacity":1,stroke:"none","stroke-width":1,"stroke-linecap":"butt","stroke-linejoin":"miter","stroke-miterlimit":4,"stroke-dasharray":"none","stroke-dashoffset":0,"stroke-opacity":1,"marker-start":"none","marker-mid":"none","marker-end":"none","paint-order":"normal","clip-path":"none","clip-rule":"nonzero",mask:"none","mask-type":"luminance",opacity:1,transform:"none","vector-effect":"none",filter:"none"};class P${constructor($,J={},Z=null){if(!$)throw new Error("SVGRenderingContext: element parameter is required");if(J!==null&&typeof J!=="object")throw new Error("SVGRenderingContext: inherited must be an object or null");this.element=$,this.defsMap=Z||new Map,this.properties=this._extractProperties($,J||{}),this.dashArray=this._parseDashArray(this.properties["stroke-dasharray"]),this.dashOffset=b7(this.properties["stroke-dashoffset"]||0),this.markers={start:this._parseMarkerRef(this.properties["marker-start"]),mid:this._parseMarkerRef(this.properties["marker-mid"]),end:this._parseMarkerRef(this.properties["marker-end"])},this.hasFill=this.properties.fill!=="none"&&this.properties["fill-opacity"]>0,this.hasStroke=this.properties.stroke!=="none"&&b7(this.properties["stroke-width"]).gt(0)&&this.properties["stroke-opacity"]>0,this.hasMarkers=this.markers.start||this.markers.mid||this.markers.end}_extractProperties($,J){if(J!==null&&typeof J!=="object")throw new Error("_extractProperties: inherited must be an object or null");let Z={...JH,...J||{}};if($&&$.getAttributeNames)for(let Q of $.getAttributeNames()){let H=$.getAttribute(Q);if(H!==null&&H!==void 0)Z[Q]=H}if(Z.style){let Q=this._parseStyleAttribute(Z.style);Object.assign(Z,Q)}let K=["stroke-width","stroke-miterlimit","stroke-dashoffset","opacity","fill-opacity","stroke-opacity"];for(let Q of K)if(typeof Z[Q]==="string"){let H=parseFloat(Z[Q]);if(!isNaN(H))Z[Q]=H}return Z}_parseStyleAttribute($){let J={};if(!$)return J;let Z=$.split(";");for(let K of Z){if(!K.includes(":"))continue;let[Q,H]=K.split(":").map((z)=>z.trim());if(Q&&H)J[Q]=H}return J}_parseDashArray($){if(!$||$==="none")return null;let J=$.toString().split(/[\s,]+/).filter((K)=>K),Z=[];for(let K of J){let Q=parseFloat(K);if(isNaN(Q)||!isFinite(Q))throw new Error(`_parseDashArray: invalid dash value '${K}'`);if(Q<0)throw new Error(`_parseDashArray: dash values must be non-negative, got ${Q}`);Z.push(b7(Q))}if(Z.length===0)return null;if(Z.length%2===1)return[...Z,...Z];return Z}_parseMarkerRef($){if(!$||$==="none")return null;let J=$.match(/url\(#?([^)]+)\)/);return J?J[1]:null}get fillRule(){return this.properties["fill-rule"]||"nonzero"}get clipRule(){return this.properties["clip-rule"]||"nonzero"}get strokeWidth(){return b7(this.properties["stroke-width"]||0)}get strokeLinecap(){return this.properties["stroke-linecap"]||"butt"}get strokeLinejoin(){return this.properties["stroke-linejoin"]||"miter"}get strokeMiterlimit(){return b7(this.properties["stroke-miterlimit"]||4)}getStrokeExtent(){if(!this.hasStroke)return b7(0);let $=this.strokeWidth.div(2),J=$;if(this.strokeLinejoin==="miter")J=$.times(this.strokeMiterlimit);if(this.strokeLinecap==="square"){let Z=$.times(2);if(Z.gt(J))J=Z}return J}expandBBoxForStroke($){if(!$||typeof $!=="object")throw new Error("expandBBoxForStroke: bbox must be an object");if(!("x"in $)||!("y"in $)||!("width"in $)||!("height"in $))throw new Error("expandBBoxForStroke: bbox must have x, y, width, height properties");if(typeof $.x.minus!=="function"||typeof $.y.minus!=="function"||typeof $.width.plus!=="function"||typeof $.height.plus!=="function")throw new Error("expandBBoxForStroke: bbox properties must be Decimal instances");if(!this.hasStroke)return $;let J=this.getStrokeExtent();return{x:$.x.minus(J),y:$.y.minus(J),width:$.width.plus(J.times(2)),height:$.height.plus(J.times(2))}}expandBBoxForMarkers($,J=null){if(!$||typeof $!=="object")throw new Error("expandBBoxForMarkers: bbox must be an object");if(!("x"in $)||!("y"in $)||!("width"in $)||!("height"in $))throw new Error("expandBBoxForMarkers: bbox must have x, y, width, height properties");if(typeof $.x.minus!=="function"||typeof $.y.minus!=="function"||typeof $.width.plus!=="function"||typeof $.height.plus!=="function")throw new Error("expandBBoxForMarkers: bbox properties must be Decimal instances");if(!this.hasMarkers)return $;let Z=b7(0);if(J){if(typeof J!=="object")throw new Error("expandBBoxForMarkers: markerSizes must be an object");let Q=[J.start,J.mid,J.end].filter((H)=>H!==null&&H!==void 0).map((H)=>{let z=typeof H==="number"?H:parseFloat(H);if(isNaN(z)||!isFinite(z))throw new Error(`expandBBoxForMarkers: invalid marker size '${H}'`);return b7(z)});if(Q.length>0)Z=L.max(...Q)}else Z=this.strokeWidth.times(3);if(Z.lte(0))return $;let K=Z.div(2);return{x:$.x.minus(K),y:$.y.minus(K),width:$.width.plus(K.times(2)),height:$.height.plus(K.times(2))}}expandBBoxForFilter($,J=null){if(!$||typeof $!=="object")throw new Error("expandBBoxForFilter: bbox must be an object");if(!("x"in $)||!("y"in $)||!("width"in $)||!("height"in $))throw new Error("expandBBoxForFilter: bbox must have x, y, width, height properties");if(typeof $.x.minus!=="function"||typeof $.y.minus!=="function"||typeof $.width.times!=="function"||typeof $.height.times!=="function")throw new Error("expandBBoxForFilter: bbox properties must be Decimal instances");let Z=this.properties.filter;if(!Z||Z==="none")return $;let K=$.width.times("0.1"),Q=$.height.times("0.1");if(J){if(typeof J!=="object")throw new Error("expandBBoxForFilter: filterDef must be an object");if(J.x!==void 0){let H=parseFloat(J.x);if(isNaN(H)||!isFinite(H))throw new Error(`expandBBoxForFilter: invalid filterDef.x value '${J.x}'`);K=b7(H).abs()}if(J.y!==void 0){let H=parseFloat(J.y);if(isNaN(H)||!isFinite(H))throw new Error(`expandBBoxForFilter: invalid filterDef.y value '${J.y}'`);Q=b7(H).abs()}}return{x:$.x.minus(K),y:$.y.minus(Q),width:$.width.plus(K.times(2)),height:$.height.plus(Q.times(2))}}getRenderedBBox($,J={}){if(!$||typeof $!=="object")throw new Error("getRenderedBBox: geometryBBox must be an object");if(!("x"in $)||!("y"in $)||!("width"in $)||!("height"in $))throw new Error("getRenderedBBox: geometryBBox must have x, y, width, height properties");if(typeof $.x.minus!=="function"||typeof $.y.minus!=="function")throw new Error("getRenderedBBox: geometryBBox properties must be Decimal instances");if(J!==null&&typeof J!=="object")throw new Error("getRenderedBBox: options must be an object or null");let Z={...$};return Z=this.expandBBoxForStroke(Z),Z=this.expandBBoxForMarkers(Z,J.markerSizes),Z=this.expandBBoxForFilter(Z,J.filterDef),Z}getFilledArea($){if(!Array.isArray($))throw new Error("getFilledArea: polygon must be an array");if($.length===0)throw new Error("getFilledArea: polygon must not be empty");let J=[];if(this.hasFill)J.push({polygon:$,fillRule:this.fillRule,type:"fill"});if(this.hasStroke){let Z=h9($,{width:this.strokeWidth.toNumber(),linecap:this.strokeLinecap,linejoin:this.strokeLinejoin,miterlimit:this.strokeMiterlimit.toNumber()});if(Z&&Z.length>0)J.push({polygon:Z,fillRule:"nonzero",type:"stroke"})}return J}isPointInRenderedArea($,J){if(!$||typeof $!=="object")throw new Error("isPointInRenderedArea: point must be an object");if($.x===void 0||$.y===void 0)throw new Error("isPointInRenderedArea: point must have x and y properties");if(!Array.isArray(J))throw new Error("isPointInRenderedArea: polygon must be an array");if(J.length===0)throw new Error("isPointInRenderedArea: polygon must not be empty");if(this.hasFill){let Z=this.fillRule==="evenodd"?a7.EVENODD:a7.NONZERO;if(I$($,J,Z)>=0)return!0}if(this.hasStroke){let Z=h9(J,{width:this.strokeWidth.toNumber(),linecap:this.strokeLinecap,linejoin:this.strokeLinejoin,miterlimit:this.strokeMiterlimit.toNumber()});if(Z&&Z.length>0){if(I$($,Z,a7.NONZERO)>=0)return!0}}return!1}canMergeWith($){if(!($ instanceof P$))throw new Error("canMergeWith: other must be an instance of SVGRenderingContext");if(this.fillRule!==$.fillRule)return{canMerge:!1,reason:"Different fill-rule"};if(this.hasStroke||$.hasStroke){if(this.hasStroke!==$.hasStroke)return{canMerge:!1,reason:"Different stroke presence"};if(!this.strokeWidth.eq($.strokeWidth))return{canMerge:!1,reason:"Different stroke-width"};if(this.strokeLinecap!==$.strokeLinecap)return{canMerge:!1,reason:"Different stroke-linecap"};if(this.strokeLinejoin!==$.strokeLinejoin)return{canMerge:!1,reason:"Different stroke-linejoin"}}if(this.hasMarkers||$.hasMarkers)return{canMerge:!1,reason:"Has markers"};if(this.properties["clip-path"]!=="none"||$.properties["clip-path"]!=="none")return{canMerge:!1,reason:"Has clip-path"};if(this.properties.mask!=="none"||$.properties.mask!=="none")return{canMerge:!1,reason:"Has mask"};if(this.properties.filter!=="none"||$.properties.filter!=="none")return{canMerge:!1,reason:"Has filter"};return{canMerge:!0,reason:null}}toSummary(){return{hasFill:this.hasFill,hasStroke:this.hasStroke,hasMarkers:this.hasMarkers,fillRule:this.fillRule,strokeWidth:this.hasStroke?this.strokeWidth.toNumber():0,strokeExtent:this.getStrokeExtent().toNumber(),linecap:this.strokeLinecap,linejoin:this.strokeLinejoin,clipPath:this.properties["clip-path"],filter:this.properties.filter}}}function d6($,J={},Z=null){if(!$)throw new Error("createRenderingContext: element parameter is required");return new P$($,J,Z)}function p6($){if(!$)throw new Error("getInheritedProperties: element parameter is required");let J={},Z=["fill","fill-rule","fill-opacity","stroke","stroke-width","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-dasharray","stroke-dashoffset","stroke-opacity","marker-start","marker-mid","marker-end","clip-rule","opacity","font-family","font-size","font-style","font-weight"];if(!$.parentNode)return J;let K=$.parentNode;while(K&&K.tagName){for(let Q of Z)if(J[Q]===void 0){let H=K.getAttribute?K.getAttribute(Q):null;if(H!==null&&H!==void 0)J[Q]=H}K=K.parentNode}return J}function v5($,J){if(!$||!J)throw new Error("setOwnerDocument: element and document are required");if(!$.children||!Array.isArray($.children))throw new Error("setOwnerDocument: element must have a children array");$.ownerDocument=J;for(let Z of $.children)if(Z instanceof B0)v5(Z,J)}function p0($){if(typeof $!=="string")throw new Error("parseSVG: input must be a string");if($.trim().length===0)throw new Error("parseSVG: input cannot be empty");let J=$.trim(),Z=h5(J,0);if(!Z.element)throw new Error("Failed to parse SVG: no root element found");let K=new D5(Z.element);return v5(Z.element,K),Z.element}class D5{constructor($=null){this.documentElement=$}createElement($){if(!$||typeof $!=="string")throw new Error("createElement: tagName must be a non-empty string");let J=new B0($);return J.ownerDocument=this,J}createElementNS($,J){if($!==null&&$!==void 0&&typeof $!=="string")throw new Error("createElementNS: namespace must be a string");return this.createElement(J)}}class B0{constructor($,J={},Z=[],K=""){if(!$||typeof $!=="string")throw new Error("SVGElement: tagName must be a non-empty string");if(J!==null&&typeof J!=="object")throw new Error("SVGElement: attributes must be an object");if(!Array.isArray(Z))throw new Error("SVGElement: children must be an array");if(typeof K!=="string")throw new Error("SVGElement: textContent must be a string");this.tagName=$,this.nodeName=$.toUpperCase(),this._attributes={...J},this.children=Z,this.childNodes=Z,this.textContent=K,this.parentNode=null,this.ownerDocument=null;for(let Q of Z)if(Q instanceof B0)Q.parentNode=this}getAttribute($){if(typeof $!=="string")throw new Error("getAttribute: name must be a string");return this._attributes[$]??null}setAttribute($,J){if(typeof $!=="string")throw new Error("setAttribute: name must be a string");if(J!==null&&J!==void 0)this._attributes[$]=String(J);else this._attributes[$]=""}hasAttribute($){if(typeof $!=="string")throw new Error("hasAttribute: name must be a string");return $ in this._attributes}removeAttribute($){if(typeof $!=="string")throw new Error("removeAttribute: name must be a string");delete this._attributes[$]}getAttributeNames(){return Object.keys(this._attributes)}getElementsByTagName($){if(typeof $!=="string")throw new Error("getElementsByTagName: tagName must be a string");if($.length===0)return[];let J=$.toLowerCase(),Z=[],K=(Q)=>{for(let H of Q.children)if(H instanceof B0){if(H.tagName.toLowerCase()===J||J==="*")Z.push(H);K(H)}};return K(this),Z}getElementById($){if(typeof $!=="string")throw new Error("getElementById: id must be a string");if($.length===0)return null;let J=(Z)=>{if(Z.getAttribute("id")===$)return Z;for(let K of Z.children)if(K instanceof B0){let Q=J(K);if(Q)return Q}return null};return J(this)}querySelector($){if(typeof $!=="string")throw new Error("querySelector: selector must be a string");return this.querySelectorAll($)[0]||null}querySelectorAll($){if(typeof $!=="string")throw new Error("querySelectorAll: selector must be a string");let J=[],Z=b5($),K=(Q)=>{for(let H of Q.children)if(H instanceof B0){if(f5(H,Z))J.push(H);K(H)}};return K(this),J}matches($){if(typeof $!=="string")throw new Error("matches: selector must be a string");let J=b5($);return f5(this,J)}cloneNode($=!0){if(typeof $!=="boolean")throw new Error("cloneNode: deep must be a boolean");let J=$?this.children.map((K)=>K instanceof B0?K.cloneNode(!0):K):[],Z=new B0(this.tagName,{...this._attributes},J,this.textContent);if(this.ownerDocument){let K=(Q,H)=>{Q.ownerDocument=H;for(let z of Q.children)if(z instanceof B0)K(z,H)};K(Z,this.ownerDocument)}return Z}appendChild($){if($===null||$===void 0)throw new Error("appendChild: child cannot be null or undefined");if($ instanceof B0&&$.parentNode)$.parentNode.removeChild($);if($ instanceof B0)$.parentNode=this;return this.children.push($),this.childNodes=this.children,$}removeChild($){if($===null||$===void 0)throw new Error("removeChild: child cannot be null or undefined");let J=this.children.indexOf($);if(J>=0){if(this.children.splice(J,1),this.childNodes=this.children,$ instanceof B0)$.parentNode=null}return $}insertBefore($,J){if($===null||$===void 0)throw new Error("insertBefore: newChild cannot be null or undefined");if(J===null||J===void 0)throw new Error("insertBefore: refChild cannot be null or undefined");if($ instanceof B0&&$.parentNode)$.parentNode.removeChild($);let Z=this.children.indexOf(J);if(Z>=0){if($ instanceof B0)$.parentNode=this;this.children.splice(Z,0,$),this.childNodes=this.children}else this.appendChild($);return $}replaceChild($,J){if($===null||$===void 0)throw new Error("replaceChild: newChild cannot be null or undefined");if(J===null||J===void 0)throw new Error("replaceChild: oldChild cannot be null or undefined");if($ instanceof B0&&$.parentNode)$.parentNode.removeChild($);let Z=this.children.indexOf(J);if(Z>=0){if(J instanceof B0)J.parentNode=null;if($ instanceof B0)$.parentNode=this;this.children[Z]=$,this.childNodes=this.children}return J}get style(){let $=this.getAttribute("style")||"",J={};if($.length===0)return J;return $.split(";").forEach((Z)=>{let K=Z.indexOf(":");if(K>0){let Q=Z.slice(0,K).trim(),H=Z.slice(K+1).trim();if(Q&&H)J[Q]=H}}),J}get firstChild(){return this.children[0]||null}get lastChild(){return this.children[this.children.length-1]||null}get nextSibling(){if(!this.parentNode)return null;let $=this.parentNode.children,J=$.indexOf(this);return $[J+1]||null}get previousSibling(){if(!this.parentNode)return null;let $=this.parentNode.children,J=$.indexOf(this);return J>0?$[J-1]:null}serialize($=0,J=!1){if(typeof $!=="number"||!Number.isFinite($)||$<0)throw new Error("serialize: indent must be a non-negative finite number");if(typeof J!=="boolean")throw new Error("serialize: minify must be a boolean");let Z=J?"":" ".repeat($),K=this._attributes["data-cdata-pending"]==="true",Q=Object.entries(this._attributes).filter(([W])=>W!=="data-cdata-pending").map(([W,G])=>`${W}="${KH(G)}"`).join(" "),H=Q?" "+Q:"";if(this.children.length===0&&!this.textContent)return`${Z}<${this.tagName}${H}/>`;let z=J?"":`
9
+ `,q=this.children.map((W)=>W instanceof B0?W.serialize($+1,J):A$(W)).join(z),j="";if(this.textContent&&this.children.length>0)if(K)j=`<![CDATA[
10
10
  ${this.textContent}
11
- ]]>`+z+q;else W=C$(this.textContent)+z+q;else if(this.textContent)if(K)W=`<![CDATA[
11
+ ]]>`+z+q;else j=A$(this.textContent)+z+q;else if(this.textContent)if(K)j=`<![CDATA[
12
12
  ${this.textContent}
13
- ]]>`;else W=C$(this.textContent);else W=q;if(this.children.length===0)return`${Z}<${this.tagName}${H}>${W}</${this.tagName}>`;return`${Z}<${this.tagName}${H}>${z}${W}${z}${Z}</${this.tagName}>`}get outerHTML(){return this.serialize(0)}get innerHTML(){return this.children.map(($)=>$ instanceof B0?$.serialize(0):C$($)).join(`
14
- `)}}function P5($,J,Z=!1){if(typeof $!=="string")throw new Error("parseElement: str must be a string");if(typeof J!=="number"||!Number.isFinite(J)||J<0)throw new Error("parseElement: pos must be a non-negative finite number");if($.length===0)return{element:null,endPos:0};if(J>=$.length)return{element:null,endPos:J};let K=J;while(K<$.length){let O=$.slice(K).match(/^(\s+)/);if(O){K+=O[1].length;continue}if($.slice(K,K+4)==="<!--"){let V=$.indexOf("-->",K+4);if(V===-1)break;K=V+3;continue}if($.slice(K,K+9)==="<![CDATA["){let V=$.indexOf("]]>",K+9);if(V===-1)break;K=V+3;continue}if($.slice(K,K+2)==="<?"){let V=$.indexOf("?>",K+2);if(V===-1)break;K=V+2;continue}if($.slice(K,K+9).toUpperCase()==="<!DOCTYPE"){let V=0,M=K+9;while(M<$.length){if($[M]==="[")V++;else if($[M]==="]")V--;else if($[M]===">"&&V===0){K=M+1;break}M++}if(M>=$.length)break;continue}break}if(K>=$.length||$[K]!=="<")return{element:null,endPos:K};let Q=$.slice(K).match(/^<([a-zA-Z][a-zA-Z0-9_:-]*)/);if(!Q)return{element:null,endPos:K};let H=Q[1];K+=Q[0].length;let z={};while(K<$.length){let O=$.slice(K).match(/^(\s+)/);if(O)K+=O[1].length;if($[K]===">"){K++;break}if($.slice(K,K+2)==="/>")return K+=2,{element:new B0(H,z,[]),endPos:K};let V=$.slice(K).match(/^([a-zA-Z][a-zA-Z0-9_:-]*)\s*=\s*(?:"([^"]*)"|'([^']*)')/);if(V){let M=V[1],Y=V[2]!==void 0?V[2]:V[3];z[M]=lQ(Y),K+=V[0].length}else{let M=$.slice(K).match(/^([a-zA-Z][a-zA-Z0-9_:-]*)/);if(M)z[M[1]]="",K+=M[0].length;else K++}}let q=[],W="",j=`</${H}>`;while(K<$.length){if($.slice(K,K+j.length).toLowerCase()===j.toLowerCase()){K+=j.length;break}if($[K]==="<"&&$[K+1]!=="/"){if($.slice(K,K+9)==="<![CDATA["){let Y=$.indexOf("]]>",K+9);if(Y!==-1){W+=$.slice(K+9,Y),K=Y+3;continue}}if($.slice(K,K+4)==="<!--"){let Y=$.indexOf("-->",K+4);if(Y!==-1){K=Y+3;continue}}let O=z["xml:space"],M=P5($,K,O==="preserve"?!0:O==="default"?!1:Z);if(M.element)q.push(M.element),K=M.endPos;else K++}else if($[K]==="<"&&$[K+1]==="/"){let O=$.slice(K).match(/^<\/([a-zA-Z][a-zA-Z0-9_:-]*)>/);if(O&&O[1].toLowerCase()===H.toLowerCase()){K+=O[0].length;break}K++}else{let O=$.indexOf("<",K);if(O===-1)W+=$.slice(K),K=$.length;else W+=$.slice(K,O),K=O}}let G=new B0(H,z,q,""),F=z["xml:space"],U=(F==="preserve"?!0:F==="default"?!1:Z)?N5(W):N5(W.trim());return G.textContent=U,{element:G,endPos:K}}function R5($){if(typeof $!=="string")throw new Error("parseSelector: selector must be a string");let J=$.trim();if(J.length===0)throw new Error("parseSelector: selector cannot be empty");let Z=[],K=J.split(/\s*,\s*/);for(let Q of K){let H={tag:null,id:null,classes:[],attrs:[]},z=Q,q=z.match(/^([a-zA-Z][a-zA-Z0-9_-]*)/);if(q)H.tag=q[1].toLowerCase(),z=z.slice(q[0].length);let W=z.match(/#([a-zA-Z][a-zA-Z0-9_-]*)/);if(W)H.id=W[1],z=z.replace(W[0],"");let j=z.matchAll(/\.([a-zA-Z][a-zA-Z0-9_-]*)/g);for(let F of j)H.classes.push(F[1]);let G=z.matchAll(/\[([a-zA-Z][a-zA-Z0-9_:-]*)(?:=["']?([^"'\]]+)["']?)?\]/g);for(let F of G)H.attrs.push({name:F[1],value:F[2]});Z.push(H)}return Z}function B5($,J){if(!($ instanceof B0))throw new Error("matchesAllSelectors: el must be an SVGElement");if(!Array.isArray(J))throw new Error("matchesAllSelectors: matchers must be an array");return J.some((Z)=>{if(Z.tag&&$.tagName.toLowerCase()!==Z.tag)return!1;if(Z.id&&$.getAttribute("id")!==Z.id)return!1;let K=($.getAttribute("class")||"").split(/\s+/).filter((Q)=>Q.length>0);for(let Q of Z.classes)if(!K.includes(Q))return!1;for(let Q of Z.attrs){if(!$.hasAttribute(Q.name))return!1;if(Q.value!==void 0&&$.getAttribute(Q.name)!==Q.value)return!1}return!0})}function C$($){if($===void 0||$===null)return"";if(typeof $!=="string")return String($);return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function cQ($){if($===null||$===void 0)return"";if(typeof $!=="string")return String($);return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function lQ($){if(!$)return $;return $.replace(/&#[xX]([0-9A-Fa-f]+);/g,(J,Z)=>{let K=parseInt(Z,16);if(!Number.isFinite(K))return"�";if(K===0||K>=1&&K<=8||K>=11&&K<=12||K>=14&&K<=31||K===65534||K===65535||K>1114111||K>=55296&&K<=57343)return"�";return String.fromCodePoint(K)}).replace(/&#(\d+);/g,(J,Z)=>{let K=parseInt(Z,10);if(!Number.isFinite(K))return"�";if(K===0||K>=1&&K<=8||K>=11&&K<=12||K>=14&&K<=31||K===65534||K===65535||K>1114111||K>=55296&&K<=57343)return"�";return String.fromCodePoint(K)}).replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/&apos;/g,"'").replace(/&nbsp;/g," ").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&")}function N5($){if(!$)return $;return $.replace(/&#[xX]([0-9A-Fa-f]+);/g,(J,Z)=>{let K=parseInt(Z,16);if(!Number.isFinite(K))return"�";if(K===0||K>=1&&K<=8||K>=11&&K<=12||K>=14&&K<=31||K===65534||K===65535||K>1114111||K>=55296&&K<=57343)return"�";return String.fromCodePoint(K)}).replace(/&#(\d+);/g,(J,Z)=>{let K=parseInt(Z,10);if(!Number.isFinite(K))return"�";if(K===0||K>=1&&K<=8||K>=11&&K<=12||K>=14&&K<=31||K===65534||K===65535||K>1114111||K>=55296&&K<=57343)return"�";return String.fromCodePoint(K)}).replace(/&nbsp;/g," ").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&")}function i7($){if(!$)throw new Error("buildDefsMap: svgRoot cannot be null or undefined");if(!($ instanceof B0))throw new Error("buildDefsMap: svgRoot must be an SVGElement");let J=new Map,Z=(K)=>{let Q=K.getAttribute("id");if(Q)J.set(Q,K);for(let H of K.children)if(H instanceof B0)Z(H)};return Z($),J}function u7($,J){if(!$)throw new Error("findElementsWithAttribute: root cannot be null or undefined");if(!($ instanceof B0))throw new Error("findElementsWithAttribute: root must be an SVGElement");if(typeof J!=="string")throw new Error("findElementsWithAttribute: attrName must be a string");let Z=[],K=(Q)=>{if(Q.hasAttribute(J))Z.push(Q);for(let H of Q.children)if(H instanceof B0)K(H)};return K($),Z}function r7($){if(!$||typeof $!=="string")return null;let J=$.trim();if(J.length===0)return null;let Z=J.match(/url\(\s*["']?#?([^"')]+)["']?\s*\)/i);return Z?Z[1]:null}function B7($,J={}){if(!$)throw new Error("serializeSVG: document is required");if(typeof $.serialize!=="function"){if(typeof $==="string")return $;throw new Error(`serializeSVG: expected SVGElement with serialize method, got ${$?.constructor?.name||typeof $}`)}let Z=J.minify||!1;return'<?xml version="1.0" encoding="UTF-8"?>'+(Z?"":`
15
- `)+$.serialize(0,Z)}var A5=(()=>({})),nQ=100,sQ=5000,d6={SILENT:0,ERROR:1,WARN:2,INFO:3,DEBUG:4},D9={level:d6.WARN,logToFile:null,timestamps:!1,_buffer:[],_flushTimer:null,_safeStringify($){if($===null)return"null";if($===void 0)return"undefined";if($ instanceof Error)return $.stack||`${$.name}: ${$.message}`;if(typeof $!=="object")return String($);try{let J=new WeakSet;return JSON.stringify($,(Z,K)=>{if(typeof K==="object"&&K!==null){if(J.has(K))return"[Circular]";J.add(K)}return K})}catch{return String($)}},_format($,J){if(typeof $!=="string"||!$)throw new Error("Logger._format: level must be a non-empty string");let Z=this._safeStringify(J);if(this.timestamps)return`[${new Date().toISOString()}] [${$}] ${Z}`;return`[${$}] ${Z}`},_bufferWrite($){if(!this.logToFile)return;if(this._buffer.push($),this._buffer.length>=nQ)this.flush();if(!this._flushTimer)this._flushTimer=setInterval(()=>this.flush(),sQ),this._flushTimer.unref()},flush(){if(!this.logToFile||this._buffer.length===0)return;try{let $=this._buffer.join(`
13
+ ]]>`;else j=A$(this.textContent);else j=q;if(this.children.length===0)return`${Z}<${this.tagName}${H}>${j}</${this.tagName}>`;return`${Z}<${this.tagName}${H}>${z}${j}${z}${Z}</${this.tagName}>`}get outerHTML(){return this.serialize(0)}get innerHTML(){return this.children.map(($)=>$ instanceof B0?$.serialize(0):A$($)).join(`
14
+ `)}}function h5($,J,Z=!1){if(typeof $!=="string")throw new Error("parseElement: str must be a string");if(typeof J!=="number"||!Number.isFinite(J)||J<0)throw new Error("parseElement: pos must be a non-negative finite number");if($.length===0)return{element:null,endPos:0};if(J>=$.length)return{element:null,endPos:J};let K=J;while(K<$.length){let M=$.slice(K).match(/^(\s+)/);if(M){K+=M[1].length;continue}if($.slice(K,K+4)==="<!--"){let V=$.indexOf("-->",K+4);if(V===-1)break;K=V+3;continue}if($.slice(K,K+9)==="<![CDATA["){let V=$.indexOf("]]>",K+9);if(V===-1)break;K=V+3;continue}if($.slice(K,K+2)==="<?"){let V=$.indexOf("?>",K+2);if(V===-1)break;K=V+2;continue}if($.slice(K,K+9).toUpperCase()==="<!DOCTYPE"){let V=0,Y=K+9;while(Y<$.length){if($[Y]==="[")V++;else if($[Y]==="]")V--;else if($[Y]===">"&&V===0){K=Y+1;break}Y++}if(Y>=$.length)break;continue}break}if(K>=$.length||$[K]!=="<")return{element:null,endPos:K};let Q=$.slice(K).match(/^<([a-zA-Z][a-zA-Z0-9_:-]*)/);if(!Q)return{element:null,endPos:K};let H=Q[1];K+=Q[0].length;let z={};while(K<$.length){let M=$.slice(K).match(/^(\s+)/);if(M)K+=M[1].length;if($[K]===">"){K++;break}if($.slice(K,K+2)==="/>")return K+=2,{element:new B0(H,z,[]),endPos:K};let V=$.slice(K).match(/^([a-zA-Z][a-zA-Z0-9_:-]*)\s*=\s*(?:"([^"]*)"|'([^']*)')/);if(V){let Y=V[1],O=V[2]!==void 0?V[2]:V[3];z[Y]=ZH(O),K+=V[0].length}else{let Y=$.slice(K).match(/^([a-zA-Z][a-zA-Z0-9_:-]*)/);if(Y)z[Y[1]]="",K+=Y[0].length;else K++}}let q=[],j="",W=`</${H}>`;while(K<$.length){if($.slice(K,K+W.length).toLowerCase()===W.toLowerCase()){K+=W.length;break}if($[K]==="<"&&$[K+1]!=="/"){if($.slice(K,K+9)==="<![CDATA["){let O=$.indexOf("]]>",K+9);if(O!==-1){j+=$.slice(K+9,O),K=O+3;continue}}if($.slice(K,K+4)==="<!--"){let O=$.indexOf("-->",K+4);if(O!==-1){K=O+3;continue}}let M=z["xml:space"],Y=h5($,K,M==="preserve"?!0:M==="default"?!1:Z);if(Y.element)q.push(Y.element),K=Y.endPos;else K++}else if($[K]==="<"&&$[K+1]==="/"){let M=$.slice(K).match(/^<\/([a-zA-Z][a-zA-Z0-9_:-]*)>/);if(M&&M[1].toLowerCase()===H.toLowerCase()){K+=M[0].length;break}K++}else{let M=$.indexOf("<",K);if(M===-1)j+=$.slice(K),K=$.length;else j+=$.slice(K,M),K=M}}let G=new B0(H,z,q,""),F=z["xml:space"],U=(F==="preserve"?!0:F==="default"?!1:Z)?S5(j):S5(j.trim());return G.textContent=U,{element:G,endPos:K}}function b5($){if(typeof $!=="string")throw new Error("parseSelector: selector must be a string");let J=$.trim();if(J.length===0)throw new Error("parseSelector: selector cannot be empty");let Z=[],K=J.split(/\s*,\s*/);for(let Q of K){let H={tag:null,id:null,classes:[],attrs:[]},z=Q,q=z.match(/^([a-zA-Z][a-zA-Z0-9_-]*)/);if(q)H.tag=q[1].toLowerCase(),z=z.slice(q[0].length);let j=z.match(/#([a-zA-Z][a-zA-Z0-9_-]*)/);if(j)H.id=j[1],z=z.replace(j[0],"");let W=z.matchAll(/\.([a-zA-Z][a-zA-Z0-9_-]*)/g);for(let F of W)H.classes.push(F[1]);let G=z.matchAll(/\[([a-zA-Z][a-zA-Z0-9_:-]*)(?:=["']?([^"'\]]+)["']?)?\]/g);for(let F of G)H.attrs.push({name:F[1],value:F[2]});Z.push(H)}return Z}function f5($,J){if(!($ instanceof B0))throw new Error("matchesAllSelectors: el must be an SVGElement");if(!Array.isArray(J))throw new Error("matchesAllSelectors: matchers must be an array");return J.some((Z)=>{if(Z.tag&&$.tagName.toLowerCase()!==Z.tag)return!1;if(Z.id&&$.getAttribute("id")!==Z.id)return!1;let K=($.getAttribute("class")||"").split(/\s+/).filter((Q)=>Q.length>0);for(let Q of Z.classes)if(!K.includes(Q))return!1;for(let Q of Z.attrs){if(!$.hasAttribute(Q.name))return!1;if(Q.value!==void 0&&$.getAttribute(Q.name)!==Q.value)return!1}return!0})}function A$($){if($===void 0||$===null)return"";if(typeof $!=="string")return String($);return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function KH($){if($===null||$===void 0)return"";if(typeof $!=="string")return String($);return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function ZH($){if(!$)return $;return $.replace(/&#[xX]([0-9A-Fa-f]+);/g,(J,Z)=>{let K=parseInt(Z,16);if(!Number.isFinite(K))return"�";if(K===0||K>=1&&K<=8||K>=11&&K<=12||K>=14&&K<=31||K===65534||K===65535||K>1114111||K>=55296&&K<=57343)return"�";return String.fromCodePoint(K)}).replace(/&#(\d+);/g,(J,Z)=>{let K=parseInt(Z,10);if(!Number.isFinite(K))return"�";if(K===0||K>=1&&K<=8||K>=11&&K<=12||K>=14&&K<=31||K===65534||K===65535||K>1114111||K>=55296&&K<=57343)return"�";return String.fromCodePoint(K)}).replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/&apos;/g,"'").replace(/&nbsp;/g," ").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&")}function S5($){if(!$)return $;return $.replace(/&#[xX]([0-9A-Fa-f]+);/g,(J,Z)=>{let K=parseInt(Z,16);if(!Number.isFinite(K))return"�";if(K===0||K>=1&&K<=8||K>=11&&K<=12||K>=14&&K<=31||K===65534||K===65535||K>1114111||K>=55296&&K<=57343)return"�";return String.fromCodePoint(K)}).replace(/&#(\d+);/g,(J,Z)=>{let K=parseInt(Z,10);if(!Number.isFinite(K))return"�";if(K===0||K>=1&&K<=8||K>=11&&K<=12||K>=14&&K<=31||K===65534||K===65535||K>1114111||K>=55296&&K<=57343)return"�";return String.fromCodePoint(K)}).replace(/&nbsp;/g," ").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&")}function t7($){if(!$)throw new Error("buildDefsMap: svgRoot cannot be null or undefined");if(!($ instanceof B0))throw new Error("buildDefsMap: svgRoot must be an SVGElement");let J=new Map,Z=(K)=>{let Q=K.getAttribute("id");if(Q)J.set(Q,K);for(let H of K.children)if(H instanceof B0)Z(H)};return Z($),J}function x7($,J){if(!$)throw new Error("findElementsWithAttribute: root cannot be null or undefined");if(!($ instanceof B0))throw new Error("findElementsWithAttribute: root must be an SVGElement");if(typeof J!=="string")throw new Error("findElementsWithAttribute: attrName must be a string");let Z=[],K=(Q)=>{if(Q.hasAttribute(J))Z.push(Q);for(let H of Q.children)if(H instanceof B0)K(H)};return K($),Z}function e7($){if(!$||typeof $!=="string")return null;let J=$.trim();if(J.length===0)return null;let Z=J.match(/url\(\s*["']?#?([^"')]+)["']?\s*\)/i);return Z?Z[1]:null}function N7($,J={}){if(!$)throw new Error("serializeSVG: document is required");if(typeof $.serialize!=="function"){if(typeof $==="string")return $;throw new Error(`serializeSVG: expected SVGElement with serialize method, got ${$?.constructor?.name||typeof $}`)}let Z=J.minify||!1;return'<?xml version="1.0" encoding="UTF-8"?>'+(Z?"":`
15
+ `)+$.serialize(0,Z)}var y5=(()=>({})),QH=100,HH=5000,c6={SILENT:0,ERROR:1,WARN:2,INFO:3,DEBUG:4},y9={level:c6.WARN,logToFile:null,timestamps:!1,_buffer:[],_flushTimer:null,_safeStringify($){if($===null)return"null";if($===void 0)return"undefined";if($ instanceof Error)return $.stack||`${$.name}: ${$.message}`;if(typeof $!=="object")return String($);try{let J=new WeakSet;return JSON.stringify($,(Z,K)=>{if(typeof K==="object"&&K!==null){if(J.has(K))return"[Circular]";J.add(K)}return K})}catch{return String($)}},_format($,J){if(typeof $!=="string"||!$)throw new Error("Logger._format: level must be a non-empty string");let Z=this._safeStringify(J);if(this.timestamps)return`[${new Date().toISOString()}] [${$}] ${Z}`;return`[${$}] ${Z}`},_bufferWrite($){if(!this.logToFile)return;if(this._buffer.push($),this._buffer.length>=QH)this.flush();if(!this._flushTimer)this._flushTimer=setInterval(()=>this.flush(),HH),this._flushTimer.unref()},flush(){if(!this.logToFile||this._buffer.length===0)return;try{let $=this._buffer.join(`
16
16
  `)+`
17
- `;A5.appendFileSync(this.logToFile,$),this._buffer=[]}catch{this._buffer=[]}},error($,...J){if(this.level<d6.ERROR)return;let Z=this._format("ERROR",$),K=J.length?" "+J.map((Q)=>this._safeStringify(Q)).join(" "):"";console.error(Z,...J),this._bufferWrite(Z+K),this.flush()},warn($,...J){if(this.level<d6.WARN)return;let Z=this._format("WARN",$),K=J.length?" "+J.map((Q)=>this._safeStringify(Q)).join(" "):"";console.warn(Z,...J),this._bufferWrite(Z+K)},info($,...J){if(this.level<d6.INFO)return;let Z=this._format("INFO",$),K=J.length?" "+J.map((Q)=>this._safeStringify(Q)).join(" "):"";console.log(Z,...J),this._bufferWrite(Z+K)},debug($,...J){if(this.level<d6.DEBUG)return;let Z=this._format("DEBUG",$),K=J.length?" "+J.map((Q)=>this._safeStringify(Q)).join(" "):"";console.log(Z,...J),this._bufferWrite(Z+K)},shutdown(){if(this._flushTimer)clearInterval(this._flushTimer),this._flushTimer=null;this.flush()}};var oQ=$7;k.set({precision:80});var _0=($)=>$ instanceof k?$:new k($),f5=20;function a7($,J=f5){if(typeof $!=="string")throw new Error("pathToPolygon: pathData must be a string");if(typeof J!=="number"||J<=0||!Number.isFinite(J))throw new Error(`pathToPolygon: samplesPerCurve must be a positive finite number, got ${J}`);let Z=[],K=_0(0),Q=_0(0),H=_0(0),z=_0(0),q=iQ($);if(!Array.isArray(q))throw new Error("pathToPolygon: parsePathCommands must return an array");for(let W of q){let{type:j,args:G}=W;if(!Array.isArray(G))throw new Error(`pathToPolygon: command args must be an array for command ${j}`);switch(j){case"M":if(G.length<2)throw new Error(`pathToPolygon: M command requires 2 arguments, got ${G.length}`);K=_0(G[0]),Q=_0(G[1]),H=K,z=Q,Z.push(b0(K,Q));break;case"m":if(G.length<2)throw new Error(`pathToPolygon: m command requires 2 arguments, got ${G.length}`);K=K.plus(G[0]),Q=Q.plus(G[1]),H=K,z=Q,Z.push(b0(K,Q));break;case"L":if(G.length<2)throw new Error(`pathToPolygon: L command requires 2 arguments, got ${G.length}`);K=_0(G[0]),Q=_0(G[1]),Z.push(b0(K,Q));break;case"l":if(G.length<2)throw new Error(`pathToPolygon: l command requires 2 arguments, got ${G.length}`);K=K.plus(G[0]),Q=Q.plus(G[1]),Z.push(b0(K,Q));break;case"H":if(G.length<1)throw new Error(`pathToPolygon: H command requires 1 argument, got ${G.length}`);K=_0(G[0]),Z.push(b0(K,Q));break;case"h":if(G.length<1)throw new Error(`pathToPolygon: h command requires 1 argument, got ${G.length}`);K=K.plus(G[0]),Z.push(b0(K,Q));break;case"V":if(G.length<1)throw new Error(`pathToPolygon: V command requires 1 argument, got ${G.length}`);Q=_0(G[0]),Z.push(b0(K,Q));break;case"v":if(G.length<1)throw new Error(`pathToPolygon: v command requires 1 argument, got ${G.length}`);Q=Q.plus(G[0]),Z.push(b0(K,Q));break;case"C":if(G.length<6)throw new Error(`pathToPolygon: C command requires 6 arguments, got ${G.length}`);E5(Z,K,Q,_0(G[0]),_0(G[1]),_0(G[2]),_0(G[3]),_0(G[4]),_0(G[5]),J),K=_0(G[4]),Q=_0(G[5]);break;case"c":if(G.length<6)throw new Error(`pathToPolygon: c command requires 6 arguments, got ${G.length}`);E5(Z,K,Q,K.plus(G[0]),Q.plus(G[1]),K.plus(G[2]),Q.plus(G[3]),K.plus(G[4]),Q.plus(G[5]),J),K=K.plus(G[4]),Q=Q.plus(G[5]);break;case"Q":if(G.length<4)throw new Error(`pathToPolygon: Q command requires 4 arguments, got ${G.length}`);T5(Z,K,Q,_0(G[0]),_0(G[1]),_0(G[2]),_0(G[3]),J),K=_0(G[2]),Q=_0(G[3]);break;case"q":if(G.length<4)throw new Error(`pathToPolygon: q command requires 4 arguments, got ${G.length}`);T5(Z,K,Q,K.plus(G[0]),Q.plus(G[1]),K.plus(G[2]),Q.plus(G[3]),J),K=K.plus(G[2]),Q=Q.plus(G[3]);break;case"A":if(G.length<7)throw new Error(`pathToPolygon: A command requires 7 arguments, got ${G.length}`);b5(Z,K,Q,_0(G[0]),_0(G[1]),_0(G[2]),G[3],G[4],_0(G[5]),_0(G[6]),J),K=_0(G[5]),Q=_0(G[6]);break;case"a":if(G.length<7)throw new Error(`pathToPolygon: a command requires 7 arguments, got ${G.length}`);b5(Z,K,Q,_0(G[0]),_0(G[1]),_0(G[2]),G[3],G[4],K.plus(G[5]),Q.plus(G[6]),J),K=K.plus(G[5]),Q=Q.plus(G[6]);break;case"Z":case"z":K=H,Q=z;break;default:break}}return rQ(Z)}function iQ($){if(typeof $!=="string")throw new Error(`parsePathCommands: pathData must be a string, got ${typeof $}`);let J=[],Z=/([MmLlHhVvCcSsQqTtAaZz])([^MmLlHhVvCcSsQqTtAaZz]*)/g,K;while((K=Z.exec($))!==null){let Q=K[1],H=K[2].trim(),z=/-?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/g,q=H.length>0?Array.from(H.matchAll(z),(W)=>Number(W[0])):[];J.push({type:Q,args:q})}return J}function E5($,J,Z,K,Q,H,z,q,W,j){if(!Array.isArray($))throw new Error("sampleCubicBezier: points must be an array");if(typeof j!=="number"||j<=0||!Number.isFinite(j))throw new Error(`sampleCubicBezier: samples must be a positive finite number, got ${j}`);if(!(J instanceof k)||!(Z instanceof k)||!(K instanceof k)||!(Q instanceof k)||!(H instanceof k)||!(z instanceof k)||!(q instanceof k)||!(W instanceof k))throw new Error("sampleCubicBezier: all coordinate parameters must be Decimal instances");for(let G=1;G<=j;G++){let F=_0(G).div(j),_=_0(1).minus(F),U=_.mul(_),O=U.mul(_),V=F.mul(F),M=V.mul(F),Y=O.mul(J).plus(_0(3).mul(U).mul(F).mul(K)).plus(_0(3).mul(_).mul(V).mul(H)).plus(M.mul(q)),X=O.mul(Z).plus(_0(3).mul(U).mul(F).mul(Q)).plus(_0(3).mul(_).mul(V).mul(z)).plus(M.mul(W));$.push(b0(Y,X))}}function T5($,J,Z,K,Q,H,z,q){if(!Array.isArray($))throw new Error("sampleQuadraticBezier: points must be an array");if(typeof q!=="number"||q<=0||!Number.isFinite(q))throw new Error(`sampleQuadraticBezier: samples must be a positive finite number, got ${q}`);if(!(J instanceof k)||!(Z instanceof k)||!(K instanceof k)||!(Q instanceof k)||!(H instanceof k)||!(z instanceof k))throw new Error("sampleQuadraticBezier: all coordinate parameters must be Decimal instances");for(let W=1;W<=q;W++){let j=_0(W).div(q),G=_0(1).minus(j),F=G.mul(G),_=j.mul(j),U=F.mul(J).plus(_0(2).mul(G).mul(j).mul(K)).plus(_.mul(H)),O=F.mul(Z).plus(_0(2).mul(G).mul(j).mul(Q)).plus(_.mul(z));$.push(b0(U,O))}}function b5($,J,Z,K,Q,H,z,q,W,j,G){if(!Array.isArray($))throw new Error("sampleArc: points must be an array");if(typeof G!=="number"||G<=0||!Number.isFinite(G))throw new Error(`sampleArc: samples must be a positive finite number, got ${G}`);if(!(J instanceof k)||!(Z instanceof k)||!(K instanceof k)||!(Q instanceof k)||!(H instanceof k)||!(W instanceof k)||!(j instanceof k))throw new Error("sampleArc: all coordinate and angle parameters must be Decimal instances");if(typeof z!=="number"||z!==0&&z!==1)throw new Error(`sampleArc: largeArc must be 0 or 1, got ${z}`);if(typeof q!=="number"||q!==0&&q!==1)throw new Error(`sampleArc: sweep must be 0 or 1, got ${q}`);if(K.eq(0)||Q.eq(0)){$.push(b0(W,j));return}let F=K.abs(),_=Q.abs(),U=H.mul(Math.PI).div(180),O=U.cos(),V=U.sin(),M=J.minus(W).div(2),Y=Z.minus(j).div(2),X=O.mul(M).plus(V.mul(Y)),w=O.mul(Y).minus(V.mul(M)),R=F.mul(F),I=_.mul(_),b=X.mul(X),u=w.mul(w),m=b.div(R).plus(u.div(I));if(m.gt(1)){let $0=m.sqrt();F=F.mul($0),_=_.mul($0),R=F.mul(F),I=_.mul(_)}let S=R.mul(I).minus(R.mul(u)).minus(I.mul(b));if(S=S.div(R.mul(u).plus(I.mul(b))),S.lt(0))S=_0(0);if(S=S.sqrt(),z===q)S=S.neg();let x=S.mul(K).mul(w).div(Q),h=S.neg().mul(Q).mul(X).div(K),E=J.plus(W).div(2),d=Z.plus(j).div(2),c=O.mul(x).minus(V.mul(h)).plus(E),p=V.mul(x).plus(O.mul(h)).plus(d),N=X.minus(x).div(K),y=w.minus(h).div(Q),B=X.neg().minus(x).div(K),e=w.neg().minus(h).div(Q),r=N.mul(N).plus(y.mul(y)).sqrt();if(r.eq(0)){D9.warn("sampleArc: degenerate arc - center coincides with start point, treating as line to end"),$.push(b0(W,j));return}let s=k.acos(N.div(r));if(y.lt(0))s=s.neg();let z0=r.mul(B.mul(B).plus(e.mul(e)).sqrt());if(z0.eq(0)){D9.warn("sampleArc: degenerate arc - zero length, treating as single point"),$.push(b0(W,j));return}let T=k.acos(N.mul(B).plus(y.mul(e)).div(z0));if(N.mul(e).minus(y.mul(B)).lt(0))T=T.neg();let P=_0(Math.PI),t=P.mul(2);if(q&&T.lt(0))T=T.plus(t);else if(!q&&T.gt(0))T=T.minus(t);for(let $0=1;$0<=G;$0++){let Q0=_0($0).div(G),U0=s.plus(T.mul(Q0)),N0=U0.cos(),h0=U0.sin(),o=O.mul(K.mul(N0)).minus(V.mul(Q.mul(h0))).plus(c),J0=V.mul(K.mul(N0)).plus(O.mul(Q.mul(h0))).plus(p);$.push(b0(o,J0))}}function rQ($){if(!Array.isArray($))throw new Error("removeDuplicateConsecutive: points must be an array");if($.length<2)return $;let J=[$[0]];for(let Z=1;Z<$.length;Z++)if(!v7($[Z],J[J.length-1]))J.push($[Z]);return J}function X6($,J=null,Z=f5,K=4){if(!$||typeof $!=="object")throw new Error("shapeToPolygon: element must be an object");if(!$.type||typeof $.type!=="string")throw new Error("shapeToPolygon: element.type must be a string");if(typeof Z!=="number"||Z<=0||!Number.isFinite(Z))throw new Error(`shapeToPolygon: samples must be a positive finite number, got ${Z}`);if(typeof K!=="number"||K<=0||!Number.isFinite(K))throw new Error(`shapeToPolygon: bezierArcs must be a positive finite number, got ${K}`);if(J!==null&&!(J instanceof M0))throw new Error("shapeToPolygon: ctm must be null or a Matrix instance");let Q;switch($.type){case"circle":if(K>4)Q=Z5($.cx||0,$.cy||0,$.r||0,K,10);else Q=W5(_0($.cx||0),_0($.cy||0),_0($.r||0));break;case"ellipse":if(K>4)Q=Y9($.cx||0,$.cy||0,$.rx||0,$.ry||0,K,10);else Q=I9(_0($.cx||0),_0($.cy||0),_0($.rx||0),_0($.ry||0));break;case"rect":Q=j5(_0($.x||0),_0($.y||0),_0($.width||0),_0($.height||0),_0($.rx||0),$.ry!==void 0?_0($.ry):null);break;case"line":Q=G5(_0($.x1||0),_0($.y1||0),_0($.x2||0),_0($.y2||0));break;case"polygon":Q=F5($.points||"");break;case"polyline":Q=_5($.points||"");break;case"path":Q=$.d||"";break;default:return[]}if($.transform){let H=oQ($.transform);if(!(H instanceof M0))throw new Error(`shapeToPolygon: parseTransform must return a Matrix, got ${typeof H}`);Q=Y6(Q,H)}if(J)Q=Y6(Q,J);return a7(Q,Z)}function h9($,J=6){if(!Array.isArray($))throw new Error("polygonToPathData: polygon must be an array");if(typeof J!=="number"||J<0||!Number.isFinite(J))throw new Error(`polygonToPathData: precision must be a non-negative finite number, got ${J}`);if($.length<2)return"";let Z=(Q)=>(Q instanceof k?Q:_0(Q)).toFixed(J).replace(/\.?0+$/,""),K=`M ${Z($[0].x)} ${Z($[0].y)}`;for(let Q=1;Q<$.length;Q++)K+=` L ${Z($[Q].x)} ${Z($[Q].y)}`;return K+" Z"}k.set({precision:80});k.set({precision:80});var S5=($)=>$ instanceof k?$:new k($),v5=-0.1,D5=-0.1,h5=1.2,y5=1.2,A$={LUMINANCE:"luminance",ALPHA:"alpha"};function u5($){if(!$)throw new Error("parseMaskElement: maskElement is required");if(!$.getAttribute)throw new Error("parseMaskElement: maskElement must be a DOM element");let J={id:$.getAttribute("id")||"",maskUnits:$.getAttribute("maskUnits")||"objectBoundingBox",maskContentUnits:$.getAttribute("maskContentUnits")||"userSpaceOnUse",maskType:$.getAttribute("mask-type")||$.style?.maskType||"luminance",x:$.getAttribute("x"),y:$.getAttribute("y"),width:$.getAttribute("width"),height:$.getAttribute("height"),transform:$.getAttribute("transform")||null,children:[]},Z=(K,Q)=>{let H=parseFloat(K);return isNaN(H)?Q:H};if(J.maskUnits==="objectBoundingBox")J.x=J.x!==null?Z(J.x,v5):v5,J.y=J.y!==null?Z(J.y,D5):D5,J.width=J.width!==null?Z(J.width,h5):h5,J.height=J.height!==null?Z(J.height,y5):y5;else J.x=J.x!==null?Z(J.x,null):null,J.y=J.y!==null?Z(J.y,null):null,J.width=J.width!==null?Z(J.width,null):null,J.height=J.height!==null?Z(J.height,null):null;if(!$.children)return J;for(let K of $.children){if(!K.tagName)continue;let Q=K.tagName.toLowerCase(),H={type:Q,fill:K.getAttribute("fill")||K.style?.fill||"black",fillOpacity:Z(K.getAttribute("fill-opacity")||K.style?.fillOpacity||"1",1),opacity:Z(K.getAttribute("opacity")||K.style?.opacity||"1",1),transform:K.getAttribute("transform")||null};switch(Q){case"rect":H.x=Z(K.getAttribute("x")||"0",0),H.y=Z(K.getAttribute("y")||"0",0),H.width=Z(K.getAttribute("width")||"0",0),H.height=Z(K.getAttribute("height")||"0",0),H.rx=Z(K.getAttribute("rx")||"0",0),H.ry=Z(K.getAttribute("ry")||"0",0);break;case"circle":H.cx=Z(K.getAttribute("cx")||"0",0),H.cy=Z(K.getAttribute("cy")||"0",0),H.r=Z(K.getAttribute("r")||"0",0);break;case"ellipse":H.cx=Z(K.getAttribute("cx")||"0",0),H.cy=Z(K.getAttribute("cy")||"0",0),H.rx=Z(K.getAttribute("rx")||"0",0),H.ry=Z(K.getAttribute("ry")||"0",0);break;case"path":H.d=K.getAttribute("d")||"";break;case"polygon":H.points=K.getAttribute("points")||"";break;case"polyline":H.points=K.getAttribute("points")||"";break;case"g":if(H.children=[],K.children){for(let z of K.children)if(z.tagName)H.children.push({type:z.tagName.toLowerCase(),fill:z.getAttribute("fill")||"inherit"})}break;default:break}J.children.push(H)}return J}function tQ($,J,Z,K=20){if(!$)throw new Error("maskChildToPolygon: child is required");if(!J)throw new Error("maskChildToPolygon: targetBBox is required");if(!Z)throw new Error("maskChildToPolygon: contentUnits is required");if(typeof K!=="number"||K<=0)throw new Error("maskChildToPolygon: samples must be a positive number");if(typeof J.x!=="number"||typeof J.y!=="number"||typeof J.width!=="number"||typeof J.height!=="number")throw new Error("maskChildToPolygon: targetBBox must have numeric x, y, width, height properties");if(J.width<0||J.height<0)throw new Error("maskChildToPolygon: targetBBox width and height cannot be negative");let Q={type:$.type,...$,transform:$.transform},H=X6(Q,null,K);if(!Array.isArray(H))return[];if(Z==="objectBoundingBox"&&H.length>0){if(J.width===0||J.height===0)return[];H=H.map((z)=>({x:S5(J.x).plus(z.x.mul(J.width)),y:S5(J.y).plus(z.y.mul(J.height))}))}return H}function eQ($){if(!$||$==="none"||$==="transparent")return 0;if(typeof $!=="string")return 0;let J=$.match(/rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i);if(J){let H=parseInt(J[1],10),z=parseInt(J[2],10),q=parseInt(J[3],10);if(isNaN(H)||isNaN(z)||isNaN(q))return 0;let W=Math.max(0,Math.min(255,H))/255,j=Math.max(0,Math.min(255,z))/255,G=Math.max(0,Math.min(255,q))/255,F=0.2126*W+0.7152*j+0.0722*G;return isNaN(F)?0:F}let Z=$.match(/^#([0-9a-f]{3,6})$/i);if(Z){let H=Z[1];if(H.length===3)H=H[0]+H[0]+H[1]+H[1]+H[2]+H[2];let z=parseInt(H.slice(0,2),16),q=parseInt(H.slice(2,4),16),W=parseInt(H.slice(4,6),16);if(isNaN(z)||isNaN(q)||isNaN(W))return 0;let j=0.2126*(z/255)+0.7152*(q/255)+0.0722*(W/255);return isNaN(j)?0:j}let K={white:1,black:0,red:0.2126,green:0.7152,blue:0.0722,yellow:0.9278,cyan:0.7874,magenta:0.2848,gray:0.5,grey:0.5},Q=$.toLowerCase();if(K[Q]!==void 0)return K[Q];return 0}function $H($,J){if(!$)throw new Error("getMaskChildOpacity: child is required");if(!J)throw new Error("getMaskChildOpacity: maskType is required");if(J!==A$.LUMINANCE&&J!==A$.ALPHA)throw new Error('getMaskChildOpacity: maskType must be "luminance" or "alpha"');let Z=typeof $.fillOpacity==="number"&&!isNaN($.fillOpacity)?$.fillOpacity:1,K=typeof $.opacity==="number"&&!isNaN($.opacity)?$.opacity:1,Q=Z*K;if(J===A$.ALPHA)return Q;let H=eQ($.fill),z=Q*H;return isNaN(z)?0:z}function JH($,J,Z={}){if(!$)throw new Error("resolveMask: maskData is required");if(!J)throw new Error("resolveMask: targetBBox is required");if(!Array.isArray($.children))throw new Error("resolveMask: maskData.children must be an array");let{samples:K=20}=Z;if(typeof K!=="number"||K<=0)throw new Error("resolveMask: samples must be a positive number");let Q=$.maskType||A$.LUMINANCE,H=[];for(let z of $.children){if(!z)continue;let q=tQ(z,J,$.maskContentUnits,K);if(q.length>=3){let W=$H(z,Q);H.push({polygon:q,opacity:W})}}return H}function KH($,J,Z=0.5,K={}){if(!$)throw new Error("maskToClipPath: maskData is required");if(!J)throw new Error("maskToClipPath: targetBBox is required");if(typeof Z!=="number"||Z<0||Z>1)throw new Error("maskToClipPath: opacityThreshold must be a number between 0 and 1");let Q=JH($,J,K),H=[];for(let{polygon:z,opacity:q}of Q)if(q>=Z&&z&&z.length>=3)if(H.length===0)H=z;else{let W=z6(H,z);if(W.length>0&&W[0].length>=3)H=W[0]}return H}function g5($,J,Z={}){if(!$)throw new Error("maskToPathData: maskData is required");if(!J)throw new Error("maskToPathData: targetBBox is required");let K=KH($,J,0.5,Z);if(K.length<3)return"";let Q="",H=0;for(let z=0;z<K.length;z++){let q=K[z];if(!q||q.x===void 0||q.y===void 0)continue;let W=Number(q.x),j=Number(q.y);if(isNaN(W)||isNaN(j)||!isFinite(W)||!isFinite(j))continue;let G=W.toFixed(6),F=j.toFixed(6);Q+=H===0?`M ${G} ${F}`:` L ${G} ${F}`,H++}if(H>=3)Q+=" Z";else return"";return Q}k.set({precision:80});function x5($){if(!$)throw new Error("parseUseElement: useElement is required");let J=$.getAttribute("href")||$.getAttribute("xlink:href")||"",Z=J.startsWith("#")?J.slice(1):J;if(!Z)throw new Error("parseUseElement: href attribute must reference a valid element id (found empty reference)");let K=parseFloat($.getAttribute("x")||"0"),Q=parseFloat($.getAttribute("y")||"0");if(isNaN(K)||isNaN(Q)||!isFinite(K)||!isFinite(Q))throw new Error("parseUseElement: x and y attributes must be valid finite numbers");let H=null,z=null;if($.getAttribute("width")){if(H=parseFloat($.getAttribute("width")),isNaN(H)||!isFinite(H)||H<=0)throw new Error("parseUseElement: width attribute must be a valid positive finite number")}if($.getAttribute("height")){if(z=parseFloat($.getAttribute("height")),isNaN(z)||!isFinite(z)||z<=0)throw new Error("parseUseElement: height attribute must be a valid positive finite number")}return{href:Z,x:K,y:Q,width:H,height:z,transform:$.getAttribute("transform")||null,style:d5($)}}function m5($){if(!$)throw new Error("parseSymbolElement: symbolElement is required");let J=parseFloat($.getAttribute("refX")||"0"),Z=parseFloat($.getAttribute("refY")||"0");if(isNaN(J)||isNaN(Z)||!isFinite(J)||!isFinite(Z))throw new Error("parseSymbolElement: refX and refY must be valid finite numbers");let K={id:$.getAttribute("id")||"",viewBox:$.getAttribute("viewBox")||null,preserveAspectRatio:$.getAttribute("preserveAspectRatio")||"xMidYMid meet",children:[],refX:J,refY:Z};if(K.viewBox){let Q=K.viewBox.trim().split(/[\s,]+/).map(Number);if(Q.length===4&&Q.every((H)=>!isNaN(H)&&isFinite(H)))K.viewBoxParsed={x:Q[0],y:Q[1],width:Q[2],height:Q[3]}}for(let Q of $.children)K.children.push(E$(Q));return K}function E$($){if(!$||!$.tagName)throw new Error("parseChildElement: element with tagName is required");let J=$.tagName.toLowerCase(),Z={type:J,id:$.getAttribute("id")||null,transform:$.getAttribute("transform")||null,style:d5($)},K=(Q,H="0")=>{let z=parseFloat($.getAttribute(Q)||H);if(isNaN(z)||!isFinite(z))throw new Error(`parseChildElement: ${Q} must be a valid finite number in ${J} element`);return z};switch(J){case"rect":Z.x=K("x"),Z.y=K("y"),Z.width=K("width"),Z.height=K("height"),Z.rx=K("rx"),Z.ry=K("ry");break;case"circle":Z.cx=K("cx"),Z.cy=K("cy"),Z.r=K("r");break;case"ellipse":Z.cx=K("cx"),Z.cy=K("cy"),Z.rx=K("rx"),Z.ry=K("ry");break;case"path":Z.d=$.getAttribute("d")||"";break;case"polygon":Z.points=$.getAttribute("points")||"";break;case"polyline":Z.points=$.getAttribute("points")||"";break;case"line":Z.x1=K("x1"),Z.y1=K("y1"),Z.x2=K("x2"),Z.y2=K("y2");break;case"g":Z.children=[];for(let Q of $.children)Z.children.push(E$(Q));break;case"use":Z.href=($.getAttribute("href")||$.getAttribute("xlink:href")||"").replace("#",""),Z.x=K("x"),Z.y=K("y"),Z.width=$.getAttribute("width")?K("width"):null,Z.height=$.getAttribute("height")?K("height"):null;break;default:break}return Z}function d5($){if(!$)throw new Error("extractStyleAttributes: element is required");return{fill:$.getAttribute("fill"),stroke:$.getAttribute("stroke"),strokeWidth:$.getAttribute("stroke-width"),opacity:$.getAttribute("opacity"),fillOpacity:$.getAttribute("fill-opacity"),strokeOpacity:$.getAttribute("stroke-opacity"),visibility:$.getAttribute("visibility"),display:$.getAttribute("display")}}function QH($,J,Z,K="xMidYMid meet"){if(!$||!J||!Z)return M0.identity(3);if(!isFinite(J)||!isFinite(Z)||J<=0||Z<=0)return M0.identity(3);let{width:Q,height:H,x:z,y:q}=$;if(!isFinite(Q)||!isFinite(H)||!isFinite(z)||!isFinite(q)||Q<=0||H<=0)return M0.identity(3);let W=K.trim().split(/\s+/),j=W[0]||"xMidYMid",G=W[1]||"meet";if(j==="none"){let X=J/Q,w=Z/H;return o0(-z*X,-q*w).mul(M7(X,w))}let F=J/Q,_=Z/H,U;if(G==="slice")U=Math.max(F,_);else U=Math.min(F,_);let O=-z*U,V=-q*U,M=Q*U,Y=H*U;if(j.includes("xMid"))O+=(J-M)/2;else if(j.includes("xMax"))O+=J-M;if(j.includes("YMid"))V+=(Z-Y)/2;else if(j.includes("YMax"))V+=Z-Y;return o0(O,V).mul(M7(U,U))}function y9($,J,Z={}){if(!$||!$.href)throw new Error("resolveUse: useData with href property is required");if(!J)throw new Error("resolveUse: defs map is required");if(typeof $.x!=="number"||isNaN($.x)||!isFinite($.x))throw new Error("resolveUse: useData.x must be a valid finite number");if(typeof $.y!=="number"||isNaN($.y)||!isFinite($.y))throw new Error("resolveUse: useData.y must be a valid finite number");if($.width!==null&&(typeof $.width!=="number"||isNaN($.width)||!isFinite($.width)||$.width<=0))throw new Error("resolveUse: useData.width must be null or a positive finite number");if($.height!==null&&(typeof $.height!=="number"||isNaN($.height)||!isFinite($.height)||$.height<=0))throw new Error("resolveUse: useData.height must be null or a positive finite number");if($.style!==null&&$.style!==void 0){if(typeof $.style!=="object"||Array.isArray($.style))throw new Error("resolveUse: useData.style must be null, undefined, or a valid non-array object")}if($.transform!==null&&$.transform!==void 0&&typeof $.transform!=="string")throw new Error("resolveUse: useData.transform must be null, undefined, or a string");if(Z&&typeof Z!=="object")throw new Error("resolveUse: options must be an object or undefined");let{maxDepth:K=10,_visited:Q=new Set}=Z;if(typeof K!=="number"||K<=0||!isFinite(K))throw new Error("resolveUse: maxDepth must be a positive finite number");if(Q.has($.href))return console.warn(`resolveUse: circular reference detected for '#${$.href}', skipping to prevent infinite loop`),null;let H=J[$.href];if(!H)return console.warn(`resolveUse: target element '#${$.href}' not found in defs map`),null;Q.add($.href);let z=o0($.x,$.y);if($.transform){let j=$7($.transform);z=z.mul(j)}if(H.type==="symbol"&&H.viewBoxParsed){if(typeof H.viewBoxParsed.x!=="number"||typeof H.viewBoxParsed.y!=="number"||typeof H.viewBoxParsed.width!=="number"||typeof H.viewBoxParsed.height!=="number"||!isFinite(H.viewBoxParsed.x)||!isFinite(H.viewBoxParsed.y)||!isFinite(H.viewBoxParsed.width)||!isFinite(H.viewBoxParsed.height)||H.viewBoxParsed.width<=0||H.viewBoxParsed.height<=0)throw new Error("resolveUse: target.viewBoxParsed must have finite x, y and positive finite width, height");let j=$.width!==null?$.width:H.viewBoxParsed.width,G=$.height!==null?$.height:H.viewBoxParsed.height;z=QH(H.viewBoxParsed,j,G,H.preserveAspectRatio||"xMidYMid meet").mul(z)}let q=[],W=H.children&&Array.isArray(H.children)&&H.children.length>0?H.children:[H];for(let j of W)if(j.type==="use"){if(K<=1){console.warn(`resolveUse: maximum nesting depth reached for use element '#${j.href}', skipping nested resolution`);continue}let G=y9(j,J,{maxDepth:K-1,_visited:Q});if(G)q.push(G)}else q.push({element:j,transform:M0.identity(3)});return Q.delete($.href),{element:H,transform:z,children:q,inheritedStyle:$.style}}function p5($,J=20){let Z=[];if(!$)return Z;if(typeof J!=="number"||J<=0||!isFinite(J))throw new Error("flattenResolvedUse: samples must be a positive finite number");if(!$.children||!$.transform)return Z;for(let K of $.children){if(!K||!K.transform)continue;let Q=$.transform.mul(K.transform),H=K.element;if(K.children){let z=p5(K,J);for(let q of z)q.polygon=q.polygon.map((W)=>{let[j,G]=c0($.transform,W.x,W.y);return{x:j,y:G}}),Z.push(q)}else{let z=HH(H,Q,J);if(z.length>=3)Z.push({polygon:z,style:zH($.inheritedStyle,H.style)})}}return Z}function HH($,J,Z=20){if(!$)throw new Error("elementToPolygon: element is required");if(typeof Z!=="number"||Z<=0||!isFinite(Z))throw new Error("elementToPolygon: samples must be a positive finite number");let K=X6($,null,Z);if(J&&K.length>0)K=K.map((Q)=>{let[H,z]=c0(J,Q.x,Q.y);return{x:H,y:z}});return K}function zH($,J){if(!J||typeof J!=="object"||Array.isArray(J))throw new Error("mergeStyles: element must be a valid non-array object");let Z={...J};if($!==null&&$!==void 0){if(typeof $!=="object"||Array.isArray($))throw new Error("mergeStyles: inherited must be null, undefined, or a valid non-array object")}for(let[K,Q]of Object.entries($||{}))if(Q!==null&&(Z[K]===null||Z[K]===void 0))Z[K]=Q;return Z}function c5($,J=20){if(typeof J!=="number"||J<=0||!isFinite(J))throw new Error("resolvedUseToPathData: samples must be a positive finite number");let Z=p5($,J),K=[];for(let{polygon:Q}of Z)if(Q.length>=3){let H="";for(let z=0;z<Q.length;z++){let q=Q[z],W=Number(q.x),j=Number(q.y);if(isNaN(W)||isNaN(j))continue;H+=z===0?`M ${W.toFixed(6)} ${j.toFixed(6)}`:` L ${W.toFixed(6)} ${j.toFixed(6)}`}H+=" Z",K.push(H)}return K.join(" ")}k.set({precision:80});var Z7=($)=>$ instanceof k?$:new k($);function l5($){if(!$)throw new Error("parsePatternElement: patternElement is required");if(typeof $.getAttribute!=="function")throw new Error("parsePatternElement: patternElement must be a DOM element with getAttribute method");let J={id:$.getAttribute("id")||"",patternUnits:$.getAttribute("patternUnits")||"objectBoundingBox",patternContentUnits:$.getAttribute("patternContentUnits")||"userSpaceOnUse",patternTransform:$.getAttribute("patternTransform")||null,x:$.getAttribute("x"),y:$.getAttribute("y"),width:$.getAttribute("width"),height:$.getAttribute("height"),viewBox:$.getAttribute("viewBox")||null,preserveAspectRatio:$.getAttribute("preserveAspectRatio")||"xMidYMid meet",href:$.getAttribute("href")||$.getAttribute("xlink:href")||null,children:[]},Z=(K,Q)=>{if(K===null||K===void 0)return Q;let H=parseFloat(K);return isNaN(H)?Q:H};if(J.x=Z(J.x,0),J.y=Z(J.y,0),J.width=Z(J.width,0),J.height=Z(J.height,0),J.viewBox){let K=J.viewBox.trim().split(/[\s,]+/).map(Number);if(K.length===4&&K.every((Q)=>!isNaN(Q)&&isFinite(Q)))J.viewBoxParsed={x:K[0],y:K[1],width:K[2],height:K[3]}}if($.children&&typeof $.children[Symbol.iterator]==="function")for(let K of $.children){if(!K||typeof K.getAttribute!=="function")continue;let Q=K.tagName?K.tagName.toLowerCase():"";if(!Q)continue;let H={type:Q,fill:K.getAttribute("fill")||"black",stroke:K.getAttribute("stroke")||"none",strokeWidth:Z(K.getAttribute("stroke-width"),1),opacity:Z(K.getAttribute("opacity"),1),transform:K.getAttribute("transform")||null};switch(Q){case"rect":H.x=Z(K.getAttribute("x"),0),H.y=Z(K.getAttribute("y"),0),H.width=Z(K.getAttribute("width"),0),H.height=Z(K.getAttribute("height"),0),H.rx=Z(K.getAttribute("rx"),0),H.ry=Z(K.getAttribute("ry"),0);break;case"circle":H.cx=Z(K.getAttribute("cx"),0),H.cy=Z(K.getAttribute("cy"),0),H.r=Z(K.getAttribute("r"),0);break;case"ellipse":H.cx=Z(K.getAttribute("cx"),0),H.cy=Z(K.getAttribute("cy"),0),H.rx=Z(K.getAttribute("rx"),0),H.ry=Z(K.getAttribute("ry"),0);break;case"path":H.d=K.getAttribute("d")||"";break;case"polygon":H.points=K.getAttribute("points")||"";break;case"polyline":H.points=K.getAttribute("points")||"";break;case"line":H.x1=Z(K.getAttribute("x1"),0),H.y1=Z(K.getAttribute("y1"),0),H.x2=Z(K.getAttribute("x2"),0),H.y2=Z(K.getAttribute("y2"),0);break;case"use":H.href=K.getAttribute("href")||K.getAttribute("xlink:href")||"",H.x=Z(K.getAttribute("x"),0),H.y=Z(K.getAttribute("y"),0);break;case"g":if(H.children=[],K.children&&typeof K.children[Symbol.iterator]==="function"){for(let z of K.children)if(z&&z.tagName&&typeof z.getAttribute==="function")H.children.push({type:z.tagName.toLowerCase(),fill:z.getAttribute("fill")||"inherit"})}break;default:break}J.children.push(H)}return J}function WH($,J){if(!$)throw new Error("getPatternTile: patternData is required");if(!J)throw new Error("getPatternTile: targetBBox is required");if(typeof J.x!=="number"||typeof J.y!=="number"||typeof J.width!=="number"||typeof J.height!=="number")throw new Error("getPatternTile: targetBBox must have numeric x, y, width, and height properties");if(typeof $.x!=="number"||typeof $.y!=="number"||typeof $.width!=="number"||typeof $.height!=="number")throw new Error("getPatternTile: patternData must have numeric x, y, width, and height properties");if($.patternUnits==="objectBoundingBox")return{x:Z7(J.x).plus(Z7($.x).mul(J.width)),y:Z7(J.y).plus(Z7($.y).mul(J.height)),width:Z7($.width).mul(J.width),height:Z7($.height).mul(J.height)};return{x:Z7($.x),y:Z7($.y),width:Z7($.width),height:Z7($.height)}}function jH($,J,Z){if(!$)throw new Error("getPatternContentTransform: patternData is required");if(!J)throw new Error("getPatternContentTransform: tile is required");if(!Z)throw new Error("getPatternContentTransform: targetBBox is required");if(!J.width||!J.height)throw new Error("getPatternContentTransform: tile must have width and height properties");if(typeof Z.x!=="number"||typeof Z.y!=="number"||typeof Z.width!=="number"||typeof Z.height!=="number")throw new Error("getPatternContentTransform: targetBBox must have numeric x, y, width, and height properties");let K=M0.identity(3);if($.viewBoxParsed){let Q=$.viewBoxParsed;if(typeof Q.x!=="number"||typeof Q.y!=="number"||typeof Q.width!=="number"||typeof Q.height!=="number")throw new Error("getPatternContentTransform: viewBoxParsed must have numeric x, y, width, and height properties");let H=Number(J.width),z=Number(J.height);if(H===0||z===0)throw new Error("getPatternContentTransform: tile width and height must be non-zero when viewBox is present");if(Q.width===0||Q.height===0)throw new Error("getPatternContentTransform: viewBox width and height must be non-zero");let q=H/Q.width,W=z/Q.height,j=Math.min(q,W);if(!isFinite(j))throw new Error("getPatternContentTransform: computed scale is not finite");let G=(H-Q.width*j)/2,F=(z-Q.height*j)/2;K=K.mul(o0(G-Q.x*j,F-Q.y*j)),K=K.mul(M7(j,j))}if($.patternContentUnits==="objectBoundingBox"){if(Z.width===0||Z.height===0)throw new Error("getPatternContentTransform: targetBBox width and height must be non-zero when patternContentUnits is objectBoundingBox");K=K.mul(o0(Z.x,Z.y)),K=K.mul(M7(Z.width,Z.height))}return K}function GH($,J=null,Z=20){if(!$)throw new Error("patternChildToPolygon: child is required");if(!$.type)throw new Error("patternChildToPolygon: child must have a type property");if(typeof Z!=="number"||Z<=0||!isFinite(Z))throw new Error("patternChildToPolygon: samples must be a positive finite number");let K={type:$.type,...$,transform:$.transform},Q=X6(K,null,Z);if(!Array.isArray(Q))return[];if(J&&Q.length>0)Q=Q.map((H)=>{if(!H||typeof H.x!=="number"||typeof H.y!=="number")throw new Error("patternChildToPolygon: invalid polygon point - must have numeric x and y properties");let[z,q]=c0(J,H.x,H.y);return{x:z,y:q}});return Q}function FH($,J){if(!$)throw new Error("getTilePositions: tile is required");if(!J)throw new Error("getTilePositions: coverBBox is required");if(!("x"in $)||!("y"in $)||!("width"in $)||!("height"in $))throw new Error("getTilePositions: tile must have x, y, width, and height properties");if(typeof J.x!=="number"||typeof J.y!=="number"||typeof J.width!=="number"||typeof J.height!=="number")throw new Error("getTilePositions: coverBBox must have numeric x, y, width, and height properties");let Z=[],K=Number($.x),Q=Number($.y),H=Number($.width),z=Number($.height);if(!isFinite(K)||!isFinite(Q)||!isFinite(H)||!isFinite(z))throw new Error("getTilePositions: tile dimensions must be finite numbers");if(H<=0||z<=0)return Z;let q=Math.floor((J.x-K)/H),W=Math.ceil((J.x+J.width-K)/H),j=Math.floor((J.y-Q)/z),G=Math.ceil((J.y+J.height-Q)/z);if(!isFinite(q)||!isFinite(W)||!isFinite(j)||!isFinite(G))throw new Error("getTilePositions: computed tile indices are not finite");for(let F=q;F<W;F++)for(let _=j;_<G;_++)Z.push({x:Z7(K).plus(Z7(H).mul(F)),y:Z7(Q).plus(Z7(z).mul(_))});return Z}function _H($,J,Z={}){if(!$)throw new Error("resolvePattern: patternData is required");if(!J)throw new Error("resolvePattern: targetBBox is required");if(!Array.isArray($.children))throw new Error("resolvePattern: patternData.children must be an array");let{samples:K=20,maxTiles:Q=1000}=Z,H=[],z=WH($,J);if(Number(z.width)<=0||Number(z.height)<=0)return H;let q=jH($,z,J),W=VH($.patternTransform),G=FH(z,J).slice(0,Q);for(let F of G){let _=o0(F.x,F.y);for(let U of $.children){let O=W.mul(_.mul(q)),V=GH(U,O,K);if(V.length>=3)H.push({polygon:V,fill:U.fill,stroke:U.stroke,strokeWidth:U.strokeWidth,opacity:U.opacity})}}return H}function UH($,J,Z={}){if(!$)throw new Error("patternToClipPath: patternData is required");if(!J)throw new Error("patternToClipPath: targetBBox is required");let K=_H($,J,Z),Q=[];for(let{polygon:H,opacity:z}of K)if(z>0&&H.length>=3)if(Q.length===0)Q=H;else{let q=z6(Q,H);if(Array.isArray(q)&&q.length>0&&Array.isArray(q[0])&&q[0].length>=3)Q=q[0]}return Q}function n5($,J,Z={}){if(!$)throw new Error("patternToPathData: patternData is required");if(!J)throw new Error("patternToPathData: targetBBox is required");let K=UH($,J,Z);if(!Array.isArray(K))return"";if(K.length<3)return"";let Q="";for(let H=0;H<K.length;H++){let z=K[H];if(!z||typeof z.x!=="number"||typeof z.y!=="number")throw new Error("patternToPathData: invalid polygon point - must have numeric x and y properties");if(!isFinite(z.x)||!isFinite(z.y))throw new Error("patternToPathData: polygon point coordinates must be finite numbers");let q=Number(z.x).toFixed(6),W=Number(z.y).toFixed(6);Q+=H===0?`M ${q} ${W}`:` L ${q} ${W}`}return Q+=" Z",Q}function VH($){if(!$)return M0.identity(3);return $7($)}k.set({precision:80});function u9($,J,Z,K=1,Q=!1){if(!$)throw new Error("getMarkerTransform: markerDef is required");if(!J||typeof J.x!=="number"||typeof J.y!=="number")throw new Error("getMarkerTransform: position must be an object with x and y numeric properties");if(typeof Z!=="number"||isNaN(Z)||!isFinite(Z))throw new Error("getMarkerTransform: tangentAngle must be a valid finite number");if(typeof K!=="number"||isNaN(K)||K<=0)throw new Error("getMarkerTransform: strokeWidth must be a positive number");let{markerWidth:H,markerHeight:z,refX:q,refY:W,orient:j,markerUnits:G,viewBox:F}=$;if(typeof H!=="number"||H<=0)throw new Error("getMarkerTransform: markerDef.markerWidth must be a positive number");if(typeof z!=="number"||z<=0)throw new Error("getMarkerTransform: markerDef.markerHeight must be a positive number");if(typeof q!=="number"||!isFinite(q))throw new Error("getMarkerTransform: markerDef.refX must be a finite number");if(typeof W!=="number"||!isFinite(W))throw new Error("getMarkerTransform: markerDef.refY must be a finite number");let _=M0.identity(3),U=o0(J.x,J.y);_=_.mul(U);let O=0;if(j==="auto")O=Z;else if(j==="auto-start-reverse")O=Q?Z+Math.PI:Z;else if(typeof j==="number")O=j*(Math.PI/180);if(O!==0){let w=O6(O);_=_.mul(w)}let V=1,M=1;if(G==="strokeWidth")V=K,M=K;let Y=!1,X=1;if(F){let{width:w,height:R}=F;if(w>0&&R>0&&isFinite(w)&&isFinite(R)){let I=H/w,b=z/R;if(isFinite(I)&&isFinite(b))X=Math.min(I,b),Y=!0,V*=X,M*=X}}if(Y){let w=(q-F.x)*X,R=(W-F.y)*X,I=o0(-w,-R);if(_=_.mul(I),V!==1||M!==1){let u=M7(V,M);_=_.mul(u)}let b=o0(-F.x,-F.y);_=_.mul(b)}else{if(V!==1||M!==1){let R=M7(V,M);_=_.mul(R)}let w=o0(-q,-W);_=_.mul(w)}return _}function OH($){if(typeof $!=="string")throw new Error("getPathVertices: pathData must be a string");let J=[],Z=0,K=0,Q=0,H=0,z=s5($);for(let q=0;q<z.length;q++){let W=z[q],j=Z,G=K;switch(W.type){case"M":if(Z=W.x,K=W.y,Q=Z,H=K,J.length>0){let F=J[J.length-1],_=Math.atan2(K-G,Z-j);F.tangentOut=_}J.push({x:Z,y:K,tangentIn:0,tangentOut:0,index:J.length});break;case"L":{Z=W.x,K=W.y;let F=Z-j,_=K-G,U=F===0&&_===0?J.length>0?J[J.length-1].tangentOut:0:Math.atan2(_,F);if(J.length>0)J[J.length-1].tangentOut=U;J.push({x:Z,y:K,tangentIn:U,tangentOut:U,index:J.length});break}case"C":{Z=W.x,K=W.y;let F=W.x1-j,_=W.y1-G,U=F===0&&_===0?Math.atan2(W.y2-G,W.x2-j):Math.atan2(_,F),O=Z-W.x2,V=K-W.y2,M=O===0&&V===0?Math.atan2(K-W.y1,Z-W.x1):Math.atan2(V,O);if(J.length>0)J[J.length-1].tangentOut=U;J.push({x:Z,y:K,tangentIn:M,tangentOut:M,index:J.length});break}case"Q":{Z=W.x,K=W.y;let F=W.x1-j,_=W.y1-G,U=F===0&&_===0?Math.atan2(K-G,Z-j):Math.atan2(_,F),O=Z-W.x1,V=K-W.y1,M=O===0&&V===0?Math.atan2(K-G,Z-j):Math.atan2(V,O);if(J.length>0)J[J.length-1].tangentOut=U;J.push({x:Z,y:K,tangentIn:M,tangentOut:M,index:J.length});break}case"A":{Z=W.x,K=W.y;let F=Z-j,_=K-G,U=F===0&&_===0?J.length>0?J[J.length-1].tangentOut:0:Math.atan2(_,F);if(J.length>0)J[J.length-1].tangentOut=U;J.push({x:Z,y:K,tangentIn:U,tangentOut:U,index:J.length});break}case"Z":{Z=Q,K=H;let F=Z-j,_=K-G,U=F===0&&_===0?J.length>0?J[J.length-1].tangentOut:0:Math.atan2(_,F);if(J.length>0)J[J.length-1].tangentOut=U;if(J.length>0)J[0].tangentIn=U;break}default:break}}return J}function s5($){if(typeof $!=="string")throw new Error("parsePathCommands: pathData must be a string");let J=[];if($.trim()==="")return J;let Z=$.replace(/([MmLlHhVvCcSsQqTtAaZz])/g," $1 ").trim(),K=/[MmLlHhVvCcSsQqTtAaZz]/,Q=/-?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/g,H=[],z=0;while(z<Z.length){while(z<Z.length&&/[\s,]/.test(Z[z]))z++;if(z>=Z.length)break;if(K.test(Z[z]))H.push(Z[z]),z++;else{Q.lastIndex=z;let F=Q.exec(Z);if(F&&F.index===z)H.push(F[0]),z=Q.lastIndex;else z++}}let q=0,W=0,j=0,G=(F,_)=>{if(F>=H.length)throw new Error(`parsePathCommands: missing ${_} parameter at token ${F}`);let U=parseFloat(H[F]);if(isNaN(U)||!isFinite(U))throw new Error(`parsePathCommands: invalid ${_} value "${H[F]}" at token ${F}`);return U};while(q<H.length){let F=H[q];switch(F.toUpperCase()){case"M":{let _=G(q+1,"M.x"),U=G(q+2,"M.y");J.push({type:"M",x:F==="M"?_:W+_,y:F==="M"?U:j+U}),W=J[J.length-1].x,j=J[J.length-1].y,q+=3;break}case"L":{let _=G(q+1,"L.x"),U=G(q+2,"L.y");J.push({type:"L",x:F==="L"?_:W+_,y:F==="L"?U:j+U}),W=J[J.length-1].x,j=J[J.length-1].y,q+=3;break}case"H":{let _=G(q+1,"H.x");J.push({type:"L",x:F==="H"?_:W+_,y:j}),W=J[J.length-1].x,q+=2;break}case"V":{let _=G(q+1,"V.y");J.push({type:"L",x:W,y:F==="V"?_:j+_}),j=J[J.length-1].y,q+=2;break}case"C":{let _=G(q+1,"C.x1"),U=G(q+2,"C.y1"),O=G(q+3,"C.x2"),V=G(q+4,"C.y2"),M=G(q+5,"C.x"),Y=G(q+6,"C.y");J.push({type:"C",x1:F==="C"?_:W+_,y1:F==="C"?U:j+U,x2:F==="C"?O:W+O,y2:F==="C"?V:j+V,x:F==="C"?M:W+M,y:F==="C"?Y:j+Y}),W=J[J.length-1].x,j=J[J.length-1].y,q+=7;break}case"Q":{let _=G(q+1,"Q.x1"),U=G(q+2,"Q.y1"),O=G(q+3,"Q.x"),V=G(q+4,"Q.y");J.push({type:"Q",x1:F==="Q"?_:W+_,y1:F==="Q"?U:j+U,x:F==="Q"?O:W+O,y:F==="Q"?V:j+V}),W=J[J.length-1].x,j=J[J.length-1].y,q+=5;break}case"A":{let _=G(q+1,"A.rx"),U=G(q+2,"A.ry"),O=G(q+3,"A.rotation");if(q+4>=H.length||q+5>=H.length)throw new Error("parsePathCommands: missing arc flag parameters");let V=parseInt(H[q+4],10),M=parseInt(H[q+5],10);if(isNaN(V)||isNaN(M))throw new Error("parsePathCommands: invalid arc flag values");let Y=G(q+6,"A.x"),X=G(q+7,"A.y");J.push({type:"A",rx:_,ry:U,xAxisRotation:O,largeArcFlag:V,sweepFlag:M,x:F==="A"?Y:W+Y,y:F==="A"?X:j+X}),W=J[J.length-1].x,j=J[J.length-1].y,q+=8;break}case"Z":J.push({type:"Z"}),q+=1;break;default:q+=1}}return J}function o5($,J){if(!$)throw new Error("resolveMarkers: pathElement is required");if(!J||typeof J!=="object")throw new Error("resolveMarkers: defsMap must be an object");let Z=[],K=$.getAttribute("marker-start"),Q=$.getAttribute("marker-mid"),H=$.getAttribute("marker-end"),z=$.getAttribute("stroke-width")||"1",q=parseFloat(z);if(isNaN(q)||q<=0)throw new Error("resolveMarkers: stroke-width must be a positive number");let W=$.getAttribute("d")||"",j=OH(W);if(j.length===0)return Z;let G=(F)=>{if(!F)return null;let _=F.match(/url\(#([^)]+)\)/);return _?_[1]:null};if(K){let F=G(K),_=F?J[F]:null;if(_&&j.length>0){let U=j[0],O=j.length>1?U.tangentOut:U.tangentIn;Z.push({markerDef:_,position:{x:U.x,y:U.y},transform:u9(_,{x:U.x,y:U.y},O,q,!0),type:"start",vertex:U})}}if(Q&&j.length>2){let F=G(Q),_=F?J[F]:null;if(_)for(let U=1;U<j.length-1;U++){let O=j[U],V=O.tangentIn,Y=O.tangentOut-V;while(Y>Math.PI)Y-=2*Math.PI;while(Y<-Math.PI)Y+=2*Math.PI;let X=V+Y/2;Z.push({markerDef:_,position:{x:O.x,y:O.y},transform:u9(_,{x:O.x,y:O.y},X,q,!1),type:"mid",vertex:O})}}if(H){let F=G(H),_=F?J[F]:null;if(_&&j.length>0){let U=j[j.length-1],O=U.tangentIn;Z.push({markerDef:_,position:{x:U.x,y:U.y},transform:u9(_,{x:U.x,y:U.y},O,q,!1),type:"end",vertex:U})}}return Z}function YH($,J={}){if(!$)throw new Error("markerToPolygons: markerInstance is required");if(!$.markerDef)throw new Error("markerToPolygons: markerInstance.markerDef is required");if(!$.transform)throw new Error("markerToPolygons: markerInstance.transform is required");let{precision:Z=2,curveSegments:K=10}=J;if(typeof Z!=="number"||Z<0)throw new Error("markerToPolygons: precision must be a non-negative number");if(typeof K!=="number"||K<=0)throw new Error("markerToPolygons: curveSegments must be a positive number");let Q=[],{markerDef:H,transform:z}=$;if(!Array.isArray(H.children))throw new Error("markerToPolygons: markerDef.children must be an array");for(let q of H.children){let W=[];switch(q.type){case"path":W=XH(q.d,K);break;case"rect":W=[{x:q.x,y:q.y},{x:q.x+q.width,y:q.y},{x:q.x+q.width,y:q.y+q.height},{x:q.x,y:q.y+q.height}];break;case"circle":W=kH(q.cx,q.cy,q.r,K*4);break;case"ellipse":W=LH(q.cx,q.cy,q.rx,q.ry,K*4);break;case"line":W=[{x:q.x1,y:q.y1},{x:q.x2,y:q.y2}];break;case"polygon":case"polyline":W=wH(q.points);break;default:break}if(W.length>0){let j=W.map((G)=>{let F=c0(z,G.x,G.y);return{x:parseFloat(F[0].toFixed(Z)),y:parseFloat(F[1].toFixed(Z))}});Q.push(j)}}return Q}function XH($,J=10){if(typeof $!=="string")throw new Error("pathToPoints: pathData must be a string");if(typeof J!=="number"||J<=0)throw new Error("pathToPoints: segments must be a positive number");let Z=[],K=s5($),Q=0,H=0;for(let z of K)switch(z.type){case"M":Q=z.x,H=z.y,Z.push({x:Q,y:H});break;case"L":Q=z.x,H=z.y,Z.push({x:Q,y:H});break;case"C":for(let q=1;q<=J;q++){let W=q/J,j=1-W,G=j*j*j*Q+3*j*j*W*z.x1+3*j*W*W*z.x2+W*W*W*z.x,F=j*j*j*H+3*j*j*W*z.y1+3*j*W*W*z.y2+W*W*W*z.y;Z.push({x:G,y:F})}Q=z.x,H=z.y;break;case"Q":for(let q=1;q<=J;q++){let W=q/J,j=1-W,G=j*j*Q+2*j*W*z.x1+W*W*z.x,F=j*j*H+2*j*W*z.y1+W*W*z.y;Z.push({x:G,y:F})}Q=z.x,H=z.y;break;case"A":Q=z.x,H=z.y,Z.push({x:Q,y:H});break;default:break}return Z}function kH($,J,Z,K=32){if(typeof $!=="number"||!isFinite($))throw new Error("circleToPoints: cx must be a finite number");if(typeof J!=="number"||!isFinite(J))throw new Error("circleToPoints: cy must be a finite number");if(typeof Z!=="number"||!isFinite(Z)||Z<0)throw new Error("circleToPoints: r must be a non-negative finite number");if(typeof K!=="number"||K<=0)throw new Error("circleToPoints: segments must be a positive number");let Q=[];for(let H=0;H<K;H++){let z=H/K*2*Math.PI;Q.push({x:$+Z*Math.cos(z),y:J+Z*Math.sin(z)})}return Q}function LH($,J,Z,K,Q=32){if(typeof $!=="number"||!isFinite($))throw new Error("ellipseToPoints: cx must be a finite number");if(typeof J!=="number"||!isFinite(J))throw new Error("ellipseToPoints: cy must be a finite number");if(typeof Z!=="number"||!isFinite(Z)||Z<0)throw new Error("ellipseToPoints: rx must be a non-negative finite number");if(typeof K!=="number"||!isFinite(K)||K<0)throw new Error("ellipseToPoints: ry must be a non-negative finite number");if(typeof Q!=="number"||Q<=0)throw new Error("ellipseToPoints: segments must be a positive number");let H=[];for(let z=0;z<Q;z++){let q=z/Q*2*Math.PI;H.push({x:$+Z*Math.cos(q),y:J+K*Math.sin(q)})}return H}function wH($){if(typeof $!=="string")throw new Error("parsePoints: pointsStr must be a string");let J=[],Z=$.trim().split(/[\s,]+/).map(Number).filter((K)=>!isNaN(K)&&isFinite(K));if(Z.length%2!==0)throw new Error("parsePoints: pointsStr must contain an even number of valid coordinates");for(let K=0;K<Z.length;K+=2)J.push({x:Z[K],y:Z[K+1]});return J}function i5($,J=2){if(!Array.isArray($))throw new Error("markersToPathData: markerInstances must be an array");if(typeof J!=="number"||J<0)throw new Error("markersToPathData: precision must be a non-negative number");let Z=[];for(let K of $){let Q=YH(K,{precision:J});for(let H of Q){if(H.length===0)continue;let z=H[0];Z.push(`M ${z.x.toFixed(J)} ${z.y.toFixed(J)}`);for(let q=1;q<H.length;q++){let W=H[q];Z.push(`L ${W.x.toFixed(J)} ${W.y.toFixed(J)}`)}Z.push("Z")}}return Z.join(" ")}k.set({precision:80});var k0=($)=>$ instanceof k?$:new k($),r0=new k(0),k6=new k(1);function L6(){let $=k.precision;if($<20)throw new Error(`Decimal precision (${$}) is too low for verification. Minimum required: 20`);let J=Math.max(1,$-10);return new k(10).pow(-J)}function e5($,J,Z){let K=L6();if(!$)return{valid:!1,error:new k(1/0),tolerance:K,message:"Matrix parameter is null or undefined"};if(J==null||Z==null)return{valid:!1,error:new k(1/0),tolerance:K,message:"Coordinates x or y are null or undefined"};let Q=k0(J),H=k0(Z);try{let[z,q]=c0($,Q,H),W=$.inverse();if(!W)return{valid:!1,error:new k(1/0),tolerance:K,message:"Matrix is not invertible (determinant = 0)",details:{determinant:$.determinant()}};let[j,G]=c0(W,z,q),F=Q.minus(j).abs(),_=H.minus(G).abs(),U=k.max(F,_),O=U.lessThan(K);return{valid:O,error:U,tolerance:K,message:O?`Round-trip verified: error ${U.toExponential()} < tolerance ${K.toExponential()}`:`Round-trip FAILED: error ${U.toExponential()} >= tolerance ${K.toExponential()}`,details:{original:{x:Q.toString(),y:H.toString()},transformed:{x:z.toString(),y:q.toString()},recovered:{x:j.toString(),y:G.toString()},errorX:F.toExponential(),errorY:_.toExponential()}}}catch(z){return{valid:!1,error:new k(1/0),tolerance:K,message:`Verification error: ${z.message}`}}}function g9($){let J=L6();if(!$)return{valid:!1,error:new k(1/0),tolerance:J,message:"Matrix parameter is null or undefined"};try{let Z=$.inverse();if(!Z)return{valid:!1,error:new k(1/0),tolerance:J,message:"Matrix is singular (not invertible)",details:{determinant:$.determinant().toString()}};let K=$.mul(Z),Q=$.rows,H=r0,z=[];for(let W=0;W<Q;W++)for(let j=0;j<Q;j++){let G=W===j?k6:r0,F=K.data[W][j],_=F.minus(G).abs();if(_.greaterThan(H))H=_;if(_.greaterThanOrEqualTo(J))z.push({row:W,col:j,expected:G.toString(),actual:F.toString(),error:_.toExponential()})}let q=H.lessThan(J);return{valid:q,error:H,tolerance:J,message:q?`Matrix inversion verified: max error ${H.toExponential()} < tolerance`:`Matrix inversion FAILED: max error ${H.toExponential()} at ${z.length} positions`,details:{matrixSize:`${Q}x${Q}`,maxError:H.toExponential(),failedElements:z.slice(0,5)}}}catch(Z){return{valid:!1,error:new k(1/0),tolerance:J,message:`Verification error: ${Z.message}`}}}function r5($,J,Z=null){let K=L6(),Q=Z||new k("1e-6");if(!$||!Array.isArray($))return{valid:!1,error:r0,tolerance:K,message:"Inner polygon parameter is null, undefined, or not an array"};if(!J||!Array.isArray(J))return{valid:!1,error:r0,tolerance:K,message:"Outer polygon parameter is null, undefined, or not an array"};if($.length<3||J.length<3)return{valid:!1,error:r0,tolerance:K,message:"Polygons must have at least 3 vertices"};try{let H=!0,z=[],q=r0;for(let W=0;W<$.length;W++){let j=$[W];if(!NH(j,J)){let G=BH(j,J);if(G.greaterThan(q))q=G;if(G.greaterThan(Q))H=!1,z.push({index:W,x:j.x.toString(),y:j.y.toString(),distanceOutside:G.toExponential()})}}return{valid:H,error:q,tolerance:Q,message:H?`All inner polygon points are inside or within tolerance (max outside: ${q.toExponential()})`:`${z.length} points exceed tolerance distance outside outer polygon`,details:{innerVertices:$.length,outerVertices:J.length,maxOutsideDistance:q.toExponential(),outsidePoints:z.slice(0,5)}}}catch(H){return{valid:!1,error:new k(1/0),tolerance:K,message:`Verification error: ${H.message}`}}}function BH($,J){if(!$||$.x==null||$.y==null)throw new Error("Invalid point parameter: must have x and y properties");if(!J||!Array.isArray(J)||J.length===0)throw new Error("Invalid polygon parameter: must be non-empty array of points");let Z=new k(1/0),K=k0($.x),Q=k0($.y);for(let H=0;H<J.length;H++){let z=(H+1)%J.length,q=J[H],W=J[z],j=k0(q.x),G=k0(q.y),F=k0(W.x),_=k0(W.y),U=F.minus(j),O=_.minus(G),V=U.times(U).plus(O.times(O)),M;if(V.isZero())M=KK($,q);else{let Y=k.max(r0,k.min(k6,K.minus(j).times(U).plus(Q.minus(G).times(O)).div(V))),X=j.plus(Y.times(U)),w=G.plus(Y.times(O));M=K.minus(X).pow(2).plus(Q.minus(w).pow(2)).sqrt()}if(M.lessThan(Z))Z=M}return Z}function $K($,J,Z){let K=L6();if(!$||!Array.isArray($))return{valid:!1,error:r0,tolerance:K,message:"Poly1 parameter must be an array"};if(!J||!Array.isArray(J))return{valid:!1,error:r0,tolerance:K,message:"Poly2 parameter must be an array"};if(!Z||!Array.isArray(Z))return{valid:!1,error:r0,tolerance:K,message:"Intersection parameter must be an array"};if(Z.length<3)return{valid:!0,error:r0,tolerance:K,message:"Intersection is empty or degenerate (valid result)",details:{intersectionVertices:Z.length}};try{let Q=r5(Z,$),H=r5(Z,J),z=p6($),q=p6(J),W=p6(Z),j=k.min(z,q),G=W.lessThanOrEqualTo(j.times(k6.plus(K))),F=Q.valid&&H.valid&&G;return{valid:F,error:F?r0:k6,tolerance:K,message:F?"Intersection verified: contained in both polygons, area valid":`Intersection FAILED: ${!Q.valid?"not in poly1, ":""}${!H.valid?"not in poly2, ":""}${!G?"area too large":""}`,details:{containedInPoly1:Q.valid,containedInPoly2:H.valid,area1:z.toString(),area2:q.toString(),intersectionArea:W.toString(),areaValid:G}}}catch(Q){return{valid:!1,error:new k(1/0),tolerance:K,message:`Verification error: ${Q.message}`}}}function JK($,J,Z){let K=L6();if(!$||typeof $!=="object")return{valid:!1,error:new k(1/0),tolerance:K,message:"Original gradient parameter must be an object"};if(!J||typeof J!=="object")return{valid:!1,error:new k(1/0),tolerance:K,message:"Baked gradient parameter must be an object"};if(!Z)return{valid:!1,error:new k(1/0),tolerance:K,message:"Matrix parameter is null or undefined"};try{let[Q,H]=c0(Z,k0($.x1||0),k0($.y1||0)),[z,q]=c0(Z,k0($.x2||1),k0($.y2||0)),W=k0(J.x1).minus(Q).abs(),j=k0(J.y1).minus(H).abs(),G=k0(J.x2).minus(z).abs(),F=k0(J.y2).minus(q).abs(),_=k.max(W,j,G,F),U=_.lessThan(K);return{valid:U,error:_,tolerance:K,message:U?`Linear gradient transform verified: max error ${_.toExponential()}`:`Linear gradient transform FAILED: max error ${_.toExponential()}`,details:{expected:{x1:Q.toString(),y1:H.toString(),x2:z.toString(),y2:q.toString()},actual:J}}}catch(Q){return{valid:!1,error:new k(1/0),tolerance:K,message:`Verification error: ${Q.message}`}}}function p6($){if(!$||!Array.isArray($))throw new Error("Invalid polygon parameter: must be an array");if($.length<3)return r0;let J=r0,Z=$.length;for(let K=0;K<Z;K++){let Q=(K+1)%Z,H=k0($[K].x),z=k0($[K].y),q=k0($[Q].x),W=k0($[Q].y);J=J.plus(H.times(W).minus(q.times(z)))}return J.abs().div(2)}function NH($,J){if(!$||$.x==null||$.y==null)throw new Error("Invalid point parameter: must have x and y properties");if(!J||!Array.isArray(J)||J.length===0)throw new Error("Invalid polygon parameter: must be non-empty array of points");let Z=k0($.x),K=k0($.y),Q=J.length,H=!1;for(let z=0,q=Q-1;z<Q;q=z++){let W=k0(J[z].x),j=k0(J[z].y),G=k0(J[q].x),F=k0(J[q].y);if(IH($,J[z],J[q]))return!0;if(j.greaterThan(K)!==F.greaterThan(K)&&Z.lessThan(G.minus(W).times(K.minus(j)).div(F.minus(j)).plus(W)))H=!H}return H}function IH($,J,Z){if(!$||$.x==null||$.y==null)throw new Error("Invalid point parameter: must have x and y properties");if(!J||J.x==null||J.y==null)throw new Error("Invalid segStart parameter: must have x and y properties");if(!Z||Z.x==null||Z.y==null)throw new Error("Invalid segEnd parameter: must have x and y properties");let K=L6(),Q=k0($.x),H=k0($.y),z=k0(J.x),q=k0(J.y),W=k0(Z.x),j=k0(Z.y),G=k.min(z,W).minus(K),F=k.max(z,W).plus(K),_=k.min(q,j).minus(K),U=k.max(q,j).plus(K);if(Q.lessThan(G)||Q.greaterThan(F)||H.lessThan(_)||H.greaterThan(U))return!1;let O=W.minus(z).times(H.minus(q)).minus(j.minus(q).times(Q.minus(z))).abs(),V=KK(J,Z);return O.div(V.plus(K)).lessThan(K)}function KK($,J){if(!$||$.x==null||$.y==null)throw new Error("Invalid p1 parameter: must have x and y properties");if(!J||J.x==null||J.y==null)throw new Error("Invalid p2 parameter: must have x and y properties");let Z=k0(J.x).minus(k0($.x)),K=k0(J.y).minus(k0($.y));return Z.times(Z).plus(K.times(K)).sqrt()}function ZK($,J){if(!$||$.length<3||!J||J.length<3)return[];let Z=[];for(let K=0;K<J.length;K++){let Q=J[K],H=J[(K+1)%J.length],z=[];for(let q=0;q<$.length;q++){let W=$[q],j=$[(q+1)%$.length],G=!a5(W,Q,H),F=!a5(j,Q,H);if(G){if(z.push(W),!F)z.push(t5(W,j,Q,H))}else if(F)z.push(t5(W,j,Q,H))}if(z.length>=3)Z.push(z)}return Z}function QK($,J,Z=[],K="1e-10"){let Q=K instanceof k?K:new k(K),H=Z||[];if(!$||!Array.isArray($))return{valid:!1,error:new k(1/0),tolerance:Q,message:"Original polygon parameter must be an array"};if(!J||!Array.isArray(J))return{valid:!1,error:new k(1/0),tolerance:Q,message:"Clipped polygon parameter must be an array"};try{let z=p6($),q=J.length>=3?p6(J):r0,W=z.minus(q),j=q.lessThanOrEqualTo(z.times(k6.plus(Q))),G=W.greaterThanOrEqualTo(r0.minus(Q.times(z))),F=z.isZero()?k6:q.div(z),_=r0,U=j&&G;return{valid:U,error:_,tolerance:Q,message:U?`ClipPath E2E verified: area conserved (clipped ${F.times(100).toFixed(2)}% of original)`:"ClipPath E2E FAILED: invalid intersection (clipped > original or negative outside)",details:{originalArea:z.toString(),clippedArea:q.toString(),outsideArea:W.toString(),areaRatio:F.toFixed(6),fragmentCount:H.length,clippedValid:j,outsideValid:G}}}catch(z){return{valid:!1,error:new k(1/0),tolerance:Q,message:`E2E verification error: ${z.message}`}}}function a5($,J,Z){if(!$||$.x==null||$.y==null)throw new Error("Invalid point parameter: must have x and y properties");if(!J||J.x==null||J.y==null)throw new Error("Invalid edgeStart parameter: must have x and y properties");if(!Z||Z.x==null||Z.y==null)throw new Error("Invalid edgeEnd parameter: must have x and y properties");let K=k0($.x).toNumber(),Q=k0($.y).toNumber(),H=k0(J.x).toNumber(),z=k0(J.y).toNumber(),q=k0(Z.x).toNumber(),W=k0(Z.y).toNumber();return(q-H)*(Q-z)-(W-z)*(K-H)>=0}function t5($,J,Z,K){if(!$||$.x==null||$.y==null)throw new Error("Invalid p1 parameter: must have x and y properties");if(!J||J.x==null||J.y==null)throw new Error("Invalid p2 parameter: must have x and y properties");if(!Z||Z.x==null||Z.y==null)throw new Error("Invalid p3 parameter: must have x and y properties");if(!K||K.x==null||K.y==null)throw new Error("Invalid p4 parameter: must have x and y properties");let Q=k0($.x).toNumber(),H=k0($.y).toNumber(),z=k0(J.x).toNumber(),q=k0(J.y).toNumber(),W=k0(Z.x).toNumber(),j=k0(Z.y).toNumber(),G=k0(K.x).toNumber(),F=k0(K.y).toNumber(),_=(Q-z)*(j-F)-(H-q)*(W-G);if(Math.abs(_)<0.0000000001)return{x:k0((Q+z)/2),y:k0((H+q)/2)};let U=((Q-W)*(j-F)-(H-j)*(W-G))/_;return{x:k0(Q+U*(z-Q)),y:k0(H+U*(q-H))}}var WK=["animate","animateTransform","animateMotion","animateColor","set"],HK=["href","xlink:href"],zK=["fill","stroke","clip-path","mask","filter","marker-start","marker-mid","marker-end","cursor","color-profile"],PH=["begin","end"],AH=["values","from","to","by"];function x9($){if(!$||typeof $!=="string")return null;let J=$.match(/url\(\s*["']?#([^"')\s]+)\s*["']?\s*\)/);return J&&J[1]?J[1]:null}function qK($){if(!$||typeof $!=="string")return null;if($.startsWith("#")){let J=$.substring(1);return J&&!J.startsWith("#")?J:null}return null}function jK($){if(!$||typeof $!=="string")return[];let J=[],Z=$.split(";");for(let K of Z){let Q=K.trim();if(Q.startsWith("#")){let z=Q.substring(1);if(z)J.push(z)}let H=x9(Q);if(H)J.push(H)}return J}function GK($){if(!$||typeof $!=="string")return[];let J=[],Z=$.split(";");for(let K of Z){let H=K.trim().match(/^([a-zA-Z_][a-zA-Z0-9_-]*)\.(begin|end|click|mousedown|mouseup|mouseover|mouseout|mousemove|mouseenter|mouseleave|focusin|focusout|activate|repeat)(?:\(\d+\))?(?:[+-]\d+(?:\.\d+)?[a-z]*)?/);if(H)J.push(H[1])}return J}function c6($){if(!$||typeof $!=="string")return[];let J=[],Z=/url\(\s*["']?#([^"')]+)["']?\s*\)/g,K;while((K=Z.exec($))!==null)if(K[1])J.push(K[1]);return J}function FK($){if(!$||typeof $!=="string")return[];let J=[],Z=/getElementById\(\s*["']([^"']+)["']\s*\)/g,K;while((K=Z.exec($))!==null)if(K[1])J.push(K[1]);let Q=/querySelector(?:All)?\(\s*["']#([^"'#\s]+)["']\s*\)/g;while((K=Q.exec($))!==null)if(K[1])J.push(K[1]);return J}function EH($){if(!$||typeof $!=="object"||!($ instanceof B0))throw new TypeError("collectElementReferences: el must be a valid SVGElement");if(typeof $.getAttributeNames!=="function")throw new TypeError("collectElementReferences: el must have getAttributeNames method");let J={static:new Set,animation:new Set,css:new Set,js:new Set},Z=$.tagName?.toLowerCase()||"",K=WK.includes(Z),Q=$.getAttributeNames();if(!Array.isArray(Q))throw new TypeError("collectElementReferences: getAttributeNames must return an array");for(let H of Q){let z=$.getAttribute(H);if(!z)continue;if(HK.includes(H)){let q=qK(z);if(q)if(K)J.animation.add(q);else J.static.add(q)}if(zK.includes(H)||H==="style"){let q=x9(z);if(q)J.static.add(q);if(H==="style")c6(z).forEach((W)=>J.css.add(W))}if(PH.includes(H))GK(z).forEach((q)=>J.animation.add(q));if(AH.includes(H))jK(z).forEach((q)=>J.animation.add(q));if(!zK.includes(H)&&z.includes("url(")){let q=x9(z);if(q)J.static.add(q)}}if(Z==="animatemotion"){if(typeof $.getElementsByTagName!=="function")throw new TypeError("collectElementReferences: el must have getElementsByTagName method");let H=$.getElementsByTagName("mpath");if(!H||typeof H[Symbol.iterator]!=="function")throw new TypeError("collectElementReferences: getElementsByTagName must return an iterable");for(let z of H){if(!z||typeof z.getAttribute!=="function")continue;for(let q of HK){let W=z.getAttribute(q),j=qK(W);if(j)J.animation.add(j)}}}return J}function _K($){if(!$||typeof $!=="object"||!($ instanceof B0))throw new TypeError("collectAllReferences: root must be a valid SVGElement");let J={all:new Set,static:new Set,animation:new Set,css:new Set,js:new Set,details:new Map},Z={animation:4,js:3,css:2,static:1},K=(H,z,q)=>{if(J.all.add(H),J[z].add(H),!J.details.has(H))J.details.set(H,{sources:[],type:z});else{let W=J.details.get(H);if(Z[z]>Z[W.type])W.type=z}J.details.get(H).sources.push(q)},Q=(H,z="")=>{let q=H.tagName?.toLowerCase()||"",W=z?`${z}>${q}`:q,j=H.getAttribute("id"),G=j?`${q}#${j}`:W,F=EH(H);if(F.static.forEach((_)=>K(_,"static",G)),F.animation.forEach((_)=>K(_,"animation",G)),F.css.forEach((_)=>K(_,"css",G)),F.js.forEach((_)=>K(_,"js",G)),q==="style"){let _=H.textContent||"";c6(_).forEach((U)=>K(U,"css","<style>"))}if(q==="script"){let _=H.textContent||"";FK(_).forEach((U)=>K(U,"js","<script>"))}if(H.children&&typeof H.children[Symbol.iterator]==="function"){for(let _ of H.children)if(_ instanceof B0)Q(_,W)}};return Q($),J}k.set({precision:80});var X7=($)=>$ instanceof k?$:new k($),TH={precision:6,curveSegments:20,clipSegments:64,bezierArcs:8,resolveUse:!0,resolveMarkers:!0,resolvePatterns:!0,resolveMasks:!0,resolveClipPaths:!0,flattenTransforms:!0,bakeGradients:!0,removeUnusedDefs:!0,preserveIds:!1,svg2Polyfills:!1,e2eTolerance:"1e-10"};function R6($,J={}){if($===null||$===void 0)throw new Error("flattenSVG: svgString parameter is required");if(typeof $!=="string")throw new Error(`flattenSVG: svgString must be a string, got ${typeof $}`);if($.trim().length===0)throw new Error("flattenSVG: svgString cannot be empty");let Z={...TH,...J},K={useResolved:0,markersResolved:0,patternsResolved:0,masksResolved:0,clipPathsApplied:0,transformsFlattened:0,gradientsProcessed:0,defsRemoved:0,errors:[],verifications:{transforms:[],matrices:[],polygons:[],gradients:[],e2e:[],passed:0,failed:0,allPassed:!0},clipOutsideFragments:[]};try{let Q=d0($);if(Q.tagName.toLowerCase()!=="svg")throw new Error("Root element must be <svg>");let H=i7(Q),z=Z.removeUnusedDefs?gH(Q):null;if(Z.resolveUse){let W=bH(Q,H,Z);K.useResolved=W.count,K.errors.push(...W.errors),H=i7(Q)}if(Z.resolveMarkers){let W=fH(Q,H,Z);K.markersResolved=W.count,K.errors.push(...W.errors)}if(Z.resolvePatterns){let W=SH(Q,H,Z);K.patternsResolved=W.count,K.errors.push(...W.errors)}if(Z.resolveMasks){let W=vH(Q,H,Z);K.masksResolved=W.count,K.errors.push(...W.errors)}if(Z.resolveClipPaths){let W=DH(Q,H,Z,K);K.clipPathsApplied=W.count,K.errors.push(...W.errors)}if(Z.flattenTransforms){let W=hH(Q,Z,K);K.transformsFlattened=W.count,K.errors.push(...W.errors)}if(Z.bakeGradients){let W=uH(Q,Z,K);K.gradientsProcessed=W.count,K.errors.push(...W.errors)}if(Z.removeUnusedDefs&&z){let W=xH(Q,z);K.defsRemoved=W.count}return{svg:B7(Q),stats:K}}catch(Q){return K.errors.push(`Pipeline error: ${Q.message}`),{svg:$,stats:K}}}var OK=new Set(["animate","animatetransform","animatemotion","animatecolor","set"]),YK=new Set(["foreignobject","audio","video","iframe","script","style",...OK]);function m9($){if(!$)return!1;let J=$.tagName?.toLowerCase();if(YK.has(J))return!0;for(let Z of $.children||[])if(Z&&Z.tagName&&m9(Z))return!0;return!1}function bH($,J,Z){if(!$||!$.getElementsByTagName)throw new Error("resolveAllUseElements: invalid root element");if(!J||!(J instanceof Map))throw new Error("resolveAllUseElements: defsMap must be a Map");if(!Z||typeof Z!=="object")throw new Error("resolveAllUseElements: opts must be an object");let K=[],Q=0,H=$.getElementsByTagName("use"),z={};for(let[q,W]of J.entries())if(W.tagName.toLowerCase()==="symbol")z[q]=m5(W),z[q].type="symbol";else z[q]=E$(W);for(let q of[...H])try{let W=q.getAttribute("href")||q.getAttribute("xlink:href");if(!W)continue;let j=W.replace(/^#/,""),G=J.get(j);if(!G){K.push(`use: referenced element #${j} not found`);continue}let F=m9(G),_=m9(q);if(F||_){let M=G.cloneNode(!0),Y=parseFloat(q.getAttribute("x")||"0"),X=parseFloat(q.getAttribute("y")||"0");if(isNaN(Y)||isNaN(X)){K.push(`use: invalid x/y coordinates for element #${j}`);continue}let w=q.getAttribute("transform")||"",R="";if(w)R=w;if(Y!==0||X!==0){let m=`translate(${Y}, ${X})`;R=R?`${R} ${m}`:m}let I=new B0("g",{});if(R)I.setAttribute("transform",R);let b=l6(q);for(let[m,S]of Object.entries(b))if(S&&!I.hasAttribute(m))I.setAttribute(m,S);if(G.tagName.toLowerCase()==="symbol"){for(let m of M.children||[])if(m&&m.tagName)I.appendChild(m.cloneNode(!0))}else M.removeAttribute("id"),I.appendChild(M);for(let m of q.children||[])if(m&&m.tagName){let S=m.tagName.toLowerCase();if(OK.has(S))I.appendChild(m.cloneNode(!0))}if(q.parentNode)q.parentNode.replaceChild(I,q),Q++;continue}let U=x5(q),O=y9(U,z,{samples:Z.curveSegments});if(!O){K.push(`use: failed to resolve #${j}`);continue}let V=c5(O,Z.curveSegments);if(V){let M=new B0("path",{d:V,...l6(q)});if(O.style){for(let[Y,X]of Object.entries(O.style))if(X&&!M.hasAttribute(Y))M.setAttribute(Y,X)}if(q.parentNode)q.parentNode.replaceChild(M,q),Q++}}catch(W){K.push(`use: ${W.message}`)}return{count:Q,errors:K}}function fH($,J,Z){if(!$||!$.getElementsByTagName)throw new Error("resolveAllMarkers: invalid root element");if(!J||!(J instanceof Map))throw new Error("resolveAllMarkers: defsMap must be a Map");if(!Z||typeof Z!=="object")throw new Error("resolveAllMarkers: opts must be an object");let K=[],Q=0,H=["marker-start","marker-mid","marker-end","marker"];for(let z of H){let q=u7($,z);for(let W of q){if(W.tagName!=="path"&&W.tagName!=="line"&&W.tagName!=="polyline"&&W.tagName!=="polygon")continue;try{let j=o5(W,Object.fromEntries(J));if(!j||j.length===0)continue;let G=i5(j,Z.precision);if(G){let F=new B0("path",{d:G,fill:W.getAttribute("stroke")||"currentColor"});if(W.parentNode){let _=W.nextSibling;if(_)W.parentNode.insertBefore(F,_);else W.parentNode.appendChild(F);Q++}}for(let F of H)W.removeAttribute(F)}catch(j){K.push(`marker: ${j.message}`)}}}return{count:Q,errors:K}}function SH($,J,Z){if(!$||!$.getElementsByTagName)throw new Error("resolveAllPatterns: invalid root element");if(!J||!(J instanceof Map))throw new Error("resolveAllPatterns: defsMap must be a Map");if(!Z||typeof Z!=="object")throw new Error("resolveAllPatterns: opts must be an object");let K=[],Q=0,H=u7($,"fill");for(let z of H){let q=z.getAttribute("fill");if(!q||!q.includes("url("))continue;let W=r7(q);if(!W)continue;let j=J.get(W);if(!j||j.tagName.toLowerCase()!=="pattern")continue;try{let G=j.getAttribute("patternUnits")||"objectBoundingBox",F=j.getAttribute("patternContentUnits")||"userSpaceOnUse",_=j.getAttribute("patternTransform");if(G!=="objectBoundingBox")K.push(`pattern ${W}: non-default patternUnits="${G}" may cause rendering issues`);if(F!=="userSpaceOnUse")K.push(`pattern ${W}: non-default patternContentUnits="${F}" may cause rendering issues`);if(_)K.push(`pattern ${W}: patternTransform present - complex transformation may cause rendering issues`);let U=XK(z);if(!U)continue;let O=l5(j),V=n5(O,U,{samples:Z.curveSegments});if(V){let M=new B0("g",{}),Y=new B0("path",{d:V,fill:"#000"});if(M.appendChild(Y),z.setAttribute("fill","none"),z.setAttribute("stroke",z.getAttribute("stroke")||"none"),z.parentNode)z.parentNode.insertBefore(M,z),Q++}}catch(G){K.push(`pattern: ${G.message}`)}}return{count:Q,errors:K}}function vH($,J,Z){if(!$||!$.getElementsByTagName)throw new Error("resolveAllMasks: invalid root element");if(!J||!(J instanceof Map))throw new Error("resolveAllMasks: defsMap must be a Map");if(!Z||typeof Z!=="object")throw new Error("resolveAllMasks: opts must be an object");let K=[],Q=0,H=u7($,"mask");for(let z of H){let q=z.getAttribute("mask");if(!q||!q.includes("url("))continue;let W=r7(q);if(!W)continue;let j=J.get(W);if(!j||j.tagName.toLowerCase()!=="mask")continue;try{let G=j.getAttribute("maskUnits")||"objectBoundingBox",F=j.getAttribute("maskContentUnits")||"userSpaceOnUse";if(G!=="objectBoundingBox")K.push(`mask ${W}: non-default maskUnits="${G}" may cause rendering issues`);if(F!=="userSpaceOnUse")K.push(`mask ${W}: non-default maskContentUnits="${F}" may cause rendering issues`);let _=XK(z);if(!_)continue;let U=u5(j),O=g5(U,_,{samples:Z.curveSegments,opacityThreshold:0.5});if(O){let V=w6(z,Z.precision);if(V){let M=a7(V,Z.curveSegments),Y=a7(O,Z.curveSegments),X=kK(M,Y);if(X&&X.length>2){let w=h9(X,Z.precision);z.setAttribute("d",w),z.removeAttribute("mask"),Q++}}}}catch(G){K.push(`mask: ${G.message}`)}}return{count:Q,errors:K}}function DH($,J,Z,K){if(!$||!$.getElementsByTagName)throw new Error("applyAllClipPaths: invalid root element");if(!J||!(J instanceof Map))throw new Error("applyAllClipPaths: defsMap must be a Map");if(!Z||typeof Z!=="object")throw new Error("applyAllClipPaths: opts must be an object");if(!K||typeof K!=="object")throw new Error("applyAllClipPaths: stats must be an object");let Q=[],H=0;if(!K.verifications.e2e)K.verifications.e2e=[];if(!K.clipOutsideFragments)K.clipOutsideFragments=[];let z=u7($,"clip-path");for(let q of z){let W=q.getAttribute("clip-path");if(!W||!W.includes("url("))continue;let j=r7(W);if(!j)continue;let G=J.get(j),F=G?G.tagName.toLowerCase():"";if(!G||F!=="clippath")continue;try{if((G.getAttribute("clipPathUnits")||"userSpaceOnUse")==="objectBoundingBox")Q.push(`clipPath ${j}: objectBoundingBox units require bbox-relative coordinate transformation`);let U=w6(q,Z.precision);if(!U)continue;let O="";if(G.children&&G.children.length>0){for(let I of G.children)if(I&&I.tagName){let b=w6(I,Z.precision);if(b)O+=(O?" ":"")+b}}if(!O)continue;let V=Z.clipSegments||64,M=a7(U,V),Y=a7(O,V),X=kK(M,Y),w=M.map((I)=>({x:I.x instanceof k?I.x:X7(I.x),y:I.y instanceof k?I.y:X7(I.y)})),R=Y.map((I)=>({x:I.x instanceof k?I.x:X7(I.x),y:I.y instanceof k?I.y:X7(I.y)}));if(X&&X.length>2){let I=X.map((x)=>({x:x.x instanceof k?x.x:X7(x.x),y:x.y instanceof k?x.y:X7(x.y)})),b=$K(w,R,I);if(K.verifications.polygons.push({element:q.tagName,clipPathId:j,...b}),b.valid)K.verifications.passed++;else K.verifications.failed++,K.verifications.allPassed=!1;let u=ZK(w,R);K.clipOutsideFragments.push({elementId:q.getAttribute("id")||`clip-${H}`,clipPathId:j,fragments:u,visible:!1});let m=Z.e2eTolerance||"1e-10",S=QK(w,I,u,m);if(K.verifications.e2e.push({element:q.tagName,clipPathId:j,type:"clip-area-conservation",...S}),S.valid)K.verifications.passed++;else K.verifications.failed++,K.verifications.allPassed=!1}if(X&&X.length>2){let I=h9(X,Z.precision),b=q;if(q.tagName==="path")q.setAttribute("d",I);else{let u=new B0("path",{d:I,...l6(q)});if(q.parentNode)q.parentNode.replaceChild(u,q),b=u}b.removeAttribute("clip-path"),H++}}catch(_){Q.push(`clipPath: ${_.message}`)}}return{count:H,errors:Q}}function hH($,J,Z){if(!$||!$.getElementsByTagName)throw new Error("flattenAllTransforms: invalid root element");if(!J||typeof J!=="object")throw new Error("flattenAllTransforms: opts must be an object");if(!Z||typeof Z!=="object")throw new Error("flattenAllTransforms: stats must be an object");let K=[],Q=0,H=u7($,"transform");for(let z of H){let q=z.getAttribute("transform");if(!q)continue;try{let W=$7(q),j=g9(W);if(Z.verifications.matrices.push({element:z.tagName,transform:q,...j}),j.valid)Z.verifications.passed++;else Z.verifications.failed++,Z.verifications.allPassed=!1;let G=w6(z,J.precision);if(!G){if(z.tagName==="g")yH(z,W,J,Z),z.removeAttribute("transform"),Q++;continue}let F=[],_=a7(G,4);if(_&&_.length>0)F=_.slice(0,4).map((V)=>({x:V.x instanceof k?V.x:X7(V.x),y:V.y instanceof k?V.y:X7(V.y)}));let U=Y6(G,W,{precision:J.precision});for(let V=0;V<F.length;V++){let M=F[V],Y=e5(W,M.x,M.y);if(Z.verifications.transforms.push({element:z.tagName,pointIndex:V,...Y}),Y.valid)Z.verifications.passed++;else Z.verifications.failed++,Z.verifications.allPassed=!1}let O=z;if(z.tagName==="path")z.setAttribute("d",U);else{let V=new B0("path",{d:U,...l6(z)});for(let M of mH(z.tagName))V.removeAttribute(M);if(z.parentNode)z.parentNode.replaceChild(V,z),O=V}O.removeAttribute("transform"),Q++}catch(W){K.push(`transform: ${W.message}`)}}return{count:Q,errors:K}}function yH($,J,Z,K){if(!$||!$.children)throw new Error("propagateTransformToChildren: invalid group element");if(!J||!J.data)throw new Error("propagateTransformToChildren: invalid matrix");if(!Z||typeof Z!=="object")throw new Error("propagateTransformToChildren: opts must be an object");if(!K||typeof K!=="object")throw new Error("propagateTransformToChildren: stats must be an object");for(let Q of[...$.children]){if(!(Q&&Q.tagName))continue;if(Q.tagName==="g"){let H=Q.getAttribute("transform");if(H){let z=$7(H),q=J.mul(z);Q.setAttribute("transform",UK(q))}else Q.setAttribute("transform",UK(J))}else{let H=w6(Q,Z.precision);if(H){let z=Q.getAttribute("transform"),q=J;if(z){let F=$7(z);q=J.mul(F)}let W=g9(q);if(K.verifications.matrices.push({element:Q.tagName,context:"group-propagation",...W}),W.valid)K.verifications.passed++;else K.verifications.failed++,K.verifications.allPassed=!1;let j=Y6(H,q,{precision:Z.precision}),G=Q;if(Q.tagName==="path")Q.setAttribute("d",j);else{let F=new B0("path",{d:j,...l6(Q)});$.replaceChild(F,Q),G=F}G.removeAttribute("transform")}}}}function uH($,J,Z){if(!$||!$.getElementsByTagName)throw new Error("bakeAllGradientTransforms: invalid root element");if(!J||typeof J!=="object")throw new Error("bakeAllGradientTransforms: opts must be an object");if(!Z||typeof Z!=="object")throw new Error("bakeAllGradientTransforms: stats must be an object");let K=[],Q=0,H=$.getElementsByTagName("linearGradient");for(let q of H){let W=q.getAttribute("gradientTransform");if(!W)continue;try{let j=$7(W),G=parseFloat(q.getAttribute("x1")||"0"),F=parseFloat(q.getAttribute("y1")||"0"),_=parseFloat(q.getAttribute("x2")||"1"),U=parseFloat(q.getAttribute("y2")||"0");if(isNaN(G)||isNaN(F)||isNaN(_)||isNaN(U)){K.push(`linearGradient: invalid coordinate values for gradient ${q.getAttribute("id")||"unknown"}`);continue}let[O,V]=c0(j,G,F),[M,Y]=c0(j,_,U),X=JK({x1:G,y1:F,x2:_,y2:U},{x1:O.toNumber(),y1:V.toNumber(),x2:M.toNumber(),y2:Y.toNumber()},j);if(Z.verifications.gradients.push({gradientId:q.getAttribute("id")||"unknown",type:"linear",...X}),X.valid)Z.verifications.passed++;else Z.verifications.failed++,Z.verifications.allPassed=!1;q.setAttribute("x1",O.toFixed(J.precision)),q.setAttribute("y1",V.toFixed(J.precision)),q.setAttribute("x2",M.toFixed(J.precision)),q.setAttribute("y2",Y.toFixed(J.precision)),q.removeAttribute("gradientTransform"),Q++}catch(j){K.push(`linearGradient: ${j.message}`)}}let z=$.getElementsByTagName("radialGradient");for(let q of z){let W=q.getAttribute("gradientTransform");if(!W)continue;try{let j=$7(W),G=parseFloat(q.getAttribute("cx")||"0.5"),F=parseFloat(q.getAttribute("cy")||"0.5"),_=parseFloat(q.getAttribute("fx")||G.toString()),U=parseFloat(q.getAttribute("fy")||F.toString()),O=parseFloat(q.getAttribute("r")||"0.5");if(isNaN(G)||isNaN(F)||isNaN(_)||isNaN(U)||isNaN(O)){K.push(`radialGradient: invalid coordinate/radius values for gradient ${q.getAttribute("id")||"unknown"}`);continue}if(O<=0){K.push(`radialGradient: radius must be positive for gradient ${q.getAttribute("id")||"unknown"}`);continue}let[V,M]=c0(j,G,F),[Y,X]=c0(j,_,U),w=j.data[0][0].toNumber()*j.data[1][1].toNumber();if(Math.abs(w)<0.0000000001){K.push("radialGradient: matrix determinant too close to zero (degenerate transform)");continue}let R=Math.sqrt(Math.abs(w)),I=O*R;q.setAttribute("cx",V.toFixed(J.precision)),q.setAttribute("cy",M.toFixed(J.precision)),q.setAttribute("fx",Y.toFixed(J.precision)),q.setAttribute("fy",X.toFixed(J.precision)),q.setAttribute("r",I.toFixed(J.precision)),q.removeAttribute("gradientTransform"),Q++}catch(j){K.push(`radialGradient: ${j.message}`)}}return{count:Q,errors:K}}function gH($){if(!$||!$.getElementsByTagName)throw new Error("collectAllReferences: invalid root element");let J=new Set,Z=(K)=>{if(!K||!K.getAttributeNames)return;if(K.tagName&&K.tagName.toLowerCase()==="style"){let Q=K.textContent||"";if(Q)c6(Q).forEach((z)=>J.add(z))}for(let Q of K.getAttributeNames()){let H=K.getAttribute(Q);if(!H)continue;if(H.includes("url(")){let z=r7(H);if(z)J.add(z)}if(Q==="href"||Q==="xlink:href"){let z=H.replace(/^#/,"");if(z&&z!==H)J.add(z)}}for(let Q of K.children)if(Q&&Q.tagName)Z(Q)};return Z($),J}function xH($,J){if(!$||!$.getElementsByTagName)throw new Error("removeUnusedDefinitions: invalid root element");if(!J||!(J instanceof Set))throw new Error("removeUnusedDefinitions: referencedIds must be a Set");let Z=0;function K(H){if(!H||!H.getAttribute)return!1;let z=H.getAttribute("id");if(z&&J.has(z))return!0;for(let q of H.children||[])if(q&&q.tagName&&K(q))return!0;return!1}let Q=$.getElementsByTagName("defs");for(let H of Q)for(let z of[...H.children])if(z&&z.tagName){let q=z.tagName.toLowerCase();if(YK.has(q))continue;if(!K(z))H.removeChild(z),Z++}return{count:Z}}function w6($,J){if(!$||!$.tagName)return null;if(typeof J!=="number"||isNaN(J)||J<0)throw new Error(`getElementPathData: precision must be a non-negative number, got ${J}`);let Z=$.tagName.toLowerCase();if(Z==="path")return $.getAttribute("d");let K=(Q,H=0)=>{let z=$.getAttribute(Q);if(z===null)return H;let q=parseFloat(z);if(isNaN(q))throw new Error(`getElementPathData: invalid numeric value "${z}" for attribute "${Q}"`);return q};switch(Z){case"rect":{let H=$.getAttribute("ry")!==null?K("ry"):null;return L9(K("x"),K("y"),K("width"),K("height"),K("rx"),H,!1,J)}case"circle":return X9(K("cx"),K("cy"),K("r"),J);case"ellipse":return k9(K("cx"),K("cy"),K("rx"),K("ry"),J);case"line":return w9(K("x1"),K("y1"),K("x2"),K("y2"),J);case"polyline":return k$($.getAttribute("points")||"",J);case"polygon":return R9($.getAttribute("points")||"",J);default:return null}}function XK($){if(!$||!$.tagName)return null;let J=w6($,6);if(!J)return null;try{let Z=a7(J,10);if(!Z||Z.length===0)return null;let K=1/0,Q=1/0,H=-1/0,z=-1/0;for(let q of Z){if(!q||q.x===void 0&&q.y===void 0)continue;let W=q.x instanceof k?q.x.toNumber():typeof q.x==="number"?q.x:0,j=q.y instanceof k?q.y.toNumber():typeof q.y==="number"?q.y:0;if(isNaN(W)||isNaN(j))continue;if(W<K)K=W;if(j<Q)Q=j;if(W>H)H=W;if(j>z)z=j}if(K===1/0||H===-1/0||Q===1/0||z===-1/0)return null;return{x:K,y:Q,width:H-K,height:z-Q}}catch{return null}}function l6($){if(!$||!$.getAttribute)return{};let J=["stroke","stroke-width","stroke-linecap","stroke-linejoin","stroke-dasharray","stroke-dashoffset","stroke-miterlimit","stroke-opacity","vector-effect","fill","fill-opacity","fill-rule","clip-path","mask","filter","opacity","clip-rule","marker","marker-start","marker-mid","marker-end","visibility","display","color","font-family","font-size","font-weight","font-style","text-anchor","dominant-baseline","alignment-baseline","letter-spacing","word-spacing","text-decoration","shape-rendering","text-rendering","image-rendering","color-rendering","paint-order","pointer-events","cursor","class","style","id"],Z={};for(let K of J){let Q=$.getAttribute(K);if(Q!==null)Z[K]=Q}return Z}function mH($){if(!$||typeof $!=="string")return[];return{rect:["x","y","width","height","rx","ry"],circle:["cx","cy","r"],ellipse:["cx","cy","rx","ry"],line:["x1","y1","x2","y2"],polyline:["points"],polygon:["points"],image:["x","y","width","height","href","xlink:href","preserveAspectRatio"]}[$.toLowerCase()]||[]}function UK($){if(!$||!$.data||!Array.isArray($.data))throw new Error("matrixToTransform: invalid matrix");if(!$.data[0]||!$.data[1]||!$.data[0][0]||!$.data[0][1]||!$.data[0][2]||!$.data[1][0]||!$.data[1][1]||!$.data[1][2])throw new Error("matrixToTransform: matrix is missing required elements");let J=$.data[0][0].toNumber(),Z=$.data[1][0].toNumber(),K=$.data[0][1].toNumber(),Q=$.data[1][1].toNumber(),H=$.data[0][2].toNumber(),z=$.data[1][2].toNumber();if(!isFinite(J)||!isFinite(Z)||!isFinite(K)||!isFinite(Q)||!isFinite(H)||!isFinite(z))throw new Error("matrixToTransform: matrix contains non-finite values");return`matrix(${J} ${Z} ${K} ${Q} ${H} ${z})`}function kK($,J){if(!$||$.length<3||!J||J.length<3)return $;if(A7&&P7)try{return P7($,J)}catch(K){}let Z=[...$];for(let K=0;K<J.length;K++){if(Z.length===0)break;let Q=Z;Z=[];let H=J[K],z=J[(K+1)%J.length];for(let q=0;q<Q.length;q++){let W=Q[q],j=Q[(q+1)%Q.length],G=VK(W,H,z),F=VK(j,H,z);if(G){if(Z.push(W),!F)Z.push(MK(W,j,H,z))}else if(F)Z.push(MK(W,j,H,z))}}return Z}function VK($,J,Z){if(!$||$.x===void 0&&$.y===void 0)throw new Error("isInsideEdge: invalid point");if(!J||J.x===void 0&&J.y===void 0)throw new Error("isInsideEdge: invalid edgeStart");if(!Z||Z.x===void 0&&Z.y===void 0)throw new Error("isInsideEdge: invalid edgeEnd");let K=$.x instanceof k?$.x.toNumber():$.x||0,Q=$.y instanceof k?$.y.toNumber():$.y||0,H=J.x instanceof k?J.x.toNumber():J.x||0,z=J.y instanceof k?J.y.toNumber():J.y||0,q=Z.x instanceof k?Z.x.toNumber():Z.x||0,W=Z.y instanceof k?Z.y.toNumber():Z.y||0;return(q-H)*(Q-z)-(W-z)*(K-H)>=0}function MK($,J,Z,K){if(!$||$.x===void 0&&$.y===void 0)throw new Error("lineIntersect: invalid p1");if(!J||J.x===void 0&&J.y===void 0)throw new Error("lineIntersect: invalid p2");if(!Z||Z.x===void 0&&Z.y===void 0)throw new Error("lineIntersect: invalid p3");if(!K||K.x===void 0&&K.y===void 0)throw new Error("lineIntersect: invalid p4");let Q=$.x instanceof k?$.x.toNumber():$.x||0,H=$.y instanceof k?$.y.toNumber():$.y||0,z=J.x instanceof k?J.x.toNumber():J.x||0,q=J.y instanceof k?J.y.toNumber():J.y||0,W=Z.x instanceof k?Z.x.toNumber():Z.x||0,j=Z.y instanceof k?Z.y.toNumber():Z.y||0,G=K.x instanceof k?K.x.toNumber():K.x||0,F=K.y instanceof k?K.y.toNumber():K.y||0,_=(Q-z)*(j-F)-(H-q)*(W-G);if(Math.abs(_)<0.0000000001)return{x:X7((Q+z)/2),y:X7((H+q)/2)};let U=((Q-W)*(j-F)-(H-j)*(W-G))/_;return{x:X7(Q+U*(z-Q)),y:X7(H+U*(q-H))}}var q6=new Set(["clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cursor","direction","dominant-baseline","fill","fill-opacity","fill-rule","font","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","glyph-orientation-horizontal","glyph-orientation-vertical","image-rendering","letter-spacing","marker","marker-end","marker-mid","marker-start","paint-order","pointer-events","shape-rendering","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-anchor","text-rendering","visibility","word-spacing","writing-mode"]);var n6={animation:new Set(["animate","animateColor","animatecolor","animateMotion","animatemotion","animateTransform","animatetransform","set"]),descriptive:new Set(["desc","metadata","title"]),shape:new Set(["circle","ellipse","line","path","polygon","polyline","rect"]),structural:new Set(["defs","g","svg","symbol","use"]),paintServer:new Set(["hatch","linearGradient","lineargradient","meshGradient","meshgradient","pattern","radialGradient","radialgradient","solidColor","solidcolor"]),nonRendering:new Set(["clipPath","clippath","filter","linearGradient","lineargradient","marker","mask","pattern","radialGradient","radialgradient","solidColor","solidcolor","symbol"]),container:new Set(["a","defs","g","marker","mask","pattern","svg","switch","symbol"]),textContent:new Set(["altGlyph","altGlyphDef","altGlyphItem","glyph","glyphRef","text","textPath","tref","tspan"]),filterPrimitive:new Set(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence"]),lightSource:new Set(["feDistantLight","fePointLight","feSpotLight"])};var s6={svg:new Set(["a","altGlyphDef","animate","animateColor","animateMotion","animateTransform","circle","clipPath","cursor","defs","desc","ellipse","filter","font","font-face","foreignObject","g","image","line","linearGradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialGradient","rect","script","set","style","svg","switch","symbol","text","title","use","view"]),g:new Set(["a","animate","animateColor","animateMotion","animateTransform","circle","clipPath","cursor","defs","desc","ellipse","filter","font","font-face","foreignObject","g","image","line","linearGradient","marker","mask","metadata","path","pattern","polygon","polyline","radialGradient","rect","script","set","style","svg","switch","symbol","text","title","use","view"]),defs:new Set(["a","altGlyphDef","animate","animateColor","animateMotion","animateTransform","circle","clipPath","cursor","defs","desc","ellipse","filter","font","font-face","foreignObject","g","image","line","linearGradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialGradient","rect","script","set","style","svg","switch","symbol","text","title","use","view","meshgradient","meshGradient","hatch","solidcolor","solidColor"]),symbol:new Set(["a","animate","animateColor","animateMotion","animateTransform","circle","clipPath","cursor","defs","desc","ellipse","filter","font","font-face","foreignObject","g","image","line","linearGradient","marker","mask","metadata","path","pattern","polygon","polyline","radialGradient","rect","script","set","style","svg","switch","symbol","text","title","use","view"]),marker:new Set(["a","animate","animateColor","animateMotion","animateTransform","circle","clipPath","cursor","defs","desc","ellipse","filter","font","font-face","foreignObject","g","image","line","linearGradient","marker","mask","metadata","path","pattern","polygon","polyline","radialGradient","rect","script","set","style","svg","switch","symbol","text","title","use","view"]),clipPath:new Set(["animate","animateColor","animateMotion","animateTransform","circle","desc","ellipse","line","metadata","path","polygon","polyline","rect","set","text","title","use"]),mask:new Set(["a","animate","animateColor","animateMotion","animateTransform","circle","clipPath","cursor","defs","desc","ellipse","filter","font","font-face","foreignObject","g","image","line","linearGradient","marker","mask","metadata","path","pattern","polygon","polyline","radialGradient","rect","script","set","style","svg","switch","symbol","text","title","use","view"]),pattern:new Set(["a","animate","animateColor","animateMotion","animateTransform","circle","clipPath","cursor","defs","desc","ellipse","filter","font","font-face","foreignObject","g","image","line","linearGradient","marker","mask","metadata","path","pattern","polygon","polyline","radialGradient","rect","script","set","style","svg","switch","symbol","text","title","use","view"]),a:new Set(["a","animate","animateColor","animateMotion","animateTransform","circle","clipPath","cursor","defs","desc","ellipse","filter","font","font-face","foreignObject","g","image","line","linearGradient","marker","mask","metadata","path","pattern","polygon","polyline","radialGradient","rect","script","set","style","svg","switch","symbol","text","title","use","view"]),switch:new Set(["a","animate","animateColor","animateMotion","animateTransform","circle","cursor","desc","ellipse","foreignObject","g","image","line","metadata","path","polygon","polyline","rect","set","svg","switch","text","title","use","view"]),text:new Set(["a","altGlyph","animate","animateColor","animateMotion","animateTransform","desc","metadata","set","textPath","title","tref","tspan"]),textPath:new Set(["a","altGlyph","animate","animateColor","desc","metadata","set","title","tref","tspan"]),tspan:new Set(["a","altGlyph","animate","animateColor","desc","metadata","set","title","tref","tspan"]),linearGradient:new Set(["animate","animateTransform","desc","metadata","set","stop","title"]),radialGradient:new Set(["animate","animateTransform","desc","metadata","set","stop","title"]),meshgradient:new Set(["animate","animateTransform","desc","metadata","meshrow","set","title"]),meshGradient:new Set(["animate","animateTransform","desc","metadata","meshrow","set","title"]),meshrow:new Set(["meshpatch"]),meshpatch:new Set(["stop"]),hatch:new Set(["animate","animateTransform","desc","hatchpath","hatchPath","metadata","script","set","style","title"]),hatchpath:new Set(["animate","animateTransform","desc","metadata","script","set","title"]),hatchPath:new Set(["animate","animateTransform","desc","metadata","script","set","title"]),filter:new Set(["animate","animateTransform","desc","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","metadata","set","title"]),feBlend:new Set(["animate","set"]),feColorMatrix:new Set(["animate","set"]),feComponentTransfer:new Set(["feFuncA","feFuncB","feFuncG","feFuncR"]),feComposite:new Set(["animate","set"]),feConvolveMatrix:new Set(["animate","set"]),feDiffuseLighting:new Set(["animate","feDistantLight","fePointLight","feSpotLight","set"]),feDisplacementMap:new Set(["animate","set"]),feDropShadow:new Set(["animate","set"]),feFlood:new Set(["animate","set"]),feFuncA:new Set(["animate","set"]),feFuncB:new Set(["animate","set"]),feFuncG:new Set(["animate","set"]),feFuncR:new Set(["animate","set"]),feGaussianBlur:new Set(["animate","set"]),feImage:new Set(["animate","set"]),feMerge:new Set(["feMergeNode"]),feMergeNode:new Set(["animate","set"]),feMorphology:new Set(["animate","set"]),feOffset:new Set(["animate","set"]),feSpecularLighting:new Set(["animate","feDistantLight","fePointLight","feSpotLight","set"]),feTile:new Set(["animate","set"]),feTurbulence:new Set(["animate","set"]),animate:new Set(["desc","metadata","title"]),animateColor:new Set(["desc","metadata","title"]),animateMotion:new Set(["desc","metadata","mpath","title"]),animateTransform:new Set(["desc","metadata","title"]),set:new Set(["desc","metadata","title"]),circle:new Set(["animate","animateColor","animateMotion","animateTransform","desc","metadata","set","title"]),ellipse:new Set(["animate","animateColor","animateMotion","animateTransform","desc","metadata","set","title"]),line:new Set(["animate","animateColor","animateMotion","animateTransform","desc","metadata","set","title"]),path:new Set(["animate","animateColor","animateMotion","animateTransform","desc","metadata","set","title"]),polygon:new Set(["animate","animateColor","animateMotion","animateTransform","desc","metadata","set","title"]),polyline:new Set(["animate","animateColor","animateMotion","animateTransform","desc","metadata","set","title"]),rect:new Set(["animate","animateColor","animateMotion","animateTransform","desc","metadata","set","title"]),image:new Set(["animate","animateColor","animateMotion","animateTransform","desc","metadata","set","title"]),use:new Set(["animate","animateColor","animateMotion","animateTransform","desc","metadata","set","title"]),title:new Set([]),desc:new Set([]),metadata:new Set([]),feDistantLight:new Set(["animate","set"]),fePointLight:new Set(["animate","set"]),feSpotLight:new Set(["animate","set"]),stop:new Set(["animate","set"]),solidColor:new Set(["animate","animateColor","animateTransform","desc","metadata","set","title"]),solidcolor:new Set(["animate","animateColor","animateTransform","desc","metadata","set","title"]),tref:new Set(["animate","animateColor","desc","metadata","set","title"]),altGlyph:new Set(["animate","animateColor","desc","metadata","set","title"]),altGlyphDef:new Set(["altGlyphItem"]),altGlyphItem:new Set(["glyphRef","altGlyphItem"]),glyph:new Set(["animate","animateColor","animateMotion","animateTransform","circle","desc","ellipse","line","metadata","path","polygon","polyline","rect","set","title","use"]),glyphRef:new Set([]),foreignObject:new Set([]),style:new Set([]),script:new Set([]),view:new Set(["desc","metadata","title"]),mpath:new Set(["desc","metadata","title"])},LK={userAction:new Set([":hover",":active",":focus",":focus-within",":focus-visible"]),treeStructural:new Set([":root",":empty",":first-child",":last-child",":only-child",":first-of-type",":last-of-type",":only-of-type",":nth-child",":nth-last-child",":nth-of-type",":nth-last-of-type"]),link:new Set([":link",":visited",":any-link",":local-link",":target"]),input:new Set([":enabled",":disabled",":read-only",":read-write",":placeholder-shown",":default",":checked",":indeterminate",":valid",":invalid",":in-range",":out-of-range",":required",":optional"]),linguistic:new Set([":lang",":dir"]),functional:new Set([":not",":is",":where",":has"]),preventInlining:new Set([":hover",":active",":focus",":focus-within",":focus-visible",":visited",":target",":lang",":dir",":not",":is",":where",":has"])};k.set({precision:20,rounding:k.ROUND_HALF_UP});var d9={linear:[0,0,1,1],ease:[0.25,0.1,0.25,1],"ease-in":[0.42,0,1,1],"ease-out":[0,0,0.58,1],"ease-in-out":[0.42,0,0.58,1]};function o6($,J=3){if($===null||$===void 0)throw new Error("formatSplineValue: value parameter is required");if(typeof J!=="number"||J<0||!Number.isFinite(J))throw new Error("formatSplineValue: precision must be a non-negative finite number");let Z=typeof $==="number"?$:parseFloat($);if(!Number.isFinite(Z))throw new Error(`formatSplineValue: value must be a finite number, got ${$}`);let H=new k($).toDecimalPlaces(J).toString();if(H.includes("."))H=H.replace(/0+$/,""),H=H.replace(/\.$/,"");if(H.startsWith("0."))H=H.substring(1);else if(H.startsWith("-0."))H="-"+H.substring(2);if(H===""||H==="."||H==="-0")H="0";return H}function b$($){if(!$||typeof $!=="string")return[];return $.split(";").map((Z)=>Z.trim()).filter((Z)=>Z).map((Z)=>{let K=Z.split(/[\s,]+/).map((Q)=>parseFloat(Q)).filter((Q)=>Number.isFinite(Q));if(K.length!==4)throw new Error(`parseKeySplines: invalid spline "${Z}", expected 4 values, got ${K.length}`);return K})}function p9($,J=3){if(!Array.isArray($))throw new Error("serializeKeySplines: splines must be an array");if(typeof J!=="number"||J<0||!Number.isFinite(J))throw new Error("serializeKeySplines: precision must be a non-negative finite number");return $.map((Z,K)=>{if(!Array.isArray(Z))throw new Error(`serializeKeySplines: spline at index ${K} must be an array`);if(Z.length!==4)throw new Error(`serializeKeySplines: spline at index ${K} must have exactly 4 values, got ${Z.length}`);return Z.map((Q)=>o6(Q,J)).join(" ")}).join("; ")}function f$($,J=0.001){if(!Array.isArray($)||$.length!==4)return!1;if(typeof J!=="number"||J<0||!Number.isFinite(J))throw new Error("isLinearSpline: tolerance must be a non-negative finite number");let[Z,K,Q,H]=$;if(!Number.isFinite(Z)||!Number.isFinite(K)||!Number.isFinite(Q)||!Number.isFinite(H))return!1;return Math.abs(Z)<J&&Math.abs(K)<J&&Math.abs(Q-1)<J&&Math.abs(H-1)<J}function wK($){let J=b$($);if(J.length===0)return!1;return J.every((Z)=>f$(Z))}function c9($,J=0.01){if(!Array.isArray($)||$.length!==4)return null;if(typeof J!=="number"||J<0||!Number.isFinite(J))throw new Error("identifyStandardEasing: tolerance must be a non-negative finite number");if(!$.every((Z)=>Number.isFinite(Z)))return null;for(let[Z,K]of Object.entries(d9))if($.every((H,z)=>Math.abs(H-K[z])<J))return Z;return null}function l9($,J={}){let Z=J.precision??3,K=J.removeLinear!==!1,Q=b$($);if(Q.length===0)return{value:null,allLinear:!1,standardEasings:[]};let H=Q.every((W)=>f$(W)),z=Q.map((W)=>c9(W)).filter(Boolean);if(H&&K)return{value:null,allLinear:!0,standardEasings:z};return{value:p9(Q,Z),allLinear:H,standardEasings:z}}function dH($){if(!$||typeof $!=="string")return[];return $.split(";").map((J)=>parseFloat(J.trim())).filter((J)=>Number.isFinite(J))}function pH($,J=3){if(!Array.isArray($))throw new Error("serializeKeyTimes: times must be an array");if(typeof J!=="number"||J<0||!Number.isFinite(J))throw new Error("serializeKeyTimes: precision must be a non-negative finite number");if($.length===0)return"";return $.map((Z)=>o6(Z,J)).join("; ")}function n9($,J=3){if($===null||$===void 0)throw new Error("optimizeKeyTimes: keyTimes parameter is required");if(typeof J!=="number"||J<0||!Number.isFinite(J))throw new Error("optimizeKeyTimes: precision must be a non-negative finite number");let Z=dH($);if(Z.length===0)return $;return pH(Z,J)}function T$($,J=3){if(!$||typeof $!=="string")return $;if(typeof J!=="number"||J<0||!Number.isFinite(J))throw new Error("optimizeAnimationValues: precision must be a non-negative finite number");let Z=$.split(";");if(Z.length===0)return $;return Z.map((Q)=>{let H=Q.trim();if(H.startsWith("#")||H.includes("url("))return H;return H.split(/[\s,]+/).filter((W)=>W).map((W)=>{let j=parseFloat(W);if(!Number.isFinite(j))return W;return o6(j,J)}).join(" ")}).join("; ")}function cH($,J={}){if(!$||typeof $!=="object")throw new Error("optimizeElementTiming: el parameter must be a valid element");if(typeof $.getAttribute!=="function"||typeof $.setAttribute!=="function"||typeof $.removeAttribute!=="function")throw new Error("optimizeElementTiming: el parameter must have getAttribute, setAttribute, and removeAttribute methods");let Z=J.precision??3,K=J.removeLinearSplines!==!1,Q=J.optimizeValues!==!1;if(typeof Z!=="number"||Z<0||!Number.isFinite(Z))throw new Error("optimizeElementTiming: options.precision must be a non-negative finite number");let H=[],z=!1,q=$.getAttribute("keySplines");if(q){let j=l9(q,{precision:Z,removeLinear:K});if(j.allLinear&&K){if($.getAttribute("calcMode")==="spline")$.setAttribute("calcMode","linear"),$.removeAttribute("keySplines"),H.push('Converted linear splines to calcMode="linear"'),z=!0}else if(j.value&&j.value!==q)$.setAttribute("keySplines",j.value),H.push(`keySplines: "${q}" -> "${j.value}"`),z=!0}let W=$.getAttribute("keyTimes");if(W){let j=n9(W,Z);if(j!==W)$.setAttribute("keyTimes",j),H.push(`keyTimes: "${W}" -> "${j}"`),z=!0}if(Q){let j=$.getAttribute("values");if(j){let G=T$(j,Z);if(G!==j)$.setAttribute("values",G),H.push(`values: "${j}" -> "${G}"`),z=!0}}for(let j of["from","to","by"]){let G=$.getAttribute(j);if(G){let F=T$(G,Z);if(F!==G)$.setAttribute(j,F),H.push(`${j}: "${G}" -> "${F}"`),z=!0}}return{modified:z,changes:H}}var lH=["animate","animatetransform","animatemotion","animatecolor","set"];function RK($,J={}){if(!$||typeof $!=="object")throw new Error("optimizeDocumentAnimationTiming: root parameter must be a valid element");let Z=0,K=0,Q=[],H=(z)=>{if(!z||typeof z!=="object")return;let q=z.tagName?.toLowerCase();if(!q)return;if(lH.includes(q)){let j=cH(z,J);if(j.modified)Z++,K+=j.changes.length,Q.push({element:q,id:z.getAttribute("id")||null,changes:j.changes})}let W=z.children||[];for(let j of W)H(j)};return H($),{elementsModified:Z,totalChanges:K,details:Q}}var o9={M:2,m:2,L:2,l:2,H:1,h:1,V:1,v:1,C:6,c:6,S:4,s:4,Q:4,q:4,T:2,t:2,A:7,a:7,Z:0,z:0};function nH($){if(typeof $!=="string")throw new TypeError(`parseArcArgs: argsStr must be a string, got ${typeof $}`);let J=[],Z=/-?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/g,K=0,Q=0;while(K<$.length){while(K<$.length&&/[\s,]/.test($[K]))K++;if(K>=$.length)break;let H=Q%7;if(H===3||H===4)if($[K]==="0"||$[K]==="1")J.push($[K]==="1"?1:0),K++,Q++;else return null;else{Z.lastIndex=K;let z=Z.exec($);if(z&&z.index===K)J.push(parseFloat(z[0])),K=Z.lastIndex,Q++;else K++}}return J}function l0($){if(!$||typeof $!=="string")return[];let J=[],Z=/([MmLlHhVvCcSsQqTtAaZz])([^MmLlHhVvCcSsQqTtAaZz]*)/g,K;while((K=Z.exec($))!==null){let Q=K[1],H=K[2].trim();if(Q==="Z"||Q==="z"){J.push({command:"Z",args:[]});let W=H.match(/-?\d*\.?\d+(?:[eE][+-]?\d+)?/g);if(W&&W.length>=2){J.push({command:"M",args:[parseFloat(W[0]),parseFloat(W[1])]});for(let j=2;j+1<W.length;j+=2)J.push({command:"L",args:[parseFloat(W[j]),parseFloat(W[j+1])]})}continue}let z;if(Q==="A"||Q==="a"){if(z=nH(H),z===null){console.warn(`Invalid arc command with malformed flags - skipping: ${Q}${H}`);continue}for(let W=0;W<z.length;W+=7)if(W+6<z.length)z[W]=Math.abs(z[W]),z[W+1]=Math.abs(z[W+1])}else{let W=/-?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/g;z=[];let j;while((j=W.exec(H))!==null)z.push(parseFloat(j[0]))}let q=o9[Q];if(q===void 0){console.warn(`Unknown SVG path command '${Q}' - skipping`);continue}if(q===0||z.length===0)J.push({command:Q,args:[]});else for(let W=0;W<z.length;W+=q){let j=z.slice(W,W+q);if(j.length===q){let G=W>0&&(Q==="M"||Q==="m")?Q==="M"?"L":"l":Q;J.push({command:G,args:j})}else if(j.length>0)console.warn(`Incomplete ${Q} command: expected ${q} args, got ${j.length} - remaining args dropped`)}}return J}function T7($,J=3){if(typeof $!=="number")throw new TypeError(`formatNumber: num must be a number, got ${typeof $}`);if(typeof J!=="number"||!Number.isInteger(J)||J<0)throw new TypeError(`formatNumber: precision must be a non-negative integer, got ${J}`);if(!isFinite($))return"0";if($===0)return"0";let Z=Math.pow(10,J),Q=(Math.round($*Z)/Z).toFixed(J);if(Q.includes("."))Q=Q.replace(/\.?0+$/,"");if(Q.startsWith("0."))Q=Q.substring(1);else if(Q.startsWith("-0."))Q="-"+Q.substring(2);if(Q===""||Q==="."||Q==="-.")Q="0";return Q}function k7($,J,Z){if(!$||typeof $!=="object")throw new TypeError(`toAbsolute: cmd must be an object, got ${typeof $}`);if(typeof $.command!=="string")throw new TypeError(`toAbsolute: cmd.command must be a string, got ${typeof $.command}`);if(!Array.isArray($.args))throw new TypeError("toAbsolute: cmd.args must be an array");if(typeof J!=="number"||!isFinite(J))throw new TypeError(`toAbsolute: cx must be a finite number, got ${J}`);if(typeof Z!=="number"||!isFinite(Z))throw new TypeError(`toAbsolute: cy must be a finite number, got ${Z}`);let{command:K,args:Q}=$;if(K===K.toUpperCase()){if(o9[K]===void 0)throw new TypeError(`toAbsolute: unknown command '${K}'`);return $}let H=K.toUpperCase(),z=[...Q];switch(K){case"m":case"l":case"t":if(z.length<2)throw new RangeError(`toAbsolute: command ${K} requires at least 2 args, got ${z.length}`);z[0]+=J,z[1]+=Z;break;case"h":if(z.length<1)throw new RangeError(`toAbsolute: command ${K} requires at least 1 arg, got ${z.length}`);z[0]+=J;break;case"v":if(z.length<1)throw new RangeError(`toAbsolute: command ${K} requires at least 1 arg, got ${z.length}`);z[0]+=Z;break;case"c":if(z.length<6)throw new RangeError(`toAbsolute: command ${K} requires at least 6 args, got ${z.length}`);z[0]+=J,z[1]+=Z,z[2]+=J,z[3]+=Z,z[4]+=J,z[5]+=Z;break;case"s":case"q":if(z.length<4)throw new RangeError(`toAbsolute: command ${K} requires at least 4 args, got ${z.length}`);z[0]+=J,z[1]+=Z,z[2]+=J,z[3]+=Z;break;case"a":if(z.length<7)throw new RangeError(`toAbsolute: command ${K} requires at least 7 args, got ${z.length}`);z[5]+=J,z[6]+=Z;break;default:throw new TypeError(`toAbsolute: unsupported command '${K}' for conversion`)}return{command:H,args:z}}function i9($,J,Z){if(!$||typeof $!=="object")throw new TypeError(`toRelative: cmd must be an object, got ${typeof $}`);if(typeof $.command!=="string")throw new TypeError(`toRelative: cmd.command must be a string, got ${typeof $.command}`);if(!Array.isArray($.args))throw new TypeError("toRelative: cmd.args must be an array");if(typeof J!=="number"||!isFinite(J))throw new TypeError(`toRelative: cx must be a finite number, got ${J}`);if(typeof Z!=="number"||!isFinite(Z))throw new TypeError(`toRelative: cy must be a finite number, got ${Z}`);let{command:K,args:Q}=$;if(K===K.toLowerCase()&&K!=="z"){if(o9[K]===void 0)throw new TypeError(`toRelative: unknown command '${K}'`);return $}if(K==="Z"||K==="z")return{command:"z",args:[]};let H=K.toLowerCase(),z=[...Q];switch(K){case"M":case"L":case"T":if(z.length<2)throw new RangeError(`toRelative: command ${K} requires at least 2 args, got ${z.length}`);z[0]-=J,z[1]-=Z;break;case"H":if(z.length<1)throw new RangeError(`toRelative: command ${K} requires at least 1 arg, got ${z.length}`);z[0]-=J;break;case"V":if(z.length<1)throw new RangeError(`toRelative: command ${K} requires at least 1 arg, got ${z.length}`);z[0]-=Z;break;case"C":if(z.length<6)throw new RangeError(`toRelative: command ${K} requires at least 6 args, got ${z.length}`);z[0]-=J,z[1]-=Z,z[2]-=J,z[3]-=Z,z[4]-=J,z[5]-=Z;break;case"S":case"Q":if(z.length<4)throw new RangeError(`toRelative: command ${K} requires at least 4 args, got ${z.length}`);z[0]-=J,z[1]-=Z,z[2]-=J,z[3]-=Z;break;case"A":if(z.length<7)throw new RangeError(`toRelative: command ${K} requires at least 7 args, got ${z.length}`);z[5]-=J,z[6]-=Z;break;default:throw new TypeError(`toRelative: unsupported command '${K}' for conversion`)}return{command:H,args:z}}function sH($,J,Z,K=0.000001){if(!$||typeof $!=="object")throw new TypeError(`lineToHV: cmd must be an object, got ${typeof $}`);if(typeof $.command!=="string")throw new TypeError(`lineToHV: cmd.command must be a string, got ${typeof $.command}`);if(!Array.isArray($.args))throw new TypeError("lineToHV: cmd.args must be an array");if(typeof J!=="number"||!isFinite(J))throw new TypeError(`lineToHV: cx must be a finite number, got ${J}`);if(typeof Z!=="number"||!isFinite(Z))throw new TypeError(`lineToHV: cy must be a finite number, got ${Z}`);if(typeof K!=="number"||!isFinite(K)||K<0)throw new TypeError(`lineToHV: tolerance must be a non-negative finite number, got ${K}`);let{command:Q,args:H}=$;if(Q!=="L"&&Q!=="l")return null;if(H.length<2)throw new RangeError(`lineToHV: command ${Q} requires at least 2 args, got ${H.length}`);let z=Q==="L",q=z?H[0]:J+H[0],W=z?H[1]:Z+H[1];if(Math.abs(W-Z)<K)return z?{command:"H",args:[q]}:{command:"h",args:[q-J]};if(Math.abs(q-J)<K)return z?{command:"V",args:[W]}:{command:"v",args:[W-Z]};return null}function oH($,J,Z,K,Q,H=0.000001){if(!$||typeof $!=="object")throw new TypeError(`lineToZ: cmd must be an object, got ${typeof $}`);if(typeof $.command!=="string")throw new TypeError(`lineToZ: cmd.command must be a string, got ${typeof $.command}`);if(!Array.isArray($.args))throw new TypeError("lineToZ: cmd.args must be an array");if(typeof J!=="number"||!isFinite(J))throw new TypeError(`lineToZ: cx must be a finite number, got ${J}`);if(typeof Z!=="number"||!isFinite(Z))throw new TypeError(`lineToZ: cy must be a finite number, got ${Z}`);if(typeof K!=="number"||!isFinite(K))throw new TypeError(`lineToZ: startX must be a finite number, got ${K}`);if(typeof Q!=="number"||!isFinite(Q))throw new TypeError(`lineToZ: startY must be a finite number, got ${Q}`);if(typeof H!=="number"||!isFinite(H)||H<0)throw new TypeError(`lineToZ: tolerance must be a non-negative finite number, got ${H}`);let{command:z,args:q}=$;if(z!=="L"&&z!=="l")return!1;if(q.length<2)throw new RangeError(`lineToZ: command ${z} requires at least 2 args, got ${q.length}`);let W=z==="L",j=W?q[0]:J+q[0],G=W?q[1]:Z+q[1];return Math.abs(j-K)<H&&Math.abs(G-Q)<H}function iH($,J,Z,K,Q,H,z,q,W=0.5){let j={x0:$,y0:J,cp1x:Z,cp1y:K,cp2x:Q,cp2y:H,x3:z,y3:q,tolerance:W};for(let[O,V]of Object.entries(j))if(typeof V!=="number"||!isFinite(V))throw new TypeError(`isCurveStraight: ${O} must be a finite number, got ${V}`);if(W<0)throw new TypeError(`isCurveStraight: tolerance must be non-negative, got ${W}`);let G=(z-$)**2+(q-J)**2;if(G<0.0000000001){let O=Math.sqrt((Z-$)**2+(K-J)**2),V=Math.sqrt((Q-$)**2+(H-J)**2);return Math.max(O,V)<W}let F=Math.sqrt(G),_=Math.abs((q-J)*Z-(z-$)*K+z*J-q*$)/F,U=Math.abs((q-J)*Q-(z-$)*H+z*J-q*$)/F;return Math.max(_,U)<W}function rH($,J,Z,K=0.5){if(!$||typeof $!=="object")throw new TypeError(`straightCurveToLine: cmd must be an object, got ${typeof $}`);if(typeof $.command!=="string")throw new TypeError(`straightCurveToLine: cmd.command must be a string, got ${typeof $.command}`);if(!Array.isArray($.args))throw new TypeError("straightCurveToLine: cmd.args must be an array");if(typeof J!=="number"||!isFinite(J))throw new TypeError(`straightCurveToLine: cx must be a finite number, got ${J}`);if(typeof Z!=="number"||!isFinite(Z))throw new TypeError(`straightCurveToLine: cy must be a finite number, got ${Z}`);if(typeof K!=="number"||!isFinite(K)||K<0)throw new TypeError(`straightCurveToLine: tolerance must be a non-negative finite number, got ${K}`);let{command:Q,args:H}=$;if(Q!=="C"&&Q!=="c")return null;if(H.length<6)throw new RangeError(`straightCurveToLine: command ${Q} requires at least 6 args, got ${H.length}`);let z=Q==="C",q=z?H[0]:J+H[0],W=z?H[1]:Z+H[1],j=z?H[2]:J+H[2],G=z?H[3]:Z+H[3],F=z?H[4]:J+H[4],_=z?H[5]:Z+H[5];if(iH(J,Z,q,W,j,G,F,_,K))return z?{command:"L",args:[F,_]}:{command:"l",args:[F-J,_-Z]};return null}function s9($,J,Z=3,K=!1){if(!$||typeof $!=="object")throw new TypeError(`serializeCommand: cmd must be an object, got ${typeof $}`);if(typeof $.command!=="string")throw new TypeError(`serializeCommand: cmd.command must be a string, got ${typeof $.command}`);if(!Array.isArray($.args))throw new TypeError("serializeCommand: cmd.args must be an array");if(J!==null&&typeof J!=="string")throw new TypeError(`serializeCommand: prevCommand must be a string or null, got ${typeof J}`);if(typeof Z!=="number"||!Number.isInteger(Z)||Z<0)throw new TypeError(`serializeCommand: precision must be a non-negative integer, got ${Z}`);if(typeof K!=="boolean")throw new TypeError(`serializeCommand: prevLastArgHadDecimal must be a boolean, got ${typeof K}`);let{command:Q,args:H}=$;if(Q==="Z"||Q==="z")return{str:"z",lastArgHadDecimal:!1};if(Q==="A"||Q==="a"){if(H.length<7)throw new RangeError(`serializeCommand: arc command requires at least 7 args, got ${H.length}`);if(H.length>7)console.warn(`serializeCommand: arc command has ${H.length} args (expected 7) - only first 7 will be used`);let F=[T7(H[0],Z),T7(H[1],Z),T7(H[2],Z),H[3]?"1":"0",H[4]?"1":"0",T7(H[5],Z),T7(H[6],Z)].join(" ");return{str:Q+F,lastArgHadDecimal:F.includes(".")}}if(H.length===0)throw new RangeError(`serializeCommand: command ${Q} has empty args array (only Z/z should have no args)`);let z=H.map((F)=>T7(F,Z)),q="";for(let F=0;F<z.length;F++){let _=z[F];if(F===0)q=_;else{let O=z[F-1].includes(".");if(_.startsWith("-"))q+=_;else if(_.startsWith(".")&&O)q+=_;else q+=" "+_}}let j=(z[z.length-1]||"").includes("."),G=Q;if(J==="M"&&Q==="L")G="";else if(J==="m"&&Q==="l")G="";else if(J===Q&&Q!=="A"&&Q!=="a")G="";if(G)return{str:G+q,lastArgHadDecimal:j};else{let F=z[0]||"";if(F.startsWith("-"))return{str:q,lastArgHadDecimal:j};else if(F.startsWith(".")&&K)return{str:q,lastArgHadDecimal:j};else return{str:" "+q,lastArgHadDecimal:j}}}function n0($,J=3){if(!Array.isArray($))throw new TypeError(`serializePath: commands must be an array, got ${typeof $}`);if(typeof J!=="number"||!Number.isInteger(J)||J<0)throw new TypeError(`serializePath: precision must be a non-negative integer, got ${J}`);if($.length===0)return"";let Z="",K=null,Q=!1;for(let H of $){let{str:z,lastArgHadDecimal:q}=s9(H,K,J,Q);Z+=z,K=H.command,Q=q}return Z}function r9($,J={}){if(typeof $!=="string")throw new TypeError(`convertPathData: d must be a string, got ${typeof $}`);if(typeof J!=="object"||J===null||Array.isArray(J))throw new TypeError(`convertPathData: options must be an object, got ${typeof J}`);let{floatPrecision:Z=3,straightCurves:K=!0,lineShorthands:Q=!0,convertToZ:H=!0,utilizeAbsolute:z=!0,straightTolerance:q=0.5}=J;if(typeof Z!=="number"||!Number.isInteger(Z)||Z<0)throw new TypeError(`convertPathData: floatPrecision must be a non-negative integer, got ${Z}`);if(typeof K!=="boolean")throw new TypeError(`convertPathData: straightCurves must be a boolean, got ${typeof K}`);if(typeof Q!=="boolean")throw new TypeError(`convertPathData: lineShorthands must be a boolean, got ${typeof Q}`);if(typeof H!=="boolean")throw new TypeError(`convertPathData: convertToZ must be a boolean, got ${typeof H}`);if(typeof z!=="boolean")throw new TypeError(`convertPathData: utilizeAbsolute must be a boolean, got ${typeof z}`);if(typeof q!=="number"||!isFinite(q)||q<0)throw new TypeError(`convertPathData: straightTolerance must be a non-negative finite number, got ${q}`);let W=$.length,j=l0($);if(j.length===0)return{d:$,originalLength:W,optimizedLength:W,savings:0};let G=0,F=0,_=0,U=0,O=[];for(let M=0;M<j.length;M++){let Y=j[M];if(Y.command==="A"||Y.command==="a"){if(Y.args.length<7)console.warn(`Arc command has insufficient args (${Y.args.length} < 7) - skipping optimization`);else if(Y.args[0]===0||Y.args[1]===0){let w=Y.command==="A",R=Y.args[5],I=Y.args[6];Y=w?{command:"L",args:[R,I]}:{command:"l",args:[R,I]}}}if(K&&(Y.command==="C"||Y.command==="c")){let w=rH(Y,G,F,q);if(w)Y=w}if(Q&&(Y.command==="L"||Y.command==="l")){let w=sH(Y,G,F);if(w)Y=w}if(H&&(Y.command==="L"||Y.command==="l")){if(oH(Y,G,F,_,U))Y={command:"z",args:[]}}if(z&&Y.command!=="Z"&&Y.command!=="z"){let w=k7(Y,G,F),R=i9(Y,G,F),I=s9(w,null,Z);Y=s9(R,null,Z).str.length<I.str.length?R:w}O.push(Y);let X=k7(Y,G,F);switch(X.command){case"M":if(X.args.length>=2)G=X.args[0],F=X.args[1],_=G,U=F;break;case"L":case"T":if(X.args.length>=2)G=X.args[0],F=X.args[1];break;case"H":if(X.args.length>=1)G=X.args[0];break;case"V":if(X.args.length>=1)F=X.args[0];break;case"C":if(X.args.length>=6)G=X.args[4],F=X.args[5];break;case"S":case"Q":if(X.args.length>=4)G=X.args[2],F=X.args[3];break;case"A":if(X.args.length>=7)G=X.args[5],F=X.args[6];break;case"Z":G=_,F=U;break;default:break}}let V=n0(O,Z);return{d:V,originalLength:W,optimizedLength:V.length,savings:W-V.length}}function BK($,J={}){if(!$||typeof $!=="object")throw new TypeError(`optimizeDocumentPaths: root must be a DOM element object, got ${typeof $}`);if(typeof J!=="object"||J===null||Array.isArray(J))throw new TypeError(`optimizeDocumentPaths: options must be an object, got ${typeof J}`);let Z=0,K=0,Q=[],H=(z)=>{if(!z||typeof z!=="object")return;if(z.tagName?.toLowerCase()==="path"){let W=z.getAttribute("d");if(W){let j=r9(W,J);if(j.savings>0)z.setAttribute("d",j.d),Z++,K+=j.savings,Q.push({id:z.getAttribute("id")||null,originalLength:j.originalLength,optimizedLength:j.optimizedLength,savings:j.savings})}}for(let W of z.children||[])H(W)};return H($),{pathsOptimized:Z,totalSavings:K,details:Q}}function NK($,J,Z){if(!$||typeof $.x!=="number"||typeof $.y!=="number")throw new TypeError("perpendicularDistance: point must be an object with numeric x and y properties");if(!J||typeof J.x!=="number"||typeof J.y!=="number")throw new TypeError("perpendicularDistance: lineStart must be an object with numeric x and y properties");if(!Z||typeof Z.x!=="number"||typeof Z.y!=="number")throw new TypeError("perpendicularDistance: lineEnd must be an object with numeric x and y properties");if(!Number.isFinite($.x)||!Number.isFinite($.y)||!Number.isFinite(J.x)||!Number.isFinite(J.y)||!Number.isFinite(Z.x)||!Number.isFinite(Z.y))throw new RangeError("perpendicularDistance: all coordinates must be finite numbers");let K=Z.x-J.x,Q=Z.y-J.y,H=K*K+Q*Q;if(H<0.0000000001){let W=$.x-J.x,j=$.y-J.y;return Math.sqrt(W*W+j*j)}let z=Math.abs(Q*$.x-K*$.y+Z.x*J.y-Z.y*J.x),q=Math.sqrt(H);return z/q}function i6($,J){if(!Array.isArray($))throw new TypeError("douglasPeucker: points must be an array");if($.length===0)throw new RangeError("douglasPeucker: points array cannot be empty");for(let z=0;z<$.length;z++){let q=$[z];if(!q||typeof q!=="object")throw new TypeError(`douglasPeucker: point at index ${z} must be an object`);if(typeof q.x!=="number"||!Number.isFinite(q.x))throw new TypeError(`douglasPeucker: point at index ${z} must have a finite numeric x property`);if(typeof q.y!=="number"||!Number.isFinite(q.y))throw new TypeError(`douglasPeucker: point at index ${z} must have a finite numeric y property`)}if(typeof J!=="number"||!Number.isFinite(J))throw new TypeError("douglasPeucker: tolerance must be a finite number");if(J<0)throw new RangeError("douglasPeucker: tolerance cannot be negative");if(J>0&&J<0.0000000001)throw new RangeError("douglasPeucker: tolerance must be either 0 or >= 1e-10 to avoid numerical precision issues");if($.length<=2)return $;if($.length>1e4)return aH($,J);let Z=0,K=0,Q=$[0],H=$[$.length-1];for(let z=1;z<$.length-1;z++){let q=NK($[z],Q,H);if(q>Z)Z=q,K=z}if(Z>J){let z=i6($.slice(0,K+1),J),q=i6($.slice(K),J);return z.slice(0,-1).concat(q)}else return[Q,H]}function aH($,J){if($.length<=2)return $;let Z=new Array($.length).fill(!1);Z[0]=!0,Z[$.length-1]=!0;let K=[[0,$.length-1]];while(K.length>0){let[Q,H]=K.pop();if(H-Q<=1)continue;let z=0,q=Q,W=$[Q],j=$[H];for(let G=Q+1;G<H;G++){let F=NK($[G],W,j);if(F>z)z=F,q=G}if(z>J)Z[q]=!0,K.push([Q,q]),K.push([q,H])}return $.filter((Q,H)=>Z[H])}function a9($,J){if(!Array.isArray($))throw new TypeError("visvalingamWhyatt: points must be an array");if($.length===0)throw new RangeError("visvalingamWhyatt: points array cannot be empty");for(let q=0;q<$.length;q++){let W=$[q];if(!W||typeof W!=="object")throw new TypeError(`visvalingamWhyatt: point at index ${q} must be an object`);if(typeof W.x!=="number"||!Number.isFinite(W.x))throw new TypeError(`visvalingamWhyatt: point at index ${q} must have a finite numeric x property`);if(typeof W.y!=="number"||!Number.isFinite(W.y))throw new TypeError(`visvalingamWhyatt: point at index ${q} must have a finite numeric y property`)}if(typeof J!=="number"||!Number.isFinite(J))throw new TypeError("visvalingamWhyatt: minArea must be a finite number");if(J<0)throw new RangeError("visvalingamWhyatt: minArea cannot be negative");if($.length<=2)return $;let Z=(q,W,j)=>{return Math.abs((W.x-q.x)*(j.y-q.y)-(j.x-q.x)*(W.y-q.y))/2},K=$.map((q,W)=>({...q,index:W})),Q=new Array(K.length).fill(1/0);for(let q=1;q<K.length-1;q++)Q[q]=Z(K[q-1],K[q],K[q+1]);let H=new Array(K.length).fill(!0),z=K.length;while(z>2){let q=1/0,W=-1;for(let F=1;F<K.length-1;F++)if(H[F]&&Q[F]<q)q=Q[F],W=F;if(q>=J||W===-1)break;H[W]=!1,z--;let j=W-1;while(j>=0&&!H[j])j--;let G=W+1;while(G<K.length&&!H[G])G++;if(j>0){let F=j-1;while(F>=0&&!H[F])F--;if(F>=0&&G<K.length)Q[j]=Z(K[F],K[j],K[G])}if(G<K.length-1){let F=G+1;while(F<K.length&&!H[F])F++;if(F<K.length&&j>=0)Q[G]=Z(K[j],K[G],K[F])}}return K.filter((q,W)=>H[W])}function t9($,J,Z="douglas-peucker"){if(!Array.isArray($))throw new TypeError("simplifyPolyline: points must be an array");if($.length===0)throw new RangeError("simplifyPolyline: points array cannot be empty");if(typeof J!=="number"||!Number.isFinite(J))throw new TypeError("simplifyPolyline: tolerance must be a finite number");if(J<0)throw new RangeError("simplifyPolyline: tolerance cannot be negative");if(J>0&&J<0.0000000001)throw new RangeError("simplifyPolyline: tolerance must be either 0 or >= 1e-10 to avoid numerical precision issues");if(typeof Z!=="string")throw new TypeError("simplifyPolyline: algorithm must be a string");let K=["douglas-peucker","visvalingam"];if(!K.includes(Z))throw new RangeError(`simplifyPolyline: algorithm must be one of: ${K.join(", ")}`);if(Z==="visvalingam")return a9($,J*J);return i6($,J)}function tH($){if(!Array.isArray($))throw new TypeError("extractPolylinePoints: commands must be an array");let J=[],Z=0,K=0,Q=0,H=0;for(let z of $){if(!z||typeof z!=="object")throw new TypeError("extractPolylinePoints: each command must be an object");if(typeof z.command!=="string")throw new TypeError('extractPolylinePoints: each command must have a string "command" property');if(!Array.isArray(z.args))throw new TypeError('extractPolylinePoints: each command must have an "args" array');let{command:q,args:W}=z,j=(F)=>{if(W.length<F)throw new RangeError(`extractPolylinePoints: command "${q}" requires at least ${F} arguments, got ${W.length}`)},G=(F)=>{if(typeof W[F]!=="number"||!Number.isFinite(W[F]))throw new TypeError(`extractPolylinePoints: command "${q}" argument at index ${F} must be a finite number, got ${W[F]}`)};switch(q){case"M":j(2),G(0),G(1),Z=W[0],K=W[1],Q=Z,H=K,J.push({x:Z,y:K});break;case"m":j(2),G(0),G(1),Z+=W[0],K+=W[1],Q=Z,H=K,J.push({x:Z,y:K});break;case"L":j(2),G(0),G(1),Z=W[0],K=W[1],J.push({x:Z,y:K});break;case"l":j(2),G(0),G(1),Z+=W[0],K+=W[1],J.push({x:Z,y:K});break;case"H":j(1),G(0),Z=W[0],J.push({x:Z,y:K});break;case"h":j(1),G(0),Z+=W[0],J.push({x:Z,y:K});break;case"V":j(1),G(0),K=W[0],J.push({x:Z,y:K});break;case"v":j(1),G(0),K+=W[0],J.push({x:Z,y:K});break;case"Z":case"z":if(Z!==Q||K!==H)J.push({x:Q,y:H});Z=Q,K=H;break;case"C":j(6),G(4),G(5),Z=W[4],K=W[5];break;case"c":j(6),G(4),G(5),Z+=W[4],K+=W[5];break;case"S":case"Q":j(4),G(2),G(3),Z=W[2],K=W[3];break;case"s":case"q":j(4),G(2),G(3),Z+=W[2],K+=W[3];break;case"T":j(2),G(0),G(1),Z=W[0],K=W[1];break;case"t":j(2),G(0),G(1),Z+=W[0],K+=W[1];break;case"A":j(7),G(5),G(6),Z=W[5],K=W[6];break;case"a":j(7),G(5),G(6),Z+=W[5],K+=W[6];break;default:break}}return J}function eH($,J=!1){if(!Array.isArray($))throw new TypeError("rebuildPathFromPoints: points must be an array");if($.length===0)return[];if(typeof J!=="boolean")throw new TypeError("rebuildPathFromPoints: closed must be a boolean");for(let K=0;K<$.length;K++){let Q=$[K];if(!Q||typeof Q!=="object")throw new TypeError(`rebuildPathFromPoints: point at index ${K} must be an object`);if(typeof Q.x!=="number"||!Number.isFinite(Q.x))throw new TypeError(`rebuildPathFromPoints: point at index ${K} must have a finite numeric x property`);if(typeof Q.y!=="number"||!Number.isFinite(Q.y))throw new TypeError(`rebuildPathFromPoints: point at index ${K} must have a finite numeric y property`)}let Z=[];Z.push({command:"M",args:[$[0].x,$[0].y]});for(let K=1;K<$.length;K++)Z.push({command:"L",args:[$[K].x,$[K].y]});if(J)Z.push({command:"Z",args:[]});return Z}function e9($){if(!Array.isArray($))throw new TypeError("isPurePolyline: commands must be an array");let J=new Set(["M","m","L","l","H","h","V","v","Z","z"]);return $.every((Z)=>{if(!Z||typeof Z!=="object"||typeof Z.command!=="string")return!1;return J.has(Z.command)})}function $8($,J,Z="douglas-peucker"){if(!Array.isArray($))throw new TypeError("simplifyPath: commands must be an array");if(typeof J!=="number"||!Number.isFinite(J))throw new TypeError("simplifyPath: tolerance must be a finite number");if(J<0)throw new RangeError("simplifyPath: tolerance cannot be negative");if(J>0&&J<0.0000000001)throw new RangeError("simplifyPath: tolerance must be either 0 or >= 1e-10 to avoid numerical precision issues");if(!e9($)||$.length<3)return{commands:$,simplified:!1,originalPoints:0,simplifiedPoints:0};let K=tH($),Q=K.length;if(Q<3)return{commands:$,simplified:!1,originalPoints:Q,simplifiedPoints:Q};let H=$[$.length-1].command.toLowerCase()==="z";if(H&&K.length>1){let j=K[0],G=K[K.length-1];if(Math.abs(G.x-j.x)<0.0000000001&&Math.abs(G.y-j.y)<0.0000000001)K=K.slice(0,-1)}let z=t9(K,J,Z),q=z.length;if(q>=Q)return{commands:$,simplified:!1,originalPoints:Q,simplifiedPoints:Q};return{commands:eH(z,H),simplified:!0,originalPoints:Q,simplifiedPoints:q}}function Q7($){if(typeof $!=="string")throw new TypeError("Path d must be a string")}function H7($){if(typeof $!=="number"||!Number.isFinite($)||$<0)throw new TypeError(`Precision must be a finite non-negative number, got ${$}`)}function t7($){if(typeof $!=="number"||!Number.isFinite($)||$<0)throw new TypeError(`Tolerance must be a finite non-negative number, got ${$}`)}function z7($,J=0){if(!$||typeof $!=="object")throw new TypeError("Command must be an object");if(typeof $.command!=="string")throw new TypeError("Command must have a string 'command' property");if(!Array.isArray($.args))throw new TypeError("Command must have an array 'args' property");if($.args.length<J)throw new TypeError(`Command ${$.command} requires at least ${J} args, got ${$.args.length}`);for(let Z=0;Z<$.args.length;Z++)if(typeof $.args[Z]!=="number"||!Number.isFinite($.args[Z]))throw new TypeError(`Command ${$.command} arg[${Z}] must be a finite number, got ${$.args[Z]}`)}function v$($,J=3){Q7($),H7(J);let Z=l0($);if(Z.length===0)return $;Z.forEach((Q)=>z7(Q));let K=Z.map((Q)=>({command:Q.command,args:Q.args.map((H)=>{let z=T7(H,J),q=parseFloat(z);if(!Number.isFinite(q))throw new Error(`Invalid numeric value encountered: ${z}`);return q})}));return n0(K,J)}function D$($,J=3){Q7($),H7(J);let Z=l0($);if(Z.length===0)return $;return Z.forEach((K)=>z7(K)),n0(Z,J)}function h$($,J=3){Q7($),H7(J);let Z=l0($);if(Z.length===0)return $;Z.forEach((W)=>z7(W));let K=0,Q=0,H=0,z=0,q=[];for(let W of Z){let j=i9(W,K,Q);q.push(j);let G=k7(W,K,Q);switch(G.command){case"M":K=G.args[0],Q=G.args[1],H=K,z=Q;break;case"L":case"T":K=G.args[0],Q=G.args[1];break;case"H":K=G.args[0];break;case"V":Q=G.args[0];break;case"C":K=G.args[4],Q=G.args[5];break;case"S":case"Q":K=G.args[2],Q=G.args[3];break;case"A":K=G.args[5],Q=G.args[6];break;case"Z":K=H,Q=z;break;default:break}}return n0(q,J)}function y$($,J=3){Q7($),H7(J);let Z=l0($);if(Z.length===0)return $;Z.forEach((W)=>z7(W));let K=0,Q=0,H=0,z=0,q=[];for(let W of Z){let j=k7(W,K,Q);switch(q.push(j),j.command){case"M":K=j.args[0],Q=j.args[1],H=K,z=Q;break;case"L":case"T":K=j.args[0],Q=j.args[1];break;case"H":K=j.args[0];break;case"V":Q=j.args[0];break;case"C":K=j.args[4],Q=j.args[5];break;case"S":case"Q":K=j.args[2],Q=j.args[3];break;case"A":K=j.args[5],Q=j.args[6];break;case"Z":K=H,Q=z;break;default:break}}return n0(q,J)}function u$($,J=0.000001,Z=3){Q7($),t7(J),H7(Z);let K=l0($);if(K.length===0)return $;K.forEach((j)=>z7(j));let Q=0,H=0,z=0,q=0,W=[];for(let j of K){let G=j;if(j.command==="L"||j.command==="l"){let _=j.command==="L",U=_?j.args[0]:Q+j.args[0],O=_?j.args[1]:H+j.args[1];if(Math.abs(O-H)<J)G=_?{command:"H",args:[U]}:{command:"h",args:[U-Q]};else if(Math.abs(U-Q)<J)G=_?{command:"V",args:[O]}:{command:"v",args:[O-H]}}W.push(G);let F=k7(G,Q,H);switch(F.command){case"M":Q=F.args[0],H=F.args[1],z=Q,q=H;break;case"L":case"T":Q=F.args[0],H=F.args[1];break;case"H":Q=F.args[0];break;case"V":H=F.args[0];break;case"C":Q=F.args[4],H=F.args[5];break;case"S":case"Q":Q=F.args[2],H=F.args[3];break;case"A":Q=F.args[5],H=F.args[6];break;case"Z":Q=z,H=q;break;default:break}}return n0(W,Z)}function g$($,J=0.000001,Z=3){Q7($),t7(J),H7(Z);let K=l0($);if(K.length===0)return $;K.forEach((j)=>z7(j));let Q=0,H=0,z=0,q=0,W=[];for(let j=0;j<K.length;j++){let G=K[j],F=G;if(G.command==="L"||G.command==="l"){let U=G.command==="L",O=U?G.args[0]:Q+G.args[0],V=U?G.args[1]:H+G.args[1];if((j===K.length-1||K[j+1].command==="M"||K[j+1].command==="m")&&Math.abs(O-z)<J&&Math.abs(V-q)<J)F={command:"z",args:[]}}W.push(F);let _=k7(F,Q,H);switch(_.command){case"M":Q=_.args[0],H=_.args[1],z=Q,q=H;break;case"L":case"T":Q=_.args[0],H=_.args[1];break;case"H":Q=_.args[0];break;case"V":H=_.args[0];break;case"C":Q=_.args[4],H=_.args[5];break;case"S":case"Q":Q=_.args[2],H=_.args[3];break;case"A":Q=_.args[5],H=_.args[6];break;case"Z":Q=z,H=q;break;default:break}}return n0(W,Z)}function B6(...$){for(let J=0;J<$.length;J++)if(typeof $[J]!=="number"||!Number.isFinite($[J]))throw new TypeError(`Coordinate at position ${J} must be a finite number, got ${$[J]}`)}function IK($){if(typeof $!=="number"||!Number.isFinite($))throw new TypeError(`Parameter t must be a finite number, got ${$}`);if($<0||$>1)throw new RangeError(`Parameter t must be in range [0, 1], got ${$}`)}function S$($,J,Z,K,Q,H,z,q,W){IK($),B6(J,Z,K,Q,H,z,q,W);let j=1-$,G=j*j,F=G*j,_=$*$,U=_*$;return{x:F*J+3*G*$*K+3*j*_*H+U*q,y:F*Z+3*G*$*Q+3*j*_*z+U*W}}function J8($,J,Z,K,Q,H){B6($,J,Z,K,Q,H);let z=Q-Z,q=H-K,W=z*z+q*q;if(W<0.0000000001)return Math.sqrt(($-Z)**2+(J-K)**2);let j=Math.max(0,Math.min(1,(($-Z)*z+(J-K)*q)/W)),G=Z+j*z,F=K+j*q;return Math.sqrt(($-G)**2+(J-F)**2)}function $z($,J,Z,K,Q,H,z,q){B6($,J,Z,K,Q,H,z,q);let W=0,j=[0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9];for(let G of j){let F=S$(G,$,J,Z,K,Q,H,z,q),_=J8(F.x,F.y,$,J,z,q);if(_>W)W=_}for(let G=0;G<j.length-1;G++){let F=(j[G]+j[G+1])/2,_=S$(F,$,J,Z,K,Q,H,z,q),U=J8(_.x,_.y,$,J,z,q);if(U>W)W=U}for(let G of[0.05,0.95]){let F=S$(G,$,J,Z,K,Q,H,z,q),_=J8(F.x,F.y,$,J,z,q);if(_>W)W=_}return W}function Jz($,J,Z,K,Q,H,z,q,W){return $z($,J,Z,K,Q,H,z,q)<=W}function x$($,J=0.5,Z=3){Q7($),t7(J),H7(Z);let K=l0($);if(K.length===0)return $;K.forEach((j)=>z7(j));let Q=0,H=0,z=0,q=0,W=[];for(let j of K){let G=j;if(j.command==="C"||j.command==="c"){let _=j.command==="C",U=_?j.args[0]:Q+j.args[0],O=_?j.args[1]:H+j.args[1],V=_?j.args[2]:Q+j.args[2],M=_?j.args[3]:H+j.args[3],Y=_?j.args[4]:Q+j.args[4],X=_?j.args[5]:H+j.args[5];if(Jz(Q,H,U,O,V,M,Y,X,J))G=_?{command:"L",args:[Y,X]}:{command:"l",args:[Y-Q,X-H]}}W.push(G);let F=k7(G,Q,H);switch(F.command){case"M":Q=F.args[0],H=F.args[1],z=Q,q=H;break;case"L":case"T":Q=F.args[0],H=F.args[1];break;case"H":Q=F.args[0];break;case"V":H=F.args[0];break;case"C":Q=F.args[4],H=F.args[5];break;case"S":case"Q":Q=F.args[2],H=F.args[3];break;case"A":Q=F.args[5],H=F.args[6];break;case"Z":Q=z,H=q;break;default:break}}return n0(W,Z)}function m$($,J=3){Q7($),H7(J);let Z=l0($);if(Z.length===0)return $;return Z.forEach((K)=>z7(K)),n0(Z,J)}function d$($,J=3){if(Q7($),H7(J),J>15)throw new RangeError(`Precision ${J} is too large (max 15)`);let Z=l0($);if(Z.length===0)return $;Z.forEach((H)=>z7(H));let K=Math.pow(10,J),Q=Z.map((H)=>({command:H.command,args:H.args.map((z)=>Math.round(z*K)/K)}));return n0(Q,J)}function p$($,J=0.000001,Z=3){Q7($),t7(J),H7(Z);let K=l0($);if(K.length===0)return $;K.forEach((j)=>z7(j));let Q=0,H=0,z=0,q=0,W=[];for(let j of K){let G=k7(j,Q,H),F=!0;switch(G.command){case"L":case"T":if(Math.abs(G.args[0]-Q)<J&&Math.abs(G.args[1]-H)<J)F=!1;break;case"H":if(Math.abs(G.args[0]-Q)<J)F=!1;break;case"V":if(Math.abs(G.args[0]-H)<J)F=!1;break;case"C":if(Math.abs(G.args[4]-Q)<J&&Math.abs(G.args[5]-H)<J&&Math.abs(G.args[0]-Q)<J&&Math.abs(G.args[1]-H)<J&&Math.abs(G.args[2]-Q)<J&&Math.abs(G.args[3]-H)<J)F=!1;break;case"S":if(Math.abs(G.args[2]-Q)<J&&Math.abs(G.args[3]-H)<J&&Math.abs(G.args[0]-Q)<J&&Math.abs(G.args[1]-H)<J)F=!1;break;case"Q":if(Math.abs(G.args[2]-Q)<J&&Math.abs(G.args[3]-H)<J&&Math.abs(G.args[0]-Q)<J&&Math.abs(G.args[1]-H)<J)F=!1;break;case"A":if(Math.abs(G.args[5]-Q)<J&&Math.abs(G.args[6]-H)<J||Math.abs(G.args[0])<J||Math.abs(G.args[1])<J)F=!1;break;default:break}if(F)switch(W.push(j),G.command){case"M":Q=G.args[0],H=G.args[1],z=Q,q=H;break;case"L":case"T":Q=G.args[0],H=G.args[1];break;case"H":Q=G.args[0];break;case"V":H=G.args[0];break;case"C":Q=G.args[4],H=G.args[5];break;case"S":case"Q":Q=G.args[2],H=G.args[3];break;case"A":Q=G.args[5],H=G.args[6];break;case"Z":Q=z,H=q;break;default:break}}return n0(W,Z)}function Kz($,J,Z,K,Q,H,z){IK($),B6(J,Z,K,Q,H,z);let q=1-$,W=q*q,j=$*$;return{x:W*J+2*q*$*K+j*H,y:W*Z+2*q*$*Q+j*z}}function Zz($,J,Z,K,Q,H,z,q,W,j){B6($,J,Z,K,Q,H,z,q,W,j);let G=0,F=[0.05,0.1,0.15,0.2,0.25,0.3,0.35,0.4,0.45,0.5,0.55,0.6,0.65,0.7,0.75,0.8,0.85,0.9,0.95];for(let _ of F){let U=S$(_,$,J,Z,K,Q,H,z,q),O=Kz(_,$,J,W,j,z,q),V=Math.sqrt((U.x-O.x)**2+(U.y-O.y)**2);if(V>G)G=V}return G}function Qz($,J,Z,K,Q,H,z,q,W){B6($,J,Z,K,Q,H,z,q),t7(W);let j=(3*(Z+Q)-$-z)/4,G=(3*(K+H)-J-q)/4;if(Zz($,J,Z,K,Q,H,z,q,j,G)<=W)return{cpx:j,cpy:G};return null}function c$($,J=0.5,Z=3){Q7($),t7(J),H7(Z);let K=l0($);if(K.length===0)return $;K.forEach((j)=>z7(j));let Q=0,H=0,z=0,q=0,W=[];for(let j of K){let G=j;if(j.command==="C"||j.command==="c"){let _=j.command==="C",U=_?j.args[0]:Q+j.args[0],O=_?j.args[1]:H+j.args[1],V=_?j.args[2]:Q+j.args[2],M=_?j.args[3]:H+j.args[3],Y=_?j.args[4]:Q+j.args[4],X=_?j.args[5]:H+j.args[5],w=Qz(Q,H,U,O,V,M,Y,X,J);if(w)G=_?{command:"Q",args:[w.cpx,w.cpy,Y,X]}:{command:"q",args:[w.cpx-Q,w.cpy-H,Y-Q,X-H]}}W.push(G);let F=k7(G,Q,H);switch(F.command){case"M":Q=F.args[0],H=F.args[1],z=Q,q=H;break;case"L":case"T":Q=F.args[0],H=F.args[1];break;case"H":Q=F.args[0];break;case"V":H=F.args[0];break;case"C":Q=F.args[4],H=F.args[5];break;case"S":case"Q":Q=F.args[2],H=F.args[3];break;case"A":Q=F.args[5],H=F.args[6];break;case"Z":Q=z,H=q;break;default:break}}return n0(W,Z)}function l$($,J=0.000001,Z=3){Q7($),t7(J),H7(Z);let K=l0($);if(K.length===0)return $;K.forEach((F)=>z7(F));let Q=0,H=0,z=0,q=0,W=null,j=null,G=[];for(let F of K){let _=F,U=k7(F,Q,H);if(U.command==="Q"&&W!==null){let O=2*Q-W,V=2*H-j;if(Math.abs(U.args[0]-O)<J&&Math.abs(U.args[1]-V)<J)_=F.command==="Q"?{command:"T",args:[U.args[2],U.args[3]]}:{command:"t",args:[U.args[2]-Q,U.args[3]-H]}}if(G.push(_),U.command==="Q")W=U.args[0],j=U.args[1];else if(U.command==="T")if(W!==null)W=2*Q-W,j=2*H-j;else W=Q,j=H;else W=null,j=null;switch(U.command){case"M":Q=U.args[0],H=U.args[1],z=Q,q=H;break;case"L":case"T":Q=U.args[0],H=U.args[1];break;case"H":Q=U.args[0];break;case"V":H=U.args[0];break;case"C":Q=U.args[4],H=U.args[5];break;case"S":case"Q":Q=U.args[2],H=U.args[3];break;case"A":Q=U.args[5],H=U.args[6];break;case"Z":Q=z,H=q;break;default:break}}return n0(G,Z)}function n$($,J=0.000001,Z=3){Q7($),t7(J),H7(Z);let K=l0($);if(K.length===0)return $;K.forEach((F)=>z7(F));let Q=0,H=0,z=0,q=0,W=null,j=null,G=[];for(let F of K){let _=F,U=k7(F,Q,H);if(U.command==="C"&&W!==null){let O=2*Q-W,V=2*H-j;if(Math.abs(U.args[0]-O)<J&&Math.abs(U.args[1]-V)<J)_=F.command==="C"?{command:"S",args:[U.args[2],U.args[3],U.args[4],U.args[5]]}:{command:"s",args:[U.args[2]-Q,U.args[3]-H,U.args[4]-Q,U.args[5]-H]}}if(G.push(_),U.command==="C")W=U.args[2],j=U.args[3];else if(U.command==="S")W=U.args[0],j=U.args[1];else W=null,j=null;switch(U.command){case"M":Q=U.args[0],H=U.args[1],z=Q,q=H;break;case"L":case"T":Q=U.args[0],H=U.args[1];break;case"H":Q=U.args[0];break;case"V":H=U.args[0];break;case"C":Q=U.args[4],H=U.args[5];break;case"S":case"Q":Q=U.args[2],H=U.args[3];break;case"A":Q=U.args[5],H=U.args[6];break;case"Z":Q=z,H=q;break;default:break}}return n0(G,Z)}function s$($,J=3){Q7($),H7(J);let Z=l0($);if(Z.length===0)return $;Z.forEach((Q)=>z7(Q));let K=Z.map((Q)=>{if(Q.command==="A"||Q.command==="a"){let H=[...Q.args];if(H.length!==7)throw new Error(`Arc command requires 7 arguments, got ${H.length}`);if(H[2]=(H[2]%360+360)%360,Math.abs(H[0]-H[1])<0.000001)H[2]=0;return H[3]=H[3]?1:0,H[4]=H[4]?1:0,{command:Q.command,args:H}}return Q});return n0(K,J)}var G6=new Set(["a","altGlyph","altGlyphDef","altGlyphItem","animate","animateColor","animateMotion","animateTransform","circle","clipPath","color-profile","cursor","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","font","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignObject","g","glyph","glyphRef","hkern","image","line","linearGradient","marker","mask","metadata","missing-glyph","mpath","path","pattern","polygon","polyline","radialGradient","rect","script","set","stop","style","svg","switch","symbol","text","textPath","title","tref","tspan","use","view","vkern"]),H8=new Set([...G6].map(($)=>$.toLowerCase())),F6=new Set(["accent-height","accumulate","additive","alignment-baseline","alphabetic","amplitude","arabic-form","ascent","attributeName","attributeType","azimuth","baseFrequency","baseline-shift","baseProfile","bbox","begin","bias","by","calcMode","cap-height","class","clip","clip-path","clip-rule","clipPathUnits","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","contentScriptType","contentStyleType","cursor","cx","cy","d","descent","diffuseConstant","direction","display","divisor","dominant-baseline","dur","dx","dy","edgeMode","elevation","enable-background","end","exponent","externalResourcesRequired","fill","fill-opacity","fill-rule","filter","filterRes","filterUnits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","format","from","fx","fy","g1","g2","glyph-name","glyph-orientation-horizontal","glyph-orientation-vertical","glyphRef","gradientTransform","gradientUnits","hanging","height","horiz-adv-x","horiz-origin-x","horiz-origin-y","href","id","ideographic","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kernelMatrix","kernelUnitLength","kerning","keyPoints","keySplines","keyTimes","lang","lengthAdjust","letter-spacing","lighting-color","limitingConeAngle","local","marker-end","marker-mid","marker-start","markerHeight","markerUnits","markerWidth","mask","maskContentUnits","maskUnits","mathematical","max","media","method","min","mode","name","numOctaves","offset","onabort","onactivate","onbegin","onclick","onend","onerror","onfocusin","onfocusout","onload","onmousedown","onmousemove","onmouseout","onmouseover","onmouseup","onrepeat","onresize","onscroll","onunload","onzoom","opacity","operator","order","orient","orientation","origin","overflow","overline-position","overline-thickness","panose-1","path","pathLength","patternContentUnits","patternTransform","patternUnits","pointer-events","points","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","r","radius","refX","refY","rendering-intent","repeatCount","repeatDur","requiredExtensions","requiredFeatures","restart","result","rotate","rx","ry","scale","seed","shape-rendering","slope","spacing","specularConstant","specularExponent","spreadMethod","startOffset","stdDeviation","stemh","stemv","stitchTiles","stop-color","stop-opacity","strikethrough-position","strikethrough-thickness","string","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","surfaceScale","systemLanguage","tableValues","target","targetX","targetY","text-anchor","text-decoration","text-rendering","textLength","title","to","transform","type","u1","u2","underline-position","underline-thickness","unicode","unicode-bidi","unicode-range","units-per-em","v-alphabetic","v-hanging","v-ideographic","v-mathematical","values","version","vert-adv-y","vert-origin-x","vert-origin-y","viewBox","viewTarget","visibility","width","widths","word-spacing","writing-mode","x","x-height","x1","x2","xChannelSelector","xlink:actuate","xlink:arcrole","xlink:href","xlink:role","xlink:show","xlink:title","xlink:type","xml:base","xml:id","xml:lang","xml:space","xmlns","xmlns:xlink","y","y1","y2","yChannelSelector","z","zoomAndPan","line-height","marker"]),z8=new Set([...F6].map(($)=>$.toLowerCase())),Ez=new Set(["mesh","meshgradient","meshpatch","meshrow","solidcolor","hatch","hatchpath","discard","unknown","canvas","video","audio","iframe","source","track"]),Tz=new Set(["href","tabindex","lang","transform-origin","vector-effect","paint-order","pathLength","fr","side","crossorigin","role","aria-label","aria-labelledby","aria-describedby","aria-hidden","aria-controls","aria-expanded","aria-haspopup","aria-live","aria-atomic","aria-relevant","aria-busy","aria-owns"]),bz=($)=>{if(!$||typeof $!=="string")return!1;return Ez.has($.toLowerCase())},fz=($)=>{if(!$||typeof $!=="string")return!1;let J=$.toLowerCase();return Tz.has(J)||J.startsWith("aria-")||J.startsWith("data-")},TK=new Set(["foreignobject","script","style","title","desc","metadata"]),o$=new Map,Sz=($,J)=>{if(typeof $!=="string"||typeof J!=="string")throw new Error("Both parameters must be strings");let Z=`${$}|${J}`;if(o$.has(Z))return o$.get(Z);if($.length===0)return J.length;if(J.length===0)return $.length;let K=[];for(let H=0;H<=J.length;H++)K[H]=[H];for(let H=0;H<=$.length;H++)K[0][H]=H;for(let H=1;H<=J.length;H++)for(let z=1;z<=$.length;z++){let q=$[z-1]===J[H-1]?0:1;K[H][z]=Math.min(K[H-1][z]+1,K[H][z-1]+1,K[H-1][z-1]+q)}let Q=K[J.length][$.length];return o$.set(Z,Q),Q},vz=()=>o$.clear(),C6=($,J,Z=2)=>{if(!$||typeof $!=="string")return null;if(!J||!(J instanceof Set)||J.size===0)return null;let K=typeof Z!=="number"||Z<0?2:Z,Q=$.toLowerCase(),H=null,z=K+1;for(let q of J){let W=Sz(Q,q.toLowerCase());if(W>0&&W<z)z=W,H=q}return H};function m7($){if(!$||typeof $!=="string")return!1;return/(%|em|rem|px|pt|cm|mm|in|pc|ex|ch|vw|vh|vmin|vmax|Q)$/i.test($.trim())}function Dz($,J,Z=100){let K=new Set,Q=$,H=0;while(Q!==null&&Q!==void 0&&H<Z){if(K.has(Q))return!0;K.add(Q),Q=J(Q),H++}return H>=Z}function bK($){if(!$||typeof $!=="string")return $||"";return $.replace(/<(script|style)([^>]*)\sdata-cdata-pending="true"([^>]*)>([\s\S]*?)<\/\1>/gi,(J,Z,K,Q,H)=>{let z=H.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").replace(/&quot;/g,'"').replace(/&#39;/g,"'"),q=(K+Q).replace(/\s*data-cdata-pending="true"\s*/g," ").trim(),W=q?" "+q:"";return`<${Z}${W}><![CDATA[
17
+ `;y5.appendFileSync(this.logToFile,$),this._buffer=[]}catch{this._buffer=[]}},error($,...J){if(this.level<c6.ERROR)return;let Z=this._format("ERROR",$),K=J.length?" "+J.map((Q)=>this._safeStringify(Q)).join(" "):"";console.error(Z,...J),this._bufferWrite(Z+K),this.flush()},warn($,...J){if(this.level<c6.WARN)return;let Z=this._format("WARN",$),K=J.length?" "+J.map((Q)=>this._safeStringify(Q)).join(" "):"";console.warn(Z,...J),this._bufferWrite(Z+K)},info($,...J){if(this.level<c6.INFO)return;let Z=this._format("INFO",$),K=J.length?" "+J.map((Q)=>this._safeStringify(Q)).join(" "):"";console.log(Z,...J),this._bufferWrite(Z+K)},debug($,...J){if(this.level<c6.DEBUG)return;let Z=this._format("DEBUG",$),K=J.length?" "+J.map((Q)=>this._safeStringify(Q)).join(" "):"";console.log(Z,...J),this._bufferWrite(Z+K)},shutdown(){if(this._flushTimer)clearInterval(this._flushTimer),this._flushTimer=null;this.flush()}};var zH=J7;L.set({precision:80});var _0=($)=>$ instanceof L?$:new L($),m5=20;function $6($,J=m5){if(typeof $!=="string")throw new Error("pathToPolygon: pathData must be a string");if(typeof J!=="number"||J<=0||!Number.isFinite(J))throw new Error(`pathToPolygon: samplesPerCurve must be a positive finite number, got ${J}`);let Z=[],K=_0(0),Q=_0(0),H=_0(0),z=_0(0),q=qH($);if(!Array.isArray(q))throw new Error("pathToPolygon: parsePathCommands must return an array");for(let j of q){let{type:W,args:G}=j;if(!Array.isArray(G))throw new Error(`pathToPolygon: command args must be an array for command ${W}`);switch(W){case"M":if(G.length<2)throw new Error(`pathToPolygon: M command requires 2 arguments, got ${G.length}`);K=_0(G[0]),Q=_0(G[1]),H=K,z=Q,Z.push(f0(K,Q));break;case"m":if(G.length<2)throw new Error(`pathToPolygon: m command requires 2 arguments, got ${G.length}`);K=K.plus(G[0]),Q=Q.plus(G[1]),H=K,z=Q,Z.push(f0(K,Q));break;case"L":if(G.length<2)throw new Error(`pathToPolygon: L command requires 2 arguments, got ${G.length}`);K=_0(G[0]),Q=_0(G[1]),Z.push(f0(K,Q));break;case"l":if(G.length<2)throw new Error(`pathToPolygon: l command requires 2 arguments, got ${G.length}`);K=K.plus(G[0]),Q=Q.plus(G[1]),Z.push(f0(K,Q));break;case"H":if(G.length<1)throw new Error(`pathToPolygon: H command requires 1 argument, got ${G.length}`);K=_0(G[0]),Z.push(f0(K,Q));break;case"h":if(G.length<1)throw new Error(`pathToPolygon: h command requires 1 argument, got ${G.length}`);K=K.plus(G[0]),Z.push(f0(K,Q));break;case"V":if(G.length<1)throw new Error(`pathToPolygon: V command requires 1 argument, got ${G.length}`);Q=_0(G[0]),Z.push(f0(K,Q));break;case"v":if(G.length<1)throw new Error(`pathToPolygon: v command requires 1 argument, got ${G.length}`);Q=Q.plus(G[0]),Z.push(f0(K,Q));break;case"C":if(G.length<6)throw new Error(`pathToPolygon: C command requires 6 arguments, got ${G.length}`);u5(Z,K,Q,_0(G[0]),_0(G[1]),_0(G[2]),_0(G[3]),_0(G[4]),_0(G[5]),J),K=_0(G[4]),Q=_0(G[5]);break;case"c":if(G.length<6)throw new Error(`pathToPolygon: c command requires 6 arguments, got ${G.length}`);u5(Z,K,Q,K.plus(G[0]),Q.plus(G[1]),K.plus(G[2]),Q.plus(G[3]),K.plus(G[4]),Q.plus(G[5]),J),K=K.plus(G[4]),Q=Q.plus(G[5]);break;case"Q":if(G.length<4)throw new Error(`pathToPolygon: Q command requires 4 arguments, got ${G.length}`);g5(Z,K,Q,_0(G[0]),_0(G[1]),_0(G[2]),_0(G[3]),J),K=_0(G[2]),Q=_0(G[3]);break;case"q":if(G.length<4)throw new Error(`pathToPolygon: q command requires 4 arguments, got ${G.length}`);g5(Z,K,Q,K.plus(G[0]),Q.plus(G[1]),K.plus(G[2]),Q.plus(G[3]),J),K=K.plus(G[2]),Q=Q.plus(G[3]);break;case"A":if(G.length<7)throw new Error(`pathToPolygon: A command requires 7 arguments, got ${G.length}`);x5(Z,K,Q,_0(G[0]),_0(G[1]),_0(G[2]),G[3],G[4],_0(G[5]),_0(G[6]),J),K=_0(G[5]),Q=_0(G[6]);break;case"a":if(G.length<7)throw new Error(`pathToPolygon: a command requires 7 arguments, got ${G.length}`);x5(Z,K,Q,_0(G[0]),_0(G[1]),_0(G[2]),G[3],G[4],K.plus(G[5]),Q.plus(G[6]),J),K=K.plus(G[5]),Q=Q.plus(G[6]);break;case"Z":case"z":K=H,Q=z;break;default:break}}return WH(Z)}function qH($){if(typeof $!=="string")throw new Error(`parsePathCommands: pathData must be a string, got ${typeof $}`);let J=[],Z=/([MmLlHhVvCcSsQqTtAaZz])([^MmLlHhVvCcSsQqTtAaZz]*)/g,K;while((K=Z.exec($))!==null){let Q=K[1],H=K[2].trim(),z=/-?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/g,q=H.length>0?Array.from(H.matchAll(z),(j)=>Number(j[0])):[];J.push({type:Q,args:q})}return J}function u5($,J,Z,K,Q,H,z,q,j,W){if(!Array.isArray($))throw new Error("sampleCubicBezier: points must be an array");if(typeof W!=="number"||W<=0||!Number.isFinite(W))throw new Error(`sampleCubicBezier: samples must be a positive finite number, got ${W}`);if(!(J instanceof L)||!(Z instanceof L)||!(K instanceof L)||!(Q instanceof L)||!(H instanceof L)||!(z instanceof L)||!(q instanceof L)||!(j instanceof L))throw new Error("sampleCubicBezier: all coordinate parameters must be Decimal instances");for(let G=1;G<=W;G++){let F=_0(G).div(W),_=_0(1).minus(F),U=_.mul(_),M=U.mul(_),V=F.mul(F),Y=V.mul(F),O=M.mul(J).plus(_0(3).mul(U).mul(F).mul(K)).plus(_0(3).mul(_).mul(V).mul(H)).plus(Y.mul(q)),X=M.mul(Z).plus(_0(3).mul(U).mul(F).mul(Q)).plus(_0(3).mul(_).mul(V).mul(z)).plus(Y.mul(j));$.push(f0(O,X))}}function g5($,J,Z,K,Q,H,z,q){if(!Array.isArray($))throw new Error("sampleQuadraticBezier: points must be an array");if(typeof q!=="number"||q<=0||!Number.isFinite(q))throw new Error(`sampleQuadraticBezier: samples must be a positive finite number, got ${q}`);if(!(J instanceof L)||!(Z instanceof L)||!(K instanceof L)||!(Q instanceof L)||!(H instanceof L)||!(z instanceof L))throw new Error("sampleQuadraticBezier: all coordinate parameters must be Decimal instances");for(let j=1;j<=q;j++){let W=_0(j).div(q),G=_0(1).minus(W),F=G.mul(G),_=W.mul(W),U=F.mul(J).plus(_0(2).mul(G).mul(W).mul(K)).plus(_.mul(H)),M=F.mul(Z).plus(_0(2).mul(G).mul(W).mul(Q)).plus(_.mul(z));$.push(f0(U,M))}}function x5($,J,Z,K,Q,H,z,q,j,W,G){if(!Array.isArray($))throw new Error("sampleArc: points must be an array");if(typeof G!=="number"||G<=0||!Number.isFinite(G))throw new Error(`sampleArc: samples must be a positive finite number, got ${G}`);if(!(J instanceof L)||!(Z instanceof L)||!(K instanceof L)||!(Q instanceof L)||!(H instanceof L)||!(j instanceof L)||!(W instanceof L))throw new Error("sampleArc: all coordinate and angle parameters must be Decimal instances");if(typeof z!=="number"||z!==0&&z!==1)throw new Error(`sampleArc: largeArc must be 0 or 1, got ${z}`);if(typeof q!=="number"||q!==0&&q!==1)throw new Error(`sampleArc: sweep must be 0 or 1, got ${q}`);if(K.eq(0)||Q.eq(0)){$.push(f0(j,W));return}let F=K.abs(),_=Q.abs(),U=H.mul(Math.PI).div(180),M=U.cos(),V=U.sin(),Y=J.minus(j).div(2),O=Z.minus(W).div(2),X=M.mul(Y).plus(V.mul(O)),w=M.mul(O).minus(V.mul(Y)),R=F.mul(F),B=_.mul(_),I=X.mul(X),h=w.mul(w),m=I.div(R).plus(h.div(B));if(m.gt(1)){let $0=m.sqrt();F=F.mul($0),_=_.mul($0),R=F.mul(F),B=_.mul(_)}let v=R.mul(B).minus(R.mul(h)).minus(B.mul(I));if(v=v.div(R.mul(h).plus(B.mul(I))),v.lt(0))v=_0(0);if(v=v.sqrt(),z===q)v=v.neg();let x=v.mul(K).mul(w).div(Q),y=v.neg().mul(Q).mul(X).div(K),T=J.plus(j).div(2),d=Z.plus(W).div(2),p=M.mul(x).minus(V.mul(y)).plus(T),c=V.mul(x).plus(M.mul(y)).plus(d),C=X.minus(x).div(K),u=w.minus(y).div(Q),N=X.neg().minus(x).div(K),e=w.neg().minus(y).div(Q),a=C.mul(C).plus(u.mul(u)).sqrt();if(a.eq(0)){y9.warn("sampleArc: degenerate arc - center coincides with start point, treating as line to end"),$.push(f0(j,W));return}let s=L.acos(C.div(a));if(u.lt(0))s=s.neg();let H0=a.mul(N.mul(N).plus(e.mul(e)).sqrt());if(H0.eq(0)){y9.warn("sampleArc: degenerate arc - zero length, treating as single point"),$.push(f0(j,W));return}let S=L.acos(C.mul(N).plus(u.mul(e)).div(H0));if(C.mul(e).minus(u.mul(N)).lt(0))S=S.neg();let E=_0(Math.PI),t=E.mul(2);if(q&&S.lt(0))S=S.plus(t);else if(!q&&S.gt(0))S=S.minus(t);for(let $0=1;$0<=G;$0++){let Q0=_0($0).div(G),U0=s.plus(S.mul(Q0)),C0=U0.cos(),y0=U0.sin(),o=M.mul(K.mul(C0)).minus(V.mul(Q.mul(y0))).plus(p),K0=V.mul(K.mul(C0)).plus(M.mul(Q.mul(y0))).plus(c);$.push(f0(o,K0))}}function WH($){if(!Array.isArray($))throw new Error("removeDuplicateConsecutive: points must be an array");if($.length<2)return $;let J=[$[0]];for(let Z=1;Z<$.length;Z++)if(!h7($[Z],J[J.length-1]))J.push($[Z]);return J}function k6($,J=null,Z=m5,K=4){if(!$||typeof $!=="object")throw new Error("shapeToPolygon: element must be an object");if(!$.type||typeof $.type!=="string")throw new Error("shapeToPolygon: element.type must be a string");if(typeof Z!=="number"||Z<=0||!Number.isFinite(Z))throw new Error(`shapeToPolygon: samples must be a positive finite number, got ${Z}`);if(typeof K!=="number"||K<=0||!Number.isFinite(K))throw new Error(`shapeToPolygon: bezierArcs must be a positive finite number, got ${K}`);if(J!==null&&!(J instanceof V0))throw new Error("shapeToPolygon: ctm must be null or a Matrix instance");let Q;switch($.type){case"circle":if(K>4)Q=_5($.cx||0,$.cy||0,$.r||0,K,10);else Q=Y5(_0($.cx||0),_0($.cy||0),_0($.r||0));break;case"ellipse":if(K>4)Q=L9($.cx||0,$.cy||0,$.rx||0,$.ry||0,K,10);else Q=P9(_0($.cx||0),_0($.cy||0),_0($.rx||0),_0($.ry||0));break;case"rect":Q=X5(_0($.x||0),_0($.y||0),_0($.width||0),_0($.height||0),_0($.rx||0),$.ry!==void 0?_0($.ry):null);break;case"line":Q=L5(_0($.x1||0),_0($.y1||0),_0($.x2||0),_0($.y2||0));break;case"polygon":Q=k5($.points||"");break;case"polyline":Q=w5($.points||"");break;case"path":Q=$.d||"";break;default:return[]}if($.transform){let H=zH($.transform);if(!(H instanceof V0))throw new Error(`shapeToPolygon: parseTransform must return a Matrix, got ${typeof H}`);Q=L6(Q,H)}if(J)Q=L6(Q,J);return $6(Q,Z)}function u9($,J=6){if(!Array.isArray($))throw new Error("polygonToPathData: polygon must be an array");if(typeof J!=="number"||J<0||!Number.isFinite(J))throw new Error(`polygonToPathData: precision must be a non-negative finite number, got ${J}`);if($.length<2)return"";let Z=(Q)=>(Q instanceof L?Q:_0(Q)).toFixed(J).replace(/\.?0+$/,""),K=`M ${Z($[0].x)} ${Z($[0].y)}`;for(let Q=1;Q<$.length;Q++)K+=` L ${Z($[Q].x)} ${Z($[Q].y)}`;return K+" Z"}L.set({precision:80});L.set({precision:80});var d5=($)=>$ instanceof L?$:new L($),p5=-0.1,c5=-0.1,l5=1.2,n5=1.2,T$={LUMINANCE:"luminance",ALPHA:"alpha"};function s5($){if(!$)throw new Error("parseMaskElement: maskElement is required");if(!$.getAttribute)throw new Error("parseMaskElement: maskElement must be a DOM element");let J={id:$.getAttribute("id")||"",maskUnits:$.getAttribute("maskUnits")||"objectBoundingBox",maskContentUnits:$.getAttribute("maskContentUnits")||"userSpaceOnUse",maskType:$.getAttribute("mask-type")||$.style?.maskType||"luminance",x:$.getAttribute("x"),y:$.getAttribute("y"),width:$.getAttribute("width"),height:$.getAttribute("height"),transform:$.getAttribute("transform")||null,children:[]},Z=(K,Q)=>{let H=parseFloat(K);return isNaN(H)?Q:H};if(J.maskUnits==="objectBoundingBox")J.x=J.x!==null?Z(J.x,p5):p5,J.y=J.y!==null?Z(J.y,c5):c5,J.width=J.width!==null?Z(J.width,l5):l5,J.height=J.height!==null?Z(J.height,n5):n5;else J.x=J.x!==null?Z(J.x,null):null,J.y=J.y!==null?Z(J.y,null):null,J.width=J.width!==null?Z(J.width,null):null,J.height=J.height!==null?Z(J.height,null):null;if(!$.children)return J;for(let K of $.children){if(!K.tagName)continue;let Q=K.tagName.toLowerCase(),H={type:Q,fill:K.getAttribute("fill")||K.style?.fill||"black",fillOpacity:Z(K.getAttribute("fill-opacity")||K.style?.fillOpacity||"1",1),opacity:Z(K.getAttribute("opacity")||K.style?.opacity||"1",1),transform:K.getAttribute("transform")||null};switch(Q){case"rect":H.x=Z(K.getAttribute("x")||"0",0),H.y=Z(K.getAttribute("y")||"0",0),H.width=Z(K.getAttribute("width")||"0",0),H.height=Z(K.getAttribute("height")||"0",0),H.rx=Z(K.getAttribute("rx")||"0",0),H.ry=Z(K.getAttribute("ry")||"0",0);break;case"circle":H.cx=Z(K.getAttribute("cx")||"0",0),H.cy=Z(K.getAttribute("cy")||"0",0),H.r=Z(K.getAttribute("r")||"0",0);break;case"ellipse":H.cx=Z(K.getAttribute("cx")||"0",0),H.cy=Z(K.getAttribute("cy")||"0",0),H.rx=Z(K.getAttribute("rx")||"0",0),H.ry=Z(K.getAttribute("ry")||"0",0);break;case"path":H.d=K.getAttribute("d")||"";break;case"polygon":H.points=K.getAttribute("points")||"";break;case"polyline":H.points=K.getAttribute("points")||"";break;case"g":if(H.children=[],K.children){for(let z of K.children)if(z.tagName)H.children.push({type:z.tagName.toLowerCase(),fill:z.getAttribute("fill")||"inherit"})}break;default:break}J.children.push(H)}return J}function GH($,J,Z,K=20){if(!$)throw new Error("maskChildToPolygon: child is required");if(!J)throw new Error("maskChildToPolygon: targetBBox is required");if(!Z)throw new Error("maskChildToPolygon: contentUnits is required");if(typeof K!=="number"||K<=0)throw new Error("maskChildToPolygon: samples must be a positive number");if(typeof J.x!=="number"||typeof J.y!=="number"||typeof J.width!=="number"||typeof J.height!=="number")throw new Error("maskChildToPolygon: targetBBox must have numeric x, y, width, height properties");if(J.width<0||J.height<0)throw new Error("maskChildToPolygon: targetBBox width and height cannot be negative");let Q={type:$.type,...$,transform:$.transform},H=k6(Q,null,K);if(!Array.isArray(H))return[];if(Z==="objectBoundingBox"&&H.length>0){if(J.width===0||J.height===0)return[];H=H.map((z)=>({x:d5(J.x).plus(z.x.mul(J.width)),y:d5(J.y).plus(z.y.mul(J.height))}))}return H}function FH($){if(!$||$==="none"||$==="transparent")return 0;if(typeof $!=="string")return 0;let J=$.match(/rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i);if(J){let H=parseInt(J[1],10),z=parseInt(J[2],10),q=parseInt(J[3],10);if(isNaN(H)||isNaN(z)||isNaN(q))return 0;let j=Math.max(0,Math.min(255,H))/255,W=Math.max(0,Math.min(255,z))/255,G=Math.max(0,Math.min(255,q))/255,F=0.2126*j+0.7152*W+0.0722*G;return isNaN(F)?0:F}let Z=$.match(/^#([0-9a-f]{3,6})$/i);if(Z){let H=Z[1];if(H.length===3)H=H[0]+H[0]+H[1]+H[1]+H[2]+H[2];let z=parseInt(H.slice(0,2),16),q=parseInt(H.slice(2,4),16),j=parseInt(H.slice(4,6),16);if(isNaN(z)||isNaN(q)||isNaN(j))return 0;let W=0.2126*(z/255)+0.7152*(q/255)+0.0722*(j/255);return isNaN(W)?0:W}let K={white:1,black:0,red:0.2126,green:0.7152,blue:0.0722,yellow:0.9278,cyan:0.7874,magenta:0.2848,gray:0.5,grey:0.5},Q=$.toLowerCase();if(K[Q]!==void 0)return K[Q];return 0}function _H($,J){if(!$)throw new Error("getMaskChildOpacity: child is required");if(!J)throw new Error("getMaskChildOpacity: maskType is required");if(J!==T$.LUMINANCE&&J!==T$.ALPHA)throw new Error('getMaskChildOpacity: maskType must be "luminance" or "alpha"');let Z=typeof $.fillOpacity==="number"&&!isNaN($.fillOpacity)?$.fillOpacity:1,K=typeof $.opacity==="number"&&!isNaN($.opacity)?$.opacity:1,Q=Z*K;if(J===T$.ALPHA)return Q;let H=FH($.fill),z=Q*H;return isNaN(z)?0:z}function UH($,J,Z={}){if(!$)throw new Error("resolveMask: maskData is required");if(!J)throw new Error("resolveMask: targetBBox is required");if(!Array.isArray($.children))throw new Error("resolveMask: maskData.children must be an array");let{samples:K=20}=Z;if(typeof K!=="number"||K<=0)throw new Error("resolveMask: samples must be a positive number");let Q=$.maskType||T$.LUMINANCE,H=[];for(let z of $.children){if(!z)continue;let q=GH(z,J,$.maskContentUnits,K);if(q.length>=3){let j=_H(z,Q);H.push({polygon:q,opacity:j})}}return H}function VH($,J,Z=0.5,K={}){if(!$)throw new Error("maskToClipPath: maskData is required");if(!J)throw new Error("maskToClipPath: targetBBox is required");if(typeof Z!=="number"||Z<0||Z>1)throw new Error("maskToClipPath: opacityThreshold must be a number between 0 and 1");let Q=UH($,J,K),H=[];for(let{polygon:z,opacity:q}of Q)if(q>=Z&&z&&z.length>=3)if(H.length===0)H=z;else{let j=W6(H,z);if(j.length>0&&j[0].length>=3)H=j[0]}return H}function o5($,J,Z={}){if(!$)throw new Error("maskToPathData: maskData is required");if(!J)throw new Error("maskToPathData: targetBBox is required");let K=VH($,J,0.5,Z);if(K.length<3)return"";let Q="",H=0;for(let z=0;z<K.length;z++){let q=K[z];if(!q||q.x===void 0||q.y===void 0)continue;let j=Number(q.x),W=Number(q.y);if(isNaN(j)||isNaN(W)||!isFinite(j)||!isFinite(W))continue;let G=j.toFixed(6),F=W.toFixed(6);Q+=H===0?`M ${G} ${F}`:` L ${G} ${F}`,H++}if(H>=3)Q+=" Z";else return"";return Q}L.set({precision:80});function i5($){if(!$)throw new Error("parseUseElement: useElement is required");let J=$.getAttribute("href")||$.getAttribute("xlink:href")||"",Z=J.startsWith("#")?J.slice(1):J;if(!Z)throw new Error("parseUseElement: href attribute must reference a valid element id (found empty reference)");let K=parseFloat($.getAttribute("x")||"0"),Q=parseFloat($.getAttribute("y")||"0");if(isNaN(K)||isNaN(Q)||!isFinite(K)||!isFinite(Q))throw new Error("parseUseElement: x and y attributes must be valid finite numbers");let H=null,z=null;if($.getAttribute("width")){if(H=parseFloat($.getAttribute("width")),isNaN(H)||!isFinite(H)||H<=0)throw new Error("parseUseElement: width attribute must be a valid positive finite number")}if($.getAttribute("height")){if(z=parseFloat($.getAttribute("height")),isNaN(z)||!isFinite(z)||z<=0)throw new Error("parseUseElement: height attribute must be a valid positive finite number")}return{href:Z,x:K,y:Q,width:H,height:z,transform:$.getAttribute("transform")||null,style:a5($)}}function r5($){if(!$)throw new Error("parseSymbolElement: symbolElement is required");let J=parseFloat($.getAttribute("refX")||"0"),Z=parseFloat($.getAttribute("refY")||"0");if(isNaN(J)||isNaN(Z)||!isFinite(J)||!isFinite(Z))throw new Error("parseSymbolElement: refX and refY must be valid finite numbers");let K={id:$.getAttribute("id")||"",viewBox:$.getAttribute("viewBox")||null,preserveAspectRatio:$.getAttribute("preserveAspectRatio")||"xMidYMid meet",children:[],refX:J,refY:Z};if(K.viewBox){let Q=K.viewBox.trim().split(/[\s,]+/).map(Number);if(Q.length===4&&Q.every((H)=>!isNaN(H)&&isFinite(H)))K.viewBoxParsed={x:Q[0],y:Q[1],width:Q[2],height:Q[3]}}for(let Q of $.children)K.children.push(b$(Q));return K}function b$($){if(!$||!$.tagName)throw new Error("parseChildElement: element with tagName is required");let J=$.tagName.toLowerCase(),Z={type:J,id:$.getAttribute("id")||null,transform:$.getAttribute("transform")||null,style:a5($)},K=(Q,H="0")=>{let z=parseFloat($.getAttribute(Q)||H);if(isNaN(z)||!isFinite(z))throw new Error(`parseChildElement: ${Q} must be a valid finite number in ${J} element`);return z};switch(J){case"rect":Z.x=K("x"),Z.y=K("y"),Z.width=K("width"),Z.height=K("height"),Z.rx=K("rx"),Z.ry=K("ry");break;case"circle":Z.cx=K("cx"),Z.cy=K("cy"),Z.r=K("r");break;case"ellipse":Z.cx=K("cx"),Z.cy=K("cy"),Z.rx=K("rx"),Z.ry=K("ry");break;case"path":Z.d=$.getAttribute("d")||"";break;case"polygon":Z.points=$.getAttribute("points")||"";break;case"polyline":Z.points=$.getAttribute("points")||"";break;case"line":Z.x1=K("x1"),Z.y1=K("y1"),Z.x2=K("x2"),Z.y2=K("y2");break;case"g":Z.children=[];for(let Q of $.children)Z.children.push(b$(Q));break;case"use":Z.href=($.getAttribute("href")||$.getAttribute("xlink:href")||"").replace("#",""),Z.x=K("x"),Z.y=K("y"),Z.width=$.getAttribute("width")?K("width"):null,Z.height=$.getAttribute("height")?K("height"):null;break;default:break}return Z}function a5($){if(!$)throw new Error("extractStyleAttributes: element is required");return{fill:$.getAttribute("fill"),stroke:$.getAttribute("stroke"),strokeWidth:$.getAttribute("stroke-width"),opacity:$.getAttribute("opacity"),fillOpacity:$.getAttribute("fill-opacity"),strokeOpacity:$.getAttribute("stroke-opacity"),visibility:$.getAttribute("visibility"),display:$.getAttribute("display")}}function OH($,J,Z,K="xMidYMid meet"){if(!$||!J||!Z)return V0.identity(3);if(!isFinite(J)||!isFinite(Z)||J<=0||Z<=0)return V0.identity(3);let{width:Q,height:H,x:z,y:q}=$;if(!isFinite(Q)||!isFinite(H)||!isFinite(z)||!isFinite(q)||Q<=0||H<=0)return V0.identity(3);let j=K.trim().split(/\s+/),W=j[0]||"xMidYMid",G=j[1]||"meet";if(W==="none"){let X=J/Q,w=Z/H;return i0(-z*X,-q*w).mul(O7(X,w))}let F=J/Q,_=Z/H,U;if(G==="slice")U=Math.max(F,_);else U=Math.min(F,_);let M=-z*U,V=-q*U,Y=Q*U,O=H*U;if(W.includes("xMid"))M+=(J-Y)/2;else if(W.includes("xMax"))M+=J-Y;if(W.includes("YMid"))V+=(Z-O)/2;else if(W.includes("YMax"))V+=Z-O;return i0(M,V).mul(O7(U,U))}function g9($,J,Z={}){if(!$||!$.href)throw new Error("resolveUse: useData with href property is required");if(!J)throw new Error("resolveUse: defs map is required");if(typeof $.x!=="number"||isNaN($.x)||!isFinite($.x))throw new Error("resolveUse: useData.x must be a valid finite number");if(typeof $.y!=="number"||isNaN($.y)||!isFinite($.y))throw new Error("resolveUse: useData.y must be a valid finite number");if($.width!==null&&(typeof $.width!=="number"||isNaN($.width)||!isFinite($.width)||$.width<=0))throw new Error("resolveUse: useData.width must be null or a positive finite number");if($.height!==null&&(typeof $.height!=="number"||isNaN($.height)||!isFinite($.height)||$.height<=0))throw new Error("resolveUse: useData.height must be null or a positive finite number");if($.style!==null&&$.style!==void 0){if(typeof $.style!=="object"||Array.isArray($.style))throw new Error("resolveUse: useData.style must be null, undefined, or a valid non-array object")}if($.transform!==null&&$.transform!==void 0&&typeof $.transform!=="string")throw new Error("resolveUse: useData.transform must be null, undefined, or a string");if(Z&&typeof Z!=="object")throw new Error("resolveUse: options must be an object or undefined");let{maxDepth:K=10,_visited:Q=new Set}=Z;if(typeof K!=="number"||K<=0||!isFinite(K))throw new Error("resolveUse: maxDepth must be a positive finite number");if(Q.has($.href))return console.warn(`resolveUse: circular reference detected for '#${$.href}', skipping to prevent infinite loop`),null;let H=J[$.href];if(!H)return console.warn(`resolveUse: target element '#${$.href}' not found in defs map`),null;Q.add($.href);let z=i0($.x,$.y);if($.transform){let W=J7($.transform);z=z.mul(W)}if(H.type==="symbol"&&H.viewBoxParsed){if(typeof H.viewBoxParsed.x!=="number"||typeof H.viewBoxParsed.y!=="number"||typeof H.viewBoxParsed.width!=="number"||typeof H.viewBoxParsed.height!=="number"||!isFinite(H.viewBoxParsed.x)||!isFinite(H.viewBoxParsed.y)||!isFinite(H.viewBoxParsed.width)||!isFinite(H.viewBoxParsed.height)||H.viewBoxParsed.width<=0||H.viewBoxParsed.height<=0)throw new Error("resolveUse: target.viewBoxParsed must have finite x, y and positive finite width, height");let W=$.width!==null?$.width:H.viewBoxParsed.width,G=$.height!==null?$.height:H.viewBoxParsed.height;z=OH(H.viewBoxParsed,W,G,H.preserveAspectRatio||"xMidYMid meet").mul(z)}let q=[],j=H.children&&Array.isArray(H.children)&&H.children.length>0?H.children:[H];for(let W of j)if(W.type==="use"){if(K<=1){console.warn(`resolveUse: maximum nesting depth reached for use element '#${W.href}', skipping nested resolution`);continue}let G=g9(W,J,{maxDepth:K-1,_visited:Q});if(G)q.push(G)}else q.push({element:W,transform:V0.identity(3)});return Q.delete($.href),{element:H,transform:z,children:q,inheritedStyle:$.style}}function t5($,J=20){let Z=[];if(!$)return Z;if(typeof J!=="number"||J<=0||!isFinite(J))throw new Error("flattenResolvedUse: samples must be a positive finite number");if(!$.children||!$.transform)return Z;for(let K of $.children){if(!K||!K.transform)continue;let Q=$.transform.mul(K.transform),H=K.element;if(K.children){let z=t5(K,J);for(let q of z)q.polygon=q.polygon.map((j)=>{let[W,G]=l0($.transform,j.x,j.y);return{x:W,y:G}}),Z.push(q)}else{let z=YH(H,Q,J);if(z.length>=3)Z.push({polygon:z,style:XH($.inheritedStyle,H.style)})}}return Z}function YH($,J,Z=20){if(!$)throw new Error("elementToPolygon: element is required");if(typeof Z!=="number"||Z<=0||!isFinite(Z))throw new Error("elementToPolygon: samples must be a positive finite number");let K=k6($,null,Z);if(J&&K.length>0)K=K.map((Q)=>{let[H,z]=l0(J,Q.x,Q.y);return{x:H,y:z}});return K}function XH($,J){if(!J||typeof J!=="object"||Array.isArray(J))throw new Error("mergeStyles: element must be a valid non-array object");let Z={...J};if($!==null&&$!==void 0){if(typeof $!=="object"||Array.isArray($))throw new Error("mergeStyles: inherited must be null, undefined, or a valid non-array object")}for(let[K,Q]of Object.entries($||{}))if(Q!==null&&(Z[K]===null||Z[K]===void 0))Z[K]=Q;return Z}function e5($,J=20){if(typeof J!=="number"||J<=0||!isFinite(J))throw new Error("resolvedUseToPathData: samples must be a positive finite number");let Z=t5($,J),K=[];for(let{polygon:Q}of Z)if(Q.length>=3){let H="";for(let z=0;z<Q.length;z++){let q=Q[z],j=Number(q.x),W=Number(q.y);if(isNaN(j)||isNaN(W))continue;H+=z===0?`M ${j.toFixed(6)} ${W.toFixed(6)}`:` L ${j.toFixed(6)} ${W.toFixed(6)}`}H+=" Z",K.push(H)}return K.join(" ")}L.set({precision:80});var H7=($)=>$ instanceof L?$:new L($);function $K($){if(!$)throw new Error("parsePatternElement: patternElement is required");if(typeof $.getAttribute!=="function")throw new Error("parsePatternElement: patternElement must be a DOM element with getAttribute method");let J={id:$.getAttribute("id")||"",patternUnits:$.getAttribute("patternUnits")||"objectBoundingBox",patternContentUnits:$.getAttribute("patternContentUnits")||"userSpaceOnUse",patternTransform:$.getAttribute("patternTransform")||null,x:$.getAttribute("x"),y:$.getAttribute("y"),width:$.getAttribute("width"),height:$.getAttribute("height"),viewBox:$.getAttribute("viewBox")||null,preserveAspectRatio:$.getAttribute("preserveAspectRatio")||"xMidYMid meet",href:$.getAttribute("href")||$.getAttribute("xlink:href")||null,children:[]},Z=(K,Q)=>{if(K===null||K===void 0)return Q;let H=parseFloat(K);return isNaN(H)?Q:H};if(J.x=Z(J.x,0),J.y=Z(J.y,0),J.width=Z(J.width,0),J.height=Z(J.height,0),J.viewBox){let K=J.viewBox.trim().split(/[\s,]+/).map(Number);if(K.length===4&&K.every((Q)=>!isNaN(Q)&&isFinite(Q)))J.viewBoxParsed={x:K[0],y:K[1],width:K[2],height:K[3]}}if($.children&&typeof $.children[Symbol.iterator]==="function")for(let K of $.children){if(!K||typeof K.getAttribute!=="function")continue;let Q=K.tagName?K.tagName.toLowerCase():"";if(!Q)continue;let H={type:Q,fill:K.getAttribute("fill")||"black",stroke:K.getAttribute("stroke")||"none",strokeWidth:Z(K.getAttribute("stroke-width"),1),opacity:Z(K.getAttribute("opacity"),1),transform:K.getAttribute("transform")||null};switch(Q){case"rect":H.x=Z(K.getAttribute("x"),0),H.y=Z(K.getAttribute("y"),0),H.width=Z(K.getAttribute("width"),0),H.height=Z(K.getAttribute("height"),0),H.rx=Z(K.getAttribute("rx"),0),H.ry=Z(K.getAttribute("ry"),0);break;case"circle":H.cx=Z(K.getAttribute("cx"),0),H.cy=Z(K.getAttribute("cy"),0),H.r=Z(K.getAttribute("r"),0);break;case"ellipse":H.cx=Z(K.getAttribute("cx"),0),H.cy=Z(K.getAttribute("cy"),0),H.rx=Z(K.getAttribute("rx"),0),H.ry=Z(K.getAttribute("ry"),0);break;case"path":H.d=K.getAttribute("d")||"";break;case"polygon":H.points=K.getAttribute("points")||"";break;case"polyline":H.points=K.getAttribute("points")||"";break;case"line":H.x1=Z(K.getAttribute("x1"),0),H.y1=Z(K.getAttribute("y1"),0),H.x2=Z(K.getAttribute("x2"),0),H.y2=Z(K.getAttribute("y2"),0);break;case"use":H.href=K.getAttribute("href")||K.getAttribute("xlink:href")||"",H.x=Z(K.getAttribute("x"),0),H.y=Z(K.getAttribute("y"),0);break;case"g":if(H.children=[],K.children&&typeof K.children[Symbol.iterator]==="function"){for(let z of K.children)if(z&&z.tagName&&typeof z.getAttribute==="function")H.children.push({type:z.tagName.toLowerCase(),fill:z.getAttribute("fill")||"inherit"})}break;default:break}J.children.push(H)}return J}function kH($,J){if(!$)throw new Error("getPatternTile: patternData is required");if(!J)throw new Error("getPatternTile: targetBBox is required");if(typeof J.x!=="number"||typeof J.y!=="number"||typeof J.width!=="number"||typeof J.height!=="number")throw new Error("getPatternTile: targetBBox must have numeric x, y, width, and height properties");if(typeof $.x!=="number"||typeof $.y!=="number"||typeof $.width!=="number"||typeof $.height!=="number")throw new Error("getPatternTile: patternData must have numeric x, y, width, and height properties");if($.patternUnits==="objectBoundingBox")return{x:H7(J.x).plus(H7($.x).mul(J.width)),y:H7(J.y).plus(H7($.y).mul(J.height)),width:H7($.width).mul(J.width),height:H7($.height).mul(J.height)};return{x:H7($.x),y:H7($.y),width:H7($.width),height:H7($.height)}}function wH($,J,Z){if(!$)throw new Error("getPatternContentTransform: patternData is required");if(!J)throw new Error("getPatternContentTransform: tile is required");if(!Z)throw new Error("getPatternContentTransform: targetBBox is required");if(!J.width||!J.height)throw new Error("getPatternContentTransform: tile must have width and height properties");if(typeof Z.x!=="number"||typeof Z.y!=="number"||typeof Z.width!=="number"||typeof Z.height!=="number")throw new Error("getPatternContentTransform: targetBBox must have numeric x, y, width, and height properties");let K=V0.identity(3);if($.viewBoxParsed){let Q=$.viewBoxParsed;if(typeof Q.x!=="number"||typeof Q.y!=="number"||typeof Q.width!=="number"||typeof Q.height!=="number")throw new Error("getPatternContentTransform: viewBoxParsed must have numeric x, y, width, and height properties");let H=Number(J.width),z=Number(J.height);if(H===0||z===0)throw new Error("getPatternContentTransform: tile width and height must be non-zero when viewBox is present");if(Q.width===0||Q.height===0)throw new Error("getPatternContentTransform: viewBox width and height must be non-zero");let q=H/Q.width,j=z/Q.height,W=Math.min(q,j);if(!isFinite(W))throw new Error("getPatternContentTransform: computed scale is not finite");let G=(H-Q.width*W)/2,F=(z-Q.height*W)/2;K=K.mul(i0(G-Q.x*W,F-Q.y*W)),K=K.mul(O7(W,W))}if($.patternContentUnits==="objectBoundingBox"){if(Z.width===0||Z.height===0)throw new Error("getPatternContentTransform: targetBBox width and height must be non-zero when patternContentUnits is objectBoundingBox");K=K.mul(i0(Z.x,Z.y)),K=K.mul(O7(Z.width,Z.height))}return K}function RH($,J=null,Z=20){if(!$)throw new Error("patternChildToPolygon: child is required");if(!$.type)throw new Error("patternChildToPolygon: child must have a type property");if(typeof Z!=="number"||Z<=0||!isFinite(Z))throw new Error("patternChildToPolygon: samples must be a positive finite number");let K={type:$.type,...$,transform:$.transform},Q=k6(K,null,Z);if(!Array.isArray(Q))return[];if(J&&Q.length>0)Q=Q.map((H)=>{if(!H||typeof H.x!=="number"||typeof H.y!=="number")throw new Error("patternChildToPolygon: invalid polygon point - must have numeric x and y properties");let[z,q]=l0(J,H.x,H.y);return{x:z,y:q}});return Q}function BH($,J){if(!$)throw new Error("getTilePositions: tile is required");if(!J)throw new Error("getTilePositions: coverBBox is required");if(!("x"in $)||!("y"in $)||!("width"in $)||!("height"in $))throw new Error("getTilePositions: tile must have x, y, width, and height properties");if(typeof J.x!=="number"||typeof J.y!=="number"||typeof J.width!=="number"||typeof J.height!=="number")throw new Error("getTilePositions: coverBBox must have numeric x, y, width, and height properties");let Z=[],K=Number($.x),Q=Number($.y),H=Number($.width),z=Number($.height);if(!isFinite(K)||!isFinite(Q)||!isFinite(H)||!isFinite(z))throw new Error("getTilePositions: tile dimensions must be finite numbers");if(H<=0||z<=0)return Z;let q=Math.floor((J.x-K)/H),j=Math.ceil((J.x+J.width-K)/H),W=Math.floor((J.y-Q)/z),G=Math.ceil((J.y+J.height-Q)/z);if(!isFinite(q)||!isFinite(j)||!isFinite(W)||!isFinite(G))throw new Error("getTilePositions: computed tile indices are not finite");for(let F=q;F<j;F++)for(let _=W;_<G;_++)Z.push({x:H7(K).plus(H7(H).mul(F)),y:H7(Q).plus(H7(z).mul(_))});return Z}function NH($,J,Z={}){if(!$)throw new Error("resolvePattern: patternData is required");if(!J)throw new Error("resolvePattern: targetBBox is required");if(!Array.isArray($.children))throw new Error("resolvePattern: patternData.children must be an array");let{samples:K=20,maxTiles:Q=1000}=Z,H=[],z=kH($,J);if(Number(z.width)<=0||Number(z.height)<=0)return H;let q=wH($,z,J),j=IH($.patternTransform),G=BH(z,J).slice(0,Q);for(let F of G){let _=i0(F.x,F.y);for(let U of $.children){let M=j.mul(_.mul(q)),V=RH(U,M,K);if(V.length>=3)H.push({polygon:V,fill:U.fill,stroke:U.stroke,strokeWidth:U.strokeWidth,opacity:U.opacity})}}return H}function CH($,J,Z={}){if(!$)throw new Error("patternToClipPath: patternData is required");if(!J)throw new Error("patternToClipPath: targetBBox is required");let K=NH($,J,Z),Q=[];for(let{polygon:H,opacity:z}of K)if(z>0&&H.length>=3)if(Q.length===0)Q=H;else{let q=W6(Q,H);if(Array.isArray(q)&&q.length>0&&Array.isArray(q[0])&&q[0].length>=3)Q=q[0]}return Q}function JK($,J,Z={}){if(!$)throw new Error("patternToPathData: patternData is required");if(!J)throw new Error("patternToPathData: targetBBox is required");let K=CH($,J,Z);if(!Array.isArray(K))return"";if(K.length<3)return"";let Q="";for(let H=0;H<K.length;H++){let z=K[H];if(!z||typeof z.x!=="number"||typeof z.y!=="number")throw new Error("patternToPathData: invalid polygon point - must have numeric x and y properties");if(!isFinite(z.x)||!isFinite(z.y))throw new Error("patternToPathData: polygon point coordinates must be finite numbers");let q=Number(z.x).toFixed(6),j=Number(z.y).toFixed(6);Q+=H===0?`M ${q} ${j}`:` L ${q} ${j}`}return Q+=" Z",Q}function IH($){if(!$)return V0.identity(3);return J7($)}L.set({precision:80});function x9($,J,Z,K=1,Q=!1){if(!$)throw new Error("getMarkerTransform: markerDef is required");if(!J||typeof J.x!=="number"||typeof J.y!=="number")throw new Error("getMarkerTransform: position must be an object with x and y numeric properties");if(typeof Z!=="number"||isNaN(Z)||!isFinite(Z))throw new Error("getMarkerTransform: tangentAngle must be a valid finite number");if(typeof K!=="number"||isNaN(K)||K<=0)throw new Error("getMarkerTransform: strokeWidth must be a positive number");let{markerWidth:H,markerHeight:z,refX:q,refY:j,orient:W,markerUnits:G,viewBox:F}=$;if(typeof H!=="number"||H<=0)throw new Error("getMarkerTransform: markerDef.markerWidth must be a positive number");if(typeof z!=="number"||z<=0)throw new Error("getMarkerTransform: markerDef.markerHeight must be a positive number");if(typeof q!=="number"||!isFinite(q))throw new Error("getMarkerTransform: markerDef.refX must be a finite number");if(typeof j!=="number"||!isFinite(j))throw new Error("getMarkerTransform: markerDef.refY must be a finite number");let _=V0.identity(3),U=i0(J.x,J.y);_=_.mul(U);let M=0;if(W==="auto")M=Z;else if(W==="auto-start-reverse")M=Q?Z+Math.PI:Z;else if(typeof W==="number")M=W*(Math.PI/180);if(M!==0){let w=X6(M);_=_.mul(w)}let V=1,Y=1;if(G==="strokeWidth")V=K,Y=K;let O=!1,X=1;if(F){let{width:w,height:R}=F;if(w>0&&R>0&&isFinite(w)&&isFinite(R)){let B=H/w,I=z/R;if(isFinite(B)&&isFinite(I))X=Math.min(B,I),O=!0,V*=X,Y*=X}}if(O){let w=(q-F.x)*X,R=(j-F.y)*X,B=i0(-w,-R);if(_=_.mul(B),V!==1||Y!==1){let h=O7(V,Y);_=_.mul(h)}let I=i0(-F.x,-F.y);_=_.mul(I)}else{if(V!==1||Y!==1){let R=O7(V,Y);_=_.mul(R)}let w=i0(-q,-j);_=_.mul(w)}return _}function AH($){if(typeof $!=="string")throw new Error("getPathVertices: pathData must be a string");let J=[],Z=0,K=0,Q=0,H=0,z=KK($);for(let q=0;q<z.length;q++){let j=z[q],W=Z,G=K;switch(j.type){case"M":if(Z=j.x,K=j.y,Q=Z,H=K,J.length>0){let F=J[J.length-1],_=Math.atan2(K-G,Z-W);F.tangentOut=_}J.push({x:Z,y:K,tangentIn:0,tangentOut:0,index:J.length});break;case"L":{Z=j.x,K=j.y;let F=Z-W,_=K-G,U=F===0&&_===0?J.length>0?J[J.length-1].tangentOut:0:Math.atan2(_,F);if(J.length>0)J[J.length-1].tangentOut=U;J.push({x:Z,y:K,tangentIn:U,tangentOut:U,index:J.length});break}case"C":{Z=j.x,K=j.y;let F=j.x1-W,_=j.y1-G,U=F===0&&_===0?Math.atan2(j.y2-G,j.x2-W):Math.atan2(_,F),M=Z-j.x2,V=K-j.y2,Y=M===0&&V===0?Math.atan2(K-j.y1,Z-j.x1):Math.atan2(V,M);if(J.length>0)J[J.length-1].tangentOut=U;J.push({x:Z,y:K,tangentIn:Y,tangentOut:Y,index:J.length});break}case"Q":{Z=j.x,K=j.y;let F=j.x1-W,_=j.y1-G,U=F===0&&_===0?Math.atan2(K-G,Z-W):Math.atan2(_,F),M=Z-j.x1,V=K-j.y1,Y=M===0&&V===0?Math.atan2(K-G,Z-W):Math.atan2(V,M);if(J.length>0)J[J.length-1].tangentOut=U;J.push({x:Z,y:K,tangentIn:Y,tangentOut:Y,index:J.length});break}case"A":{Z=j.x,K=j.y;let F=Z-W,_=K-G,U=F===0&&_===0?J.length>0?J[J.length-1].tangentOut:0:Math.atan2(_,F);if(J.length>0)J[J.length-1].tangentOut=U;J.push({x:Z,y:K,tangentIn:U,tangentOut:U,index:J.length});break}case"Z":{Z=Q,K=H;let F=Z-W,_=K-G,U=F===0&&_===0?J.length>0?J[J.length-1].tangentOut:0:Math.atan2(_,F);if(J.length>0)J[J.length-1].tangentOut=U;if(J.length>0)J[0].tangentIn=U;break}default:break}}return J}function KK($){if(typeof $!=="string")throw new Error("parsePathCommands: pathData must be a string");let J=[];if($.trim()==="")return J;let Z=$.replace(/([MmLlHhVvCcSsQqTtAaZz])/g," $1 ").trim(),K=/[MmLlHhVvCcSsQqTtAaZz]/,Q=/-?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/g,H=[],z=0;while(z<Z.length){while(z<Z.length&&/[\s,]/.test(Z[z]))z++;if(z>=Z.length)break;if(K.test(Z[z]))H.push(Z[z]),z++;else{Q.lastIndex=z;let F=Q.exec(Z);if(F&&F.index===z)H.push(F[0]),z=Q.lastIndex;else z++}}let q=0,j=0,W=0,G=(F,_)=>{if(F>=H.length)throw new Error(`parsePathCommands: missing ${_} parameter at token ${F}`);let U=parseFloat(H[F]);if(isNaN(U)||!isFinite(U))throw new Error(`parsePathCommands: invalid ${_} value "${H[F]}" at token ${F}`);return U};while(q<H.length){let F=H[q];switch(F.toUpperCase()){case"M":{let _=G(q+1,"M.x"),U=G(q+2,"M.y");J.push({type:"M",x:F==="M"?_:j+_,y:F==="M"?U:W+U}),j=J[J.length-1].x,W=J[J.length-1].y,q+=3;break}case"L":{let _=G(q+1,"L.x"),U=G(q+2,"L.y");J.push({type:"L",x:F==="L"?_:j+_,y:F==="L"?U:W+U}),j=J[J.length-1].x,W=J[J.length-1].y,q+=3;break}case"H":{let _=G(q+1,"H.x");J.push({type:"L",x:F==="H"?_:j+_,y:W}),j=J[J.length-1].x,q+=2;break}case"V":{let _=G(q+1,"V.y");J.push({type:"L",x:j,y:F==="V"?_:W+_}),W=J[J.length-1].y,q+=2;break}case"C":{let _=G(q+1,"C.x1"),U=G(q+2,"C.y1"),M=G(q+3,"C.x2"),V=G(q+4,"C.y2"),Y=G(q+5,"C.x"),O=G(q+6,"C.y");J.push({type:"C",x1:F==="C"?_:j+_,y1:F==="C"?U:W+U,x2:F==="C"?M:j+M,y2:F==="C"?V:W+V,x:F==="C"?Y:j+Y,y:F==="C"?O:W+O}),j=J[J.length-1].x,W=J[J.length-1].y,q+=7;break}case"Q":{let _=G(q+1,"Q.x1"),U=G(q+2,"Q.y1"),M=G(q+3,"Q.x"),V=G(q+4,"Q.y");J.push({type:"Q",x1:F==="Q"?_:j+_,y1:F==="Q"?U:W+U,x:F==="Q"?M:j+M,y:F==="Q"?V:W+V}),j=J[J.length-1].x,W=J[J.length-1].y,q+=5;break}case"A":{let _=G(q+1,"A.rx"),U=G(q+2,"A.ry"),M=G(q+3,"A.rotation");if(q+4>=H.length||q+5>=H.length)throw new Error("parsePathCommands: missing arc flag parameters");let V=parseInt(H[q+4],10),Y=parseInt(H[q+5],10);if(isNaN(V)||isNaN(Y))throw new Error("parsePathCommands: invalid arc flag values");let O=G(q+6,"A.x"),X=G(q+7,"A.y");J.push({type:"A",rx:_,ry:U,xAxisRotation:M,largeArcFlag:V,sweepFlag:Y,x:F==="A"?O:j+O,y:F==="A"?X:W+X}),j=J[J.length-1].x,W=J[J.length-1].y,q+=8;break}case"Z":J.push({type:"Z"}),q+=1;break;default:q+=1}}return J}function ZK($,J){if(!$)throw new Error("resolveMarkers: pathElement is required");if(!J||typeof J!=="object")throw new Error("resolveMarkers: defsMap must be an object");let Z=[],K=$.getAttribute("marker-start"),Q=$.getAttribute("marker-mid"),H=$.getAttribute("marker-end"),z=$.getAttribute("stroke-width")||"1",q=parseFloat(z);if(isNaN(q)||q<=0)throw new Error("resolveMarkers: stroke-width must be a positive number");let j=$.getAttribute("d")||"",W=AH(j);if(W.length===0)return Z;let G=(F)=>{if(!F)return null;let _=F.match(/url\(#([^)]+)\)/);return _?_[1]:null};if(K){let F=G(K),_=F?J[F]:null;if(_&&W.length>0){let U=W[0],M=W.length>1?U.tangentOut:U.tangentIn;Z.push({markerDef:_,position:{x:U.x,y:U.y},transform:x9(_,{x:U.x,y:U.y},M,q,!0),type:"start",vertex:U})}}if(Q&&W.length>2){let F=G(Q),_=F?J[F]:null;if(_)for(let U=1;U<W.length-1;U++){let M=W[U],V=M.tangentIn,O=M.tangentOut-V;while(O>Math.PI)O-=2*Math.PI;while(O<-Math.PI)O+=2*Math.PI;let X=V+O/2;Z.push({markerDef:_,position:{x:M.x,y:M.y},transform:x9(_,{x:M.x,y:M.y},X,q,!1),type:"mid",vertex:M})}}if(H){let F=G(H),_=F?J[F]:null;if(_&&W.length>0){let U=W[W.length-1],M=U.tangentIn;Z.push({markerDef:_,position:{x:U.x,y:U.y},transform:x9(_,{x:U.x,y:U.y},M,q,!1),type:"end",vertex:U})}}return Z}function EH($,J={}){if(!$)throw new Error("markerToPolygons: markerInstance is required");if(!$.markerDef)throw new Error("markerToPolygons: markerInstance.markerDef is required");if(!$.transform)throw new Error("markerToPolygons: markerInstance.transform is required");let{precision:Z=2,curveSegments:K=10}=J;if(typeof Z!=="number"||Z<0)throw new Error("markerToPolygons: precision must be a non-negative number");if(typeof K!=="number"||K<=0)throw new Error("markerToPolygons: curveSegments must be a positive number");let Q=[],{markerDef:H,transform:z}=$;if(!Array.isArray(H.children))throw new Error("markerToPolygons: markerDef.children must be an array");for(let q of H.children){let j=[];switch(q.type){case"path":j=TH(q.d,K);break;case"rect":j=[{x:q.x,y:q.y},{x:q.x+q.width,y:q.y},{x:q.x+q.width,y:q.y+q.height},{x:q.x,y:q.y+q.height}];break;case"circle":j=bH(q.cx,q.cy,q.r,K*4);break;case"ellipse":j=fH(q.cx,q.cy,q.rx,q.ry,K*4);break;case"line":j=[{x:q.x1,y:q.y1},{x:q.x2,y:q.y2}];break;case"polygon":case"polyline":j=SH(q.points);break;default:break}if(j.length>0){let W=j.map((G)=>{let F=l0(z,G.x,G.y);return{x:parseFloat(F[0].toFixed(Z)),y:parseFloat(F[1].toFixed(Z))}});Q.push(W)}}return Q}function TH($,J=10){if(typeof $!=="string")throw new Error("pathToPoints: pathData must be a string");if(typeof J!=="number"||J<=0)throw new Error("pathToPoints: segments must be a positive number");let Z=[],K=KK($),Q=0,H=0;for(let z of K)switch(z.type){case"M":Q=z.x,H=z.y,Z.push({x:Q,y:H});break;case"L":Q=z.x,H=z.y,Z.push({x:Q,y:H});break;case"C":for(let q=1;q<=J;q++){let j=q/J,W=1-j,G=W*W*W*Q+3*W*W*j*z.x1+3*W*j*j*z.x2+j*j*j*z.x,F=W*W*W*H+3*W*W*j*z.y1+3*W*j*j*z.y2+j*j*j*z.y;Z.push({x:G,y:F})}Q=z.x,H=z.y;break;case"Q":for(let q=1;q<=J;q++){let j=q/J,W=1-j,G=W*W*Q+2*W*j*z.x1+j*j*z.x,F=W*W*H+2*W*j*z.y1+j*j*z.y;Z.push({x:G,y:F})}Q=z.x,H=z.y;break;case"A":Q=z.x,H=z.y,Z.push({x:Q,y:H});break;default:break}return Z}function bH($,J,Z,K=32){if(typeof $!=="number"||!isFinite($))throw new Error("circleToPoints: cx must be a finite number");if(typeof J!=="number"||!isFinite(J))throw new Error("circleToPoints: cy must be a finite number");if(typeof Z!=="number"||!isFinite(Z)||Z<0)throw new Error("circleToPoints: r must be a non-negative finite number");if(typeof K!=="number"||K<=0)throw new Error("circleToPoints: segments must be a positive number");let Q=[];for(let H=0;H<K;H++){let z=H/K*2*Math.PI;Q.push({x:$+Z*Math.cos(z),y:J+Z*Math.sin(z)})}return Q}function fH($,J,Z,K,Q=32){if(typeof $!=="number"||!isFinite($))throw new Error("ellipseToPoints: cx must be a finite number");if(typeof J!=="number"||!isFinite(J))throw new Error("ellipseToPoints: cy must be a finite number");if(typeof Z!=="number"||!isFinite(Z)||Z<0)throw new Error("ellipseToPoints: rx must be a non-negative finite number");if(typeof K!=="number"||!isFinite(K)||K<0)throw new Error("ellipseToPoints: ry must be a non-negative finite number");if(typeof Q!=="number"||Q<=0)throw new Error("ellipseToPoints: segments must be a positive number");let H=[];for(let z=0;z<Q;z++){let q=z/Q*2*Math.PI;H.push({x:$+Z*Math.cos(q),y:J+K*Math.sin(q)})}return H}function SH($){if(typeof $!=="string")throw new Error("parsePoints: pointsStr must be a string");let J=[],Z=$.trim().split(/[\s,]+/).map(Number).filter((K)=>!isNaN(K)&&isFinite(K));if(Z.length%2!==0)throw new Error("parsePoints: pointsStr must contain an even number of valid coordinates");for(let K=0;K<Z.length;K+=2)J.push({x:Z[K],y:Z[K+1]});return J}function QK($,J=2){if(!Array.isArray($))throw new Error("markersToPathData: markerInstances must be an array");if(typeof J!=="number"||J<0)throw new Error("markersToPathData: precision must be a non-negative number");let Z=[];for(let K of $){let Q=EH(K,{precision:J});for(let H of Q){if(H.length===0)continue;let z=H[0];Z.push(`M ${z.x.toFixed(J)} ${z.y.toFixed(J)}`);for(let q=1;q<H.length;q++){let j=H[q];Z.push(`L ${j.x.toFixed(J)} ${j.y.toFixed(J)}`)}Z.push("Z")}}return Z.join(" ")}L.set({precision:80});var k0=($)=>$ instanceof L?$:new L($),a0=new L(0),w6=new L(1);function R6(){let $=L.precision;if($<20)throw new Error(`Decimal precision (${$}) is too low for verification. Minimum required: 20`);let J=Math.max(1,$-10);return new L(10).pow(-J)}function WK($,J,Z){let K=R6();if(!$)return{valid:!1,error:new L(1/0),tolerance:K,message:"Matrix parameter is null or undefined"};if(J==null||Z==null)return{valid:!1,error:new L(1/0),tolerance:K,message:"Coordinates x or y are null or undefined"};let Q=k0(J),H=k0(Z);try{let[z,q]=l0($,Q,H),j=$.inverse();if(!j)return{valid:!1,error:new L(1/0),tolerance:K,message:"Matrix is not invertible (determinant = 0)",details:{determinant:$.determinant()}};let[W,G]=l0(j,z,q),F=Q.minus(W).abs(),_=H.minus(G).abs(),U=L.max(F,_),M=U.lessThan(K);return{valid:M,error:U,tolerance:K,message:M?`Round-trip verified: error ${U.toExponential()} < tolerance ${K.toExponential()}`:`Round-trip FAILED: error ${U.toExponential()} >= tolerance ${K.toExponential()}`,details:{original:{x:Q.toString(),y:H.toString()},transformed:{x:z.toString(),y:q.toString()},recovered:{x:W.toString(),y:G.toString()},errorX:F.toExponential(),errorY:_.toExponential()}}}catch(z){return{valid:!1,error:new L(1/0),tolerance:K,message:`Verification error: ${z.message}`}}}function m9($){let J=R6();if(!$)return{valid:!1,error:new L(1/0),tolerance:J,message:"Matrix parameter is null or undefined"};try{let Z=$.inverse();if(!Z)return{valid:!1,error:new L(1/0),tolerance:J,message:"Matrix is singular (not invertible)",details:{determinant:$.determinant().toString()}};let K=$.mul(Z),Q=$.rows,H=a0,z=[];for(let j=0;j<Q;j++)for(let W=0;W<Q;W++){let G=j===W?w6:a0,F=K.data[j][W],_=F.minus(G).abs();if(_.greaterThan(H))H=_;if(_.greaterThanOrEqualTo(J))z.push({row:j,col:W,expected:G.toString(),actual:F.toString(),error:_.toExponential()})}let q=H.lessThan(J);return{valid:q,error:H,tolerance:J,message:q?`Matrix inversion verified: max error ${H.toExponential()} < tolerance`:`Matrix inversion FAILED: max error ${H.toExponential()} at ${z.length} positions`,details:{matrixSize:`${Q}x${Q}`,maxError:H.toExponential(),failedElements:z.slice(0,5)}}}catch(Z){return{valid:!1,error:new L(1/0),tolerance:J,message:`Verification error: ${Z.message}`}}}function HK($,J,Z=null){let K=R6(),Q=Z||new L("1e-6");if(!$||!Array.isArray($))return{valid:!1,error:a0,tolerance:K,message:"Inner polygon parameter is null, undefined, or not an array"};if(!J||!Array.isArray(J))return{valid:!1,error:a0,tolerance:K,message:"Outer polygon parameter is null, undefined, or not an array"};if($.length<3||J.length<3)return{valid:!1,error:a0,tolerance:K,message:"Polygons must have at least 3 vertices"};try{let H=!0,z=[],q=a0;for(let j=0;j<$.length;j++){let W=$[j];if(!hH(W,J)){let G=DH(W,J);if(G.greaterThan(q))q=G;if(G.greaterThan(Q))H=!1,z.push({index:j,x:W.x.toString(),y:W.y.toString(),distanceOutside:G.toExponential()})}}return{valid:H,error:q,tolerance:Q,message:H?`All inner polygon points are inside or within tolerance (max outside: ${q.toExponential()})`:`${z.length} points exceed tolerance distance outside outer polygon`,details:{innerVertices:$.length,outerVertices:J.length,maxOutsideDistance:q.toExponential(),outsidePoints:z.slice(0,5)}}}catch(H){return{valid:!1,error:new L(1/0),tolerance:K,message:`Verification error: ${H.message}`}}}function DH($,J){if(!$||$.x==null||$.y==null)throw new Error("Invalid point parameter: must have x and y properties");if(!J||!Array.isArray(J)||J.length===0)throw new Error("Invalid polygon parameter: must be non-empty array of points");let Z=new L(1/0),K=k0($.x),Q=k0($.y);for(let H=0;H<J.length;H++){let z=(H+1)%J.length,q=J[H],j=J[z],W=k0(q.x),G=k0(q.y),F=k0(j.x),_=k0(j.y),U=F.minus(W),M=_.minus(G),V=U.times(U).plus(M.times(M)),Y;if(V.isZero())Y=FK($,q);else{let O=L.max(a0,L.min(w6,K.minus(W).times(U).plus(Q.minus(G).times(M)).div(V))),X=W.plus(O.times(U)),w=G.plus(O.times(M));Y=K.minus(X).pow(2).plus(Q.minus(w).pow(2)).sqrt()}if(Y.lessThan(Z))Z=Y}return Z}function jK($,J,Z){let K=R6();if(!$||!Array.isArray($))return{valid:!1,error:a0,tolerance:K,message:"Poly1 parameter must be an array"};if(!J||!Array.isArray(J))return{valid:!1,error:a0,tolerance:K,message:"Poly2 parameter must be an array"};if(!Z||!Array.isArray(Z))return{valid:!1,error:a0,tolerance:K,message:"Intersection parameter must be an array"};if(Z.length<3)return{valid:!0,error:a0,tolerance:K,message:"Intersection is empty or degenerate (valid result)",details:{intersectionVertices:Z.length}};try{let Q=HK(Z,$),H=HK(Z,J),z=l6($),q=l6(J),j=l6(Z),W=L.min(z,q),G=j.lessThanOrEqualTo(W.times(w6.plus(K))),F=Q.valid&&H.valid&&G;return{valid:F,error:F?a0:w6,tolerance:K,message:F?"Intersection verified: contained in both polygons, area valid":`Intersection FAILED: ${!Q.valid?"not in poly1, ":""}${!H.valid?"not in poly2, ":""}${!G?"area too large":""}`,details:{containedInPoly1:Q.valid,containedInPoly2:H.valid,area1:z.toString(),area2:q.toString(),intersectionArea:j.toString(),areaValid:G}}}catch(Q){return{valid:!1,error:new L(1/0),tolerance:K,message:`Verification error: ${Q.message}`}}}function GK($,J,Z){let K=R6();if(!$||typeof $!=="object")return{valid:!1,error:new L(1/0),tolerance:K,message:"Original gradient parameter must be an object"};if(!J||typeof J!=="object")return{valid:!1,error:new L(1/0),tolerance:K,message:"Baked gradient parameter must be an object"};if(!Z)return{valid:!1,error:new L(1/0),tolerance:K,message:"Matrix parameter is null or undefined"};try{let[Q,H]=l0(Z,k0($.x1||0),k0($.y1||0)),[z,q]=l0(Z,k0($.x2||1),k0($.y2||0)),j=k0(J.x1).minus(Q).abs(),W=k0(J.y1).minus(H).abs(),G=k0(J.x2).minus(z).abs(),F=k0(J.y2).minus(q).abs(),_=L.max(j,W,G,F),U=_.lessThan(K);return{valid:U,error:_,tolerance:K,message:U?`Linear gradient transform verified: max error ${_.toExponential()}`:`Linear gradient transform FAILED: max error ${_.toExponential()}`,details:{expected:{x1:Q.toString(),y1:H.toString(),x2:z.toString(),y2:q.toString()},actual:J}}}catch(Q){return{valid:!1,error:new L(1/0),tolerance:K,message:`Verification error: ${Q.message}`}}}function l6($){if(!$||!Array.isArray($))throw new Error("Invalid polygon parameter: must be an array");if($.length<3)return a0;let J=a0,Z=$.length;for(let K=0;K<Z;K++){let Q=(K+1)%Z,H=k0($[K].x),z=k0($[K].y),q=k0($[Q].x),j=k0($[Q].y);J=J.plus(H.times(j).minus(q.times(z)))}return J.abs().div(2)}function hH($,J){if(!$||$.x==null||$.y==null)throw new Error("Invalid point parameter: must have x and y properties");if(!J||!Array.isArray(J)||J.length===0)throw new Error("Invalid polygon parameter: must be non-empty array of points");let Z=k0($.x),K=k0($.y),Q=J.length,H=!1;for(let z=0,q=Q-1;z<Q;q=z++){let j=k0(J[z].x),W=k0(J[z].y),G=k0(J[q].x),F=k0(J[q].y);if(yH($,J[z],J[q]))return!0;if(W.greaterThan(K)!==F.greaterThan(K)&&Z.lessThan(G.minus(j).times(K.minus(W)).div(F.minus(W)).plus(j)))H=!H}return H}function yH($,J,Z){if(!$||$.x==null||$.y==null)throw new Error("Invalid point parameter: must have x and y properties");if(!J||J.x==null||J.y==null)throw new Error("Invalid segStart parameter: must have x and y properties");if(!Z||Z.x==null||Z.y==null)throw new Error("Invalid segEnd parameter: must have x and y properties");let K=R6(),Q=k0($.x),H=k0($.y),z=k0(J.x),q=k0(J.y),j=k0(Z.x),W=k0(Z.y),G=L.min(z,j).minus(K),F=L.max(z,j).plus(K),_=L.min(q,W).minus(K),U=L.max(q,W).plus(K);if(Q.lessThan(G)||Q.greaterThan(F)||H.lessThan(_)||H.greaterThan(U))return!1;let M=j.minus(z).times(H.minus(q)).minus(W.minus(q).times(Q.minus(z))).abs(),V=FK(J,Z);return M.div(V.plus(K)).lessThan(K)}function FK($,J){if(!$||$.x==null||$.y==null)throw new Error("Invalid p1 parameter: must have x and y properties");if(!J||J.x==null||J.y==null)throw new Error("Invalid p2 parameter: must have x and y properties");let Z=k0(J.x).minus(k0($.x)),K=k0(J.y).minus(k0($.y));return Z.times(Z).plus(K.times(K)).sqrt()}function _K($,J){if(!$||$.length<3||!J||J.length<3)return[];let Z=[];for(let K=0;K<J.length;K++){let Q=J[K],H=J[(K+1)%J.length],z=[];for(let q=0;q<$.length;q++){let j=$[q],W=$[(q+1)%$.length],G=!zK(j,Q,H),F=!zK(W,Q,H);if(G){if(z.push(j),!F)z.push(qK(j,W,Q,H))}else if(F)z.push(qK(j,W,Q,H))}if(z.length>=3)Z.push(z)}return Z}function UK($,J,Z=[],K="1e-10"){let Q=K instanceof L?K:new L(K),H=Z||[];if(!$||!Array.isArray($))return{valid:!1,error:new L(1/0),tolerance:Q,message:"Original polygon parameter must be an array"};if(!J||!Array.isArray(J))return{valid:!1,error:new L(1/0),tolerance:Q,message:"Clipped polygon parameter must be an array"};try{let z=l6($),q=J.length>=3?l6(J):a0,j=z.minus(q),W=q.lessThanOrEqualTo(z.times(w6.plus(Q))),G=j.greaterThanOrEqualTo(a0.minus(Q.times(z))),F=z.isZero()?w6:q.div(z),_=a0,U=W&&G;return{valid:U,error:_,tolerance:Q,message:U?`ClipPath E2E verified: area conserved (clipped ${F.times(100).toFixed(2)}% of original)`:"ClipPath E2E FAILED: invalid intersection (clipped > original or negative outside)",details:{originalArea:z.toString(),clippedArea:q.toString(),outsideArea:j.toString(),areaRatio:F.toFixed(6),fragmentCount:H.length,clippedValid:W,outsideValid:G}}}catch(z){return{valid:!1,error:new L(1/0),tolerance:Q,message:`E2E verification error: ${z.message}`}}}function zK($,J,Z){if(!$||$.x==null||$.y==null)throw new Error("Invalid point parameter: must have x and y properties");if(!J||J.x==null||J.y==null)throw new Error("Invalid edgeStart parameter: must have x and y properties");if(!Z||Z.x==null||Z.y==null)throw new Error("Invalid edgeEnd parameter: must have x and y properties");let K=k0($.x).toNumber(),Q=k0($.y).toNumber(),H=k0(J.x).toNumber(),z=k0(J.y).toNumber(),q=k0(Z.x).toNumber(),j=k0(Z.y).toNumber();return(q-H)*(Q-z)-(j-z)*(K-H)>=0}function qK($,J,Z,K){if(!$||$.x==null||$.y==null)throw new Error("Invalid p1 parameter: must have x and y properties");if(!J||J.x==null||J.y==null)throw new Error("Invalid p2 parameter: must have x and y properties");if(!Z||Z.x==null||Z.y==null)throw new Error("Invalid p3 parameter: must have x and y properties");if(!K||K.x==null||K.y==null)throw new Error("Invalid p4 parameter: must have x and y properties");let Q=k0($.x).toNumber(),H=k0($.y).toNumber(),z=k0(J.x).toNumber(),q=k0(J.y).toNumber(),j=k0(Z.x).toNumber(),W=k0(Z.y).toNumber(),G=k0(K.x).toNumber(),F=k0(K.y).toNumber(),_=(Q-z)*(W-F)-(H-q)*(j-G);if(Math.abs(_)<0.0000000001)return{x:k0((Q+z)/2),y:k0((H+q)/2)};let U=((Q-j)*(W-F)-(H-W)*(j-G))/_;return{x:k0(Q+U*(z-Q)),y:k0(H+U*(q-H))}}var YK=["animate","animateTransform","animateMotion","animateColor","set"],VK=["href","xlink:href"],MK=["fill","stroke","clip-path","mask","filter","marker-start","marker-mid","marker-end","cursor","color-profile"],gH=["begin","end"],xH=["values","from","to","by"];function d9($){if(!$||typeof $!=="string")return null;let J=$.match(/url\(\s*["']?#([^"')\s]+)\s*["']?\s*\)/);return J&&J[1]?J[1]:null}function OK($){if(!$||typeof $!=="string")return null;if($.startsWith("#")){let J=$.substring(1);return J&&!J.startsWith("#")?J:null}return null}function XK($){if(!$||typeof $!=="string")return[];let J=[],Z=$.split(";");for(let K of Z){let Q=K.trim();if(Q.startsWith("#")){let z=Q.substring(1);if(z)J.push(z)}let H=d9(Q);if(H)J.push(H)}return J}function LK($){if(!$||typeof $!=="string")return[];let J=[],Z=$.split(";");for(let K of Z){let H=K.trim().match(/^([a-zA-Z_][a-zA-Z0-9_-]*)\.(begin|end|click|mousedown|mouseup|mouseover|mouseout|mousemove|mouseenter|mouseleave|focusin|focusout|activate|repeat)(?:\(\d+\))?(?:[+-]\d+(?:\.\d+)?[a-z]*)?/);if(H)J.push(H[1])}return J}function n6($){if(!$||typeof $!=="string")return[];let J=[],Z=/url\(\s*["']?#([^"')]+)["']?\s*\)/g,K;while((K=Z.exec($))!==null)if(K[1])J.push(K[1]);return J}function kK($){if(!$||typeof $!=="string")return[];let J=[],Z=/getElementById\(\s*["']([^"']+)["']\s*\)/g,K;while((K=Z.exec($))!==null)if(K[1])J.push(K[1]);let Q=/querySelector(?:All)?\(\s*["']#([^"'#\s]+)["']\s*\)/g;while((K=Q.exec($))!==null)if(K[1])J.push(K[1]);return J}function mH($){if(!$||typeof $!=="object"||!($ instanceof B0))throw new TypeError("collectElementReferences: el must be a valid SVGElement");if(typeof $.getAttributeNames!=="function")throw new TypeError("collectElementReferences: el must have getAttributeNames method");let J={static:new Set,animation:new Set,css:new Set,js:new Set},Z=$.tagName?.toLowerCase()||"",K=YK.includes(Z),Q=$.getAttributeNames();if(!Array.isArray(Q))throw new TypeError("collectElementReferences: getAttributeNames must return an array");for(let H of Q){let z=$.getAttribute(H);if(!z)continue;if(VK.includes(H)){let q=OK(z);if(q)if(K)J.animation.add(q);else J.static.add(q)}if(MK.includes(H)||H==="style"){let q=d9(z);if(q)J.static.add(q);if(H==="style")n6(z).forEach((j)=>J.css.add(j))}if(gH.includes(H))LK(z).forEach((q)=>J.animation.add(q));if(xH.includes(H))XK(z).forEach((q)=>J.animation.add(q));if(!MK.includes(H)&&z.includes("url(")){let q=d9(z);if(q)J.static.add(q)}}if(Z==="animatemotion"){if(typeof $.getElementsByTagName!=="function")throw new TypeError("collectElementReferences: el must have getElementsByTagName method");let H=$.getElementsByTagName("mpath");if(!H||typeof H[Symbol.iterator]!=="function")throw new TypeError("collectElementReferences: getElementsByTagName must return an iterable");for(let z of H){if(!z||typeof z.getAttribute!=="function")continue;for(let q of VK){let j=z.getAttribute(q),W=OK(j);if(W)J.animation.add(W)}}}return J}function wK($){if(!$||typeof $!=="object"||!($ instanceof B0))throw new TypeError("collectAllReferences: root must be a valid SVGElement");let J={all:new Set,static:new Set,animation:new Set,css:new Set,js:new Set,details:new Map},Z={animation:4,js:3,css:2,static:1},K=(H,z,q)=>{if(J.all.add(H),J[z].add(H),!J.details.has(H))J.details.set(H,{sources:[],type:z});else{let j=J.details.get(H);if(Z[z]>Z[j.type])j.type=z}J.details.get(H).sources.push(q)},Q=(H,z="")=>{let q=H.tagName?.toLowerCase()||"",j=z?`${z}>${q}`:q,W=H.getAttribute("id"),G=W?`${q}#${W}`:j,F=mH(H);if(F.static.forEach((_)=>K(_,"static",G)),F.animation.forEach((_)=>K(_,"animation",G)),F.css.forEach((_)=>K(_,"css",G)),F.js.forEach((_)=>K(_,"js",G)),q==="style"){let _=H.textContent||"";n6(_).forEach((U)=>K(U,"css","<style>"))}if(q==="script"){let _=H.textContent||"";kK(_).forEach((U)=>K(U,"js","<script>"))}if(H.children&&typeof H.children[Symbol.iterator]==="function"){for(let _ of H.children)if(_ instanceof B0)Q(_,j)}};return Q($),J}L.set({precision:80});var L7=($)=>$ instanceof L?$:new L($),dH={precision:6,curveSegments:20,clipSegments:64,bezierArcs:8,resolveUse:!0,resolveMarkers:!0,resolvePatterns:!0,resolveMasks:!0,resolveClipPaths:!0,flattenTransforms:!0,bakeGradients:!0,removeUnusedDefs:!0,preserveIds:!1,svg2Polyfills:!1,e2eTolerance:"1e-10"};function N6($,J={}){if($===null||$===void 0)throw new Error("flattenSVG: svgString parameter is required");if(typeof $!=="string")throw new Error(`flattenSVG: svgString must be a string, got ${typeof $}`);if($.trim().length===0)throw new Error("flattenSVG: svgString cannot be empty");let Z={...dH,...J},K={useResolved:0,markersResolved:0,patternsResolved:0,masksResolved:0,clipPathsApplied:0,transformsFlattened:0,gradientsProcessed:0,defsRemoved:0,errors:[],verifications:{transforms:[],matrices:[],polygons:[],gradients:[],e2e:[],passed:0,failed:0,allPassed:!0},clipOutsideFragments:[]};try{let Q=p0($);if(Q.tagName.toLowerCase()!=="svg")throw new Error("Root element must be <svg>");let H=t7(Q),z=Z.removeUnusedDefs?aH(Q):null;if(Z.resolveUse){let j=pH(Q,H,Z);K.useResolved=j.count,K.errors.push(...j.errors),H=t7(Q)}if(Z.resolveMarkers){let j=cH(Q,H,Z);K.markersResolved=j.count,K.errors.push(...j.errors)}if(Z.resolvePatterns){let j=lH(Q,H,Z);K.patternsResolved=j.count,K.errors.push(...j.errors)}if(Z.resolveMasks){let j=nH(Q,H,Z);K.masksResolved=j.count,K.errors.push(...j.errors)}if(Z.resolveClipPaths){let j=sH(Q,H,Z,K);K.clipPathsApplied=j.count,K.errors.push(...j.errors)}if(Z.flattenTransforms){let j=oH(Q,Z,K);K.transformsFlattened=j.count,K.errors.push(...j.errors)}if(Z.bakeGradients){let j=rH(Q,Z,K);K.gradientsProcessed=j.count,K.errors.push(...j.errors)}if(Z.removeUnusedDefs&&z){let j=tH(Q,z);K.defsRemoved=j.count}return{svg:N7(Q),stats:K}}catch(Q){return K.errors.push(`Pipeline error: ${Q.message}`),{svg:$,stats:K}}}var CK=new Set(["animate","animatetransform","animatemotion","animatecolor","set"]),IK=new Set(["foreignobject","audio","video","iframe","script","style",...CK]);function p9($){if(!$)return!1;let J=$.tagName?.toLowerCase();if(IK.has(J))return!0;for(let Z of $.children||[])if(Z&&Z.tagName&&p9(Z))return!0;return!1}function pH($,J,Z){if(!$||!$.getElementsByTagName)throw new Error("resolveAllUseElements: invalid root element");if(!J||!(J instanceof Map))throw new Error("resolveAllUseElements: defsMap must be a Map");if(!Z||typeof Z!=="object")throw new Error("resolveAllUseElements: opts must be an object");let K=[],Q=0,H=$.getElementsByTagName("use"),z={};for(let[q,j]of J.entries())if(j.tagName.toLowerCase()==="symbol")z[q]=r5(j),z[q].type="symbol";else z[q]=b$(j);for(let q of[...H])try{let j=q.getAttribute("href")||q.getAttribute("xlink:href");if(!j)continue;let W=j.replace(/^#/,""),G=J.get(W);if(!G){K.push(`use: referenced element #${W} not found`);continue}let F=p9(G),_=p9(q);if(F||_){let Y=G.cloneNode(!0),O=parseFloat(q.getAttribute("x")||"0"),X=parseFloat(q.getAttribute("y")||"0");if(isNaN(O)||isNaN(X)){K.push(`use: invalid x/y coordinates for element #${W}`);continue}let w=q.getAttribute("transform")||"",R="";if(w)R=w;if(O!==0||X!==0){let m=`translate(${O}, ${X})`;R=R?`${R} ${m}`:m}let B=new B0("g",{});if(R)B.setAttribute("transform",R);let I=s6(q);for(let[m,v]of Object.entries(I))if(v&&!B.hasAttribute(m))B.setAttribute(m,v);if(G.tagName.toLowerCase()==="symbol"){for(let m of Y.children||[])if(m&&m.tagName)B.appendChild(m.cloneNode(!0))}else Y.removeAttribute("id"),B.appendChild(Y);for(let m of q.children||[])if(m&&m.tagName){let v=m.tagName.toLowerCase();if(CK.has(v))B.appendChild(m.cloneNode(!0))}if(q.parentNode)q.parentNode.replaceChild(B,q),Q++;continue}let U=i5(q),M=g9(U,z,{samples:Z.curveSegments});if(!M){K.push(`use: failed to resolve #${W}`);continue}let V=e5(M,Z.curveSegments);if(V){let Y=new B0("path",{d:V,...s6(q)});if(M.style){for(let[O,X]of Object.entries(M.style))if(X&&!Y.hasAttribute(O))Y.setAttribute(O,X)}if(q.parentNode)q.parentNode.replaceChild(Y,q),Q++}}catch(j){K.push(`use: ${j.message}`)}return{count:Q,errors:K}}function cH($,J,Z){if(!$||!$.getElementsByTagName)throw new Error("resolveAllMarkers: invalid root element");if(!J||!(J instanceof Map))throw new Error("resolveAllMarkers: defsMap must be a Map");if(!Z||typeof Z!=="object")throw new Error("resolveAllMarkers: opts must be an object");let K=[],Q=0,H=["marker-start","marker-mid","marker-end","marker"];for(let z of H){let q=x7($,z);for(let j of q){if(j.tagName!=="path"&&j.tagName!=="line"&&j.tagName!=="polyline"&&j.tagName!=="polygon")continue;try{let W=ZK(j,Object.fromEntries(J));if(!W||W.length===0)continue;let G=QK(W,Z.precision);if(G){let F=new B0("path",{d:G,fill:j.getAttribute("stroke")||"currentColor"});if(j.parentNode){let _=j.nextSibling;if(_)j.parentNode.insertBefore(F,_);else j.parentNode.appendChild(F);Q++}}for(let F of H)j.removeAttribute(F)}catch(W){K.push(`marker: ${W.message}`)}}}return{count:Q,errors:K}}function lH($,J,Z){if(!$||!$.getElementsByTagName)throw new Error("resolveAllPatterns: invalid root element");if(!J||!(J instanceof Map))throw new Error("resolveAllPatterns: defsMap must be a Map");if(!Z||typeof Z!=="object")throw new Error("resolveAllPatterns: opts must be an object");let K=[],Q=0,H=x7($,"fill");for(let z of H){let q=z.getAttribute("fill");if(!q||!q.includes("url("))continue;let j=e7(q);if(!j)continue;let W=J.get(j);if(!W||W.tagName.toLowerCase()!=="pattern")continue;try{let G=W.getAttribute("patternUnits")||"objectBoundingBox",F=W.getAttribute("patternContentUnits")||"userSpaceOnUse",_=W.getAttribute("patternTransform");if(G!=="objectBoundingBox")K.push(`pattern ${j}: non-default patternUnits="${G}" may cause rendering issues`);if(F!=="userSpaceOnUse")K.push(`pattern ${j}: non-default patternContentUnits="${F}" may cause rendering issues`);if(_)K.push(`pattern ${j}: patternTransform present - complex transformation may cause rendering issues`);let U=PK(z);if(!U)continue;let M=$K(W),V=JK(M,U,{samples:Z.curveSegments});if(V){let Y=new B0("g",{}),O=new B0("path",{d:V,fill:"#000"});if(Y.appendChild(O),z.setAttribute("fill","none"),z.setAttribute("stroke",z.getAttribute("stroke")||"none"),z.parentNode)z.parentNode.insertBefore(Y,z),Q++}}catch(G){K.push(`pattern: ${G.message}`)}}return{count:Q,errors:K}}function nH($,J,Z){if(!$||!$.getElementsByTagName)throw new Error("resolveAllMasks: invalid root element");if(!J||!(J instanceof Map))throw new Error("resolveAllMasks: defsMap must be a Map");if(!Z||typeof Z!=="object")throw new Error("resolveAllMasks: opts must be an object");let K=[],Q=0,H=x7($,"mask");for(let z of H){let q=z.getAttribute("mask");if(!q||!q.includes("url("))continue;let j=e7(q);if(!j)continue;let W=J.get(j);if(!W||W.tagName.toLowerCase()!=="mask")continue;try{let G=W.getAttribute("maskUnits")||"objectBoundingBox",F=W.getAttribute("maskContentUnits")||"userSpaceOnUse";if(G!=="objectBoundingBox")K.push(`mask ${j}: non-default maskUnits="${G}" may cause rendering issues`);if(F!=="userSpaceOnUse")K.push(`mask ${j}: non-default maskContentUnits="${F}" may cause rendering issues`);let _=PK(z);if(!_)continue;let U=s5(W),M=o5(U,_,{samples:Z.curveSegments,opacityThreshold:0.5});if(M){let V=B6(z,Z.precision);if(V){let Y=$6(V,Z.curveSegments),O=$6(M,Z.curveSegments),X=AK(Y,O);if(X&&X.length>2){let w=u9(X,Z.precision);z.setAttribute("d",w),z.removeAttribute("mask"),Q++}}}}catch(G){K.push(`mask: ${G.message}`)}}return{count:Q,errors:K}}function sH($,J,Z,K){if(!$||!$.getElementsByTagName)throw new Error("applyAllClipPaths: invalid root element");if(!J||!(J instanceof Map))throw new Error("applyAllClipPaths: defsMap must be a Map");if(!Z||typeof Z!=="object")throw new Error("applyAllClipPaths: opts must be an object");if(!K||typeof K!=="object")throw new Error("applyAllClipPaths: stats must be an object");let Q=[],H=0;if(!K.verifications.e2e)K.verifications.e2e=[];if(!K.clipOutsideFragments)K.clipOutsideFragments=[];let z=x7($,"clip-path");for(let q of z){let j=q.getAttribute("clip-path");if(!j||!j.includes("url("))continue;let W=e7(j);if(!W)continue;let G=J.get(W),F=G?G.tagName.toLowerCase():"";if(!G||F!=="clippath")continue;try{if((G.getAttribute("clipPathUnits")||"userSpaceOnUse")==="objectBoundingBox")Q.push(`clipPath ${W}: objectBoundingBox units require bbox-relative coordinate transformation`);let U=B6(q,Z.precision);if(!U)continue;let M="";if(G.children&&G.children.length>0){for(let B of G.children)if(B&&B.tagName){let I=B6(B,Z.precision);if(I)M+=(M?" ":"")+I}}if(!M)continue;let V=Z.clipSegments||64,Y=$6(U,V),O=$6(M,V),X=AK(Y,O),w=Y.map((B)=>({x:B.x instanceof L?B.x:L7(B.x),y:B.y instanceof L?B.y:L7(B.y)})),R=O.map((B)=>({x:B.x instanceof L?B.x:L7(B.x),y:B.y instanceof L?B.y:L7(B.y)}));if(X&&X.length>2){let B=X.map((x)=>({x:x.x instanceof L?x.x:L7(x.x),y:x.y instanceof L?x.y:L7(x.y)})),I=jK(w,R,B);if(K.verifications.polygons.push({element:q.tagName,clipPathId:W,...I}),I.valid)K.verifications.passed++;else K.verifications.failed++,K.verifications.allPassed=!1;let h=_K(w,R);K.clipOutsideFragments.push({elementId:q.getAttribute("id")||`clip-${H}`,clipPathId:W,fragments:h,visible:!1});let m=Z.e2eTolerance||"1e-10",v=UK(w,B,h,m);if(K.verifications.e2e.push({element:q.tagName,clipPathId:W,type:"clip-area-conservation",...v}),v.valid)K.verifications.passed++;else K.verifications.failed++,K.verifications.allPassed=!1}if(X&&X.length>2){let B=u9(X,Z.precision),I=q;if(q.tagName==="path")q.setAttribute("d",B);else{let h=new B0("path",{d:B,...s6(q)});if(q.parentNode)q.parentNode.replaceChild(h,q),I=h}I.removeAttribute("clip-path"),H++}}catch(_){Q.push(`clipPath: ${_.message}`)}}return{count:H,errors:Q}}function oH($,J,Z){if(!$||!$.getElementsByTagName)throw new Error("flattenAllTransforms: invalid root element");if(!J||typeof J!=="object")throw new Error("flattenAllTransforms: opts must be an object");if(!Z||typeof Z!=="object")throw new Error("flattenAllTransforms: stats must be an object");let K=[],Q=0,H=x7($,"transform");for(let z of H){let q=z.getAttribute("transform");if(!q)continue;try{let j=J7(q),W=m9(j);if(Z.verifications.matrices.push({element:z.tagName,transform:q,...W}),W.valid)Z.verifications.passed++;else Z.verifications.failed++,Z.verifications.allPassed=!1;let G=B6(z,J.precision);if(!G){if(z.tagName==="g")iH(z,j,J,Z),z.removeAttribute("transform"),Q++;continue}let F=[],_=$6(G,4);if(_&&_.length>0)F=_.slice(0,4).map((V)=>({x:V.x instanceof L?V.x:L7(V.x),y:V.y instanceof L?V.y:L7(V.y)}));let U=L6(G,j,{precision:J.precision});for(let V=0;V<F.length;V++){let Y=F[V],O=WK(j,Y.x,Y.y);if(Z.verifications.transforms.push({element:z.tagName,pointIndex:V,...O}),O.valid)Z.verifications.passed++;else Z.verifications.failed++,Z.verifications.allPassed=!1}let M=z;if(z.tagName==="path")z.setAttribute("d",U);else{let V=new B0("path",{d:U,...s6(z)});for(let Y of eH(z.tagName))V.removeAttribute(Y);if(z.parentNode)z.parentNode.replaceChild(V,z),M=V}M.removeAttribute("transform"),Q++}catch(j){K.push(`transform: ${j.message}`)}}return{count:Q,errors:K}}function iH($,J,Z,K){if(!$||!$.children)throw new Error("propagateTransformToChildren: invalid group element");if(!J||!J.data)throw new Error("propagateTransformToChildren: invalid matrix");if(!Z||typeof Z!=="object")throw new Error("propagateTransformToChildren: opts must be an object");if(!K||typeof K!=="object")throw new Error("propagateTransformToChildren: stats must be an object");for(let Q of[...$.children]){if(!(Q&&Q.tagName))continue;if(Q.tagName==="g"){let H=Q.getAttribute("transform");if(H){let z=J7(H),q=J.mul(z);Q.setAttribute("transform",RK(q))}else Q.setAttribute("transform",RK(J))}else{let H=B6(Q,Z.precision);if(H){let z=Q.getAttribute("transform"),q=J;if(z){let F=J7(z);q=J.mul(F)}let j=m9(q);if(K.verifications.matrices.push({element:Q.tagName,context:"group-propagation",...j}),j.valid)K.verifications.passed++;else K.verifications.failed++,K.verifications.allPassed=!1;let W=L6(H,q,{precision:Z.precision}),G=Q;if(Q.tagName==="path")Q.setAttribute("d",W);else{let F=new B0("path",{d:W,...s6(Q)});$.replaceChild(F,Q),G=F}G.removeAttribute("transform")}}}}function rH($,J,Z){if(!$||!$.getElementsByTagName)throw new Error("bakeAllGradientTransforms: invalid root element");if(!J||typeof J!=="object")throw new Error("bakeAllGradientTransforms: opts must be an object");if(!Z||typeof Z!=="object")throw new Error("bakeAllGradientTransforms: stats must be an object");let K=[],Q=0,H=$.getElementsByTagName("linearGradient");for(let q of H){let j=q.getAttribute("gradientTransform");if(!j)continue;try{let W=J7(j),G=parseFloat(q.getAttribute("x1")||"0"),F=parseFloat(q.getAttribute("y1")||"0"),_=parseFloat(q.getAttribute("x2")||"1"),U=parseFloat(q.getAttribute("y2")||"0");if(isNaN(G)||isNaN(F)||isNaN(_)||isNaN(U)){K.push(`linearGradient: invalid coordinate values for gradient ${q.getAttribute("id")||"unknown"}`);continue}let[M,V]=l0(W,G,F),[Y,O]=l0(W,_,U),X=GK({x1:G,y1:F,x2:_,y2:U},{x1:M.toNumber(),y1:V.toNumber(),x2:Y.toNumber(),y2:O.toNumber()},W);if(Z.verifications.gradients.push({gradientId:q.getAttribute("id")||"unknown",type:"linear",...X}),X.valid)Z.verifications.passed++;else Z.verifications.failed++,Z.verifications.allPassed=!1;q.setAttribute("x1",M.toFixed(J.precision)),q.setAttribute("y1",V.toFixed(J.precision)),q.setAttribute("x2",Y.toFixed(J.precision)),q.setAttribute("y2",O.toFixed(J.precision)),q.removeAttribute("gradientTransform"),Q++}catch(W){K.push(`linearGradient: ${W.message}`)}}let z=$.getElementsByTagName("radialGradient");for(let q of z){let j=q.getAttribute("gradientTransform");if(!j)continue;try{let W=J7(j),G=parseFloat(q.getAttribute("cx")||"0.5"),F=parseFloat(q.getAttribute("cy")||"0.5"),_=parseFloat(q.getAttribute("fx")||G.toString()),U=parseFloat(q.getAttribute("fy")||F.toString()),M=parseFloat(q.getAttribute("r")||"0.5");if(isNaN(G)||isNaN(F)||isNaN(_)||isNaN(U)||isNaN(M)){K.push(`radialGradient: invalid coordinate/radius values for gradient ${q.getAttribute("id")||"unknown"}`);continue}if(M<=0){K.push(`radialGradient: radius must be positive for gradient ${q.getAttribute("id")||"unknown"}`);continue}let[V,Y]=l0(W,G,F),[O,X]=l0(W,_,U),w=W.data[0][0].toNumber()*W.data[1][1].toNumber();if(Math.abs(w)<0.0000000001){K.push("radialGradient: matrix determinant too close to zero (degenerate transform)");continue}let R=Math.sqrt(Math.abs(w)),B=M*R;q.setAttribute("cx",V.toFixed(J.precision)),q.setAttribute("cy",Y.toFixed(J.precision)),q.setAttribute("fx",O.toFixed(J.precision)),q.setAttribute("fy",X.toFixed(J.precision)),q.setAttribute("r",B.toFixed(J.precision)),q.removeAttribute("gradientTransform"),Q++}catch(W){K.push(`radialGradient: ${W.message}`)}}return{count:Q,errors:K}}function aH($){if(!$||!$.getElementsByTagName)throw new Error("collectAllReferences: invalid root element");let J=new Set,Z=(K)=>{if(!K||!K.getAttributeNames)return;if(K.tagName&&K.tagName.toLowerCase()==="style"){let Q=K.textContent||"";if(Q)n6(Q).forEach((z)=>J.add(z))}for(let Q of K.getAttributeNames()){let H=K.getAttribute(Q);if(!H)continue;if(H.includes("url(")){let z=e7(H);if(z)J.add(z)}if(Q==="href"||Q==="xlink:href"){let z=H.replace(/^#/,"");if(z&&z!==H)J.add(z)}}for(let Q of K.children)if(Q&&Q.tagName)Z(Q)};return Z($),J}function tH($,J){if(!$||!$.getElementsByTagName)throw new Error("removeUnusedDefinitions: invalid root element");if(!J||!(J instanceof Set))throw new Error("removeUnusedDefinitions: referencedIds must be a Set");let Z=0;function K(H){if(!H||!H.getAttribute)return!1;let z=H.getAttribute("id");if(z&&J.has(z))return!0;for(let q of H.children||[])if(q&&q.tagName&&K(q))return!0;return!1}let Q=$.getElementsByTagName("defs");for(let H of Q)for(let z of[...H.children])if(z&&z.tagName){let q=z.tagName.toLowerCase();if(IK.has(q))continue;if(!K(z))H.removeChild(z),Z++}return{count:Z}}function B6($,J){if(!$||!$.tagName)return null;if(typeof J!=="number"||isNaN(J)||J<0)throw new Error(`getElementPathData: precision must be a non-negative number, got ${J}`);let Z=$.tagName.toLowerCase();if(Z==="path")return $.getAttribute("d");let K=(Q,H=0)=>{let z=$.getAttribute(Q);if(z===null)return H;let q=parseFloat(z);if(isNaN(q))throw new Error(`getElementPathData: invalid numeric value "${z}" for attribute "${Q}"`);return q};switch(Z){case"rect":{let H=$.getAttribute("ry")!==null?K("ry"):null;return R9(K("x"),K("y"),K("width"),K("height"),K("rx"),H,!1,J)}case"circle":return k9(K("cx"),K("cy"),K("r"),J);case"ellipse":return w9(K("cx"),K("cy"),K("rx"),K("ry"),J);case"line":return B9(K("x1"),K("y1"),K("x2"),K("y2"),J);case"polyline":return w$($.getAttribute("points")||"",J);case"polygon":return N9($.getAttribute("points")||"",J);default:return null}}function PK($){if(!$||!$.tagName)return null;let J=B6($,6);if(!J)return null;try{let Z=$6(J,10);if(!Z||Z.length===0)return null;let K=1/0,Q=1/0,H=-1/0,z=-1/0;for(let q of Z){if(!q||q.x===void 0&&q.y===void 0)continue;let j=q.x instanceof L?q.x.toNumber():typeof q.x==="number"?q.x:0,W=q.y instanceof L?q.y.toNumber():typeof q.y==="number"?q.y:0;if(isNaN(j)||isNaN(W))continue;if(j<K)K=j;if(W<Q)Q=W;if(j>H)H=j;if(W>z)z=W}if(K===1/0||H===-1/0||Q===1/0||z===-1/0)return null;return{x:K,y:Q,width:H-K,height:z-Q}}catch{return null}}function s6($){if(!$||!$.getAttribute)return{};let J=["stroke","stroke-width","stroke-linecap","stroke-linejoin","stroke-dasharray","stroke-dashoffset","stroke-miterlimit","stroke-opacity","vector-effect","fill","fill-opacity","fill-rule","clip-path","mask","filter","opacity","clip-rule","marker","marker-start","marker-mid","marker-end","visibility","display","color","font-family","font-size","font-weight","font-style","text-anchor","dominant-baseline","alignment-baseline","letter-spacing","word-spacing","text-decoration","shape-rendering","text-rendering","image-rendering","color-rendering","paint-order","pointer-events","cursor","class","style","id"],Z={};for(let K of J){let Q=$.getAttribute(K);if(Q!==null)Z[K]=Q}return Z}function eH($){if(!$||typeof $!=="string")return[];return{rect:["x","y","width","height","rx","ry"],circle:["cx","cy","r"],ellipse:["cx","cy","rx","ry"],line:["x1","y1","x2","y2"],polyline:["points"],polygon:["points"],image:["x","y","width","height","href","xlink:href","preserveAspectRatio"]}[$.toLowerCase()]||[]}function RK($){if(!$||!$.data||!Array.isArray($.data))throw new Error("matrixToTransform: invalid matrix");if(!$.data[0]||!$.data[1]||!$.data[0][0]||!$.data[0][1]||!$.data[0][2]||!$.data[1][0]||!$.data[1][1]||!$.data[1][2])throw new Error("matrixToTransform: matrix is missing required elements");let J=$.data[0][0].toNumber(),Z=$.data[1][0].toNumber(),K=$.data[0][1].toNumber(),Q=$.data[1][1].toNumber(),H=$.data[0][2].toNumber(),z=$.data[1][2].toNumber();if(!isFinite(J)||!isFinite(Z)||!isFinite(K)||!isFinite(Q)||!isFinite(H)||!isFinite(z))throw new Error("matrixToTransform: matrix contains non-finite values");return`matrix(${J} ${Z} ${K} ${Q} ${H} ${z})`}function AK($,J){if(!$||$.length<3||!J||J.length<3)return $;if(T7&&E7)try{return E7($,J)}catch(K){}let Z=[...$];for(let K=0;K<J.length;K++){if(Z.length===0)break;let Q=Z;Z=[];let H=J[K],z=J[(K+1)%J.length];for(let q=0;q<Q.length;q++){let j=Q[q],W=Q[(q+1)%Q.length],G=BK(j,H,z),F=BK(W,H,z);if(G){if(Z.push(j),!F)Z.push(NK(j,W,H,z))}else if(F)Z.push(NK(j,W,H,z))}}return Z}function BK($,J,Z){if(!$||$.x===void 0&&$.y===void 0)throw new Error("isInsideEdge: invalid point");if(!J||J.x===void 0&&J.y===void 0)throw new Error("isInsideEdge: invalid edgeStart");if(!Z||Z.x===void 0&&Z.y===void 0)throw new Error("isInsideEdge: invalid edgeEnd");let K=$.x instanceof L?$.x.toNumber():$.x||0,Q=$.y instanceof L?$.y.toNumber():$.y||0,H=J.x instanceof L?J.x.toNumber():J.x||0,z=J.y instanceof L?J.y.toNumber():J.y||0,q=Z.x instanceof L?Z.x.toNumber():Z.x||0,j=Z.y instanceof L?Z.y.toNumber():Z.y||0;return(q-H)*(Q-z)-(j-z)*(K-H)>=0}function NK($,J,Z,K){if(!$||$.x===void 0&&$.y===void 0)throw new Error("lineIntersect: invalid p1");if(!J||J.x===void 0&&J.y===void 0)throw new Error("lineIntersect: invalid p2");if(!Z||Z.x===void 0&&Z.y===void 0)throw new Error("lineIntersect: invalid p3");if(!K||K.x===void 0&&K.y===void 0)throw new Error("lineIntersect: invalid p4");let Q=$.x instanceof L?$.x.toNumber():$.x||0,H=$.y instanceof L?$.y.toNumber():$.y||0,z=J.x instanceof L?J.x.toNumber():J.x||0,q=J.y instanceof L?J.y.toNumber():J.y||0,j=Z.x instanceof L?Z.x.toNumber():Z.x||0,W=Z.y instanceof L?Z.y.toNumber():Z.y||0,G=K.x instanceof L?K.x.toNumber():K.x||0,F=K.y instanceof L?K.y.toNumber():K.y||0,_=(Q-z)*(W-F)-(H-q)*(j-G);if(Math.abs(_)<0.0000000001)return{x:L7((Q+z)/2),y:L7((H+q)/2)};let U=((Q-j)*(W-F)-(H-W)*(j-G))/_;return{x:L7(Q+U*(z-Q)),y:L7(H+U*(q-H))}}var c9="http://www.inkscape.org/namespaces/inkscape",l9="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd";var n9={groupmode:{type:"string",values:["layer"],description:"Identifies a group as a layer"},label:{type:"string",description:"Human-readable label for objects/layers"},expanded:{type:"boolean",description:"UI state - whether group is expanded in layers panel"},version:{type:"string",description:"Inkscape version that created/edited the file"},"document-units":{type:"string",values:["px","pt","pc","mm","cm","in"],description:"Default document units"},zoom:{type:"number",description:"Current zoom level"},rotation:{type:"number",description:"Current view rotation in degrees"},cx:{type:"number",description:"View center X coordinate"},cy:{type:"number",description:"View center Y coordinate"},"window-width":{type:"number",description:"Window width in pixels"},"window-height":{type:"number",description:"Window height in pixels"},"window-x":{type:"number",description:"Window X position"},"window-y":{type:"number",description:"Window Y position"},"window-maximized":{type:"boolean",description:"Whether window is maximized"},"current-layer":{type:"string",description:"ID of the currently active layer"},pageopacity:{type:"number",min:0,max:1,description:"Page opacity"},pageshadow:{type:"number",description:"Page shadow intensity"},showpageshadow:{type:"boolean",description:"Whether to show page shadow"},deskcolor:{type:"color",description:"Desk (canvas background) color"},deskopacity:{type:"number",min:0,max:1,description:"Desk opacity"},pagecheckerboard:{type:"boolean",description:"Show checkerboard pattern for transparency"},"desk-color":{type:"color",description:"Desk (canvas background) color (alternate form)"},"desk-opacity":{type:"number",min:0,max:1,description:"Desk opacity (alternate form)"},"desk-checkerboard":{type:"boolean",description:"Show checkerboard pattern (alternate form)"},"clip-to-page":{type:"boolean",description:"Clip rendering to page bounds"},"clip-to-page-rendering":{type:"boolean",description:"Clip rendering to page bounds (rendering mode)"},"antialias-rendering":{type:"boolean",description:"Enable antialiasing in rendering"},margin:{type:"string",description:"Page margin (CSS-like format)"},bleed:{type:"string",description:"Page bleed area"},"page-size":{type:"string",description:"Named page size (A4, Letter, etc.)"},"svg-dpi":{type:"number",description:"DPI for SVG export"},"origin-correction":{type:"string",description:"Origin correction for page positioning"},"y-axis-down":{type:"boolean",description:"Y axis direction (true=down, false=up)"},lockguides:{type:"boolean",description:"Lock all guides from editing"},color:{type:"color",description:"Guide color"},locked:{type:"boolean",description:"Object is locked from editing"},pinned:{type:"boolean",description:"Object is pinned in place"},collect:{type:"string",values:["always","never"],description:"Garbage collection behavior for defs"},"highlight-color":{type:"color",description:"Highlight color for object selection"},swatch:{type:"boolean",description:"Gradient is a color swatch"},"transform-center-x":{type:"number",description:"Custom rotation center X offset"},"transform-center-y":{type:"number",description:"Custom rotation center Y offset"},"path-effect":{type:"string",description:"Reference to inkscape:path-effect element (#id or #id;#id2)"},"original-d":{type:"string",description:"Original path data before LPE application"},original:{type:"string",description:"Original element reference"},"connector-type":{type:"string",values:["polyline","orthogonal"],description:"Connector line type"},"connector-curvature":{type:"number",description:"Connector curve amount"},"connector-spacing":{type:"number",description:"Spacing around connectors"},"connector-avoid":{type:"boolean",description:"Other connectors avoid this object"},"connection-points":{type:"string",description:"Custom connection point definitions"},"connection-start":{type:"string",description:"Start connection point reference"},"connection-end":{type:"string",description:"End connection point reference"},"connection-start-point":{type:"string",description:"Child-object reference for start connection"},"connection-end-point":{type:"string",description:"Child-object reference for end connection"},perspectiveID:{type:"string",description:"Reference to perspective element"},"box3d-perspectiveID":{type:"string",description:"Reference to perspective element (3D box alternate)"},"box3d-perspective-id":{type:"string",description:"Reference to perspective element (hyphenated form)"},corner0:{type:"string",description:"3D box corner 0 coordinates"},corner7:{type:"string",description:"3D box corner 7 coordinates"},box3dsidetype:{type:"string",description:"3D box side type"},persp3d:{type:"string",description:"3D perspective definition"},vp_x:{type:"string",description:"X vanishing point"},vp_y:{type:"string",description:"Y vanishing point"},vp_z:{type:"string",description:"Z vanishing point"},"persp3d-origin":{type:"string",description:"Perspective origin point"},flatsided:{type:"boolean",description:"Polygon has flat sides (not star)"},rounded:{type:"number",description:"Corner rounding amount"},randomized:{type:"number",description:"Random vertex displacement"},radius:{type:"number",description:"Shape radius"},href:{type:"string",description:"Inkscape-specific href reference"},"font-specification":{type:"string",description:"Full font specification string (fontconfig format)"},"font-spec":{type:"string",description:"Full font specification (alternate form)"},srcNoMarkup:{type:"string",description:"Text source without markup"},srcPango:{type:"string",description:"Text source in Pango markup"},dstShape:{type:"string",description:"Text flow destination shape"},dstPath:{type:"string",description:"Text flow destination path"},dstBox:{type:"string",description:"Text flow destination box"},dstColumn:{type:"string",description:"Text flow column settings"},excludeShape:{type:"string",description:"Shapes to exclude from text flow"},layoutOptions:{type:"string",description:"Text layout options"},"auto-region":{type:"boolean",description:"Auto-create text flow region"},"export-filename":{type:"string",description:"Default export filename"},"export-xdpi":{type:"number",description:"Export X DPI"},"export-ydpi":{type:"number",description:"Export Y DPI"},"spray-origin":{type:"string",description:"Spray tool origin reference"},"tiled-clone-of":{type:"string",description:"Source element for tiled clone"},"tile-cx":{type:"number",description:"Tile clone center X"},"tile-cy":{type:"number",description:"Tile clone center Y"},"tile-w":{type:"number",description:"Tile clone width"},"tile-h":{type:"number",description:"Tile clone height"},"tile-x0":{type:"number",description:"Tile origin X coordinate"},"tile-y0":{type:"number",description:"Tile origin Y coordinate"},"grid-bbox":{type:"boolean",description:"Show grid bounding box"},"grid-points":{type:"boolean",description:"Show grid points"},"guide-bbox":{type:"boolean",description:"Show guide bounding box"},"guide-points":{type:"boolean",description:"Show guide points"},"object-bbox":{type:"boolean",description:"Show object bounding box"},"object-nodes":{type:"boolean",description:"Show object nodes"},"object-paths":{type:"boolean",description:"Show object paths"},"object-points":{type:"boolean",description:"Show object points"},marker:{type:"string",description:"Marker reference"},stockid:{type:"string",description:"Stock marker/pattern ID"},isstock:{type:"boolean",description:"Element is a stock resource (pattern, symbol, etc.)"},menu:{type:"string",description:"Menu category for stock resources"},"menu-tooltip":{type:"string",description:"Tooltip text for stock resource menu item"},dataloss:{type:"boolean",description:"Indicates data loss on save"},has_abs_tolerance:{type:"boolean",description:"Has absolute tolerance"},output_extension:{type:"string",description:"Output extension ID"},offset:{type:"number",description:"Offset distance for offset paths"},"-inkscape-stroke":{type:"string",values:["hairline"],description:"Inkscape stroke rendering mode"}},s9={docname:{type:"string",description:"Document filename"},docbase:{type:"string",description:"Document base directory (absolute path)"},version:{type:"string",description:"Sodipodi version that saved the document"},modified:{type:"boolean",description:"Internal: document modified since last save"},type:{type:"string",values:["arc","star","spiral","inkscape:offset"],description:"Sodipodi shape type"},insensitive:{type:"boolean",description:"Object cannot be selected with mouse"},nonprintable:{type:"boolean",description:"Object should not be printed"},cx:{type:"number",description:"Arc center X"},cy:{type:"number",description:"Arc center Y"},rx:{type:"number",description:"Arc radius X"},ry:{type:"number",description:"Arc radius Y"},start:{type:"number",description:"Arc start angle (radians)"},end:{type:"number",description:"Arc end angle (radians)"},open:{type:"boolean",description:"Arc is open (not closed)"},"arc-type":{type:"string",values:["arc","slice","chord"],description:"Arc rendering type"},star:{type:"boolean",description:"Shape is a star (vs polygon)"},sides:{type:"number",min:3,description:"Number of polygon/star sides"},r1:{type:"number",description:"Star outer radius"},r2:{type:"number",description:"Star inner radius"},arg1:{type:"number",description:"Star angle argument 1 (radians)"},arg2:{type:"number",description:"Star angle argument 2 (radians)"},spiral:{type:"boolean",description:"Shape is a spiral"},expansion:{type:"number",description:"Spiral expansion rate"},revolution:{type:"number",description:"Number of spiral revolutions"},radius:{type:"number",description:"Spiral radius"},argument:{type:"number",description:"Spiral argument (start angle in radians)"},t0:{type:"number",min:0,max:1,description:"Spiral start parameter (0-1)"},original:{type:"string",description:"Original path or element reference"},nodetypes:{type:"string",pattern:/^[csza]+$/,description:"Path node types (c=corner, s=smooth, z=symmetric, a=auto)"},absref:{type:"string",description:"Absolute native path to external resource"},role:{type:"string",values:["line"],description:"Text span role (line = separate line)"},linespacing:{type:"string",description:"Line spacing (percentage like '125%' or absolute)"}},$z=["namedview","guide"],Jz=["path-effect","perspective","page","clipboard","grid","box3dside"],EK=["flowRoot","flowPara","flowRegion","flowSpan","flowDiv","flowLine"];function Kz($,J){let Z=n9[$];if(!Z)return{valid:!0};if(Z.values&&!Z.values.includes(J))return{valid:!1,error:`Invalid value "${J}" for inkscape:${$}. Expected: ${Z.values.join(", ")}`};if(Z.type==="number"){let K=parseFloat(J);if(isNaN(K))return{valid:!1,error:`inkscape:${$} must be a number`};if(Z.min!==void 0&&K<Z.min)return{valid:!1,error:`inkscape:${$} must be >= ${Z.min}`};if(Z.max!==void 0&&K>Z.max)return{valid:!1,error:`inkscape:${$} must be <= ${Z.max}`}}if(Z.type==="boolean"){if(J==="true"||J==="false")return{valid:!0};let K=parseInt(J,10);if(isNaN(K)||String(K)!==J)return{valid:!1,error:`inkscape:${$} must be a boolean (true/false) or integer`}}if(Z.pattern&&!Z.pattern.test(J))return{valid:!1,error:`inkscape:${$} has invalid format`};return{valid:!0}}function Zz($,J){let Z=s9[$];if(!Z)return{valid:!0};if(Z.values&&!Z.values.includes(J))return{valid:!1,error:`Invalid value "${J}" for sodipodi:${$}. Expected: ${Z.values.join(", ")}`};if(Z.type==="number"){let K=parseFloat(J);if(isNaN(K))return{valid:!1,error:`sodipodi:${$} must be a number`};if(Z.min!==void 0&&K<Z.min)return{valid:!1,error:`sodipodi:${$} must be >= ${Z.min}`};if(Z.max!==void 0&&K>Z.max)return{valid:!1,error:`sodipodi:${$} must be <= ${Z.max}`}}if(Z.pattern&&!Z.pattern.test(J))return{valid:!1,error:`sodipodi:${$} has invalid format`};return{valid:!0}}function TK($){if(!$)return{isInkscape:!1,hasFlowText:!1};let J=$.documentElement||$;if(!J||typeof J.getAttribute!=="function")return{isInkscape:!1,hasFlowText:!1};let Z=J.getAttribute("xmlns:inkscape")===c9,K=J.getAttribute("xmlns:sodipodi")===l9,Q=J.getAttribute("inkscape:version"),H=!1,z=(q)=>{if(!q)return;if(EK.includes(q.tagName)){H=!0;return}if(q.children&&Array.isArray(q.children)){for(let j of q.children)if(z(j),H)return}};return z(J),{isInkscape:Z||K||!!Q,version:Q||void 0,hasFlowText:H}}var K7={ERROR:"error",WARNING:"warning",INFO:"info"};function bK($,J={}){let{strict:Z=!1,warnFlowText:K=!0,checkPolyfillNeeds:Q=!0}=J,H=[],z=new Set,q=!1,j=!1,W=!1,G=TK($);q=G.hasFlowText;let F=(V,Y,O,X,w)=>{H.push({severity:V,type:Y,element:O,attribute:X,message:w})},_=$.documentElement||$;if(_&&typeof _.getAttribute==="function"){let V=_.getAttribute("xmlns:inkscape"),Y=_.getAttribute("xmlns:sodipodi");if(V&&V!==c9)F(K7.ERROR,"invalid_namespace_uri","svg","xmlns:inkscape",`Invalid Inkscape namespace URI. Expected: ${c9}, got: ${V}`);if(Y&&Y!==l9)F(K7.ERROR,"invalid_namespace_uri","svg","xmlns:sodipodi",`Invalid Sodipodi namespace URI. Expected: ${l9}, got: ${Y}`)}let U=(V)=>{if(!V||typeof V.getAttributeNames!=="function")return;let Y=V.tagName||"unknown";if(Q){let O=Y.toLowerCase();if(O==="meshgradient"||O==="meshrow"||O==="meshpatch")j=!0;if(O==="hatch"||O==="hatchpath")W=!0;if(EK.includes(Y))q=!0}if(Y.startsWith("sodipodi:")){let O=Y.substring(9);if(!$z.includes(O))F(K7.ERROR,"unknown_sodipodi_element",Y,null,`Unknown sodipodi element: ${Y} - not in Sodipodi namespace schema`)}if(Y.startsWith("inkscape:")){let O=Y.substring(9);if(!Jz.includes(O))F(K7.ERROR,"unknown_inkscape_element",Y,null,`Unknown inkscape element: ${Y} - not in Inkscape namespace schema`)}for(let O of V.getAttributeNames()){let X=V.getAttribute(O);if(O.startsWith("inkscape:")){let w=O.substring(9),R=Kz(w,X);if(!R.valid)F(K7.ERROR,"invalid_inkscape_attribute",Y,O,R.error);else if(Z&&!n9[w])F(K7.ERROR,"unknown_inkscape_attribute",Y,O,`Unknown inkscape attribute: ${O} - not in Inkscape namespace schema`)}if(O.startsWith("sodipodi:")){let w=O.substring(9),R=Zz(w,X);if(!R.valid)F(K7.ERROR,"invalid_sodipodi_attribute",Y,O,R.error);else if(Z&&!s9[w])F(K7.ERROR,"unknown_sodipodi_attribute",Y,O,`Unknown sodipodi attribute: ${O} - not in Sodipodi namespace schema`)}if(O==="style"&&X.includes("-inkscape-stroke"))z.add("hairlineStroke")}if(V.children&&Array.isArray(V.children))for(let O of V.children)U(O);else if(V.childNodes){for(let O of V.childNodes)if(O.nodeType===1)U(O)}};if(U(_),j)z.add("meshGradient");if(W)z.add("hatchPaint");if(q&&K)F(K7.WARNING,"flowtext_compatibility","flowRoot",null,"SVG contains flowRoot elements (SVG 1.2 draft). These are not supported by browsers and should be converted to regular text.");let M={errors:H.filter((V)=>V.severity===K7.ERROR).length,warnings:H.filter((V)=>V.severity===K7.WARNING).length,info:H.filter((V)=>V.severity===K7.INFO).length};return{isValid:M.errors===0,isInkscape:G.isInkscape,version:G.version,issues:H,summary:M,polyfillsNeeded:[...z],hasFlowText:q}}var j6=new Set(["clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cursor","direction","dominant-baseline","fill","fill-opacity","fill-rule","font","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","glyph-orientation-horizontal","glyph-orientation-vertical","image-rendering","letter-spacing","marker","marker-end","marker-mid","marker-start","paint-order","pointer-events","shape-rendering","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-anchor","text-rendering","visibility","word-spacing","writing-mode"]);var o6={animation:new Set(["animate","animateColor","animatecolor","animateMotion","animatemotion","animateTransform","animatetransform","set"]),descriptive:new Set(["desc","metadata","title"]),shape:new Set(["circle","ellipse","line","path","polygon","polyline","rect"]),structural:new Set(["defs","g","svg","symbol","use"]),paintServer:new Set(["hatch","linearGradient","lineargradient","meshGradient","meshgradient","pattern","radialGradient","radialgradient","solidColor","solidcolor"]),nonRendering:new Set(["clipPath","clippath","filter","linearGradient","lineargradient","marker","mask","pattern","radialGradient","radialgradient","solidColor","solidcolor","symbol"]),container:new Set(["a","defs","g","marker","mask","pattern","svg","switch","symbol"]),textContent:new Set(["altGlyph","altGlyphDef","altGlyphItem","glyph","glyphRef","text","textPath","tref","tspan"]),filterPrimitive:new Set(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence"]),lightSource:new Set(["feDistantLight","fePointLight","feSpotLight"])};var i6={svg:new Set(["a","altGlyphDef","animate","animateColor","animateMotion","animateTransform","circle","clipPath","cursor","defs","desc","ellipse","filter","font","font-face","foreignObject","g","image","line","linearGradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialGradient","rect","script","set","style","svg","switch","symbol","text","title","use","view"]),g:new Set(["a","animate","animateColor","animateMotion","animateTransform","circle","clipPath","cursor","defs","desc","ellipse","filter","font","font-face","foreignObject","g","image","line","linearGradient","marker","mask","metadata","path","pattern","polygon","polyline","radialGradient","rect","script","set","style","svg","switch","symbol","text","title","use","view"]),defs:new Set(["a","altGlyphDef","animate","animateColor","animateMotion","animateTransform","circle","clipPath","cursor","defs","desc","ellipse","filter","font","font-face","foreignObject","g","image","line","linearGradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialGradient","rect","script","set","style","svg","switch","symbol","text","title","use","view","meshgradient","meshGradient","hatch","solidcolor","solidColor"]),symbol:new Set(["a","animate","animateColor","animateMotion","animateTransform","circle","clipPath","cursor","defs","desc","ellipse","filter","font","font-face","foreignObject","g","image","line","linearGradient","marker","mask","metadata","path","pattern","polygon","polyline","radialGradient","rect","script","set","style","svg","switch","symbol","text","title","use","view"]),marker:new Set(["a","animate","animateColor","animateMotion","animateTransform","circle","clipPath","cursor","defs","desc","ellipse","filter","font","font-face","foreignObject","g","image","line","linearGradient","marker","mask","metadata","path","pattern","polygon","polyline","radialGradient","rect","script","set","style","svg","switch","symbol","text","title","use","view"]),clipPath:new Set(["animate","animateColor","animateMotion","animateTransform","circle","desc","ellipse","line","metadata","path","polygon","polyline","rect","set","text","title","use"]),mask:new Set(["a","animate","animateColor","animateMotion","animateTransform","circle","clipPath","cursor","defs","desc","ellipse","filter","font","font-face","foreignObject","g","image","line","linearGradient","marker","mask","metadata","path","pattern","polygon","polyline","radialGradient","rect","script","set","style","svg","switch","symbol","text","title","use","view"]),pattern:new Set(["a","animate","animateColor","animateMotion","animateTransform","circle","clipPath","cursor","defs","desc","ellipse","filter","font","font-face","foreignObject","g","image","line","linearGradient","marker","mask","metadata","path","pattern","polygon","polyline","radialGradient","rect","script","set","style","svg","switch","symbol","text","title","use","view"]),a:new Set(["a","animate","animateColor","animateMotion","animateTransform","circle","clipPath","cursor","defs","desc","ellipse","filter","font","font-face","foreignObject","g","image","line","linearGradient","marker","mask","metadata","path","pattern","polygon","polyline","radialGradient","rect","script","set","style","svg","switch","symbol","text","title","use","view"]),switch:new Set(["a","animate","animateColor","animateMotion","animateTransform","circle","cursor","desc","ellipse","foreignObject","g","image","line","metadata","path","polygon","polyline","rect","set","svg","switch","text","title","use","view"]),text:new Set(["a","altGlyph","animate","animateColor","animateMotion","animateTransform","desc","metadata","set","textPath","title","tref","tspan"]),textPath:new Set(["a","altGlyph","animate","animateColor","desc","metadata","set","title","tref","tspan"]),tspan:new Set(["a","altGlyph","animate","animateColor","desc","metadata","set","title","tref","tspan"]),linearGradient:new Set(["animate","animateTransform","desc","metadata","set","stop","title"]),radialGradient:new Set(["animate","animateTransform","desc","metadata","set","stop","title"]),meshgradient:new Set(["animate","animateTransform","desc","metadata","meshrow","set","title"]),meshGradient:new Set(["animate","animateTransform","desc","metadata","meshrow","set","title"]),meshrow:new Set(["meshpatch"]),meshpatch:new Set(["stop"]),hatch:new Set(["animate","animateTransform","desc","hatchpath","hatchPath","metadata","script","set","style","title"]),hatchpath:new Set(["animate","animateTransform","desc","metadata","script","set","title"]),hatchPath:new Set(["animate","animateTransform","desc","metadata","script","set","title"]),filter:new Set(["animate","animateTransform","desc","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","metadata","set","title"]),feBlend:new Set(["animate","set"]),feColorMatrix:new Set(["animate","set"]),feComponentTransfer:new Set(["feFuncA","feFuncB","feFuncG","feFuncR"]),feComposite:new Set(["animate","set"]),feConvolveMatrix:new Set(["animate","set"]),feDiffuseLighting:new Set(["animate","feDistantLight","fePointLight","feSpotLight","set"]),feDisplacementMap:new Set(["animate","set"]),feDropShadow:new Set(["animate","set"]),feFlood:new Set(["animate","set"]),feFuncA:new Set(["animate","set"]),feFuncB:new Set(["animate","set"]),feFuncG:new Set(["animate","set"]),feFuncR:new Set(["animate","set"]),feGaussianBlur:new Set(["animate","set"]),feImage:new Set(["animate","set"]),feMerge:new Set(["feMergeNode"]),feMergeNode:new Set(["animate","set"]),feMorphology:new Set(["animate","set"]),feOffset:new Set(["animate","set"]),feSpecularLighting:new Set(["animate","feDistantLight","fePointLight","feSpotLight","set"]),feTile:new Set(["animate","set"]),feTurbulence:new Set(["animate","set"]),animate:new Set(["desc","metadata","title"]),animateColor:new Set(["desc","metadata","title"]),animateMotion:new Set(["desc","metadata","mpath","title"]),animateTransform:new Set(["desc","metadata","title"]),set:new Set(["desc","metadata","title"]),circle:new Set(["animate","animateColor","animateMotion","animateTransform","desc","metadata","set","title"]),ellipse:new Set(["animate","animateColor","animateMotion","animateTransform","desc","metadata","set","title"]),line:new Set(["animate","animateColor","animateMotion","animateTransform","desc","metadata","set","title"]),path:new Set(["animate","animateColor","animateMotion","animateTransform","desc","metadata","set","title"]),polygon:new Set(["animate","animateColor","animateMotion","animateTransform","desc","metadata","set","title"]),polyline:new Set(["animate","animateColor","animateMotion","animateTransform","desc","metadata","set","title"]),rect:new Set(["animate","animateColor","animateMotion","animateTransform","desc","metadata","set","title"]),image:new Set(["animate","animateColor","animateMotion","animateTransform","desc","metadata","set","title"]),use:new Set(["animate","animateColor","animateMotion","animateTransform","desc","metadata","set","title"]),title:new Set([]),desc:new Set([]),metadata:new Set([]),feDistantLight:new Set(["animate","set"]),fePointLight:new Set(["animate","set"]),feSpotLight:new Set(["animate","set"]),stop:new Set(["animate","set"]),solidColor:new Set(["animate","animateColor","animateTransform","desc","metadata","set","title"]),solidcolor:new Set(["animate","animateColor","animateTransform","desc","metadata","set","title"]),tref:new Set(["animate","animateColor","desc","metadata","set","title"]),altGlyph:new Set(["animate","animateColor","desc","metadata","set","title"]),altGlyphDef:new Set(["altGlyphItem"]),altGlyphItem:new Set(["glyphRef","altGlyphItem"]),glyph:new Set(["animate","animateColor","animateMotion","animateTransform","circle","desc","ellipse","line","metadata","path","polygon","polyline","rect","set","title","use"]),glyphRef:new Set([]),foreignObject:new Set([]),style:new Set([]),script:new Set([]),view:new Set(["desc","metadata","title"]),mpath:new Set(["desc","metadata","title"])},fK={userAction:new Set([":hover",":active",":focus",":focus-within",":focus-visible"]),treeStructural:new Set([":root",":empty",":first-child",":last-child",":only-child",":first-of-type",":last-of-type",":only-of-type",":nth-child",":nth-last-child",":nth-of-type",":nth-last-of-type"]),link:new Set([":link",":visited",":any-link",":local-link",":target"]),input:new Set([":enabled",":disabled",":read-only",":read-write",":placeholder-shown",":default",":checked",":indeterminate",":valid",":invalid",":in-range",":out-of-range",":required",":optional"]),linguistic:new Set([":lang",":dir"]),functional:new Set([":not",":is",":where",":has"]),preventInlining:new Set([":hover",":active",":focus",":focus-within",":focus-visible",":visited",":target",":lang",":dir",":not",":is",":where",":has"])};L.set({precision:20,rounding:L.ROUND_HALF_UP});var o9={linear:[0,0,1,1],ease:[0.25,0.1,0.25,1],"ease-in":[0.42,0,1,1],"ease-out":[0,0,0.58,1],"ease-in-out":[0.42,0,0.58,1]};function r6($,J=3){if($===null||$===void 0)throw new Error("formatSplineValue: value parameter is required");if(typeof J!=="number"||J<0||!Number.isFinite(J))throw new Error("formatSplineValue: precision must be a non-negative finite number");let Z=typeof $==="number"?$:parseFloat($);if(!Number.isFinite(Z))throw new Error(`formatSplineValue: value must be a finite number, got ${$}`);let H=new L($).toDecimalPlaces(J).toString();if(H.includes("."))H=H.replace(/0+$/,""),H=H.replace(/\.$/,"");if(H.startsWith("0."))H=H.substring(1);else if(H.startsWith("-0."))H="-"+H.substring(2);if(H===""||H==="."||H==="-0")H="0";return H}function S$($){if(!$||typeof $!=="string")return[];return $.split(";").map((Z)=>Z.trim()).filter((Z)=>Z).map((Z)=>{let K=Z.split(/[\s,]+/).map((Q)=>parseFloat(Q)).filter((Q)=>Number.isFinite(Q));if(K.length!==4)throw new Error(`parseKeySplines: invalid spline "${Z}", expected 4 values, got ${K.length}`);return K})}function i9($,J=3){if(!Array.isArray($))throw new Error("serializeKeySplines: splines must be an array");if(typeof J!=="number"||J<0||!Number.isFinite(J))throw new Error("serializeKeySplines: precision must be a non-negative finite number");return $.map((Z,K)=>{if(!Array.isArray(Z))throw new Error(`serializeKeySplines: spline at index ${K} must be an array`);if(Z.length!==4)throw new Error(`serializeKeySplines: spline at index ${K} must have exactly 4 values, got ${Z.length}`);return Z.map((Q)=>r6(Q,J)).join(" ")}).join("; ")}function v$($,J=0.001){if(!Array.isArray($)||$.length!==4)return!1;if(typeof J!=="number"||J<0||!Number.isFinite(J))throw new Error("isLinearSpline: tolerance must be a non-negative finite number");let[Z,K,Q,H]=$;if(!Number.isFinite(Z)||!Number.isFinite(K)||!Number.isFinite(Q)||!Number.isFinite(H))return!1;return Math.abs(Z)<J&&Math.abs(K)<J&&Math.abs(Q-1)<J&&Math.abs(H-1)<J}function SK($){let J=S$($);if(J.length===0)return!1;return J.every((Z)=>v$(Z))}function r9($,J=0.01){if(!Array.isArray($)||$.length!==4)return null;if(typeof J!=="number"||J<0||!Number.isFinite(J))throw new Error("identifyStandardEasing: tolerance must be a non-negative finite number");if(!$.every((Z)=>Number.isFinite(Z)))return null;for(let[Z,K]of Object.entries(o9))if($.every((H,z)=>Math.abs(H-K[z])<J))return Z;return null}function a9($,J={}){let Z=J.precision??3,K=J.removeLinear!==!1,Q=S$($);if(Q.length===0)return{value:null,allLinear:!1,standardEasings:[]};let H=Q.every((j)=>v$(j)),z=Q.map((j)=>r9(j)).filter(Boolean);if(H&&K)return{value:null,allLinear:!0,standardEasings:z};return{value:i9(Q,Z),allLinear:H,standardEasings:z}}function Qz($){if(!$||typeof $!=="string")return[];return $.split(";").map((J)=>parseFloat(J.trim())).filter((J)=>Number.isFinite(J))}function Hz($,J=3){if(!Array.isArray($))throw new Error("serializeKeyTimes: times must be an array");if(typeof J!=="number"||J<0||!Number.isFinite(J))throw new Error("serializeKeyTimes: precision must be a non-negative finite number");if($.length===0)return"";return $.map((Z)=>r6(Z,J)).join("; ")}function t9($,J=3){if($===null||$===void 0)throw new Error("optimizeKeyTimes: keyTimes parameter is required");if(typeof J!=="number"||J<0||!Number.isFinite(J))throw new Error("optimizeKeyTimes: precision must be a non-negative finite number");let Z=Qz($);if(Z.length===0)return $;return Hz(Z,J)}function f$($,J=3){if(!$||typeof $!=="string")return $;if(typeof J!=="number"||J<0||!Number.isFinite(J))throw new Error("optimizeAnimationValues: precision must be a non-negative finite number");if($.startsWith("data:"))return $;let Z=$.split(";");if(Z.length===0)return $;return Z.map((Q)=>{let H=Q.trim();if(H.startsWith("#")||H.includes("url("))return H;if(H.startsWith("data:"))return H;if(/^(rgb|rgba|hsl|hsla|hwb|lab|lch|oklch|oklab|color)\s*\(/i.test(H))return H;if(/^[MmZzLlHhVvCcSsQqTtAa][\s\d.,+-]+/.test(H))return H;if(/^(['"]?[\w\s-]+['"]?,\s*)+['"]?[\w\s-]+['"]?$/.test(H))return H;return H.split(/[\s,]+/).filter((j)=>j).map((j)=>{let W=parseFloat(j);if(!Number.isFinite(W))return j;return r6(W,J)}).join(" ")}).join("; ")}function zz($,J={}){if(!$||typeof $!=="object")throw new Error("optimizeElementTiming: el parameter must be a valid element");if(typeof $.getAttribute!=="function"||typeof $.setAttribute!=="function"||typeof $.removeAttribute!=="function")throw new Error("optimizeElementTiming: el parameter must have getAttribute, setAttribute, and removeAttribute methods");let Z=J.precision??3,K=J.removeLinearSplines!==!1,Q=J.optimizeValues!==!1;if(typeof Z!=="number"||Z<0||!Number.isFinite(Z))throw new Error("optimizeElementTiming: options.precision must be a non-negative finite number");let H=[],z=!1,q=$.getAttribute("keySplines");if(q){let W=a9(q,{precision:Z,removeLinear:K});if(W.allLinear&&K){if($.getAttribute("calcMode")==="spline")$.setAttribute("calcMode","linear"),$.removeAttribute("keySplines"),H.push('Converted linear splines to calcMode="linear"'),z=!0}else if(W.value&&W.value!==q)$.setAttribute("keySplines",W.value),H.push(`keySplines: "${q}" -> "${W.value}"`),z=!0}let j=$.getAttribute("keyTimes");if(j){let W=t9(j,Z);if(W!==j)$.setAttribute("keyTimes",W),H.push(`keyTimes: "${j}" -> "${W}"`),z=!0}if(Q){let W=$.getAttribute("values");if(W){let G=f$(W,Z);if(G!==W)$.setAttribute("values",G),H.push(`values: "${W}" -> "${G}"`),z=!0}}for(let W of["from","to","by"]){let G=$.getAttribute(W);if(G){let F=f$(G,Z);if(F!==G)$.setAttribute(W,F),H.push(`${W}: "${G}" -> "${F}"`),z=!0}}return{modified:z,changes:H}}var qz=["animate","animatetransform","animatemotion","animatecolor","set"];function vK($,J={}){if(!$||typeof $!=="object")throw new Error("optimizeDocumentAnimationTiming: root parameter must be a valid element");let Z=0,K=0,Q=[],H=(z)=>{if(!z||typeof z!=="object")return;let q=z.tagName?.toLowerCase();if(!q)return;if(qz.includes(q)){let W=zz(z,J);if(W.modified)Z++,K+=W.changes.length,Q.push({element:q,id:z.getAttribute("id")||null,changes:W.changes})}let j=z.children||[];for(let W of j)H(W)};return H($),{elementsModified:Z,totalChanges:K,details:Q}}var $8={M:2,m:2,L:2,l:2,H:1,h:1,V:1,v:1,C:6,c:6,S:4,s:4,Q:4,q:4,T:2,t:2,A:7,a:7,Z:0,z:0};function Wz($){if(typeof $!=="string")throw new TypeError(`parseArcArgs: argsStr must be a string, got ${typeof $}`);let J=[],Z=/-?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/g,K=0,Q=0;while(K<$.length){while(K<$.length&&/[\s,]/.test($[K]))K++;if(K>=$.length)break;let H=Q%7;if(H===3||H===4)if($[K]==="0"||$[K]==="1")J.push($[K]==="1"?1:0),K++,Q++;else return null;else{Z.lastIndex=K;let z=Z.exec($);if(z&&z.index===K)J.push(parseFloat(z[0])),K=Z.lastIndex,Q++;else K++}}return J}function n0($){if(!$||typeof $!=="string")return[];let J=[],Z=/([MmLlHhVvCcSsQqTtAaZz])([^MmLlHhVvCcSsQqTtAaZz]*)/g,K;while((K=Z.exec($))!==null){let Q=K[1],H=K[2].trim();if(Q==="Z"||Q==="z"){J.push({command:"Z",args:[]});let j=H.match(/-?\d*\.?\d+(?:[eE][+-]?\d+)?/g);if(j&&j.length>=2){J.push({command:"M",args:[parseFloat(j[0]),parseFloat(j[1])]});for(let W=2;W+1<j.length;W+=2)J.push({command:"L",args:[parseFloat(j[W]),parseFloat(j[W+1])]})}continue}let z;if(Q==="A"||Q==="a"){if(z=Wz(H),z===null){console.warn(`Invalid arc command with malformed flags - skipping: ${Q}${H}`);continue}for(let j=0;j<z.length;j+=7)if(j+6<z.length)z[j]=Math.abs(z[j]),z[j+1]=Math.abs(z[j+1])}else{let j=/-?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/g;z=[];let W;while((W=j.exec(H))!==null)z.push(parseFloat(W[0]))}let q=$8[Q];if(q===void 0){console.warn(`Unknown SVG path command '${Q}' - skipping`);continue}if(q===0||z.length===0)J.push({command:Q,args:[]});else for(let j=0;j<z.length;j+=q){let W=z.slice(j,j+q);if(W.length===q){let G=j>0&&(Q==="M"||Q==="m")?Q==="M"?"L":"l":Q;J.push({command:G,args:W})}else if(W.length>0)console.warn(`Incomplete ${Q} command: expected ${q} args, got ${W.length} - remaining args dropped`)}}return J}function f7($,J=3){if(typeof $!=="number")throw new TypeError(`formatNumber: num must be a number, got ${typeof $}`);if(typeof J!=="number"||!Number.isInteger(J)||J<0)throw new TypeError(`formatNumber: precision must be a non-negative integer, got ${J}`);if(!isFinite($))return"0";if($===0)return"0";let Z=Math.pow(10,J),Q=(Math.round($*Z)/Z).toFixed(J);if(Q.includes("."))Q=Q.replace(/\.?0+$/,"");if(Q.startsWith("0."))Q=Q.substring(1);else if(Q.startsWith("-0."))Q="-"+Q.substring(2);if(Q===""||Q==="."||Q==="-.")Q="0";return Q}function k7($,J,Z){if(!$||typeof $!=="object")throw new TypeError(`toAbsolute: cmd must be an object, got ${typeof $}`);if(typeof $.command!=="string")throw new TypeError(`toAbsolute: cmd.command must be a string, got ${typeof $.command}`);if(!Array.isArray($.args))throw new TypeError("toAbsolute: cmd.args must be an array");if(typeof J!=="number"||!isFinite(J))throw new TypeError(`toAbsolute: cx must be a finite number, got ${J}`);if(typeof Z!=="number"||!isFinite(Z))throw new TypeError(`toAbsolute: cy must be a finite number, got ${Z}`);let{command:K,args:Q}=$;if(K===K.toUpperCase()){if($8[K]===void 0)throw new TypeError(`toAbsolute: unknown command '${K}'`);return $}let H=K.toUpperCase(),z=[...Q];switch(K){case"m":case"l":case"t":if(z.length<2)throw new RangeError(`toAbsolute: command ${K} requires at least 2 args, got ${z.length}`);z[0]+=J,z[1]+=Z;break;case"h":if(z.length<1)throw new RangeError(`toAbsolute: command ${K} requires at least 1 arg, got ${z.length}`);z[0]+=J;break;case"v":if(z.length<1)throw new RangeError(`toAbsolute: command ${K} requires at least 1 arg, got ${z.length}`);z[0]+=Z;break;case"c":if(z.length<6)throw new RangeError(`toAbsolute: command ${K} requires at least 6 args, got ${z.length}`);z[0]+=J,z[1]+=Z,z[2]+=J,z[3]+=Z,z[4]+=J,z[5]+=Z;break;case"s":case"q":if(z.length<4)throw new RangeError(`toAbsolute: command ${K} requires at least 4 args, got ${z.length}`);z[0]+=J,z[1]+=Z,z[2]+=J,z[3]+=Z;break;case"a":if(z.length<7)throw new RangeError(`toAbsolute: command ${K} requires at least 7 args, got ${z.length}`);z[5]+=J,z[6]+=Z;break;default:throw new TypeError(`toAbsolute: unsupported command '${K}' for conversion`)}return{command:H,args:z}}function J8($,J,Z){if(!$||typeof $!=="object")throw new TypeError(`toRelative: cmd must be an object, got ${typeof $}`);if(typeof $.command!=="string")throw new TypeError(`toRelative: cmd.command must be a string, got ${typeof $.command}`);if(!Array.isArray($.args))throw new TypeError("toRelative: cmd.args must be an array");if(typeof J!=="number"||!isFinite(J))throw new TypeError(`toRelative: cx must be a finite number, got ${J}`);if(typeof Z!=="number"||!isFinite(Z))throw new TypeError(`toRelative: cy must be a finite number, got ${Z}`);let{command:K,args:Q}=$;if(K===K.toLowerCase()&&K!=="z"){if($8[K]===void 0)throw new TypeError(`toRelative: unknown command '${K}'`);return $}if(K==="Z"||K==="z")return{command:"z",args:[]};let H=K.toLowerCase(),z=[...Q];switch(K){case"M":case"L":case"T":if(z.length<2)throw new RangeError(`toRelative: command ${K} requires at least 2 args, got ${z.length}`);z[0]-=J,z[1]-=Z;break;case"H":if(z.length<1)throw new RangeError(`toRelative: command ${K} requires at least 1 arg, got ${z.length}`);z[0]-=J;break;case"V":if(z.length<1)throw new RangeError(`toRelative: command ${K} requires at least 1 arg, got ${z.length}`);z[0]-=Z;break;case"C":if(z.length<6)throw new RangeError(`toRelative: command ${K} requires at least 6 args, got ${z.length}`);z[0]-=J,z[1]-=Z,z[2]-=J,z[3]-=Z,z[4]-=J,z[5]-=Z;break;case"S":case"Q":if(z.length<4)throw new RangeError(`toRelative: command ${K} requires at least 4 args, got ${z.length}`);z[0]-=J,z[1]-=Z,z[2]-=J,z[3]-=Z;break;case"A":if(z.length<7)throw new RangeError(`toRelative: command ${K} requires at least 7 args, got ${z.length}`);z[5]-=J,z[6]-=Z;break;default:throw new TypeError(`toRelative: unsupported command '${K}' for conversion`)}return{command:H,args:z}}function jz($,J,Z,K=0.000001){if(!$||typeof $!=="object")throw new TypeError(`lineToHV: cmd must be an object, got ${typeof $}`);if(typeof $.command!=="string")throw new TypeError(`lineToHV: cmd.command must be a string, got ${typeof $.command}`);if(!Array.isArray($.args))throw new TypeError("lineToHV: cmd.args must be an array");if(typeof J!=="number"||!isFinite(J))throw new TypeError(`lineToHV: cx must be a finite number, got ${J}`);if(typeof Z!=="number"||!isFinite(Z))throw new TypeError(`lineToHV: cy must be a finite number, got ${Z}`);if(typeof K!=="number"||!isFinite(K)||K<0)throw new TypeError(`lineToHV: tolerance must be a non-negative finite number, got ${K}`);let{command:Q,args:H}=$;if(Q!=="L"&&Q!=="l")return null;if(H.length<2)throw new RangeError(`lineToHV: command ${Q} requires at least 2 args, got ${H.length}`);let z=Q==="L",q=z?H[0]:J+H[0],j=z?H[1]:Z+H[1];if(Math.abs(j-Z)<K)return z?{command:"H",args:[q]}:{command:"h",args:[q-J]};if(Math.abs(q-J)<K)return z?{command:"V",args:[j]}:{command:"v",args:[j-Z]};return null}function Gz($,J,Z,K,Q,H=0.000001){if(!$||typeof $!=="object")throw new TypeError(`lineToZ: cmd must be an object, got ${typeof $}`);if(typeof $.command!=="string")throw new TypeError(`lineToZ: cmd.command must be a string, got ${typeof $.command}`);if(!Array.isArray($.args))throw new TypeError("lineToZ: cmd.args must be an array");if(typeof J!=="number"||!isFinite(J))throw new TypeError(`lineToZ: cx must be a finite number, got ${J}`);if(typeof Z!=="number"||!isFinite(Z))throw new TypeError(`lineToZ: cy must be a finite number, got ${Z}`);if(typeof K!=="number"||!isFinite(K))throw new TypeError(`lineToZ: startX must be a finite number, got ${K}`);if(typeof Q!=="number"||!isFinite(Q))throw new TypeError(`lineToZ: startY must be a finite number, got ${Q}`);if(typeof H!=="number"||!isFinite(H)||H<0)throw new TypeError(`lineToZ: tolerance must be a non-negative finite number, got ${H}`);let{command:z,args:q}=$;if(z!=="L"&&z!=="l")return!1;if(q.length<2)throw new RangeError(`lineToZ: command ${z} requires at least 2 args, got ${q.length}`);let j=z==="L",W=j?q[0]:J+q[0],G=j?q[1]:Z+q[1];return Math.abs(W-K)<H&&Math.abs(G-Q)<H}function Fz($,J,Z,K,Q,H,z,q,j=0.5){let W={x0:$,y0:J,cp1x:Z,cp1y:K,cp2x:Q,cp2y:H,x3:z,y3:q,tolerance:j};for(let[M,V]of Object.entries(W))if(typeof V!=="number"||!isFinite(V))throw new TypeError(`isCurveStraight: ${M} must be a finite number, got ${V}`);if(j<0)throw new TypeError(`isCurveStraight: tolerance must be non-negative, got ${j}`);let G=(z-$)**2+(q-J)**2;if(G<0.0000000001){let M=Math.sqrt((Z-$)**2+(K-J)**2),V=Math.sqrt((Q-$)**2+(H-J)**2);return Math.max(M,V)<j}let F=Math.sqrt(G),_=Math.abs((q-J)*Z-(z-$)*K+z*J-q*$)/F,U=Math.abs((q-J)*Q-(z-$)*H+z*J-q*$)/F;return Math.max(_,U)<j}function _z($,J,Z,K=0.5){if(!$||typeof $!=="object")throw new TypeError(`straightCurveToLine: cmd must be an object, got ${typeof $}`);if(typeof $.command!=="string")throw new TypeError(`straightCurveToLine: cmd.command must be a string, got ${typeof $.command}`);if(!Array.isArray($.args))throw new TypeError("straightCurveToLine: cmd.args must be an array");if(typeof J!=="number"||!isFinite(J))throw new TypeError(`straightCurveToLine: cx must be a finite number, got ${J}`);if(typeof Z!=="number"||!isFinite(Z))throw new TypeError(`straightCurveToLine: cy must be a finite number, got ${Z}`);if(typeof K!=="number"||!isFinite(K)||K<0)throw new TypeError(`straightCurveToLine: tolerance must be a non-negative finite number, got ${K}`);let{command:Q,args:H}=$;if(Q!=="C"&&Q!=="c")return null;if(H.length<6)throw new RangeError(`straightCurveToLine: command ${Q} requires at least 6 args, got ${H.length}`);let z=Q==="C",q=z?H[0]:J+H[0],j=z?H[1]:Z+H[1],W=z?H[2]:J+H[2],G=z?H[3]:Z+H[3],F=z?H[4]:J+H[4],_=z?H[5]:Z+H[5];if(Fz(J,Z,q,j,W,G,F,_,K))return z?{command:"L",args:[F,_]}:{command:"l",args:[F-J,_-Z]};return null}function e9($,J,Z=3,K=!1){if(!$||typeof $!=="object")throw new TypeError(`serializeCommand: cmd must be an object, got ${typeof $}`);if(typeof $.command!=="string")throw new TypeError(`serializeCommand: cmd.command must be a string, got ${typeof $.command}`);if(!Array.isArray($.args))throw new TypeError("serializeCommand: cmd.args must be an array");if(J!==null&&typeof J!=="string")throw new TypeError(`serializeCommand: prevCommand must be a string or null, got ${typeof J}`);if(typeof Z!=="number"||!Number.isInteger(Z)||Z<0)throw new TypeError(`serializeCommand: precision must be a non-negative integer, got ${Z}`);if(typeof K!=="boolean")throw new TypeError(`serializeCommand: prevLastArgHadDecimal must be a boolean, got ${typeof K}`);let{command:Q,args:H}=$;if(Q==="Z"||Q==="z")return{str:"z",lastArgHadDecimal:!1};if(Q==="A"||Q==="a"){if(H.length<7)throw new RangeError(`serializeCommand: arc command requires at least 7 args, got ${H.length}`);if(H.length>7)console.warn(`serializeCommand: arc command has ${H.length} args (expected 7) - only first 7 will be used`);let F=[f7(H[0],Z),f7(H[1],Z),f7(H[2],Z),H[3]?"1":"0",H[4]?"1":"0",f7(H[5],Z),f7(H[6],Z)].join(" ");return{str:Q+F,lastArgHadDecimal:F.includes(".")}}if(H.length===0)throw new RangeError(`serializeCommand: command ${Q} has empty args array (only Z/z should have no args)`);let z=H.map((F)=>f7(F,Z)),q="";for(let F=0;F<z.length;F++){let _=z[F];if(F===0)q=_;else{let M=z[F-1].includes(".");if(_.startsWith("-"))q+=_;else if(_.startsWith(".")&&M)q+=_;else q+=" "+_}}let W=(z[z.length-1]||"").includes("."),G=Q;if(J==="M"&&Q==="L")G="";else if(J==="m"&&Q==="l")G="";else if(J===Q&&Q!=="A"&&Q!=="a")G="";if(G)return{str:G+q,lastArgHadDecimal:W};else{let F=z[0]||"";if(F.startsWith("-"))return{str:q,lastArgHadDecimal:W};else if(F.startsWith(".")&&K)return{str:q,lastArgHadDecimal:W};else return{str:" "+q,lastArgHadDecimal:W}}}function s0($,J=3){if(!Array.isArray($))throw new TypeError(`serializePath: commands must be an array, got ${typeof $}`);if(typeof J!=="number"||!Number.isInteger(J)||J<0)throw new TypeError(`serializePath: precision must be a non-negative integer, got ${J}`);if($.length===0)return"";let Z="",K=null,Q=!1;for(let H of $){let{str:z,lastArgHadDecimal:q}=e9(H,K,J,Q);Z+=z,K=H.command,Q=q}return Z}function K8($,J={}){if(typeof $!=="string")throw new TypeError(`convertPathData: d must be a string, got ${typeof $}`);if(typeof J!=="object"||J===null||Array.isArray(J))throw new TypeError(`convertPathData: options must be an object, got ${typeof J}`);let{floatPrecision:Z=3,straightCurves:K=!0,lineShorthands:Q=!0,convertToZ:H=!0,utilizeAbsolute:z=!0,straightTolerance:q=0.5}=J;if(typeof Z!=="number"||!Number.isInteger(Z)||Z<0)throw new TypeError(`convertPathData: floatPrecision must be a non-negative integer, got ${Z}`);if(typeof K!=="boolean")throw new TypeError(`convertPathData: straightCurves must be a boolean, got ${typeof K}`);if(typeof Q!=="boolean")throw new TypeError(`convertPathData: lineShorthands must be a boolean, got ${typeof Q}`);if(typeof H!=="boolean")throw new TypeError(`convertPathData: convertToZ must be a boolean, got ${typeof H}`);if(typeof z!=="boolean")throw new TypeError(`convertPathData: utilizeAbsolute must be a boolean, got ${typeof z}`);if(typeof q!=="number"||!isFinite(q)||q<0)throw new TypeError(`convertPathData: straightTolerance must be a non-negative finite number, got ${q}`);let j=$.length,W=n0($);if(W.length===0)return{d:$,originalLength:j,optimizedLength:j,savings:0};let G=0,F=0,_=0,U=0,M=[];for(let Y=0;Y<W.length;Y++){let O=W[Y];if(O.command==="A"||O.command==="a"){if(O.args.length<7)console.warn(`Arc command has insufficient args (${O.args.length} < 7) - skipping optimization`);else if(O.args[0]===0||O.args[1]===0){let w=O.command==="A",R=O.args[5],B=O.args[6];O=w?{command:"L",args:[R,B]}:{command:"l",args:[R,B]}}}if(K&&(O.command==="C"||O.command==="c")){let w=_z(O,G,F,q);if(w)O=w}if(Q&&(O.command==="L"||O.command==="l")){let w=jz(O,G,F);if(w)O=w}if(H&&(O.command==="L"||O.command==="l")){if(Gz(O,G,F,_,U))O={command:"z",args:[]}}if(z&&O.command!=="Z"&&O.command!=="z"){let w=k7(O,G,F),R=J8(O,G,F),B=e9(w,null,Z);O=e9(R,null,Z).str.length<B.str.length?R:w}M.push(O);let X=k7(O,G,F);switch(X.command){case"M":if(X.args.length>=2)G=X.args[0],F=X.args[1],_=G,U=F;break;case"L":case"T":if(X.args.length>=2)G=X.args[0],F=X.args[1];break;case"H":if(X.args.length>=1)G=X.args[0];break;case"V":if(X.args.length>=1)F=X.args[0];break;case"C":if(X.args.length>=6)G=X.args[4],F=X.args[5];break;case"S":case"Q":if(X.args.length>=4)G=X.args[2],F=X.args[3];break;case"A":if(X.args.length>=7)G=X.args[5],F=X.args[6];break;case"Z":G=_,F=U;break;default:break}}let V=s0(M,Z);return{d:V,originalLength:j,optimizedLength:V.length,savings:j-V.length}}function DK($,J={}){if(!$||typeof $!=="object")throw new TypeError(`optimizeDocumentPaths: root must be a DOM element object, got ${typeof $}`);if(typeof J!=="object"||J===null||Array.isArray(J))throw new TypeError(`optimizeDocumentPaths: options must be an object, got ${typeof J}`);let Z=0,K=0,Q=[],H=(z)=>{if(!z||typeof z!=="object")return;if(z.tagName?.toLowerCase()==="path"){let j=z.getAttribute("d");if(j){let W=K8(j,J);if(W.savings>0)z.setAttribute("d",W.d),Z++,K+=W.savings,Q.push({id:z.getAttribute("id")||null,originalLength:W.originalLength,optimizedLength:W.optimizedLength,savings:W.savings})}}for(let j of z.children||[])H(j)};return H($),{pathsOptimized:Z,totalSavings:K,details:Q}}function hK($,J,Z){if(!$||typeof $.x!=="number"||typeof $.y!=="number")throw new TypeError("perpendicularDistance: point must be an object with numeric x and y properties");if(!J||typeof J.x!=="number"||typeof J.y!=="number")throw new TypeError("perpendicularDistance: lineStart must be an object with numeric x and y properties");if(!Z||typeof Z.x!=="number"||typeof Z.y!=="number")throw new TypeError("perpendicularDistance: lineEnd must be an object with numeric x and y properties");if(!Number.isFinite($.x)||!Number.isFinite($.y)||!Number.isFinite(J.x)||!Number.isFinite(J.y)||!Number.isFinite(Z.x)||!Number.isFinite(Z.y))throw new RangeError("perpendicularDistance: all coordinates must be finite numbers");let K=Z.x-J.x,Q=Z.y-J.y,H=K*K+Q*Q;if(H<0.0000000001){let j=$.x-J.x,W=$.y-J.y;return Math.sqrt(j*j+W*W)}let z=Math.abs(Q*$.x-K*$.y+Z.x*J.y-Z.y*J.x),q=Math.sqrt(H);return z/q}function a6($,J){if(!Array.isArray($))throw new TypeError("douglasPeucker: points must be an array");if($.length===0)throw new RangeError("douglasPeucker: points array cannot be empty");for(let z=0;z<$.length;z++){let q=$[z];if(!q||typeof q!=="object")throw new TypeError(`douglasPeucker: point at index ${z} must be an object`);if(typeof q.x!=="number"||!Number.isFinite(q.x))throw new TypeError(`douglasPeucker: point at index ${z} must have a finite numeric x property`);if(typeof q.y!=="number"||!Number.isFinite(q.y))throw new TypeError(`douglasPeucker: point at index ${z} must have a finite numeric y property`)}if(typeof J!=="number"||!Number.isFinite(J))throw new TypeError("douglasPeucker: tolerance must be a finite number");if(J<0)throw new RangeError("douglasPeucker: tolerance cannot be negative");if(J>0&&J<0.0000000001)throw new RangeError("douglasPeucker: tolerance must be either 0 or >= 1e-10 to avoid numerical precision issues");if($.length<=2)return $;if($.length>1e4)return Uz($,J);let Z=0,K=0,Q=$[0],H=$[$.length-1];for(let z=1;z<$.length-1;z++){let q=hK($[z],Q,H);if(q>Z)Z=q,K=z}if(Z>J){let z=a6($.slice(0,K+1),J),q=a6($.slice(K),J);return z.slice(0,-1).concat(q)}else return[Q,H]}function Uz($,J){if($.length<=2)return $;let Z=new Array($.length).fill(!1);Z[0]=!0,Z[$.length-1]=!0;let K=[[0,$.length-1]];while(K.length>0){let[Q,H]=K.pop();if(H-Q<=1)continue;let z=0,q=Q,j=$[Q],W=$[H];for(let G=Q+1;G<H;G++){let F=hK($[G],j,W);if(F>z)z=F,q=G}if(z>J)Z[q]=!0,K.push([Q,q]),K.push([q,H])}return $.filter((Q,H)=>Z[H])}function Z8($,J){if(!Array.isArray($))throw new TypeError("visvalingamWhyatt: points must be an array");if($.length===0)throw new RangeError("visvalingamWhyatt: points array cannot be empty");for(let q=0;q<$.length;q++){let j=$[q];if(!j||typeof j!=="object")throw new TypeError(`visvalingamWhyatt: point at index ${q} must be an object`);if(typeof j.x!=="number"||!Number.isFinite(j.x))throw new TypeError(`visvalingamWhyatt: point at index ${q} must have a finite numeric x property`);if(typeof j.y!=="number"||!Number.isFinite(j.y))throw new TypeError(`visvalingamWhyatt: point at index ${q} must have a finite numeric y property`)}if(typeof J!=="number"||!Number.isFinite(J))throw new TypeError("visvalingamWhyatt: minArea must be a finite number");if(J<0)throw new RangeError("visvalingamWhyatt: minArea cannot be negative");if($.length<=2)return $;let Z=(q,j,W)=>{return Math.abs((j.x-q.x)*(W.y-q.y)-(W.x-q.x)*(j.y-q.y))/2},K=$.map((q,j)=>({...q,index:j})),Q=new Array(K.length).fill(1/0);for(let q=1;q<K.length-1;q++)Q[q]=Z(K[q-1],K[q],K[q+1]);let H=new Array(K.length).fill(!0),z=K.length;while(z>2){let q=1/0,j=-1;for(let F=1;F<K.length-1;F++)if(H[F]&&Q[F]<q)q=Q[F],j=F;if(q>=J||j===-1)break;H[j]=!1,z--;let W=j-1;while(W>=0&&!H[W])W--;let G=j+1;while(G<K.length&&!H[G])G++;if(W>0){let F=W-1;while(F>=0&&!H[F])F--;if(F>=0&&G<K.length)Q[W]=Z(K[F],K[W],K[G])}if(G<K.length-1){let F=G+1;while(F<K.length&&!H[F])F++;if(F<K.length&&W>=0)Q[G]=Z(K[W],K[G],K[F])}}return K.filter((q,j)=>H[j])}function Q8($,J,Z="douglas-peucker"){if(!Array.isArray($))throw new TypeError("simplifyPolyline: points must be an array");if($.length===0)throw new RangeError("simplifyPolyline: points array cannot be empty");if(typeof J!=="number"||!Number.isFinite(J))throw new TypeError("simplifyPolyline: tolerance must be a finite number");if(J<0)throw new RangeError("simplifyPolyline: tolerance cannot be negative");if(J>0&&J<0.0000000001)throw new RangeError("simplifyPolyline: tolerance must be either 0 or >= 1e-10 to avoid numerical precision issues");if(typeof Z!=="string")throw new TypeError("simplifyPolyline: algorithm must be a string");let K=["douglas-peucker","visvalingam"];if(!K.includes(Z))throw new RangeError(`simplifyPolyline: algorithm must be one of: ${K.join(", ")}`);if(Z==="visvalingam")return Z8($,J*J);return a6($,J)}function Vz($){if(!Array.isArray($))throw new TypeError("extractPolylinePoints: commands must be an array");let J=[],Z=0,K=0,Q=0,H=0;for(let z of $){if(!z||typeof z!=="object")throw new TypeError("extractPolylinePoints: each command must be an object");if(typeof z.command!=="string")throw new TypeError('extractPolylinePoints: each command must have a string "command" property');if(!Array.isArray(z.args))throw new TypeError('extractPolylinePoints: each command must have an "args" array');let{command:q,args:j}=z,W=(F)=>{if(j.length<F)throw new RangeError(`extractPolylinePoints: command "${q}" requires at least ${F} arguments, got ${j.length}`)},G=(F)=>{if(typeof j[F]!=="number"||!Number.isFinite(j[F]))throw new TypeError(`extractPolylinePoints: command "${q}" argument at index ${F} must be a finite number, got ${j[F]}`)};switch(q){case"M":W(2),G(0),G(1),Z=j[0],K=j[1],Q=Z,H=K,J.push({x:Z,y:K});break;case"m":W(2),G(0),G(1),Z+=j[0],K+=j[1],Q=Z,H=K,J.push({x:Z,y:K});break;case"L":W(2),G(0),G(1),Z=j[0],K=j[1],J.push({x:Z,y:K});break;case"l":W(2),G(0),G(1),Z+=j[0],K+=j[1],J.push({x:Z,y:K});break;case"H":W(1),G(0),Z=j[0],J.push({x:Z,y:K});break;case"h":W(1),G(0),Z+=j[0],J.push({x:Z,y:K});break;case"V":W(1),G(0),K=j[0],J.push({x:Z,y:K});break;case"v":W(1),G(0),K+=j[0],J.push({x:Z,y:K});break;case"Z":case"z":if(Z!==Q||K!==H)J.push({x:Q,y:H});Z=Q,K=H;break;case"C":W(6),G(4),G(5),Z=j[4],K=j[5];break;case"c":W(6),G(4),G(5),Z+=j[4],K+=j[5];break;case"S":case"Q":W(4),G(2),G(3),Z=j[2],K=j[3];break;case"s":case"q":W(4),G(2),G(3),Z+=j[2],K+=j[3];break;case"T":W(2),G(0),G(1),Z=j[0],K=j[1];break;case"t":W(2),G(0),G(1),Z+=j[0],K+=j[1];break;case"A":W(7),G(5),G(6),Z=j[5],K=j[6];break;case"a":W(7),G(5),G(6),Z+=j[5],K+=j[6];break;default:break}}return J}function Mz($,J=!1){if(!Array.isArray($))throw new TypeError("rebuildPathFromPoints: points must be an array");if($.length===0)return[];if(typeof J!=="boolean")throw new TypeError("rebuildPathFromPoints: closed must be a boolean");for(let K=0;K<$.length;K++){let Q=$[K];if(!Q||typeof Q!=="object")throw new TypeError(`rebuildPathFromPoints: point at index ${K} must be an object`);if(typeof Q.x!=="number"||!Number.isFinite(Q.x))throw new TypeError(`rebuildPathFromPoints: point at index ${K} must have a finite numeric x property`);if(typeof Q.y!=="number"||!Number.isFinite(Q.y))throw new TypeError(`rebuildPathFromPoints: point at index ${K} must have a finite numeric y property`)}let Z=[];Z.push({command:"M",args:[$[0].x,$[0].y]});for(let K=1;K<$.length;K++)Z.push({command:"L",args:[$[K].x,$[K].y]});if(J)Z.push({command:"Z",args:[]});return Z}function H8($){if(!Array.isArray($))throw new TypeError("isPurePolyline: commands must be an array");let J=new Set(["M","m","L","l","H","h","V","v","Z","z"]);return $.every((Z)=>{if(!Z||typeof Z!=="object"||typeof Z.command!=="string")return!1;return J.has(Z.command)})}function z8($,J,Z="douglas-peucker"){if(!Array.isArray($))throw new TypeError("simplifyPath: commands must be an array");if(typeof J!=="number"||!Number.isFinite(J))throw new TypeError("simplifyPath: tolerance must be a finite number");if(J<0)throw new RangeError("simplifyPath: tolerance cannot be negative");if(J>0&&J<0.0000000001)throw new RangeError("simplifyPath: tolerance must be either 0 or >= 1e-10 to avoid numerical precision issues");if(!H8($)||$.length<3)return{commands:$,simplified:!1,originalPoints:0,simplifiedPoints:0};let K=Vz($),Q=K.length;if(Q<3)return{commands:$,simplified:!1,originalPoints:Q,simplifiedPoints:Q};let H=$[$.length-1].command.toLowerCase()==="z";if(H&&K.length>1){let W=K[0],G=K[K.length-1];if(Math.abs(G.x-W.x)<0.0000000001&&Math.abs(G.y-W.y)<0.0000000001)K=K.slice(0,-1)}let z=Q8(K,J,Z),q=z.length;if(q>=Q)return{commands:$,simplified:!1,originalPoints:Q,simplifiedPoints:Q};return{commands:Mz(z,H),simplified:!0,originalPoints:Q,simplifiedPoints:q}}function z7($){if(typeof $!=="string")throw new TypeError("Path d must be a string")}function q7($){if(typeof $!=="number"||!Number.isFinite($)||$<0)throw new TypeError(`Precision must be a finite non-negative number, got ${$}`)}function J6($){if(typeof $!=="number"||!Number.isFinite($)||$<0)throw new TypeError(`Tolerance must be a finite non-negative number, got ${$}`)}function W7($,J=0){if(!$||typeof $!=="object")throw new TypeError("Command must be an object");if(typeof $.command!=="string")throw new TypeError("Command must have a string 'command' property");if(!Array.isArray($.args))throw new TypeError("Command must have an array 'args' property");if($.args.length<J)throw new TypeError(`Command ${$.command} requires at least ${J} args, got ${$.args.length}`);for(let Z=0;Z<$.args.length;Z++)if(typeof $.args[Z]!=="number"||!Number.isFinite($.args[Z]))throw new TypeError(`Command ${$.command} arg[${Z}] must be a finite number, got ${$.args[Z]}`)}function h$($,J=3){z7($),q7(J);let Z=n0($);if(Z.length===0)return $;Z.forEach((Q)=>W7(Q));let K=Z.map((Q)=>({command:Q.command,args:Q.args.map((H)=>{let z=f7(H,J),q=parseFloat(z);if(!Number.isFinite(q))throw new Error(`Invalid numeric value encountered: ${z}`);return q})}));return s0(K,J)}function y$($,J=3){z7($),q7(J);let Z=n0($);if(Z.length===0)return $;return Z.forEach((K)=>W7(K)),s0(Z,J)}function u$($,J=3){z7($),q7(J);let Z=n0($);if(Z.length===0)return $;Z.forEach((j)=>W7(j));let K=0,Q=0,H=0,z=0,q=[];for(let j of Z){let W=J8(j,K,Q);q.push(W);let G=k7(j,K,Q);switch(G.command){case"M":K=G.args[0],Q=G.args[1],H=K,z=Q;break;case"L":case"T":K=G.args[0],Q=G.args[1];break;case"H":K=G.args[0];break;case"V":Q=G.args[0];break;case"C":K=G.args[4],Q=G.args[5];break;case"S":case"Q":K=G.args[2],Q=G.args[3];break;case"A":K=G.args[5],Q=G.args[6];break;case"Z":K=H,Q=z;break;default:break}}return s0(q,J)}function g$($,J=3){z7($),q7(J);let Z=n0($);if(Z.length===0)return $;Z.forEach((j)=>W7(j));let K=0,Q=0,H=0,z=0,q=[];for(let j of Z){let W=k7(j,K,Q);switch(q.push(W),W.command){case"M":K=W.args[0],Q=W.args[1],H=K,z=Q;break;case"L":case"T":K=W.args[0],Q=W.args[1];break;case"H":K=W.args[0];break;case"V":Q=W.args[0];break;case"C":K=W.args[4],Q=W.args[5];break;case"S":case"Q":K=W.args[2],Q=W.args[3];break;case"A":K=W.args[5],Q=W.args[6];break;case"Z":K=H,Q=z;break;default:break}}return s0(q,J)}function x$($,J=0.000001,Z=3){z7($),J6(J),q7(Z);let K=n0($);if(K.length===0)return $;K.forEach((W)=>W7(W));let Q=0,H=0,z=0,q=0,j=[];for(let W of K){let G=W;if(W.command==="L"||W.command==="l"){let _=W.command==="L",U=_?W.args[0]:Q+W.args[0],M=_?W.args[1]:H+W.args[1];if(Math.abs(M-H)<J)G=_?{command:"H",args:[U]}:{command:"h",args:[U-Q]};else if(Math.abs(U-Q)<J)G=_?{command:"V",args:[M]}:{command:"v",args:[M-H]}}j.push(G);let F=k7(G,Q,H);switch(F.command){case"M":Q=F.args[0],H=F.args[1],z=Q,q=H;break;case"L":case"T":Q=F.args[0],H=F.args[1];break;case"H":Q=F.args[0];break;case"V":H=F.args[0];break;case"C":Q=F.args[4],H=F.args[5];break;case"S":case"Q":Q=F.args[2],H=F.args[3];break;case"A":Q=F.args[5],H=F.args[6];break;case"Z":Q=z,H=q;break;default:break}}return s0(j,Z)}function m$($,J=0.000001,Z=3){z7($),J6(J),q7(Z);let K=n0($);if(K.length===0)return $;K.forEach((W)=>W7(W));let Q=0,H=0,z=0,q=0,j=[];for(let W=0;W<K.length;W++){let G=K[W],F=G;if(G.command==="L"||G.command==="l"){let U=G.command==="L",M=U?G.args[0]:Q+G.args[0],V=U?G.args[1]:H+G.args[1];if((W===K.length-1||K[W+1].command==="M"||K[W+1].command==="m")&&Math.abs(M-z)<J&&Math.abs(V-q)<J)F={command:"z",args:[]}}j.push(F);let _=k7(F,Q,H);switch(_.command){case"M":Q=_.args[0],H=_.args[1],z=Q,q=H;break;case"L":case"T":Q=_.args[0],H=_.args[1];break;case"H":Q=_.args[0];break;case"V":H=_.args[0];break;case"C":Q=_.args[4],H=_.args[5];break;case"S":case"Q":Q=_.args[2],H=_.args[3];break;case"A":Q=_.args[5],H=_.args[6];break;case"Z":Q=z,H=q;break;default:break}}return s0(j,Z)}function C6(...$){for(let J=0;J<$.length;J++)if(typeof $[J]!=="number"||!Number.isFinite($[J]))throw new TypeError(`Coordinate at position ${J} must be a finite number, got ${$[J]}`)}function yK($){if(typeof $!=="number"||!Number.isFinite($))throw new TypeError(`Parameter t must be a finite number, got ${$}`);if($<0||$>1)throw new RangeError(`Parameter t must be in range [0, 1], got ${$}`)}function D$($,J,Z,K,Q,H,z,q,j){yK($),C6(J,Z,K,Q,H,z,q,j);let W=1-$,G=W*W,F=G*W,_=$*$,U=_*$;return{x:F*J+3*G*$*K+3*W*_*H+U*q,y:F*Z+3*G*$*Q+3*W*_*z+U*j}}function q8($,J,Z,K,Q,H){C6($,J,Z,K,Q,H);let z=Q-Z,q=H-K,j=z*z+q*q;if(j<0.0000000001)return Math.sqrt(($-Z)**2+(J-K)**2);let W=Math.max(0,Math.min(1,(($-Z)*z+(J-K)*q)/j)),G=Z+W*z,F=K+W*q;return Math.sqrt(($-G)**2+(J-F)**2)}function Oz($,J,Z,K,Q,H,z,q){C6($,J,Z,K,Q,H,z,q);let j=0,W=[0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9];for(let G of W){let F=D$(G,$,J,Z,K,Q,H,z,q),_=q8(F.x,F.y,$,J,z,q);if(_>j)j=_}for(let G=0;G<W.length-1;G++){let F=(W[G]+W[G+1])/2,_=D$(F,$,J,Z,K,Q,H,z,q),U=q8(_.x,_.y,$,J,z,q);if(U>j)j=U}for(let G of[0.05,0.95]){let F=D$(G,$,J,Z,K,Q,H,z,q),_=q8(F.x,F.y,$,J,z,q);if(_>j)j=_}return j}function Yz($,J,Z,K,Q,H,z,q,j){return Oz($,J,Z,K,Q,H,z,q)<=j}function d$($,J=0.5,Z=3){z7($),J6(J),q7(Z);let K=n0($);if(K.length===0)return $;K.forEach((W)=>W7(W));let Q=0,H=0,z=0,q=0,j=[];for(let W of K){let G=W;if(W.command==="C"||W.command==="c"){let _=W.command==="C",U=_?W.args[0]:Q+W.args[0],M=_?W.args[1]:H+W.args[1],V=_?W.args[2]:Q+W.args[2],Y=_?W.args[3]:H+W.args[3],O=_?W.args[4]:Q+W.args[4],X=_?W.args[5]:H+W.args[5];if(Yz(Q,H,U,M,V,Y,O,X,J))G=_?{command:"L",args:[O,X]}:{command:"l",args:[O-Q,X-H]}}j.push(G);let F=k7(G,Q,H);switch(F.command){case"M":Q=F.args[0],H=F.args[1],z=Q,q=H;break;case"L":case"T":Q=F.args[0],H=F.args[1];break;case"H":Q=F.args[0];break;case"V":H=F.args[0];break;case"C":Q=F.args[4],H=F.args[5];break;case"S":case"Q":Q=F.args[2],H=F.args[3];break;case"A":Q=F.args[5],H=F.args[6];break;case"Z":Q=z,H=q;break;default:break}}return s0(j,Z)}function p$($,J=3){z7($),q7(J);let Z=n0($);if(Z.length===0)return $;return Z.forEach((K)=>W7(K)),s0(Z,J)}function c$($,J=3){if(z7($),q7(J),J>15)throw new RangeError(`Precision ${J} is too large (max 15)`);let Z=n0($);if(Z.length===0)return $;Z.forEach((H)=>W7(H));let K=Math.pow(10,J),Q=Z.map((H)=>({command:H.command,args:H.args.map((z)=>Math.round(z*K)/K)}));return s0(Q,J)}function l$($,J=0.000001,Z=3){z7($),J6(J),q7(Z);let K=n0($);if(K.length===0)return $;K.forEach((W)=>W7(W));let Q=0,H=0,z=0,q=0,j=[];for(let W of K){let G=k7(W,Q,H),F=!0;switch(G.command){case"L":case"T":if(Math.abs(G.args[0]-Q)<J&&Math.abs(G.args[1]-H)<J)F=!1;break;case"H":if(Math.abs(G.args[0]-Q)<J)F=!1;break;case"V":if(Math.abs(G.args[0]-H)<J)F=!1;break;case"C":if(Math.abs(G.args[4]-Q)<J&&Math.abs(G.args[5]-H)<J&&Math.abs(G.args[0]-Q)<J&&Math.abs(G.args[1]-H)<J&&Math.abs(G.args[2]-Q)<J&&Math.abs(G.args[3]-H)<J)F=!1;break;case"S":if(Math.abs(G.args[2]-Q)<J&&Math.abs(G.args[3]-H)<J&&Math.abs(G.args[0]-Q)<J&&Math.abs(G.args[1]-H)<J)F=!1;break;case"Q":if(Math.abs(G.args[2]-Q)<J&&Math.abs(G.args[3]-H)<J&&Math.abs(G.args[0]-Q)<J&&Math.abs(G.args[1]-H)<J)F=!1;break;case"A":if(Math.abs(G.args[5]-Q)<J&&Math.abs(G.args[6]-H)<J||Math.abs(G.args[0])<J||Math.abs(G.args[1])<J)F=!1;break;default:break}if(F)switch(j.push(W),G.command){case"M":Q=G.args[0],H=G.args[1],z=Q,q=H;break;case"L":case"T":Q=G.args[0],H=G.args[1];break;case"H":Q=G.args[0];break;case"V":H=G.args[0];break;case"C":Q=G.args[4],H=G.args[5];break;case"S":case"Q":Q=G.args[2],H=G.args[3];break;case"A":Q=G.args[5],H=G.args[6];break;case"Z":Q=z,H=q;break;default:break}}return s0(j,Z)}function Xz($,J,Z,K,Q,H,z){yK($),C6(J,Z,K,Q,H,z);let q=1-$,j=q*q,W=$*$;return{x:j*J+2*q*$*K+W*H,y:j*Z+2*q*$*Q+W*z}}function Lz($,J,Z,K,Q,H,z,q,j,W){C6($,J,Z,K,Q,H,z,q,j,W);let G=0,F=[0.05,0.1,0.15,0.2,0.25,0.3,0.35,0.4,0.45,0.5,0.55,0.6,0.65,0.7,0.75,0.8,0.85,0.9,0.95];for(let _ of F){let U=D$(_,$,J,Z,K,Q,H,z,q),M=Xz(_,$,J,j,W,z,q),V=Math.sqrt((U.x-M.x)**2+(U.y-M.y)**2);if(V>G)G=V}return G}function kz($,J,Z,K,Q,H,z,q,j){C6($,J,Z,K,Q,H,z,q),J6(j);let W=(3*(Z+Q)-$-z)/4,G=(3*(K+H)-J-q)/4;if(Lz($,J,Z,K,Q,H,z,q,W,G)<=j)return{cpx:W,cpy:G};return null}function n$($,J=0.5,Z=3){z7($),J6(J),q7(Z);let K=n0($);if(K.length===0)return $;K.forEach((W)=>W7(W));let Q=0,H=0,z=0,q=0,j=[];for(let W of K){let G=W;if(W.command==="C"||W.command==="c"){let _=W.command==="C",U=_?W.args[0]:Q+W.args[0],M=_?W.args[1]:H+W.args[1],V=_?W.args[2]:Q+W.args[2],Y=_?W.args[3]:H+W.args[3],O=_?W.args[4]:Q+W.args[4],X=_?W.args[5]:H+W.args[5],w=kz(Q,H,U,M,V,Y,O,X,J);if(w)G=_?{command:"Q",args:[w.cpx,w.cpy,O,X]}:{command:"q",args:[w.cpx-Q,w.cpy-H,O-Q,X-H]}}j.push(G);let F=k7(G,Q,H);switch(F.command){case"M":Q=F.args[0],H=F.args[1],z=Q,q=H;break;case"L":case"T":Q=F.args[0],H=F.args[1];break;case"H":Q=F.args[0];break;case"V":H=F.args[0];break;case"C":Q=F.args[4],H=F.args[5];break;case"S":case"Q":Q=F.args[2],H=F.args[3];break;case"A":Q=F.args[5],H=F.args[6];break;case"Z":Q=z,H=q;break;default:break}}return s0(j,Z)}function s$($,J=0.000001,Z=3){z7($),J6(J),q7(Z);let K=n0($);if(K.length===0)return $;K.forEach((F)=>W7(F));let Q=0,H=0,z=0,q=0,j=null,W=null,G=[];for(let F of K){let _=F,U=k7(F,Q,H);if(U.command==="Q"&&j!==null){let M=2*Q-j,V=2*H-W;if(Math.abs(U.args[0]-M)<J&&Math.abs(U.args[1]-V)<J)_=F.command==="Q"?{command:"T",args:[U.args[2],U.args[3]]}:{command:"t",args:[U.args[2]-Q,U.args[3]-H]}}if(G.push(_),U.command==="Q")j=U.args[0],W=U.args[1];else if(U.command==="T")if(j!==null)j=2*Q-j,W=2*H-W;else j=Q,W=H;else j=null,W=null;switch(U.command){case"M":Q=U.args[0],H=U.args[1],z=Q,q=H;break;case"L":case"T":Q=U.args[0],H=U.args[1];break;case"H":Q=U.args[0];break;case"V":H=U.args[0];break;case"C":Q=U.args[4],H=U.args[5];break;case"S":case"Q":Q=U.args[2],H=U.args[3];break;case"A":Q=U.args[5],H=U.args[6];break;case"Z":Q=z,H=q;break;default:break}}return s0(G,Z)}function o$($,J=0.000001,Z=3){z7($),J6(J),q7(Z);let K=n0($);if(K.length===0)return $;K.forEach((F)=>W7(F));let Q=0,H=0,z=0,q=0,j=null,W=null,G=[];for(let F of K){let _=F,U=k7(F,Q,H);if(U.command==="C"&&j!==null){let M=2*Q-j,V=2*H-W;if(Math.abs(U.args[0]-M)<J&&Math.abs(U.args[1]-V)<J)_=F.command==="C"?{command:"S",args:[U.args[2],U.args[3],U.args[4],U.args[5]]}:{command:"s",args:[U.args[2]-Q,U.args[3]-H,U.args[4]-Q,U.args[5]-H]}}if(G.push(_),U.command==="C")j=U.args[2],W=U.args[3];else if(U.command==="S")j=U.args[0],W=U.args[1];else j=null,W=null;switch(U.command){case"M":Q=U.args[0],H=U.args[1],z=Q,q=H;break;case"L":case"T":Q=U.args[0],H=U.args[1];break;case"H":Q=U.args[0];break;case"V":H=U.args[0];break;case"C":Q=U.args[4],H=U.args[5];break;case"S":case"Q":Q=U.args[2],H=U.args[3];break;case"A":Q=U.args[5],H=U.args[6];break;case"Z":Q=z,H=q;break;default:break}}return s0(G,Z)}function i$($,J=3){z7($),q7(J);let Z=n0($);if(Z.length===0)return $;Z.forEach((Q)=>W7(Q));let K=Z.map((Q)=>{if(Q.command==="A"||Q.command==="a"){let H=[...Q.args];if(H.length!==7)throw new Error(`Arc command requires 7 arguments, got ${H.length}`);if(H[2]=(H[2]%360+360)%360,Math.abs(H[0]-H[1])<0.000001)H[2]=0;return H[3]=H[3]?1:0,H[4]=H[4]?1:0,{command:Q.command,args:H}}return Q});return s0(K,J)}var _6=new Set(["a","altGlyph","altGlyphDef","altGlyphItem","animate","animateColor","animateMotion","animateTransform","circle","clipPath","color-profile","cursor","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","font","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignObject","g","glyph","glyphRef","hkern","image","line","linearGradient","marker","mask","metadata","missing-glyph","mpath","path","pattern","polygon","polyline","radialGradient","rect","script","set","stop","style","svg","switch","symbol","text","textPath","title","tref","tspan","use","view","vkern"]),F8=new Set([..._6].map(($)=>$.toLowerCase())),U6=new Set(["accent-height","accumulate","additive","alignment-baseline","alphabetic","amplitude","arabic-form","ascent","attributeName","attributeType","azimuth","baseFrequency","baseline-shift","baseProfile","bbox","begin","bias","by","calcMode","cap-height","class","clip","clip-path","clip-rule","clipPathUnits","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","contentScriptType","contentStyleType","cursor","cx","cy","d","descent","diffuseConstant","direction","display","divisor","dominant-baseline","dur","dx","dy","edgeMode","elevation","enable-background","end","exponent","externalResourcesRequired","fill","fill-opacity","fill-rule","filter","filterRes","filterUnits","filterPrimitiveUnits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","format","from","fx","fy","g1","g2","glyph-name","glyph-orientation-horizontal","glyph-orientation-vertical","glyphRef","gradientTransform","gradientUnits","hanging","height","horiz-adv-x","horiz-origin-x","horiz-origin-y","href","id","ideographic","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kernelMatrix","kernelUnitLength","kerning","keyPoints","keySplines","keyTimes","lang","lengthAdjust","letter-spacing","lighting-color","limitingConeAngle","local","marker-end","marker-mid","marker-start","markerHeight","markerUnits","markerWidth","mask","maskContentUnits","maskUnits","mathematical","max","media","method","min","mode","name","numOctaves","offset","onabort","onactivate","onbegin","onclick","onend","onerror","onfocusin","onfocusout","onload","onmousedown","onmousemove","onmouseout","onmouseover","onmouseup","onrepeat","onresize","onscroll","onunload","onzoom","opacity","operator","order","orient","orientation","origin","overflow","overline-position","overline-thickness","panose-1","path","pathLength","patternContentUnits","patternTransform","patternUnits","pointer-events","points","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","r","radius","refX","refY","rendering-intent","repeatCount","repeatDur","requiredExtensions","requiredFeatures","restart","result","rotate","rx","ry","scale","seed","shape-rendering","slope","spacing","specularConstant","specularExponent","spreadMethod","startOffset","stdDeviation","stemh","stemv","stitchTiles","stop-color","stop-opacity","strikethrough-position","strikethrough-thickness","string","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","surfaceScale","systemLanguage","tableValues","target","targetX","targetY","text-anchor","text-decoration","text-rendering","textLength","title","to","transform","type","u1","u2","underline-position","underline-thickness","unicode","unicode-bidi","unicode-range","units-per-em","v-alphabetic","v-hanging","v-ideographic","v-mathematical","values","version","vert-adv-y","vert-origin-x","vert-origin-y","viewBox","viewTarget","visibility","width","widths","word-spacing","writing-mode","x","x-height","x1","x2","xChannelSelector","xlink:actuate","xlink:arcrole","xlink:href","xlink:role","xlink:show","xlink:title","xlink:type","xml:base","xml:id","xml:lang","xml:space","xmlns","xmlns:xlink","y","y1","y2","yChannelSelector","z","zoomAndPan","line-height","marker"]),_8=new Set([...U6].map(($)=>$.toLowerCase())),lz=new Set(["mesh","meshgradient","meshpatch","meshrow","solidcolor","hatch","hatchpath","discard","unknown","canvas","video","audio","iframe","source","track"]),nz=new Set(["href","tabindex","lang","transform-origin","vector-effect","paint-order","pathLength","fr","side","crossorigin","role","aria-label","aria-labelledby","aria-describedby","aria-hidden","aria-controls","aria-expanded","aria-haspopup","aria-live","aria-atomic","aria-relevant","aria-busy","aria-owns"]),sz=($)=>{if(!$||typeof $!=="string")return!1;return lz.has($.toLowerCase())},oz=($)=>{if(!$||typeof $!=="string")return!1;let J=$.toLowerCase();return nz.has(J)||J.startsWith("aria-")||J.startsWith("data-")},dK=new Set(["foreignobject","script","style","title","desc","metadata"]),r$=new Map,iz=($,J)=>{if(typeof $!=="string"||typeof J!=="string")throw new Error("Both parameters must be strings");let Z=`${$}|${J}`;if(r$.has(Z))return r$.get(Z);if($.length===0)return J.length;if(J.length===0)return $.length;let K=[];for(let H=0;H<=J.length;H++)K[H]=[H];for(let H=0;H<=$.length;H++)K[0][H]=H;for(let H=1;H<=J.length;H++)for(let z=1;z<=$.length;z++){let q=$[z-1]===J[H-1]?0:1;K[H][z]=Math.min(K[H-1][z]+1,K[H][z-1]+1,K[H-1][z-1]+q)}let Q=K[J.length][$.length];return r$.set(Z,Q),Q},rz=()=>r$.clear(),A6=($,J,Z=2)=>{if(!$||typeof $!=="string")return null;if(!J||!(J instanceof Set)||J.size===0)return null;let K=typeof Z!=="number"||Z<0?2:Z,Q=$.toLowerCase(),H=null,z=K+1;for(let q of J){let j=iz(Q,q.toLowerCase());if(j>0&&j<z)z=j,H=q}return H};function p7($){if(!$||typeof $!=="string")return!1;return/(%|em|rem|px|pt|cm|mm|in|pc|ex|ch|vw|vh|vmin|vmax|Q)$/i.test($.trim())}function az($,J,Z=100){let K=new Set,Q=$,H=0;while(Q!==null&&Q!==void 0&&H<Z){if(K.has(Q))return!0;K.add(Q),Q=J(Q),H++}return H>=Z}function pK($){if(!$||typeof $!=="string")return $||"";return $.replace(/<(script|style)([^>]*)\sdata-cdata-pending="true"([^>]*)>([\s\S]*?)<\/\1>/gi,(J,Z,K,Q,H)=>{let z=H.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").replace(/&quot;/g,'"').replace(/&#39;/g,"'"),q=(K+Q).replace(/\s*data-cdata-pending="true"\s*/g," ").trim(),j=q?" "+q:"";return`<${Z}${j}><![CDATA[
18
18
  ${z}
19
- ]]></${Z}>`})}var i$=/-?\d*\.?\d+(?:[eE][+-]?\d+)?/g,P6=80,t6=6,W8={BROWSER_MIN:2,BROWSER_TYPICAL:6,FLOAT32:7,FLOAT64:15,GEOGRAPHIC:8,SCIENTIFIC:20,MAX:80};k.set({precision:P6,rounding:k.ROUND_HALF_UP});var j8=($)=>$ instanceof k?$:new k($);function a($){return $!==null&&typeof $==="object"&&typeof $.tagName==="string"&&typeof $.getAttribute==="function"&&typeof $.setAttribute==="function"}function G8($,J=t6){if($===null||$===void 0)return"0";let Z=J;if(typeof J!=="number"||isNaN(J)||J<0)Z=t6;if(Z>P6)Z=P6;let Q=j8($).toFixed(Z);if(Q.includes("."))return Q.replace(/\.?0+$/,"");return Q}function gK($){if($===null||$===void 0)return"";return String($).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}var S0={SVG_STRING:"string",DOM_ELEMENT:"dom",FILE_PATH:"file",URL:"url",XML_DOCUMENT:"xml",CSS_SELECTOR:"selector",OBJECT_ELEMENT:"object",EMBED_ELEMENT:"embed",IFRAME_ELEMENT:"iframe"},W7={SVG_STRING:"string",DOM_ELEMENT:"dom",XML_DOCUMENT:"xml"},q7={STRING:"string",FILE:"file",DOM_REPLACE:"dom_replace",DOM_UPDATE:"dom_update",DOWNLOAD:"download"};function t$($){if($===null||$===void 0)return q7.STRING;if(typeof $==="object"&&$.nodeType)return q7.DOM_UPDATE;if(typeof $==="string"){let J=$.trim();if(typeof document!=="undefined"&&(J.startsWith("#")||J.startsWith(".")||J.startsWith("[")))return q7.DOM_REPLACE;if(J.includes("/")||J.includes("\\")||/\.\w+$/.test(J))return q7.FILE;if(J.toLowerCase()==="download")return q7.DOWNLOAD}return q7.STRING}async function F8($,J=null,Z={}){let K=t$(J),Q;if(typeof $==="string")Q=$;else Q=T6($,W7.SVG_STRING,Z);switch(K){case q7.STRING:return Q;case q7.FILE:{if(typeof process!=="undefined"&&process.versions?.node){let H=await import("fs"),q=(await Promise.resolve().then(() => (I6(),N6))).dirname(J);if(q&&q!=="."&&!H.existsSync(q))H.mkdirSync(q,{recursive:!0});H.writeFileSync(J,Q,"utf8");return}throw new Error("File saving requires Node.js environment")}case q7.DOM_REPLACE:{if(typeof document==="undefined")throw new Error("DOM operations require browser environment");let H=document.querySelector(J);if(!H)throw new Error(`No element found for selector: ${J}`);H.innerHTML=Q;return}case q7.DOM_UPDATE:{if(typeof document==="undefined")throw new Error("DOM operations require browser environment");if(J.tagName?.toLowerCase()==="svg"){let q=new DOMParser().parseFromString(Q,"image/svg+xml").documentElement;while(J.attributes.length>0)J.removeAttribute(J.attributes[0].name);for(let W of q.attributes)J.setAttribute(W.name,W.value);J.innerHTML=q.innerHTML}else J.innerHTML=Q;return}case q7.DOWNLOAD:{if(typeof document==="undefined"||typeof Blob==="undefined")throw new Error("Download requires browser environment");let H=new Blob([Q],{type:"image/svg+xml"}),z=URL.createObjectURL(H),q=document.createElement("a");q.href=z,q.download=Z.filename||"output.svg",document.body.appendChild(q),q.click(),document.body.removeChild(q),URL.revokeObjectURL(z);return}default:return Q}}function A6($){if($===null||$===void 0)throw new Error("Input cannot be null or undefined");if(typeof $==="string"){let J=$.trim();if(J.startsWith("<"))return S0.SVG_STRING;else if($.startsWith("http://")||$.startsWith("https://"))return S0.URL;else if(typeof document!=="undefined"&&(J.startsWith("#")||J.startsWith(".")||J.startsWith("[")))return S0.CSS_SELECTOR;else return S0.FILE_PATH}if(typeof HTMLObjectElement!=="undefined"&&$ instanceof HTMLObjectElement)return S0.OBJECT_ELEMENT;if(typeof HTMLEmbedElement!=="undefined"&&$ instanceof HTMLEmbedElement)return S0.EMBED_ELEMENT;if(typeof HTMLIFrameElement!=="undefined"&&$ instanceof HTMLIFrameElement)return S0.IFRAME_ELEMENT;if(a($))return S0.DOM_ELEMENT;if($&&$.nodeType===9)return S0.XML_DOCUMENT;return S0.SVG_STRING}async function E6($,J){switch(J){case S0.SVG_STRING:return d0($);case S0.DOM_ELEMENT:if($&&typeof $.serialize==="function")return $;if(typeof XMLSerializer!=="undefined"){let K=new XMLSerializer().serializeToString($);return d0(K)}return $;case S0.XML_DOCUMENT:{let Z=$.documentElement||$;if(Z&&typeof Z.serialize==="function")return Z;if(typeof XMLSerializer!=="undefined"){let Q=new XMLSerializer().serializeToString(Z);return d0(Q)}return Z}case S0.FILE_PATH:{let K=(()=>({})).readFileSync($,"utf8");return d0(K)}if(typeof process!=="undefined"&&process.versions?.node){let{readFileSync:Z}=await import("fs"),K=Z($,"utf8");return d0(K)}throw new Error("File loading requires Node.js environment");case S0.URL:if(typeof fetch!=="undefined"){let K=await(await fetch($)).text();return d0(K)}throw new Error("URL loading requires fetch API");case S0.CSS_SELECTOR:if(typeof document!=="undefined"){let Z=document.querySelector($);if(!Z)throw new Error(`No element found for selector: ${$}`);if(Z.tagName.toLowerCase()==="svg")return d0(new XMLSerializer().serializeToString(Z));let K=Z.querySelector("svg");if(K)return d0(new XMLSerializer().serializeToString(K));throw new Error(`Element "${$}" is not an SVG and contains no SVG`)}throw new Error("CSS selector requires browser environment");case S0.OBJECT_ELEMENT:try{if($.contentDocument&&$.contentDocument.documentElement){let Z=$.contentDocument.documentElement;if(Z.tagName.toLowerCase()==="svg")return d0(new XMLSerializer().serializeToString(Z))}}catch(Z){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${Z.message}`);throw new Error("HTMLObjectElement: SVG content not accessible (cross-origin or security error)")}throw new Error("HTMLObjectElement: SVG content not accessible (not loaded or cross-origin)");case S0.EMBED_ELEMENT:if(typeof $.getSVGDocument==="function"){let Z=$.getSVGDocument();if(Z&&Z.documentElement)return d0(new XMLSerializer().serializeToString(Z.documentElement))}throw new Error("HTMLEmbedElement: SVG content not accessible");case S0.IFRAME_ELEMENT:try{let Z=$.contentDocument;if(Z&&Z.documentElement){let K=Z.documentElement;if(K.tagName.toLowerCase()==="svg")return d0(new XMLSerializer().serializeToString(K))}}catch(Z){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${Z.message}`);throw new Error("HTMLIFrameElement: SVG content not accessible (cross-origin)")}throw new Error("HTMLIFrameElement: No SVG content found");default:throw new Error(`Unknown input type: ${J}`)}}function T6($,J,Z={}){switch(J){case W7.SVG_STRING:{let K=B7($,{minify:Z.minify!==!1});return bK(K)}case W7.DOM_ELEMENT:return $;case W7.XML_DOCUMENT:return $;default:{let K=B7($,{minify:Z.minify!==!1});return bK(K)}}}function j0($){return async function(J,Z={}){let K=A6(J),Q=await E6(J,K),H=Z.outputFormat||(K===S0.DOM_ELEMENT?W7.DOM_ELEMENT:W7.SVG_STRING),z=await $(Q,Z);return T6(z,H,Z)}}var e$=j0(($,J={})=>{let Z=J.minify!==!1,K=J.remove!==!1,Q=J.force||!1,H=J.preserve||[],z=J.preservePrefixes||[];if(!Q){let I=$.querySelectorAll("script").length>0,b=Array.from($.querySelectorAll("style")).some((u)=>u.textContent&&u.textContent.trim().length>0);if(I||b)return $}let q=(I)=>{if(H.includes(I))return!0;if(z.some((b)=>I.startsWith(b)))return!0;return!1},W=(I)=>{try{return decodeURI(I)}catch(b){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${b.message}`);return I}},j=_K($),G=new Set;for(let I of j.all)G.add(I),G.add(W(I));let F=new Map,_=(I)=>{let b=I.getAttribute("id");if(b){if(!F.has(b))F.set(b,I)}for(let u of I.children)if(a(u))_(u)};_($);let U=new Set,O=new Set,V=(I)=>{let b=I.getAttribute("id");if(b){if(U.has(b))O.add(b);U.add(b)}for(let u of I.children)if(a(u))V(u)};V($);let M=new Set,Y=new Map,X=0,w=()=>{let I;do I=`a${X++}`;while(G.has(I)&&!F.has(I));return I},R=(I)=>{let b=I.getAttribute("id");if(b){if(O.has(b)){if(M.has(b)){I.removeAttribute("id");return}M.add(b)}let u=W(b),m=G.has(b)||G.has(u);if(q(b));else if(!m&&K)I.removeAttribute("id");else if(Z&&m){let S=w();if(Y.set(b,S),u!==b)Y.set(u,S);I.setAttribute("id",S)}}for(let u of I.children)if(a(u))R(u)};if(R($),Z){let I=(m)=>{let S=(x)=>x.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");for(let x of m.getAttributeNames()){let h=m.getAttribute(x);if(h&&h.includes("url(#")){for(let[E,d]of Y){let c=S(E);h=h.replace(new RegExp(`url\\(#${c}\\)`,"g"),`url(#${d})`);let p=S(encodeURI(E));h=h.replace(new RegExp(`url\\(#${p}\\)`,"g"),`url(#${d})`)}m.setAttribute(x,h)}if((x==="href"||x==="xlink:href")&&h?.startsWith("#")){let E=h.substring(1),d=W(E);if(Y.has(E))m.setAttribute(x,`#${Y.get(E)}`);else if(Y.has(d))m.setAttribute(x,`#${Y.get(d)}`)}if((x==="begin"||x==="end")&&h){for(let[E,d]of Y){let c=S(E);h=h.replace(new RegExp(`^${c}\\.`,"g"),`${d}.`),h=h.replace(new RegExp(`;${c}\\.`,"g"),`;${d}.`)}m.setAttribute(x,h)}if((x==="values"||x==="from"||x==="to"||x==="by")&&h){for(let[E,d]of Y){let c=S(E);h=h.replace(new RegExp(`#${c}([;\\s]|$)`,"g"),`#${d}$1`)}m.setAttribute(x,h)}}for(let x of m.children)if(a(x))I(x)};I($);let b=(m)=>m.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),u=$.getElementsByTagName("style");for(let m of u){let S=m.textContent;if(!S)continue;for(let[x,h]of Y){let E=b(x);S=S.replace(new RegExp(`#${E}([^\\w-]|$)`,"g"),`#${h}$1`),S=S.replace(new RegExp(`url\\(#${E}\\)`,"g"),`url(#${h})`)}m.textContent=S}}return $}),e6=j0(($,J={})=>{let Z=J.precision||6,K=(H)=>{let z=parseFloat(H);if(isNaN(z))return H;let j=j8(z).toDecimalPlaces(Z).toString();if(j.includes("."))j=j.replace(/0+$/,""),j=j.replace(/\.$/,"");return j},Q=(H)=>{for(let z of H.getAttributeNames()){let q=H.getAttribute(z);if(z.match(/^(x|y|cx|cy|r|rx|ry|width|height|x1|y1|x2|y2|stroke-width|font-size)$/)){if(m7(q))continue;H.setAttribute(z,K(q))}if(z==="d"&&q){let W=q.replace(i$,(j)=>K(j));H.setAttribute("d",W)}if(z==="transform"&&q){let W=q.replace(i$,(j)=>K(j));H.setAttribute("transform",W)}if(z==="points"&&q){let W=q.replace(i$,(j)=>K(j));H.setAttribute("points",W)}}for(let z of H.children)if(a(z))Q(z)};return Q($),$}),_8=j0(($,J={})=>{let Z=J.precision||6,K=(H)=>{let z=parseFloat(H);if(isNaN(z))return H;let W=j8(z).toDecimalPlaces(Z).toString();if(W.includes("."))W=W.replace(/0+$/,""),W=W.replace(/\.$/,"");return W},Q=(H)=>{for(let z of["points"]){let q=H.getAttribute(z);if(q){let W=q.replace(i$,K);H.setAttribute(z,W)}}for(let z of H.children)if(a(z))Q(z)};return Q($),$}),U8=j0(($,J={})=>{let Z=["data-name","data-id","class"],K=["xmlns:serif"],Q=(H)=>{for(let z of Z)if(H.hasAttribute(z))H.removeAttribute(z);if(!J.preserveVendor){for(let z of K)if(H.hasAttribute(z))H.removeAttribute(z)}for(let z of H.children)if(a(z))Q(z)};return Q($),$}),V8=j0(($,J={})=>{let Z=(K)=>{if(K.hasAttribute("enable-background"))K.removeAttribute("enable-background");for(let Q of K.children)if(a(Q))Z(Q)};return Z($),$}),M8=j0(($,J={})=>{let Z=Array.from($.querySelectorAll("style")).some((Y)=>{let X=Y.textContent||"";return X.includes("@media")||X.includes(":hover")||X.includes(":focus")||X.includes(":active")||X.includes(":visited")||X.includes(":first-child")||X.includes(":last-child")||X.includes(":nth-child")||X.includes(":not(")}),K=$.querySelectorAll("script").length>0,Q=new Set,H=$.outerHTML||"",z=H.matchAll(/url\(#([^)]+)\)/g);for(let Y of z)Q.add(Y[1]);let q=H.matchAll(/xlink:href="#([^"]+)"/g);for(let Y of q)Q.add(Y[1]);let W=H.matchAll(/\shref="#([^"]+)"/g);for(let Y of W)Q.add(Y[1]);let j={clippath:"clipPath",textpath:"textPath",lineargradient:"linearGradient",radialgradient:"radialGradient",meshgradient:"meshGradient",hatchpath:"hatchPath",solidcolor:"solidColor",foreignobject:"foreignObject",feblend:"feBlend",fecolormatrix:"feColorMatrix",fecomponenttransfer:"feComponentTransfer",fecomposite:"feComposite",feconvolvematrix:"feConvolveMatrix",fediffuselighting:"feDiffuseLighting",fedisplacementmap:"feDisplacementMap",fedistantlight:"feDistantLight",fedropshadow:"feDropShadow",feflood:"feFlood",fefunca:"feFuncA",fefuncb:"feFuncB",fefuncg:"feFuncG",fefuncr:"feFuncR",fegaussianblur:"feGaussianBlur",feimage:"feImage",femerge:"feMerge",femergenode:"feMergeNode",femorphology:"feMorphology",feoffset:"feOffset",fepointlight:"fePointLight",fespecularlighting:"feSpecularLighting",fespotlight:"feSpotLight",fetile:"feTile",feturbulence:"feTurbulence",animatemotion:"animateMotion",animatetransform:"animateTransform"},G=(Y)=>j[Y]||Y,F=["svg","g","path","rect","circle","ellipse","line","polyline","polygon","text","tspan","tref","textPath","textpath","defs","clipPath","clippath","mask","pattern","linearGradient","lineargradient","radialGradient","radialgradient","meshGradient","meshgradient","meshrow","meshpatch","hatch","hatchpath","hatchPath","solidcolor","solidColor","stop","image","use","symbol","marker","title","desc","metadata","foreignObject","foreignobject","switch","a","filter","feBlend","feblend","feColorMatrix","fecolormatrix","feComponentTransfer","fecomponenttransfer","feComposite","fecomposite","feConvolveMatrix","feconvolvematrix","feDiffuseLighting","fediffuselighting","feDisplacementMap","fedisplacementmap","feDistantLight","fedistantlight","feDropShadow","fedropshadow","feFlood","feflood","feFuncA","fefunca","feFuncB","fefuncb","feFuncG","fefuncg","feFuncR","fefuncr","feGaussianBlur","fegaussianblur","feImage","feimage","feMerge","femerge","feMergeNode","femergenode","feMorphology","femorphology","feOffset","feoffset","fePointLight","fepointlight","feSpecularLighting","fespecularlighting","feSpotLight","fespotlight","feTile","fetile","feTurbulence","feturbulence","animate","animateMotion","animatemotion","animateTransform","animatetransform","set","mpath","view","cursor","style","script","font","font-face","font-face-src","font-face-uri","font-face-format","font-face-name","glyph","missing-glyph","hkern","vkern"],_={fill:"#000","fill-opacity":"1","fill-rule":"nonzero",stroke:"none","stroke-width":"1","stroke-opacity":"1","stroke-linecap":"butt","stroke-linejoin":"miter","stroke-miterlimit":"4","stroke-dasharray":"none","stroke-dashoffset":"0",opacity:"1",visibility:"visible",display:"inline",clip:"auto","clip-path":"none","clip-rule":"nonzero",mask:"none","marker-start":"none","marker-mid":"none","marker-end":"none","stop-color":"#000","stop-opacity":"1","flood-color":"#000","flood-opacity":"1","lighting-color":"#fff","color-interpolation":"sRGB","color-interpolation-filters":"linearRGB","color-rendering":"auto","shape-rendering":"auto","text-rendering":"auto","image-rendering":"auto","paint-order":"normal","vector-effect":"none","text-anchor":"start","text-overflow":"clip","text-decoration":"none","dominant-baseline":"auto","alignment-baseline":"baseline","baseline-shift":"baseline","writing-mode":"lr-tb",direction:"ltr","unicode-bidi":"normal","letter-spacing":"normal","word-spacing":"normal","font-style":"normal","font-variant":"normal","font-weight":"normal","font-stretch":"normal","font-size":"medium","font-size-adjust":"none"},U={circle:{cx:"0",cy:"0"},ellipse:{cx:"0",cy:"0"},line:{x1:"0",y1:"0",x2:"0",y2:"0"},rect:{x:"0",y:"0",rx:"0",ry:"0"},image:{x:"0",y:"0",preserveAspectRatio:"xMidYMid meet"},svg:{x:"0",y:"0",preserveAspectRatio:"xMidYMid meet"},symbol:{preserveAspectRatio:"xMidYMid meet"},marker:{markerUnits:"strokeWidth",refX:"0",refY:"0",markerWidth:"3",markerHeight:"3"},linearGradient:{x1:"0",y1:"0",x2:"100%",y2:"0",spreadMethod:"pad"},radialGradient:{cx:"50%",cy:"50%",r:"50%",fx:"50%",fy:"50%",spreadMethod:"pad"},pattern:{x:"0",y:"0",patternUnits:"objectBoundingBox",patternContentUnits:"userSpaceOnUse"},clipPath:{clipPathUnits:"userSpaceOnUse"},mask:{maskUnits:"objectBoundingBox",maskContentUnits:"userSpaceOnUse",x:"-10%",y:"-10%",width:"120%",height:"120%"},filter:{primitiveUnits:"userSpaceOnUse",x:"-10%",y:"-10%",width:"120%",height:"120%"},feBlend:{mode:"normal"},feColorMatrix:{type:"matrix"},feComposite:{operator:"over",k1:"0",k2:"0",k3:"0",k4:"0"},feTurbulence:{baseFrequency:"0",numOctaves:"1",seed:"0",stitchTiles:"noStitch",type:"turbulence"},feDisplacementMap:{scale:"0",xChannelSelector:"A",yChannelSelector:"A"},feDistantLight:{azimuth:"0",elevation:"0"},fePointLight:{x:"0",y:"0",z:"0"},a:{target:"_self"},textPath:{startOffset:"0"}},O=(Y)=>{if(Y.startsWith("data-"))return!0;if(Y.startsWith("aria-"))return!0;if(Y==="role")return!0;if(Y==="xmlns")return!0;if(Y.includes(":")&&!Y.startsWith("xml:")&&!Y.startsWith("xlink:"))return!0;return!1},V=(Y,X)=>{let w=Y.parentNode;while(w&&a(w)){let R=w.getAttribute(X);if(R!==null)return R;w=w.parentNode}return null},M=(Y,X={})=>{if(Y.tagName==="foreignObject")return;if(Y.tagName.includes(":"))return;if(!Y.getAttribute("id")){for(let[u,m]of Object.entries(_))if(!O(u)&&Y.getAttribute(u)===m)Y.removeAttribute(u);let b=U[Y.tagName.toLowerCase()]||{};for(let[u,m]of Object.entries(b))if(!O(u)&&Y.getAttribute(u)===m)Y.removeAttribute(u);if(!Z){for(let u of Y.getAttributeNames())if(q6.has(u)&&!O(u)){let m=Y.getAttribute(u),S=V(Y,u);if(S!==null&&m===S)Y.removeAttribute(u)}}}let w={...X};for(let b of q6){let u=Y.getAttribute(b);if(u!==null)w[b]=u}let R=Y.tagName.toLowerCase(),I=s6[R]||s6[G(R)];for(let b of[...Y.children])if(a(b)){if(b.tagName.includes(":"))continue;let u=b.tagName.toLowerCase(),m=b.getAttribute("id"),S=K&&m,x=(h)=>{let E=h.getAttribute("id");if(E&&Q.has(E))return!0;for(let d of h.children||[])if(a(d)&&x(d))return!0;return!1};if(!F.includes(u)){if(!x(b)&&!S){Y.removeChild(b);continue}}if(I&&!I.has(u)&&!I.has(G(u))){if(!x(b)&&!S){Y.removeChild(b);continue}}M(b,w)}};return M($,{}),$}),O8=j0(($,J={})=>{let Z=["x","y","width","height","viewBox"],K=(Q)=>{if(Q.tagName==="g"){for(let H of Z)if(Q.hasAttribute(H))Q.removeAttribute(H)}for(let H of Q.children)if(a(H))K(H)};return K($),$}),Y8=j0(($,J={})=>{let Z=$.getElementsByTagName("defs");for(let K of[...Z])if(K.children.length===0){if(K.parentNode)K.parentNode.removeChild(K)}return $}),$$=j0(($,J={})=>{let Z=J.force||!1,K=$.querySelectorAll("script").length>0,Q=new Set,H=(G)=>{for(let F of G.getAttributeNames()){let _=G.getAttribute(F);if(_&&_.includes("url(#")){let U=_.matchAll(/url\(#([^)]+)\)/g);for(let O of U)Q.add(O[1])}if((F==="href"||F==="xlink:href")&&_&&_.startsWith("#"))Q.add(_.substring(1))}for(let F of G.children)if(a(F))H(F)};H($);let z=(G)=>{let F=G.getAttribute("href")||G.getAttribute("xlink:href");if(F&&F.startsWith("#"))return!0;for(let _ of G.getAttributeNames?G.getAttributeNames():[]){let U=G.getAttribute(_);if(U&&U.includes("url(#"))return!0}return!1},q=(G)=>{for(let F of G.children){if(!a(F))continue;let _=F.tagName?.toLowerCase();if(n6.animation.has(_))return!0;if(q(F))return!0}return!1},W=(G)=>{let F=G.getAttribute("id");if(F&&(Q.has(F)||K))return!0;for(let _ of G.children){if(!a(_))continue;if(W(_))return!0}return!1},j=(G,F=!1)=>{let _=G.tagName.toLowerCase(),U=F||_==="defs",O=G.getAttribute("display"),V=G.getAttribute("visibility"),M=parseFloat(G.getAttribute("opacity")||"1");if(O==="none"||V==="hidden"||M===0){if(!Z&&W(G));else if(!Z&&_==="marker");else if(!Z&&(G.getAttribute("marker-start")||G.getAttribute("marker-mid")||G.getAttribute("marker-end")));else if(!Z&&U&&n6.nonRendering.has(_));else if(!Z&&n6.animation.has(_));else if(!Z&&q(G));else if(!Z&&_==="use");else if(!Z&&z(G));else if(G.parentNode){G.parentNode.removeChild(G);return}}for(let X of[...G.children])if(a(X))j(X,U)};return j($),$}),X8=j0(($,J={})=>{let Z=$.getElementsByTagName("text"),K=(z)=>{let q=z.textContent||"";if(z.children)for(let W of z.children)q+=K(W);return q},Q=(z,q)=>{if(!q||q.length===0)return!1;return(z.getAttributeNames?z.getAttributeNames():[]).some((j)=>q.some((G)=>j.startsWith(G+":")))},H=J.preserveNamespaces||[];for(let z of[...Z]){let q=K(z),W=!q||q.trim()==="",j=Q(z,H);if(W&&!j){if(z.parentNode)z.parentNode.removeChild(z)}}return $}),J$=j0(($,J={})=>{let Z=["g","defs","symbol","marker","clipPath","clippath","mask","pattern"],K=$.querySelectorAll("script").length>0,Q=new Set,H=(q)=>{for(let W of q.getAttributeNames?q.getAttributeNames():[]){let j=q.getAttribute(W);if(j&&j.includes("url(#")){let G=j.matchAll(/url\(#([^)]+)\)/g);for(let F of G)Q.add(F[1])}if((W==="href"||W==="xlink:href")&&j&&j.startsWith("#"))Q.add(j.substring(1))}for(let W of q.children||[])if(a(W))H(W)};H($);let z=(q)=>{for(let G of[...q.children])if(a(G))z(G);let W=q.tagName?.toLowerCase();if(!Z.includes(q.tagName)&&!Z.includes(W))return;if(q.getAttribute("href")||q.getAttribute("xlink:href"))return;let j=q.getAttribute("id");if(j&&(Q.has(j)||K))return;if(q.children.length===0){if(q.parentNode)q.parentNode.removeChild(q)}};return z($),$}),k8=j0(($,J={})=>{return $}),L8=j0(($,J={})=>{return $}),K$=j0(($,J={})=>{return $}),Z$=j0(($,J={})=>{if(J.preserveVendor)return $;let Z=$.getElementsByTagName("metadata");for(let K of[...Z])if(K.parentNode)K.parentNode.removeChild(K);return $}),w8=j0(($,J={})=>{let Z=$.getElementsByTagName("title");for(let K of[...Z])if(K.parentNode)K.parentNode.removeChild(K);return $}),R8=j0(($,J={})=>{let Z=$.getElementsByTagName("desc");for(let K of[...Z])if(K.parentNode)K.parentNode.removeChild(K);return $}),$9=j0(($,J={})=>{if(J.preserveVendor===!0)return $;let Z=J.preserveNamespaces||[],K=new Set(Z);if(K.has("sodipodi"))K.add("inkscape");if(K.has("inkscape"))K.add("sodipodi");let Q=["inkscape","sodipodi","illustrator","sketch","ai","serif","vectornator","figma"].filter((j)=>!K.has(j));if(Q.length===0)return $;let H=(j)=>{for(let G of[...j.children])if(a(G)){let F=G.tagName.indexOf(":");if(F>0){let _=G.tagName.substring(0,F);if(Q.includes(_)){j.removeChild(G);continue}}H(G)}};H($);let z=(j)=>{for(let G of[...j.getAttributeNames()]){if(G.startsWith("xmlns:"))continue;let F=G.indexOf(":");if(F>0){let _=G.substring(0,F);if(Q.includes(_))j.removeAttribute(G)}}for(let G of j.children)if(a(G))z(G)};z($);let q=new Set,W=(j)=>{for(let F of j.getAttributeNames()){if(F.startsWith("xmlns:"))continue;let _=F.indexOf(":");if(_>0){let U=F.substring(0,_);q.add(U)}}let G=j.tagName.indexOf(":");if(G>0)q.add(j.tagName.substring(0,G));for(let F of j.children)if(a(F))W(F)};W($);for(let j of Q){let G=`xmlns:${j}`;if($.hasAttribute(G)&&!q.has(j))$.removeAttribute(G)}return $}),B8=j0(($,J={})=>{let Z=(K)=>{for(let Q of[...K.getAttributeNames()]){let H=K.getAttribute(Q);if(H===""||H===null)K.removeAttribute(Q)}for(let Q of K.children)if(a(Q))Z(Q)};return Z($),$}),N8=j0(($,J={})=>{let Z=$.getAttribute("width"),K=$.getAttribute("height"),Q=$.getAttribute("viewBox");if(m7(Z)||m7(K))return $;if(Z&&K&&Q){let H=Q.split(/[\s,]+/).map(parseFloat),z=parseFloat(Z),q=parseFloat(K);if(isNaN(z)||isNaN(q)||H.some((j)=>isNaN(j)))return $;let W=0.000001;if(H.length===4&&Math.abs(H[0])<W&&Math.abs(H[1])<W&&Math.abs(H[2]-z)<W&&Math.abs(H[3]-q)<W)$.removeAttribute("viewBox")}return $}),I8=j0(($,J={})=>{let Z=J.preserveSvgNamespace!==!1,K=J.removeXlinkNamespace!==!1;if(J.preserveVendor){if(!Z)$.removeAttribute("xmlns");return $}if(!Z)$.removeAttribute("xmlns");if(K){let Q=!1,H=(z)=>{for(let q of z.getAttributeNames())if(q.startsWith("xlink:")){Q=!0;return}for(let q of z.children){if(a(q))H(q);if(Q)return}};if(H($),!Q)$.removeAttribute("xmlns:xlink")}return $.removeAttribute("xmlns:svg"),$}),C8=j0(($,J={})=>{let Z=$.querySelectorAll("script").length>0,K=new Set,Q=(z)=>{for(let q of z.getAttributeNames()){let W=z.getAttribute(q);if(W&&W.includes("url(#")){let j=W.matchAll(/url\(#([^)]+)\)/g);for(let G of j)K.add(G[1])}if((q==="href"||q==="xlink:href")&&W&&W.startsWith("#"))K.add(W.substring(1))}for(let q of z.children)if(a(q))Q(q)};Q($);let H=$.getElementsByTagName("image");for(let z of[...H]){let q=z.getAttribute("id");if(q&&(K.has(q)||Z))continue;if(z.parentNode)z.parentNode.removeChild(z)}return $}),P8=j0(($,J={})=>{let Z=new Set,K=(H)=>{for(let z of H.getAttributeNames()){let q=H.getAttribute(z);if(q&&q.includes("url(#")){let W=q.matchAll(/url\(#([^)]+)\)/g);for(let j of W)Z.add(j[1])}if((z==="href"||z==="xlink:href")&&q&&q.startsWith("#"))Z.add(q.substring(1))}for(let z of H.children)if(a(z))K(z)};K($);let Q=$.getElementsByTagName("script");for(let H of[...Q]){let z=H.getAttribute("id");if(!z||!Z.has(z)){if(H.parentNode)H.parentNode.removeChild(H)}}return $}),A8=j0(($,J={})=>{let Z=J.precision||6,K=J.convertRoundedRects||!1,Q=["rect","circle","ellipse","line","polyline","polygon"],H=(z)=>{if(Q.includes(z.tagName)){if(z.tagName==="rect"){let W=parseFloat(z.getAttribute("x")||"0"),j=parseFloat(z.getAttribute("y")||"0"),G=parseFloat(z.getAttribute("width")||"0"),F=parseFloat(z.getAttribute("height")||"0");if(isNaN(W)||isNaN(j)||isNaN(G)||isNaN(F)){for(let _ of[...z.children])if(a(_))H(_);return}}if(z.tagName==="rect"&&!K){let W=parseFloat(z.getAttribute("rx")||"0"),j=parseFloat(z.getAttribute("ry")||"0");if(isNaN(W)||isNaN(j)||W>0||j>0){for(let G of[...z.children])if(a(G))H(G);return}}if(z.tagName==="polyline"||z.tagName==="polygon"){if((z.getAttribute("points")||"").trim().split(/[\s,]+/).length<4){for(let G of[...z.children])if(a(G))H(G);return}}let q=H5(z,Z);if(q){let W=new B0("path",{d:q});for(let j of z.getAttributeNames())if(!j.match(/^(x|y|cx|cy|r|rx|ry|width|height|x1|y1|x2|y2|points)$/)){let G=z.getAttribute(j);if(G!==null)W.setAttribute(j,G)}for(let j of[...z.children])W.appendChild(j);if(z.parentNode)z.parentNode.replaceChild(W,z)}}for(let q of[...z.children])if(a(q))H(q)};return H($),$}),E8=j0(($,J={})=>{let Z=J.precision||6,K=J.force||!1,Q=new Set,H=(q)=>{for(let W of["href","xlink:href"]){let j=q.getAttribute(W);if(j&&j.startsWith("#"))Q.add(j.substring(1))}for(let W of q.children)if(a(W))H(W)};H($);let z=$.getElementsByTagName("path");for(let q of z){let W=q.getAttribute("d");if(!W)continue;let j=q.getAttribute("id");if(!K&&j&&Q.has(j))continue;if(!K&&q.getAttribute("style"))continue;let G=q.getAttribute("stroke-linecap"),F=G&&G!=="butt";if((W.match(/[MmLlHhVvCcSsQqTtAaZz]/g)||[]).length<=1)continue;if(!K&&q.getAttribute("marker-mid"))continue;let U=Q5(W);q.setAttribute("d",U)}return $}),T8=j0(($,J={})=>{let Z=J.precision||6,K=J.force||!1,Q=(H)=>{let z=H.getAttribute("transform");if(z){let q=$7(z),W=V5(q,Z);if(!K&&W.length>=z.length);else if(!K&&H.getAttribute("stroke")&&H.getAttribute("stroke")!=="none"){let j=q.data[0][0].toNumber(),G=q.data[0][1].toNumber(),F=q.data[1][0].toNumber(),_=q.data[1][1].toNumber(),U=j*_-G*F,O=Math.abs(j-_)<0.000001&&Math.abs(G+F)<0.000001,V=0.0000000001;if(!O&&Math.abs(U)>0.0000000001);else H.setAttribute("transform",W)}else H.setAttribute("transform",W)}for(let q of H.children)if(a(q))Q(q)};return Q($),$}),Q$=j0(($,J={})=>{let Z=["fill","stroke","stop-color","flood-color","lighting-color"],K=(H)=>{if(!H||typeof H!=="string")return H;let z={white:"#fff",black:"#000",red:"#f00",green:"#0f0",blue:"#00f",yellow:"#ff0",cyan:"#0ff",magenta:"#f0f"};if(z[H.toLowerCase()])return z[H.toLowerCase()];let q=H.match(/^#([0-9a-f]{6})$/i);if(q){let W=q[1];if(W[0]===W[1]&&W[2]===W[3]&&W[4]===W[5])return`#${W[0]}${W[2]}${W[4]}`}return H},Q=(H)=>{for(let z of Z){let q=H.getAttribute(z);if(q)H.setAttribute(z,K(q))}for(let z of H.children)if(a(z))Q(z)};return Q($),$}),J9=j0(($,J={})=>{let Z=J.preserveVendor||!1,K=new Set(["alignment-baseline","baseline-shift","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cursor","direction","display","dominant-baseline","enable-background","fill","fill-opacity","fill-rule","filter","flood-color","flood-opacity","font","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","glyph-orientation-horizontal","glyph-orientation-vertical","image-rendering","kerning","letter-spacing","lighting-color","marker","marker-end","marker-mid","marker-start","mask","opacity","overflow","pointer-events","shape-rendering","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-anchor","text-decoration","text-rendering","transform","transform-origin","unicode-bidi","vector-effect","visibility","word-spacing","writing-mode"]),Q=(H)=>{let z=H.getAttribute("style");if(z){let q=z.split(";").map((j)=>j.trim()).filter((j)=>j),W=[];for(let j of q){let G=j.indexOf(":");if(G===-1)continue;let F=j.substring(0,G).trim(),_=j.substring(G+1).trim();if(F&&_){if(!F.startsWith("-")&&K.has(F))H.setAttribute(F,_);else if(Z&&F.startsWith("-"))W.push(j)}}if(W.length>0)H.setAttribute("style",W.join("; "));else H.removeAttribute("style")}for(let q of H.children)if(a(q))Q(q)};return Q($),$}),b8=j0(($,J={})=>{let Z=$.getElementsByTagName("ellipse");for(let K of[...Z]){let Q=parseFloat(K.getAttribute("rx")||"0"),H=parseFloat(K.getAttribute("ry")||"0");if(isNaN(Q)||isNaN(H))continue;if(Math.abs(Q-H)<0.001){let z=new B0("circle",{});for(let q of K.getAttributeNames()){let W=K.getAttribute(q);if(q==="rx"||q==="ry")z.setAttribute("r",W);else z.setAttribute(q,W)}for(let q of[...K.children])z.appendChild(q);if(K.parentNode)K.parentNode.replaceChild(z,K)}}return $}),f8=j0(($,J={})=>{let Z=J.force||!1,K=(Q,H=!1,z=!1)=>{let q=Q.tagName.toLowerCase(),W=z||q==="switch";for(let j of[...Q.children])if(a(j))K(j,!1,W);if(q!=="g")return;if(!Z&&(H||W))return;if(!Z&&Q.getAttribute("filter"))return;if(Q.children.length===1){let j=Q.children[0];if(!a(j))return;if(!Z&&j.getAttribute("id"))return;let G=Array.from(Q.children).some((U)=>a(U)&&n6.animation.has(U.tagName.toLowerCase()));if(!Z&&G)return;let F=Q.getAttributeNames(),_=F.some((U)=>{if(q6.has(U))return!1;return j.hasAttribute(U)});if(!Z&&_)return;if(F.length===0){if(Q.parentNode)Q.parentNode.replaceChild(j,Q)}else{let U=!0;for(let O of F){if(!q6.has(O)&&O!=="class"&&O!=="style"){U=!1;break}if(j.hasAttribute(O)){U=!1;break}}if(U&&Q.parentNode){for(let O of F){let V=Q.getAttribute(O);if(V!==null)j.setAttribute(O,V)}Q.parentNode.replaceChild(j,Q)}}}};return K($,!0),$}),S8=j0(($,J={})=>{let Z=J.force||!1,K=(H)=>H&&H.includes("url("),Q=(H)=>{let z=[...H.children].filter((q)=>a(q)&&q.tagName==="path");for(let q=0;q<z.length-1;q++){let W=z[q],j=z[q+1];if(!Z&&(W.children.length>0||j.children.length>0))continue;let F=["marker-start","marker-mid","marker-end"].some((O)=>W.getAttribute(O)||j.getAttribute(O));if(!Z&&F)continue;if(!Z&&(W.getAttribute("clip-path")||W.getAttribute("mask")||j.getAttribute("clip-path")||j.getAttribute("mask")))continue;if(!Z){let O=W.getAttribute("fill"),V=W.getAttribute("stroke"),M=j.getAttribute("fill"),Y=j.getAttribute("stroke");if(K(O)||K(V)||K(M)||K(Y))continue}if(!Z){let O=W.getAttribute("fill-rule")||"nonzero",V=j.getAttribute("fill-rule")||"nonzero";if(O!==V)continue}if(!Z&&(W.getAttribute("filter")||j.getAttribute("filter")))continue;let _=W.getAttributeNames().filter((O)=>O!=="d").sort(),U=j.getAttributeNames().filter((O)=>O!=="d").sort();if(JSON.stringify(_)===JSON.stringify(U)){let O=!0;for(let V of _)if(W.getAttribute(V)!==j.getAttribute(V)){O=!1;break}if(O){let V=W.getAttribute("d"),M=j.getAttribute("d");if(W.setAttribute("d",`${V} ${M}`),j.parentNode)j.parentNode.removeChild(j);z.splice(q+1,1),q--}}}for(let q of H.children)if(a(q))Q(q)};return Q($),$}),v8=j0(($,J={})=>{let Z=(K)=>{if(K.tagName==="g")for(let Q of[...K.getAttributeNames()]){if(!q6.has(Q))continue;let H=K.getAttribute(Q);if(H){for(let z of K.children)if(a(z)&&!z.hasAttribute(Q))z.setAttribute(Q,H);K.removeAttribute(Q)}}for(let Q of K.children)if(a(Q))Z(Q)};return Z($),$}),D8=j0(($,J={})=>{let Z=(K)=>{if(K.tagName==="g"&&K.children.length>1)for(let Q of q6){let H=null,z=!0;for(let q of K.children){if(!a(q))continue;let W=q.getAttribute(Q);if(!W){z=!1;break}if(H===null)H=W;else if(H!==W){z=!1;break}}if(z&&H){K.setAttribute(Q,H);for(let q of K.children)if(a(q))q.removeAttribute(Q)}}for(let Q of K.children)if(a(Q))Z(Q)};return Z($),$}),K9=j0(($,J={})=>{if($.getElementsByTagName("script").length>0&&!J.force)return $;let K=$.getElementsByTagName("style");for(let Q of K){let H=Q.textContent;if(!H||!H.trim())continue;let z=H.includes("<![CDATA[")||H.includes("]]>"),q="",W="";if(z){let j=H.match(/^(\s*<!\[CDATA\[\s*)/),G=H.match(/(\s*\]\]>\s*)$/);if(j)q="<![CDATA[",H=H.replace(/^\s*<!\[CDATA\[\s*/,"");if(G)W="]]>",H=H.replace(/\s*\]\]>\s*$/,"")}if(H=H.replace(/\/\*[\s\S]*?\*\//g,""),H=H.replace(/\s+/g," "),H=H.replace(/\s*([{}:;,])\s*/g,"$1"),H=H.trim(),q||W)H=q+H+W;Q.textContent=H}return $}),h8=j0(($,J={})=>{let Z=J.onlyMatchedOnce!==!1,K=J.removeStyleElement!==!1,Q=$.getElementsByTagName("style"),H=[];for(let z of Q){let q=z.getAttribute("type");if(q&&q!=="text/css")continue;let W=z.textContent;if(!W||!W.trim())continue;if(W.includes("@media")||W.includes("@keyframes")||W.includes("@supports")||W.includes("@font-face"))continue;let j=W.match(/([^{]+)\{([^}]+)\}/g)||[],G=[];for(let U of j){let O=U.match(/([^{]+)\{([^}]+)\}/);if(!O)continue;let V=O[1].trim(),M=O[2].trim(),Y=!1;for(let w of LK.preventInlining)if(V.includes(w)){Y=!0;break}if(Y){H.push(U);continue}let X;try{X=Y$(V)}catch(w){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${w.message}`);H.push(U);continue}G.push({selector:V,declarations:M,specificity:X,originalRule:U})}G.sort((U,O)=>X$(U.specificity,O.specificity));let F=new WeakMap,_=new Set;for(let{selector:U,declarations:O,specificity:V,originalRule:M}of G)try{let Y=$.querySelectorAll(U);if(Z&&U.startsWith("#")&&Y.length>1){H.push(M);continue}for(let X of Y){let w=X,R=!1;while(w){if(w.tagName==="foreignObject"){R=!0;break}w=w.parentNode}if(R)continue;if(!F.has(X))F.set(X,new Map),_.add(X);let I=F.get(X),b=X.getAttribute("style")||"";if(b&&I.size===0){let m=b.split(";");for(let S of m){let x=S.indexOf(":");if(x>0){let h=S.substring(0,x).trim(),E=S.substring(x+1).trim(),d=E.includes("!important");if(d)E=E.replace(/\s*!important\s*/g,"").trim();I.set(h,{specificity:[1,0,0,0],isImportant:d,value:E})}}}let u=O.split(";");for(let m of u){let S=m.indexOf(":");if(S<=0)continue;let x=m.substring(0,S).trim(),h=m.substring(S+1).trim(),E=h.includes("!important");if(E)h=h.replace(/\s*!important\s*/g,"").trim();let d=I.get(x);if(d){let c=X$(V,d.specificity);if(c<0){if(E&&!d.isImportant)I.set(x,{specificity:V,isImportant:E,value:h})}else if(c===0){if(E||!d.isImportant)I.set(x,{specificity:V,isImportant:E,value:h})}else if(!d.isImportant||E)I.set(x,{specificity:V,isImportant:E,value:h})}else I.set(x,{specificity:V,isImportant:E,value:h})}}}catch(Y){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${Y.message}`);H.push(M)}for(let U of _){let O=F.get(U),V=[];for(let[M,{value:Y,isImportant:X}]of O)if(X)V.push(`${M}: ${Y} !important`);else V.push(`${M}: ${Y}`);U.setAttribute("style",V.join("; "))}if(K&&z.parentNode)if(H.length>0)z.textContent=H.join(`
20
- `);else z.parentNode.removeChild(z)}return $}),y8=j0(($,J={})=>{let Z=(K)=>{let Q=K.getAttributeNames().sort(),H=Q.map((z)=>[z,K.getAttribute(z)]);for(let z of Q)K.removeAttribute(z);for(let[z,q]of H)K.setAttribute(z,q);for(let z of K.children)if(a(z))Z(z)};return Z($),$}),u8=j0(($,J={})=>{let Z=$.getElementsByTagName("defs");for(let K of Z){let Q=[...K.children].filter((H)=>a(H));Q.sort((H,z)=>H.tagName.localeCompare(z.tagName));for(let H of[...K.children])K.removeChild(H);for(let H of Q)K.appendChild(H)}return $}),g8=j0(($,J={})=>{let Z=J.threshold||2,K=$.getElementsByTagName("path"),Q=new Map;for(let q of K){let W=q.getAttribute("d");if(W){if(!Q.has(W))Q.set(W,[]);Q.get(W).push(q)}}let H=$.querySelector("defs");if(!H)if(H=new B0("defs",{}),$.firstChild)$.insertBefore(H,$.firstChild);else $.appendChild(H);let z=0;for(let[q,W]of Q)if(W.length>=Z){let j=`path${z++}`,G=new B0("path",{id:j,d:q});H.appendChild(G);for(let F of W){let _=new B0("use",{href:`#${j}`});for(let U of F.getAttributeNames())if(U!=="d"){let O=F.getAttribute(U);if(O!==null)_.setAttribute(U,O)}for(let U of[...F.children])_.appendChild(U);if(F.parentNode)F.parentNode.replaceChild(_,F)}}return $}),x8=j0(($,J={})=>{let Z=$.getAttribute("viewBox");if(!Z)return $;let K=$5(Z);if(!K)return $;let Q=i7($),H=$.getElementsByTagName("path");for(let z of[...H]){let q=z.getAttribute("d");if(!q)continue;try{let W=y6(q),j=J5(W);if(!j)continue;let G=m6(z),_=x6(z,G,Q).getRenderedBBox(j),U={x:_.x,y:_.y,width:_.width,height:_.height};if(!K5(U,K)){if(z.parentNode)z.parentNode.removeChild(z)}}catch(W){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${W.message}`)}}return $}),m8=j0(($,J={})=>{let Z=$.getElementsByTagName("style");for(let K of[...Z])if(K.parentNode)K.parentNode.removeChild(K);return $}),d8=j0(($,J={})=>{let Z={new:"_blank",replace:"_self"},K=!1,Q=(H)=>{for(let z of[...H.getAttributeNames()])if(z.startsWith("xlink:")){let q=z.substring(6),W=H.getAttribute(z);if(q==="href")K=!0;else if(q==="show"){if(!H.hasAttribute("target")){let j=Z[W];if(j)H.setAttribute("target",j)}H.removeAttribute(z)}else if(q==="title"){if(!(H.querySelector&&H.querySelector("title"))&&W){let G=new B0("title",{},[],W);if(typeof H.insertBefore==="function"&&H.firstChild)H.insertBefore(G,H.firstChild);else if(typeof H.appendChild==="function")H.appendChild(G);else if(H.children&&Array.isArray(H.children))H.children.unshift(G),G.parentNode=H}H.removeAttribute(z)}else if(["actuate","type","role","arcrole"].includes(q))H.removeAttribute(z);else K=!0}for(let z of H.children)if(a(z))Q(z)};if(Q($),!K)$.removeAttribute("xmlns:xlink");return $}),p8=j0(($,J={})=>{let Z=J.attributes||{};for(let[K,Q]of Object.entries(Z))$.setAttribute(K,Q);return $}),c8=j0(($,J={})=>{let Z=J.classes||[],K=$.getAttribute("class")||"",Q=K?`${K} ${Z.join(" ")}`:Z.join(" ");return $.setAttribute("class",Q.trim()),$}),l8=j0(($,J={})=>{let Z=J.prefix||"svg",K=new Map,Q=new Map,H=(j)=>j.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),z=(j)=>{let G=j.getAttribute("id");if(G){let F=`${Z}${G}`;K.set(G,F),j.setAttribute("id",F)}for(let F of j.children)if(a(F))z(F)};if(z($),J.prefixClassNames!==!1){let j=(F)=>{let _=F.getAttribute("class");if(_){for(let U of _.split(/\s+/))if(U&&!Q.has(U))Q.set(U,`${Z}${U}`)}for(let U of F.children)if(a(U))j(U)};j($);let G=(F)=>{let _=F.getAttribute("class");if(_){let U=_.split(/\s+/).map((O)=>Q.get(O)||O).join(" ");F.setAttribute("class",U)}for(let U of F.children)if(a(U))G(U)};G($)}let q=$.getElementsByTagName("style");for(let j of q){let G=j.textContent;if(!G)continue;for(let[F,_]of K){let U=H(F);G=G.replace(new RegExp(`#${U}([^\\w-]|$)`,"g"),`#${_}$1`),G=G.replace(new RegExp(`url\\(#${U}\\)`,"g"),`url(#${_})`)}if(J.prefixClassNames!==!1)for(let[F,_]of Q){let U=H(F);G=G.replace(new RegExp(`\\.${U}([^\\w-]|$)`,"g"),`.${_}$1`)}j.textContent=G}let W=(j)=>{for(let G of j.getAttributeNames()){let F=j.getAttribute(G);if(F&&F.includes("url(#")){for(let[_,U]of K){let O=H(_);F=F.replace(new RegExp(`url\\(#${O}\\)`,"g"),`url(#${U})`)}j.setAttribute(G,F)}if((G==="href"||G==="xlink:href")&&F?.startsWith("#")){let _=F.substring(1);if(K.has(_))j.setAttribute(G,`#${K.get(_)}`)}if(G==="begin"||G==="end"){for(let[_,U]of K){let O=H(_);F=F.replace(new RegExp(`(^|;|\\s)${O}\\.`,"g"),`$1${U}.`)}j.setAttribute(G,F)}if(G==="values"||G==="from"||G==="to"||G==="by"){for(let[_,U]of K){let O=H(_);F=F.replace(new RegExp(`#${O}([;\\s]|$)`,"g"),`#${U}$1`)}j.setAttribute(G,F)}}for(let G of j.children)if(a(G))W(G)};return W($),$}),n8=j0(($,J={})=>{return $.removeAttribute("width"),$.removeAttribute("height"),$}),s8=j0(($,J={})=>{let Z=J.selector||"*",K=J.attributes||[];try{let Q=$.querySelectorAll(Z);for(let H of Q)for(let z of K)if(H.hasAttribute(z))H.removeAttribute(z)}catch(Q){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${Q.message}`)}return $}),o8=j0(($,J={})=>{let Z=J.pattern?new RegExp(J.pattern):null,K=J.attrs||[],Q=(H)=>{for(let z of[...H.getAttributeNames()])if(K.includes(z)||Z&&Z.test(z))H.removeAttribute(z);for(let z of H.children)if(a(z))Q(z)};return Q($),$}),i8=j0(($,J={})=>{let{name:Z,value:K}=J;if(!Z)return $;let Q=(H)=>{for(let z of[...H.children]){if(!a(z))continue;let q=z.getAttribute(Z);if(K===void 0){if(q!==null){H.removeChild(z);continue}}else if(q===K){H.removeChild(z);continue}Q(z)}};return Q($),$}),Z9=j0(async($,J={})=>{let Z={...J,outputFormat:W7.DOM_ELEMENT},K=$;return K=await Z$(K,Z),K=await K$(K,Z),K=await J$(K,Z),K=await $$(K,Z),K=await e6(K,Z),K=await Q$(K,Z),K=await J9(K,Z),K=await $9(K,Z),K=await e$(K,Z),K=await K9(K,Z),K}),Q9=j0(($,J={})=>{return $}),r8=j0(async($,J={})=>{let Z=J.preset||"default",K={...J,outputFormat:W7.DOM_ELEMENT};switch(Z){case"default":return await Z9($,K);case"none":return await Q9($,K);default:return $}}),a8=j0(async($,J={})=>{let Z=J.config||{},K={...J,outputFormat:W7.DOM_ELEMENT},Q=$;if(Z.removeMetadata!==!1)Q=await Z$(Q,K);if(Z.removeComments!==!1)Q=await K$(Q,K);if(Z.cleanupNumericValues!==!1)Q=await e6(Q,K);if(Z.convertColors!==!1)Q=await Q$(Q,K);if(Z.removeHiddenElements!==!1)Q=await $$(Q,K);if(Z.removeEmptyContainers!==!1)Q=await J$(Q,K);return Q});function t8($={}){return{precision:$.precision||6,removeMetadata:$.removeMetadata!==!1,removeComments:$.removeComments!==!1,cleanupNumericValues:$.cleanupNumericValues!==!1,convertColors:$.convertColors!==!1,removeHiddenElements:$.removeHiddenElements!==!1,removeEmptyContainers:$.removeEmptyContainers!==!1,...$}}var e8=j0(async($,J={})=>{let Z=B7($,{minify:J.minify!==!1}),K=await R6(Z,{...J,resolveClipPaths:!0,resolveUse:!1,resolveMarkers:!1,resolvePatterns:!1,resolveMasks:!1,flattenTransforms:!1,removeUnusedDefs:!1});return d0(K.svg)}),$J=j0(async($,J={})=>{let Z=B7($,{minify:J.minify!==!1}),K=await R6(Z,{...J,resolveMasks:!0,resolveClipPaths:!1,resolveUse:!1,resolveMarkers:!1,resolvePatterns:!1,flattenTransforms:!1,removeUnusedDefs:!1});return d0(K.svg)}),JJ=j0(($,J={})=>{let Z=i7($),K=(j)=>{let G=Z.get(j);if(!G)return null;let F=G.getAttribute("href")||G.getAttribute("xlink:href");return F?.startsWith("#")?F.substring(1):null},Q=(j,G)=>{let F=j.getAttribute("gradientUnits")||"objectBoundingBox",_=j.getAttribute("gradientTransform");if(Dz(G,K)){if(J.verbose)console.warn(`Circular gradient reference detected: #${G}`);return!1}if(F==="userSpaceOnUse")return!1;if(_)return!1;return!0},H=u7($,"fill");for(let j of H){let G=j.getAttribute("fill");if(G&&G.includes("url(")){let F=r7(G);if(F&&Z.has(F)){let _=Z.get(F),U=_.tagName.toLowerCase();if(U==="lineargradient"||U==="radialgradient"){if(!Q(_,F)){if(J.verbose)console.warn(`Skipping gradient flatten for ${F}: userSpaceOnUse or gradientTransform requires coordinate transformation`);continue}let O=fK(_,J.position||0.5);j.setAttribute("fill",O)}}else j.setAttribute("fill",J.fallbackColor||"#808080")}}let z=u7($,"stroke");for(let j of z){let G=j.getAttribute("stroke");if(G&&G.includes("url(")){let F=r7(G);if(F&&Z.has(F)){let _=Z.get(F),U=_.tagName.toLowerCase();if(U==="lineargradient"||U==="radialgradient"){if(!Q(_,F)){if(J.verbose)console.warn(`Skipping gradient flatten for ${F}: userSpaceOnUse or gradientTransform requires coordinate transformation`);continue}let O=fK(_,J.position||0.5);j.setAttribute("stroke",O)}}else j.setAttribute("stroke",J.fallbackColor||"#808080")}}let q=[...$.querySelectorAll("linearGradient, radialGradient")],W=(j)=>j.replace(/["\\]/g,"\\$&");for(let j of q){let G=j.getAttribute("id"),F=G?W(G):"";if(!(G&&([...$.querySelectorAll(`[fill*="url(#${F})"]`)].length>0||[...$.querySelectorAll(`[stroke*="url(#${F})"]`)].length>0))&&j.parentNode)j.parentNode.removeChild(j)}return $});function fK($,J=0.5){let Z=[...$.children].filter((q)=>q.tagName&&q.tagName.toLowerCase()==="stop");if(Z.length===0)return"#808080";if(Z.length===1)return SK(Z[0]);let K=Z.map((q)=>{let W=q.getAttribute("offset")||"0";if(W.endsWith("%"))W=parseFloat(W)/100;else W=parseFloat(W);return W=isNaN(W)?0:Math.max(0,Math.min(1,W)),{offset:W,color:SK(q),opacity:hz(q)}});K.sort((q,W)=>q.offset-W.offset);let Q=null,H=null;for(let q=0;q<K.length;q++){let W=K[q];if(W.offset<=J)Q=W;if(W.offset>=J&&!H){H=W;break}}if(!Q)return K[0].color;if(!H)return K[K.length-1].color;if(Q.offset===H.offset)return Q.color;let z=(J-Q.offset)/(H.offset-Q.offset);return uz(Q.color,H.color,z)}function SK($){let J=$.getAttribute("stop-color");if(!J){let Z=$.getAttribute("style");if(Z){let K=Z.match(/stop-color\s*:\s*([^;]+)/i);if(K)J=K[1].trim()}}if(!J)J="#000000";return yz(J)}function hz($){let J=$.getAttribute("stop-opacity");if(!J){let K=$.getAttribute("style");if(K){let Q=K.match(/stop-opacity\s*:\s*([^;]+)/i);if(Q)J=Q[1].trim()}}let Z=J?parseFloat(J):1;return isNaN(Z)?1:Z}function yz($){if(!$||typeof $!=="string")return"#000000";let J=$.trim().toLowerCase();if(J.startsWith("#")){if(J.length===4)return"#"+J[1]+J[1]+J[2]+J[2]+J[3]+J[3];return J}if(J.startsWith("rgb(")){let K=J.match(/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);if(K){let Q=parseInt(K[1],10),H=parseInt(K[2],10),z=parseInt(K[3],10);return xK(Q,H,z)}}let Z={black:"#000000",white:"#ffffff",red:"#ff0000",green:"#008000",blue:"#0000ff",yellow:"#ffff00",cyan:"#00ffff",magenta:"#ff00ff",gray:"#808080",grey:"#808080",silver:"#c0c0c0",maroon:"#800000",olive:"#808000",lime:"#00ff00",aqua:"#00ffff",teal:"#008080",navy:"#000080",fuchsia:"#ff00ff",purple:"#800080"};if(Z[J])return Z[J];return"#000000"}function uz($,J,Z){let K=(U)=>{let O=U.replace("#","");if(O.length===3)O=O[0]+O[0]+O[1]+O[1]+O[2]+O[2];let V=parseInt(O.slice(0,2),16),M=parseInt(O.slice(2,4),16),Y=parseInt(O.slice(4,6),16);if(isNaN(V)||isNaN(M)||isNaN(Y))return[0,0,0];return[V,M,Y]},[Q,H,z]=K($),[q,W,j]=K(J),G=Math.round(Q+(q-Q)*Z),F=Math.round(H+(W-H)*Z),_=Math.round(z+(j-z)*Z);return xK(G,F,_)}function xK($,J,Z){let K=(Q)=>{return Math.max(0,Math.min(255,Math.round(Q))).toString(16).padStart(2,"0")};return"#"+K($)+K(J)+K(Z)}var KJ=j0(async($,J={})=>{let Z=B7($,{minify:J.minify!==!1}),K=await R6(Z,{...J,resolvePatterns:!0,resolveClipPaths:!1,resolveUse:!1,resolveMarkers:!1,resolveMasks:!1,flattenTransforms:!1,removeUnusedDefs:!1});return d0(K.svg)}),ZJ=j0(($,J={})=>{let Z=(Q)=>{if(Q.hasAttribute("filter"))Q.removeAttribute("filter");for(let H of Q.children)if(a(H))Z(H)};Z($);let K=$.getElementsByTagName("filter");for(let Q of[...K])if(Q.parentNode)Q.parentNode.removeChild(Q);return $}),QJ=j0(async($,J={})=>{let Z=B7($,{minify:J.minify!==!1}),K=await R6(Z,{...J,resolveUse:!0,resolveClipPaths:!1,resolveMarkers:!1,resolvePatterns:!1,resolveMasks:!1,flattenTransforms:!1,removeUnusedDefs:!1});return d0(K.svg)}),HJ=j0(($,J={})=>{let Z=$.getElementsByTagName("image");for(let K of[...Z])K.setAttribute("data-trace-needed","true");return $}),zJ=j0(($,J={})=>{let{samples:Z=10,includeStroke:K=!0,includeFillOnly:Q=!1}=J,H=[...$.getElementsByTagName("path"),...$.getElementsByTagName("rect"),...$.getElementsByTagName("circle"),...$.getElementsByTagName("ellipse")],z=i7($),q=[];for(let W=0;W<H.length;W++)for(let j=W+1;j<H.length;j++){let G=H[W],F=H[j],_=r$(G,Z),U=r$(F,Z);if(!_||!U)continue;let O=m6(G),V=m6(F),M=x6(G,O,z),Y=x6(F,V,z);if(K&&!Q){if(M.hasStroke){let w=M.getStrokeExtent().toNumber();_=vK(_,w)}if(Y.hasStroke){let w=Y.getStrokeExtent().toNumber();U=vK(U,w)}}if(O$(_,U).overlaps)q.push({shape1:G.tagName,shape2:F.tagName,id1:G.getAttribute("id"),id2:F.getAttribute("id"),stroke1:M.hasStroke?M.strokeWidth.toNumber():0,stroke2:Y.hasStroke?Y.strokeWidth.toNumber():0,fillRule1:M.fillRule,fillRule2:Y.fillRule})}if(q.length>0)$.setAttribute("data-collisions",JSON.stringify(q));return $});function vK($,J){if(J<=0||!$||$.length===0)return $;let Z=0,K=0;for(let Q of $)Z+=Q.x,K+=Q.y;return Z/=$.length,K/=$.length,$.map((Q)=>{let H=Q.x-Z,z=Q.y-K,q=Math.sqrt(H*H+z*z);if(q<0.0001)return Q;let W=(q+J)/q;return{x:Z+H*W,y:K+z*W}})}var qJ=j0(($,J={})=>{let{id1:Z,id2:K}=J;if(!Z||!K)return $;let Q=$.getElementById(Z),H=$.getElementById(K);if(!Q||!H)return $;let z=r$(Q,J.samples||10),q=r$(H,J.samples||10);if(z&&q){let W=rJ(z,q);$.setAttribute("data-distance",W.distance.toString())}return $}),WJ=j0(($,J={})=>{let Z=[],K=[],Q=new Set,H=new Set,z=(W)=>{if(W.tagName.includes(":")){let j=W.tagName.split(":")[0];Q.add(j)}for(let j of W.getAttributeNames()){let G=W.getAttribute(j);if(j==="xmlns")H.add("");else if(j.startsWith("xmlns:")){let F=j.substring(6);H.add(F)}if(j.includes(":")&&!j.startsWith("xmlns:")){let F=j.split(":")[0];Q.add(F)}if(G&&/[\x00-\x08\x0B\x0C\x0E-\x1F]/.test(G))Z.push(`Invalid XML characters in attribute '${j}' of <${W.tagName}>`)}if(W.textContent&&/[\x00-\x08\x0B\x0C\x0E-\x1F]/.test(W.textContent))Z.push(`Invalid XML characters in text content of <${W.tagName}>`);for(let j of W.children)if(a(j))z(j)};z($);for(let W of Q)if(W&&!H.has(W))Z.push(`Unbound namespace prefix: '${W}' - SVGO would produce invalid XML here`);let q={valid:Z.length===0,errors:Z,warnings:K,namespacesUsed:[...Q],namespacesDeclared:[...H]};return $.setAttribute("data-xml-validation",JSON.stringify(q)),$}),jJ=j0(($,J={})=>{let Z=[],K=[],Q=J.version||"1.1";if($.tagName!=="svg")Z.push("Root element must be <svg>");let H=$.getAttribute("xmlns");if(!H)K.push("Missing xmlns attribute (required for standalone SVG)");else if(H!=="http://www.w3.org/2000/svg")Z.push(`Invalid SVG namespace: expected 'http://www.w3.org/2000/svg', got '${H}'`);let z=$.getAttribute("viewBox");if(z){let F=z.split(/[\s,]+/);if(F.length!==4)Z.push(`Invalid viewBox: expected 4 values, got ${F.length}`);else if(F.some((_)=>isNaN(parseFloat(_))))Z.push("Invalid viewBox: contains non-numeric values");else{let[_,U,O,V]=F.map(parseFloat);if(O<0||V<0)Z.push("Invalid viewBox: width and height must be non-negative")}}let q={meshGradients:[],hatches:[],solidColors:[],needsPolyfills:!1},W={meshGradient:"meshgradient",meshRow:"meshrow",meshPatch:"meshpatch",hatchPath:"hatchpath",solidColor:"solidcolor"},j=(F,_=0)=>{if(!F||!F.tagName){K.push(`Element at depth ${_} has no tagName property`);return}let U=F.tagName.toLowerCase(),O=F.tagName;if(W[O])Z.push(`Invalid SVG 2.0 element: <${O}> must be lowercase <${W[O]}> per SVG 2.0 specification`);if(U==="meshgradient"){let V=F.getAttribute("id");if(q.meshGradients.push(V||null),q.needsPolyfills=!0,!V)K.push("<meshgradient> element without 'id' attribute may be difficult to reference")}if(U==="hatch"){let V=F.getAttribute("id");if(q.hatches.push(V||null),q.needsPolyfills=!0,!V)K.push("<hatch> element without 'id' attribute may be difficult to reference")}if(U==="solidcolor"){let V=F.getAttribute("id");if(q.solidColors.push(V||null),q.needsPolyfills=!0,!V)K.push("<solidcolor> element without 'id' attribute may be difficult to reference")}if(U==="path"){let V=F.getAttribute("d");if(!V||!V.trim())Z.push("<path> element missing required 'd' attribute");else{let M=V.match(/[MmLlHhVvCcSsQqTtAaZz]/g);if(!M||M.length===0)Z.push("<path> 'd' attribute contains no valid commands");let Y=V.trim()[0];if(Y!=="M"&&Y!=="m")Z.push("<path> 'd' must start with M or m command")}}if(U==="rect"){let V=F.getAttribute("width"),M=F.getAttribute("height");if(V!==null&&!m7(V)&&parseFloat(V)<0)Z.push("<rect> width must be non-negative");if(M!==null&&!m7(M)&&parseFloat(M)<0)Z.push("<rect> height must be non-negative")}if(U==="circle"){let V=F.getAttribute("r");if(V!==null&&parseFloat(V)<0)Z.push("<circle> r must be non-negative")}if(U==="ellipse"){let V=F.getAttribute("rx"),M=F.getAttribute("ry");if(V!==null&&parseFloat(V)<0)Z.push("<ellipse> rx must be non-negative");if(M!==null&&parseFloat(M)<0)Z.push("<ellipse> ry must be non-negative")}if(U==="use"){let V=F.getAttribute("href")||F.getAttribute("xlink:href");if(V&&V.startsWith("#")){let M=V.substring(1);if(!$.getElementById(M))K.push(`<use> references non-existent ID: '${M}'`)}}for(let V of["fill","stroke","clip-path","mask","filter"]){let M=F.getAttribute(V);if(M&&M.startsWith("url(#")){let Y=M.match(/url\(#([^)]+)\)/);if(Y){let X=Y[1];if(!$.getElementById(X))K.push(`<${F.tagName}> ${V} references non-existent ID: '${X}'`)}}}if(s6[U]){let V=s6[U];for(let M of F.children)if(a(M)){let Y=M.tagName.toLowerCase();if(!V.has(Y))K.push(`<${Y}> is not a standard child of <${U}>`)}}for(let V of F.children)if(a(V))j(V,_+1)};if(j($),q.needsPolyfills){let F=[];if(q.meshGradients.length>0)F.push(`meshgradient (${q.meshGradients.length} found)`);if(q.hatches.length>0)F.push(`hatch (${q.hatches.length} found)`);if(q.solidColors.length>0)F.push(`solidcolor (${q.solidColors.length} found)`);K.push(`SVG contains SVG 2.0 features that require polyfills for browser compatibility: ${F.join(", ")}. Use --svg2-polyfills option to inject runtime polyfills.`)}let G={valid:Z.length===0,svgVersion:Q,errors:Z,warnings:K,elementsChecked:oK($),svg2Features:q};if($.setAttribute("data-svg-validation",JSON.stringify(G)),Z.length>0)$.setAttribute("data-validation-errors",JSON.stringify(Z));else $.setAttribute("data-validation-status","valid");return $}),gz=new Set(["click","dblclick","mousedown","mouseup","mouseover","mouseout","mousemove","mouseenter","mouseleave","focus","blur","focusin","focusout","keydown","keyup","keypress","activate","load","unload","abort","error","resize","scroll","beginEvent","endEvent","repeatEvent","touchstart","touchend","touchmove","touchcancel","wheel","auxclick","input","beforeinput","select","compositionstart","compositionupdate","compositionend"]),mK=j0(($,J={})=>{let Z=J.verbose||!1,K=J.printTables!==!1,Q={valid:!0,timestamp:new Date().toISOString(),media:{hasAudio:!1,hasVideo:!1,audioElements:[],videoElements:[],foreignObjectWithMedia:[],mediaEmbedMethod:null},smil:{hasAnimations:!1,animationCount:0,animationElements:{animate:0,animateTransform:0,animateMotion:0,animateColor:0,set:0},hasInteractiveAnimations:!1,eventTriggers:[],timingTriggers:[]},compatibility:{worksInAllBrowsers:!0,issues:[],recommendations:[]},errors:[],warnings:[],info:[]},H=(V)=>{let M=[],Y=V.toLowerCase(),X=(w)=>{if(w.tagName&&w.tagName.toLowerCase()===Y)M.push(w);for(let R of w.children||[])if(R&&R.tagName)X(R)};return X($),M},z=(V,M=[])=>{if(V.tagName)M.push(V);for(let Y of V.children||[])if(Y&&Y.tagName)z(Y,M);return M},q=H("audio");if(q.length>0)Q.media.hasAudio=!0,Q.media.audioElements=q.map((V)=>({id:V.getAttribute("id"),src:V.getAttribute("src"),hasSource:H("source").filter((M)=>M.parentNode===V).length>0}));let W=H("video");if(W.length>0)Q.media.hasVideo=!0,Q.media.videoElements=W.map((V)=>({id:V.getAttribute("id"),src:V.getAttribute("src")}));let j=H("foreignObject");for(let V of j){let M=V.children||[],Y=!1,X=[],w=(R)=>{let I=R.tagName?.toLowerCase();if(I==="audio"||I==="video")Y=!0,X.push({type:I,id:R.getAttribute("id"),src:R.getAttribute("src")});for(let b of R.children||[])if(b&&b.tagName)w(b)};for(let R of M)if(R&&R.tagName)w(R);if(Y)Q.media.hasAudio=!0,Q.media.foreignObjectWithMedia.push({id:V.getAttribute("id"),media:X}),Q.media.mediaEmbedMethod="foreignObject"}let G=z($);for(let V of G)for(let M of["src","href","xlink:href"]){let Y=V.getAttribute(M);if(Y&&Y.startsWith("data:audio/"))Q.media.hasAudio=!0,Q.media.mediaEmbedMethod="data-uri";if(Y&&Y.startsWith("data:video/"))Q.media.hasVideo=!0,Q.media.mediaEmbedMethod="data-uri"}let F=["animate","animateTransform","animateMotion","animateColor","set"];for(let V of F){let M=H(V),Y=M.length;Q.smil.animationElements[V==="animateTransform"?"animateTransform":V==="animateMotion"?"animateMotion":V==="animateColor"?"animateColor":V]=Y,Q.smil.animationCount+=Y;for(let X of M){let w=X.getAttribute("begin")||"",R=X.getAttribute("end")||"",I=(m,S)=>{let x=m.split(";").map((h)=>h.trim()).filter(Boolean);for(let h of x){let E=h.match(/^(?:([a-zA-Z_][a-zA-Z0-9_-]*)\.)?([a-zA-Z]+)(\s*[+-]\s*[\d.]+[smh]?)?$/);if(E){let[,d,c,p]=E;if(gz.has(c))Q.smil.hasInteractiveAnimations=!0,Q.smil.eventTriggers.push({animationElement:V,animationId:X.getAttribute("id"),attribute:S,event:c,targetId:d||null,offset:p?.trim()||null,parentId:X.parentNode?.getAttribute?.("id")})}else if(/^[\d.]+[smh]?$/.test(h)||h==="indefinite")Q.smil.timingTriggers.push({animationElement:V,value:h});else if(/\.(begin|end)/.test(h))Q.smil.timingTriggers.push({animationElement:V,value:h,type:"syncbase"})}};if(w)I(w,"begin");if(R)I(R,"end");let b=X.getAttribute("onbegin"),u=X.getAttribute("onend");if(b||u){if(Q.smil.hasInteractiveAnimations=!0,b?.includes("play()")||u?.includes("play()"))Q.info.push(`Animation uses JavaScript to trigger audio playback via ${b?"onbegin":"onend"} handler`)}}}if(Q.smil.hasAnimations=Q.smil.animationCount>0,Q.media.hasAudio)Q.compatibility.worksInAllBrowsers=!1,Q.warnings.push("SVG contains embedded audio. Browser autoplay policies will block playback in most scenarios."),Q.compatibility.issues.push({type:"AUDIO_AUTOPLAY_BLOCKED",severity:"HIGH",description:"Embedded audio in SVG is blocked by Chrome/Firefox/Safari autoplay policies",affectedBrowsers:["Chrome","Firefox","Safari","Edge"]}),Q.compatibility.recommendations.push("To enable audio playback, embed the SVG in an HTML page that extracts audio dynamically after user interaction","Use JavaScript to extract audio data URI from foreignObject and create Audio element on click","Consider using Web Audio API for more control over audio playback");if(Q.media.hasVideo)Q.compatibility.worksInAllBrowsers=!1,Q.warnings.push("SVG contains embedded video. This has limited browser support and autoplay restrictions.");if(Q.smil.hasAnimations)Q.info.push(`SVG contains ${Q.smil.animationCount} SMIL animation elements`),Q.compatibility.issues.push({type:"SMIL_IE_UNSUPPORTED",severity:"LOW",description:"SMIL animations are not supported in IE11",affectedBrowsers:["IE (no support)"]});if(Q.smil.hasInteractiveAnimations){let V=[...new Set(Q.smil.eventTriggers.map((M)=>M.event))];if(Q.info.push(`SVG contains interactive SMIL animations triggered by: ${V.join(", ")}`),V.includes("click")||V.includes("mouseover"))Q.compatibility.recommendations.push("Interactive animations (click/hover) work in most browsers but require the SVG to be inline or loaded as <object>/<embed>","Using <img> tag to display SVG will disable all interactivity and animations")}let _={Chrome:{smil:"Full support",audio:"Blocked (autoplay policy)",interactive:"Full support",notes:"Autoplay blocked without user gesture"},Firefox:{smil:"Full support",audio:"Blocked (autoplay policy)",interactive:"Full support",notes:"MEI (Media Engagement Index) affects autoplay"},Safari:{smil:"Full support",audio:"Blocked (autoplay policy)",interactive:"Full support",notes:"Strict autoplay policy"},Edge:{smil:"Full support",audio:"Blocked (autoplay policy)",interactive:"Full support",notes:"Chromium-based, same as Chrome"},"IE 11":{smil:"No support",audio:"No support",interactive:"No support",notes:"Use CSS animations or JavaScript"}},U=[{scenario:"Standalone SVG",protocol:"file://",example:"file:///path/to/sample.svg",smilWorks:!0,audioWorks:!1,interactiveWorks:!0,notes:"SMIL works, audio blocked by autoplay policy"},{scenario:"Standalone SVG",protocol:"http://",example:"http://localhost/sample.svg",smilWorks:!0,audioWorks:!1,interactiveWorks:!0,notes:"SMIL works, audio blocked by autoplay policy"},{scenario:"SVG in HTML via <img>",protocol:"any",example:'<img src="sample.svg">',smilWorks:!1,audioWorks:!1,interactiveWorks:!1,notes:"All scripting and interactivity disabled"},{scenario:"SVG in HTML via <object>",protocol:"any",example:'<object data="sample.svg">',smilWorks:!0,audioWorks:!1,interactiveWorks:!0,notes:"Full SVG features, audio still blocked"},{scenario:"SVG in HTML via <embed>",protocol:"any",example:'<embed src="sample.svg">',smilWorks:!0,audioWorks:!1,interactiveWorks:!0,notes:"Full SVG features, audio still blocked"},{scenario:"Inline SVG in HTML",protocol:"any",example:"<svg>...</svg> in HTML",smilWorks:!0,audioWorks:!1,interactiveWorks:!0,notes:"Full features, audio needs user gesture"},{scenario:"HTML extracts audio on click",protocol:"file://",example:"JS extracts data-uri, plays on click",smilWorks:!0,audioWorks:!0,interactiveWorks:!0,notes:"WORKS - user gesture enables audio"},{scenario:"HTML extracts audio on click",protocol:"http://",example:"JS extracts data-uri, plays on click",smilWorks:!0,audioWorks:!0,interactiveWorks:!0,notes:"WORKS - user gesture enables audio"}],O=[{trigger:'begin="click"',description:"Animation starts on click (on animation target)",syntax:'<animate begin="click" .../>',browserSupport:"Chrome, Firefox, Safari, Edge",notes:"Target element must be clickable (not in <defs>)"},{trigger:'begin="elementId.click"',description:"Animation starts when another element is clicked",syntax:'<animate begin="button.click" .../>',browserSupport:"Chrome, Firefox, Safari, Edge",notes:"Referenced element must exist with matching id"},{trigger:'begin="mouseover"',description:"Animation starts on mouse hover",syntax:'<animate begin="mouseover" .../>',browserSupport:"Chrome, Firefox, Safari, Edge",notes:"Often paired with mouseout for hover effects"},{trigger:'begin="elementId.mouseover"',description:"Animation starts when hovering another element",syntax:'<animate begin="trigger.mouseover" .../>',browserSupport:"Chrome, Firefox, Safari, Edge",notes:"Useful for triggering animations on related elements"},{trigger:'begin="mouseout"',description:"Animation starts when mouse leaves",syntax:'<animate begin="mouseout" .../>',browserSupport:"Chrome, Firefox, Safari, Edge",notes:"Use with mouseover for complete hover cycle"},{trigger:'begin="focus"',description:"Animation starts when element receives focus",syntax:'<animate begin="focus" .../>',browserSupport:"Chrome, Firefox, Safari, Edge",notes:"Works with focusable elements (links, inputs)"},{trigger:'begin="accessKey(s)"',description:"Animation starts on keyboard shortcut",syntax:'<animate begin="accessKey(s)" .../>',browserSupport:"Limited",notes:"Press Alt+S (Windows) or Ctrl+Opt+S (Mac)"}];if(Q.tables={browserSupport:_,usageScenarios:U,smilEventScenarios:O},K&&(Q.media.hasAudio||Q.media.hasVideo||Q.smil.hasInteractiveAnimations)){if(console.log(`
19
+ ]]></${Z}>`})}var a$=/-?\d*\.?\d+(?:[eE][+-]?\d+)?/g,E6=80,$$=6,V8={BROWSER_MIN:2,BROWSER_TYPICAL:6,FLOAT32:7,FLOAT64:15,GEOGRAPHIC:8,SCIENTIFIC:20,MAX:80};L.set({precision:E6,rounding:L.ROUND_HALF_UP});var M8=($)=>$ instanceof L?$:new L($);function i($){return $!==null&&typeof $==="object"&&typeof $.tagName==="string"&&typeof $.getAttribute==="function"&&typeof $.setAttribute==="function"}function O8($,J=$$){if($===null||$===void 0)return"0";let Z=J;if(typeof J!=="number"||isNaN(J)||J<0)Z=$$;if(Z>E6)Z=E6;let Q=M8($).toFixed(Z);if(Q.includes("."))return Q.replace(/\.?0+$/,"");return Q}function aK($){if($===null||$===void 0)return"";return String($).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}var v0={SVG_STRING:"string",DOM_ELEMENT:"dom",FILE_PATH:"file",URL:"url",XML_DOCUMENT:"xml",CSS_SELECTOR:"selector",OBJECT_ELEMENT:"object",EMBED_ELEMENT:"embed",IFRAME_ELEMENT:"iframe"},G7={SVG_STRING:"string",DOM_ELEMENT:"dom",XML_DOCUMENT:"xml"},j7={STRING:"string",FILE:"file",DOM_REPLACE:"dom_replace",DOM_UPDATE:"dom_update",DOWNLOAD:"download"};function $9($){if($===null||$===void 0)return j7.STRING;if(typeof $==="object"&&$.nodeType)return j7.DOM_UPDATE;if(typeof $==="string"){let J=$.trim();if(typeof document!=="undefined"&&(J.startsWith("#")||J.startsWith(".")||J.startsWith("[")))return j7.DOM_REPLACE;if(J.includes("/")||J.includes("\\")||/\.\w+$/.test(J))return j7.FILE;if(J.toLowerCase()==="download")return j7.DOWNLOAD}return j7.STRING}async function Y8($,J=null,Z={}){let K=$9(J),Q;if(typeof $==="string")Q=$;else Q=f6($,G7.SVG_STRING,Z);switch(K){case j7.STRING:return Q;case j7.FILE:{if(typeof process!=="undefined"&&process.versions?.node){let H=await import("fs"),q=(await Promise.resolve().then(() => (P6(),I6))).dirname(J);if(q&&q!=="."&&!H.existsSync(q))H.mkdirSync(q,{recursive:!0});H.writeFileSync(J,Q,"utf8");return}throw new Error("File saving requires Node.js environment")}case j7.DOM_REPLACE:{if(typeof document==="undefined")throw new Error("DOM operations require browser environment");let H=document.querySelector(J);if(!H)throw new Error(`No element found for selector: ${J}`);H.innerHTML=Q;return}case j7.DOM_UPDATE:{if(typeof document==="undefined")throw new Error("DOM operations require browser environment");if(J.tagName?.toLowerCase()==="svg"){let q=new DOMParser().parseFromString(Q,"image/svg+xml").documentElement;while(J.attributes.length>0)J.removeAttribute(J.attributes[0].name);for(let j of q.attributes)J.setAttribute(j.name,j.value);J.innerHTML=q.innerHTML}else J.innerHTML=Q;return}case j7.DOWNLOAD:{if(typeof document==="undefined"||typeof Blob==="undefined")throw new Error("Download requires browser environment");let H=new Blob([Q],{type:"image/svg+xml"}),z=URL.createObjectURL(H),q=document.createElement("a");q.href=z,q.download=Z.filename||"output.svg",document.body.appendChild(q),q.click(),document.body.removeChild(q),URL.revokeObjectURL(z);return}default:return Q}}function T6($){if($===null||$===void 0)throw new Error("Input cannot be null or undefined");if(typeof $==="string"){let J=$.trim();if(J.startsWith("<"))return v0.SVG_STRING;else if($.startsWith("http://")||$.startsWith("https://"))return v0.URL;else if(typeof document!=="undefined"&&(J.startsWith("#")||J.startsWith(".")||J.startsWith("[")))return v0.CSS_SELECTOR;else return v0.FILE_PATH}if(typeof HTMLObjectElement!=="undefined"&&$ instanceof HTMLObjectElement)return v0.OBJECT_ELEMENT;if(typeof HTMLEmbedElement!=="undefined"&&$ instanceof HTMLEmbedElement)return v0.EMBED_ELEMENT;if(typeof HTMLIFrameElement!=="undefined"&&$ instanceof HTMLIFrameElement)return v0.IFRAME_ELEMENT;if(i($))return v0.DOM_ELEMENT;if($&&$.nodeType===9)return v0.XML_DOCUMENT;return v0.SVG_STRING}async function b6($,J){switch(J){case v0.SVG_STRING:return p0($);case v0.DOM_ELEMENT:if($&&typeof $.serialize==="function")return $;if(typeof XMLSerializer!=="undefined"){let K=new XMLSerializer().serializeToString($);return p0(K)}return $;case v0.XML_DOCUMENT:{let Z=$.documentElement||$;if(Z&&typeof Z.serialize==="function")return Z;if(typeof XMLSerializer!=="undefined"){let Q=new XMLSerializer().serializeToString(Z);return p0(Q)}return Z}case v0.FILE_PATH:{let K=(()=>({})).readFileSync($,"utf8");return p0(K)}if(typeof process!=="undefined"&&process.versions?.node){let{readFileSync:Z}=await import("fs"),K=Z($,"utf8");return p0(K)}throw new Error("File loading requires Node.js environment");case v0.URL:if(typeof fetch!=="undefined"){let K=await(await fetch($)).text();return p0(K)}throw new Error("URL loading requires fetch API");case v0.CSS_SELECTOR:if(typeof document!=="undefined"){let Z=document.querySelector($);if(!Z)throw new Error(`No element found for selector: ${$}`);if(Z.tagName.toLowerCase()==="svg")return p0(new XMLSerializer().serializeToString(Z));let K=Z.querySelector("svg");if(K)return p0(new XMLSerializer().serializeToString(K));throw new Error(`Element "${$}" is not an SVG and contains no SVG`)}throw new Error("CSS selector requires browser environment");case v0.OBJECT_ELEMENT:try{if($.contentDocument&&$.contentDocument.documentElement){let Z=$.contentDocument.documentElement;if(Z.tagName.toLowerCase()==="svg")return p0(new XMLSerializer().serializeToString(Z))}}catch(Z){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${Z.message}`);throw new Error("HTMLObjectElement: SVG content not accessible (cross-origin or security error)")}throw new Error("HTMLObjectElement: SVG content not accessible (not loaded or cross-origin)");case v0.EMBED_ELEMENT:if(typeof $.getSVGDocument==="function"){let Z=$.getSVGDocument();if(Z&&Z.documentElement)return p0(new XMLSerializer().serializeToString(Z.documentElement))}throw new Error("HTMLEmbedElement: SVG content not accessible");case v0.IFRAME_ELEMENT:try{let Z=$.contentDocument;if(Z&&Z.documentElement){let K=Z.documentElement;if(K.tagName.toLowerCase()==="svg")return p0(new XMLSerializer().serializeToString(K))}}catch(Z){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${Z.message}`);throw new Error("HTMLIFrameElement: SVG content not accessible (cross-origin)")}throw new Error("HTMLIFrameElement: No SVG content found");default:throw new Error(`Unknown input type: ${J}`)}}function f6($,J,Z={}){switch(J){case G7.SVG_STRING:{let K=N7($,{minify:Z.minify!==!1});return pK(K)}case G7.DOM_ELEMENT:return $;case G7.XML_DOCUMENT:return $;default:{let K=N7($,{minify:Z.minify!==!1});return pK(K)}}}function G0($){return async function(J,Z={}){let K=T6(J),Q=await b6(J,K),H=Z.outputFormat||(K===v0.DOM_ELEMENT?G7.DOM_ELEMENT:G7.SVG_STRING),z=await $(Q,Z);return f6(z,H,Z)}}var J9=G0(($,J={})=>{let Z=J.minify!==!1,K=J.remove!==!1,Q=J.force||!1,H=J.preserve||[],z=J.preservePrefixes||[];if(!Q){let B=$.querySelectorAll("script").length>0,I=Array.from($.querySelectorAll("style")).some((h)=>h.textContent&&h.textContent.trim().length>0);if(B||I)return $}let q=(B)=>{if(H.includes(B))return!0;if(z.some((I)=>B.startsWith(I)))return!0;return!1},j=(B)=>{try{return decodeURI(B)}catch(I){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${I.message}`);return B}},W=wK($),G=new Set;for(let B of W.all)G.add(B),G.add(j(B));let F=new Map,_=(B)=>{let I=B.getAttribute("id");if(I){if(!F.has(I))F.set(I,B)}for(let h of B.children)if(i(h))_(h)};_($);let U=new Set,M=new Set,V=(B)=>{let I=B.getAttribute("id");if(I){if(U.has(I))M.add(I);U.add(I)}for(let h of B.children)if(i(h))V(h)};V($);let Y=new Set,O=new Map,X=0,w=()=>{let B;do B=`a${X++}`;while(G.has(B)&&!F.has(B));return B},R=(B)=>{let I=B.getAttribute("id");if(I){if(M.has(I)){if(Y.has(I)){B.removeAttribute("id");return}Y.add(I)}let h=j(I),m=G.has(I)||G.has(h);if(q(I));else if(!m&&K)B.removeAttribute("id");else if(Z&&m){let v=w();if(O.set(I,v),h!==I)O.set(h,v);B.setAttribute("id",v)}}for(let h of B.children)if(i(h))R(h)};if(R($),Z){let B=(m)=>{let v=(x)=>x.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");for(let x of m.getAttributeNames()){let y=m.getAttribute(x);if(y&&y.includes("url(#")){for(let[T,d]of O){let p=v(T);y=y.replace(new RegExp(`url\\(#${p}\\)`,"g"),`url(#${d})`);let c=v(encodeURI(T));y=y.replace(new RegExp(`url\\(#${c}\\)`,"g"),`url(#${d})`)}m.setAttribute(x,y)}if((x==="href"||x==="xlink:href")&&y?.startsWith("#")){let T=y.substring(1),d=j(T);if(O.has(T))m.setAttribute(x,`#${O.get(T)}`);else if(O.has(d))m.setAttribute(x,`#${O.get(d)}`)}if((x==="begin"||x==="end")&&y){for(let[T,d]of O){let p=v(T);y=y.replace(new RegExp(`^${p}\\.`,"g"),`${d}.`),y=y.replace(new RegExp(`;${p}\\.`,"g"),`;${d}.`)}m.setAttribute(x,y)}if((x==="values"||x==="from"||x==="to"||x==="by")&&y){for(let[T,d]of O){let p=v(T);y=y.replace(new RegExp(`#${p}([;\\s]|$)`,"g"),`#${d}$1`)}m.setAttribute(x,y)}}for(let x of m.children)if(i(x))B(x)};B($);let I=(m)=>m.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),h=$.getElementsByTagName("style");for(let m of h){let v=m.textContent;if(!v)continue;for(let[x,y]of O){let T=I(x);v=v.replace(new RegExp(`#${T}([^\\w-]|$)`,"g"),`#${y}$1`),v=v.replace(new RegExp(`url\\(#${T}\\)`,"g"),`url(#${y})`)}m.textContent=v}}return $}),J$=G0(($,J={})=>{let Z=J.precision||6,K=(H)=>{let z=parseFloat(H);if(isNaN(z))return H;let W=M8(z).toDecimalPlaces(Z).toString();if(W.includes("."))W=W.replace(/0+$/,""),W=W.replace(/\.$/,"");return W},Q=(H)=>{for(let z of H.getAttributeNames()){let q=H.getAttribute(z);if(z.match(/^(x|y|cx|cy|r|rx|ry|width|height|x1|y1|x2|y2|stroke-width|font-size)$/)){if(p7(q))continue;H.setAttribute(z,K(q))}if(z==="d"&&q){let j=q.replace(a$,(W)=>K(W));H.setAttribute("d",j)}if(z==="transform"&&q){let j=q.replace(a$,(W)=>K(W));H.setAttribute("transform",j)}if(z==="points"&&q){let j=q.replace(a$,(W)=>K(W));H.setAttribute("points",j)}}for(let z of H.children)if(i(z))Q(z)};return Q($),$}),X8=G0(($,J={})=>{let Z=J.precision||6,K=(H)=>{let z=parseFloat(H);if(isNaN(z))return H;let j=M8(z).toDecimalPlaces(Z).toString();if(j.includes("."))j=j.replace(/0+$/,""),j=j.replace(/\.$/,"");return j},Q=(H)=>{for(let z of["points"]){let q=H.getAttribute(z);if(q){let j=q.replace(a$,K);H.setAttribute(z,j)}}for(let z of H.children)if(i(z))Q(z)};return Q($),$}),L8=G0(($,J={})=>{let Z=["data-name","data-id","class"],K=["xmlns:serif"],Q=(H)=>{for(let z of Z)if(H.hasAttribute(z))H.removeAttribute(z);if(!J.preserveVendor){for(let z of K)if(H.hasAttribute(z))H.removeAttribute(z)}for(let z of H.children)if(i(z))Q(z)};return Q($),$}),k8=G0(($,J={})=>{let Z=(K)=>{if(K.hasAttribute("enable-background"))K.removeAttribute("enable-background");for(let Q of K.children)if(i(Q))Z(Q)};return Z($),$}),w8=G0(($,J={})=>{let Z=Array.from($.querySelectorAll("style")).some((O)=>{let X=O.textContent||"";return X.includes("@media")||X.includes(":hover")||X.includes(":focus")||X.includes(":active")||X.includes(":visited")||X.includes(":first-child")||X.includes(":last-child")||X.includes(":nth-child")||X.includes(":not(")}),K=$.querySelectorAll("script").length>0,Q=new Set,H=$.outerHTML||"",z=H.matchAll(/url\(#([^)]+)\)/g);for(let O of z)Q.add(O[1]);let q=H.matchAll(/xlink:href="#([^"]+)"/g);for(let O of q)Q.add(O[1]);let j=H.matchAll(/\shref="#([^"]+)"/g);for(let O of j)Q.add(O[1]);let W={clippath:"clipPath",textpath:"textPath",lineargradient:"linearGradient",radialgradient:"radialGradient",meshgradient:"meshGradient",hatchpath:"hatchPath",solidcolor:"solidColor",foreignobject:"foreignObject",feblend:"feBlend",fecolormatrix:"feColorMatrix",fecomponenttransfer:"feComponentTransfer",fecomposite:"feComposite",feconvolvematrix:"feConvolveMatrix",fediffuselighting:"feDiffuseLighting",fedisplacementmap:"feDisplacementMap",fedistantlight:"feDistantLight",fedropshadow:"feDropShadow",feflood:"feFlood",fefunca:"feFuncA",fefuncb:"feFuncB",fefuncg:"feFuncG",fefuncr:"feFuncR",fegaussianblur:"feGaussianBlur",feimage:"feImage",femerge:"feMerge",femergenode:"feMergeNode",femorphology:"feMorphology",feoffset:"feOffset",fepointlight:"fePointLight",fespecularlighting:"feSpecularLighting",fespotlight:"feSpotLight",fetile:"feTile",feturbulence:"feTurbulence",animatemotion:"animateMotion",animatetransform:"animateTransform"},G=(O)=>W[O]||O,F=["svg","g","path","rect","circle","ellipse","line","polyline","polygon","text","tspan","tref","textPath","textpath","defs","clipPath","clippath","mask","pattern","linearGradient","lineargradient","radialGradient","radialgradient","meshGradient","meshgradient","meshrow","meshpatch","hatch","hatchpath","hatchPath","solidcolor","solidColor","stop","image","use","symbol","marker","title","desc","metadata","foreignObject","foreignobject","switch","a","filter","feBlend","feblend","feColorMatrix","fecolormatrix","feComponentTransfer","fecomponenttransfer","feComposite","fecomposite","feConvolveMatrix","feconvolvematrix","feDiffuseLighting","fediffuselighting","feDisplacementMap","fedisplacementmap","feDistantLight","fedistantlight","feDropShadow","fedropshadow","feFlood","feflood","feFuncA","fefunca","feFuncB","fefuncb","feFuncG","fefuncg","feFuncR","fefuncr","feGaussianBlur","fegaussianblur","feImage","feimage","feMerge","femerge","feMergeNode","femergenode","feMorphology","femorphology","feOffset","feoffset","fePointLight","fepointlight","feSpecularLighting","fespecularlighting","feSpotLight","fespotlight","feTile","fetile","feTurbulence","feturbulence","animate","animateMotion","animatemotion","animateTransform","animatetransform","set","mpath","view","cursor","style","script","font","font-face","font-face-src","font-face-uri","font-face-format","font-face-name","glyph","missing-glyph","hkern","vkern"],_={fill:"#000","fill-opacity":"1","fill-rule":"nonzero",stroke:"none","stroke-width":"1","stroke-opacity":"1","stroke-linecap":"butt","stroke-linejoin":"miter","stroke-miterlimit":"4","stroke-dasharray":"none","stroke-dashoffset":"0",opacity:"1",visibility:"visible",display:"inline",clip:"auto","clip-path":"none","clip-rule":"nonzero",mask:"none","marker-start":"none","marker-mid":"none","marker-end":"none","stop-color":"#000","stop-opacity":"1","flood-color":"#000","flood-opacity":"1","lighting-color":"#fff","color-interpolation":"sRGB","color-interpolation-filters":"linearRGB","color-rendering":"auto","shape-rendering":"auto","text-rendering":"auto","image-rendering":"auto","paint-order":"normal","vector-effect":"none","text-anchor":"start","text-overflow":"clip","text-decoration":"none","dominant-baseline":"auto","alignment-baseline":"baseline","baseline-shift":"baseline","writing-mode":"lr-tb",direction:"ltr","unicode-bidi":"normal","letter-spacing":"normal","word-spacing":"normal","font-style":"normal","font-variant":"normal","font-weight":"normal","font-stretch":"normal","font-size":"medium","font-size-adjust":"none"},U={circle:{cx:"0",cy:"0"},ellipse:{cx:"0",cy:"0"},line:{x1:"0",y1:"0",x2:"0",y2:"0"},rect:{x:"0",y:"0",rx:"0",ry:"0"},image:{x:"0",y:"0",preserveAspectRatio:"xMidYMid meet"},svg:{x:"0",y:"0",preserveAspectRatio:"xMidYMid meet"},symbol:{preserveAspectRatio:"xMidYMid meet"},marker:{markerUnits:"strokeWidth",refX:"0",refY:"0",markerWidth:"3",markerHeight:"3"},linearGradient:{x1:"0",y1:"0",x2:"100%",y2:"0",spreadMethod:"pad"},radialGradient:{cx:"50%",cy:"50%",r:"50%",fx:"50%",fy:"50%",spreadMethod:"pad"},pattern:{x:"0",y:"0",patternUnits:"objectBoundingBox",patternContentUnits:"userSpaceOnUse"},clipPath:{clipPathUnits:"userSpaceOnUse"},mask:{maskUnits:"objectBoundingBox",maskContentUnits:"userSpaceOnUse",x:"-10%",y:"-10%",width:"120%",height:"120%"},filter:{primitiveUnits:"userSpaceOnUse",x:"-10%",y:"-10%",width:"120%",height:"120%"},feBlend:{mode:"normal"},feColorMatrix:{type:"matrix"},feComposite:{operator:"over",k1:"0",k2:"0",k3:"0",k4:"0"},feTurbulence:{baseFrequency:"0",numOctaves:"1",seed:"0",stitchTiles:"noStitch",type:"turbulence"},feDisplacementMap:{scale:"0",xChannelSelector:"A",yChannelSelector:"A"},feDistantLight:{azimuth:"0",elevation:"0"},fePointLight:{x:"0",y:"0",z:"0"},a:{target:"_self"},textPath:{startOffset:"0"}},M=(O)=>{if(O.startsWith("data-"))return!0;if(O.startsWith("aria-"))return!0;if(O==="role")return!0;if(O==="xmlns")return!0;if(O.includes(":")&&!O.startsWith("xml:")&&!O.startsWith("xlink:"))return!0;return!1},V=(O,X)=>{let w=O.parentNode;while(w&&i(w)){let R=w.getAttribute(X);if(R!==null)return R;w=w.parentNode}return null},Y=(O,X={})=>{if(O.tagName==="foreignObject")return;if(O.tagName.includes(":"))return;if(!O.getAttribute("id")){for(let[h,m]of Object.entries(_))if(!M(h)&&O.getAttribute(h)===m)O.removeAttribute(h);let I=U[O.tagName.toLowerCase()]||{};for(let[h,m]of Object.entries(I))if(!M(h)&&O.getAttribute(h)===m)O.removeAttribute(h);if(!Z){for(let h of O.getAttributeNames())if(j6.has(h)&&!M(h)){let m=O.getAttribute(h),v=V(O,h);if(v!==null&&m===v)O.removeAttribute(h)}}}let w={...X};for(let I of j6){let h=O.getAttribute(I);if(h!==null)w[I]=h}let R=O.tagName.toLowerCase(),B=i6[R]||i6[G(R)];for(let I of[...O.children])if(i(I)){if(I.tagName.includes(":"))continue;let h=I.tagName.toLowerCase(),m=I.getAttribute("id"),v=K&&m,x=(y)=>{let T=y.getAttribute("id");if(T&&Q.has(T))return!0;for(let d of y.children||[])if(i(d)&&x(d))return!0;return!1};if(!F.includes(h)){if(!x(I)&&!v){O.removeChild(I);continue}}if(B&&!B.has(h)&&!B.has(G(h))){if(!x(I)&&!v){O.removeChild(I);continue}}Y(I,w)}};return Y($,{}),$}),R8=G0(($,J={})=>{let Z=["x","y","width","height","viewBox"],K=(Q)=>{if(Q.tagName==="g"){for(let H of Z)if(Q.hasAttribute(H))Q.removeAttribute(H)}for(let H of Q.children)if(i(H))K(H)};return K($),$}),B8=G0(($,J={})=>{let Z=$.getElementsByTagName("defs");for(let K of[...Z])if(K.children.length===0){if(K.parentNode)K.parentNode.removeChild(K)}return $}),K$=G0(($,J={})=>{let Z=J.force||!1,K=$.querySelectorAll("script").length>0,Q=new Set,H=(G)=>{for(let F of G.getAttributeNames()){let _=G.getAttribute(F);if(_&&_.includes("url(#")){let U=_.matchAll(/url\(#([^)]+)\)/g);for(let M of U)Q.add(M[1])}if((F==="href"||F==="xlink:href")&&_&&_.startsWith("#"))Q.add(_.substring(1))}for(let F of G.children)if(i(F))H(F)};H($);let z=(G)=>{let F=G.getAttribute("href")||G.getAttribute("xlink:href");if(F&&F.startsWith("#"))return!0;for(let _ of G.getAttributeNames?G.getAttributeNames():[]){let U=G.getAttribute(_);if(U&&U.includes("url(#"))return!0}return!1},q=(G)=>{for(let F of G.children){if(!i(F))continue;let _=F.tagName?.toLowerCase();if(o6.animation.has(_))return!0;if(q(F))return!0}return!1},j=(G)=>{let F=G.getAttribute("id");if(F&&(Q.has(F)||K))return!0;for(let _ of G.children){if(!i(_))continue;if(j(_))return!0}return!1},W=(G,F=!1)=>{let _=G.tagName.toLowerCase(),U=F||_==="defs",M=G.getAttribute("display"),V=G.getAttribute("visibility"),Y=parseFloat(G.getAttribute("opacity")||"1");if(M==="none"||V==="hidden"||Y===0){if(!Z&&j(G));else if(!Z&&_==="marker");else if(!Z&&(G.getAttribute("marker-start")||G.getAttribute("marker-mid")||G.getAttribute("marker-end")));else if(!Z&&U&&o6.nonRendering.has(_));else if(!Z&&o6.animation.has(_));else if(!Z&&q(G));else if(!Z&&_==="use");else if(!Z&&z(G));else if(G.parentNode){G.parentNode.removeChild(G);return}}for(let X of[...G.children])if(i(X))W(X,U)};return W($),$}),N8=G0(($,J={})=>{let Z=$.getElementsByTagName("text"),K=(z)=>{let q=z.textContent||"";if(z.children)for(let j of z.children)q+=K(j);return q},Q=(z,q)=>{if(!q||q.length===0)return!1;return(z.getAttributeNames?z.getAttributeNames():[]).some((W)=>q.some((G)=>W.startsWith(G+":")))},H=J.preserveNamespaces||[];for(let z of[...Z]){let q=K(z),j=!q||q.trim()==="",W=Q(z,H);if(j&&!W){if(z.parentNode)z.parentNode.removeChild(z)}}return $}),Z$=G0(($,J={})=>{let Z=["g","defs","symbol","marker","clipPath","clippath","mask","pattern"],K=$.querySelectorAll("script").length>0,Q=new Set,H=(q)=>{for(let j of q.getAttributeNames?q.getAttributeNames():[]){let W=q.getAttribute(j);if(W&&W.includes("url(#")){let G=W.matchAll(/url\(#([^)]+)\)/g);for(let F of G)Q.add(F[1])}if((j==="href"||j==="xlink:href")&&W&&W.startsWith("#"))Q.add(W.substring(1))}for(let j of q.children||[])if(i(j))H(j)};H($);let z=(q)=>{for(let G of[...q.children])if(i(G))z(G);let j=q.tagName?.toLowerCase();if(!Z.includes(q.tagName)&&!Z.includes(j))return;if(q.getAttribute("href")||q.getAttribute("xlink:href"))return;let W=q.getAttribute("id");if(W&&(Q.has(W)||K))return;if(q.children.length===0){if(q.parentNode)q.parentNode.removeChild(q)}};return z($),$}),C8=G0(($,J={})=>{return $}),I8=G0(($,J={})=>{return $}),Q$=G0(($,J={})=>{return $}),H$=G0(($,J={})=>{if(J.preserveVendor)return $;let Z=$.getElementsByTagName("metadata");for(let K of[...Z])if(K.parentNode)K.parentNode.removeChild(K);return $}),P8=G0(($,J={})=>{let Z=$.getElementsByTagName("title");for(let K of[...Z])if(K.parentNode)K.parentNode.removeChild(K);return $}),A8=G0(($,J={})=>{let Z=$.getElementsByTagName("desc");for(let K of[...Z])if(K.parentNode)K.parentNode.removeChild(K);return $}),K9=G0(($,J={})=>{if(J.preserveVendor===!0)return $;let Z=J.preserveNamespaces||[],K=new Set(Z);if(K.has("sodipodi"))K.add("inkscape");if(K.has("inkscape"))K.add("sodipodi");let Q=["inkscape","sodipodi","illustrator","sketch","ai","serif","vectornator","figma"].filter((W)=>!K.has(W));if(Q.length===0)return $;let H=(W)=>{for(let G of[...W.children])if(i(G)){let F=G.tagName.indexOf(":");if(F>0){let _=G.tagName.substring(0,F);if(Q.includes(_)){W.removeChild(G);continue}}H(G)}};H($);let z=(W)=>{for(let G of[...W.getAttributeNames()]){if(G.startsWith("xmlns:"))continue;let F=G.indexOf(":");if(F>0){let _=G.substring(0,F);if(Q.includes(_))W.removeAttribute(G)}}for(let G of W.children)if(i(G))z(G)};z($);let q=new Set,j=(W)=>{for(let F of W.getAttributeNames()){if(F.startsWith("xmlns:"))continue;let _=F.indexOf(":");if(_>0){let U=F.substring(0,_);q.add(U)}}let G=W.tagName.indexOf(":");if(G>0)q.add(W.tagName.substring(0,G));for(let F of W.children)if(i(F))j(F)};j($);for(let W of Q){let G=`xmlns:${W}`;if($.hasAttribute(G)&&!q.has(W))$.removeAttribute(G)}return $}),E8=G0(($,J={})=>{let Z=(K)=>{for(let Q of[...K.getAttributeNames()]){let H=K.getAttribute(Q);if(H===""||H===null)K.removeAttribute(Q)}for(let Q of K.children)if(i(Q))Z(Q)};return Z($),$}),T8=G0(($,J={})=>{let{removeFlowText:Z=!0,removeEmptyDefs:K=!0,removeEmptyGroups:Q=!1}=J,H=["inkscape","sodipodi"],z=["flowRoot","flowPara","flowRegion","flowSpan","flowDiv","flowLine"],q=(W)=>{for(let G of[...W.children])if(i(G)){let F=G.tagName.indexOf(":");if(F>0){let _=G.tagName.substring(0,F);if(H.includes(_)){W.removeChild(G);continue}}q(G)}};if(q($),Z){let W=(G)=>{for(let F of[...G.children])if(i(F)){if(z.includes(F.tagName)){G.removeChild(F);continue}W(F)}};W($)}let j=(W)=>{for(let G of[...W.getAttributeNames()]){if(G.startsWith("xmlns:"))continue;let F=G.indexOf(":");if(F>0){let _=G.substring(0,F);if(H.includes(_))W.removeAttribute(G)}}for(let G of W.children)if(i(G))j(G)};j($);for(let W of H)$.removeAttribute(`xmlns:${W}`);if(K){let W=(G)=>{for(let F of[...G.children])if(i(F))if(F.tagName==="defs"&&F.children.length===0)G.removeChild(F);else W(F)};W($)}if(Q){let W=(G)=>{let F=!0;while(F){F=!1;for(let _ of[...G.children])if(i(_))if(_.tagName==="g"&&_.children.length===0){let U=_.hasAttribute("id"),M=_.hasAttribute("class");if(!U&&!M)G.removeChild(_),F=!0}else W(_)}};W($)}return $}),b8=G0(($,J={})=>{let Z=$.getAttribute("width"),K=$.getAttribute("height"),Q=$.getAttribute("viewBox");if(p7(Z)||p7(K))return $;if(Z&&K&&Q){let H=Q.split(/[\s,]+/).map(parseFloat),z=parseFloat(Z),q=parseFloat(K);if(isNaN(z)||isNaN(q)||H.some((W)=>isNaN(W)))return $;let j=0.000001;if(H.length===4&&Math.abs(H[0])<j&&Math.abs(H[1])<j&&Math.abs(H[2]-z)<j&&Math.abs(H[3]-q)<j)$.removeAttribute("viewBox")}return $}),f8=G0(($,J={})=>{let Z=J.preserveSvgNamespace!==!1,K=J.removeXlinkNamespace!==!1;if(J.preserveVendor){if(!Z)$.removeAttribute("xmlns");return $}if(!Z)$.removeAttribute("xmlns");if(K){let Q=!1,H=(z)=>{for(let q of z.getAttributeNames())if(q.startsWith("xlink:")){Q=!0;return}for(let q of z.children){if(i(q))H(q);if(Q)return}};if(H($),!Q)$.removeAttribute("xmlns:xlink")}return $.removeAttribute("xmlns:svg"),$}),S8=G0(($,J={})=>{let Z=$.querySelectorAll("script").length>0,K=new Set,Q=(z)=>{for(let q of z.getAttributeNames()){let j=z.getAttribute(q);if(j&&j.includes("url(#")){let W=j.matchAll(/url\(#([^)]+)\)/g);for(let G of W)K.add(G[1])}if((q==="href"||q==="xlink:href")&&j&&j.startsWith("#"))K.add(j.substring(1))}for(let q of z.children)if(i(q))Q(q)};Q($);let H=$.getElementsByTagName("image");for(let z of[...H]){let q=z.getAttribute("id");if(q&&(K.has(q)||Z))continue;if(z.parentNode)z.parentNode.removeChild(z)}return $}),v8=G0(($,J={})=>{let Z=new Set,K=(H)=>{for(let z of H.getAttributeNames()){let q=H.getAttribute(z);if(q&&q.includes("url(#")){let j=q.matchAll(/url\(#([^)]+)\)/g);for(let W of j)Z.add(W[1])}if((z==="href"||z==="xlink:href")&&q&&q.startsWith("#"))Z.add(q.substring(1))}for(let z of H.children)if(i(z))K(z)};K($);let Q=$.getElementsByTagName("script");for(let H of[...Q]){let z=H.getAttribute("id");if(!z||!Z.has(z)){if(H.parentNode)H.parentNode.removeChild(H)}}return $}),D8=G0(($,J={})=>{let Z=J.precision||6,K=J.convertRoundedRects||!1,Q=["rect","circle","ellipse","line","polyline","polygon"],H=(z)=>{if(Q.includes(z.tagName)){if(z.tagName==="rect"){let j=parseFloat(z.getAttribute("x")||"0"),W=parseFloat(z.getAttribute("y")||"0"),G=parseFloat(z.getAttribute("width")||"0"),F=parseFloat(z.getAttribute("height")||"0");if(isNaN(j)||isNaN(W)||isNaN(G)||isNaN(F)){for(let _ of[...z.children])if(i(_))H(_);return}}if(z.tagName==="rect"&&!K){let j=parseFloat(z.getAttribute("rx")||"0"),W=parseFloat(z.getAttribute("ry")||"0");if(isNaN(j)||isNaN(W)||j>0||W>0){for(let G of[...z.children])if(i(G))H(G);return}}if(z.tagName==="polyline"||z.tagName==="polygon"){if((z.getAttribute("points")||"").trim().split(/[\s,]+/).length<4){for(let G of[...z.children])if(i(G))H(G);return}}let q=V5(z,Z);if(q){let j=new B0("path",{d:q});for(let W of z.getAttributeNames())if(!W.match(/^(x|y|cx|cy|r|rx|ry|width|height|x1|y1|x2|y2|points)$/)){let G=z.getAttribute(W);if(G!==null)j.setAttribute(W,G)}for(let W of[...z.children])j.appendChild(W);if(z.parentNode)z.parentNode.replaceChild(j,z)}}for(let q of[...z.children])if(i(q))H(q)};return H($),$}),h8=G0(($,J={})=>{let Z=J.precision||6,K=J.force||!1,Q=new Set,H=(q)=>{for(let j of["href","xlink:href"]){let W=q.getAttribute(j);if(W&&W.startsWith("#"))Q.add(W.substring(1))}for(let j of q.children)if(i(j))H(j)};H($);let z=$.getElementsByTagName("path");for(let q of z){let j=q.getAttribute("d");if(!j)continue;let W=q.getAttribute("id");if(!K&&W&&Q.has(W))continue;if(!K&&q.getAttribute("style"))continue;let G=q.getAttribute("stroke-linecap"),F=G&&G!=="butt";if((j.match(/[MmLlHhVvCcSsQqTtAaZz]/g)||[]).length<=1)continue;if(!K&&q.getAttribute("marker-mid"))continue;let U=U5(j);q.setAttribute("d",U)}return $}),y8=G0(($,J={})=>{let Z=J.precision||6,K=J.force||!1,Q=(H)=>{let z=H.getAttribute("transform");if(z){let q=J7(z),j=B5(q,Z);if(!K&&j.length>=z.length);else if(!K&&H.getAttribute("stroke")&&H.getAttribute("stroke")!=="none"){let W=q.data[0][0].toNumber(),G=q.data[0][1].toNumber(),F=q.data[1][0].toNumber(),_=q.data[1][1].toNumber(),U=W*_-G*F,M=Math.abs(W-_)<0.000001&&Math.abs(G+F)<0.000001,V=0.0000000001;if(!M&&Math.abs(U)>0.0000000001);else H.setAttribute("transform",j)}else H.setAttribute("transform",j)}for(let q of H.children)if(i(q))Q(q)};return Q($),$}),z$=G0(($,J={})=>{let Z=["fill","stroke","stop-color","flood-color","lighting-color"],K=(H)=>{if(!H||typeof H!=="string")return H;let z={white:"#fff",black:"#000",red:"#f00",green:"#0f0",blue:"#00f",yellow:"#ff0",cyan:"#0ff",magenta:"#f0f"};if(z[H.toLowerCase()])return z[H.toLowerCase()];let q=H.match(/^#([0-9a-f]{6})$/i);if(q){let j=q[1];if(j[0]===j[1]&&j[2]===j[3]&&j[4]===j[5])return`#${j[0]}${j[2]}${j[4]}`}return H},Q=(H)=>{for(let z of Z){let q=H.getAttribute(z);if(q)H.setAttribute(z,K(q))}for(let z of H.children)if(i(z))Q(z)};return Q($),$}),Z9=G0(($,J={})=>{let Z=J.preserveVendor||!1,K=new Set(["alignment-baseline","baseline-shift","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cursor","direction","display","dominant-baseline","enable-background","fill","fill-opacity","fill-rule","filter","flood-color","flood-opacity","font","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","glyph-orientation-horizontal","glyph-orientation-vertical","image-rendering","kerning","letter-spacing","lighting-color","marker","marker-end","marker-mid","marker-start","mask","opacity","overflow","pointer-events","shape-rendering","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-anchor","text-decoration","text-rendering","transform","transform-origin","unicode-bidi","vector-effect","visibility","word-spacing","writing-mode"]),Q=(H)=>{let z=H.getAttribute("style");if(z){let q=z.split(";").map((W)=>W.trim()).filter((W)=>W),j=[];for(let W of q){let G=W.indexOf(":");if(G===-1)continue;let F=W.substring(0,G).trim(),_=W.substring(G+1).trim();if(F&&_){if(!F.startsWith("-")&&K.has(F))H.setAttribute(F,_);else if(Z&&F.startsWith("-"))j.push(W)}}if(j.length>0)H.setAttribute("style",j.join("; "));else H.removeAttribute("style")}for(let q of H.children)if(i(q))Q(q)};return Q($),$}),u8=G0(($,J={})=>{let Z=$.getElementsByTagName("ellipse");for(let K of[...Z]){let Q=parseFloat(K.getAttribute("rx")||"0"),H=parseFloat(K.getAttribute("ry")||"0");if(isNaN(Q)||isNaN(H))continue;if(Math.abs(Q-H)<0.001){let z=new B0("circle",{});for(let q of K.getAttributeNames()){let j=K.getAttribute(q);if(q==="rx"||q==="ry")z.setAttribute("r",j);else z.setAttribute(q,j)}for(let q of[...K.children])z.appendChild(q);if(K.parentNode)K.parentNode.replaceChild(z,K)}}return $}),g8=G0(($,J={})=>{let Z=J.force||!1,K=(Q,H=!1,z=!1)=>{let q=Q.tagName.toLowerCase(),j=z||q==="switch";for(let W of[...Q.children])if(i(W))K(W,!1,j);if(q!=="g")return;if(!Z&&(H||j))return;if(!Z&&Q.getAttribute("filter"))return;if(Q.children.length===1){let W=Q.children[0];if(!i(W))return;if(!Z&&W.getAttribute("id"))return;let G=Array.from(Q.children).some((U)=>i(U)&&o6.animation.has(U.tagName.toLowerCase()));if(!Z&&G)return;let F=Q.getAttributeNames(),_=F.some((U)=>{if(j6.has(U))return!1;return W.hasAttribute(U)});if(!Z&&_)return;if(F.length===0){if(Q.parentNode)Q.parentNode.replaceChild(W,Q)}else{let U=!0;for(let M of F){if(!j6.has(M)&&M!=="class"&&M!=="style"){U=!1;break}if(W.hasAttribute(M)){U=!1;break}}if(U&&Q.parentNode){for(let M of F){let V=Q.getAttribute(M);if(V!==null)W.setAttribute(M,V)}Q.parentNode.replaceChild(W,Q)}}}};return K($,!0),$}),x8=G0(($,J={})=>{let Z=J.force||!1,K=(H)=>H&&H.includes("url("),Q=(H)=>{let z=[...H.children].filter((q)=>i(q)&&q.tagName==="path");for(let q=0;q<z.length-1;q++){let j=z[q],W=z[q+1];if(!Z&&(j.children.length>0||W.children.length>0))continue;let F=["marker-start","marker-mid","marker-end"].some((M)=>j.getAttribute(M)||W.getAttribute(M));if(!Z&&F)continue;if(!Z&&(j.getAttribute("clip-path")||j.getAttribute("mask")||W.getAttribute("clip-path")||W.getAttribute("mask")))continue;if(!Z){let M=j.getAttribute("fill"),V=j.getAttribute("stroke"),Y=W.getAttribute("fill"),O=W.getAttribute("stroke");if(K(M)||K(V)||K(Y)||K(O))continue}if(!Z){let M=j.getAttribute("fill-rule")||"nonzero",V=W.getAttribute("fill-rule")||"nonzero";if(M!==V)continue}if(!Z&&(j.getAttribute("filter")||W.getAttribute("filter")))continue;let _=j.getAttributeNames().filter((M)=>M!=="d").sort(),U=W.getAttributeNames().filter((M)=>M!=="d").sort();if(JSON.stringify(_)===JSON.stringify(U)){let M=!0;for(let V of _)if(j.getAttribute(V)!==W.getAttribute(V)){M=!1;break}if(M){let V=j.getAttribute("d"),Y=W.getAttribute("d");if(j.setAttribute("d",`${V} ${Y}`),W.parentNode)W.parentNode.removeChild(W);z.splice(q+1,1),q--}}}for(let q of H.children)if(i(q))Q(q)};return Q($),$}),m8=G0(($,J={})=>{let Z=(K)=>{if(K.tagName==="g")for(let Q of[...K.getAttributeNames()]){if(!j6.has(Q))continue;let H=K.getAttribute(Q);if(H){for(let z of K.children)if(i(z)&&!z.hasAttribute(Q))z.setAttribute(Q,H);K.removeAttribute(Q)}}for(let Q of K.children)if(i(Q))Z(Q)};return Z($),$}),d8=G0(($,J={})=>{let Z=(K)=>{if(K.tagName==="g"&&K.children.length>1)for(let Q of j6){let H=null,z=!0;for(let q of K.children){if(!i(q))continue;let j=q.getAttribute(Q);if(!j){z=!1;break}if(H===null)H=j;else if(H!==j){z=!1;break}}if(z&&H){K.setAttribute(Q,H);for(let q of K.children)if(i(q))q.removeAttribute(Q)}}for(let Q of K.children)if(i(Q))Z(Q)};return Z($),$}),Q9=G0(($,J={})=>{if($.getElementsByTagName("script").length>0&&!J.force)return $;let K=$.getElementsByTagName("style");for(let Q of K){let H=Q.textContent;if(!H||!H.trim())continue;let z=H.includes("<![CDATA[")||H.includes("]]>"),q="",j="";if(z){let W=H.match(/^(\s*<!\[CDATA\[\s*)/),G=H.match(/(\s*\]\]>\s*)$/);if(W)q="<![CDATA[",H=H.replace(/^\s*<!\[CDATA\[\s*/,"");if(G)j="]]>",H=H.replace(/\s*\]\]>\s*$/,"")}if(H=H.replace(/\/\*[\s\S]*?\*\//g,""),H=H.replace(/\s+/g," "),H=H.replace(/\s*([{}:;,])\s*/g,"$1"),H=H.trim(),q||j)H=q+H+j;Q.textContent=H}return $}),p8=G0(($,J={})=>{let Z=J.onlyMatchedOnce!==!1,K=J.removeStyleElement!==!1,Q=$.getElementsByTagName("style"),H=[];for(let z of Q){let q=z.getAttribute("type");if(q&&q!=="text/css")continue;let j=z.textContent;if(!j||!j.trim())continue;if(j.includes("@media")||j.includes("@keyframes")||j.includes("@supports")||j.includes("@font-face"))continue;let W=j.match(/([^{]+)\{([^}]+)\}/g)||[],G=[];for(let U of W){let M=U.match(/([^{]+)\{([^}]+)\}/);if(!M)continue;let V=M[1].trim(),Y=M[2].trim(),O=!1;for(let w of fK.preventInlining)if(V.includes(w)){O=!0;break}if(O){H.push(U);continue}let X;try{X=L$(V)}catch(w){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${w.message}`);H.push(U);continue}G.push({selector:V,declarations:Y,specificity:X,originalRule:U})}G.sort((U,M)=>k$(U.specificity,M.specificity));let F=new WeakMap,_=new Set;for(let{selector:U,declarations:M,specificity:V,originalRule:Y}of G)try{let O=$.querySelectorAll(U);if(Z&&U.startsWith("#")&&O.length>1){H.push(Y);continue}for(let X of O){let w=X,R=!1;while(w){if(w.tagName==="foreignObject"){R=!0;break}w=w.parentNode}if(R)continue;if(!F.has(X))F.set(X,new Map),_.add(X);let B=F.get(X),I=X.getAttribute("style")||"";if(I&&B.size===0){let m=I.split(";");for(let v of m){let x=v.indexOf(":");if(x>0){let y=v.substring(0,x).trim(),T=v.substring(x+1).trim(),d=T.includes("!important");if(d)T=T.replace(/\s*!important\s*/g,"").trim();B.set(y,{specificity:[1,0,0,0],isImportant:d,value:T})}}}let h=M.split(";");for(let m of h){let v=m.indexOf(":");if(v<=0)continue;let x=m.substring(0,v).trim(),y=m.substring(v+1).trim(),T=y.includes("!important");if(T)y=y.replace(/\s*!important\s*/g,"").trim();let d=B.get(x);if(d){let p=k$(V,d.specificity);if(p<0){if(T&&!d.isImportant)B.set(x,{specificity:V,isImportant:T,value:y})}else if(p===0){if(T||!d.isImportant)B.set(x,{specificity:V,isImportant:T,value:y})}else if(!d.isImportant||T)B.set(x,{specificity:V,isImportant:T,value:y})}else B.set(x,{specificity:V,isImportant:T,value:y})}}}catch(O){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${O.message}`);H.push(Y)}for(let U of _){let M=F.get(U),V=[];for(let[Y,{value:O,isImportant:X}]of M)if(X)V.push(`${Y}: ${O} !important`);else V.push(`${Y}: ${O}`);U.setAttribute("style",V.join("; "))}if(K&&z.parentNode)if(H.length>0)z.textContent=H.join(`
20
+ `);else z.parentNode.removeChild(z)}return $}),c8=G0(($,J={})=>{let Z=(K)=>{let Q=K.getAttributeNames().sort(),H=Q.map((z)=>[z,K.getAttribute(z)]);for(let z of Q)K.removeAttribute(z);for(let[z,q]of H)K.setAttribute(z,q);for(let z of K.children)if(i(z))Z(z)};return Z($),$}),l8=G0(($,J={})=>{let Z=$.getElementsByTagName("defs");for(let K of Z){let Q=[...K.children].filter((H)=>i(H));Q.sort((H,z)=>H.tagName.localeCompare(z.tagName));for(let H of[...K.children])K.removeChild(H);for(let H of Q)K.appendChild(H)}return $}),n8=G0(($,J={})=>{let Z=J.threshold||2,K=$.getElementsByTagName("path"),Q=new Map;for(let q of K){let j=q.getAttribute("d");if(j){if(!Q.has(j))Q.set(j,[]);Q.get(j).push(q)}}let H=$.querySelector("defs");if(!H)if(H=new B0("defs",{}),$.firstChild)$.insertBefore(H,$.firstChild);else $.appendChild(H);let z=0;for(let[q,j]of Q)if(j.length>=Z){let W=`path${z++}`,G=new B0("path",{id:W,d:q});H.appendChild(G);for(let F of j){let _=new B0("use",{href:`#${W}`});for(let U of F.getAttributeNames())if(U!=="d"){let M=F.getAttribute(U);if(M!==null)_.setAttribute(U,M)}for(let U of[...F.children])_.appendChild(U);if(F.parentNode)F.parentNode.replaceChild(_,F)}}return $}),s8=G0(($,J={})=>{let Z=$.getAttribute("viewBox");if(!Z)return $;let K=j5(Z);if(!K)return $;let Q=t7($),H=$.getElementsByTagName("path");for(let z of[...H]){let q=z.getAttribute("d");if(!q)continue;try{let j=g6(q),W=G5(j);if(!W)continue;let G=p6(z),_=d6(z,G,Q).getRenderedBBox(W),U={x:_.x,y:_.y,width:_.width,height:_.height};if(!F5(U,K)){if(z.parentNode)z.parentNode.removeChild(z)}}catch(j){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${j.message}`)}}return $}),o8=G0(($,J={})=>{let Z=$.getElementsByTagName("style");for(let K of[...Z])if(K.parentNode)K.parentNode.removeChild(K);return $}),i8=G0(($,J={})=>{let Z={new:"_blank",replace:"_self"},K=!1,Q=(H)=>{for(let z of[...H.getAttributeNames()])if(z.startsWith("xlink:")){let q=z.substring(6),j=H.getAttribute(z);if(q==="href")K=!0;else if(q==="show"){if(!H.hasAttribute("target")){let W=Z[j];if(W)H.setAttribute("target",W)}H.removeAttribute(z)}else if(q==="title"){if(!(H.querySelector&&H.querySelector("title"))&&j){let G=new B0("title",{},[],j);if(typeof H.insertBefore==="function"&&H.firstChild)H.insertBefore(G,H.firstChild);else if(typeof H.appendChild==="function")H.appendChild(G);else if(H.children&&Array.isArray(H.children))H.children.unshift(G),G.parentNode=H}H.removeAttribute(z)}else if(["actuate","type","role","arcrole"].includes(q))H.removeAttribute(z);else K=!0}for(let z of H.children)if(i(z))Q(z)};if(Q($),!K)$.removeAttribute("xmlns:xlink");return $}),r8=G0(($,J={})=>{let Z=J.attributes||{};for(let[K,Q]of Object.entries(Z))$.setAttribute(K,Q);return $}),a8=G0(($,J={})=>{let Z=J.classes||[],K=$.getAttribute("class")||"",Q=K?`${K} ${Z.join(" ")}`:Z.join(" ");return $.setAttribute("class",Q.trim()),$}),t8=G0(($,J={})=>{let Z=J.prefix||"svg",K=new Map,Q=new Map,H=(W)=>W.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),z=(W)=>{let G=W.getAttribute("id");if(G){let F=`${Z}${G}`;K.set(G,F),W.setAttribute("id",F)}for(let F of W.children)if(i(F))z(F)};if(z($),J.prefixClassNames!==!1){let W=(F)=>{let _=F.getAttribute("class");if(_){for(let U of _.split(/\s+/))if(U&&!Q.has(U))Q.set(U,`${Z}${U}`)}for(let U of F.children)if(i(U))W(U)};W($);let G=(F)=>{let _=F.getAttribute("class");if(_){let U=_.split(/\s+/).map((M)=>Q.get(M)||M).join(" ");F.setAttribute("class",U)}for(let U of F.children)if(i(U))G(U)};G($)}let q=$.getElementsByTagName("style");for(let W of q){let G=W.textContent;if(!G)continue;for(let[F,_]of K){let U=H(F);G=G.replace(new RegExp(`#${U}([^\\w-]|$)`,"g"),`#${_}$1`),G=G.replace(new RegExp(`url\\(#${U}\\)`,"g"),`url(#${_})`)}if(J.prefixClassNames!==!1)for(let[F,_]of Q){let U=H(F);G=G.replace(new RegExp(`\\.${U}([^\\w-]|$)`,"g"),`.${_}$1`)}W.textContent=G}let j=(W)=>{for(let G of W.getAttributeNames()){let F=W.getAttribute(G);if(F&&F.includes("url(#")){for(let[_,U]of K){let M=H(_);F=F.replace(new RegExp(`url\\(#${M}\\)`,"g"),`url(#${U})`)}W.setAttribute(G,F)}if((G==="href"||G==="xlink:href")&&F?.startsWith("#")){let _=F.substring(1);if(K.has(_))W.setAttribute(G,`#${K.get(_)}`)}if(G==="begin"||G==="end"){for(let[_,U]of K){let M=H(_);F=F.replace(new RegExp(`(^|;|\\s)${M}\\.`,"g"),`$1${U}.`)}W.setAttribute(G,F)}if(G==="values"||G==="from"||G==="to"||G==="by"){for(let[_,U]of K){let M=H(_);F=F.replace(new RegExp(`#${M}([;\\s]|$)`,"g"),`#${U}$1`)}W.setAttribute(G,F)}}for(let G of W.children)if(i(G))j(G)};return j($),$}),e8=G0(($,J={})=>{return $.removeAttribute("width"),$.removeAttribute("height"),$}),$J=G0(($,J={})=>{let Z=J.selector||"*",K=J.attributes||[];try{let Q=$.querySelectorAll(Z);for(let H of Q)for(let z of K)if(H.hasAttribute(z))H.removeAttribute(z)}catch(Q){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${Q.message}`)}return $}),JJ=G0(($,J={})=>{let Z=J.pattern?new RegExp(J.pattern):null,K=J.attrs||[],Q=(H)=>{for(let z of[...H.getAttributeNames()])if(K.includes(z)||Z&&Z.test(z))H.removeAttribute(z);for(let z of H.children)if(i(z))Q(z)};return Q($),$}),KJ=G0(($,J={})=>{let{name:Z,value:K}=J;if(!Z)return $;let Q=(H)=>{for(let z of[...H.children]){if(!i(z))continue;let q=z.getAttribute(Z);if(K===void 0){if(q!==null){H.removeChild(z);continue}}else if(q===K){H.removeChild(z);continue}Q(z)}};return Q($),$}),H9=G0(async($,J={})=>{let Z={...J,outputFormat:G7.DOM_ELEMENT},K=$;return K=await H$(K,Z),K=await Q$(K,Z),K=await Z$(K,Z),K=await K$(K,Z),K=await J$(K,Z),K=await z$(K,Z),K=await Z9(K,Z),K=await K9(K,Z),K=await J9(K,Z),K=await Q9(K,Z),K}),z9=G0(($,J={})=>{return $}),ZJ=G0(async($,J={})=>{let Z=J.preset||"default",K={...J,outputFormat:G7.DOM_ELEMENT};switch(Z){case"default":return await H9($,K);case"none":return await z9($,K);default:return $}}),QJ=G0(async($,J={})=>{let Z=J.config||{},K={...J,outputFormat:G7.DOM_ELEMENT},Q=$;if(Z.removeMetadata!==!1)Q=await H$(Q,K);if(Z.removeComments!==!1)Q=await Q$(Q,K);if(Z.cleanupNumericValues!==!1)Q=await J$(Q,K);if(Z.convertColors!==!1)Q=await z$(Q,K);if(Z.removeHiddenElements!==!1)Q=await K$(Q,K);if(Z.removeEmptyContainers!==!1)Q=await Z$(Q,K);return Q});function HJ($={}){return{precision:$.precision||6,removeMetadata:$.removeMetadata!==!1,removeComments:$.removeComments!==!1,cleanupNumericValues:$.cleanupNumericValues!==!1,convertColors:$.convertColors!==!1,removeHiddenElements:$.removeHiddenElements!==!1,removeEmptyContainers:$.removeEmptyContainers!==!1,...$}}var zJ=G0(async($,J={})=>{let Z=N7($,{minify:J.minify!==!1}),K=await N6(Z,{...J,resolveClipPaths:!0,resolveUse:!1,resolveMarkers:!1,resolvePatterns:!1,resolveMasks:!1,flattenTransforms:!1,removeUnusedDefs:!1});return p0(K.svg)}),qJ=G0(async($,J={})=>{let Z=N7($,{minify:J.minify!==!1}),K=await N6(Z,{...J,resolveMasks:!0,resolveClipPaths:!1,resolveUse:!1,resolveMarkers:!1,resolvePatterns:!1,flattenTransforms:!1,removeUnusedDefs:!1});return p0(K.svg)}),WJ=G0(($,J={})=>{let Z=t7($),K=(W)=>{let G=Z.get(W);if(!G)return null;let F=G.getAttribute("href")||G.getAttribute("xlink:href");return F?.startsWith("#")?F.substring(1):null},Q=(W,G)=>{let F=W.getAttribute("gradientUnits")||"objectBoundingBox",_=W.getAttribute("gradientTransform");if(az(G,K)){if(J.verbose)console.warn(`Circular gradient reference detected: #${G}`);return!1}if(F==="userSpaceOnUse")return!1;if(_)return!1;return!0},H=x7($,"fill");for(let W of H){let G=W.getAttribute("fill");if(G&&G.includes("url(")){let F=e7(G);if(F&&Z.has(F)){let _=Z.get(F),U=_.tagName.toLowerCase();if(U==="lineargradient"||U==="radialgradient"){if(!Q(_,F)){if(J.verbose)console.warn(`Skipping gradient flatten for ${F}: userSpaceOnUse or gradientTransform requires coordinate transformation`);continue}let M=cK(_,J.position||0.5);W.setAttribute("fill",M)}}else W.setAttribute("fill",J.fallbackColor||"#808080")}}let z=x7($,"stroke");for(let W of z){let G=W.getAttribute("stroke");if(G&&G.includes("url(")){let F=e7(G);if(F&&Z.has(F)){let _=Z.get(F),U=_.tagName.toLowerCase();if(U==="lineargradient"||U==="radialgradient"){if(!Q(_,F)){if(J.verbose)console.warn(`Skipping gradient flatten for ${F}: userSpaceOnUse or gradientTransform requires coordinate transformation`);continue}let M=cK(_,J.position||0.5);W.setAttribute("stroke",M)}}else W.setAttribute("stroke",J.fallbackColor||"#808080")}}let q=[...$.querySelectorAll("linearGradient, radialGradient")],j=(W)=>W.replace(/["\\]/g,"\\$&");for(let W of q){let G=W.getAttribute("id"),F=G?j(G):"";if(!(G&&([...$.querySelectorAll(`[fill*="url(#${F})"]`)].length>0||[...$.querySelectorAll(`[stroke*="url(#${F})"]`)].length>0))&&W.parentNode)W.parentNode.removeChild(W)}return $});function cK($,J=0.5){let Z=[...$.children].filter((q)=>q.tagName&&q.tagName.toLowerCase()==="stop");if(Z.length===0)return"#808080";if(Z.length===1)return lK(Z[0]);let K=Z.map((q)=>{let j=q.getAttribute("offset")||"0";if(j.endsWith("%"))j=parseFloat(j)/100;else j=parseFloat(j);return j=isNaN(j)?0:Math.max(0,Math.min(1,j)),{offset:j,color:lK(q),opacity:tz(q)}});K.sort((q,j)=>q.offset-j.offset);let Q=null,H=null;for(let q=0;q<K.length;q++){let j=K[q];if(j.offset<=J)Q=j;if(j.offset>=J&&!H){H=j;break}}if(!Q)return K[0].color;if(!H)return K[K.length-1].color;if(Q.offset===H.offset)return Q.color;let z=(J-Q.offset)/(H.offset-Q.offset);return $q(Q.color,H.color,z)}function lK($){let J=$.getAttribute("stop-color");if(!J){let Z=$.getAttribute("style");if(Z){let K=Z.match(/stop-color\s*:\s*([^;]+)/i);if(K)J=K[1].trim()}}if(!J)J="#000000";return ez(J)}function tz($){let J=$.getAttribute("stop-opacity");if(!J){let K=$.getAttribute("style");if(K){let Q=K.match(/stop-opacity\s*:\s*([^;]+)/i);if(Q)J=Q[1].trim()}}let Z=J?parseFloat(J):1;return isNaN(Z)?1:Z}function ez($){if(!$||typeof $!=="string")return"#000000";let J=$.trim().toLowerCase();if(J.startsWith("#")){if(J.length===4)return"#"+J[1]+J[1]+J[2]+J[2]+J[3]+J[3];return J}if(J.startsWith("rgb(")){let K=J.match(/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);if(K){let Q=parseInt(K[1],10),H=parseInt(K[2],10),z=parseInt(K[3],10);return tK(Q,H,z)}}let Z={black:"#000000",white:"#ffffff",red:"#ff0000",green:"#008000",blue:"#0000ff",yellow:"#ffff00",cyan:"#00ffff",magenta:"#ff00ff",gray:"#808080",grey:"#808080",silver:"#c0c0c0",maroon:"#800000",olive:"#808000",lime:"#00ff00",aqua:"#00ffff",teal:"#008080",navy:"#000080",fuchsia:"#ff00ff",purple:"#800080"};if(Z[J])return Z[J];return"#000000"}function $q($,J,Z){let K=(U)=>{let M=U.replace("#","");if(M.length===3)M=M[0]+M[0]+M[1]+M[1]+M[2]+M[2];let V=parseInt(M.slice(0,2),16),Y=parseInt(M.slice(2,4),16),O=parseInt(M.slice(4,6),16);if(isNaN(V)||isNaN(Y)||isNaN(O))return[0,0,0];return[V,Y,O]},[Q,H,z]=K($),[q,j,W]=K(J),G=Math.round(Q+(q-Q)*Z),F=Math.round(H+(j-H)*Z),_=Math.round(z+(W-z)*Z);return tK(G,F,_)}function tK($,J,Z){let K=(Q)=>{return Math.max(0,Math.min(255,Math.round(Q))).toString(16).padStart(2,"0")};return"#"+K($)+K(J)+K(Z)}var jJ=G0(async($,J={})=>{let Z=N7($,{minify:J.minify!==!1}),K=await N6(Z,{...J,resolvePatterns:!0,resolveClipPaths:!1,resolveUse:!1,resolveMarkers:!1,resolveMasks:!1,flattenTransforms:!1,removeUnusedDefs:!1});return p0(K.svg)}),GJ=G0(($,J={})=>{let Z=(Q)=>{if(Q.hasAttribute("filter"))Q.removeAttribute("filter");for(let H of Q.children)if(i(H))Z(H)};Z($);let K=$.getElementsByTagName("filter");for(let Q of[...K])if(Q.parentNode)Q.parentNode.removeChild(Q);return $}),FJ=G0(async($,J={})=>{let Z=N7($,{minify:J.minify!==!1}),K=await N6(Z,{...J,resolveUse:!0,resolveClipPaths:!1,resolveMarkers:!1,resolvePatterns:!1,resolveMasks:!1,flattenTransforms:!1,removeUnusedDefs:!1});return p0(K.svg)}),_J=G0(($,J={})=>{let Z=$.getElementsByTagName("image");for(let K of[...Z])K.setAttribute("data-trace-needed","true");return $}),UJ=G0(($,J={})=>{let{samples:Z=10,includeStroke:K=!0,includeFillOnly:Q=!1}=J,H=[...$.getElementsByTagName("path"),...$.getElementsByTagName("rect"),...$.getElementsByTagName("circle"),...$.getElementsByTagName("ellipse")],z=t7($),q=[];for(let j=0;j<H.length;j++)for(let W=j+1;W<H.length;W++){let G=H[j],F=H[W],_=t$(G,Z),U=t$(F,Z);if(!_||!U)continue;let M=p6(G),V=p6(F),Y=d6(G,M,z),O=d6(F,V,z);if(K&&!Q){if(Y.hasStroke){let w=Y.getStrokeExtent().toNumber();_=nK(_,w)}if(O.hasStroke){let w=O.getStrokeExtent().toNumber();U=nK(U,w)}}if(X$(_,U).overlaps)q.push({shape1:G.tagName,shape2:F.tagName,id1:G.getAttribute("id"),id2:F.getAttribute("id"),stroke1:Y.hasStroke?Y.strokeWidth.toNumber():0,stroke2:O.hasStroke?O.strokeWidth.toNumber():0,fillRule1:Y.fillRule,fillRule2:O.fillRule})}if(q.length>0)$.setAttribute("data-collisions",JSON.stringify(q));return $});function nK($,J){if(J<=0||!$||$.length===0)return $;let Z=0,K=0;for(let Q of $)Z+=Q.x,K+=Q.y;return Z/=$.length,K/=$.length,$.map((Q)=>{let H=Q.x-Z,z=Q.y-K,q=Math.sqrt(H*H+z*z);if(q<0.0001)return Q;let j=(q+J)/q;return{x:Z+H*j,y:K+z*j}})}var VJ=G0(($,J={})=>{let{id1:Z,id2:K}=J;if(!Z||!K)return $;let Q=$.getElementById(Z),H=$.getElementById(K);if(!Q||!H)return $;let z=t$(Q,J.samples||10),q=t$(H,J.samples||10);if(z&&q){let j=H5(z,q);$.setAttribute("data-distance",j.distance.toString())}return $}),MJ=G0(($,J={})=>{let Z=[],K=[],Q=new Set,H=new Set,z=(j)=>{if(j.tagName.includes(":")){let W=j.tagName.split(":")[0];Q.add(W)}for(let W of j.getAttributeNames()){let G=j.getAttribute(W);if(W==="xmlns")H.add("");else if(W.startsWith("xmlns:")){let F=W.substring(6);H.add(F)}if(W.includes(":")&&!W.startsWith("xmlns:")){let F=W.split(":")[0];Q.add(F)}if(G&&/[\x00-\x08\x0B\x0C\x0E-\x1F]/.test(G))Z.push(`Invalid XML characters in attribute '${W}' of <${j.tagName}>`)}if(j.textContent&&/[\x00-\x08\x0B\x0C\x0E-\x1F]/.test(j.textContent))Z.push(`Invalid XML characters in text content of <${j.tagName}>`);for(let W of j.children)if(i(W))z(W)};z($);for(let j of Q)if(j&&!H.has(j))Z.push(`Unbound namespace prefix: '${j}' - SVGO would produce invalid XML here`);let q={valid:Z.length===0,errors:Z,warnings:K,namespacesUsed:[...Q],namespacesDeclared:[...H]};return $.setAttribute("data-xml-validation",JSON.stringify(q)),$}),OJ=G0(($,J={})=>{let Z=[],K=[],Q=J.version||"1.1";if($.tagName!=="svg")Z.push("Root element must be <svg>");let H=$.getAttribute("xmlns");if(!H)K.push("Missing xmlns attribute (required for standalone SVG)");else if(H!=="http://www.w3.org/2000/svg")Z.push(`Invalid SVG namespace: expected 'http://www.w3.org/2000/svg', got '${H}'`);let z=$.getAttribute("viewBox");if(z){let F=z.split(/[\s,]+/);if(F.length!==4)Z.push(`Invalid viewBox: expected 4 values, got ${F.length}`);else if(F.some((_)=>isNaN(parseFloat(_))))Z.push("Invalid viewBox: contains non-numeric values");else{let[_,U,M,V]=F.map(parseFloat);if(M<0||V<0)Z.push("Invalid viewBox: width and height must be non-negative")}}let q={meshGradients:[],hatches:[],solidColors:[],needsPolyfills:!1},j={meshGradient:"meshgradient",meshRow:"meshrow",meshPatch:"meshpatch",hatchPath:"hatchpath",solidColor:"solidcolor"},W=(F,_=0)=>{if(!F||!F.tagName){K.push(`Element at depth ${_} has no tagName property`);return}let U=F.tagName.toLowerCase(),M=F.tagName;if(j[M])Z.push(`Invalid SVG 2.0 element: <${M}> must be lowercase <${j[M]}> per SVG 2.0 specification`);if(U==="meshgradient"){let V=F.getAttribute("id");if(q.meshGradients.push(V||null),q.needsPolyfills=!0,!V)K.push("<meshgradient> element without 'id' attribute may be difficult to reference")}if(U==="hatch"){let V=F.getAttribute("id");if(q.hatches.push(V||null),q.needsPolyfills=!0,!V)K.push("<hatch> element without 'id' attribute may be difficult to reference")}if(U==="solidcolor"){let V=F.getAttribute("id");if(q.solidColors.push(V||null),q.needsPolyfills=!0,!V)K.push("<solidcolor> element without 'id' attribute may be difficult to reference")}if(U==="path"){let V=F.getAttribute("d");if(!V||!V.trim())Z.push("<path> element missing required 'd' attribute");else{let Y=V.match(/[MmLlHhVvCcSsQqTtAaZz]/g);if(!Y||Y.length===0)Z.push("<path> 'd' attribute contains no valid commands");let O=V.trim()[0];if(O!=="M"&&O!=="m")Z.push("<path> 'd' must start with M or m command")}}if(U==="rect"){let V=F.getAttribute("width"),Y=F.getAttribute("height");if(V!==null&&!p7(V)&&parseFloat(V)<0)Z.push("<rect> width must be non-negative");if(Y!==null&&!p7(Y)&&parseFloat(Y)<0)Z.push("<rect> height must be non-negative")}if(U==="circle"){let V=F.getAttribute("r");if(V!==null&&parseFloat(V)<0)Z.push("<circle> r must be non-negative")}if(U==="ellipse"){let V=F.getAttribute("rx"),Y=F.getAttribute("ry");if(V!==null&&parseFloat(V)<0)Z.push("<ellipse> rx must be non-negative");if(Y!==null&&parseFloat(Y)<0)Z.push("<ellipse> ry must be non-negative")}if(U==="use"){let V=F.getAttribute("href")||F.getAttribute("xlink:href");if(V&&V.startsWith("#")){let Y=V.substring(1);if(!$.getElementById(Y))K.push(`<use> references non-existent ID: '${Y}'`)}}for(let V of["fill","stroke","clip-path","mask","filter"]){let Y=F.getAttribute(V);if(Y&&Y.startsWith("url(#")){let O=Y.match(/url\(#([^)]+)\)/);if(O){let X=O[1];if(!$.getElementById(X))K.push(`<${F.tagName}> ${V} references non-existent ID: '${X}'`)}}}if(i6[U]){let V=i6[U];for(let Y of F.children)if(i(Y)){let O=Y.tagName.toLowerCase();if(!V.has(O))K.push(`<${O}> is not a standard child of <${U}>`)}}for(let V of F.children)if(i(V))W(V,_+1)};if(W($),q.needsPolyfills){let F=[];if(q.meshGradients.length>0)F.push(`meshgradient (${q.meshGradients.length} found)`);if(q.hatches.length>0)F.push(`hatch (${q.hatches.length} found)`);if(q.solidColors.length>0)F.push(`solidcolor (${q.solidColors.length} found)`);K.push(`SVG contains SVG 2.0 features that require polyfills for browser compatibility: ${F.join(", ")}. Use --svg2-polyfills option to inject runtime polyfills.`)}let G={valid:Z.length===0,svgVersion:Q,errors:Z,warnings:K,elementsChecked:zZ($),svg2Features:q};if($.setAttribute("data-svg-validation",JSON.stringify(G)),Z.length>0)$.setAttribute("data-validation-errors",JSON.stringify(Z));else $.setAttribute("data-validation-status","valid");return $}),Jq=new Set(["click","dblclick","mousedown","mouseup","mouseover","mouseout","mousemove","mouseenter","mouseleave","focus","blur","focusin","focusout","keydown","keyup","keypress","activate","load","unload","abort","error","resize","scroll","beginEvent","endEvent","repeatEvent","touchstart","touchend","touchmove","touchcancel","wheel","auxclick","input","beforeinput","select","compositionstart","compositionupdate","compositionend"]),eK=G0(($,J={})=>{let Z=J.verbose||!1,K=J.printTables!==!1,Q={valid:!0,timestamp:new Date().toISOString(),media:{hasAudio:!1,hasVideo:!1,audioElements:[],videoElements:[],foreignObjectWithMedia:[],mediaEmbedMethod:null},smil:{hasAnimations:!1,animationCount:0,animationElements:{animate:0,animateTransform:0,animateMotion:0,animateColor:0,set:0},hasInteractiveAnimations:!1,eventTriggers:[],timingTriggers:[]},compatibility:{worksInAllBrowsers:!0,issues:[],recommendations:[]},errors:[],warnings:[],info:[]},H=(V)=>{let Y=[],O=V.toLowerCase(),X=(w)=>{if(w.tagName&&w.tagName.toLowerCase()===O)Y.push(w);for(let R of w.children||[])if(R&&R.tagName)X(R)};return X($),Y},z=(V,Y=[])=>{if(V.tagName)Y.push(V);for(let O of V.children||[])if(O&&O.tagName)z(O,Y);return Y},q=H("audio");if(q.length>0)Q.media.hasAudio=!0,Q.media.audioElements=q.map((V)=>({id:V.getAttribute("id"),src:V.getAttribute("src"),hasSource:H("source").filter((Y)=>Y.parentNode===V).length>0}));let j=H("video");if(j.length>0)Q.media.hasVideo=!0,Q.media.videoElements=j.map((V)=>({id:V.getAttribute("id"),src:V.getAttribute("src")}));let W=H("foreignObject");for(let V of W){let Y=V.children||[],O=!1,X=[],w=(R)=>{let B=R.tagName?.toLowerCase();if(B==="audio"||B==="video")O=!0,X.push({type:B,id:R.getAttribute("id"),src:R.getAttribute("src")});for(let I of R.children||[])if(I&&I.tagName)w(I)};for(let R of Y)if(R&&R.tagName)w(R);if(O)Q.media.hasAudio=!0,Q.media.foreignObjectWithMedia.push({id:V.getAttribute("id"),media:X}),Q.media.mediaEmbedMethod="foreignObject"}let G=z($);for(let V of G)for(let Y of["src","href","xlink:href"]){let O=V.getAttribute(Y);if(O&&O.startsWith("data:audio/"))Q.media.hasAudio=!0,Q.media.mediaEmbedMethod="data-uri";if(O&&O.startsWith("data:video/"))Q.media.hasVideo=!0,Q.media.mediaEmbedMethod="data-uri"}let F=["animate","animateTransform","animateMotion","animateColor","set"];for(let V of F){let Y=H(V),O=Y.length;Q.smil.animationElements[V==="animateTransform"?"animateTransform":V==="animateMotion"?"animateMotion":V==="animateColor"?"animateColor":V]=O,Q.smil.animationCount+=O;for(let X of Y){let w=X.getAttribute("begin")||"",R=X.getAttribute("end")||"",B=(m,v)=>{let x=m.split(";").map((y)=>y.trim()).filter(Boolean);for(let y of x){let T=y.match(/^(?:([a-zA-Z_][a-zA-Z0-9_-]*)\.)?([a-zA-Z]+)(\s*[+-]\s*[\d.]+[smh]?)?$/);if(T){let[,d,p,c]=T;if(Jq.has(p))Q.smil.hasInteractiveAnimations=!0,Q.smil.eventTriggers.push({animationElement:V,animationId:X.getAttribute("id"),attribute:v,event:p,targetId:d||null,offset:c?.trim()||null,parentId:X.parentNode?.getAttribute?.("id")})}else if(/^[\d.]+[smh]?$/.test(y)||y==="indefinite")Q.smil.timingTriggers.push({animationElement:V,value:y});else if(/\.(begin|end)/.test(y))Q.smil.timingTriggers.push({animationElement:V,value:y,type:"syncbase"})}};if(w)B(w,"begin");if(R)B(R,"end");let I=X.getAttribute("onbegin"),h=X.getAttribute("onend");if(I||h){if(Q.smil.hasInteractiveAnimations=!0,I?.includes("play()")||h?.includes("play()"))Q.info.push(`Animation uses JavaScript to trigger audio playback via ${I?"onbegin":"onend"} handler`)}}}if(Q.smil.hasAnimations=Q.smil.animationCount>0,Q.media.hasAudio)Q.compatibility.worksInAllBrowsers=!1,Q.warnings.push("SVG contains embedded audio. Browser autoplay policies will block playback in most scenarios."),Q.compatibility.issues.push({type:"AUDIO_AUTOPLAY_BLOCKED",severity:"HIGH",description:"Embedded audio in SVG is blocked by Chrome/Firefox/Safari autoplay policies",affectedBrowsers:["Chrome","Firefox","Safari","Edge"]}),Q.compatibility.recommendations.push("To enable audio playback, embed the SVG in an HTML page that extracts audio dynamically after user interaction","Use JavaScript to extract audio data URI from foreignObject and create Audio element on click","Consider using Web Audio API for more control over audio playback");if(Q.media.hasVideo)Q.compatibility.worksInAllBrowsers=!1,Q.warnings.push("SVG contains embedded video. This has limited browser support and autoplay restrictions.");if(Q.smil.hasAnimations)Q.info.push(`SVG contains ${Q.smil.animationCount} SMIL animation elements`),Q.compatibility.issues.push({type:"SMIL_IE_UNSUPPORTED",severity:"LOW",description:"SMIL animations are not supported in IE11",affectedBrowsers:["IE (no support)"]});if(Q.smil.hasInteractiveAnimations){let V=[...new Set(Q.smil.eventTriggers.map((Y)=>Y.event))];if(Q.info.push(`SVG contains interactive SMIL animations triggered by: ${V.join(", ")}`),V.includes("click")||V.includes("mouseover"))Q.compatibility.recommendations.push("Interactive animations (click/hover) work in most browsers but require the SVG to be inline or loaded as <object>/<embed>","Using <img> tag to display SVG will disable all interactivity and animations")}let _={Chrome:{smil:"Full support",audio:"Blocked (autoplay policy)",interactive:"Full support",notes:"Autoplay blocked without user gesture"},Firefox:{smil:"Full support",audio:"Blocked (autoplay policy)",interactive:"Full support",notes:"MEI (Media Engagement Index) affects autoplay"},Safari:{smil:"Full support",audio:"Blocked (autoplay policy)",interactive:"Full support",notes:"Strict autoplay policy"},Edge:{smil:"Full support",audio:"Blocked (autoplay policy)",interactive:"Full support",notes:"Chromium-based, same as Chrome"},"IE 11":{smil:"No support",audio:"No support",interactive:"No support",notes:"Use CSS animations or JavaScript"}},U=[{scenario:"Standalone SVG",protocol:"file://",example:"file:///path/to/sample.svg",smilWorks:!0,audioWorks:!1,interactiveWorks:!0,notes:"SMIL works, audio blocked by autoplay policy"},{scenario:"Standalone SVG",protocol:"http://",example:"http://localhost/sample.svg",smilWorks:!0,audioWorks:!1,interactiveWorks:!0,notes:"SMIL works, audio blocked by autoplay policy"},{scenario:"SVG in HTML via <img>",protocol:"any",example:'<img src="sample.svg">',smilWorks:!1,audioWorks:!1,interactiveWorks:!1,notes:"All scripting and interactivity disabled"},{scenario:"SVG in HTML via <object>",protocol:"any",example:'<object data="sample.svg">',smilWorks:!0,audioWorks:!1,interactiveWorks:!0,notes:"Full SVG features, audio still blocked"},{scenario:"SVG in HTML via <embed>",protocol:"any",example:'<embed src="sample.svg">',smilWorks:!0,audioWorks:!1,interactiveWorks:!0,notes:"Full SVG features, audio still blocked"},{scenario:"Inline SVG in HTML",protocol:"any",example:"<svg>...</svg> in HTML",smilWorks:!0,audioWorks:!1,interactiveWorks:!0,notes:"Full features, audio needs user gesture"},{scenario:"HTML extracts audio on click",protocol:"file://",example:"JS extracts data-uri, plays on click",smilWorks:!0,audioWorks:!0,interactiveWorks:!0,notes:"WORKS - user gesture enables audio"},{scenario:"HTML extracts audio on click",protocol:"http://",example:"JS extracts data-uri, plays on click",smilWorks:!0,audioWorks:!0,interactiveWorks:!0,notes:"WORKS - user gesture enables audio"}],M=[{trigger:'begin="click"',description:"Animation starts on click (on animation target)",syntax:'<animate begin="click" .../>',browserSupport:"Chrome, Firefox, Safari, Edge",notes:"Target element must be clickable (not in <defs>)"},{trigger:'begin="elementId.click"',description:"Animation starts when another element is clicked",syntax:'<animate begin="button.click" .../>',browserSupport:"Chrome, Firefox, Safari, Edge",notes:"Referenced element must exist with matching id"},{trigger:'begin="mouseover"',description:"Animation starts on mouse hover",syntax:'<animate begin="mouseover" .../>',browserSupport:"Chrome, Firefox, Safari, Edge",notes:"Often paired with mouseout for hover effects"},{trigger:'begin="elementId.mouseover"',description:"Animation starts when hovering another element",syntax:'<animate begin="trigger.mouseover" .../>',browserSupport:"Chrome, Firefox, Safari, Edge",notes:"Useful for triggering animations on related elements"},{trigger:'begin="mouseout"',description:"Animation starts when mouse leaves",syntax:'<animate begin="mouseout" .../>',browserSupport:"Chrome, Firefox, Safari, Edge",notes:"Use with mouseover for complete hover cycle"},{trigger:'begin="focus"',description:"Animation starts when element receives focus",syntax:'<animate begin="focus" .../>',browserSupport:"Chrome, Firefox, Safari, Edge",notes:"Works with focusable elements (links, inputs)"},{trigger:'begin="accessKey(s)"',description:"Animation starts on keyboard shortcut",syntax:'<animate begin="accessKey(s)" .../>',browserSupport:"Limited",notes:"Press Alt+S (Windows) or Ctrl+Opt+S (Mac)"}];if(Q.tables={browserSupport:_,usageScenarios:U,smilEventScenarios:M},K&&(Q.media.hasAudio||Q.media.hasVideo||Q.smil.hasInteractiveAnimations)){if(console.log(`
21
21
  `+"=".repeat(80)),console.log("SVG COMPATIBILITY ANALYSIS REPORT"),console.log("=".repeat(80)),console.log(`
22
22
  --- SUMMARY ---`),console.log(`SMIL Animations: ${Q.smil.animationCount} (${Q.smil.hasInteractiveAnimations?"includes interactive":"time-based only"})`),console.log(`Audio Elements: ${Q.media.hasAudio?"YES":"NO"}`),console.log(`Video Elements: ${Q.media.hasVideo?"YES":"NO"}`),Q.media.hasAudio)console.log(`
23
23
  --- AUDIO PLAYBACK WARNING ---`),console.log("This SVG contains embedded audio which will be BLOCKED by browser autoplay policies."),console.log("Audio will NOT play automatically in any browser without user interaction.");console.log(`
24
- --- BROWSER SUPPORT ---`),console.log("┌─────────────┬────────────────────┬──────────────────────────┬─────────────┐"),console.log("│ Browser │ SMIL Animations │ Audio Autoplay │ Interactive │"),console.log("├─────────────┼────────────────────┼──────────────────────────┼─────────────┤");for(let[V,M]of Object.entries(_)){let Y=V.padEnd(11),X=M.smil.padEnd(18),w=M.audio.padEnd(24),R=M.interactive.padEnd(11);console.log(`│ ${Y} │ ${X} │ ${w} │ ${R} │`)}console.log("└─────────────┴────────────────────┴──────────────────────────┴─────────────┘"),console.log(`
25
- --- USAGE SCENARIOS ---`),console.log("┌────────────────────────────────┬───────────┬───────┬───────┬─────────────┐"),console.log("│ Scenario │ Protocol │ SMIL │ Audio │ Interactive │"),console.log("├────────────────────────────────┼───────────┼───────┼───────┼─────────────┤");for(let V of U){let M=V.scenario.substring(0,30).padEnd(30),Y=V.protocol.padEnd(9),X=(V.smilWorks?"✅":"❌").padEnd(5),w=(V.audioWorks?"✅":"❌").padEnd(5),R=(V.interactiveWorks?"✅":"❌").padEnd(11);console.log(`│ ${M} │ ${Y} │ ${X} │ ${w} │ ${R} │`)}if(console.log("└────────────────────────────────┴───────────┴───────┴───────┴─────────────┘"),Q.smil.hasInteractiveAnimations){console.log(`
26
- --- SMIL INTERACTIVE EVENT TRIGGERS ---`),console.log("┌───────────────────────────────┬────────────────────────────────────────────┐"),console.log("│ Trigger Syntax │ Description │"),console.log("├───────────────────────────────┼────────────────────────────────────────────┤");for(let V of O){let M=V.trigger.padEnd(29),Y=V.description.substring(0,42).padEnd(42);console.log(`│ ${M} │ ${Y} │`)}if(console.log("└───────────────────────────────┴────────────────────────────────────────────┘"),Q.smil.eventTriggers.length>0){console.log(`
27
- --- DETECTED INTERACTIVE TRIGGERS IN THIS SVG ---`);for(let V of Q.smil.eventTriggers){let M=V.targetId?`${V.targetId}.${V.event}`:V.event;console.log(` - <${V.animationElement}> triggered by: ${M}${V.offset?` ${V.offset}`:""}`)}}}if(Q.compatibility.recommendations.length>0){console.log(`
24
+ --- BROWSER SUPPORT ---`),console.log("┌─────────────┬────────────────────┬──────────────────────────┬─────────────┐"),console.log("│ Browser │ SMIL Animations │ Audio Autoplay │ Interactive │"),console.log("├─────────────┼────────────────────┼──────────────────────────┼─────────────┤");for(let[V,Y]of Object.entries(_)){let O=V.padEnd(11),X=Y.smil.padEnd(18),w=Y.audio.padEnd(24),R=Y.interactive.padEnd(11);console.log(`│ ${O} │ ${X} │ ${w} │ ${R} │`)}console.log("└─────────────┴────────────────────┴──────────────────────────┴─────────────┘"),console.log(`
25
+ --- USAGE SCENARIOS ---`),console.log("┌────────────────────────────────┬───────────┬───────┬───────┬─────────────┐"),console.log("│ Scenario │ Protocol │ SMIL │ Audio │ Interactive │"),console.log("├────────────────────────────────┼───────────┼───────┼───────┼─────────────┤");for(let V of U){let Y=V.scenario.substring(0,30).padEnd(30),O=V.protocol.padEnd(9),X=(V.smilWorks?"✅":"❌").padEnd(5),w=(V.audioWorks?"✅":"❌").padEnd(5),R=(V.interactiveWorks?"✅":"❌").padEnd(11);console.log(`│ ${Y} │ ${O} │ ${X} │ ${w} │ ${R} │`)}if(console.log("└────────────────────────────────┴───────────┴───────┴───────┴─────────────┘"),Q.smil.hasInteractiveAnimations){console.log(`
26
+ --- SMIL INTERACTIVE EVENT TRIGGERS ---`),console.log("┌───────────────────────────────┬────────────────────────────────────────────┐"),console.log("│ Trigger Syntax │ Description │"),console.log("├───────────────────────────────┼────────────────────────────────────────────┤");for(let V of M){let Y=V.trigger.padEnd(29),O=V.description.substring(0,42).padEnd(42);console.log(`│ ${Y} │ ${O} │`)}if(console.log("└───────────────────────────────┴────────────────────────────────────────────┘"),Q.smil.eventTriggers.length>0){console.log(`
27
+ --- DETECTED INTERACTIVE TRIGGERS IN THIS SVG ---`);for(let V of Q.smil.eventTriggers){let Y=V.targetId?`${V.targetId}.${V.event}`:V.event;console.log(` - <${V.animationElement}> triggered by: ${Y}${V.offset?` ${V.offset}`:""}`)}}}if(Q.compatibility.recommendations.length>0){console.log(`
28
28
  --- RECOMMENDATIONS ---`);for(let V of Q.compatibility.recommendations)console.log(` • ${V}`)}console.log(`
29
29
  `+"=".repeat(80)+`
30
- `)}return Q.valid=Q.errors.length===0,$.setAttribute("data-compatibility-report",JSON.stringify({hasAudio:Q.media.hasAudio,hasVideo:Q.media.hasVideo,smilCount:Q.smil.animationCount,hasInteractive:Q.smil.hasInteractiveAnimations,issues:Q.compatibility.issues.length})),$._compatibilityReport=Q,$}),r6={RENDER_VECTORS:{cat:"display",name:"Vector paths/shapes",critical:!0},RENDER_TEXT:{cat:"display",name:"Text rendering",critical:!0},RENDER_GRADIENTS:{cat:"display",name:"Gradients (linear/radial)",critical:!1},RENDER_PATTERNS:{cat:"display",name:"Pattern fills",critical:!1},RENDER_OPACITY:{cat:"display",name:"Opacity/transparency",critical:!1},RENDER_BLENDMODES:{cat:"display",name:"Blend modes",critical:!1},RENDER_TRANSFORMS:{cat:"display",name:"Transforms",critical:!0},FONTS_EMBEDDED:{cat:"fonts",name:"Embedded fonts (data-uri)",critical:!1},FONTS_SYSTEM:{cat:"fonts",name:"System fonts",critical:!1},FONTS_WEB_SAME:{cat:"fonts",name:"Web fonts (same-origin)",critical:!1},FONTS_WEB_CROSS:{cat:"fonts",name:"Web fonts (cross-origin)",critical:!1},IMAGES_EMBEDDED:{cat:"images",name:"Embedded images (data-uri)",critical:!1},IMAGES_LOCAL:{cat:"images",name:"Local images",critical:!1},IMAGES_REMOTE_SAME:{cat:"images",name:"Remote images (same-origin)",critical:!1},IMAGES_REMOTE_CROSS:{cat:"images",name:"Remote images (cross-origin)",critical:!1},FILTERS_BASIC:{cat:"effects",name:"Basic filters (blur, shadow)",critical:!1},FILTERS_COMPLEX:{cat:"effects",name:"Complex filters (lighting, turbulence)",critical:!1},MASKS:{cat:"effects",name:"Mask elements",critical:!1},CLIP_PATHS:{cat:"effects",name:"Clip paths",critical:!1},SMIL_TIMED:{cat:"animation",name:"SMIL time-based animation",critical:!1},SMIL_CLICK:{cat:"animation",name:"SMIL click-triggered",critical:!1},SMIL_HOVER:{cat:"animation",name:"SMIL mouseover-triggered",critical:!1},SMIL_FOCUS:{cat:"animation",name:"SMIL focus-triggered",critical:!1},SMIL_ACCESSKEY:{cat:"animation",name:"SMIL accessKey-triggered",critical:!1},SMIL_SYNCBASE:{cat:"animation",name:"SMIL syncbase (anim.begin)",critical:!1},CSS_KEYFRAMES:{cat:"animation",name:"CSS @keyframes animation",critical:!1},CSS_TRANSITIONS:{cat:"animation",name:"CSS transitions",critical:!1},CSS_HOVER:{cat:"animation",name:"CSS :hover effects",critical:!1},SCRIPT_INLINE:{cat:"scripting",name:"Inline <script>",critical:!1},SCRIPT_EXTERNAL:{cat:"scripting",name:'External <script src="">',critical:!1},SCRIPT_MODULE:{cat:"scripting",name:"ES modules in SVG",critical:!1},EVENT_ONCLICK:{cat:"events",name:"onclick handler",critical:!1},EVENT_ONDBLCLICK:{cat:"events",name:"ondblclick handler",critical:!1},EVENT_ONMOUSEDOWN:{cat:"events",name:"onmousedown handler",critical:!1},EVENT_ONMOUSEUP:{cat:"events",name:"onmouseup handler",critical:!1},EVENT_ONMOUSEOVER:{cat:"events",name:"onmouseover handler",critical:!1},EVENT_ONMOUSEOUT:{cat:"events",name:"onmouseout handler",critical:!1},EVENT_ONMOUSEMOVE:{cat:"events",name:"onmousemove handler",critical:!1},EVENT_ONFOCUS:{cat:"events",name:"onfocus handler",critical:!1},EVENT_ONBLUR:{cat:"events",name:"onblur handler",critical:!1},EVENT_ONLOAD:{cat:"events",name:"onload handler",critical:!1},EVENT_ONERROR:{cat:"events",name:"onerror handler",critical:!1},EVENT_ONSCROLL:{cat:"events",name:"onscroll handler",critical:!1},EVENT_ONWHEEL:{cat:"events",name:"onwheel handler",critical:!1},EVENT_ONTOUCH:{cat:"events",name:"touch events",critical:!1},EVENT_ONKEYBOARD:{cat:"events",name:"keyboard events",critical:!1},LINK_INTERNAL:{cat:"links",name:"Internal anchor links",critical:!1},LINK_EXTERNAL:{cat:"links",name:"External hyperlinks",critical:!1},LINK_TARGET:{cat:"links",name:"Link target attribute",critical:!1},LINK_DOWNLOAD:{cat:"links",name:"Download attribute",critical:!1},FOREIGNOBJECT_BASIC:{cat:"html",name:"foreignObject rendering",critical:!1},FOREIGNOBJECT_HTML:{cat:"html",name:"HTML in foreignObject",critical:!1},FOREIGNOBJECT_FORM:{cat:"html",name:"Forms in foreignObject",critical:!1},FOREIGNOBJECT_INPUT:{cat:"html",name:"Input elements in foreignObject",critical:!1},FOREIGNOBJECT_CANVAS:{cat:"html",name:"Canvas in foreignObject",critical:!1},FOREIGNOBJECT_VIDEO:{cat:"html",name:"Video in foreignObject",critical:!1},FOREIGNOBJECT_IFRAME:{cat:"html",name:"iframe in foreignObject",critical:!1},AUDIO_EMBEDDED:{cat:"media",name:"Embedded audio (data-uri)",critical:!1},AUDIO_LOCAL:{cat:"media",name:"Local audio files",critical:!1},AUDIO_REMOTE:{cat:"media",name:"Remote audio files",critical:!1},AUDIO_AUTOPLAY:{cat:"media",name:"Audio autoplay",critical:!1},AUDIO_CONTROLS:{cat:"media",name:"Audio controls visible",critical:!1},VIDEO_EMBEDDED:{cat:"media",name:"Embedded video (data-uri)",critical:!1},VIDEO_LOCAL:{cat:"media",name:"Local video files",critical:!1},VIDEO_REMOTE:{cat:"media",name:"Remote video files",critical:!1},VIDEO_AUTOPLAY:{cat:"media",name:"Video autoplay",critical:!1},USE_INTERNAL:{cat:"sprites",name:"Internal <use> references",critical:!1},USE_EXTERNAL_SAME:{cat:"sprites",name:"External <use> (same-origin)",critical:!1},USE_EXTERNAL_CROSS:{cat:"sprites",name:"External <use> (cross-origin)",critical:!1},USE_SHADOW_DOM:{cat:"sprites",name:"Shadow DOM styling of <use>",critical:!1},MAP_BASIC:{cat:"maps",name:"SVG as image map",critical:!1},MAP_COORDS:{cat:"maps",name:"Clickable regions",critical:!1},A11Y_ARIA:{cat:"accessibility",name:"ARIA attributes",critical:!1},A11Y_ROLE:{cat:"accessibility",name:"Role attributes",critical:!1},A11Y_TITLE:{cat:"accessibility",name:"Title/desc for screen readers",critical:!1},A11Y_TABINDEX:{cat:"accessibility",name:"Tab navigation",critical:!1},META_DATA_ATTRS:{cat:"metadata",name:"data-* attributes",critical:!1},META_CLASS:{cat:"metadata",name:"class attribute styling",critical:!1},META_ID:{cat:"metadata",name:"id references",critical:!0},EXT_CSS_LINK:{cat:"external",name:"External CSS via <?xml-stylesheet?>",critical:!1},EXT_CSS_IMPORT:{cat:"external",name:"@import in <style>",critical:!1},EXT_XLINK:{cat:"external",name:"xlink:href references",critical:!1}},xz={STANDALONE_BROWSER:{id:"standalone-browser",name:"Standalone (Browser)",type:"browser"},HTML_PAGE:{id:"html-page",name:"HTML Page",type:"browser"},ELECTRON:{id:"electron",name:"Electron App",type:"browser"},WEBVIEW_IOS:{id:"webview-ios",name:"iOS WKWebView",type:"mobile"},WEBVIEW_ANDROID:{id:"webview-android",name:"Android WebView",type:"mobile"},CAIRO:{id:"cairo",name:"Cairo/librsvg",type:"renderer"},INKSCAPE:{id:"inkscape",name:"Inkscape",type:"renderer"},IMAGEMAGICK:{id:"imagemagick",name:"ImageMagick",type:"renderer"},BATIK:{id:"batik",name:"Apache Batik",type:"renderer"},RESVG:{id:"resvg",name:"resvg",type:"renderer"},QT_SVG:{id:"qt-svg",name:"Qt SVG",type:"renderer"},SKIA:{id:"skia",name:"Skia (Chrome/Flutter)",type:"renderer"}},mz={FILE:{id:"file",name:"file://",protocol:"file"},HTTP:{id:"http",name:"http://",protocol:"http"},HTTPS:{id:"https",name:"https://",protocol:"https"},DATA_URI:{id:"data-uri",name:"data: URI",protocol:"data"},BLOB_URL:{id:"blob-url",name:"blob: URL",protocol:"blob"}},dz={INLINE:{id:"inline",name:"Inline in HTML",location:"inline"},BASE64:{id:"base64",name:"Base64 encoded",location:"embedded"},LOCAL_SAME:{id:"local-same",name:"Local (same dir)",location:"local"},LOCAL_ABS:{id:"local-abs",name:"Local (absolute)",location:"local"},REMOTE_SAME:{id:"remote-same",name:"Remote (same-origin)",location:"remote"},REMOTE_CROSS:{id:"remote-cross",name:"Remote (cross-origin)",location:"cross"},REMOTE_CORS:{id:"remote-cors",name:"Remote (cross+CORS)",location:"cors"}},DK={DIRECT:{id:"direct",name:"Direct SVG file",html:!1},IMG:{id:"img",name:'<img src="">',html:!0},PICTURE:{id:"picture",name:"<picture><source>",html:!0},OBJECT:{id:"object",name:'<object data="">',html:!0},EMBED:{id:"embed",name:'<embed src="">',html:!0},IFRAME:{id:"iframe",name:'<iframe src="">',html:!0},INLINE_SVG:{id:"inline-svg",name:"<svg>...</svg>",html:!0},CSS_BG:{id:"css-bg",name:"CSS background-image",html:!0},CSS_MASK:{id:"css-mask",name:"CSS mask-image",html:!0},CSS_CONTENT:{id:"css-content",name:"CSS content: url()",html:!0},CSS_LIST:{id:"css-list",name:"CSS list-style-image",html:!0},CSS_BORDER:{id:"css-border",name:"CSS border-image",html:!0},CANVAS_DRAW:{id:"canvas-draw",name:"canvas.drawImage()",html:!0},SCRIPT_INNER:{id:"script-inner",name:"innerHTML assignment",html:!0},SCRIPT_DOM:{id:"script-dom",name:"DOM createElement",html:!0},SCRIPT_FETCH:{id:"script-fetch",name:"fetch + parse",html:!0}},pz={NA:{id:"n/a",name:"N/A (not script)",script:!1},INLINE_SCRIPT:{id:"inline-script",name:"Inline <script>",script:!0},SAME_ORIGIN:{id:"same-origin",name:"Same-origin script",script:!0},CROSS_CORS:{id:"cross-cors",name:"Cross-origin (CORS)",script:!0},CROSS_NO_CORS:{id:"cross-no-cors",name:"Cross-origin (no CORS)",script:!0}},hK={CHROME:{id:"chrome",name:"Chrome",engine:"blink"},FIREFOX:{id:"firefox",name:"Firefox",engine:"gecko"},SAFARI:{id:"safari",name:"Safari",engine:"webkit"},EDGE:{id:"edge",name:"Edge",engine:"blink"},IE11:{id:"ie11",name:"IE 11",engine:"trident"},SAFARI_IOS:{id:"safari-ios",name:"Safari iOS",engine:"webkit"},CHROME_ANDROID:{id:"chrome-android",name:"Chrome Android",engine:"blink"},SAMSUNG:{id:"samsung",name:"Samsung Internet",engine:"blink"}},L={WORKS:"✅",PARTIAL:"⚠️",BLOCKED:"❌",DEPENDS:"❓",NA:"➖"},Z8={RENDER_VECTORS:{default:L.WORKS,exceptions:{}},RENDER_TEXT:{default:L.WORKS,exceptions:{"renderer:imagemagick":{status:L.PARTIAL,note:"Font substitution may occur"},"renderer:batik":{status:L.PARTIAL,note:"Limited font support"}}},RENDER_GRADIENTS:{default:L.WORKS,exceptions:{"browser:ie11":{status:L.PARTIAL,note:"Some gradient types unsupported"}}},RENDER_PATTERNS:{default:L.WORKS,exceptions:{"renderer:resvg":{status:L.PARTIAL,note:"Limited pattern support"}}},RENDER_OPACITY:{default:L.WORKS,exceptions:{}},RENDER_BLENDMODES:{default:L.WORKS,exceptions:{"browser:ie11":{status:L.BLOCKED,note:"No blend mode support"},"renderer:cairo":{status:L.PARTIAL,note:"Limited blend modes"}}},FONTS_EMBEDDED:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No embedded fonts in img context",browsers:"all"},"syntax:css-bg":{status:L.BLOCKED,note:"No embedded fonts in CSS context",browsers:"all"},"syntax:css-mask":{status:L.BLOCKED,note:"No embedded fonts in CSS context",browsers:"all"},"renderer:imagemagick":{status:L.BLOCKED,note:"Cannot process embedded fonts"}}},FONTS_SYSTEM:{default:L.WORKS,exceptions:{}},FONTS_WEB_SAME:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No external resources in img"},"syntax:css-bg":{status:L.BLOCKED,note:"No external resources in CSS bg"},"load:file":{status:L.PARTIAL,note:"May fail due to local file restrictions"},"renderer:*":{status:L.BLOCKED,note:"Renderers cannot fetch web fonts"}}},FONTS_WEB_CROSS:{default:L.PARTIAL,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No external resources"},"syntax:css-*":{status:L.BLOCKED,note:"No external resources in CSS"},"storage:remote-cors":{status:L.WORKS,note:"Works with CORS headers"},"renderer:*":{status:L.BLOCKED,note:"Renderers cannot fetch fonts"}}},IMAGES_EMBEDDED:{default:L.WORKS,exceptions:{}},IMAGES_LOCAL:{default:L.WORKS,exceptions:{"load:http":{status:L.BLOCKED,note:"Cannot load file:// from http://"},"load:https":{status:L.BLOCKED,note:"Cannot load file:// from https://"},"syntax:img":{status:L.BLOCKED,note:"No external resources in img"}}},IMAGES_REMOTE_SAME:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No external resources in img"},"load:file":{status:L.BLOCKED,note:"Cannot fetch http from file://"}}},IMAGES_REMOTE_CROSS:{default:L.PARTIAL,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No external resources in img"},"storage:remote-cors":{status:L.WORKS,note:"Works with CORS"},"load:file":{status:L.BLOCKED,note:"CORS not applicable"}}},FILTERS_BASIC:{default:L.WORKS,exceptions:{"browser:ie11":{status:L.PARTIAL,note:"Limited filter support"}}},FILTERS_COMPLEX:{default:L.WORKS,exceptions:{"browser:ie11":{status:L.BLOCKED,note:"Complex filters unsupported"},"renderer:resvg":{status:L.PARTIAL,note:"Some filters unsupported"},"renderer:qt-svg":{status:L.PARTIAL,note:"Limited filter primitives"}}},MASKS:{default:L.WORKS,exceptions:{"browser:ie11":{status:L.BLOCKED,note:"SVG masks not supported"}}},CLIP_PATHS:{default:L.WORKS,exceptions:{}},SMIL_TIMED:{default:L.WORKS,exceptions:{"browser:ie11":{status:L.BLOCKED,note:"No SMIL support"},"syntax:img":{status:L.PARTIAL,note:"May animate, no interaction",browsers:["chrome","firefox"]},"syntax:css-bg":{status:L.PARTIAL,note:"May animate, varies by browser"},"renderer:*":{status:L.BLOCKED,note:"Static render, no animation"}}},SMIL_CLICK:{default:L.WORKS,exceptions:{"browser:ie11":{status:L.BLOCKED,note:"No SMIL support"},"syntax:img":{status:L.BLOCKED,note:"No interaction in img context"},"syntax:css-*":{status:L.BLOCKED,note:"No interaction in CSS context"},"syntax:canvas-draw":{status:L.BLOCKED,note:"Rasterized, no interaction"},"renderer:*":{status:L.BLOCKED,note:"No interaction in renderers"}}},SMIL_HOVER:{default:L.WORKS,exceptions:{"browser:ie11":{status:L.BLOCKED,note:"No SMIL support"},"syntax:img":{status:L.BLOCKED,note:"No interaction in img context"},"syntax:css-*":{status:L.BLOCKED,note:"No interaction in CSS context"},"renderer:*":{status:L.BLOCKED,note:"No interaction"}}},SMIL_FOCUS:{default:L.WORKS,exceptions:{"browser:ie11":{status:L.BLOCKED,note:"No SMIL support"},"syntax:img":{status:L.BLOCKED,note:"No interaction"},"syntax:css-*":{status:L.BLOCKED,note:"No interaction"},"renderer:*":{status:L.BLOCKED,note:"No interaction"}}},SMIL_ACCESSKEY:{default:L.PARTIAL,exceptions:{"browser:ie11":{status:L.BLOCKED,note:"No SMIL support"},"browser:chrome":{status:L.PARTIAL,note:"Limited accessKey support"},"syntax:img":{status:L.BLOCKED,note:"No keyboard in img context"},"syntax:css-*":{status:L.BLOCKED,note:"No keyboard in CSS context"},"renderer:*":{status:L.BLOCKED,note:"No keyboard"}}},SMIL_SYNCBASE:{default:L.WORKS,exceptions:{"browser:ie11":{status:L.BLOCKED,note:"No SMIL support"},"syntax:img":{status:L.PARTIAL,note:"Sync works if animation plays"},"renderer:*":{status:L.BLOCKED,note:"No animation"}}},CSS_KEYFRAMES:{default:L.WORKS,exceptions:{"syntax:img":{status:L.WORKS,note:"CSS animations work in img"},"syntax:css-bg":{status:L.WORKS,note:"CSS animations work"},"renderer:*":{status:L.BLOCKED,note:"Static render"}}},CSS_TRANSITIONS:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No interaction for transitions"},"syntax:css-bg":{status:L.BLOCKED,note:"No interaction"},"renderer:*":{status:L.BLOCKED,note:"Static render"}}},CSS_HOVER:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No :hover in img context"},"syntax:css-*":{status:L.BLOCKED,note:"No :hover in CSS context"},"renderer:*":{status:L.BLOCKED,note:"No interaction"}}},SCRIPT_INLINE:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"Scripts disabled for security"},"syntax:css-*":{status:L.BLOCKED,note:"Scripts disabled in CSS context"},"syntax:canvas-draw":{status:L.BLOCKED,note:"Rasterized, no scripts"},"renderer:*":{status:L.BLOCKED,note:"No script execution"},"display:html-page+syntax:inline-svg":{status:L.WORKS,note:"Runs in page context"},"display:html-page+syntax:object":{status:L.WORKS,note:"Isolated context"},"display:html-page+syntax:embed":{status:L.WORKS,note:"Isolated context"}}},SCRIPT_EXTERNAL:{default:L.PARTIAL,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No external resources"},"syntax:css-*":{status:L.BLOCKED,note:"No external resources"},"load:file":{status:L.PARTIAL,note:"May be blocked by local file restrictions"},"storage:remote-cross":{status:L.BLOCKED,note:"CORS required"},"storage:remote-cors":{status:L.WORKS,note:"Works with CORS"},"renderer:*":{status:L.BLOCKED,note:"No scripts"}}},SCRIPT_MODULE:{default:L.PARTIAL,exceptions:{"browser:ie11":{status:L.BLOCKED,note:"No ES modules"},"browser:safari":{status:L.PARTIAL,note:"Limited module support in SVG"},"syntax:img":{status:L.BLOCKED,note:"No scripts"},"syntax:css-*":{status:L.BLOCKED,note:"No scripts"},"renderer:*":{status:L.BLOCKED,note:"No scripts"}}},EVENT_ONCLICK:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No events in img context"},"syntax:css-*":{status:L.BLOCKED,note:"No events in CSS context"},"syntax:canvas-draw":{status:L.BLOCKED,note:"Rasterized"},"renderer:*":{status:L.BLOCKED,note:"No events"}}},EVENT_ONDBLCLICK:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No events"},"syntax:css-*":{status:L.BLOCKED,note:"No events"},"renderer:*":{status:L.BLOCKED,note:"No events"}}},EVENT_ONMOUSEDOWN:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No events"},"syntax:css-*":{status:L.BLOCKED,note:"No events"},"renderer:*":{status:L.BLOCKED,note:"No events"}}},EVENT_ONMOUSEUP:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No events"},"syntax:css-*":{status:L.BLOCKED,note:"No events"},"renderer:*":{status:L.BLOCKED,note:"No events"}}},EVENT_ONMOUSEOVER:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No events"},"syntax:css-*":{status:L.BLOCKED,note:"No events"},"renderer:*":{status:L.BLOCKED,note:"No events"}}},EVENT_ONMOUSEOUT:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No events"},"syntax:css-*":{status:L.BLOCKED,note:"No events"},"renderer:*":{status:L.BLOCKED,note:"No events"}}},EVENT_ONMOUSEMOVE:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No events"},"syntax:css-*":{status:L.BLOCKED,note:"No events"},"renderer:*":{status:L.BLOCKED,note:"No events"}}},EVENT_ONFOCUS:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No focus in img"},"syntax:css-*":{status:L.BLOCKED,note:"No focus"},"renderer:*":{status:L.BLOCKED,note:"No events"}}},EVENT_ONBLUR:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No events"},"syntax:css-*":{status:L.BLOCKED,note:"No events"},"renderer:*":{status:L.BLOCKED,note:"No events"}}},EVENT_ONLOAD:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No scripts/events"},"syntax:css-*":{status:L.BLOCKED,note:"No scripts"},"renderer:*":{status:L.BLOCKED,note:"No scripts"}}},EVENT_ONERROR:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No scripts"},"syntax:css-*":{status:L.BLOCKED,note:"No scripts"},"renderer:*":{status:L.BLOCKED,note:"No scripts"}}},EVENT_ONSCROLL:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No scroll in img"},"syntax:css-*":{status:L.BLOCKED,note:"No scroll"},"renderer:*":{status:L.BLOCKED,note:"No events"}}},EVENT_ONWHEEL:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No events"},"syntax:css-*":{status:L.BLOCKED,note:"No events"},"renderer:*":{status:L.BLOCKED,note:"No events"}}},EVENT_ONTOUCH:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No touch events"},"syntax:css-*":{status:L.BLOCKED,note:"No touch"},"display:*-browser":{status:L.NA,note:"No touch on desktop"},"renderer:*":{status:L.BLOCKED,note:"No events"}}},EVENT_ONKEYBOARD:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No keyboard"},"syntax:css-*":{status:L.BLOCKED,note:"No keyboard"},"renderer:*":{status:L.BLOCKED,note:"No events"}}},LINK_INTERNAL:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No links in img"},"syntax:css-*":{status:L.BLOCKED,note:"No links in CSS"},"renderer:*":{status:L.BLOCKED,note:"No interaction"}}},LINK_EXTERNAL:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No links in img"},"syntax:css-*":{status:L.BLOCKED,note:"No links"},"syntax:object":{status:L.WORKS,note:"Opens in object frame"},"renderer:*":{status:L.BLOCKED,note:"No links"}}},LINK_TARGET:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No links"},"syntax:css-*":{status:L.BLOCKED,note:"No links"},"syntax:object":{status:L.PARTIAL,note:"May not break out of frame"},"renderer:*":{status:L.BLOCKED,note:"No links"}}},LINK_DOWNLOAD:{default:L.PARTIAL,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No links"},"browser:safari":{status:L.PARTIAL,note:"Limited download attr support"},"renderer:*":{status:L.BLOCKED,note:"No links"}}},FOREIGNOBJECT_BASIC:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"foreignObject disabled in img"},"syntax:css-*":{status:L.BLOCKED,note:"foreignObject disabled in CSS"},"syntax:canvas-draw":{status:L.BLOCKED,note:"Security: tainted canvas"},"browser:ie11":{status:L.BLOCKED,note:"No foreignObject support"},"renderer:cairo":{status:L.BLOCKED,note:"No foreignObject"},"renderer:resvg":{status:L.BLOCKED,note:"No foreignObject"},"renderer:imagemagick":{status:L.BLOCKED,note:"No foreignObject"}}},FOREIGNOBJECT_HTML:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No foreignObject"},"syntax:css-*":{status:L.BLOCKED,note:"No foreignObject"},"browser:ie11":{status:L.BLOCKED,note:"No foreignObject"},"renderer:*":{status:L.BLOCKED,note:"No HTML rendering"}}},FOREIGNOBJECT_FORM:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No foreignObject"},"syntax:css-*":{status:L.BLOCKED,note:"No foreignObject"},"syntax:object":{status:L.PARTIAL,note:"Form submission may be restricted"},"browser:ie11":{status:L.BLOCKED,note:"No foreignObject"},"renderer:*":{status:L.BLOCKED,note:"No forms"}}},FOREIGNOBJECT_INPUT:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No foreignObject"},"syntax:css-*":{status:L.BLOCKED,note:"No foreignObject"},"browser:ie11":{status:L.BLOCKED,note:"No foreignObject"},"renderer:*":{status:L.BLOCKED,note:"No inputs"}}},FOREIGNOBJECT_CANVAS:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No foreignObject"},"syntax:css-*":{status:L.BLOCKED,note:"No foreignObject"},"browser:ie11":{status:L.BLOCKED,note:"No foreignObject"},"renderer:*":{status:L.BLOCKED,note:"No canvas"}}},FOREIGNOBJECT_VIDEO:{default:L.PARTIAL,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No foreignObject"},"syntax:css-*":{status:L.BLOCKED,note:"No foreignObject"},"browser:ie11":{status:L.BLOCKED,note:"No foreignObject"},"renderer:*":{status:L.BLOCKED,note:"No video"}}},FOREIGNOBJECT_IFRAME:{default:L.PARTIAL,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No foreignObject"},"syntax:css-*":{status:L.BLOCKED,note:"No foreignObject"},"syntax:object":{status:L.PARTIAL,note:"Nested contexts may fail"},"browser:ie11":{status:L.BLOCKED,note:"No foreignObject"},"renderer:*":{status:L.BLOCKED,note:"No iframes"}}},AUDIO_EMBEDDED:{default:L.BLOCKED,exceptions:{"display:html-page+syntax:inline-svg+processing:*-script":{status:L.WORKS,note:"Play on user gesture via JS"},"syntax:script-*":{status:L.WORKS,note:"JS can play on user gesture"}},note:"All browsers block autoplay without user gesture"},AUDIO_LOCAL:{default:L.BLOCKED,exceptions:{"display:html-page+syntax:inline-svg":{status:L.PARTIAL,note:"Needs user gesture"},"load:file":{status:L.PARTIAL,note:"May work locally with gesture"}}},AUDIO_REMOTE:{default:L.BLOCKED,exceptions:{"display:html-page+syntax:inline-svg":{status:L.PARTIAL,note:"Needs user gesture + CORS"},"storage:remote-cors":{status:L.PARTIAL,note:"Needs user gesture"}}},AUDIO_AUTOPLAY:{default:L.BLOCKED,exceptions:{},note:"Autoplay blocked by ALL modern browsers"},AUDIO_CONTROLS:{default:L.PARTIAL,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No foreignObject/audio"},"syntax:css-*":{status:L.BLOCKED,note:"No foreignObject/audio"},"syntax:object":{status:L.PARTIAL,note:"May render controls"}}},VIDEO_EMBEDDED:{default:L.BLOCKED,exceptions:{"display:html-page+syntax:inline-svg":{status:L.PARTIAL,note:"Needs user gesture"},"syntax:script-*":{status:L.WORKS,note:"JS can play on gesture"}}},VIDEO_LOCAL:{default:L.BLOCKED,exceptions:{"display:html-page+syntax:inline-svg":{status:L.PARTIAL,note:"Needs user gesture"}}},VIDEO_REMOTE:{default:L.BLOCKED,exceptions:{"display:html-page+syntax:inline-svg":{status:L.PARTIAL,note:"Needs gesture + CORS"}}},VIDEO_AUTOPLAY:{default:L.BLOCKED,exceptions:{"browser:*":{status:L.PARTIAL,note:"May work muted"}},note:"Autoplay only works muted in most browsers"},USE_INTERNAL:{default:L.WORKS,exceptions:{"syntax:img":{status:L.WORKS,note:"Internal refs work"},"syntax:css-*":{status:L.WORKS,note:"Internal refs work"}}},USE_EXTERNAL_SAME:{default:L.PARTIAL,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No external refs"},"syntax:css-*":{status:L.BLOCKED,note:"No external refs"},"browser:chrome":{status:L.BLOCKED,note:"External use blocked since Chrome 50"},"browser:firefox":{status:L.BLOCKED,note:"Blocked for security"},"browser:safari":{status:L.PARTIAL,note:"May work same-origin"}},note:"Most browsers block external <use> for security"},USE_EXTERNAL_CROSS:{default:L.BLOCKED,exceptions:{},note:"Cross-origin external <use> blocked by all browsers"},USE_SHADOW_DOM:{default:L.PARTIAL,exceptions:{"browser:ie11":{status:L.BLOCKED,note:"No shadow DOM"},"syntax:img":{status:L.BLOCKED,note:"No styling access"}},note:"Styling shadow DOM from <use> is limited"},MAP_BASIC:{default:L.NA,exceptions:{"syntax:inline-svg":{status:L.WORKS,note:"Can use SVG elements as map"}},note:"Traditional image maps not applicable, use SVG events"},MAP_COORDS:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No events for clickable regions"},"syntax:css-*":{status:L.BLOCKED,note:"No events"},"renderer:*":{status:L.BLOCKED,note:"No interaction"}}},A11Y_ARIA:{default:L.WORKS,exceptions:{"syntax:img":{status:L.PARTIAL,note:"Only alt text accessible"},"syntax:css-*":{status:L.BLOCKED,note:"No a11y in CSS images"},"renderer:*":{status:L.BLOCKED,note:"No a11y tree"}}},A11Y_ROLE:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"Use alt attribute instead"},"syntax:css-*":{status:L.BLOCKED,note:"No a11y"},"renderer:*":{status:L.BLOCKED,note:"No a11y"}}},A11Y_TITLE:{default:L.WORKS,exceptions:{"syntax:img":{status:L.PARTIAL,note:"May not be read by screen readers"},"syntax:css-*":{status:L.BLOCKED,note:"Not accessible"}}},A11Y_TABINDEX:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No focus in img"},"syntax:css-*":{status:L.BLOCKED,note:"No focus"},"renderer:*":{status:L.BLOCKED,note:"No interaction"}}},META_DATA_ATTRS:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"Not accessible from outside"},"syntax:css-*":{status:L.BLOCKED,note:"Not accessible"}}},META_CLASS:{default:L.WORKS,exceptions:{}},META_ID:{default:L.WORKS,exceptions:{"syntax:img":{status:L.PARTIAL,note:"IDs isolated"}}},EXT_CSS_LINK:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No external resources"},"syntax:css-*":{status:L.BLOCKED,note:"No external resources"},"load:file":{status:L.PARTIAL,note:"Local file restrictions"},"renderer:*":{status:L.BLOCKED,note:"No external fetch"}}},EXT_CSS_IMPORT:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No @import"},"syntax:css-*":{status:L.BLOCKED,note:"No @import"},"load:file":{status:L.PARTIAL,note:"May be blocked"},"renderer:*":{status:L.BLOCKED,note:"No external fetch"}}},EXT_XLINK:{default:L.WORKS,exceptions:{"syntax:img":{status:L.BLOCKED,note:"No external xlink"},"syntax:css-*":{status:L.BLOCKED,note:"No external xlink"},"storage:remote-cross":{status:L.BLOCKED,note:"CORS required"}}}},X0={JAVASCRIPT:"javascript",EVENT_HANDLERS:"event_handlers",SMIL_ANIMATIONS:"smil_animations",SMIL_INTERACTIVE:"smil_interactive",CSS_ANIMATIONS:"css_animations",AUDIO:"audio",VIDEO:"video",EXTERNAL_IMAGES:"external_images",EXTERNAL_CSS:"external_css",EXTERNAL_FONTS:"external_fonts",EXTERNAL_SCRIPTS:"external_scripts",EXTERNAL_USE:"external_use",FOREIGN_OBJECT:"foreign_object",IFRAME:"iframe",FILTERS:"filters",MASKS:"masks",CLIP_PATHS:"clip_paths",HYPERLINKS:"hyperlinks",ANCHORS:"anchors"},dK=j0(($,J={})=>{let Z=J.verbose||!1,K=J.printTables!==!1,Q=J.includeMetaAnalysis!==!1,H=(T)=>{let P=[],t=T.toLowerCase(),$0=(Q0)=>{if(Q0.tagName&&Q0.tagName.toLowerCase()===t)P.push(Q0);for(let U0 of Q0.children||[])if(U0&&U0.tagName)$0(U0)};return $0($),P},z=(T,P=[])=>{if(T.tagName)P.push(T);for(let t of T.children||[])if(t&&t.tagName)z(t,P);return P},q=(T,...P)=>{for(let t of P)if(T.getAttribute(t))return!0;return!1},W={detected:new Set,details:{}},j=z($),G=H("script");if(G.length>0){if(W.detected.add(X0.JAVASCRIPT),W.details.javascript={count:G.length,hasExternalSrc:G.some((T)=>T.getAttribute("src")||T.getAttribute("href")||T.getAttribute("xlink:href")),types:G.map((T)=>T.getAttribute("type")||"text/javascript")},W.details.javascript.hasExternalSrc)W.detected.add(X0.EXTERNAL_SCRIPTS)}let F=["onclick","ondblclick","onmousedown","onmouseup","onmouseover","onmouseout","onmousemove","onmouseenter","onmouseleave","onfocus","onblur","onkeydown","onkeyup","onkeypress","onload","onerror","onscroll","onwheel","ontouchstart","ontouchend","ontouchmove","onbegin","onend","onrepeat"],_=[];for(let T of j){let P=F.filter((t)=>T.getAttribute(t));if(P.length>0)_.push({tag:T.tagName,handlers:P})}if(_.length>0)W.detected.add(X0.EVENT_HANDLERS),W.details.eventHandlers={count:_.length,types:[...new Set(_.flatMap((T)=>T.handlers))],elements:_.slice(0,10)};let U=["animate","animatetransform","animatemotion","animatecolor","set"],O=[],V=[];for(let T of U){let P=H(T);O.push(...P);for(let t of P){let $0=t.getAttribute("begin")||"",Q0=t.getAttribute("end")||"",U0=["click","dblclick","mousedown","mouseup","mouseover","mouseout","mousemove","mouseenter","mouseleave","focus","blur","focusin","focusout"];for(let N0 of U0)if($0.includes(N0)||Q0.includes(N0))V.push({element:t.tagName,event:N0,begin:$0,end:Q0});if($0.includes("accessKey(")||Q0.includes("accessKey("))V.push({element:t.tagName,event:"accessKey",begin:$0,end:Q0})}}if(O.length>0){if(W.detected.add(X0.SMIL_ANIMATIONS),W.details.smilAnimations={count:O.length,breakdown:{animate:H("animate").length,animateTransform:H("animatetransform").length,animateMotion:H("animatemotion").length,animateColor:H("animatecolor").length,set:H("set").length}},V.length>0)W.detected.add(X0.SMIL_INTERACTIVE),W.details.smilInteractive={count:V.length,triggers:[...new Set(V.map((T)=>T.event))],elements:V.slice(0,10)}}let M=H("style"),Y=!1;for(let T of M){let P=T.textContent||"";if(P.includes("@keyframes")||P.includes("animation:")||P.includes("animation-name")||P.includes("transition:")||P.includes("transition-property")){Y=!0;break}}for(let T of j){let P=T.getAttribute("style")||"";if(P.includes("animation")||P.includes("transition")){Y=!0;break}}if(Y)W.detected.add(X0.CSS_ANIMATIONS),W.details.cssAnimations={detected:!0};let X=H("audio"),w=H("video"),R=H("foreignobject");for(let T of R){let P=[],t=[],$0=(Q0)=>{let U0=Q0.tagName?.toLowerCase();if(U0==="audio")P.push(Q0);if(U0==="video")t.push(Q0);for(let N0 of Q0.children||[])if(N0&&N0.tagName)$0(N0)};for(let Q0 of T.children||[])if(Q0&&Q0.tagName)$0(Q0);X.push(...P),w.push(...t)}if(X.length>0)W.detected.add(X0.AUDIO),W.details.audio={count:X.length,hasAutoplay:X.some((T)=>T.hasAttribute("autoplay")),sources:X.map((T)=>({id:T.getAttribute("id"),src:T.getAttribute("src"),isDataUri:(T.getAttribute("src")||"").startsWith("data:"),isExternal:(T.getAttribute("src")||"").startsWith("http")}))};if(w.length>0)W.detected.add(X0.VIDEO),W.details.video={count:w.length,hasAutoplay:w.some((T)=>T.hasAttribute("autoplay"))};let I=H("image"),b=[],u=[];for(let T of I){let P=T.getAttribute("href")||T.getAttribute("xlink:href")||"";if(P.startsWith("http://")||P.startsWith("https://")||P.startsWith("//"))b.push({href:P,element:"image"});else if(P.startsWith("data:"))u.push({type:"data-uri",element:"image"});else if(P&&!P.startsWith("#"))b.push({href:P,element:"image",type:"local"})}if(b.length>0)W.detected.add(X0.EXTERNAL_IMAGES),W.details.externalImages={count:b.length,urls:b.slice(0,5)};let m=H("use"),S=[];for(let T of m){let P=T.getAttribute("href")||T.getAttribute("xlink:href")||"";if(P&&!P.startsWith("#"))S.push({href:P})}if(S.length>0)W.detected.add(X0.EXTERNAL_USE),W.details.externalUse={count:S.length,refs:S.slice(0,5)};let x=!1;for(let T of M){let P=T.textContent||"";if(P.includes("@font-face")&&P.includes("url(")){let t=P.match(/url\(['"]?(https?:\/\/[^'")\s]+)['"]?\)/);if(t){x=!0,W.detected.add(X0.EXTERNAL_FONTS),W.details.externalFonts={detected:!0,sample:t[1]};break}}}if(R.length>0){if(W.detected.add(X0.FOREIGN_OBJECT),W.details.foreignObject={count:R.length,hasIframe:R.some((T)=>{let P=!1,t=($0)=>{if($0.tagName?.toLowerCase()==="iframe")P=!0;for(let Q0 of $0.children||[])if(Q0&&Q0.tagName)t(Q0)};return t(T),P})},W.details.foreignObject.hasIframe)W.detected.add(X0.IFRAME)}let h=H("filter"),E=H("mask"),d=H("clippath");if(h.length>0)W.detected.add(X0.FILTERS),W.details.filters={count:h.length};if(E.length>0)W.detected.add(X0.MASKS),W.details.masks={count:E.length};if(d.length>0)W.detected.add(X0.CLIP_PATHS),W.details.clipPaths={count:d.length};let c=H("a");if(c.length>0)W.detected.add(X0.HYPERLINKS),W.details.hyperlinks={count:c.length,hasExternal:c.some((T)=>{return(T.getAttribute("href")||T.getAttribute("xlink:href")||"").startsWith("http")})};let p={STANDALONE:"standalone",HTML:"html",CUSTOM_RENDERER:"custom"},N={FILE:"file://",HTTP:"http://"},y={INLINE_BASE64:"inline",LOCAL_PATH:"local",REMOTE_URL:"remote"},B={NONE:"none",IMG:"img",OBJECT:"object",EMBED:"embed",INLINE:"inline",CSS:"css",SCRIPT:"script"},e={INLINE_CODE:"inline",LOCAL_SERVER:"local",REMOTE_CDN:"remote"},r={[X0.JAVASCRIPT]:{[B.NONE]:{file:"✅",http:"✅",note:"Full JS execution"},[B.IMG]:{file:"❌",http:"❌",note:"All scripting disabled for security"},[B.OBJECT]:{file:"✅",http:"✅",note:"Isolated JS context"},[B.EMBED]:{file:"✅",http:"✅",note:"Isolated JS context"},[B.INLINE]:{file:"✅",http:"✅",note:"Same JS context as parent page"},[B.CSS]:{file:"❌",http:"❌",note:"CSS image context - no scripts"},[B.SCRIPT]:{file:"✅",http:"✅",note:"JS-generated = full control"}},[X0.EVENT_HANDLERS]:{[B.NONE]:{file:"✅",http:"✅",note:"Full event handling"},[B.IMG]:{file:"❌",http:"❌",note:"No events in img context"},[B.OBJECT]:{file:"✅",http:"✅",note:"Events work, isolated from parent"},[B.EMBED]:{file:"✅",http:"✅",note:"Events work, isolated from parent"},[B.INLINE]:{file:"✅",http:"✅",note:"Full event handling"},[B.CSS]:{file:"❌",http:"❌",note:"No events in CSS context"},[B.SCRIPT]:{file:"✅",http:"✅",note:"Full event handling"}},[X0.SMIL_ANIMATIONS]:{[B.NONE]:{file:"✅",http:"✅",note:"Full SMIL support"},[B.IMG]:{file:"⚠️",http:"⚠️",note:"Time-based only, varies by browser"},[B.OBJECT]:{file:"✅",http:"✅",note:"Full SMIL support"},[B.EMBED]:{file:"✅",http:"✅",note:"Full SMIL support"},[B.INLINE]:{file:"✅",http:"✅",note:"Full SMIL support"},[B.CSS]:{file:"⚠️",http:"⚠️",note:"Time-based only, varies by browser"},[B.SCRIPT]:{file:"✅",http:"✅",note:"Full SMIL support"}},[X0.SMIL_INTERACTIVE]:{[B.NONE]:{file:"✅",http:"✅",note:"Full interactive SMIL"},[B.IMG]:{file:"❌",http:"❌",note:"No interaction in img context"},[B.OBJECT]:{file:"✅",http:"✅",note:"Interactive SMIL works"},[B.EMBED]:{file:"✅",http:"✅",note:"Interactive SMIL works"},[B.INLINE]:{file:"✅",http:"✅",note:"Full interactive SMIL"},[B.CSS]:{file:"❌",http:"❌",note:"No interaction in CSS context"},[B.SCRIPT]:{file:"✅",http:"✅",note:"Full interactive SMIL"}},[X0.CSS_ANIMATIONS]:{[B.NONE]:{file:"✅",http:"✅",note:"Full CSS animation support"},[B.IMG]:{file:"✅",http:"✅",note:"CSS animations work in img"},[B.OBJECT]:{file:"✅",http:"✅",note:"Full CSS animation support"},[B.EMBED]:{file:"✅",http:"✅",note:"Full CSS animation support"},[B.INLINE]:{file:"✅",http:"✅",note:"Full CSS animation support"},[B.CSS]:{file:"✅",http:"✅",note:"CSS animations work"},[B.SCRIPT]:{file:"✅",http:"✅",note:"Full CSS animation support"}},[X0.AUDIO]:{[B.NONE]:{file:"❌",http:"❌",note:"Autoplay blocked, needs user gesture"},[B.IMG]:{file:"❌",http:"❌",note:"No audio in img context"},[B.OBJECT]:{file:"❌",http:"❌",note:"Autoplay blocked"},[B.EMBED]:{file:"❌",http:"❌",note:"Autoplay blocked"},[B.INLINE]:{file:"⚠️",http:"⚠️",note:"Needs JS + user gesture to play"},[B.CSS]:{file:"❌",http:"❌",note:"No audio in CSS context"},[B.SCRIPT]:{file:"✅",http:"✅",note:"JS can play audio on user gesture"}},[X0.VIDEO]:{[B.NONE]:{file:"❌",http:"❌",note:"Autoplay blocked, needs user gesture"},[B.IMG]:{file:"❌",http:"❌",note:"No video in img context"},[B.OBJECT]:{file:"❌",http:"❌",note:"Autoplay blocked"},[B.EMBED]:{file:"❌",http:"❌",note:"Autoplay blocked"},[B.INLINE]:{file:"⚠️",http:"⚠️",note:"Needs JS + user gesture to play"},[B.CSS]:{file:"❌",http:"❌",note:"No video in CSS context"},[B.SCRIPT]:{file:"✅",http:"✅",note:"JS can play video on user gesture"}},[X0.EXTERNAL_IMAGES]:{[B.NONE]:{file:"⚠️",http:"✅",note:"file:// may have CORS issues"},[B.IMG]:{file:"❌",http:"⚠️",note:"Blocked or CORS restricted"},[B.OBJECT]:{file:"⚠️",http:"✅",note:"CORS applies"},[B.EMBED]:{file:"⚠️",http:"✅",note:"CORS applies"},[B.INLINE]:{file:"⚠️",http:"✅",note:"CORS applies"},[B.CSS]:{file:"❌",http:"⚠️",note:"Restricted for security"},[B.SCRIPT]:{file:"⚠️",http:"✅",note:"CORS applies"}},[X0.EXTERNAL_CSS]:{[B.NONE]:{file:"✅",http:"✅",note:"External CSS loaded"},[B.IMG]:{file:"❌",http:"❌",note:"No external resources in img"},[B.OBJECT]:{file:"✅",http:"✅",note:"External CSS works"},[B.EMBED]:{file:"✅",http:"✅",note:"External CSS works"},[B.INLINE]:{file:"✅",http:"✅",note:"External CSS works"},[B.CSS]:{file:"❌",http:"❌",note:"No external resources"},[B.SCRIPT]:{file:"✅",http:"✅",note:"External CSS works"}},[X0.EXTERNAL_FONTS]:{[B.NONE]:{file:"✅",http:"✅",note:"External fonts loaded"},[B.IMG]:{file:"❌",http:"❌",note:"No external resources in img"},[B.OBJECT]:{file:"✅",http:"✅",note:"External fonts work (CORS)"},[B.EMBED]:{file:"✅",http:"✅",note:"External fonts work (CORS)"},[B.INLINE]:{file:"✅",http:"✅",note:"External fonts work (CORS)"},[B.CSS]:{file:"❌",http:"⚠️",note:"Limited, varies by browser"},[B.SCRIPT]:{file:"✅",http:"✅",note:"External fonts work"}},[X0.EXTERNAL_USE]:{[B.NONE]:{file:"❌",http:"⚠️",note:"Most browsers block external use"},[B.IMG]:{file:"❌",http:"❌",note:"No external use in img"},[B.OBJECT]:{file:"❌",http:"⚠️",note:"Most browsers block"},[B.EMBED]:{file:"❌",http:"⚠️",note:"Most browsers block"},[B.INLINE]:{file:"❌",http:"⚠️",note:"Most browsers block"},[B.CSS]:{file:"❌",http:"❌",note:"No external use"},[B.SCRIPT]:{file:"❌",http:"⚠️",note:"Most browsers block"}},[X0.FOREIGN_OBJECT]:{[B.NONE]:{file:"✅",http:"✅",note:"Full foreignObject support"},[B.IMG]:{file:"❌",http:"❌",note:"foreignObject disabled in img"},[B.OBJECT]:{file:"✅",http:"✅",note:"foreignObject works"},[B.EMBED]:{file:"✅",http:"✅",note:"foreignObject works"},[B.INLINE]:{file:"✅",http:"✅",note:"foreignObject works"},[B.CSS]:{file:"❌",http:"❌",note:"foreignObject disabled"},[B.SCRIPT]:{file:"✅",http:"✅",note:"foreignObject works"}},[X0.HYPERLINKS]:{[B.NONE]:{file:"✅",http:"✅",note:"Links work"},[B.IMG]:{file:"❌",http:"❌",note:"No links in img context"},[B.OBJECT]:{file:"✅",http:"✅",note:"Links work (in iframe-like context)"},[B.EMBED]:{file:"✅",http:"✅",note:"Links work"},[B.INLINE]:{file:"✅",http:"✅",note:"Links work normally"},[B.CSS]:{file:"❌",http:"❌",note:"No links in CSS context"},[B.SCRIPT]:{file:"✅",http:"✅",note:"Links work"}},[X0.FILTERS]:{[B.NONE]:{file:"✅",http:"✅",note:"Full filter support"},[B.IMG]:{file:"✅",http:"✅",note:"Filters work"},[B.OBJECT]:{file:"✅",http:"✅",note:"Filters work"},[B.EMBED]:{file:"✅",http:"✅",note:"Filters work"},[B.INLINE]:{file:"✅",http:"✅",note:"Filters work"},[B.CSS]:{file:"✅",http:"✅",note:"Filters work"},[B.SCRIPT]:{file:"✅",http:"✅",note:"Filters work"}}},s={"GitHub README.md":{syntax:"IMG (implicit)",restrictions:["No JavaScript","No SMIL","No external resources","No foreignObject","No links"],worksFor:["Static SVG","CSS animations (some)","Embedded images (data-uri)"],note:"GitHub sanitizes SVG heavily - only safe static content"},"GitHub Flavored Markdown (GFM)":{syntax:"IMG",restrictions:["Same as GitHub README"],worksFor:["Static SVG only"],note:"GFM renders SVG as images"},"GitLab README.md":{syntax:"IMG (implicit)",restrictions:["Similar to GitHub but slightly more permissive"],worksFor:["Static SVG","Some CSS animations"],note:"GitLab also sanitizes SVG"},"Wikipedia/MediaWiki":{syntax:"IMG (sanitized)",restrictions:["Heavy sanitization","No scripts","No external resources","No animations"],worksFor:["Static vector graphics only"],note:"MediaWiki converts SVG to PNG for display"},"EPUB 3.x":{syntax:"IMG or INLINE",restrictions:["No external resources","Limited JavaScript","No autoplay"],worksFor:["Static SVG","CSS animations","SMIL (in some readers)"],note:"Support varies by e-reader - Apple Books better than Kindle"},"Email (HTML email)":{syntax:"IMG (base64)",restrictions:["Heavily filtered","No scripts","No external resources","No animations"],worksFor:["Static embedded SVG only","Many clients block SVG entirely"],note:"Most email clients block or rasterize SVG"},"Slack/Discord":{syntax:"IMG (auto-converted)",restrictions:["Converted to raster","No interactivity"],worksFor:["Static preview only"],note:"SVG files are typically converted to PNG previews"},"Twitter/X":{syntax:"N/A",restrictions:["SVG not supported as media"],worksFor:["Nothing - upload as PNG"],note:"Twitter does not support SVG uploads"},Notion:{syntax:"EMBED/IMG",restrictions:["Limited - treated as image"],worksFor:["Static SVG"],note:"Notion embeds SVG as images"},Obsidian:{syntax:"INLINE or IMG",restrictions:["Depends on mode and plugins"],worksFor:["Static SVG","Some CSS animations"],note:"Obsidian has good local SVG support"},"Bear Notes":{syntax:"IMG",restrictions:["Image context only"],worksFor:["Static SVG"],note:"Bear treats SVG as images"},"Markdown-it":{syntax:"IMG (default)",restrictions:["Default IMG behavior","Can be configured for INLINE"],worksFor:["Depends on configuration"],note:"Parser library - output depends on implementation"},MDX:{syntax:"INLINE (JSX)",restrictions:["Full React component - depends on framework"],worksFor:["Full SVG when used as component"],note:"MDX can import SVG as React components"},"iOS Safari":{syntax:"ALL",restrictions:["Stricter autoplay policies"],worksFor:["All standard SVG features except auto-audio"],note:"Good SVG support, strict media policies"},"Android WebView":{syntax:"ALL",restrictions:["Varies by Android version"],worksFor:["Most SVG features"],note:"WebView behavior varies significantly"},"Cairo/librsvg":{syntax:"CUSTOM_RENDERER",restrictions:["Limited JS","Limited SMIL","No foreignObject"],worksFor:["Static SVG","Basic filters","CSS styling"],note:"Server-side rendering library - no dynamic features"},Inkscape:{syntax:"CUSTOM_RENDERER",restrictions:["May not run JS","SMIL playback varies"],worksFor:["All static SVG","Partial animation preview"],note:"Full SVG editor with preview capabilities"},ImageMagick:{syntax:"CUSTOM_RENDERER",restrictions:["Rasterizes immediately","No animations","No JS"],worksFor:["Static rasterization only"],note:"Converts SVG to raster - no dynamic features"}},z0={timestamp:new Date().toISOString(),features:W,interactivityLevel:"static",bySyntax:{},specialCases:{},recommendations:[],warnings:[]};if(W.detected.has(X0.JAVASCRIPT)||W.detected.has(X0.EVENT_HANDLERS))z0.interactivityLevel="scripted";else if(W.detected.has(X0.SMIL_INTERACTIVE))z0.interactivityLevel="interactive";else if(W.detected.has(X0.SMIL_ANIMATIONS)||W.detected.has(X0.CSS_ANIMATIONS))z0.interactivityLevel="animated";for(let T of Object.values(B)){z0.bySyntax[T]={file:{works:[],partial:[],blocked:[]},http:{works:[],partial:[],blocked:[]}};for(let P of W.detected){let t=r[P];if(t&&t[T]){let{file:$0,http:Q0,note:U0}=t[T];if($0==="✅")z0.bySyntax[T].file.works.push({feature:P,note:U0});else if($0==="⚠️")z0.bySyntax[T].file.partial.push({feature:P,note:U0});else z0.bySyntax[T].file.blocked.push({feature:P,note:U0});if(Q0==="✅")z0.bySyntax[T].http.works.push({feature:P,note:U0});else if(Q0==="⚠️")z0.bySyntax[T].http.partial.push({feature:P,note:U0});else z0.bySyntax[T].http.blocked.push({feature:P,note:U0})}}}for(let[T,P]of Object.entries(s)){let t=[],$0=[];for(let Q0 of W.detected){let N0={[X0.JAVASCRIPT]:"JavaScript",[X0.EVENT_HANDLERS]:"Event handlers",[X0.SMIL_ANIMATIONS]:"SMIL",[X0.SMIL_INTERACTIVE]:"Interactive SMIL",[X0.CSS_ANIMATIONS]:"CSS animations",[X0.AUDIO]:"Audio",[X0.VIDEO]:"Video",[X0.EXTERNAL_IMAGES]:"External images",[X0.EXTERNAL_USE]:"External use",[X0.FOREIGN_OBJECT]:"foreignObject",[X0.HYPERLINKS]:"Links"}[Q0]||Q0;if(P.restrictions.some((o)=>o.toLowerCase().includes(N0.toLowerCase())||o.toLowerCase().includes("no "+N0.toLowerCase())))t.push(N0);else if(P.worksFor.some((J0)=>J0.toLowerCase().includes(N0.toLowerCase())))$0.push(N0)}z0.specialCases[T]={syntax:P.syntax,blockedFeatures:t,workingFeatures:$0,note:P.note,overallCompat:t.length===0?"✅ Compatible":t.length<W.detected.size/2?"⚠️ Partial":"❌ Not compatible"}}if(W.detected.has(X0.AUDIO))z0.recommendations.push({issue:"Audio playback blocked",solution:"Use SCRIPT syntax with user gesture: embed SVG inline, extract audio data-uri via JavaScript, play on click",example:`document.querySelector('svg').addEventListener('click', () => {
30
+ `)}return Q.valid=Q.errors.length===0,$.setAttribute("data-compatibility-report",JSON.stringify({hasAudio:Q.media.hasAudio,hasVideo:Q.media.hasVideo,smilCount:Q.smil.animationCount,hasInteractive:Q.smil.hasInteractiveAnimations,issues:Q.compatibility.issues.length})),$._compatibilityReport=Q,$}),t6={RENDER_VECTORS:{cat:"display",name:"Vector paths/shapes",critical:!0},RENDER_TEXT:{cat:"display",name:"Text rendering",critical:!0},RENDER_GRADIENTS:{cat:"display",name:"Gradients (linear/radial)",critical:!1},RENDER_PATTERNS:{cat:"display",name:"Pattern fills",critical:!1},RENDER_OPACITY:{cat:"display",name:"Opacity/transparency",critical:!1},RENDER_BLENDMODES:{cat:"display",name:"Blend modes",critical:!1},RENDER_TRANSFORMS:{cat:"display",name:"Transforms",critical:!0},FONTS_EMBEDDED:{cat:"fonts",name:"Embedded fonts (data-uri)",critical:!1},FONTS_SYSTEM:{cat:"fonts",name:"System fonts",critical:!1},FONTS_WEB_SAME:{cat:"fonts",name:"Web fonts (same-origin)",critical:!1},FONTS_WEB_CROSS:{cat:"fonts",name:"Web fonts (cross-origin)",critical:!1},IMAGES_EMBEDDED:{cat:"images",name:"Embedded images (data-uri)",critical:!1},IMAGES_LOCAL:{cat:"images",name:"Local images",critical:!1},IMAGES_REMOTE_SAME:{cat:"images",name:"Remote images (same-origin)",critical:!1},IMAGES_REMOTE_CROSS:{cat:"images",name:"Remote images (cross-origin)",critical:!1},FILTERS_BASIC:{cat:"effects",name:"Basic filters (blur, shadow)",critical:!1},FILTERS_COMPLEX:{cat:"effects",name:"Complex filters (lighting, turbulence)",critical:!1},MASKS:{cat:"effects",name:"Mask elements",critical:!1},CLIP_PATHS:{cat:"effects",name:"Clip paths",critical:!1},SMIL_TIMED:{cat:"animation",name:"SMIL time-based animation",critical:!1},SMIL_CLICK:{cat:"animation",name:"SMIL click-triggered",critical:!1},SMIL_HOVER:{cat:"animation",name:"SMIL mouseover-triggered",critical:!1},SMIL_FOCUS:{cat:"animation",name:"SMIL focus-triggered",critical:!1},SMIL_ACCESSKEY:{cat:"animation",name:"SMIL accessKey-triggered",critical:!1},SMIL_SYNCBASE:{cat:"animation",name:"SMIL syncbase (anim.begin)",critical:!1},CSS_KEYFRAMES:{cat:"animation",name:"CSS @keyframes animation",critical:!1},CSS_TRANSITIONS:{cat:"animation",name:"CSS transitions",critical:!1},CSS_HOVER:{cat:"animation",name:"CSS :hover effects",critical:!1},SCRIPT_INLINE:{cat:"scripting",name:"Inline <script>",critical:!1},SCRIPT_EXTERNAL:{cat:"scripting",name:'External <script src="">',critical:!1},SCRIPT_MODULE:{cat:"scripting",name:"ES modules in SVG",critical:!1},EVENT_ONCLICK:{cat:"events",name:"onclick handler",critical:!1},EVENT_ONDBLCLICK:{cat:"events",name:"ondblclick handler",critical:!1},EVENT_ONMOUSEDOWN:{cat:"events",name:"onmousedown handler",critical:!1},EVENT_ONMOUSEUP:{cat:"events",name:"onmouseup handler",critical:!1},EVENT_ONMOUSEOVER:{cat:"events",name:"onmouseover handler",critical:!1},EVENT_ONMOUSEOUT:{cat:"events",name:"onmouseout handler",critical:!1},EVENT_ONMOUSEMOVE:{cat:"events",name:"onmousemove handler",critical:!1},EVENT_ONFOCUS:{cat:"events",name:"onfocus handler",critical:!1},EVENT_ONBLUR:{cat:"events",name:"onblur handler",critical:!1},EVENT_ONLOAD:{cat:"events",name:"onload handler",critical:!1},EVENT_ONERROR:{cat:"events",name:"onerror handler",critical:!1},EVENT_ONSCROLL:{cat:"events",name:"onscroll handler",critical:!1},EVENT_ONWHEEL:{cat:"events",name:"onwheel handler",critical:!1},EVENT_ONTOUCH:{cat:"events",name:"touch events",critical:!1},EVENT_ONKEYBOARD:{cat:"events",name:"keyboard events",critical:!1},LINK_INTERNAL:{cat:"links",name:"Internal anchor links",critical:!1},LINK_EXTERNAL:{cat:"links",name:"External hyperlinks",critical:!1},LINK_TARGET:{cat:"links",name:"Link target attribute",critical:!1},LINK_DOWNLOAD:{cat:"links",name:"Download attribute",critical:!1},FOREIGNOBJECT_BASIC:{cat:"html",name:"foreignObject rendering",critical:!1},FOREIGNOBJECT_HTML:{cat:"html",name:"HTML in foreignObject",critical:!1},FOREIGNOBJECT_FORM:{cat:"html",name:"Forms in foreignObject",critical:!1},FOREIGNOBJECT_INPUT:{cat:"html",name:"Input elements in foreignObject",critical:!1},FOREIGNOBJECT_CANVAS:{cat:"html",name:"Canvas in foreignObject",critical:!1},FOREIGNOBJECT_VIDEO:{cat:"html",name:"Video in foreignObject",critical:!1},FOREIGNOBJECT_IFRAME:{cat:"html",name:"iframe in foreignObject",critical:!1},AUDIO_EMBEDDED:{cat:"media",name:"Embedded audio (data-uri)",critical:!1},AUDIO_LOCAL:{cat:"media",name:"Local audio files",critical:!1},AUDIO_REMOTE:{cat:"media",name:"Remote audio files",critical:!1},AUDIO_AUTOPLAY:{cat:"media",name:"Audio autoplay",critical:!1},AUDIO_CONTROLS:{cat:"media",name:"Audio controls visible",critical:!1},VIDEO_EMBEDDED:{cat:"media",name:"Embedded video (data-uri)",critical:!1},VIDEO_LOCAL:{cat:"media",name:"Local video files",critical:!1},VIDEO_REMOTE:{cat:"media",name:"Remote video files",critical:!1},VIDEO_AUTOPLAY:{cat:"media",name:"Video autoplay",critical:!1},USE_INTERNAL:{cat:"sprites",name:"Internal <use> references",critical:!1},USE_EXTERNAL_SAME:{cat:"sprites",name:"External <use> (same-origin)",critical:!1},USE_EXTERNAL_CROSS:{cat:"sprites",name:"External <use> (cross-origin)",critical:!1},USE_SHADOW_DOM:{cat:"sprites",name:"Shadow DOM styling of <use>",critical:!1},MAP_BASIC:{cat:"maps",name:"SVG as image map",critical:!1},MAP_COORDS:{cat:"maps",name:"Clickable regions",critical:!1},A11Y_ARIA:{cat:"accessibility",name:"ARIA attributes",critical:!1},A11Y_ROLE:{cat:"accessibility",name:"Role attributes",critical:!1},A11Y_TITLE:{cat:"accessibility",name:"Title/desc for screen readers",critical:!1},A11Y_TABINDEX:{cat:"accessibility",name:"Tab navigation",critical:!1},META_DATA_ATTRS:{cat:"metadata",name:"data-* attributes",critical:!1},META_CLASS:{cat:"metadata",name:"class attribute styling",critical:!1},META_ID:{cat:"metadata",name:"id references",critical:!0},EXT_CSS_LINK:{cat:"external",name:"External CSS via <?xml-stylesheet?>",critical:!1},EXT_CSS_IMPORT:{cat:"external",name:"@import in <style>",critical:!1},EXT_XLINK:{cat:"external",name:"xlink:href references",critical:!1}},Kq={STANDALONE_BROWSER:{id:"standalone-browser",name:"Standalone (Browser)",type:"browser"},HTML_PAGE:{id:"html-page",name:"HTML Page",type:"browser"},ELECTRON:{id:"electron",name:"Electron App",type:"browser"},WEBVIEW_IOS:{id:"webview-ios",name:"iOS WKWebView",type:"mobile"},WEBVIEW_ANDROID:{id:"webview-android",name:"Android WebView",type:"mobile"},CAIRO:{id:"cairo",name:"Cairo/librsvg",type:"renderer"},INKSCAPE:{id:"inkscape",name:"Inkscape",type:"renderer"},IMAGEMAGICK:{id:"imagemagick",name:"ImageMagick",type:"renderer"},BATIK:{id:"batik",name:"Apache Batik",type:"renderer"},RESVG:{id:"resvg",name:"resvg",type:"renderer"},QT_SVG:{id:"qt-svg",name:"Qt SVG",type:"renderer"},SKIA:{id:"skia",name:"Skia (Chrome/Flutter)",type:"renderer"}},Zq={FILE:{id:"file",name:"file://",protocol:"file"},HTTP:{id:"http",name:"http://",protocol:"http"},HTTPS:{id:"https",name:"https://",protocol:"https"},DATA_URI:{id:"data-uri",name:"data: URI",protocol:"data"},BLOB_URL:{id:"blob-url",name:"blob: URL",protocol:"blob"}},Qq={INLINE:{id:"inline",name:"Inline in HTML",location:"inline"},BASE64:{id:"base64",name:"Base64 encoded",location:"embedded"},LOCAL_SAME:{id:"local-same",name:"Local (same dir)",location:"local"},LOCAL_ABS:{id:"local-abs",name:"Local (absolute)",location:"local"},REMOTE_SAME:{id:"remote-same",name:"Remote (same-origin)",location:"remote"},REMOTE_CROSS:{id:"remote-cross",name:"Remote (cross-origin)",location:"cross"},REMOTE_CORS:{id:"remote-cors",name:"Remote (cross+CORS)",location:"cors"}},sK={DIRECT:{id:"direct",name:"Direct SVG file",html:!1},IMG:{id:"img",name:'<img src="">',html:!0},PICTURE:{id:"picture",name:"<picture><source>",html:!0},OBJECT:{id:"object",name:'<object data="">',html:!0},EMBED:{id:"embed",name:'<embed src="">',html:!0},IFRAME:{id:"iframe",name:'<iframe src="">',html:!0},INLINE_SVG:{id:"inline-svg",name:"<svg>...</svg>",html:!0},CSS_BG:{id:"css-bg",name:"CSS background-image",html:!0},CSS_MASK:{id:"css-mask",name:"CSS mask-image",html:!0},CSS_CONTENT:{id:"css-content",name:"CSS content: url()",html:!0},CSS_LIST:{id:"css-list",name:"CSS list-style-image",html:!0},CSS_BORDER:{id:"css-border",name:"CSS border-image",html:!0},CANVAS_DRAW:{id:"canvas-draw",name:"canvas.drawImage()",html:!0},SCRIPT_INNER:{id:"script-inner",name:"innerHTML assignment",html:!0},SCRIPT_DOM:{id:"script-dom",name:"DOM createElement",html:!0},SCRIPT_FETCH:{id:"script-fetch",name:"fetch + parse",html:!0}},Hq={NA:{id:"n/a",name:"N/A (not script)",script:!1},INLINE_SCRIPT:{id:"inline-script",name:"Inline <script>",script:!0},SAME_ORIGIN:{id:"same-origin",name:"Same-origin script",script:!0},CROSS_CORS:{id:"cross-cors",name:"Cross-origin (CORS)",script:!0},CROSS_NO_CORS:{id:"cross-no-cors",name:"Cross-origin (no CORS)",script:!0}},oK={CHROME:{id:"chrome",name:"Chrome",engine:"blink"},FIREFOX:{id:"firefox",name:"Firefox",engine:"gecko"},SAFARI:{id:"safari",name:"Safari",engine:"webkit"},EDGE:{id:"edge",name:"Edge",engine:"blink"},IE11:{id:"ie11",name:"IE 11",engine:"trident"},SAFARI_IOS:{id:"safari-ios",name:"Safari iOS",engine:"webkit"},CHROME_ANDROID:{id:"chrome-android",name:"Chrome Android",engine:"blink"},SAMSUNG:{id:"samsung",name:"Samsung Internet",engine:"blink"}},k={WORKS:"✅",PARTIAL:"⚠️",BLOCKED:"❌",DEPENDS:"❓",NA:"➖"},j8={RENDER_VECTORS:{default:k.WORKS,exceptions:{}},RENDER_TEXT:{default:k.WORKS,exceptions:{"renderer:imagemagick":{status:k.PARTIAL,note:"Font substitution may occur"},"renderer:batik":{status:k.PARTIAL,note:"Limited font support"}}},RENDER_GRADIENTS:{default:k.WORKS,exceptions:{"browser:ie11":{status:k.PARTIAL,note:"Some gradient types unsupported"}}},RENDER_PATTERNS:{default:k.WORKS,exceptions:{"renderer:resvg":{status:k.PARTIAL,note:"Limited pattern support"}}},RENDER_OPACITY:{default:k.WORKS,exceptions:{}},RENDER_BLENDMODES:{default:k.WORKS,exceptions:{"browser:ie11":{status:k.BLOCKED,note:"No blend mode support"},"renderer:cairo":{status:k.PARTIAL,note:"Limited blend modes"}}},FONTS_EMBEDDED:{default:k.WORKS,exceptions:{"syntax:img":{status:k.BLOCKED,note:"No embedded fonts in img context",browsers:"all"},"syntax:css-bg":{status:k.BLOCKED,note:"No embedded fonts in CSS context",browsers:"all"},"syntax:css-mask":{status:k.BLOCKED,note:"No embedded fonts in CSS context",browsers:"all"},"renderer:imagemagick":{status:k.BLOCKED,note:"Cannot process embedded fonts"}}},FONTS_SYSTEM:{default:k.WORKS,exceptions:{}},FONTS_WEB_SAME:{default:k.WORKS,exceptions:{"syntax:img":{status:k.BLOCKED,note:"No external resources in img"},"syntax:css-bg":{status:k.BLOCKED,note:"No external resources in CSS bg"},"load:file":{status:k.PARTIAL,note:"May fail due to local file restrictions"},"renderer:*":{status:k.BLOCKED,note:"Renderers cannot fetch web fonts"}}},FONTS_WEB_CROSS:{default:k.PARTIAL,exceptions:{"syntax:img":{status:k.BLOCKED,note:"No external resources"},"syntax:css-*":{status:k.BLOCKED,note:"No external resources in CSS"},"storage:remote-cors":{status:k.WORKS,note:"Works with CORS headers"},"renderer:*":{status:k.BLOCKED,note:"Renderers cannot fetch fonts"}}},IMAGES_EMBEDDED:{default:k.WORKS,exceptions:{}},IMAGES_LOCAL:{default:k.WORKS,exceptions:{"load:http":{status:k.BLOCKED,note:"Cannot load file:// from http://"},"load:https":{status:k.BLOCKED,note:"Cannot load file:// from https://"},"syntax:img":{status:k.BLOCKED,note:"No external resources in img"}}},IMAGES_REMOTE_SAME:{default:k.WORKS,exceptions:{"syntax:img":{status:k.BLOCKED,note:"No external resources in img"},"load:file":{status:k.BLOCKED,note:"Cannot fetch http from file://"}}},IMAGES_REMOTE_CROSS:{default:k.PARTIAL,exceptions:{"syntax:img":{status:k.BLOCKED,note:"No external resources in img"},"storage:remote-cors":{status:k.WORKS,note:"Works with CORS"},"load:file":{status:k.BLOCKED,note:"CORS not applicable"}}},FILTERS_BASIC:{default:k.WORKS,exceptions:{"browser:ie11":{status:k.PARTIAL,note:"Limited filter support"}}},FILTERS_COMPLEX:{default:k.WORKS,exceptions:{"browser:ie11":{status:k.BLOCKED,note:"Complex filters unsupported"},"renderer:resvg":{status:k.PARTIAL,note:"Some filters unsupported"},"renderer:qt-svg":{status:k.PARTIAL,note:"Limited filter primitives"}}},MASKS:{default:k.WORKS,exceptions:{"browser:ie11":{status:k.BLOCKED,note:"SVG masks not supported"}}},CLIP_PATHS:{default:k.WORKS,exceptions:{}},SMIL_TIMED:{default:k.WORKS,exceptions:{"browser:ie11":{status:k.BLOCKED,note:"No SMIL support"},"syntax:img":{status:k.PARTIAL,note:"May animate, no interaction",browsers:["chrome","firefox"]},"syntax:css-bg":{status:k.PARTIAL,note:"May animate, varies by browser"},"renderer:*":{status:k.BLOCKED,note:"Static render, no animation"}}},SMIL_CLICK:{default:k.WORKS,exceptions:{"browser:ie11":{status:k.BLOCKED,note:"No SMIL support"},"syntax:img":{status:k.BLOCKED,note:"No interaction in img context"},"syntax:css-*":{status:k.BLOCKED,note:"No interaction in CSS context"},"syntax:canvas-draw":{status:k.BLOCKED,note:"Rasterized, no interaction"},"renderer:*":{status:k.BLOCKED,note:"No interaction in renderers"}}},SMIL_HOVER:{default:k.WORKS,exceptions:{"browser:ie11":{status:k.BLOCKED,note:"No SMIL support"},"syntax:img":{status:k.BLOCKED,note:"No interaction in img context"},"syntax:css-*":{status:k.BLOCKED,note:"No interaction in CSS context"},"renderer:*":{status:k.BLOCKED,note:"No interaction"}}},SMIL_FOCUS:{default:k.WORKS,exceptions:{"browser:ie11":{status:k.BLOCKED,note:"No SMIL support"},"syntax:img":{status:k.BLOCKED,note:"No interaction"},"syntax:css-*":{status:k.BLOCKED,note:"No interaction"},"renderer:*":{status:k.BLOCKED,note:"No interaction"}}},SMIL_ACCESSKEY:{default:k.PARTIAL,exceptions:{"browser:ie11":{status:k.BLOCKED,note:"No SMIL support"},"browser:chrome":{status:k.PARTIAL,note:"Limited accessKey support"},"syntax:img":{status:k.BLOCKED,note:"No keyboard in img context"},"syntax:css-*":{status:k.BLOCKED,note:"No keyboard in CSS context"},"renderer:*":{status:k.BLOCKED,note:"No keyboard"}}},SMIL_SYNCBASE:{default:k.WORKS,exceptions:{"browser:ie11":{status:k.BLOCKED,note:"No SMIL support"},"syntax:img":{status:k.PARTIAL,note:"Sync works if animation plays"},"renderer:*":{status:k.BLOCKED,note:"No animation"}}},CSS_KEYFRAMES:{default:k.WORKS,exceptions:{"syntax:img":{status:k.WORKS,note:"CSS animations work in img"},"syntax:css-bg":{status:k.WORKS,note:"CSS animations work"},"renderer:*":{status:k.BLOCKED,note:"Static render"}}},CSS_TRANSITIONS:{default:k.WORKS,exceptions:{"syntax:img":{status:k.BLOCKED,note:"No interaction for transitions"},"syntax:css-bg":{status:k.BLOCKED,note:"No interaction"},"renderer:*":{status:k.BLOCKED,note:"Static render"}}},CSS_HOVER:{default:k.WORKS,exceptions:{"syntax:img":{status:k.BLOCKED,note:"No :hover in img context"},"syntax:css-*":{status:k.BLOCKED,note:"No :hover in CSS context"},"renderer:*":{status:k.BLOCKED,note:"No interaction"}}},SCRIPT_INLINE:{default:k.WORKS,exceptions:{"syntax:img":{status:k.BLOCKED,note:"Scripts disabled for security"},"syntax:css-*":{status:k.BLOCKED,note:"Scripts disabled in CSS context"},"syntax:canvas-draw":{status:k.BLOCKED,note:"Rasterized, no scripts"},"renderer:*":{status:k.BLOCKED,note:"No script execution"},"display:html-page+syntax:inline-svg":{status:k.WORKS,note:"Runs in page context"},"display:html-page+syntax:object":{status:k.WORKS,note:"Isolated context"},"display:html-page+syntax:embed":{status:k.WORKS,note:"Isolated context"}}},SCRIPT_EXTERNAL:{default:k.PARTIAL,exceptions:{"syntax:img":{status:k.BLOCKED,note:"No external resources"},"syntax:css-*":{status:k.BLOCKED,note:"No external resources"},"load:file":{status:k.PARTIAL,note:"May be blocked by local file restrictions"},"storage:remote-cross":{status:k.BLOCKED,note:"CORS required"},"storage:remote-cors":{status:k.WORKS,note:"Works with CORS"},"renderer:*":{status:k.BLOCKED,note:"No scripts"}}},SCRIPT_MODULE:{default:k.PARTIAL,exceptions:{"browser:ie11":{status:k.BLOCKED,note:"No ES modules"},"browser:safari":{status:k.PARTIAL,note:"Limited module support in SVG"},"syntax:img":{status:k.BLOCKED,note:"No scripts"},"syntax:css-*":{status:k.BLOCKED,note:"No scripts"},"renderer:*":{status:k.BLOCKED,note:"No scripts"}}},EVENT_ONCLICK:{default:k.WORKS,exceptions:{"syntax:img":{status:k.BLOCKED,note:"No events in img context"},"syntax:css-*":{status:k.BLOCKED,note:"No events in CSS context"},"syntax:canvas-draw":{status:k.BLOCKED,note:"Rasterized"},"renderer:*":{status:k.BLOCKED,note:"No events"}}},EVENT_ONDBLCLICK:{default:k.WORKS,exceptions:{"syntax:img":{status:k.BLOCKED,note:"No events"},"syntax:css-*":{status:k.BLOCKED,note:"No events"},"renderer:*":{status:k.BLOCKED,note:"No events"}}},EVENT_ONMOUSEDOWN:{default:k.WORKS,exceptions:{"syntax:img":{status:k.BLOCKED,note:"No events"},"syntax:css-*":{status:k.BLOCKED,note:"No events"},"renderer:*":{status:k.BLOCKED,note:"No events"}}},EVENT_ONMOUSEUP:{default:k.WORKS,exceptions:{"syntax:img":{status:k.BLOCKED,note:"No events"},"syntax:css-*":{status:k.BLOCKED,note:"No events"},"renderer:*":{status:k.BLOCKED,note:"No events"}}},EVENT_ONMOUSEOVER:{default:k.WORKS,exceptions:{"syntax:img":{status:k.BLOCKED,note:"No events"},"syntax:css-*":{status:k.BLOCKED,note:"No events"},"renderer:*":{status:k.BLOCKED,note:"No events"}}},EVENT_ONMOUSEOUT:{default:k.WORKS,exceptions:{"syntax:img":{status:k.BLOCKED,note:"No events"},"syntax:css-*":{status:k.BLOCKED,note:"No events"},"renderer:*":{status:k.BLOCKED,note:"No events"}}},EVENT_ONMOUSEMOVE:{default:k.WORKS,exceptions:{"syntax:img":{status:k.BLOCKED,note:"No events"},"syntax:css-*":{status:k.BLOCKED,note:"No events"},"renderer:*":{status:k.BLOCKED,note:"No events"}}},EVENT_ONFOCUS:{default:k.WORKS,exceptions:{"syntax:img":{status:k.BLOCKED,note:"No focus in img"},"syntax:css-*":{status:k.BLOCKED,note:"No focus"},"renderer:*":{status:k.BLOCKED,note:"No events"}}},EVENT_ONBLUR:{default:k.WORKS,exceptions:{"syntax:img":{status:k.BLOCKED,note:"No events"},"syntax:css-*":{status:k.BLOCKED,note:"No events"},"renderer:*":{status:k.BLOCKED,note:"No events"}}},EVENT_ONLOAD:{default:k.WORKS,exceptions:{"syntax:img":{status:k.BLOCKED,note:"No scripts/events"},"syntax:css-*":{status:k.BLOCKED,note:"No scripts"},"renderer:*":{status:k.BLOCKED,note:"No scripts"}}},EVENT_ONERROR:{default:k.WORKS,exceptions:{"syntax:img":{status:k.BLOCKED,note:"No scripts"},"syntax:css-*":{status:k.BLOCKED,note:"No scripts"},"renderer:*":{status:k.BLOCKED,note:"No scripts"}}},EVENT_ONSCROLL:{default:k.WORKS,exceptions:{"syntax:img":{status:k.BLOCKED,note:"No scroll in img"},"syntax:css-*":{status:k.BLOCKED,note:"No scroll"},"renderer:*":{status:k.BLOCKED,note:"No events"}}},EVENT_ONWHEEL:{default:k.WORKS,exceptions:{"syntax:img":{status:k.BLOCKED,note:"No events"},"syntax:css-*":{status:k.BLOCKED,note:"No events"},"renderer:*":{status:k.BLOCKED,note:"No events"}}},EVENT_ONTOUCH:{default:k.WORKS,exceptions:{"syntax:img":{status:k.BLOCKED,note:"No touch events"},"syntax:css-*":{status:k.BLOCKED,note:"No touch"},"display:*-browser":{status:k.NA,note:"No touch on desktop"},"renderer:*":{status:k.BLOCKED,note:"No events"}}},EVENT_ONKEYBOARD:{default:k.WORKS,exceptions:{"syntax:img":{status:k.BLOCKED,note:"No keyboard"},"syntax:css-*":{status:k.BLOCKED,note:"No keyboard"},"renderer:*":{status:k.BLOCKED,note:"No events"}}},LINK_INTERNAL:{default:k.WORKS,exceptions:{"syntax:img":{status:k.BLOCKED,note:"No links in img"},"syntax:css-*":{status:k.BLOCKED,note:"No links in CSS"},"renderer:*":{status:k.BLOCKED,note:"No interaction"}}},LINK_EXTERNAL:{default:k.WORKS,exceptions:{"syntax:img":{status:k.BLOCKED,note:"No links in img"},"syntax:css-*":{status:k.BLOCKED,note:"No links"},"syntax:object":{status:k.WORKS,note:"Opens in object frame"},"renderer:*":{status:k.BLOCKED,note:"No links"}}},LINK_TARGET:{default:k.WORKS,exceptions:{"syntax:img":{status:k.BLOCKED,note:"No links"},"syntax:css-*":{status:k.BLOCKED,note:"No links"},"syntax:object":{status:k.PARTIAL,note:"May not break out of frame"},"renderer:*":{status:k.BLOCKED,note:"No links"}}},LINK_DOWNLOAD:{default:k.PARTIAL,exceptions:{"syntax:img":{status:k.BLOCKED,note:"No links"},"browser:safari":{status:k.PARTIAL,note:"Limited download attr support"},"renderer:*":{status:k.BLOCKED,note:"No links"}}},FOREIGNOBJECT_BASIC:{default:k.WORKS,exceptions:{"syntax:img":{status:k.BLOCKED,note:"foreignObject disabled in img"},"syntax:css-*":{status:k.BLOCKED,note:"foreignObject disabled in CSS"},"syntax:canvas-draw":{status:k.BLOCKED,note:"Security: tainted canvas"},"browser:ie11":{status:k.BLOCKED,note:"No foreignObject support"},"renderer:cairo":{status:k.BLOCKED,note:"No foreignObject"},"renderer:resvg":{status:k.BLOCKED,note:"No foreignObject"},"renderer:imagemagick":{status:k.BLOCKED,note:"No foreignObject"}}},FOREIGNOBJECT_HTML:{default:k.WORKS,exceptions:{"syntax:img":{status:k.BLOCKED,note:"No foreignObject"},"syntax:css-*":{status:k.BLOCKED,note:"No foreignObject"},"browser:ie11":{status:k.BLOCKED,note:"No foreignObject"},"renderer:*":{status:k.BLOCKED,note:"No HTML rendering"}}},FOREIGNOBJECT_FORM:{default:k.WORKS,exceptions:{"syntax:img":{status:k.BLOCKED,note:"No foreignObject"},"syntax:css-*":{status:k.BLOCKED,note:"No foreignObject"},"syntax:object":{status:k.PARTIAL,note:"Form submission may be restricted"},"browser:ie11":{status:k.BLOCKED,note:"No foreignObject"},"renderer:*":{status:k.BLOCKED,note:"No forms"}}},FOREIGNOBJECT_INPUT:{default:k.WORKS,exceptions:{"syntax:img":{status:k.BLOCKED,note:"No foreignObject"},"syntax:css-*":{status:k.BLOCKED,note:"No foreignObject"},"browser:ie11":{status:k.BLOCKED,note:"No foreignObject"},"renderer:*":{status:k.BLOCKED,note:"No inputs"}}},FOREIGNOBJECT_CANVAS:{default:k.WORKS,exceptions:{"syntax:img":{status:k.BLOCKED,note:"No foreignObject"},"syntax:css-*":{status:k.BLOCKED,note:"No foreignObject"},"browser:ie11":{status:k.BLOCKED,note:"No foreignObject"},"renderer:*":{status:k.BLOCKED,note:"No canvas"}}},FOREIGNOBJECT_VIDEO:{default:k.PARTIAL,exceptions:{"syntax:img":{status:k.BLOCKED,note:"No foreignObject"},"syntax:css-*":{status:k.BLOCKED,note:"No foreignObject"},"browser:ie11":{status:k.BLOCKED,note:"No foreignObject"},"renderer:*":{status:k.BLOCKED,note:"No video"}}},FOREIGNOBJECT_IFRAME:{default:k.PARTIAL,exceptions:{"syntax:img":{status:k.BLOCKED,note:"No foreignObject"},"syntax:css-*":{status:k.BLOCKED,note:"No foreignObject"},"syntax:object":{status:k.PARTIAL,note:"Nested contexts may fail"},"browser:ie11":{status:k.BLOCKED,note:"No foreignObject"},"renderer:*":{status:k.BLOCKED,note:"No iframes"}}},AUDIO_EMBEDDED:{default:k.BLOCKED,exceptions:{"display:html-page+syntax:inline-svg+processing:*-script":{status:k.WORKS,note:"Play on user gesture via JS"},"syntax:script-*":{status:k.WORKS,note:"JS can play on user gesture"}},note:"All browsers block autoplay without user gesture"},AUDIO_LOCAL:{default:k.BLOCKED,exceptions:{"display:html-page+syntax:inline-svg":{status:k.PARTIAL,note:"Needs user gesture"},"load:file":{status:k.PARTIAL,note:"May work locally with gesture"}}},AUDIO_REMOTE:{default:k.BLOCKED,exceptions:{"display:html-page+syntax:inline-svg":{status:k.PARTIAL,note:"Needs user gesture + CORS"},"storage:remote-cors":{status:k.PARTIAL,note:"Needs user gesture"}}},AUDIO_AUTOPLAY:{default:k.BLOCKED,exceptions:{},note:"Autoplay blocked by ALL modern browsers"},AUDIO_CONTROLS:{default:k.PARTIAL,exceptions:{"syntax:img":{status:k.BLOCKED,note:"No foreignObject/audio"},"syntax:css-*":{status:k.BLOCKED,note:"No foreignObject/audio"},"syntax:object":{status:k.PARTIAL,note:"May render controls"}}},VIDEO_EMBEDDED:{default:k.BLOCKED,exceptions:{"display:html-page+syntax:inline-svg":{status:k.PARTIAL,note:"Needs user gesture"},"syntax:script-*":{status:k.WORKS,note:"JS can play on gesture"}}},VIDEO_LOCAL:{default:k.BLOCKED,exceptions:{"display:html-page+syntax:inline-svg":{status:k.PARTIAL,note:"Needs user gesture"}}},VIDEO_REMOTE:{default:k.BLOCKED,exceptions:{"display:html-page+syntax:inline-svg":{status:k.PARTIAL,note:"Needs gesture + CORS"}}},VIDEO_AUTOPLAY:{default:k.BLOCKED,exceptions:{"browser:*":{status:k.PARTIAL,note:"May work muted"}},note:"Autoplay only works muted in most browsers"},USE_INTERNAL:{default:k.WORKS,exceptions:{"syntax:img":{status:k.WORKS,note:"Internal refs work"},"syntax:css-*":{status:k.WORKS,note:"Internal refs work"}}},USE_EXTERNAL_SAME:{default:k.PARTIAL,exceptions:{"syntax:img":{status:k.BLOCKED,note:"No external refs"},"syntax:css-*":{status:k.BLOCKED,note:"No external refs"},"browser:chrome":{status:k.BLOCKED,note:"External use blocked since Chrome 50"},"browser:firefox":{status:k.BLOCKED,note:"Blocked for security"},"browser:safari":{status:k.PARTIAL,note:"May work same-origin"}},note:"Most browsers block external <use> for security"},USE_EXTERNAL_CROSS:{default:k.BLOCKED,exceptions:{},note:"Cross-origin external <use> blocked by all browsers"},USE_SHADOW_DOM:{default:k.PARTIAL,exceptions:{"browser:ie11":{status:k.BLOCKED,note:"No shadow DOM"},"syntax:img":{status:k.BLOCKED,note:"No styling access"}},note:"Styling shadow DOM from <use> is limited"},MAP_BASIC:{default:k.NA,exceptions:{"syntax:inline-svg":{status:k.WORKS,note:"Can use SVG elements as map"}},note:"Traditional image maps not applicable, use SVG events"},MAP_COORDS:{default:k.WORKS,exceptions:{"syntax:img":{status:k.BLOCKED,note:"No events for clickable regions"},"syntax:css-*":{status:k.BLOCKED,note:"No events"},"renderer:*":{status:k.BLOCKED,note:"No interaction"}}},A11Y_ARIA:{default:k.WORKS,exceptions:{"syntax:img":{status:k.PARTIAL,note:"Only alt text accessible"},"syntax:css-*":{status:k.BLOCKED,note:"No a11y in CSS images"},"renderer:*":{status:k.BLOCKED,note:"No a11y tree"}}},A11Y_ROLE:{default:k.WORKS,exceptions:{"syntax:img":{status:k.BLOCKED,note:"Use alt attribute instead"},"syntax:css-*":{status:k.BLOCKED,note:"No a11y"},"renderer:*":{status:k.BLOCKED,note:"No a11y"}}},A11Y_TITLE:{default:k.WORKS,exceptions:{"syntax:img":{status:k.PARTIAL,note:"May not be read by screen readers"},"syntax:css-*":{status:k.BLOCKED,note:"Not accessible"}}},A11Y_TABINDEX:{default:k.WORKS,exceptions:{"syntax:img":{status:k.BLOCKED,note:"No focus in img"},"syntax:css-*":{status:k.BLOCKED,note:"No focus"},"renderer:*":{status:k.BLOCKED,note:"No interaction"}}},META_DATA_ATTRS:{default:k.WORKS,exceptions:{"syntax:img":{status:k.BLOCKED,note:"Not accessible from outside"},"syntax:css-*":{status:k.BLOCKED,note:"Not accessible"}}},META_CLASS:{default:k.WORKS,exceptions:{}},META_ID:{default:k.WORKS,exceptions:{"syntax:img":{status:k.PARTIAL,note:"IDs isolated"}}},EXT_CSS_LINK:{default:k.WORKS,exceptions:{"syntax:img":{status:k.BLOCKED,note:"No external resources"},"syntax:css-*":{status:k.BLOCKED,note:"No external resources"},"load:file":{status:k.PARTIAL,note:"Local file restrictions"},"renderer:*":{status:k.BLOCKED,note:"No external fetch"}}},EXT_CSS_IMPORT:{default:k.WORKS,exceptions:{"syntax:img":{status:k.BLOCKED,note:"No @import"},"syntax:css-*":{status:k.BLOCKED,note:"No @import"},"load:file":{status:k.PARTIAL,note:"May be blocked"},"renderer:*":{status:k.BLOCKED,note:"No external fetch"}}},EXT_XLINK:{default:k.WORKS,exceptions:{"syntax:img":{status:k.BLOCKED,note:"No external xlink"},"syntax:css-*":{status:k.BLOCKED,note:"No external xlink"},"storage:remote-cross":{status:k.BLOCKED,note:"CORS required"}}}},X0={JAVASCRIPT:"javascript",EVENT_HANDLERS:"event_handlers",SMIL_ANIMATIONS:"smil_animations",SMIL_INTERACTIVE:"smil_interactive",CSS_ANIMATIONS:"css_animations",AUDIO:"audio",VIDEO:"video",EXTERNAL_IMAGES:"external_images",EXTERNAL_CSS:"external_css",EXTERNAL_FONTS:"external_fonts",EXTERNAL_SCRIPTS:"external_scripts",EXTERNAL_USE:"external_use",FOREIGN_OBJECT:"foreign_object",IFRAME:"iframe",FILTERS:"filters",MASKS:"masks",CLIP_PATHS:"clip_paths",HYPERLINKS:"hyperlinks",ANCHORS:"anchors"},$Z=G0(($,J={})=>{let Z=J.verbose||!1,K=J.printTables!==!1,Q=J.includeMetaAnalysis!==!1,H=(S)=>{let E=[],t=S.toLowerCase(),$0=(Q0)=>{if(Q0.tagName&&Q0.tagName.toLowerCase()===t)E.push(Q0);for(let U0 of Q0.children||[])if(U0&&U0.tagName)$0(U0)};return $0($),E},z=(S,E=[])=>{if(S.tagName)E.push(S);for(let t of S.children||[])if(t&&t.tagName)z(t,E);return E},q=(S,...E)=>{for(let t of E)if(S.getAttribute(t))return!0;return!1},j={detected:new Set,details:{}},W=z($),G=H("script");if(G.length>0){if(j.detected.add(X0.JAVASCRIPT),j.details.javascript={count:G.length,hasExternalSrc:G.some((S)=>S.getAttribute("src")||S.getAttribute("href")||S.getAttribute("xlink:href")),types:G.map((S)=>S.getAttribute("type")||"text/javascript")},j.details.javascript.hasExternalSrc)j.detected.add(X0.EXTERNAL_SCRIPTS)}let F=["onclick","ondblclick","onmousedown","onmouseup","onmouseover","onmouseout","onmousemove","onmouseenter","onmouseleave","onfocus","onblur","onkeydown","onkeyup","onkeypress","onload","onerror","onscroll","onwheel","ontouchstart","ontouchend","ontouchmove","onbegin","onend","onrepeat"],_=[];for(let S of W){let E=F.filter((t)=>S.getAttribute(t));if(E.length>0)_.push({tag:S.tagName,handlers:E})}if(_.length>0)j.detected.add(X0.EVENT_HANDLERS),j.details.eventHandlers={count:_.length,types:[...new Set(_.flatMap((S)=>S.handlers))],elements:_.slice(0,10)};let U=["animate","animatetransform","animatemotion","animatecolor","set"],M=[],V=[];for(let S of U){let E=H(S);M.push(...E);for(let t of E){let $0=t.getAttribute("begin")||"",Q0=t.getAttribute("end")||"",U0=["click","dblclick","mousedown","mouseup","mouseover","mouseout","mousemove","mouseenter","mouseleave","focus","blur","focusin","focusout"];for(let C0 of U0)if($0.includes(C0)||Q0.includes(C0))V.push({element:t.tagName,event:C0,begin:$0,end:Q0});if($0.includes("accessKey(")||Q0.includes("accessKey("))V.push({element:t.tagName,event:"accessKey",begin:$0,end:Q0})}}if(M.length>0){if(j.detected.add(X0.SMIL_ANIMATIONS),j.details.smilAnimations={count:M.length,breakdown:{animate:H("animate").length,animateTransform:H("animatetransform").length,animateMotion:H("animatemotion").length,animateColor:H("animatecolor").length,set:H("set").length}},V.length>0)j.detected.add(X0.SMIL_INTERACTIVE),j.details.smilInteractive={count:V.length,triggers:[...new Set(V.map((S)=>S.event))],elements:V.slice(0,10)}}let Y=H("style"),O=!1;for(let S of Y){let E=S.textContent||"";if(E.includes("@keyframes")||E.includes("animation:")||E.includes("animation-name")||E.includes("transition:")||E.includes("transition-property")){O=!0;break}}for(let S of W){let E=S.getAttribute("style")||"";if(E.includes("animation")||E.includes("transition")){O=!0;break}}if(O)j.detected.add(X0.CSS_ANIMATIONS),j.details.cssAnimations={detected:!0};let X=H("audio"),w=H("video"),R=H("foreignobject");for(let S of R){let E=[],t=[],$0=(Q0)=>{let U0=Q0.tagName?.toLowerCase();if(U0==="audio")E.push(Q0);if(U0==="video")t.push(Q0);for(let C0 of Q0.children||[])if(C0&&C0.tagName)$0(C0)};for(let Q0 of S.children||[])if(Q0&&Q0.tagName)$0(Q0);X.push(...E),w.push(...t)}if(X.length>0)j.detected.add(X0.AUDIO),j.details.audio={count:X.length,hasAutoplay:X.some((S)=>S.hasAttribute("autoplay")),sources:X.map((S)=>({id:S.getAttribute("id"),src:S.getAttribute("src"),isDataUri:(S.getAttribute("src")||"").startsWith("data:"),isExternal:(S.getAttribute("src")||"").startsWith("http")}))};if(w.length>0)j.detected.add(X0.VIDEO),j.details.video={count:w.length,hasAutoplay:w.some((S)=>S.hasAttribute("autoplay"))};let B=H("image"),I=[],h=[];for(let S of B){let E=S.getAttribute("href")||S.getAttribute("xlink:href")||"";if(E.startsWith("http://")||E.startsWith("https://")||E.startsWith("//"))I.push({href:E,element:"image"});else if(E.startsWith("data:"))h.push({type:"data-uri",element:"image"});else if(E&&!E.startsWith("#"))I.push({href:E,element:"image",type:"local"})}if(I.length>0)j.detected.add(X0.EXTERNAL_IMAGES),j.details.externalImages={count:I.length,urls:I.slice(0,5)};let m=H("use"),v=[];for(let S of m){let E=S.getAttribute("href")||S.getAttribute("xlink:href")||"";if(E&&!E.startsWith("#"))v.push({href:E})}if(v.length>0)j.detected.add(X0.EXTERNAL_USE),j.details.externalUse={count:v.length,refs:v.slice(0,5)};let x=!1;for(let S of Y){let E=S.textContent||"";if(E.includes("@font-face")&&E.includes("url(")){let t=E.match(/url\(['"]?(https?:\/\/[^'")\s]+)['"]?\)/);if(t){x=!0,j.detected.add(X0.EXTERNAL_FONTS),j.details.externalFonts={detected:!0,sample:t[1]};break}}}if(R.length>0){if(j.detected.add(X0.FOREIGN_OBJECT),j.details.foreignObject={count:R.length,hasIframe:R.some((S)=>{let E=!1,t=($0)=>{if($0.tagName?.toLowerCase()==="iframe")E=!0;for(let Q0 of $0.children||[])if(Q0&&Q0.tagName)t(Q0)};return t(S),E})},j.details.foreignObject.hasIframe)j.detected.add(X0.IFRAME)}let y=H("filter"),T=H("mask"),d=H("clippath");if(y.length>0)j.detected.add(X0.FILTERS),j.details.filters={count:y.length};if(T.length>0)j.detected.add(X0.MASKS),j.details.masks={count:T.length};if(d.length>0)j.detected.add(X0.CLIP_PATHS),j.details.clipPaths={count:d.length};let p=H("a");if(p.length>0)j.detected.add(X0.HYPERLINKS),j.details.hyperlinks={count:p.length,hasExternal:p.some((S)=>{return(S.getAttribute("href")||S.getAttribute("xlink:href")||"").startsWith("http")})};let c={STANDALONE:"standalone",HTML:"html",CUSTOM_RENDERER:"custom"},C={FILE:"file://",HTTP:"http://"},u={INLINE_BASE64:"inline",LOCAL_PATH:"local",REMOTE_URL:"remote"},N={NONE:"none",IMG:"img",OBJECT:"object",EMBED:"embed",INLINE:"inline",CSS:"css",SCRIPT:"script"},e={INLINE_CODE:"inline",LOCAL_SERVER:"local",REMOTE_CDN:"remote"},a={[X0.JAVASCRIPT]:{[N.NONE]:{file:"✅",http:"✅",note:"Full JS execution"},[N.IMG]:{file:"❌",http:"❌",note:"All scripting disabled for security"},[N.OBJECT]:{file:"✅",http:"✅",note:"Isolated JS context"},[N.EMBED]:{file:"✅",http:"✅",note:"Isolated JS context"},[N.INLINE]:{file:"✅",http:"✅",note:"Same JS context as parent page"},[N.CSS]:{file:"❌",http:"❌",note:"CSS image context - no scripts"},[N.SCRIPT]:{file:"✅",http:"✅",note:"JS-generated = full control"}},[X0.EVENT_HANDLERS]:{[N.NONE]:{file:"✅",http:"✅",note:"Full event handling"},[N.IMG]:{file:"❌",http:"❌",note:"No events in img context"},[N.OBJECT]:{file:"✅",http:"✅",note:"Events work, isolated from parent"},[N.EMBED]:{file:"✅",http:"✅",note:"Events work, isolated from parent"},[N.INLINE]:{file:"✅",http:"✅",note:"Full event handling"},[N.CSS]:{file:"❌",http:"❌",note:"No events in CSS context"},[N.SCRIPT]:{file:"✅",http:"✅",note:"Full event handling"}},[X0.SMIL_ANIMATIONS]:{[N.NONE]:{file:"✅",http:"✅",note:"Full SMIL support"},[N.IMG]:{file:"⚠️",http:"⚠️",note:"Time-based only, varies by browser"},[N.OBJECT]:{file:"✅",http:"✅",note:"Full SMIL support"},[N.EMBED]:{file:"✅",http:"✅",note:"Full SMIL support"},[N.INLINE]:{file:"✅",http:"✅",note:"Full SMIL support"},[N.CSS]:{file:"⚠️",http:"⚠️",note:"Time-based only, varies by browser"},[N.SCRIPT]:{file:"✅",http:"✅",note:"Full SMIL support"}},[X0.SMIL_INTERACTIVE]:{[N.NONE]:{file:"✅",http:"✅",note:"Full interactive SMIL"},[N.IMG]:{file:"❌",http:"❌",note:"No interaction in img context"},[N.OBJECT]:{file:"✅",http:"✅",note:"Interactive SMIL works"},[N.EMBED]:{file:"✅",http:"✅",note:"Interactive SMIL works"},[N.INLINE]:{file:"✅",http:"✅",note:"Full interactive SMIL"},[N.CSS]:{file:"❌",http:"❌",note:"No interaction in CSS context"},[N.SCRIPT]:{file:"✅",http:"✅",note:"Full interactive SMIL"}},[X0.CSS_ANIMATIONS]:{[N.NONE]:{file:"✅",http:"✅",note:"Full CSS animation support"},[N.IMG]:{file:"✅",http:"✅",note:"CSS animations work in img"},[N.OBJECT]:{file:"✅",http:"✅",note:"Full CSS animation support"},[N.EMBED]:{file:"✅",http:"✅",note:"Full CSS animation support"},[N.INLINE]:{file:"✅",http:"✅",note:"Full CSS animation support"},[N.CSS]:{file:"✅",http:"✅",note:"CSS animations work"},[N.SCRIPT]:{file:"✅",http:"✅",note:"Full CSS animation support"}},[X0.AUDIO]:{[N.NONE]:{file:"❌",http:"❌",note:"Autoplay blocked, needs user gesture"},[N.IMG]:{file:"❌",http:"❌",note:"No audio in img context"},[N.OBJECT]:{file:"❌",http:"❌",note:"Autoplay blocked"},[N.EMBED]:{file:"❌",http:"❌",note:"Autoplay blocked"},[N.INLINE]:{file:"⚠️",http:"⚠️",note:"Needs JS + user gesture to play"},[N.CSS]:{file:"❌",http:"❌",note:"No audio in CSS context"},[N.SCRIPT]:{file:"✅",http:"✅",note:"JS can play audio on user gesture"}},[X0.VIDEO]:{[N.NONE]:{file:"❌",http:"❌",note:"Autoplay blocked, needs user gesture"},[N.IMG]:{file:"❌",http:"❌",note:"No video in img context"},[N.OBJECT]:{file:"❌",http:"❌",note:"Autoplay blocked"},[N.EMBED]:{file:"❌",http:"❌",note:"Autoplay blocked"},[N.INLINE]:{file:"⚠️",http:"⚠️",note:"Needs JS + user gesture to play"},[N.CSS]:{file:"❌",http:"❌",note:"No video in CSS context"},[N.SCRIPT]:{file:"✅",http:"✅",note:"JS can play video on user gesture"}},[X0.EXTERNAL_IMAGES]:{[N.NONE]:{file:"⚠️",http:"✅",note:"file:// may have CORS issues"},[N.IMG]:{file:"❌",http:"⚠️",note:"Blocked or CORS restricted"},[N.OBJECT]:{file:"⚠️",http:"✅",note:"CORS applies"},[N.EMBED]:{file:"⚠️",http:"✅",note:"CORS applies"},[N.INLINE]:{file:"⚠️",http:"✅",note:"CORS applies"},[N.CSS]:{file:"❌",http:"⚠️",note:"Restricted for security"},[N.SCRIPT]:{file:"⚠️",http:"✅",note:"CORS applies"}},[X0.EXTERNAL_CSS]:{[N.NONE]:{file:"✅",http:"✅",note:"External CSS loaded"},[N.IMG]:{file:"❌",http:"❌",note:"No external resources in img"},[N.OBJECT]:{file:"✅",http:"✅",note:"External CSS works"},[N.EMBED]:{file:"✅",http:"✅",note:"External CSS works"},[N.INLINE]:{file:"✅",http:"✅",note:"External CSS works"},[N.CSS]:{file:"❌",http:"❌",note:"No external resources"},[N.SCRIPT]:{file:"✅",http:"✅",note:"External CSS works"}},[X0.EXTERNAL_FONTS]:{[N.NONE]:{file:"✅",http:"✅",note:"External fonts loaded"},[N.IMG]:{file:"❌",http:"❌",note:"No external resources in img"},[N.OBJECT]:{file:"✅",http:"✅",note:"External fonts work (CORS)"},[N.EMBED]:{file:"✅",http:"✅",note:"External fonts work (CORS)"},[N.INLINE]:{file:"✅",http:"✅",note:"External fonts work (CORS)"},[N.CSS]:{file:"❌",http:"⚠️",note:"Limited, varies by browser"},[N.SCRIPT]:{file:"✅",http:"✅",note:"External fonts work"}},[X0.EXTERNAL_USE]:{[N.NONE]:{file:"❌",http:"⚠️",note:"Most browsers block external use"},[N.IMG]:{file:"❌",http:"❌",note:"No external use in img"},[N.OBJECT]:{file:"❌",http:"⚠️",note:"Most browsers block"},[N.EMBED]:{file:"❌",http:"⚠️",note:"Most browsers block"},[N.INLINE]:{file:"❌",http:"⚠️",note:"Most browsers block"},[N.CSS]:{file:"❌",http:"❌",note:"No external use"},[N.SCRIPT]:{file:"❌",http:"⚠️",note:"Most browsers block"}},[X0.FOREIGN_OBJECT]:{[N.NONE]:{file:"✅",http:"✅",note:"Full foreignObject support"},[N.IMG]:{file:"❌",http:"❌",note:"foreignObject disabled in img"},[N.OBJECT]:{file:"✅",http:"✅",note:"foreignObject works"},[N.EMBED]:{file:"✅",http:"✅",note:"foreignObject works"},[N.INLINE]:{file:"✅",http:"✅",note:"foreignObject works"},[N.CSS]:{file:"❌",http:"❌",note:"foreignObject disabled"},[N.SCRIPT]:{file:"✅",http:"✅",note:"foreignObject works"}},[X0.HYPERLINKS]:{[N.NONE]:{file:"✅",http:"✅",note:"Links work"},[N.IMG]:{file:"❌",http:"❌",note:"No links in img context"},[N.OBJECT]:{file:"✅",http:"✅",note:"Links work (in iframe-like context)"},[N.EMBED]:{file:"✅",http:"✅",note:"Links work"},[N.INLINE]:{file:"✅",http:"✅",note:"Links work normally"},[N.CSS]:{file:"❌",http:"❌",note:"No links in CSS context"},[N.SCRIPT]:{file:"✅",http:"✅",note:"Links work"}},[X0.FILTERS]:{[N.NONE]:{file:"✅",http:"✅",note:"Full filter support"},[N.IMG]:{file:"✅",http:"✅",note:"Filters work"},[N.OBJECT]:{file:"✅",http:"✅",note:"Filters work"},[N.EMBED]:{file:"✅",http:"✅",note:"Filters work"},[N.INLINE]:{file:"✅",http:"✅",note:"Filters work"},[N.CSS]:{file:"✅",http:"✅",note:"Filters work"},[N.SCRIPT]:{file:"✅",http:"✅",note:"Filters work"}}},s={"GitHub README.md":{syntax:"IMG (implicit)",restrictions:["No JavaScript","No SMIL","No external resources","No foreignObject","No links"],worksFor:["Static SVG","CSS animations (some)","Embedded images (data-uri)"],note:"GitHub sanitizes SVG heavily - only safe static content"},"GitHub Flavored Markdown (GFM)":{syntax:"IMG",restrictions:["Same as GitHub README"],worksFor:["Static SVG only"],note:"GFM renders SVG as images"},"GitLab README.md":{syntax:"IMG (implicit)",restrictions:["Similar to GitHub but slightly more permissive"],worksFor:["Static SVG","Some CSS animations"],note:"GitLab also sanitizes SVG"},"Wikipedia/MediaWiki":{syntax:"IMG (sanitized)",restrictions:["Heavy sanitization","No scripts","No external resources","No animations"],worksFor:["Static vector graphics only"],note:"MediaWiki converts SVG to PNG for display"},"EPUB 3.x":{syntax:"IMG or INLINE",restrictions:["No external resources","Limited JavaScript","No autoplay"],worksFor:["Static SVG","CSS animations","SMIL (in some readers)"],note:"Support varies by e-reader - Apple Books better than Kindle"},"Email (HTML email)":{syntax:"IMG (base64)",restrictions:["Heavily filtered","No scripts","No external resources","No animations"],worksFor:["Static embedded SVG only","Many clients block SVG entirely"],note:"Most email clients block or rasterize SVG"},"Slack/Discord":{syntax:"IMG (auto-converted)",restrictions:["Converted to raster","No interactivity"],worksFor:["Static preview only"],note:"SVG files are typically converted to PNG previews"},"Twitter/X":{syntax:"N/A",restrictions:["SVG not supported as media"],worksFor:["Nothing - upload as PNG"],note:"Twitter does not support SVG uploads"},Notion:{syntax:"EMBED/IMG",restrictions:["Limited - treated as image"],worksFor:["Static SVG"],note:"Notion embeds SVG as images"},Obsidian:{syntax:"INLINE or IMG",restrictions:["Depends on mode and plugins"],worksFor:["Static SVG","Some CSS animations"],note:"Obsidian has good local SVG support"},"Bear Notes":{syntax:"IMG",restrictions:["Image context only"],worksFor:["Static SVG"],note:"Bear treats SVG as images"},"Markdown-it":{syntax:"IMG (default)",restrictions:["Default IMG behavior","Can be configured for INLINE"],worksFor:["Depends on configuration"],note:"Parser library - output depends on implementation"},MDX:{syntax:"INLINE (JSX)",restrictions:["Full React component - depends on framework"],worksFor:["Full SVG when used as component"],note:"MDX can import SVG as React components"},"iOS Safari":{syntax:"ALL",restrictions:["Stricter autoplay policies"],worksFor:["All standard SVG features except auto-audio"],note:"Good SVG support, strict media policies"},"Android WebView":{syntax:"ALL",restrictions:["Varies by Android version"],worksFor:["Most SVG features"],note:"WebView behavior varies significantly"},"Cairo/librsvg":{syntax:"CUSTOM_RENDERER",restrictions:["Limited JS","Limited SMIL","No foreignObject"],worksFor:["Static SVG","Basic filters","CSS styling"],note:"Server-side rendering library - no dynamic features"},Inkscape:{syntax:"CUSTOM_RENDERER",restrictions:["May not run JS","SMIL playback varies"],worksFor:["All static SVG","Partial animation preview"],note:"Full SVG editor with preview capabilities"},ImageMagick:{syntax:"CUSTOM_RENDERER",restrictions:["Rasterizes immediately","No animations","No JS"],worksFor:["Static rasterization only"],note:"Converts SVG to raster - no dynamic features"}},H0={timestamp:new Date().toISOString(),features:j,interactivityLevel:"static",bySyntax:{},specialCases:{},recommendations:[],warnings:[]};if(j.detected.has(X0.JAVASCRIPT)||j.detected.has(X0.EVENT_HANDLERS))H0.interactivityLevel="scripted";else if(j.detected.has(X0.SMIL_INTERACTIVE))H0.interactivityLevel="interactive";else if(j.detected.has(X0.SMIL_ANIMATIONS)||j.detected.has(X0.CSS_ANIMATIONS))H0.interactivityLevel="animated";for(let S of Object.values(N)){H0.bySyntax[S]={file:{works:[],partial:[],blocked:[]},http:{works:[],partial:[],blocked:[]}};for(let E of j.detected){let t=a[E];if(t&&t[S]){let{file:$0,http:Q0,note:U0}=t[S];if($0==="✅")H0.bySyntax[S].file.works.push({feature:E,note:U0});else if($0==="⚠️")H0.bySyntax[S].file.partial.push({feature:E,note:U0});else H0.bySyntax[S].file.blocked.push({feature:E,note:U0});if(Q0==="✅")H0.bySyntax[S].http.works.push({feature:E,note:U0});else if(Q0==="⚠️")H0.bySyntax[S].http.partial.push({feature:E,note:U0});else H0.bySyntax[S].http.blocked.push({feature:E,note:U0})}}}for(let[S,E]of Object.entries(s)){let t=[],$0=[];for(let Q0 of j.detected){let C0={[X0.JAVASCRIPT]:"JavaScript",[X0.EVENT_HANDLERS]:"Event handlers",[X0.SMIL_ANIMATIONS]:"SMIL",[X0.SMIL_INTERACTIVE]:"Interactive SMIL",[X0.CSS_ANIMATIONS]:"CSS animations",[X0.AUDIO]:"Audio",[X0.VIDEO]:"Video",[X0.EXTERNAL_IMAGES]:"External images",[X0.EXTERNAL_USE]:"External use",[X0.FOREIGN_OBJECT]:"foreignObject",[X0.HYPERLINKS]:"Links"}[Q0]||Q0;if(E.restrictions.some((o)=>o.toLowerCase().includes(C0.toLowerCase())||o.toLowerCase().includes("no "+C0.toLowerCase())))t.push(C0);else if(E.worksFor.some((K0)=>K0.toLowerCase().includes(C0.toLowerCase())))$0.push(C0)}H0.specialCases[S]={syntax:E.syntax,blockedFeatures:t,workingFeatures:$0,note:E.note,overallCompat:t.length===0?"✅ Compatible":t.length<j.detected.size/2?"⚠️ Partial":"❌ Not compatible"}}if(j.detected.has(X0.AUDIO))H0.recommendations.push({issue:"Audio playback blocked",solution:"Use SCRIPT syntax with user gesture: embed SVG inline, extract audio data-uri via JavaScript, play on click",example:`document.querySelector('svg').addEventListener('click', () => {
31
31
  const audio = new Audio(svgAudioDataUri);
32
32
  audio.play();
33
- });`});if(W.detected.has(X0.SMIL_INTERACTIVE))z0.recommendations.push({issue:"Interactive SMIL animations",solution:"Use OBJECT, EMBED, or INLINE syntax - avoid IMG and CSS background",example:'<object data="animation.svg" type="image/svg+xml"></object>'});if(W.detected.has(X0.JAVASCRIPT))z0.recommendations.push({issue:"JavaScript in SVG",solution:"Use INLINE syntax for same-page JS context, or OBJECT/EMBED for isolated context",example:"<svg><!-- your SVG with scripts --></svg>"});if(W.detected.has(X0.EXTERNAL_IMAGES)||W.detected.has(X0.EXTERNAL_FONTS)||W.detected.has(X0.EXTERNAL_USE))z0.recommendations.push({issue:"External resources",solution:"Embed resources as data-URIs for maximum compatibility, or ensure CORS headers are set",example:"Use svg-toolbox embedExternalDependencies() to inline all resources"});if(z0.interactivityLevel==="scripted")z0.warnings.push("SVG contains JavaScript - will not work in IMG, CSS, or most markdown contexts");if(W.detected.has(X0.FOREIGN_OBJECT))z0.warnings.push("SVG contains foreignObject - disabled in IMG and CSS contexts");if(W.detected.has(X0.EXTERNAL_USE))z0.warnings.push("External <use> references are blocked by most modern browsers");if(K){console.log(`
33
+ });`});if(j.detected.has(X0.SMIL_INTERACTIVE))H0.recommendations.push({issue:"Interactive SMIL animations",solution:"Use OBJECT, EMBED, or INLINE syntax - avoid IMG and CSS background",example:'<object data="animation.svg" type="image/svg+xml"></object>'});if(j.detected.has(X0.JAVASCRIPT))H0.recommendations.push({issue:"JavaScript in SVG",solution:"Use INLINE syntax for same-page JS context, or OBJECT/EMBED for isolated context",example:"<svg><!-- your SVG with scripts --></svg>"});if(j.detected.has(X0.EXTERNAL_IMAGES)||j.detected.has(X0.EXTERNAL_FONTS)||j.detected.has(X0.EXTERNAL_USE))H0.recommendations.push({issue:"External resources",solution:"Embed resources as data-URIs for maximum compatibility, or ensure CORS headers are set",example:"Use svg-toolbox embedExternalDependencies() to inline all resources"});if(H0.interactivityLevel==="scripted")H0.warnings.push("SVG contains JavaScript - will not work in IMG, CSS, or most markdown contexts");if(j.detected.has(X0.FOREIGN_OBJECT))H0.warnings.push("SVG contains foreignObject - disabled in IMG and CSS contexts");if(j.detected.has(X0.EXTERNAL_USE))H0.warnings.push("External <use> references are blocked by most modern browsers");if(K){console.log(`
34
34
  `+"═".repeat(100)),console.log("SVG COMPREHENSIVE COMPATIBILITY MATRIX ANALYSIS"),console.log("═".repeat(100)),console.log(`
35
- ┌`+"─".repeat(98)+"┐"),console.log("│ DETECTED SVG FEATURES"+" ".repeat(76)+"│"),console.log("├"+"─".repeat(98)+"┤"),console.log(`│ Interactivity Level: ${z0.interactivityLevel.toUpperCase().padEnd(75)} │`),console.log("│"+" ".repeat(98)+"│");for(let Q0 of W.detected){let U0=W.details[Q0.replace("_","")]||W.details[Q0]||{},N0=Q0;if(U0.count!==void 0)N0+=` (${U0.count})`;console.log(`│ • ${N0.padEnd(92)} │`)}console.log("└"+"─".repeat(98)+"┘"),console.log(`
36
- ┌`+"─".repeat(98)+"┐"),console.log("│ 5-AXIS COMPATIBILITY MATRIX"+" ".repeat(70)+"│"),console.log("├"+"─".repeat(98)+"┤"),console.log("│ SYNTAX TAG │ PROTOCOL │ WORKS │ PARTIAL │ BLOCKED │"),console.log("├────────────────────┼───────────┼────────────────────────────┼──────────────────┼────────────┤");for(let[Q0,U0]of Object.entries(z0.bySyntax)){let N0={none:"Direct SVG file",img:'<img src="">',object:'<object data="">',embed:'<embed src="">',inline:"<svg>...</svg>",css:"CSS background",script:"JS-generated"}[Q0]||Q0;for(let h0 of["file","http"]){let o=U0[h0],J0=o.works.length>0?o.works.length+" features":"-",F0=o.partial.length>0?o.partial.length+" features":"-",O0=o.blocked.length>0?o.blocked.length+" features":"-";console.log(`│ ${N0.padEnd(18)} │ ${(h0+"://").padEnd(9)} │ ${J0.padEnd(26)} │ ${F0.padEnd(16)} │ ${O0.padEnd(10)} │`)}}console.log("└"+"─".repeat(98)+"┘"),console.log(`
37
- ┌`+"─".repeat(98)+"┐"),console.log("│ RECOMMENDED EMBEDDING METHODS FOR THIS SVG"+" ".repeat(54)+"│"),console.log("├"+"─".repeat(98)+"┤");let T="inline",P=0;for(let[Q0,U0]of Object.entries(z0.bySyntax)){let N0=U0.http.works.length*3+U0.http.partial.length-U0.http.blocked.length*2;if(N0>P)P=N0,T=Q0}let t={none:"Open SVG file directly in browser",img:'<img src="your-file.svg" alt="description">',object:'<object data="your-file.svg" type="image/svg+xml"></object>',embed:'<embed src="your-file.svg" type="image/svg+xml">',inline:"Copy <svg>...</svg> content directly into HTML",css:'.element { background-image: url("your-file.svg"); }',script:'const svgEl = document.createElementNS("http://www.w3.org/2000/svg", "svg"); ...'};if(console.log(`│ BEST: ${T.toUpperCase().padEnd(91)} │`),console.log(`│ ${t[T].substring(0,96).padEnd(96)} │`),console.log("│"+" ".repeat(98)+"│"),z0.interactivityLevel!=="static")console.log("│ AVOID: IMG and CSS background (no interactivity)"+" ".repeat(49)+"│");console.log("└"+"─".repeat(98)+"┘"),console.log(`
38
- ┌`+"─".repeat(98)+"┐"),console.log("│ SPECIAL ENVIRONMENT COMPATIBILITY"+" ".repeat(63)+"│"),console.log("├"+"─".repeat(98)+"┤"),console.log("│ ENVIRONMENT │ COMPAT │ BLOCKED FEATURES"+" ".repeat(43)+"│"),console.log("├───────────────────────────┼────────┼"+"─".repeat(61)+"┤");let $0=["GitHub README.md","EPUB 3.x","Email (HTML email)","Wikipedia/MediaWiki","MDX","Cairo/librsvg","iOS Safari"];for(let Q0 of $0){let U0=z0.specialCases[Q0];if(U0){let N0=U0.overallCompat.substring(0,6).padEnd(6),h0=U0.blockedFeatures.slice(0,3).join(", ").substring(0,58).padEnd(58);console.log(`│ ${Q0.substring(0,25).padEnd(25)} │ ${N0} │ ${h0} │`)}}if(console.log("└"+"─".repeat(98)+"┘"),z0.warnings.length>0){console.log(`
39
- ┌`+"─".repeat(98)+"┐"),console.log("│ ⚠️ WARNINGS"+" ".repeat(85)+"│"),console.log("├"+"─".repeat(98)+"┤");for(let Q0 of z0.warnings)console.log(`│ • ${Q0.substring(0,94).padEnd(94)} │`);console.log("└"+"─".repeat(98)+"┘")}if(z0.recommendations.length>0){console.log(`
40
- ┌`+"─".repeat(98)+"┐"),console.log("│ \uD83D\uDCA1 RECOMMENDATIONS"+" ".repeat(79)+"│"),console.log("├"+"─".repeat(98)+"┤");for(let Q0 of z0.recommendations)console.log(`│ Issue: ${Q0.issue.substring(0,89).padEnd(89)} │`),console.log(`│ Solution: ${Q0.solution.substring(0,86).padEnd(86)} │`),console.log("│"+" ".repeat(98)+"│");console.log("└"+"─".repeat(98)+"┘")}if(W.detected.has(X0.AUDIO))console.log(`
35
+ ┌`+"─".repeat(98)+"┐"),console.log("│ DETECTED SVG FEATURES"+" ".repeat(76)+"│"),console.log("├"+"─".repeat(98)+"┤"),console.log(`│ Interactivity Level: ${H0.interactivityLevel.toUpperCase().padEnd(75)} │`),console.log("│"+" ".repeat(98)+"│");for(let Q0 of j.detected){let U0=j.details[Q0.replace("_","")]||j.details[Q0]||{},C0=Q0;if(U0.count!==void 0)C0+=` (${U0.count})`;console.log(`│ • ${C0.padEnd(92)} │`)}console.log("└"+"─".repeat(98)+"┘"),console.log(`
36
+ ┌`+"─".repeat(98)+"┐"),console.log("│ 5-AXIS COMPATIBILITY MATRIX"+" ".repeat(70)+"│"),console.log("├"+"─".repeat(98)+"┤"),console.log("│ SYNTAX TAG │ PROTOCOL │ WORKS │ PARTIAL │ BLOCKED │"),console.log("├────────────────────┼───────────┼────────────────────────────┼──────────────────┼────────────┤");for(let[Q0,U0]of Object.entries(H0.bySyntax)){let C0={none:"Direct SVG file",img:'<img src="">',object:'<object data="">',embed:'<embed src="">',inline:"<svg>...</svg>",css:"CSS background",script:"JS-generated"}[Q0]||Q0;for(let y0 of["file","http"]){let o=U0[y0],K0=o.works.length>0?o.works.length+" features":"-",F0=o.partial.length>0?o.partial.length+" features":"-",M0=o.blocked.length>0?o.blocked.length+" features":"-";console.log(`│ ${C0.padEnd(18)} │ ${(y0+"://").padEnd(9)} │ ${K0.padEnd(26)} │ ${F0.padEnd(16)} │ ${M0.padEnd(10)} │`)}}console.log("└"+"─".repeat(98)+"┘"),console.log(`
37
+ ┌`+"─".repeat(98)+"┐"),console.log("│ RECOMMENDED EMBEDDING METHODS FOR THIS SVG"+" ".repeat(54)+"│"),console.log("├"+"─".repeat(98)+"┤");let S="inline",E=0;for(let[Q0,U0]of Object.entries(H0.bySyntax)){let C0=U0.http.works.length*3+U0.http.partial.length-U0.http.blocked.length*2;if(C0>E)E=C0,S=Q0}let t={none:"Open SVG file directly in browser",img:'<img src="your-file.svg" alt="description">',object:'<object data="your-file.svg" type="image/svg+xml"></object>',embed:'<embed src="your-file.svg" type="image/svg+xml">',inline:"Copy <svg>...</svg> content directly into HTML",css:'.element { background-image: url("your-file.svg"); }',script:'const svgEl = document.createElementNS("http://www.w3.org/2000/svg", "svg"); ...'};if(console.log(`│ BEST: ${S.toUpperCase().padEnd(91)} │`),console.log(`│ ${t[S].substring(0,96).padEnd(96)} │`),console.log("│"+" ".repeat(98)+"│"),H0.interactivityLevel!=="static")console.log("│ AVOID: IMG and CSS background (no interactivity)"+" ".repeat(49)+"│");console.log("└"+"─".repeat(98)+"┘"),console.log(`
38
+ ┌`+"─".repeat(98)+"┐"),console.log("│ SPECIAL ENVIRONMENT COMPATIBILITY"+" ".repeat(63)+"│"),console.log("├"+"─".repeat(98)+"┤"),console.log("│ ENVIRONMENT │ COMPAT │ BLOCKED FEATURES"+" ".repeat(43)+"│"),console.log("├───────────────────────────┼────────┼"+"─".repeat(61)+"┤");let $0=["GitHub README.md","EPUB 3.x","Email (HTML email)","Wikipedia/MediaWiki","MDX","Cairo/librsvg","iOS Safari"];for(let Q0 of $0){let U0=H0.specialCases[Q0];if(U0){let C0=U0.overallCompat.substring(0,6).padEnd(6),y0=U0.blockedFeatures.slice(0,3).join(", ").substring(0,58).padEnd(58);console.log(`│ ${Q0.substring(0,25).padEnd(25)} │ ${C0} │ ${y0} │`)}}if(console.log("└"+"─".repeat(98)+"┘"),H0.warnings.length>0){console.log(`
39
+ ┌`+"─".repeat(98)+"┐"),console.log("│ ⚠️ WARNINGS"+" ".repeat(85)+"│"),console.log("├"+"─".repeat(98)+"┤");for(let Q0 of H0.warnings)console.log(`│ • ${Q0.substring(0,94).padEnd(94)} │`);console.log("└"+"─".repeat(98)+"┘")}if(H0.recommendations.length>0){console.log(`
40
+ ┌`+"─".repeat(98)+"┐"),console.log("│ \uD83D\uDCA1 RECOMMENDATIONS"+" ".repeat(79)+"│"),console.log("├"+"─".repeat(98)+"┤");for(let Q0 of H0.recommendations)console.log(`│ Issue: ${Q0.issue.substring(0,89).padEnd(89)} │`),console.log(`│ Solution: ${Q0.solution.substring(0,86).padEnd(86)} │`),console.log("│"+" ".repeat(98)+"│");console.log("└"+"─".repeat(98)+"┘")}if(j.detected.has(X0.AUDIO))console.log(`
41
41
  ┌`+"─".repeat(98)+"┐"),console.log("│ \uD83D\uDD0A AUDIO PLAYBACK TRUTH TABLE"+" ".repeat(67)+"│"),console.log("├"+"─".repeat(98)+"┤"),console.log("│ METHOD │ FILE:// │ HTTP:// │ USER GESTURE NEEDED │ RESULT │"),console.log("├─────────────────────────────────────┼─────────┼─────────┼─────────────────────┼──────────────┤"),console.log("│ SVG direct (autoplay) │ ❌ │ ❌ │ Yes but no trigger │ BLOCKED │"),console.log("│ SVG in <img> │ ❌ │ ❌ │ N/A │ NO AUDIO │"),console.log("│ SVG in <object> │ ❌ │ ❌ │ Yes but isolated │ BLOCKED │"),console.log("│ SVG inline + SMIL onbegin │ ⚠️ │ ⚠️ │ SMIL click trigger │ MAYBE │"),console.log("│ SVG inline + JS on click │ ✅ │ ✅ │ Yes - click event │ WORKS │"),console.log("│ HTML extracts audio, plays on click │ ✅ │ ✅ │ Yes - click event │ RECOMMENDED │"),console.log("└"+"─".repeat(98)+"┘"),console.log(`
42
42
  ┌`+"─".repeat(98)+"┐"),console.log("│ \uD83D\uDCDD AUDIO SOLUTION CODE EXAMPLE"+" ".repeat(66)+"│"),console.log("├"+"─".repeat(98)+"┤"),console.log("│ // In your HTML page: │"),console.log('│ <button id="play">Click to Play SVG Audio</button> │'),console.log('│ <object id="svg" data="your-audio.svg" type="image/svg+xml"></object> │'),console.log("│ │"),console.log("│ <script> │"),console.log('│ document.getElementById("play").addEventListener("click", () => { │'),console.log('│ const svgDoc = document.getElementById("svg").contentDocument; │'),console.log('│ const audioSrc = svgDoc.querySelector("source")?.getAttribute("src"); │'),console.log("│ if (audioSrc) new Audio(audioSrc).play(); │"),console.log("│ }); │"),console.log("│ </script> │"),console.log("└"+"─".repeat(98)+"┘");console.log(`
43
43
  `+"═".repeat(100)+`
44
- `)}return $._compatibilityMatrix=z0,$}),pK=j0(($,J={})=>{let Z=J.printFullMatrix||!1,K=J.groupBySyntax!==!1,Q=J.showOnlyIssues!==!1,H=J.browserDetails!==!1,z=J.filterCapabilities||null,q=(o)=>{let J0=[],F0=o.toLowerCase(),O0=(R0)=>{if(R0.tagName&&R0.tagName.toLowerCase()===F0)J0.push(R0);for(let I0 of R0.children||[])if(I0&&I0.tagName)O0(I0)};return O0($),J0},W=(o,J0=[])=>{if(o.tagName)J0.push(o);for(let F0 of o.children||[])if(F0&&F0.tagName)W(F0,J0);return J0},j=new Set,G={},F=W($);if(F.length>1)j.add("RENDER_VECTORS"),j.add("RENDER_TRANSFORMS");let U=q("text").concat(q("tspan"));if(U.length>0)j.add("RENDER_TEXT"),G.RENDER_TEXT={count:U.length};let O=q("linearGradient"),V=q("radialGradient");if(O.length>0||V.length>0)j.add("RENDER_GRADIENTS"),G.RENDER_GRADIENTS={linear:O.length,radial:V.length};let M=q("pattern");if(M.length>0)j.add("RENDER_PATTERNS"),G.RENDER_PATTERNS={count:M.length};for(let o of F)if(o.getAttribute("opacity")||o.getAttribute("fill-opacity")||o.getAttribute("stroke-opacity")||(o.getAttribute("style")||"").includes("opacity")){j.add("RENDER_OPACITY");break}for(let o of F)if((o.getAttribute("style")||"").includes("mix-blend-mode")||o.getAttribute("mix-blend-mode")){j.add("RENDER_BLENDMODES");break}let Y=q("style");for(let o of Y){let J0=o.textContent||"";if(J0.includes("@font-face")){if(J0.includes("data:"))j.add("FONTS_EMBEDDED");else if(J0.includes("url(")&&J0.match(/url\s*\(\s*['"]?https?:/))j.add("FONTS_WEB_CROSS");else if(J0.includes("url("))j.add("FONTS_WEB_SAME")}}if(U.length>0)j.add("FONTS_SYSTEM");let X=q("image");for(let o of X){let J0=o.getAttribute("href")||o.getAttribute("xlink:href")||"";if(J0.startsWith("data:"))j.add("IMAGES_EMBEDDED");else if(J0.startsWith("http://")||J0.startsWith("https://")){let F0=!0;try{let O0=new URL(J0),R0=new URL($.documentURI||$.baseURI||"");F0=O0.origin!==R0.origin}catch(O0){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${O0.message}`);F0=!0}j.add(F0?"IMAGES_REMOTE_CROSS":"IMAGES_REMOTE_SAME")}else if(J0&&!J0.startsWith("#"))j.add("IMAGES_LOCAL")}G.IMAGES={count:X.length};let w=q("filter");if(w.length>0){j.add("FILTERS_BASIC");for(let o of w){let J0=o.outerHTML||"";if(J0.includes("feTurbulence")||J0.includes("feLighting")||J0.includes("feConvolveMatrix")||J0.includes("feDisplacementMap")){j.add("FILTERS_COMPLEX");break}}G.FILTERS={count:w.length}}let R=q("mask");if(R.length>0)j.add("MASKS"),G.MASKS={count:R.length};let I=q("clippath");if(I.length>0)j.add("CLIP_PATHS"),G.CLIP_PATHS={count:I.length};let b=["animate","animatetransform","animatemotion","animatecolor","set"],u=0,m={timed:0,click:0,hover:0,focus:0,accesskey:0,syncbase:0};for(let o of b){let J0=q(o);u+=J0.length;for(let F0 of J0){let O0=(F0.getAttribute("begin")||"").toLowerCase(),R0=(F0.getAttribute("end")||"").toLowerCase(),I0=O0+" "+R0;if(I0.includes("click")||I0.includes("dblclick"))m.click++,j.add("SMIL_CLICK");if(I0.includes("mouseover")||I0.includes("mouseout")||I0.includes("mouseenter")||I0.includes("mouseleave"))m.hover++,j.add("SMIL_HOVER");if(I0.includes("focus")||I0.includes("blur"))m.focus++,j.add("SMIL_FOCUS");if(I0.includes("accesskey("))m.accesskey++,j.add("SMIL_ACCESSKEY");if(I0.match(/\w+\.(begin|end)/))m.syncbase++,j.add("SMIL_SYNCBASE");if(!I0.includes("click")&&!I0.includes("mouse")&&!I0.includes("focus")&&!I0.includes("accesskey"))m.timed++}}if(u>0)j.add("SMIL_TIMED"),G.SMIL={count:u,triggers:m};let S=!1,x=!1,h=!1;for(let o of Y){let J0=o.textContent||"";if(J0.includes("@keyframes"))S=!0;if(J0.includes("transition:")||J0.includes("transition-property"))x=!0;if(J0.includes(":hover"))h=!0}if(S)j.add("CSS_KEYFRAMES");if(x)j.add("CSS_TRANSITIONS");if(h)j.add("CSS_HOVER");let E=q("script");if(E.length>0){for(let o of E){let J0=o.getAttribute("src")||o.getAttribute("href")||o.getAttribute("xlink:href"),F0=o.getAttribute("type")||"";if(J0)j.add("SCRIPT_EXTERNAL");else j.add("SCRIPT_INLINE");if(F0==="module")j.add("SCRIPT_MODULE")}G.SCRIPTS={count:E.length}}let d=["onclick","ondblclick","onmousedown","onmouseup","onmouseover","onmouseout","onmousemove","onmouseenter","onmouseleave","onfocus","onblur","onkeydown","onkeyup","onkeypress","onload","onerror","onscroll","onwheel","ontouchstart","ontouchend","ontouchmove"],c={onclick:"EVENT_ONCLICK",ondblclick:"EVENT_ONDBLCLICK",onmousedown:"EVENT_ONMOUSEDOWN",onmouseup:"EVENT_ONMOUSEUP",onmouseover:"EVENT_ONMOUSEOVER",onmouseout:"EVENT_ONMOUSEOUT",onmousemove:"EVENT_ONMOUSEMOVE",onfocus:"EVENT_ONFOCUS",onblur:"EVENT_ONBLUR",onload:"EVENT_ONLOAD",onerror:"EVENT_ONERROR",onscroll:"EVENT_ONSCROLL",onwheel:"EVENT_ONWHEEL",ontouchstart:"EVENT_ONTOUCH",ontouchend:"EVENT_ONTOUCH",ontouchmove:"EVENT_ONTOUCH",onkeydown:"EVENT_ONKEYBOARD",onkeyup:"EVENT_ONKEYBOARD",onkeypress:"EVENT_ONKEYBOARD"};for(let o of F)for(let J0 of d)if(o.getAttribute(J0)){let F0=c[J0];if(F0)j.add(F0)}let p=q("a");if(p.length>0){for(let o of p){if((o.getAttribute("href")||o.getAttribute("xlink:href")||"").startsWith("#"))j.add("LINK_INTERNAL");else j.add("LINK_EXTERNAL");if(o.getAttribute("target"))j.add("LINK_TARGET");if(o.getAttribute("download"))j.add("LINK_DOWNLOAD")}G.LINKS={count:p.length}}let N=q("foreignobject");if(N.length>0){j.add("FOREIGNOBJECT_BASIC"),j.add("FOREIGNOBJECT_HTML");for(let o of N){let J0=(F0)=>{let O0=F0.tagName?.toLowerCase();if(O0==="form")j.add("FOREIGNOBJECT_FORM");if(O0==="input"||O0==="textarea"||O0==="select")j.add("FOREIGNOBJECT_INPUT");if(O0==="canvas")j.add("FOREIGNOBJECT_CANVAS");if(O0==="video")j.add("FOREIGNOBJECT_VIDEO");if(O0==="iframe")j.add("FOREIGNOBJECT_IFRAME");for(let R0 of F0.children||[])if(R0&&R0.tagName)J0(R0)};J0(o)}G.FOREIGNOBJECT={count:N.length}}let y=q("audio"),B=q("video");for(let o of N){let J0=(F0)=>{let O0=F0.tagName?.toLowerCase();if(O0==="audio")y.push(F0);if(O0==="video")B.push(F0);for(let R0 of F0.children||[])if(R0&&R0.tagName)J0(R0)};J0(o)}if(y.length>0){for(let o of y){let J0=o.getAttribute("src")||"",F0=q("source").filter((R0)=>R0.parentNode===o),O0=J0||(F0.length>0?F0[0].getAttribute("src"):"");if(O0?.startsWith("data:"))j.add("AUDIO_EMBEDDED");else if(O0?.startsWith("http"))j.add("AUDIO_REMOTE");else if(O0)j.add("AUDIO_LOCAL");if(o.hasAttribute("autoplay"))j.add("AUDIO_AUTOPLAY");if(o.hasAttribute("controls"))j.add("AUDIO_CONTROLS")}G.AUDIO={count:y.length}}if(B.length>0){for(let o of B){let J0=o.getAttribute("src")||"";if(J0.startsWith("data:"))j.add("VIDEO_EMBEDDED");else if(J0.startsWith("http"))j.add("VIDEO_REMOTE");else if(J0)j.add("VIDEO_LOCAL");if(o.hasAttribute("autoplay"))j.add("VIDEO_AUTOPLAY")}G.VIDEO={count:B.length}}let e=q("use");if(e.length>0){for(let o of e){let J0=o.getAttribute("href")||o.getAttribute("xlink:href")||"";if(J0.startsWith("#"))j.add("USE_INTERNAL");else if(J0.startsWith("http"))j.add("USE_EXTERNAL_CROSS");else if(J0)j.add("USE_EXTERNAL_SAME")}j.add("USE_SHADOW_DOM"),G.USE={count:e.length}}for(let o of F){for(let J0 of o.getAttributeNames?.()||[])if(J0.startsWith("aria-")){j.add("A11Y_ARIA");break}if(o.getAttribute("role"))j.add("A11Y_ROLE");if(o.getAttribute("tabindex"))j.add("A11Y_TABINDEX")}if(q("title").length>0||q("desc").length>0)j.add("A11Y_TITLE");for(let o of F){for(let J0 of o.getAttributeNames?.()||[])if(J0.startsWith("data-")){j.add("META_DATA_ATTRS");break}if(o.getAttribute("class"))j.add("META_CLASS");if(o.getAttribute("id"))j.add("META_ID")}for(let o of Y)if((o.textContent||"").includes("@import"))j.add("EXT_CSS_IMPORT");for(let o of F)for(let J0 of o.getAttributeNames?.()||[])if(J0.startsWith("xlink:")){j.add("EXT_XLINK");break}let r={timestamp:new Date().toISOString(),detectedCapabilities:[...j],capabilityDetails:G,totalCombinations:0,combinationsWithIssues:0,cells:[]},s=(o,J0,F0,O0,R0,I0)=>{let f=Z8[o];if(!f)return{status:L.DEPENDS,note:"No compatibility data",browsers:[]};let C=f.default,l="",g=[];for(let[n,G0]of Object.entries(f.exceptions||{})){let L0=!1;if(n.startsWith("syntax:")){let P0=n.substring(7);if(P0==="*"||P0===R0.id||P0.includes("*")&&R0.id.startsWith(P0.replace("*","")))L0=!0}else if(n.startsWith("load:")){if(n.substring(5)===F0.id)L0=!0}else if(n.startsWith("storage:")){if(n.substring(8)===O0.id)L0=!0}else if(n.startsWith("display:")){if(n.substring(8)===J0.id)L0=!0}else if(n.startsWith("renderer:")){let P0=n.substring(9);if(P0==="*"&&J0.type==="renderer")L0=!0;if(P0===J0.id)L0=!0}else if(n.startsWith("browser:")){let P0=n.substring(8);if(P0==="*")for(let E0 of Object.values(hK))g.push({browser:E0.name,status:G0.status,note:G0.note});else{let E0=Object.values(hK).find((U7)=>U7.id===P0);if(E0)g.push({browser:E0.name,status:G0.status,note:G0.note})}}if(L0)C=G0.status,l=G0.note||""}return{status:C,note:l,browserIssues:g}},z0=Object.values(xz),T=Object.values(mz),P=Object.values(dz),t=Object.values(DK),$0=Object.values(pz);for(let o of z0)for(let J0 of T)for(let F0 of P)for(let O0 of t)for(let R0 of $0){if(r.totalCombinations++,R0.script&&!["script-inner","script-dom","script-fetch"].includes(O0.id))continue;if(o.type==="renderer"&&O0.html)continue;let I0=[],f={};for(let C of j){if(z){let n=r6[C];if(n&&!z.includes(n.cat))continue}let l=s(C,o,J0,F0,O0,R0),g=r6[C]||{name:C,cat:"unknown"};if(f[C]={name:g.name,category:g.cat,status:l.status,note:l.note,browserIssues:l.browserIssues},l.status!==L.WORKS&&l.status!==L.NA)I0.push({capability:C,name:g.name,category:g.cat,status:l.status,note:l.note,browserIssues:l.browserIssues})}if(I0.length>0||!Q){let C={combination:{display:o.name,displayId:o.id,displayType:o.type,load:J0.name,loadId:J0.id,storage:F0.name,storageId:F0.id,syntax:O0.name,syntaxId:O0.id,processing:R0.name,processingId:R0.id},issueCount:I0.length,issues:I0,allCapabilities:f};if(r.cells.push(C),I0.length>0)r.combinationsWithIssues++}}console.log(`
44
+ `)}return $._compatibilityMatrix=H0,$}),JZ=G0(($,J={})=>{let Z=J.printFullMatrix||!1,K=J.groupBySyntax!==!1,Q=J.showOnlyIssues!==!1,H=J.browserDetails!==!1,z=J.filterCapabilities||null,q=(o)=>{let K0=[],F0=o.toLowerCase(),M0=(N0)=>{if(N0.tagName&&N0.tagName.toLowerCase()===F0)K0.push(N0);for(let I0 of N0.children||[])if(I0&&I0.tagName)M0(I0)};return M0($),K0},j=(o,K0=[])=>{if(o.tagName)K0.push(o);for(let F0 of o.children||[])if(F0&&F0.tagName)j(F0,K0);return K0},W=new Set,G={},F=j($);if(F.length>1)W.add("RENDER_VECTORS"),W.add("RENDER_TRANSFORMS");let U=q("text").concat(q("tspan"));if(U.length>0)W.add("RENDER_TEXT"),G.RENDER_TEXT={count:U.length};let M=q("linearGradient"),V=q("radialGradient");if(M.length>0||V.length>0)W.add("RENDER_GRADIENTS"),G.RENDER_GRADIENTS={linear:M.length,radial:V.length};let Y=q("pattern");if(Y.length>0)W.add("RENDER_PATTERNS"),G.RENDER_PATTERNS={count:Y.length};for(let o of F)if(o.getAttribute("opacity")||o.getAttribute("fill-opacity")||o.getAttribute("stroke-opacity")||(o.getAttribute("style")||"").includes("opacity")){W.add("RENDER_OPACITY");break}for(let o of F)if((o.getAttribute("style")||"").includes("mix-blend-mode")||o.getAttribute("mix-blend-mode")){W.add("RENDER_BLENDMODES");break}let O=q("style");for(let o of O){let K0=o.textContent||"";if(K0.includes("@font-face")){if(K0.includes("data:"))W.add("FONTS_EMBEDDED");else if(K0.includes("url(")&&K0.match(/url\s*\(\s*['"]?https?:/))W.add("FONTS_WEB_CROSS");else if(K0.includes("url("))W.add("FONTS_WEB_SAME")}}if(U.length>0)W.add("FONTS_SYSTEM");let X=q("image");for(let o of X){let K0=o.getAttribute("href")||o.getAttribute("xlink:href")||"";if(K0.startsWith("data:"))W.add("IMAGES_EMBEDDED");else if(K0.startsWith("http://")||K0.startsWith("https://")){let F0=!0;try{let M0=new URL(K0),N0=new URL($.documentURI||$.baseURI||"");F0=M0.origin!==N0.origin}catch(M0){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${M0.message}`);F0=!0}W.add(F0?"IMAGES_REMOTE_CROSS":"IMAGES_REMOTE_SAME")}else if(K0&&!K0.startsWith("#"))W.add("IMAGES_LOCAL")}G.IMAGES={count:X.length};let w=q("filter");if(w.length>0){W.add("FILTERS_BASIC");for(let o of w){let K0=o.outerHTML||"";if(K0.includes("feTurbulence")||K0.includes("feLighting")||K0.includes("feConvolveMatrix")||K0.includes("feDisplacementMap")){W.add("FILTERS_COMPLEX");break}}G.FILTERS={count:w.length}}let R=q("mask");if(R.length>0)W.add("MASKS"),G.MASKS={count:R.length};let B=q("clippath");if(B.length>0)W.add("CLIP_PATHS"),G.CLIP_PATHS={count:B.length};let I=["animate","animatetransform","animatemotion","animatecolor","set"],h=0,m={timed:0,click:0,hover:0,focus:0,accesskey:0,syncbase:0};for(let o of I){let K0=q(o);h+=K0.length;for(let F0 of K0){let M0=(F0.getAttribute("begin")||"").toLowerCase(),N0=(F0.getAttribute("end")||"").toLowerCase(),I0=M0+" "+N0;if(I0.includes("click")||I0.includes("dblclick"))m.click++,W.add("SMIL_CLICK");if(I0.includes("mouseover")||I0.includes("mouseout")||I0.includes("mouseenter")||I0.includes("mouseleave"))m.hover++,W.add("SMIL_HOVER");if(I0.includes("focus")||I0.includes("blur"))m.focus++,W.add("SMIL_FOCUS");if(I0.includes("accesskey("))m.accesskey++,W.add("SMIL_ACCESSKEY");if(I0.match(/\w+\.(begin|end)/))m.syncbase++,W.add("SMIL_SYNCBASE");if(!I0.includes("click")&&!I0.includes("mouse")&&!I0.includes("focus")&&!I0.includes("accesskey"))m.timed++}}if(h>0)W.add("SMIL_TIMED"),G.SMIL={count:h,triggers:m};let v=!1,x=!1,y=!1;for(let o of O){let K0=o.textContent||"";if(K0.includes("@keyframes"))v=!0;if(K0.includes("transition:")||K0.includes("transition-property"))x=!0;if(K0.includes(":hover"))y=!0}if(v)W.add("CSS_KEYFRAMES");if(x)W.add("CSS_TRANSITIONS");if(y)W.add("CSS_HOVER");let T=q("script");if(T.length>0){for(let o of T){let K0=o.getAttribute("src")||o.getAttribute("href")||o.getAttribute("xlink:href"),F0=o.getAttribute("type")||"";if(K0)W.add("SCRIPT_EXTERNAL");else W.add("SCRIPT_INLINE");if(F0==="module")W.add("SCRIPT_MODULE")}G.SCRIPTS={count:T.length}}let d=["onclick","ondblclick","onmousedown","onmouseup","onmouseover","onmouseout","onmousemove","onmouseenter","onmouseleave","onfocus","onblur","onkeydown","onkeyup","onkeypress","onload","onerror","onscroll","onwheel","ontouchstart","ontouchend","ontouchmove"],p={onclick:"EVENT_ONCLICK",ondblclick:"EVENT_ONDBLCLICK",onmousedown:"EVENT_ONMOUSEDOWN",onmouseup:"EVENT_ONMOUSEUP",onmouseover:"EVENT_ONMOUSEOVER",onmouseout:"EVENT_ONMOUSEOUT",onmousemove:"EVENT_ONMOUSEMOVE",onfocus:"EVENT_ONFOCUS",onblur:"EVENT_ONBLUR",onload:"EVENT_ONLOAD",onerror:"EVENT_ONERROR",onscroll:"EVENT_ONSCROLL",onwheel:"EVENT_ONWHEEL",ontouchstart:"EVENT_ONTOUCH",ontouchend:"EVENT_ONTOUCH",ontouchmove:"EVENT_ONTOUCH",onkeydown:"EVENT_ONKEYBOARD",onkeyup:"EVENT_ONKEYBOARD",onkeypress:"EVENT_ONKEYBOARD"};for(let o of F)for(let K0 of d)if(o.getAttribute(K0)){let F0=p[K0];if(F0)W.add(F0)}let c=q("a");if(c.length>0){for(let o of c){if((o.getAttribute("href")||o.getAttribute("xlink:href")||"").startsWith("#"))W.add("LINK_INTERNAL");else W.add("LINK_EXTERNAL");if(o.getAttribute("target"))W.add("LINK_TARGET");if(o.getAttribute("download"))W.add("LINK_DOWNLOAD")}G.LINKS={count:c.length}}let C=q("foreignobject");if(C.length>0){W.add("FOREIGNOBJECT_BASIC"),W.add("FOREIGNOBJECT_HTML");for(let o of C){let K0=(F0)=>{let M0=F0.tagName?.toLowerCase();if(M0==="form")W.add("FOREIGNOBJECT_FORM");if(M0==="input"||M0==="textarea"||M0==="select")W.add("FOREIGNOBJECT_INPUT");if(M0==="canvas")W.add("FOREIGNOBJECT_CANVAS");if(M0==="video")W.add("FOREIGNOBJECT_VIDEO");if(M0==="iframe")W.add("FOREIGNOBJECT_IFRAME");for(let N0 of F0.children||[])if(N0&&N0.tagName)K0(N0)};K0(o)}G.FOREIGNOBJECT={count:C.length}}let u=q("audio"),N=q("video");for(let o of C){let K0=(F0)=>{let M0=F0.tagName?.toLowerCase();if(M0==="audio")u.push(F0);if(M0==="video")N.push(F0);for(let N0 of F0.children||[])if(N0&&N0.tagName)K0(N0)};K0(o)}if(u.length>0){for(let o of u){let K0=o.getAttribute("src")||"",F0=q("source").filter((N0)=>N0.parentNode===o),M0=K0||(F0.length>0?F0[0].getAttribute("src"):"");if(M0?.startsWith("data:"))W.add("AUDIO_EMBEDDED");else if(M0?.startsWith("http"))W.add("AUDIO_REMOTE");else if(M0)W.add("AUDIO_LOCAL");if(o.hasAttribute("autoplay"))W.add("AUDIO_AUTOPLAY");if(o.hasAttribute("controls"))W.add("AUDIO_CONTROLS")}G.AUDIO={count:u.length}}if(N.length>0){for(let o of N){let K0=o.getAttribute("src")||"";if(K0.startsWith("data:"))W.add("VIDEO_EMBEDDED");else if(K0.startsWith("http"))W.add("VIDEO_REMOTE");else if(K0)W.add("VIDEO_LOCAL");if(o.hasAttribute("autoplay"))W.add("VIDEO_AUTOPLAY")}G.VIDEO={count:N.length}}let e=q("use");if(e.length>0){for(let o of e){let K0=o.getAttribute("href")||o.getAttribute("xlink:href")||"";if(K0.startsWith("#"))W.add("USE_INTERNAL");else if(K0.startsWith("http"))W.add("USE_EXTERNAL_CROSS");else if(K0)W.add("USE_EXTERNAL_SAME")}W.add("USE_SHADOW_DOM"),G.USE={count:e.length}}for(let o of F){for(let K0 of o.getAttributeNames?.()||[])if(K0.startsWith("aria-")){W.add("A11Y_ARIA");break}if(o.getAttribute("role"))W.add("A11Y_ROLE");if(o.getAttribute("tabindex"))W.add("A11Y_TABINDEX")}if(q("title").length>0||q("desc").length>0)W.add("A11Y_TITLE");for(let o of F){for(let K0 of o.getAttributeNames?.()||[])if(K0.startsWith("data-")){W.add("META_DATA_ATTRS");break}if(o.getAttribute("class"))W.add("META_CLASS");if(o.getAttribute("id"))W.add("META_ID")}for(let o of O)if((o.textContent||"").includes("@import"))W.add("EXT_CSS_IMPORT");for(let o of F)for(let K0 of o.getAttributeNames?.()||[])if(K0.startsWith("xlink:")){W.add("EXT_XLINK");break}let a={timestamp:new Date().toISOString(),detectedCapabilities:[...W],capabilityDetails:G,totalCombinations:0,combinationsWithIssues:0,cells:[]},s=(o,K0,F0,M0,N0,I0)=>{let f=j8[o];if(!f)return{status:k.DEPENDS,note:"No compatibility data",browsers:[]};let P=f.default,l="",g=[];for(let[n,q0]of Object.entries(f.exceptions||{})){let L0=!1;if(n.startsWith("syntax:")){let E0=n.substring(7);if(E0==="*"||E0===N0.id||E0.includes("*")&&N0.id.startsWith(E0.replace("*","")))L0=!0}else if(n.startsWith("load:")){if(n.substring(5)===F0.id)L0=!0}else if(n.startsWith("storage:")){if(n.substring(8)===M0.id)L0=!0}else if(n.startsWith("display:")){if(n.substring(8)===K0.id)L0=!0}else if(n.startsWith("renderer:")){let E0=n.substring(9);if(E0==="*"&&K0.type==="renderer")L0=!0;if(E0===K0.id)L0=!0}else if(n.startsWith("browser:")){let E0=n.substring(8);if(E0==="*")for(let T0 of Object.values(oK))g.push({browser:T0.name,status:q0.status,note:q0.note});else{let T0=Object.values(oK).find((V7)=>V7.id===E0);if(T0)g.push({browser:T0.name,status:q0.status,note:q0.note})}}if(L0)P=q0.status,l=q0.note||""}return{status:P,note:l,browserIssues:g}},H0=Object.values(Kq),S=Object.values(Zq),E=Object.values(Qq),t=Object.values(sK),$0=Object.values(Hq);for(let o of H0)for(let K0 of S)for(let F0 of E)for(let M0 of t)for(let N0 of $0){if(a.totalCombinations++,N0.script&&!["script-inner","script-dom","script-fetch"].includes(M0.id))continue;if(o.type==="renderer"&&M0.html)continue;let I0=[],f={};for(let P of W){if(z){let n=t6[P];if(n&&!z.includes(n.cat))continue}let l=s(P,o,K0,F0,M0,N0),g=t6[P]||{name:P,cat:"unknown"};if(f[P]={name:g.name,category:g.cat,status:l.status,note:l.note,browserIssues:l.browserIssues},l.status!==k.WORKS&&l.status!==k.NA)I0.push({capability:P,name:g.name,category:g.cat,status:l.status,note:l.note,browserIssues:l.browserIssues})}if(I0.length>0||!Q){let P={combination:{display:o.name,displayId:o.id,displayType:o.type,load:K0.name,loadId:K0.id,storage:F0.name,storageId:F0.id,syntax:M0.name,syntaxId:M0.id,processing:N0.name,processingId:N0.id},issueCount:I0.length,issues:I0,allCapabilities:f};if(a.cells.push(P),I0.length>0)a.combinationsWithIssues++}}console.log(`
45
45
  `+"═".repeat(120)),console.log("╔"+"═".repeat(118)+"╗"),console.log("║"+" FULL COMBINATORIAL SVG COMPATIBILITY MATRIX ".padStart(82).padEnd(118)+"║"),console.log("║"+" ALL AXIS COMBINATIONS × ALL CAPABILITIES × ALL BROWSERS ".padStart(88).padEnd(118)+"║"),console.log("╚"+"═".repeat(118)+"╝"),console.log(`
46
- ┌`+"─".repeat(118)+"┐"),console.log("│ SUMMARY STATISTICS"+" ".repeat(99)+"│"),console.log("├"+"─".repeat(118)+"┤"),console.log(`│ Total axis combinations evaluated: ${r.totalCombinations.toString().padEnd(80)} │`),console.log(`│ Combinations with issues: ${r.combinationsWithIssues.toString().padEnd(89)} │`),console.log(`│ Detected capabilities in SVG: ${r.detectedCapabilities.length.toString().padEnd(85)} │`),console.log("└"+"─".repeat(118)+"┘"),console.log(`
47
- ┌`+"─".repeat(118)+"┐"),console.log("│ DETECTED SVG CAPABILITIES"+" ".repeat(92)+"│"),console.log("├"+"─".repeat(118)+"┤");let Q0={};for(let o of j){let J0=r6[o]||{cat:"unknown",name:o};if(!Q0[J0.cat])Q0[J0.cat]=[];Q0[J0.cat].push({key:o,name:J0.name})}for(let[o,J0]of Object.entries(Q0)){let F0=o.toUpperCase();console.log(`│ ${F0}:`.padEnd(119)+"│");for(let O0 of J0){let R0=G[O0.key.split("_")[0]]||{},I0=` • ${O0.name}`;if(R0.count!==void 0)I0+=` (${R0.count})`;console.log(`│ ${I0}`.padEnd(119)+"│")}}if(console.log("└"+"─".repeat(118)+"┘"),K){console.log(`
48
- ╔`+"═".repeat(118)+"╗"),console.log("║ FULL COMPATIBILITY MATRIX BY EMBEDDING METHOD"+" ".repeat(71)+"║"),console.log("╚"+"═".repeat(118)+"╝");let o={};for(let J0 of r.cells){let F0=J0.combination.syntaxId;if(!o[F0])o[F0]=[];o[F0].push(J0)}for(let[J0,F0]of Object.entries(o)){let O0=Object.values(DK).find((f)=>f.id===J0),R0=O0?O0.name:J0;console.log(`
49
- ┌`+"─".repeat(118)+"┐"),console.log(`│ SYNTAX: ${R0}`.padEnd(119)+"│"),console.log("├"+"─".repeat(30)+"┬"+"─".repeat(20)+"┬"+"─".repeat(25)+"┬"+"─".repeat(40)+"┤"),console.log("│ CONTEXT COMBINATION │ ISSUES │ BLOCKED CAPABILITIES │ BROWSER-SPECIFIC NOTES │"),console.log("├"+"─".repeat(30)+"┼"+"─".repeat(20)+"┼"+"─".repeat(25)+"┼"+"─".repeat(40)+"┤"),F0.sort((f,C)=>C.issueCount-f.issueCount);let I0=Z?F0:F0.slice(0,20);for(let f of I0){let C=`${(f.combination.displayId||"").substring(0,8)}/${f.combination.loadId}/${(f.combination.storageId||"").substring(0,8)}`,l=f.issueCount.toString(),g=f.issues.filter((G0)=>G0.status===L.BLOCKED).map((G0)=>(G0.name||"").substring(0,15)).slice(0,2).join(", "),n=f.issues.flatMap((G0)=>G0.browserIssues||[]).slice(0,2).map((G0)=>`${G0.browser}: ${G0.note?.substring(0,15)||""}`).join("; ");console.log(`│ ${C.padEnd(28)} │ ${l.padEnd(18)} │ ${(g||"-").substring(0,23).padEnd(23)} │ ${(n||"-").substring(0,38).padEnd(38)} │`)}if(!Z&&F0.length>20)console.log(`│ ... and ${F0.length-20} more combinations`.padEnd(119)+"│");console.log("└"+"─".repeat(30)+"┴"+"─".repeat(20)+"┴"+"─".repeat(25)+"┴"+"─".repeat(40)+"┘")}}console.log(`
50
- ╔`+"═".repeat(118)+"╗"),console.log("║ DETAILED ISSUE BREAKDOWN BY CAPABILITY"+" ".repeat(78)+"║"),console.log("╚"+"═".repeat(118)+"╝");for(let o of j){let J0=r6[o]||{name:o,cat:"unknown"},F0=Z8[o];if(console.log(`
51
- ┌`+"─".repeat(118)+"┐"),console.log(`│ ${J0.name} (${J0.cat})`.padEnd(119)+"│"),console.log("├"+"─".repeat(118)+"┤"),!F0)console.log("│ No compatibility data available".padEnd(119)+"│");else if(console.log(`│ Default status: ${F0.default}`.padEnd(119)+"│"),Object.keys(F0.exceptions||{}).length>0){console.log("│ Exceptions:".padEnd(119)+"│");for(let[O0,R0]of Object.entries(F0.exceptions)){let I0=` ${O0}: ${R0.status} - ${R0.note||"No details"}`;console.log(`│ ${I0.substring(0,116)}`.padEnd(119)+"│")}}console.log("└"+"─".repeat(118)+"┘")}if(H){console.log(`
46
+ ┌`+"─".repeat(118)+"┐"),console.log("│ SUMMARY STATISTICS"+" ".repeat(99)+"│"),console.log("├"+"─".repeat(118)+"┤"),console.log(`│ Total axis combinations evaluated: ${a.totalCombinations.toString().padEnd(80)} │`),console.log(`│ Combinations with issues: ${a.combinationsWithIssues.toString().padEnd(89)} │`),console.log(`│ Detected capabilities in SVG: ${a.detectedCapabilities.length.toString().padEnd(85)} │`),console.log("└"+"─".repeat(118)+"┘"),console.log(`
47
+ ┌`+"─".repeat(118)+"┐"),console.log("│ DETECTED SVG CAPABILITIES"+" ".repeat(92)+"│"),console.log("├"+"─".repeat(118)+"┤");let Q0={};for(let o of W){let K0=t6[o]||{cat:"unknown",name:o};if(!Q0[K0.cat])Q0[K0.cat]=[];Q0[K0.cat].push({key:o,name:K0.name})}for(let[o,K0]of Object.entries(Q0)){let F0=o.toUpperCase();console.log(`│ ${F0}:`.padEnd(119)+"│");for(let M0 of K0){let N0=G[M0.key.split("_")[0]]||{},I0=` • ${M0.name}`;if(N0.count!==void 0)I0+=` (${N0.count})`;console.log(`│ ${I0}`.padEnd(119)+"│")}}if(console.log("└"+"─".repeat(118)+"┘"),K){console.log(`
48
+ ╔`+"═".repeat(118)+"╗"),console.log("║ FULL COMPATIBILITY MATRIX BY EMBEDDING METHOD"+" ".repeat(71)+"║"),console.log("╚"+"═".repeat(118)+"╝");let o={};for(let K0 of a.cells){let F0=K0.combination.syntaxId;if(!o[F0])o[F0]=[];o[F0].push(K0)}for(let[K0,F0]of Object.entries(o)){let M0=Object.values(sK).find((f)=>f.id===K0),N0=M0?M0.name:K0;console.log(`
49
+ ┌`+"─".repeat(118)+"┐"),console.log(`│ SYNTAX: ${N0}`.padEnd(119)+"│"),console.log("├"+"─".repeat(30)+"┬"+"─".repeat(20)+"┬"+"─".repeat(25)+"┬"+"─".repeat(40)+"┤"),console.log("│ CONTEXT COMBINATION │ ISSUES │ BLOCKED CAPABILITIES │ BROWSER-SPECIFIC NOTES │"),console.log("├"+"─".repeat(30)+"┼"+"─".repeat(20)+"┼"+"─".repeat(25)+"┼"+"─".repeat(40)+"┤"),F0.sort((f,P)=>P.issueCount-f.issueCount);let I0=Z?F0:F0.slice(0,20);for(let f of I0){let P=`${(f.combination.displayId||"").substring(0,8)}/${f.combination.loadId}/${(f.combination.storageId||"").substring(0,8)}`,l=f.issueCount.toString(),g=f.issues.filter((q0)=>q0.status===k.BLOCKED).map((q0)=>(q0.name||"").substring(0,15)).slice(0,2).join(", "),n=f.issues.flatMap((q0)=>q0.browserIssues||[]).slice(0,2).map((q0)=>`${q0.browser}: ${q0.note?.substring(0,15)||""}`).join("; ");console.log(`│ ${P.padEnd(28)} │ ${l.padEnd(18)} │ ${(g||"-").substring(0,23).padEnd(23)} │ ${(n||"-").substring(0,38).padEnd(38)} │`)}if(!Z&&F0.length>20)console.log(`│ ... and ${F0.length-20} more combinations`.padEnd(119)+"│");console.log("└"+"─".repeat(30)+"┴"+"─".repeat(20)+"┴"+"─".repeat(25)+"┴"+"─".repeat(40)+"┘")}}console.log(`
50
+ ╔`+"═".repeat(118)+"╗"),console.log("║ DETAILED ISSUE BREAKDOWN BY CAPABILITY"+" ".repeat(78)+"║"),console.log("╚"+"═".repeat(118)+"╝");for(let o of W){let K0=t6[o]||{name:o,cat:"unknown"},F0=j8[o];if(console.log(`
51
+ ┌`+"─".repeat(118)+"┐"),console.log(`│ ${K0.name} (${K0.cat})`.padEnd(119)+"│"),console.log("├"+"─".repeat(118)+"┤"),!F0)console.log("│ No compatibility data available".padEnd(119)+"│");else if(console.log(`│ Default status: ${F0.default}`.padEnd(119)+"│"),Object.keys(F0.exceptions||{}).length>0){console.log("│ Exceptions:".padEnd(119)+"│");for(let[M0,N0]of Object.entries(F0.exceptions)){let I0=` ${M0}: ${N0.status} - ${N0.note||"No details"}`;console.log(`│ ${I0.substring(0,116)}`.padEnd(119)+"│")}}console.log("└"+"─".repeat(118)+"┘")}if(H){console.log(`
52
52
  ╔`+"═".repeat(118)+"╗"),console.log("║ BROWSER-SPECIFIC COMPATIBILITY QUICK REFERENCE"+" ".repeat(70)+"║"),console.log("╚"+"═".repeat(118)+"╝"),console.log(`
53
- ┌`+"─".repeat(14)+"┬"+"─".repeat(103)+"┐"),console.log("│ BROWSER │ KNOWN LIMITATIONS FOR DETECTED CAPABILITIES"+" ".repeat(58)+"│"),console.log("├"+"─".repeat(14)+"┼"+"─".repeat(103)+"┤");let o={Chrome:["Full SMIL support","Autoplay policy","External use blocked"],Firefox:["Good SMIL support","Autoplay policy","External use blocked"],Safari:["Full SMIL support","Strict autoplay","WebKit-specific filters"],"Safari iOS":["Full SMIL","VERY strict autoplay","Touch events only"],Edge:["Same as Chrome (Blink)","Autoplay policy","External use blocked"],"IE 11":["NO SMIL","NO blend modes","Limited filters","NO foreignObject scripting"],"Android WebView":["Varies by version","Autoplay restrictions","Limited CSS animations"]};for(let[J0,F0]of Object.entries(o)){let O0=F0.filter((R0)=>{let I0=R0.toLowerCase();if(I0.includes("smil")&&[...j].some((f)=>f.startsWith("SMIL_")))return!0;if(I0.includes("autoplay")&&j.has("AUDIO_AUTOPLAY"))return!0;if(I0.includes("blend")&&j.has("RENDER_BLENDMODES"))return!0;if(I0.includes("filter")&&(j.has("FILTERS_BASIC")||j.has("FILTERS_COMPLEX")))return!0;if(I0.includes("foreign")&&[...j].some((f)=>f.startsWith("FOREIGNOBJECT_")))return!0;if(I0.includes("external use")&&(j.has("USE_EXTERNAL_SAME")||j.has("USE_EXTERNAL_CROSS")))return!0;return!1});if(O0.length>0){let R0=O0.slice(0,3).join(", ");console.log(`│ ${J0.padEnd(12)} │ ${R0.substring(0,101).padEnd(101)} │`)}}console.log("└"+"─".repeat(14)+"┴"+"─".repeat(103)+"┘")}console.log(`
54
- ╔`+"═".repeat(118)+"╗"),console.log("║ RECOMMENDATIONS FOR MAXIMUM COMPATIBILITY"+" ".repeat(75)+"║"),console.log("╚"+"═".repeat(118)+"╝");let U0=[];if(j.has("AUDIO_AUTOPLAY")||j.has("AUDIO_EMBEDDED")||j.has("AUDIO_LOCAL")||j.has("AUDIO_REMOTE"))U0.push({feature:"Audio Playback",issue:"Browser autoplay policies block automatic audio",bestSyntax:"INLINE-SVG with JavaScript",workaround:"Extract audio data-URI, create Audio object, play on user click gesture",code:"document.querySelector('svg').addEventListener('click', () => new Audio(dataUri).play());"});if(j.has("SMIL_CLICK")||j.has("SMIL_HOVER")||j.has("SMIL_FOCUS")||j.has("SMIL_ACCESSKEY"))U0.push({feature:"Interactive SMIL Animation",issue:"Blocked in <img>, CSS backgrounds, and most renderers",bestSyntax:"<object>, <embed>, <iframe>, or inline <svg>",workaround:"Avoid <img> and CSS embedding for interactive SVGs",code:'<object data="animation.svg" type="image/svg+xml" width="800" height="600"></object>'});if(j.has("SCRIPT_INLINE")||j.has("SCRIPT_EXTERNAL"))U0.push({feature:"JavaScript Execution",issue:"Completely blocked in <img>, CSS contexts, email, most social platforms",bestSyntax:"Inline <svg> or <object>/<embed>/<iframe>",workaround:"For widest compatibility, convert JS interactions to SMIL or CSS",code:`<!-- Inline: --> <div><svg>...</svg></div>
55
- <!-- Isolated: --> <object data="app.svg"></object>`});if([...j].some((o)=>o.startsWith("FOREIGNOBJECT_")))U0.push({feature:"foreignObject / HTML Content",issue:"Completely ignored in <img>, CSS contexts, most renderers (Cairo, ImageMagick)",bestSyntax:"Inline <svg> or <object>/<embed>",workaround:"For rasterization, use browser screenshot or Puppeteer instead of ImageMagick",code:'<object data="with-html.svg" type="image/svg+xml"></object>'});if(j.has("IMAGES_REMOTE_CROSS")||j.has("FONTS_WEB_CROSS")||j.has("USE_EXTERNAL_CROSS")||j.has("AUDIO_REMOTE"))U0.push({feature:"Cross-Origin Resources",issue:"Blocked without CORS headers, completely blocked in <img> context",bestSyntax:"Any syntax with proper CORS, or embed resources as data-URIs",workaround:"Use embedExternalDependencies() to inline all external resources",code:"await embedExternalDependencies(doc, { embedImages: true, embedFonts: true, embedAudio: true });"});for(let o of U0){console.log(`
56
- ┌`+"─".repeat(118)+"┐"),console.log(`│ ${o.feature}`.padEnd(119)+"│"),console.log("├"+"─".repeat(118)+"┤"),console.log(`│ Issue: ${o.issue}`.substring(0,119).padEnd(119)+"│"),console.log(`│ Best syntax: ${o.bestSyntax}`.substring(0,119).padEnd(119)+"│"),console.log(`│ Workaround: ${o.workaround}`.substring(0,119).padEnd(119)+"│"),console.log("│ Code:".padEnd(119)+"│");for(let J0 of(o.code||"").split(`
57
- `).slice(0,3))console.log(`│ ${J0}`.substring(0,119).padEnd(119)+"│");console.log("└"+"─".repeat(118)+"┘")}console.log(`
58
- ╔`+"═".repeat(118)+"╗"),console.log("║ OVERALL COMPATIBILITY ASSESSMENT"+" ".repeat(84)+"║"),console.log("╚"+"═".repeat(118)+"╝");let N0={};for(let o of t){let J0=100,F0=[];for(let O0 of j){let R0=r6[O0]||{name:O0,critical:!1},I0=Z8[O0];if(I0){for(let[f,C]of Object.entries(I0.exceptions||{}))if(f.startsWith("syntax:")){let l=f.substring(7);if(l===o.id||l==="*"||l.includes("*")&&o.id.startsWith(l.replace("*",""))){let g=R0.critical?30:10;J0-=g,F0.push({cap:R0.name,penalty:g,status:C.status})}}}}N0[o.id]={name:o.name,score:Math.max(0,J0),deductions:F0}}let h0=Object.entries(N0).sort((o,J0)=>J0[1].score-o[1].score);console.log(`
59
- ┌`+"─".repeat(25)+"┬"+"─".repeat(10)+"┬"+"─".repeat(81)+"┐"),console.log("│ EMBEDDING METHOD │ SCORE │ ISSUES"+" ".repeat(74)+"│"),console.log("├"+"─".repeat(25)+"┼"+"─".repeat(10)+"┼"+"─".repeat(81)+"┤");for(let[o,J0]of h0){let F0=J0.score===100?"100% ✅":J0.score>=70?`${J0.score}% ⚠️`:`${J0.score}% ❌`,O0=J0.deductions.slice(0,3).map((R0)=>R0.cap).join(", ")||"None";console.log(`│ ${J0.name.padEnd(23)} │ ${F0.padEnd(8)} │ ${O0.substring(0,79).padEnd(79)} │`)}if(console.log("└"+"─".repeat(25)+"┴"+"─".repeat(10)+"┴"+"─".repeat(81)+"┘"),h0.length===0)console.log(`
60
- ⚠️ No embedding methods available for recommendation.`);else{let o=h0[0];if(console.log(`
53
+ ┌`+"─".repeat(14)+"┬"+"─".repeat(103)+"┐"),console.log("│ BROWSER │ KNOWN LIMITATIONS FOR DETECTED CAPABILITIES"+" ".repeat(58)+"│"),console.log("├"+"─".repeat(14)+"┼"+"─".repeat(103)+"┤");let o={Chrome:["Full SMIL support","Autoplay policy","External use blocked"],Firefox:["Good SMIL support","Autoplay policy","External use blocked"],Safari:["Full SMIL support","Strict autoplay","WebKit-specific filters"],"Safari iOS":["Full SMIL","VERY strict autoplay","Touch events only"],Edge:["Same as Chrome (Blink)","Autoplay policy","External use blocked"],"IE 11":["NO SMIL","NO blend modes","Limited filters","NO foreignObject scripting"],"Android WebView":["Varies by version","Autoplay restrictions","Limited CSS animations"]};for(let[K0,F0]of Object.entries(o)){let M0=F0.filter((N0)=>{let I0=N0.toLowerCase();if(I0.includes("smil")&&[...W].some((f)=>f.startsWith("SMIL_")))return!0;if(I0.includes("autoplay")&&W.has("AUDIO_AUTOPLAY"))return!0;if(I0.includes("blend")&&W.has("RENDER_BLENDMODES"))return!0;if(I0.includes("filter")&&(W.has("FILTERS_BASIC")||W.has("FILTERS_COMPLEX")))return!0;if(I0.includes("foreign")&&[...W].some((f)=>f.startsWith("FOREIGNOBJECT_")))return!0;if(I0.includes("external use")&&(W.has("USE_EXTERNAL_SAME")||W.has("USE_EXTERNAL_CROSS")))return!0;return!1});if(M0.length>0){let N0=M0.slice(0,3).join(", ");console.log(`│ ${K0.padEnd(12)} │ ${N0.substring(0,101).padEnd(101)} │`)}}console.log("└"+"─".repeat(14)+"┴"+"─".repeat(103)+"┘")}console.log(`
54
+ ╔`+"═".repeat(118)+"╗"),console.log("║ RECOMMENDATIONS FOR MAXIMUM COMPATIBILITY"+" ".repeat(75)+"║"),console.log("╚"+"═".repeat(118)+"╝");let U0=[];if(W.has("AUDIO_AUTOPLAY")||W.has("AUDIO_EMBEDDED")||W.has("AUDIO_LOCAL")||W.has("AUDIO_REMOTE"))U0.push({feature:"Audio Playback",issue:"Browser autoplay policies block automatic audio",bestSyntax:"INLINE-SVG with JavaScript",workaround:"Extract audio data-URI, create Audio object, play on user click gesture",code:"document.querySelector('svg').addEventListener('click', () => new Audio(dataUri).play());"});if(W.has("SMIL_CLICK")||W.has("SMIL_HOVER")||W.has("SMIL_FOCUS")||W.has("SMIL_ACCESSKEY"))U0.push({feature:"Interactive SMIL Animation",issue:"Blocked in <img>, CSS backgrounds, and most renderers",bestSyntax:"<object>, <embed>, <iframe>, or inline <svg>",workaround:"Avoid <img> and CSS embedding for interactive SVGs",code:'<object data="animation.svg" type="image/svg+xml" width="800" height="600"></object>'});if(W.has("SCRIPT_INLINE")||W.has("SCRIPT_EXTERNAL"))U0.push({feature:"JavaScript Execution",issue:"Completely blocked in <img>, CSS contexts, email, most social platforms",bestSyntax:"Inline <svg> or <object>/<embed>/<iframe>",workaround:"For widest compatibility, convert JS interactions to SMIL or CSS",code:`<!-- Inline: --> <div><svg>...</svg></div>
55
+ <!-- Isolated: --> <object data="app.svg"></object>`});if([...W].some((o)=>o.startsWith("FOREIGNOBJECT_")))U0.push({feature:"foreignObject / HTML Content",issue:"Completely ignored in <img>, CSS contexts, most renderers (Cairo, ImageMagick)",bestSyntax:"Inline <svg> or <object>/<embed>",workaround:"For rasterization, use browser screenshot or Puppeteer instead of ImageMagick",code:'<object data="with-html.svg" type="image/svg+xml"></object>'});if(W.has("IMAGES_REMOTE_CROSS")||W.has("FONTS_WEB_CROSS")||W.has("USE_EXTERNAL_CROSS")||W.has("AUDIO_REMOTE"))U0.push({feature:"Cross-Origin Resources",issue:"Blocked without CORS headers, completely blocked in <img> context",bestSyntax:"Any syntax with proper CORS, or embed resources as data-URIs",workaround:"Use embedExternalDependencies() to inline all external resources",code:"await embedExternalDependencies(doc, { embedImages: true, embedFonts: true, embedAudio: true });"});for(let o of U0){console.log(`
56
+ ┌`+"─".repeat(118)+"┐"),console.log(`│ ${o.feature}`.padEnd(119)+"│"),console.log("├"+"─".repeat(118)+"┤"),console.log(`│ Issue: ${o.issue}`.substring(0,119).padEnd(119)+"│"),console.log(`│ Best syntax: ${o.bestSyntax}`.substring(0,119).padEnd(119)+"│"),console.log(`│ Workaround: ${o.workaround}`.substring(0,119).padEnd(119)+"│"),console.log("│ Code:".padEnd(119)+"│");for(let K0 of(o.code||"").split(`
57
+ `).slice(0,3))console.log(`│ ${K0}`.substring(0,119).padEnd(119)+"│");console.log("└"+"─".repeat(118)+"┘")}console.log(`
58
+ ╔`+"═".repeat(118)+"╗"),console.log("║ OVERALL COMPATIBILITY ASSESSMENT"+" ".repeat(84)+"║"),console.log("╚"+"═".repeat(118)+"╝");let C0={};for(let o of t){let K0=100,F0=[];for(let M0 of W){let N0=t6[M0]||{name:M0,critical:!1},I0=j8[M0];if(I0){for(let[f,P]of Object.entries(I0.exceptions||{}))if(f.startsWith("syntax:")){let l=f.substring(7);if(l===o.id||l==="*"||l.includes("*")&&o.id.startsWith(l.replace("*",""))){let g=N0.critical?30:10;K0-=g,F0.push({cap:N0.name,penalty:g,status:P.status})}}}}C0[o.id]={name:o.name,score:Math.max(0,K0),deductions:F0}}let y0=Object.entries(C0).sort((o,K0)=>K0[1].score-o[1].score);console.log(`
59
+ ┌`+"─".repeat(25)+"┬"+"─".repeat(10)+"┬"+"─".repeat(81)+"┐"),console.log("│ EMBEDDING METHOD │ SCORE │ ISSUES"+" ".repeat(74)+"│"),console.log("├"+"─".repeat(25)+"┼"+"─".repeat(10)+"┼"+"─".repeat(81)+"┤");for(let[o,K0]of y0){let F0=K0.score===100?"100% ✅":K0.score>=70?`${K0.score}% ⚠️`:`${K0.score}% ❌`,M0=K0.deductions.slice(0,3).map((N0)=>N0.cap).join(", ")||"None";console.log(`│ ${K0.name.padEnd(23)} │ ${F0.padEnd(8)} │ ${M0.substring(0,79).padEnd(79)} │`)}if(console.log("└"+"─".repeat(25)+"┴"+"─".repeat(10)+"┴"+"─".repeat(81)+"┘"),y0.length===0)console.log(`
60
+ ⚠️ No embedding methods available for recommendation.`);else{let o=y0[0];if(console.log(`
61
61
  ★ RECOMMENDED: Use "${o[1].name}" for this SVG (score: ${o[1].score}%)`),o[1].score<100)console.log(`
62
62
  ⚠️ No embedding method achieves 100% compatibility for this SVG.`),console.log(" Consider using embedExternalDependencies() to maximize portability.")}return console.log(`
63
63
  `+"═".repeat(120)+`
64
- `),$._fullCompatibilityMatrix=r,$});function cK($,J={}){let Z=J.compact!==!1,K=J.showAllCells||!1,Q=[{id:"direct",label:"DIRECT",desc:"SVG file"},{id:"img",label:"IMG",desc:"<img>"},{id:"object",label:"OBJECT",desc:"<object>"},{id:"embed",label:"EMBED",desc:"<embed>"},{id:"inline",label:"INLINE",desc:"<svg>"},{id:"css",label:"CSS",desc:"bg-image"}],H=[{id:"embedded",label:"EMB",desc:"data-uri/inline"},{id:"local",label:"LOC",desc:"local path"},{id:"remote",label:"REM",desc:"http(s) URL"}],z=[{id:"browser",label:"BROWSER",desc:"Desktop browsers"},{id:"mobile",label:"MOBILE",desc:"Mobile WebView"},{id:"renderer",label:"RENDER",desc:"Server-side"}],q=[{id:"file",label:"file://",desc:"Local filesystem"},{id:"http",label:"http(s)://",desc:"Web server"},{id:"data",label:"data:",desc:"Data URI"}],W=[{id:"script",label:"+JS",desc:"With JavaScript"},{id:"noscript",label:"-JS",desc:"No JavaScript"}],j=[{id:"chrome",code:"C",name:"Chrome"},{id:"firefox",code:"F",name:"Firefox"},{id:"safari",code:"S",name:"Safari"},{id:"edge",code:"E",name:"Edge"},{id:"ie11",code:"I",name:"IE11"},{id:"ios",code:"i",name:"iOS Safari"},{id:"android",code:"A",name:"Android"}],G={display:{icon:"D",emoji:"\uD83D\uDCD0",name:"Basic rendering"},animation:{icon:"A",emoji:"\uD83C\uDFAC",name:"SMIL/CSS animation"},scripting:{icon:"J",emoji:"\uD83D\uDCDC",name:"JavaScript"},events:{icon:"E",emoji:"\uD83D\uDDB1️",name:"Event handlers"},media:{icon:"M",emoji:"\uD83D\uDD0A",name:"Audio/Video"},html:{icon:"H",emoji:"\uD83D\uDCC4",name:"foreignObject"},images:{icon:"I",emoji:"\uD83D\uDDBC️",name:"External images"},fonts:{icon:"T",emoji:"\uD83D\uDD24",name:"External fonts"},sprites:{icon:"U",emoji:"\uD83C\uDFAF",name:"use elements"},links:{icon:"L",emoji:"\uD83D\uDD17",name:"Hyperlinks"}},F=Q.length*H.length,_=z.length*q.length*W.length,U=Z?18:28,O=25,V=Z?2:3;console.log(`
64
+ `),$._fullCompatibilityMatrix=a,$});function KZ($,J={}){let Z=J.compact!==!1,K=J.showAllCells||!1,Q=[{id:"direct",label:"DIRECT",desc:"SVG file"},{id:"img",label:"IMG",desc:"<img>"},{id:"object",label:"OBJECT",desc:"<object>"},{id:"embed",label:"EMBED",desc:"<embed>"},{id:"inline",label:"INLINE",desc:"<svg>"},{id:"css",label:"CSS",desc:"bg-image"}],H=[{id:"embedded",label:"EMB",desc:"data-uri/inline"},{id:"local",label:"LOC",desc:"local path"},{id:"remote",label:"REM",desc:"http(s) URL"}],z=[{id:"browser",label:"BROWSER",desc:"Desktop browsers"},{id:"mobile",label:"MOBILE",desc:"Mobile WebView"},{id:"renderer",label:"RENDER",desc:"Server-side"}],q=[{id:"file",label:"file://",desc:"Local filesystem"},{id:"http",label:"http(s)://",desc:"Web server"},{id:"data",label:"data:",desc:"Data URI"}],j=[{id:"script",label:"+JS",desc:"With JavaScript"},{id:"noscript",label:"-JS",desc:"No JavaScript"}],W=[{id:"chrome",code:"C",name:"Chrome"},{id:"firefox",code:"F",name:"Firefox"},{id:"safari",code:"S",name:"Safari"},{id:"edge",code:"E",name:"Edge"},{id:"ie11",code:"I",name:"IE11"},{id:"ios",code:"i",name:"iOS Safari"},{id:"android",code:"A",name:"Android"}],G={display:{icon:"D",emoji:"\uD83D\uDCD0",name:"Basic rendering"},animation:{icon:"A",emoji:"\uD83C\uDFAC",name:"SMIL/CSS animation"},scripting:{icon:"J",emoji:"\uD83D\uDCDC",name:"JavaScript"},events:{icon:"E",emoji:"\uD83D\uDDB1️",name:"Event handlers"},media:{icon:"M",emoji:"\uD83D\uDD0A",name:"Audio/Video"},html:{icon:"H",emoji:"\uD83D\uDCC4",name:"foreignObject"},images:{icon:"I",emoji:"\uD83D\uDDBC️",name:"External images"},fonts:{icon:"T",emoji:"\uD83D\uDD24",name:"External fonts"},sprites:{icon:"U",emoji:"\uD83C\uDFAF",name:"use elements"},links:{icon:"L",emoji:"\uD83D\uDD17",name:"Hyperlinks"}},F=Q.length*H.length,_=z.length*q.length*j.length,U=Z?18:28,M=25,V=Z?2:3;console.log(`
65
65
  `),console.log("╔"+"═".repeat(160)+"╗"),console.log("║"+" HIERARCHICAL SVG COMPATIBILITY MATRIX - DETAILED ".padStart(105).padEnd(160)+"║"),console.log("║"+` ${F} columns × ${_} rows = ${F*_} cells `.padStart(105).padEnd(160)+"║"),console.log("║"+" Each cell shows: [Browser status] / [Functionality issues] ".padStart(105).padEnd(160)+"║"),console.log("╚"+"═".repeat(160)+"╝"),console.log(`
66
- `);let M=H.length*U,Y=26+Q.length*(M+1),X="".padEnd(25)+"│";for(let N of Q){let y=`${N.label} (${N.desc})`;X+=y.padStart(Math.floor(M/2)+Math.floor(y.length/2)).padEnd(M)+"│"}console.log("┌"+"─".repeat(25)+"┬"+Q.map(()=>"─".repeat(M)).join("┬")+"┐"),console.log("│"+"SYNTAX →".padEnd(25)+X.substring(26));let w="".padEnd(25)+"│";for(let N of Q){for(let y of H){let B=`${y.label}`;w+=B.padStart(Math.floor(U/2)+Math.floor(B.length/2)).padEnd(U)}w+="│"}console.log("│"+"STORAGE →".padEnd(25)+w.substring(26));let R="".padEnd(25)+"│";for(let N of Q){for(let y of H)R+="Brws|Func".padStart(Math.floor(U/2)+5).padEnd(U);R+="│"}console.log("│"+"".padEnd(25)+R.substring(26)),console.log("├"+"─".repeat(25)+"┼"+Q.map(()=>H.map(()=>"─".repeat(U)).join("─")).join("┼")+"┤");let I=(N,y,B,e,r)=>{let s={browserStatus:{},funcStatus:{},overallStatus:"ok",issueCount:0,browserCount:0};for(let t of j){s.browserStatus[t.id]={};for(let[$0]of Object.entries(G))s.browserStatus[t.id][$0]="ok"}for(let[t]of Object.entries(G))s.funcStatus[t]="ok";if(e==="img"||e==="css"){let t=["animation","scripting","events","html","media","links"];for(let $0 of t){s.funcStatus[$0]="block";for(let Q0 of j)s.browserStatus[Q0.id][$0]="block"}if(B==="remote"){s.funcStatus.images="block",s.funcStatus.fonts="block";for(let $0 of j)s.browserStatus[$0.id].images="block",s.browserStatus[$0.id].fonts="block"}}if(N==="renderer"){let t=["animation","scripting","events","media"];for(let $0 of t){s.funcStatus[$0]="block";for(let Q0 of j)s.browserStatus[Q0.id][$0]="block"}s.funcStatus.html="block";for(let $0 of j)s.browserStatus[$0.id].html="block"}if(r==="noscript"){s.funcStatus.scripting="block",s.funcStatus.events="warn";for(let t of j)s.browserStatus[t.id].scripting="block",s.browserStatus[t.id].events="warn"}if(s.browserStatus.ie11.animation="block",s.browserStatus.ie11.html="block",s.browserStatus.ie11.sprites="warn",$.detectedCapabilities?.some((t)=>t.startsWith("AUDIO_")||t.startsWith("VIDEO_"))){for(let t of j)if(s.browserStatus[t.id].media!=="block")s.browserStatus[t.id].media="warn";s.browserStatus.ios.media="block",s.funcStatus.media="warn"}if(B==="remote"){s.funcStatus.images=s.funcStatus.images==="block"?"block":"warn",s.funcStatus.fonts=s.funcStatus.fonts==="block"?"block":"warn",s.funcStatus.sprites=s.funcStatus.sprites==="block"?"block":"warn";for(let t of j){if(s.browserStatus[t.id].images!=="block")s.browserStatus[t.id].images="warn";if(s.browserStatus[t.id].fonts!=="block")s.browserStatus[t.id].fonts="warn"}}if(y==="file"){if(B==="remote")s.funcStatus.images="warn",s.funcStatus.fonts="warn",s.funcStatus.links="warn"}if(y==="data"){if(B==="remote"||B==="local")s.funcStatus.images="warn",s.funcStatus.fonts="warn"}let z0=!1,T=!1,P=new Set;for(let[t,$0]of Object.entries(s.funcStatus))if($0==="block")z0=!0,s.issueCount++;else if($0==="warn")T=!0,s.issueCount++;for(let t of j)for(let[$0,Q0]of Object.entries(s.browserStatus[t.id]))if(Q0!=="ok")P.add(t.id);return s.browserCount=P.size,s.overallStatus=z0?"block":T?"warn":"ok",s},b=(N,y)=>{let B=[],e={ok:"✓",warn:"⚠",block:"✗"};if(N.overallStatus==="ok")return B.push("✅ ALL OK".padStart(Math.floor(y/2)+5).padEnd(y)),B.push("".padEnd(y)),B;let r="";for(let z0 of j){let T="ok";for(let[P,t]of Object.entries(N.browserStatus[z0.id]))if(t==="block"){T="block";break}else if(t==="warn"&&T!=="block")T="warn";r+=`${z0.code}${e[T]}`}B.push(r.padStart(Math.floor(y/2)+Math.floor(r.length/2)).padEnd(y));let s="";for(let[z0,T]of Object.entries(G)){let P=N.funcStatus[z0];if(P!=="ok")s+=`${T.icon}${e[P]}`}if(s==="")s="(ok)";return B.push(s.padStart(Math.floor(y/2)+Math.floor(s.length/2)).padEnd(y)),B},u=(N,y)=>{let B={ok:"✓",warn:"⚠",block:"✗"};if(N.overallStatus==="ok")return"✅".padStart(Math.floor(y/2)+1).padEnd(y);let e=N.overallStatus==="block"?"❌":"⚠️",r=`${N.browserCount}B`,s=`${N.issueCount}F`,z0=`${e}${r}${s}`;return z0.padStart(Math.floor(y/2)+Math.floor(z0.length/2)).padEnd(y)};for(let N of z){let y=Q.map(()=>H.map(()=>" ".repeat(U)).join(" ")).join("│");console.log("│ "+(N.label+":").padEnd(23)+"│"+y+"│");for(let B of q){for(let e of W){let r=[];for(let $0 of Q)for(let Q0 of H){let U0=I(N.id,B.id,Q0.id,$0.id,e.id);r.push(U0)}let s=r.map(($0)=>b($0,U)),T="│"+` ${B.label} ${e.label}`.padEnd(25)+"│",P=0;for(let $0=0;$0<Q.length;$0++){for(let Q0=0;Q0<H.length;Q0++)T+=s[P][0],P++;T+="│"}console.log(T.substring(0,T.length-1));let t="│"+"".padEnd(25)+"│";P=0;for(let $0=0;$0<Q.length;$0++){for(let Q0=0;Q0<H.length;Q0++)t+=s[P][1],P++;t+="│"}if(console.log(t.substring(0,t.length-1)),e!==W[W.length-1]){let $0=Q.map(()=>H.map(()=>"·".repeat(U)).join("·")).join("│");console.log("│"+"·".repeat(25)+"│"+$0+"│")}}if(B!==q[q.length-1]){let e=Q.map(()=>H.map(()=>"─".repeat(U)).join("─")).join("┼");console.log("├"+"─".repeat(25)+"┼"+e+"┤")}}if(N!==z[z.length-1]){let B=Q.map(()=>H.map(()=>"═".repeat(U)).join("═")).join("╪");console.log("╞"+"═".repeat(25)+"╪"+B+"╡")}}console.log("└"+"─".repeat(25)+"┴"+Q.map(()=>H.map(()=>"─".repeat(U)).join("─")).join("┴")+"┘"),console.log(`
67
- ┌`+"─".repeat(120)+"┐"),console.log("│ LEGEND - HOW TO READ CELL CONTENT"+" ".repeat(85)+"│"),console.log("├"+"─".repeat(120)+"┤"),console.log("│ Each cell shows 2 lines:"+" ".repeat(95)+"│"),console.log("│ Line 1: Browser status (C=Chrome F=Firefox S=Safari E=Edge I=IE11 i=iOS A=Android)"+" ".repeat(34)+"│"),console.log("│ Line 2: Functionality issues (codes below)"+" ".repeat(74)+"│"),console.log("│"+" ".repeat(120)+"│"),console.log("│ Status symbols: ✓ = works ⚠ = warning/partial ✗ = blocked/broken"+" ".repeat(49)+"│"),console.log("│"+" ".repeat(120)+"│"),console.log("│ ✅ ALL OK = No issues in this combination"+" ".repeat(78)+"│"),console.log("│"+" ".repeat(120)+"│"),console.log("│ FUNCTIONALITY CODES:"+" ".repeat(99)+"│");let m="│ ";for(let[N,y]of Object.entries(G))m+=`${y.icon}=${N} `;console.log(m.padEnd(121)+"│"),console.log("│"+" ".repeat(120)+"│"),console.log("│ FULL FUNCTIONALITY NAMES:"+" ".repeat(94)+"│");let S="│ ";for(let[N,y]of Object.entries(G))S+=`${y.icon}=${y.name} `;if(S.length>120)console.log(S.substring(0,121)+"│"),S="│ "+S.substring(121);console.log(S.padEnd(121)+"│"),console.log("│"+" ".repeat(120)+"│"),console.log("│ EXAMPLES:"+" ".repeat(110)+"│"),console.log('│ "C✓F✓S✓E⚠I✗i✗A✓" = Chrome/Firefox/Safari/Android OK, Edge warning, IE11/iOS blocked'+" ".repeat(30)+"│"),console.log('│ "A✗J✗M⚠H✗" = Animation blocked, Scripting blocked, Media warning, HTML blocked'+" ".repeat(37)+"│"),console.log("└"+"─".repeat(120)+"┘"),console.log(`
68
- `),console.log("╔"+"═".repeat(120)+"╗"),console.log("║"+" TABLE 2: INTERNAL SVG RESOURCES COMPATIBILITY ".padStart(84).padEnd(120)+"║"),console.log("╚"+"═".repeat(120)+"╝");let x=[{id:"images_embedded",label:"Embedded Images (data-uri)",icon:"\uD83D\uDDBC️"},{id:"images_local",label:"Local Images (path)",icon:"\uD83D\uDCC1"},{id:"images_remote",label:"Remote Images (URL)",icon:"\uD83C\uDF10"},{id:"fonts_embedded",label:"Embedded Fonts (data-uri)",icon:"\uD83D\uDD24"},{id:"fonts_local",label:"Local Fonts (path)",icon:"\uD83D\uDCC1"},{id:"fonts_remote",label:"Remote Fonts (URL)",icon:"\uD83C\uDF10"},{id:"css_inline",label:"Inline <style>",icon:"\uD83C\uDFA8"},{id:"css_external",label:"External CSS",icon:"\uD83D\uDCC4"},{id:"scripts_inline",label:"Inline <script>",icon:"\uD83D\uDCDC"},{id:"scripts_external",label:"External Scripts",icon:"\uD83D\uDCE6"},{id:"audio_embedded",label:"Embedded Audio",icon:"\uD83D\uDD0A"},{id:"audio_external",label:"External Audio",icon:"\uD83C\uDFB5"}],h=14,E="".padEnd(30)+"│";for(let N of Q)E+=N.label.padStart(h-1).padEnd(h);E+="│",console.log(`
69
- ┌`+"─".repeat(30)+"┬"+"─".repeat(Q.length*h)+"┐"),console.log("│"+"RESOURCE TYPE".padEnd(30)+E.substring(31)),console.log("├"+"─".repeat(30)+"┼"+"─".repeat(Q.length*h)+"┤");let d=(N,y)=>{if(y==="img"||y==="css"){if(N.includes("external")||N.includes("remote")||N.includes("scripts")||N.includes("audio"))return"❌";if(N.includes("local")&&!N.includes("embedded"))return"⚠️"}if(y==="object"||y==="embed"){if(N.includes("remote")&&!N.includes("embedded"))return"⚠️"}if(N.includes("embedded")||N.includes("inline"))return"✅";if(N.includes("local"))return"⚠️";if(N.includes("remote")||N.includes("external"))return"⚠️";return"✅"};for(let N of x){let y=`│ ${N.icon} ${N.label}`.padEnd(31)+"│";for(let B of Q){let e=d(N.id,B.id);y+=e.padStart(h-1).padEnd(h)}y+="│",console.log(y)}console.log("└"+"─".repeat(30)+"┴"+"─".repeat(Q.length*h)+"┘"),console.log(`
70
- `),console.log("╔"+"═".repeat(120)+"╗"),console.log("║"+" TABLE 3: BROWSER-SPECIFIC ISSUES FOR DETECTED CAPABILITIES ".padStart(90).padEnd(120)+"║"),console.log("╚"+"═".repeat(120)+"╝");let c={};for(let N of $.detectedCapabilities||[]){let y={RENDER_:"display",FONTS_:"fonts",IMAGES_:"images",FILTERS_:"effects",MASKS:"effects",CLIP_:"effects",SMIL_:"animation",CSS_:"animation",SCRIPT_:"scripting",EVENT_:"events",LINK_:"links",FOREIGNOBJECT_:"html",AUDIO_:"media",VIDEO_:"media",USE_:"sprites",A11Y_:"accessibility",META_:"metadata"};for(let[B,e]of Object.entries(y))if(N.startsWith(B)||N===B.replace("_","")){if(!c[e])c[e]=[];c[e].push(N);break}}console.log(`
71
- ┌`+"─".repeat(20)+"┬"+"─".repeat(99)+"┐"),console.log("│ CAPABILITY"+" ".repeat(9)+"│ BROWSER ISSUES"+" ".repeat(84)+"│"),console.log("├"+"─".repeat(20)+"┼"+"─".repeat(99)+"┤");let p={animation:{Chrome:"Full SMIL support",IE11:"NO SMIL SUPPORT",Safari:"Full support"},media:{ALL:"Autoplay blocked - needs user gesture",iOS:"VERY strict autoplay policy"},html:{IE11:"No scripting in foreignObject",Cairo:"Not rendered",ImageMagick:"Not rendered"},scripting:{IE11:"Limited ES6 support"},effects:{IE11:"Limited filter support, no blend modes"}};for(let[N,y]of Object.entries(c)){let B=p[N]||{},e=Object.entries(B).map(([r,s])=>`${r}: ${s}`).join("; ")||"No known issues";console.log(`│ ${N.toUpperCase().padEnd(18)} │ ${e.substring(0,97).padEnd(97)} │`)}return console.log("└"+"─".repeat(20)+"┴"+"─".repeat(99)+"┘"),console.log(`
66
+ `);let Y=H.length*U,O=26+Q.length*(Y+1),X="".padEnd(25)+"│";for(let C of Q){let u=`${C.label} (${C.desc})`;X+=u.padStart(Math.floor(Y/2)+Math.floor(u.length/2)).padEnd(Y)+"│"}console.log("┌"+"─".repeat(25)+"┬"+Q.map(()=>"─".repeat(Y)).join("┬")+"┐"),console.log("│"+"SYNTAX →".padEnd(25)+X.substring(26));let w="".padEnd(25)+"│";for(let C of Q){for(let u of H){let N=`${u.label}`;w+=N.padStart(Math.floor(U/2)+Math.floor(N.length/2)).padEnd(U)}w+="│"}console.log("│"+"STORAGE →".padEnd(25)+w.substring(26));let R="".padEnd(25)+"│";for(let C of Q){for(let u of H)R+="Brws|Func".padStart(Math.floor(U/2)+5).padEnd(U);R+="│"}console.log("│"+"".padEnd(25)+R.substring(26)),console.log("├"+"─".repeat(25)+"┼"+Q.map(()=>H.map(()=>"─".repeat(U)).join("─")).join("┼")+"┤");let B=(C,u,N,e,a)=>{let s={browserStatus:{},funcStatus:{},overallStatus:"ok",issueCount:0,browserCount:0};for(let t of W){s.browserStatus[t.id]={};for(let[$0]of Object.entries(G))s.browserStatus[t.id][$0]="ok"}for(let[t]of Object.entries(G))s.funcStatus[t]="ok";if(e==="img"||e==="css"){let t=["animation","scripting","events","html","media","links"];for(let $0 of t){s.funcStatus[$0]="block";for(let Q0 of W)s.browserStatus[Q0.id][$0]="block"}if(N==="remote"){s.funcStatus.images="block",s.funcStatus.fonts="block";for(let $0 of W)s.browserStatus[$0.id].images="block",s.browserStatus[$0.id].fonts="block"}}if(C==="renderer"){let t=["animation","scripting","events","media"];for(let $0 of t){s.funcStatus[$0]="block";for(let Q0 of W)s.browserStatus[Q0.id][$0]="block"}s.funcStatus.html="block";for(let $0 of W)s.browserStatus[$0.id].html="block"}if(a==="noscript"){s.funcStatus.scripting="block",s.funcStatus.events="warn";for(let t of W)s.browserStatus[t.id].scripting="block",s.browserStatus[t.id].events="warn"}if(s.browserStatus.ie11.animation="block",s.browserStatus.ie11.html="block",s.browserStatus.ie11.sprites="warn",$.detectedCapabilities?.some((t)=>t.startsWith("AUDIO_")||t.startsWith("VIDEO_"))){for(let t of W)if(s.browserStatus[t.id].media!=="block")s.browserStatus[t.id].media="warn";s.browserStatus.ios.media="block",s.funcStatus.media="warn"}if(N==="remote"){s.funcStatus.images=s.funcStatus.images==="block"?"block":"warn",s.funcStatus.fonts=s.funcStatus.fonts==="block"?"block":"warn",s.funcStatus.sprites=s.funcStatus.sprites==="block"?"block":"warn";for(let t of W){if(s.browserStatus[t.id].images!=="block")s.browserStatus[t.id].images="warn";if(s.browserStatus[t.id].fonts!=="block")s.browserStatus[t.id].fonts="warn"}}if(u==="file"){if(N==="remote")s.funcStatus.images="warn",s.funcStatus.fonts="warn",s.funcStatus.links="warn"}if(u==="data"){if(N==="remote"||N==="local")s.funcStatus.images="warn",s.funcStatus.fonts="warn"}let H0=!1,S=!1,E=new Set;for(let[t,$0]of Object.entries(s.funcStatus))if($0==="block")H0=!0,s.issueCount++;else if($0==="warn")S=!0,s.issueCount++;for(let t of W)for(let[$0,Q0]of Object.entries(s.browserStatus[t.id]))if(Q0!=="ok")E.add(t.id);return s.browserCount=E.size,s.overallStatus=H0?"block":S?"warn":"ok",s},I=(C,u)=>{let N=[],e={ok:"✓",warn:"⚠",block:"✗"};if(C.overallStatus==="ok")return N.push("✅ ALL OK".padStart(Math.floor(u/2)+5).padEnd(u)),N.push("".padEnd(u)),N;let a="";for(let H0 of W){let S="ok";for(let[E,t]of Object.entries(C.browserStatus[H0.id]))if(t==="block"){S="block";break}else if(t==="warn"&&S!=="block")S="warn";a+=`${H0.code}${e[S]}`}N.push(a.padStart(Math.floor(u/2)+Math.floor(a.length/2)).padEnd(u));let s="";for(let[H0,S]of Object.entries(G)){let E=C.funcStatus[H0];if(E!=="ok")s+=`${S.icon}${e[E]}`}if(s==="")s="(ok)";return N.push(s.padStart(Math.floor(u/2)+Math.floor(s.length/2)).padEnd(u)),N},h=(C,u)=>{let N={ok:"✓",warn:"⚠",block:"✗"};if(C.overallStatus==="ok")return"✅".padStart(Math.floor(u/2)+1).padEnd(u);let e=C.overallStatus==="block"?"❌":"⚠️",a=`${C.browserCount}B`,s=`${C.issueCount}F`,H0=`${e}${a}${s}`;return H0.padStart(Math.floor(u/2)+Math.floor(H0.length/2)).padEnd(u)};for(let C of z){let u=Q.map(()=>H.map(()=>" ".repeat(U)).join(" ")).join("│");console.log("│ "+(C.label+":").padEnd(23)+"│"+u+"│");for(let N of q){for(let e of j){let a=[];for(let $0 of Q)for(let Q0 of H){let U0=B(C.id,N.id,Q0.id,$0.id,e.id);a.push(U0)}let s=a.map(($0)=>I($0,U)),S="│"+` ${N.label} ${e.label}`.padEnd(25)+"│",E=0;for(let $0=0;$0<Q.length;$0++){for(let Q0=0;Q0<H.length;Q0++)S+=s[E][0],E++;S+="│"}console.log(S.substring(0,S.length-1));let t="│"+"".padEnd(25)+"│";E=0;for(let $0=0;$0<Q.length;$0++){for(let Q0=0;Q0<H.length;Q0++)t+=s[E][1],E++;t+="│"}if(console.log(t.substring(0,t.length-1)),e!==j[j.length-1]){let $0=Q.map(()=>H.map(()=>"·".repeat(U)).join("·")).join("│");console.log("│"+"·".repeat(25)+"│"+$0+"│")}}if(N!==q[q.length-1]){let e=Q.map(()=>H.map(()=>"─".repeat(U)).join("─")).join("┼");console.log("├"+"─".repeat(25)+"┼"+e+"┤")}}if(C!==z[z.length-1]){let N=Q.map(()=>H.map(()=>"═".repeat(U)).join("═")).join("╪");console.log("╞"+"═".repeat(25)+"╪"+N+"╡")}}console.log("└"+"─".repeat(25)+"┴"+Q.map(()=>H.map(()=>"─".repeat(U)).join("─")).join("┴")+"┘"),console.log(`
67
+ ┌`+"─".repeat(120)+"┐"),console.log("│ LEGEND - HOW TO READ CELL CONTENT"+" ".repeat(85)+"│"),console.log("├"+"─".repeat(120)+"┤"),console.log("│ Each cell shows 2 lines:"+" ".repeat(95)+"│"),console.log("│ Line 1: Browser status (C=Chrome F=Firefox S=Safari E=Edge I=IE11 i=iOS A=Android)"+" ".repeat(34)+"│"),console.log("│ Line 2: Functionality issues (codes below)"+" ".repeat(74)+"│"),console.log("│"+" ".repeat(120)+"│"),console.log("│ Status symbols: ✓ = works ⚠ = warning/partial ✗ = blocked/broken"+" ".repeat(49)+"│"),console.log("│"+" ".repeat(120)+"│"),console.log("│ ✅ ALL OK = No issues in this combination"+" ".repeat(78)+"│"),console.log("│"+" ".repeat(120)+"│"),console.log("│ FUNCTIONALITY CODES:"+" ".repeat(99)+"│");let m="│ ";for(let[C,u]of Object.entries(G))m+=`${u.icon}=${C} `;console.log(m.padEnd(121)+"│"),console.log("│"+" ".repeat(120)+"│"),console.log("│ FULL FUNCTIONALITY NAMES:"+" ".repeat(94)+"│");let v="│ ";for(let[C,u]of Object.entries(G))v+=`${u.icon}=${u.name} `;if(v.length>120)console.log(v.substring(0,121)+"│"),v="│ "+v.substring(121);console.log(v.padEnd(121)+"│"),console.log("│"+" ".repeat(120)+"│"),console.log("│ EXAMPLES:"+" ".repeat(110)+"│"),console.log('│ "C✓F✓S✓E⚠I✗i✗A✓" = Chrome/Firefox/Safari/Android OK, Edge warning, IE11/iOS blocked'+" ".repeat(30)+"│"),console.log('│ "A✗J✗M⚠H✗" = Animation blocked, Scripting blocked, Media warning, HTML blocked'+" ".repeat(37)+"│"),console.log("└"+"─".repeat(120)+"┘"),console.log(`
68
+ `),console.log("╔"+"═".repeat(120)+"╗"),console.log("║"+" TABLE 2: INTERNAL SVG RESOURCES COMPATIBILITY ".padStart(84).padEnd(120)+"║"),console.log("╚"+"═".repeat(120)+"╝");let x=[{id:"images_embedded",label:"Embedded Images (data-uri)",icon:"\uD83D\uDDBC️"},{id:"images_local",label:"Local Images (path)",icon:"\uD83D\uDCC1"},{id:"images_remote",label:"Remote Images (URL)",icon:"\uD83C\uDF10"},{id:"fonts_embedded",label:"Embedded Fonts (data-uri)",icon:"\uD83D\uDD24"},{id:"fonts_local",label:"Local Fonts (path)",icon:"\uD83D\uDCC1"},{id:"fonts_remote",label:"Remote Fonts (URL)",icon:"\uD83C\uDF10"},{id:"css_inline",label:"Inline <style>",icon:"\uD83C\uDFA8"},{id:"css_external",label:"External CSS",icon:"\uD83D\uDCC4"},{id:"scripts_inline",label:"Inline <script>",icon:"\uD83D\uDCDC"},{id:"scripts_external",label:"External Scripts",icon:"\uD83D\uDCE6"},{id:"audio_embedded",label:"Embedded Audio",icon:"\uD83D\uDD0A"},{id:"audio_external",label:"External Audio",icon:"\uD83C\uDFB5"}],y=14,T="".padEnd(30)+"│";for(let C of Q)T+=C.label.padStart(y-1).padEnd(y);T+="│",console.log(`
69
+ ┌`+"─".repeat(30)+"┬"+"─".repeat(Q.length*y)+"┐"),console.log("│"+"RESOURCE TYPE".padEnd(30)+T.substring(31)),console.log("├"+"─".repeat(30)+"┼"+"─".repeat(Q.length*y)+"┤");let d=(C,u)=>{if(u==="img"||u==="css"){if(C.includes("external")||C.includes("remote")||C.includes("scripts")||C.includes("audio"))return"❌";if(C.includes("local")&&!C.includes("embedded"))return"⚠️"}if(u==="object"||u==="embed"){if(C.includes("remote")&&!C.includes("embedded"))return"⚠️"}if(C.includes("embedded")||C.includes("inline"))return"✅";if(C.includes("local"))return"⚠️";if(C.includes("remote")||C.includes("external"))return"⚠️";return"✅"};for(let C of x){let u=`│ ${C.icon} ${C.label}`.padEnd(31)+"│";for(let N of Q){let e=d(C.id,N.id);u+=e.padStart(y-1).padEnd(y)}u+="│",console.log(u)}console.log("└"+"─".repeat(30)+"┴"+"─".repeat(Q.length*y)+"┘"),console.log(`
70
+ `),console.log("╔"+"═".repeat(120)+"╗"),console.log("║"+" TABLE 3: BROWSER-SPECIFIC ISSUES FOR DETECTED CAPABILITIES ".padStart(90).padEnd(120)+"║"),console.log("╚"+"═".repeat(120)+"╝");let p={};for(let C of $.detectedCapabilities||[]){let u={RENDER_:"display",FONTS_:"fonts",IMAGES_:"images",FILTERS_:"effects",MASKS:"effects",CLIP_:"effects",SMIL_:"animation",CSS_:"animation",SCRIPT_:"scripting",EVENT_:"events",LINK_:"links",FOREIGNOBJECT_:"html",AUDIO_:"media",VIDEO_:"media",USE_:"sprites",A11Y_:"accessibility",META_:"metadata"};for(let[N,e]of Object.entries(u))if(C.startsWith(N)||C===N.replace("_","")){if(!p[e])p[e]=[];p[e].push(C);break}}console.log(`
71
+ ┌`+"─".repeat(20)+"┬"+"─".repeat(99)+"┐"),console.log("│ CAPABILITY"+" ".repeat(9)+"│ BROWSER ISSUES"+" ".repeat(84)+"│"),console.log("├"+"─".repeat(20)+"┼"+"─".repeat(99)+"┤");let c={animation:{Chrome:"Full SMIL support",IE11:"NO SMIL SUPPORT",Safari:"Full support"},media:{ALL:"Autoplay blocked - needs user gesture",iOS:"VERY strict autoplay policy"},html:{IE11:"No scripting in foreignObject",Cairo:"Not rendered",ImageMagick:"Not rendered"},scripting:{IE11:"Limited ES6 support"},effects:{IE11:"Limited filter support, no blend modes"}};for(let[C,u]of Object.entries(p)){let N=c[C]||{},e=Object.entries(N).map(([a,s])=>`${a}: ${s}`).join("; ")||"No known issues";console.log(`│ ${C.toUpperCase().padEnd(18)} │ ${e.substring(0,97).padEnd(97)} │`)}return console.log("└"+"─".repeat(20)+"┴"+"─".repeat(99)+"┘"),console.log(`
72
72
  `+"═".repeat(140)+`
73
- `),$}function lK($,J={}){let Z=J.fontFamily||"system-ui, -apple-system, BlinkMacSystemFont, sans-serif",K=(e)=>String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"),Q=[{id:"standalone",name:"Standalone SVG",desc:"Open .svg directly",color:"#1565C0",parent:null},{id:"img",name:"<img>",desc:"Image element",color:"#1976D2",parent:"html"},{id:"object",name:"<object>",desc:"Object element",color:"#1E88E5",parent:"html"},{id:"embed",name:"<embed>",desc:"Embed element",color:"#2196F3",parent:"html"},{id:"inline",name:"Inline <svg>",desc:"SVG in HTML",color:"#42A5F5",parent:"html"},{id:"css",name:"CSS background",desc:"background-image",color:"#64B5F6",parent:"html"}],H=[{id:"desktop",name:"Desktop Browser",color:"#E3F2FD",type:"desktop"},{id:"mobile",name:"Mobile Browser",color:"#E8F5E9",type:"mobile"}],z=[{id:"nodejs",name:"Node.js (JSDOM)",color:"#FFF3E0",issues:["No rendering","No animations","No interaction"]},{id:"imagemagick",name:"ImageMagick",color:"#EFEBE9",issues:["No animations","No scripts","No foreignObject","No web fonts"]},{id:"inkscape",name:"Inkscape CLI",color:"#F3E5F5",issues:["No animations","No scripts"]},{id:"librsvg",name:"librsvg",color:"#E0F2F1",issues:["No animations","No scripts","Limited filters"]},{id:"cairo",name:"Cairo",color:"#FBE9E7",issues:["No animations","No scripts","No filters","No foreignObject"]},{id:"batik",name:"Apache Batik",color:"#F3E5F5",issues:["No CSS animations","Limited SMIL","No web fonts"]}],q=[{id:"file",name:"file://",color:"#BBDEFB"},{id:"http",name:"http(s)://",color:"#C8E6C9"}],W=[{id:"js",name:"JS enabled",color:"#DCEDC8"},{id:"nojs",name:"JS disabled",color:"#FFCDD2"}],j=(e,r,s,z0)=>{let T=[],P=(t)=>T.push({text:t});if(z0==="img"||z0==="css")return P("No scripts"),P("No events"),P("No audio/video"),P("No links"),P("No foreignObject"),P("No external resources"),T;if(s==="nojs")P("No scripts"),P("No event handlers");if(r==="file")P("No remote fonts (Chrome, Safari)"),P("No remote images (Chrome)"),P("No fetch/XHR to remote URLs");if(z0==="object"||z0==="embed"){if(P("No event bubbling to parent"),r==="http")P("No cross-origin script access")}if(e==="desktop"){if(P("No SMIL (IE11 only)"),P("No CSS variables (IE11 only)"),s==="js")P("Audio: blocked until user click/tap event"),P("Audio: once blocked, won't auto-retry")}if(e==="mobile")P("No hover/mouseover events"),P("Audio: blocked until user tap event"),P("Audio: once blocked, won't auto-retry"),P("Video autoplay blocked");return T},G=0;for(let e of H)for(let r of q)for(let s of W)for(let z0 of Q){let T=j(e.id,r.id,s.id,z0.id).length;if(T>G)G=T}let F=130,_=80,U=90,O=F+_+U,V=60,M=220,Y=13,X=Math.max(80,(G+1)*Y+25),w=Q.length,R=H.length*q.length*W.length,I=O+w*M,u=V+R*X+40,m=30,S=40+z.length*m,x=u+S+30,h=1020,E=I+50,d=55+x+h+50,c=`<?xml version="1.0" encoding="UTF-8"?>
74
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${E} ${d}" preserveAspectRatio="xMinYMin meet" height="${d}" width="100%">
73
+ `),$}function ZZ($,J={}){let Z=J.fontFamily||"system-ui, -apple-system, BlinkMacSystemFont, sans-serif",K=(e)=>String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"),Q=[{id:"standalone",name:"Standalone SVG",desc:"Open .svg directly",color:"#1565C0",parent:null},{id:"img",name:"<img>",desc:"Image element",color:"#1976D2",parent:"html"},{id:"object",name:"<object>",desc:"Object element",color:"#1E88E5",parent:"html"},{id:"embed",name:"<embed>",desc:"Embed element",color:"#2196F3",parent:"html"},{id:"inline",name:"Inline <svg>",desc:"SVG in HTML",color:"#42A5F5",parent:"html"},{id:"css",name:"CSS background",desc:"background-image",color:"#64B5F6",parent:"html"}],H=[{id:"desktop",name:"Desktop Browser",color:"#E3F2FD",type:"desktop"},{id:"mobile",name:"Mobile Browser",color:"#E8F5E9",type:"mobile"}],z=[{id:"nodejs",name:"Node.js (JSDOM)",color:"#FFF3E0",issues:["No rendering","No animations","No interaction"]},{id:"imagemagick",name:"ImageMagick",color:"#EFEBE9",issues:["No animations","No scripts","No foreignObject","No web fonts"]},{id:"inkscape",name:"Inkscape CLI",color:"#F3E5F5",issues:["No animations","No scripts"]},{id:"librsvg",name:"librsvg",color:"#E0F2F1",issues:["No animations","No scripts","Limited filters"]},{id:"cairo",name:"Cairo",color:"#FBE9E7",issues:["No animations","No scripts","No filters","No foreignObject"]},{id:"batik",name:"Apache Batik",color:"#F3E5F5",issues:["No CSS animations","Limited SMIL","No web fonts"]}],q=[{id:"file",name:"file://",color:"#BBDEFB"},{id:"http",name:"http(s)://",color:"#C8E6C9"}],j=[{id:"js",name:"JS enabled",color:"#DCEDC8"},{id:"nojs",name:"JS disabled",color:"#FFCDD2"}],W=(e,a,s,H0)=>{let S=[],E=(t)=>S.push({text:t});if(H0==="img"||H0==="css")return E("No scripts"),E("No events"),E("No audio/video"),E("No links"),E("No foreignObject"),E("No external resources"),S;if(s==="nojs")E("No scripts"),E("No event handlers");if(a==="file")E("No remote fonts (Chrome, Safari)"),E("No remote images (Chrome)"),E("No fetch/XHR to remote URLs");if(H0==="object"||H0==="embed"){if(E("No event bubbling to parent"),a==="http")E("No cross-origin script access")}if(e==="desktop"){if(E("No SMIL (IE11 only)"),E("No CSS variables (IE11 only)"),s==="js")E("Audio: blocked until user click/tap event"),E("Audio: once blocked, won't auto-retry")}if(e==="mobile")E("No hover/mouseover events"),E("Audio: blocked until user tap event"),E("Audio: once blocked, won't auto-retry"),E("Video autoplay blocked");return S},G=0;for(let e of H)for(let a of q)for(let s of j)for(let H0 of Q){let S=W(e.id,a.id,s.id,H0.id).length;if(S>G)G=S}let F=130,_=80,U=90,M=F+_+U,V=60,Y=220,O=13,X=Math.max(80,(G+1)*O+25),w=Q.length,R=H.length*q.length*j.length,B=M+w*Y,h=V+R*X+40,m=30,v=40+z.length*m,x=h+v+30,y=1020,T=B+50,d=55+x+y+50,p=`<?xml version="1.0" encoding="UTF-8"?>
74
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${T} ${d}" preserveAspectRatio="xMinYMin meet" height="${d}" width="100%">
75
75
  <title>SVG Compatibility Matrix</title>
76
76
 
77
77
  <defs>
@@ -92,35 +92,35 @@ ${z}
92
92
  </style>
93
93
  </defs>
94
94
 
95
- <text x="${E/2}" y="24" text-anchor="middle" class="title">SVG Compatibility Matrix</text>
96
- <text x="${E/2}" y="42" text-anchor="middle" class="subtitle">What problems will your SVG have in each configuration?</text>
95
+ <text x="${T/2}" y="24" text-anchor="middle" class="title">SVG Compatibility Matrix</text>
96
+ <text x="${T/2}" y="42" text-anchor="middle" class="subtitle">What problems will your SVG have in each configuration?</text>
97
97
 
98
98
  <g transform="translate(25, 55)">
99
- `,p=O;c+=` <rect x="${p}" y="0" width="${M}" height="${V}" fill="${Q[0].color}" stroke="#1565C0"/>
100
- <text x="${p+M/2}" y="25" text-anchor="middle" class="col-header">${K(Q[0].name)}</text>
101
- <text x="${p+M/2}" y="42" text-anchor="middle" class="col-desc">${K(Q[0].desc)}</text>
102
- `,p+=M;let N=(Q.length-1)*M;c+=` <rect x="${p}" y="0" width="${N}" height="25" fill="#0D47A1"/>
103
- <text x="${p+N/2}" y="17" text-anchor="middle" class="col-header">In HTML Page</text>
104
- `;for(let e=1;e<Q.length;e++){let r=Q[e];c+=` <rect x="${p}" y="25" width="${M}" height="${V-25}" fill="${r.color}" stroke="#1976D2"/>
105
- <text x="${p+M/2}" y="42" text-anchor="middle" class="col-header">${K(r.name)}</text>
106
- <text x="${p+M/2}" y="55" text-anchor="middle" class="col-desc">${K(r.desc)}</text>
107
- `,p+=M}let y=V;for(let e of H){let r=q.length*W.length*X;c+=` <rect x="0" y="${y}" width="${F}" height="${r}" fill="${e.color}" stroke="#999"/>
108
- <text x="${F/2}" y="${y+r/2+4}" text-anchor="middle" class="row-label-bold">${K(e.name)}</text>
109
- `;for(let s of q){let z0=W.length*X;c+=` <rect x="${F}" y="${y}" width="${_}" height="${z0}" fill="${s.color}" stroke="#CCC"/>
110
- <text x="${F+_/2}" y="${y+z0/2+4}" text-anchor="middle" class="row-label">${K(s.name)}</text>
111
- `;for(let T of W){c+=` <rect x="${F+_}" y="${y}" width="${U}" height="${X}" fill="${T.color}" stroke="#DDD"/>
112
- <text x="${F+_+U/2}" y="${y+X/2+4}" text-anchor="middle" class="row-label">${K(T.name)}</text>
113
- `,p=O;for(let P of Q){let t=j(e.id,s.id,T.id,P.id),$0="cell-ok";if(t.length>=4)$0="cell-bad";else if(t.length>0)$0="cell-warn";if(c+=` <rect x="${p}" y="${y}" width="${M}" height="${X}" class="${$0}" stroke="#DDD"/>
114
- `,t.length===0)c+=` <text x="${p+M/2}" y="${y+X/2-5}" text-anchor="middle" class="ok-text">No issues</text>
115
- <text x="${p+M/2}" y="${y+X/2+12}" text-anchor="middle" class="problem-text" style="fill:#388E3C">Everything works</text>
116
- `;else{let Q0=y+16;for(let U0 of t){let N0=`• ${U0.text||"Unknown issue"}`;c+=` <text x="${p+8}" y="${Q0}" class="problem-text">${K(N0)}</text>
117
- `,Q0+=Y}}p+=M}y+=X}}c+=` <line x1="0" y1="${y}" x2="${I}" y2="${y}" stroke="#999" stroke-width="2"/>
118
- `}c+=`
119
- <text x="0" y="${u}" class="legend-title">SERVER-SIDE SVG RENDERERS (no HTML embedding)</text>
120
- `;let B=u+20;for(let e of z){c+=` <rect x="0" y="${B}" width="150" height="${m-4}" fill="${e.color}" stroke="#999"/>
121
- <text x="10" y="${B+18}" class="row-label-bold">${K(e.name)}</text>
122
- `;let r=e.issues.join(" • ");c+=` <text x="160" y="${B+18}" class="problem-text">${K(r)}</text>
123
- `,B+=m}return c+=`
99
+ `,c=M;p+=` <rect x="${c}" y="0" width="${Y}" height="${V}" fill="${Q[0].color}" stroke="#1565C0"/>
100
+ <text x="${c+Y/2}" y="25" text-anchor="middle" class="col-header">${K(Q[0].name)}</text>
101
+ <text x="${c+Y/2}" y="42" text-anchor="middle" class="col-desc">${K(Q[0].desc)}</text>
102
+ `,c+=Y;let C=(Q.length-1)*Y;p+=` <rect x="${c}" y="0" width="${C}" height="25" fill="#0D47A1"/>
103
+ <text x="${c+C/2}" y="17" text-anchor="middle" class="col-header">In HTML Page</text>
104
+ `;for(let e=1;e<Q.length;e++){let a=Q[e];p+=` <rect x="${c}" y="25" width="${Y}" height="${V-25}" fill="${a.color}" stroke="#1976D2"/>
105
+ <text x="${c+Y/2}" y="42" text-anchor="middle" class="col-header">${K(a.name)}</text>
106
+ <text x="${c+Y/2}" y="55" text-anchor="middle" class="col-desc">${K(a.desc)}</text>
107
+ `,c+=Y}let u=V;for(let e of H){let a=q.length*j.length*X;p+=` <rect x="0" y="${u}" width="${F}" height="${a}" fill="${e.color}" stroke="#999"/>
108
+ <text x="${F/2}" y="${u+a/2+4}" text-anchor="middle" class="row-label-bold">${K(e.name)}</text>
109
+ `;for(let s of q){let H0=j.length*X;p+=` <rect x="${F}" y="${u}" width="${_}" height="${H0}" fill="${s.color}" stroke="#CCC"/>
110
+ <text x="${F+_/2}" y="${u+H0/2+4}" text-anchor="middle" class="row-label">${K(s.name)}</text>
111
+ `;for(let S of j){p+=` <rect x="${F+_}" y="${u}" width="${U}" height="${X}" fill="${S.color}" stroke="#DDD"/>
112
+ <text x="${F+_+U/2}" y="${u+X/2+4}" text-anchor="middle" class="row-label">${K(S.name)}</text>
113
+ `,c=M;for(let E of Q){let t=W(e.id,s.id,S.id,E.id),$0="cell-ok";if(t.length>=4)$0="cell-bad";else if(t.length>0)$0="cell-warn";if(p+=` <rect x="${c}" y="${u}" width="${Y}" height="${X}" class="${$0}" stroke="#DDD"/>
114
+ `,t.length===0)p+=` <text x="${c+Y/2}" y="${u+X/2-5}" text-anchor="middle" class="ok-text">No issues</text>
115
+ <text x="${c+Y/2}" y="${u+X/2+12}" text-anchor="middle" class="problem-text" style="fill:#388E3C">Everything works</text>
116
+ `;else{let Q0=u+16;for(let U0 of t){let C0=`• ${U0.text||"Unknown issue"}`;p+=` <text x="${c+8}" y="${Q0}" class="problem-text">${K(C0)}</text>
117
+ `,Q0+=O}}c+=Y}u+=X}}p+=` <line x1="0" y1="${u}" x2="${B}" y2="${u}" stroke="#999" stroke-width="2"/>
118
+ `}p+=`
119
+ <text x="0" y="${h}" class="legend-title">SERVER-SIDE SVG RENDERERS (no HTML embedding)</text>
120
+ `;let N=h+20;for(let e of z){p+=` <rect x="0" y="${N}" width="150" height="${m-4}" fill="${e.color}" stroke="#999"/>
121
+ <text x="10" y="${N+18}" class="row-label-bold">${K(e.name)}</text>
122
+ `;let a=e.issues.join(" • ");p+=` <text x="160" y="${N+18}" class="problem-text">${K(a)}</text>
123
+ `,N+=m}return p+=`
124
124
  <g transform="translate(0, ${x})">
125
125
  <text x="0" y="0" class="legend-title">LEGEND</text>
126
126
 
@@ -209,8 +209,8 @@ ${z}
209
209
  <text x="0" y="995" class="legend-text">4. All animations and audio are synchronized because they share the same trigger event</text>
210
210
  </g>
211
211
  </g>
212
- </svg>`,c}function GJ($){let{title:J="Data Table",subtitle:Z="",columns:K=[],rowLevels:Q=[],rowData:H=[],getCellContent:z=()=>({lines:[],status:"ok"}),legend:q=null,additionalSections:W=[],options:j={}}=$,G={fontFamily:j.fontFamily||"system-ui, -apple-system, BlinkMacSystemFont, sans-serif",minCellWidth:j.minCellWidth||150,maxCellWidth:j.maxCellWidth||300,minCellHeight:j.minCellHeight||60,cellPaddingX:j.cellPaddingX||8,cellPaddingY:j.cellPaddingY||12,titleFontSize:j.titleFontSize||20,subtitleFontSize:j.subtitleFontSize||12,headerFontSize:j.headerFontSize||12,cellFontSize:j.cellFontSize||10,lineHeight:j.lineHeight||13,titleColor:j.titleColor||"#1a1a1a",subtitleColor:j.subtitleColor||"#666",borderColor:j.borderColor||"#DDD",okColor:j.okColor||"#C8E6C9",warnColor:j.warnColor||"#FFF9C4",badColor:j.badColor||"#FFCDD2",okTextColor:j.okTextColor||"#2E7D32",colHeaderHeight:j.colHeaderHeight||60,marginTop:j.marginTop||55,marginLeft:j.marginLeft||25,marginRight:j.marginRight||25,marginBottom:j.marginBottom||50,sectionSpacing:j.sectionSpacing||40,groupHeaderHeight:j.groupHeaderHeight||25,groupHeaderColor:j.groupHeaderColor||"#0D47A1"},F=(T)=>String(T).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"),_=(T,P=0,t=[])=>{let $0=[];for(let Q0 of T){let U0=[...t,{level:P,...Q0}];if(Q0.children&&Q0.children.length>0&&P<Q.length-1)$0.push(..._(Q0.children,P+1,U0));else $0.push(U0)}return $0},U=_(H[0]||[]),O=U.length,V=Q.length,M=Q.map((T,P)=>{if(T.width)return T.width;let t=T.name.length,$0=(Q0,U0)=>{for(let N0 of Q0){if(U0===P)t=Math.max(t,(N0.name||"").length);if(N0.children)$0(N0.children,U0+1)}};return $0(H[0]||[],0),Math.max(60,t*7+20)}),Y=M.reduce((T,P)=>T+P,0),X=0,w=0;for(let T of U)for(let P of K){let $0=z(T,P.id).lines||[];X=Math.max(X,$0.length);for(let Q0 of $0)w=Math.max(w,Q0.length)}let R=Math.min(G.maxCellWidth,Math.max(G.minCellWidth,w*6+G.cellPaddingX*2)),I=Math.max(G.minCellHeight,(X+1)*G.lineHeight+G.cellPaddingY*2),b=[],u=null;for(let T=0;T<K.length;T++){let P=K[T];if(P.group)if(!u||u.name!==P.group)u={name:P.group,startIndex:T,count:1,color:P.groupColor||G.groupHeaderColor},b.push(u);else u.count++;else u=null}let m=b.length>0,S=m?G.colHeaderHeight+G.groupHeaderHeight:G.colHeaderHeight,x=Y+K.length*R,h=S+O*I,E=0;for(let T of W)E+=G.sectionSpacing+(T.height||100);let d=q?j.legendHeight||200:0,c=x+G.marginLeft+G.marginRight,p=G.marginTop+h+E+(q?G.sectionSpacing+d:0)+G.marginBottom,N=`<?xml version="1.0" encoding="UTF-8"?>
213
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${c} ${p}" preserveAspectRatio="xMinYMin meet" height="${p}" width="100%">
212
+ </svg>`,p}function YJ($){let{title:J="Data Table",subtitle:Z="",columns:K=[],rowLevels:Q=[],rowData:H=[],getCellContent:z=()=>({lines:[],status:"ok"}),legend:q=null,additionalSections:j=[],options:W={}}=$,G={fontFamily:W.fontFamily||"system-ui, -apple-system, BlinkMacSystemFont, sans-serif",minCellWidth:W.minCellWidth||150,maxCellWidth:W.maxCellWidth||300,minCellHeight:W.minCellHeight||60,cellPaddingX:W.cellPaddingX||8,cellPaddingY:W.cellPaddingY||12,titleFontSize:W.titleFontSize||20,subtitleFontSize:W.subtitleFontSize||12,headerFontSize:W.headerFontSize||12,cellFontSize:W.cellFontSize||10,lineHeight:W.lineHeight||13,titleColor:W.titleColor||"#1a1a1a",subtitleColor:W.subtitleColor||"#666",borderColor:W.borderColor||"#DDD",okColor:W.okColor||"#C8E6C9",warnColor:W.warnColor||"#FFF9C4",badColor:W.badColor||"#FFCDD2",okTextColor:W.okTextColor||"#2E7D32",colHeaderHeight:W.colHeaderHeight||60,marginTop:W.marginTop||55,marginLeft:W.marginLeft||25,marginRight:W.marginRight||25,marginBottom:W.marginBottom||50,sectionSpacing:W.sectionSpacing||40,groupHeaderHeight:W.groupHeaderHeight||25,groupHeaderColor:W.groupHeaderColor||"#0D47A1"},F=(S)=>String(S).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"),_=(S,E=0,t=[])=>{let $0=[];for(let Q0 of S){let U0=[...t,{level:E,...Q0}];if(Q0.children&&Q0.children.length>0&&E<Q.length-1)$0.push(..._(Q0.children,E+1,U0));else $0.push(U0)}return $0},U=_(H[0]||[]),M=U.length,V=Q.length,Y=Q.map((S,E)=>{if(S.width)return S.width;let t=S.name.length,$0=(Q0,U0)=>{for(let C0 of Q0){if(U0===E)t=Math.max(t,(C0.name||"").length);if(C0.children)$0(C0.children,U0+1)}};return $0(H[0]||[],0),Math.max(60,t*7+20)}),O=Y.reduce((S,E)=>S+E,0),X=0,w=0;for(let S of U)for(let E of K){let $0=z(S,E.id).lines||[];X=Math.max(X,$0.length);for(let Q0 of $0)w=Math.max(w,Q0.length)}let R=Math.min(G.maxCellWidth,Math.max(G.minCellWidth,w*6+G.cellPaddingX*2)),B=Math.max(G.minCellHeight,(X+1)*G.lineHeight+G.cellPaddingY*2),I=[],h=null;for(let S=0;S<K.length;S++){let E=K[S];if(E.group)if(!h||h.name!==E.group)h={name:E.group,startIndex:S,count:1,color:E.groupColor||G.groupHeaderColor},I.push(h);else h.count++;else h=null}let m=I.length>0,v=m?G.colHeaderHeight+G.groupHeaderHeight:G.colHeaderHeight,x=O+K.length*R,y=v+M*B,T=0;for(let S of j)T+=G.sectionSpacing+(S.height||100);let d=q?W.legendHeight||200:0,p=x+G.marginLeft+G.marginRight,c=G.marginTop+y+T+(q?G.sectionSpacing+d:0)+G.marginBottom,C=`<?xml version="1.0" encoding="UTF-8"?>
213
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${p} ${c}" preserveAspectRatio="xMinYMin meet" height="${c}" width="100%">
214
214
  <title>${F(J)}</title>
215
215
 
216
216
  <defs>
@@ -231,37 +231,37 @@ ${z}
231
231
  </style>
232
232
  </defs>
233
233
 
234
- <text x="${c/2}" y="24" text-anchor="middle" class="title">${F(J)}</text>
235
- ${Z?`<text x="${c/2}" y="42" text-anchor="middle" class="subtitle">${F(Z)}</text>`:""}
234
+ <text x="${p/2}" y="24" text-anchor="middle" class="title">${F(J)}</text>
235
+ ${Z?`<text x="${p/2}" y="42" text-anchor="middle" class="subtitle">${F(Z)}</text>`:""}
236
236
 
237
237
  <g transform="translate(${G.marginLeft}, ${G.marginTop})">
238
- `,y=Y;if(m){let T=0;for(let P=0;P<K.length&&!K[P].group;P++)T++;for(let P of b){let t=Y+P.startIndex*R,$0=P.count*R;N+=` <rect x="${t}" y="0" width="${$0}" height="${G.groupHeaderHeight}" fill="${P.color}"/>
239
- <text x="${t+$0/2}" y="${G.groupHeaderHeight-8}" text-anchor="middle" class="col-header">${F(P.name)}</text>
240
- `}}let B=m?G.groupHeaderHeight:0,e=m?G.colHeaderHeight:S;for(let T=0;T<K.length;T++){let P=K[T],t=Y+T*R,$0=P.group?B:0,Q0=P.group?e:S;if(N+=` <rect x="${t}" y="${$0}" width="${R}" height="${Q0}" fill="${P.color}" stroke="${G.borderColor}"/>
241
- <text x="${t+R/2}" y="${$0+Q0/2-5}" text-anchor="middle" class="col-header">${F(P.name)}</text>
242
- `,P.desc)N+=` <text x="${t+R/2}" y="${$0+Q0/2+10}" text-anchor="middle" class="col-desc">${F(P.desc)}</text>
243
- `}let r=new Map,s=S;for(let T=0;T<U.length;T++){let P=U[T],t=0;for(let $0=0;$0<V;$0++){let Q0=P.find((N0)=>N0.level===$0);if(!Q0){t+=M[$0];continue}let U0=`${$0}-${Q0.id}`;if(!r.has(U0)){let N0=1;for(let o=T+1;o<U.length;o++){let J0=U[o].find((F0)=>F0.level===$0);if(J0&&J0.id===Q0.id)N0++;else break}let h0=N0*I;N+=` <rect x="${t}" y="${s}" width="${M[$0]}" height="${h0}" fill="${Q0.color||"#F5F5F5"}" stroke="${G.borderColor}"/>
244
- <text x="${t+M[$0]/2}" y="${s+h0/2+4}" text-anchor="middle" class="${$0===0?"row-label-bold":"row-label"}">${F(Q0.name)}</text>
245
- `,r.set(U0,{y:s,height:h0})}t+=M[$0]}for(let $0=0;$0<K.length;$0++){let Q0=K[$0],U0=Y+$0*R,N0=z(P,Q0.id),h0=N0.lines||[],o=N0.status||"ok";if(N+=` <rect x="${U0}" y="${s}" width="${R}" height="${I}" class="${o==="bad"?"cell-bad":o==="warn"?"cell-warn":"cell-ok"}" stroke="${G.borderColor}"/>
246
- `,h0.length===0)N+=` <text x="${U0+R/2}" y="${s+I/2}" text-anchor="middle" class="ok-text">No issues</text>
247
- `;else{let F0=s+G.cellPaddingY+G.lineHeight;for(let O0 of h0)N+=` <text x="${U0+G.cellPaddingX}" y="${F0}" class="cell-text">${F("• "+O0)}</text>
248
- `,F0+=G.lineHeight}}if(s+=I,T<U.length-1){let $0=P[0]?.id,Q0=U[T+1][0]?.id;if($0!==Q0)N+=` <line x1="0" y1="${s}" x2="${x}" y2="${s}" stroke="#999" stroke-width="2"/>
249
- `}}let z0=h+G.sectionSpacing;for(let T of W){if(T.title)N+=`
250
- <text x="0" y="${z0}" class="section-title">${F(T.title)}</text>
251
- `,z0+=20;if(T.content)N+=` <g transform="translate(0, ${z0})">
252
- ${T.content}
238
+ `,u=O;if(m){let S=0;for(let E=0;E<K.length&&!K[E].group;E++)S++;for(let E of I){let t=O+E.startIndex*R,$0=E.count*R;C+=` <rect x="${t}" y="0" width="${$0}" height="${G.groupHeaderHeight}" fill="${E.color}"/>
239
+ <text x="${t+$0/2}" y="${G.groupHeaderHeight-8}" text-anchor="middle" class="col-header">${F(E.name)}</text>
240
+ `}}let N=m?G.groupHeaderHeight:0,e=m?G.colHeaderHeight:v;for(let S=0;S<K.length;S++){let E=K[S],t=O+S*R,$0=E.group?N:0,Q0=E.group?e:v;if(C+=` <rect x="${t}" y="${$0}" width="${R}" height="${Q0}" fill="${E.color}" stroke="${G.borderColor}"/>
241
+ <text x="${t+R/2}" y="${$0+Q0/2-5}" text-anchor="middle" class="col-header">${F(E.name)}</text>
242
+ `,E.desc)C+=` <text x="${t+R/2}" y="${$0+Q0/2+10}" text-anchor="middle" class="col-desc">${F(E.desc)}</text>
243
+ `}let a=new Map,s=v;for(let S=0;S<U.length;S++){let E=U[S],t=0;for(let $0=0;$0<V;$0++){let Q0=E.find((C0)=>C0.level===$0);if(!Q0){t+=Y[$0];continue}let U0=`${$0}-${Q0.id}`;if(!a.has(U0)){let C0=1;for(let o=S+1;o<U.length;o++){let K0=U[o].find((F0)=>F0.level===$0);if(K0&&K0.id===Q0.id)C0++;else break}let y0=C0*B;C+=` <rect x="${t}" y="${s}" width="${Y[$0]}" height="${y0}" fill="${Q0.color||"#F5F5F5"}" stroke="${G.borderColor}"/>
244
+ <text x="${t+Y[$0]/2}" y="${s+y0/2+4}" text-anchor="middle" class="${$0===0?"row-label-bold":"row-label"}">${F(Q0.name)}</text>
245
+ `,a.set(U0,{y:s,height:y0})}t+=Y[$0]}for(let $0=0;$0<K.length;$0++){let Q0=K[$0],U0=O+$0*R,C0=z(E,Q0.id),y0=C0.lines||[],o=C0.status||"ok";if(C+=` <rect x="${U0}" y="${s}" width="${R}" height="${B}" class="${o==="bad"?"cell-bad":o==="warn"?"cell-warn":"cell-ok"}" stroke="${G.borderColor}"/>
246
+ `,y0.length===0)C+=` <text x="${U0+R/2}" y="${s+B/2}" text-anchor="middle" class="ok-text">No issues</text>
247
+ `;else{let F0=s+G.cellPaddingY+G.lineHeight;for(let M0 of y0)C+=` <text x="${U0+G.cellPaddingX}" y="${F0}" class="cell-text">${F("• "+M0)}</text>
248
+ `,F0+=G.lineHeight}}if(s+=B,S<U.length-1){let $0=E[0]?.id,Q0=U[S+1][0]?.id;if($0!==Q0)C+=` <line x1="0" y1="${s}" x2="${x}" y2="${s}" stroke="#999" stroke-width="2"/>
249
+ `}}let H0=y+G.sectionSpacing;for(let S of j){if(S.title)C+=`
250
+ <text x="0" y="${H0}" class="section-title">${F(S.title)}</text>
251
+ `,H0+=20;if(S.content)C+=` <g transform="translate(0, ${H0})">
252
+ ${S.content}
253
253
  </g>
254
- `;if(T.items)for(let P of T.items){if(P.rect)N+=` <rect x="${P.rect.x}" y="${z0+P.rect.y}" width="${P.rect.width}" height="${P.rect.height}" fill="${P.rect.fill||"#EEE"}" stroke="${P.rect.stroke||"#999"}"/>
255
- `;if(P.text)N+=` <text x="${P.text.x}" y="${z0+P.text.y}" class="${P.text.class||"legend-text"}">${F(P.text.content)}</text>
256
- `}z0+=T.height||100}if(q)N+=`
257
- <g transform="translate(0, ${z0})">
254
+ `;if(S.items)for(let E of S.items){if(E.rect)C+=` <rect x="${E.rect.x}" y="${H0+E.rect.y}" width="${E.rect.width}" height="${E.rect.height}" fill="${E.rect.fill||"#EEE"}" stroke="${E.rect.stroke||"#999"}"/>
255
+ `;if(E.text)C+=` <text x="${E.text.x}" y="${H0+E.text.y}" class="${E.text.class||"legend-text"}">${F(E.text.content)}</text>
256
+ `}H0+=S.height||100}if(q)C+=`
257
+ <g transform="translate(0, ${H0})">
258
258
  ${q}
259
259
  </g>
260
- `;return N+=` </g>
261
- </svg>`,N}function nK($={}){let J=$.fontFamily||"system-ui, -apple-system, BlinkMacSystemFont, sans-serif",Z=[{id:"standalone",name:"Standalone SVG",desc:"Open .svg directly",color:"#1565C0"},{id:"img",name:"<img>",desc:"Image element",color:"#1976D2",group:"In HTML Page",groupColor:"#0D47A1"},{id:"object",name:"<object>",desc:"Object element",color:"#1E88E5",group:"In HTML Page"},{id:"embed",name:"<embed>",desc:"Embed element",color:"#2196F3",group:"In HTML Page"},{id:"inline",name:"Inline <svg>",desc:"SVG in HTML",color:"#42A5F5",group:"In HTML Page"},{id:"css",name:"CSS background",desc:"background-image",color:"#64B5F6",group:"In HTML Page"}],K=[{id:"environment",name:"Environment",width:130},{id:"protocol",name:"Protocol",width:80},{id:"script",name:"JavaScript",width:90}],Q=[[{id:"desktop",name:"Desktop Browser",color:"#E3F2FD",children:[{id:"file",name:"file://",color:"#BBDEFB",children:[{id:"js",name:"JS enabled",color:"#DCEDC8"},{id:"nojs",name:"JS disabled",color:"#FFCDD2"}]},{id:"http",name:"http(s)://",color:"#C8E6C9",children:[{id:"js",name:"JS enabled",color:"#DCEDC8"},{id:"nojs",name:"JS disabled",color:"#FFCDD2"}]}]},{id:"mobile",name:"Mobile Browser",color:"#E8F5E9",children:[{id:"file",name:"file://",color:"#BBDEFB",children:[{id:"js",name:"JS enabled",color:"#DCEDC8"},{id:"nojs",name:"JS disabled",color:"#FFCDD2"}]},{id:"http",name:"http(s)://",color:"#C8E6C9",children:[{id:"js",name:"JS enabled",color:"#DCEDC8"},{id:"nojs",name:"JS disabled",color:"#FFCDD2"}]}]}]],H=$.getCellContent||((G,F)=>{return{lines:[],status:"ok"}}),z=[{name:"Node.js (JSDOM)",color:"#FFF3E0",issues:["No rendering","No animations","No interaction"]},{name:"ImageMagick",color:"#EFEBE9",issues:["No animations","No scripts","No foreignObject","No web fonts"]},{name:"Inkscape CLI",color:"#F3E5F5",issues:["No animations","No scripts"]},{name:"librsvg",color:"#E0F2F1",issues:["No animations","No scripts","Limited filters"]},{name:"Cairo",color:"#FBE9E7",issues:["No animations","No scripts","No filters","No foreignObject"]},{name:"Apache Batik",color:"#F3E5F5",issues:["No CSS animations","Limited SMIL","No web fonts"]}],q="",W=0;for(let G of z)q+=`<rect x="0" y="${W}" width="150" height="26" fill="${G.color}" stroke="#999"/>
262
- <text x="10" y="${W+18}" class="row-label-bold">${G.name}</text>
263
- <text x="160" y="${W+18}" class="cell-text">${G.issues.join(" • ")}</text>
264
- `,W+=30;let j=`
260
+ `;return C+=` </g>
261
+ </svg>`,C}function QZ($={}){let J=$.fontFamily||"system-ui, -apple-system, BlinkMacSystemFont, sans-serif",Z=[{id:"standalone",name:"Standalone SVG",desc:"Open .svg directly",color:"#1565C0"},{id:"img",name:"<img>",desc:"Image element",color:"#1976D2",group:"In HTML Page",groupColor:"#0D47A1"},{id:"object",name:"<object>",desc:"Object element",color:"#1E88E5",group:"In HTML Page"},{id:"embed",name:"<embed>",desc:"Embed element",color:"#2196F3",group:"In HTML Page"},{id:"inline",name:"Inline <svg>",desc:"SVG in HTML",color:"#42A5F5",group:"In HTML Page"},{id:"css",name:"CSS background",desc:"background-image",color:"#64B5F6",group:"In HTML Page"}],K=[{id:"environment",name:"Environment",width:130},{id:"protocol",name:"Protocol",width:80},{id:"script",name:"JavaScript",width:90}],Q=[[{id:"desktop",name:"Desktop Browser",color:"#E3F2FD",children:[{id:"file",name:"file://",color:"#BBDEFB",children:[{id:"js",name:"JS enabled",color:"#DCEDC8"},{id:"nojs",name:"JS disabled",color:"#FFCDD2"}]},{id:"http",name:"http(s)://",color:"#C8E6C9",children:[{id:"js",name:"JS enabled",color:"#DCEDC8"},{id:"nojs",name:"JS disabled",color:"#FFCDD2"}]}]},{id:"mobile",name:"Mobile Browser",color:"#E8F5E9",children:[{id:"file",name:"file://",color:"#BBDEFB",children:[{id:"js",name:"JS enabled",color:"#DCEDC8"},{id:"nojs",name:"JS disabled",color:"#FFCDD2"}]},{id:"http",name:"http(s)://",color:"#C8E6C9",children:[{id:"js",name:"JS enabled",color:"#DCEDC8"},{id:"nojs",name:"JS disabled",color:"#FFCDD2"}]}]}]],H=$.getCellContent||((G,F)=>{return{lines:[],status:"ok"}}),z=[{name:"Node.js (JSDOM)",color:"#FFF3E0",issues:["No rendering","No animations","No interaction"]},{name:"ImageMagick",color:"#EFEBE9",issues:["No animations","No scripts","No foreignObject","No web fonts"]},{name:"Inkscape CLI",color:"#F3E5F5",issues:["No animations","No scripts"]},{name:"librsvg",color:"#E0F2F1",issues:["No animations","No scripts","Limited filters"]},{name:"Cairo",color:"#FBE9E7",issues:["No animations","No scripts","No filters","No foreignObject"]},{name:"Apache Batik",color:"#F3E5F5",issues:["No CSS animations","Limited SMIL","No web fonts"]}],q="",j=0;for(let G of z)q+=`<rect x="0" y="${j}" width="150" height="26" fill="${G.color}" stroke="#999"/>
262
+ <text x="10" y="${j+18}" class="row-label-bold">${G.name}</text>
263
+ <text x="160" y="${j+18}" class="cell-text">${G.issues.join(" • ")}</text>
264
+ `,j+=30;let W=`
265
265
  <text x="0" y="0" class="section-title">LEGEND</text>
266
266
 
267
267
  <rect x="0" y="15" width="18" height="14" class="cell-ok" stroke="#4CAF50"/>
@@ -347,12 +347,12 @@ ${z}
347
347
  <text x="0" y="963" class="legend-text">2. Set ALL animations AND audio to begin="mySvg.click"</text>
348
348
  <text x="0" y="979" class="legend-text">3. User clicks anywhere on SVG → user activation satisfied → audio plays → animations start</text>
349
349
  <text x="0" y="995" class="legend-text">4. All animations and audio are synchronized because they share the same trigger event</text>
350
- `;return GJ({title:"SVG Compatibility Matrix",subtitle:"What problems will your SVG have in each configuration?",columns:Z,rowLevels:K,rowData:Q,getCellContent:H,additionalSections:[{title:"SERVER-SIDE SVG RENDERERS (no HTML embedding)",content:q,height:z.length*30+20}],legend:j,options:{fontFamily:J,minCellWidth:220,legendHeight:1020,...$}})}var FJ=j0(($,J={})=>{let Z=J.fixInvalidGroupAttrs!==!1,K=J.fixMissingNamespaces!==!1,Q=J.fixBrokenRefs!==!1,H=J.fixAnimationTiming!==!1,z=J.verbose||!1,q=[],W=new Set,j=(f)=>{let C=f.getAttribute("id");if(C)W.add(C);for(let l of f.children)if(a(l))j(l)};j($);let G=["x","y","width","height","cx","cy","r","rx","ry","x1","y1","x2","y2","d","points"],F=new Set(["svg","rect","image","foreignObject","use","symbol","pattern","mask","filter","clipPath"]),_=(f)=>{let C=f.tagName.toLowerCase();if(C==="g"&&Z){for(let l of G)if(f.hasAttribute(l)){let g=f.getAttribute(l);f.removeAttribute(l),q.push({type:"invalid_attr_removed",element:C,attr:l,value:g,reason:`SVG 1.1: <g> elements do not support '${l}' attribute`})}}for(let l of f.children)if(a(l))_(l)},U=()=>{if(!K)return;let f=!1,C=(l)=>{for(let g of l.getAttributeNames())if(g.startsWith("xlink:")){f=!0;return}for(let g of l.children){if(a(g))C(g);if(f)return}};if(C($),f&&!$.hasAttribute("xmlns:xlink"))$.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),q.push({type:"namespace_added",namespace:"xmlns:xlink",value:"http://www.w3.org/1999/xlink",reason:"SVG 1.1: xmlns:xlink required when xlink:* attributes are present"})},O=(f)=>{let C=[f,f.replace(/^FRAME(\d+)$/,"FRAME0$1"),f.replace(/^FRAME0(\d+)$/,"FRAME00$1"),f.replace(/^FRAME00(\d+)$/,"FRAME000$1"),f.replace(/^FRAME0+(\d+)$/,"FRAME$1"),f.replace(/^FRAME(\d)$/,"FRAME0000$1"),f.replace(/^FRAME(\d{2})$/,"FRAME000$1"),f.replace(/^FRAME(\d{3})$/,"FRAME00$1"),f.replace(/^FRAME(\d{4})$/,"FRAME0$1")];for(let n of C)if(W.has(n)&&n!==f)return n;let l=null,g=1/0;for(let n of W)if(n.toLowerCase().includes(f.toLowerCase())||f.toLowerCase().includes(n.toLowerCase())){let G0=Math.abs(n.length-f.length);if(G0<g&&G0<=2)g=G0,l=n}return l},V=(f)=>{if(!Q)return;for(let C of["href","xlink:href"]){let l=f.getAttribute(C);if(l&&l.startsWith("#")){let g=l.substring(1);if(!W.has(g)){let n=O(g);if(n)f.setAttribute(C,`#${n}`),q.push({type:"ref_fixed",element:f.tagName.toLowerCase(),attr:C,oldValue:l,newValue:`#${n}`,reason:`ID '${g}' not found, fixed to similar ID '${n}'`})}}}if(f.tagName.toLowerCase()==="animate"){let C=f.getAttribute("attributeName");if(C==="href"||C==="xlink:href"){let l=f.getAttribute("values");if(l){let g=l.split(";"),n=!1,G0=g.map((L0)=>{let P0=L0.trim();if(P0.startsWith("#")){let E0=P0.substring(1);if(!W.has(E0)){let U7=O(E0);if(U7)return n=!0,`#${U7}`}}return P0});if(n){let L0=G0.join(";");f.setAttribute("values",L0),q.push({type:"animate_values_fixed",oldValue:l,newValue:L0,reason:"Fixed broken ID references in animate values"})}}}}for(let C of["fill","stroke","clip-path","mask","filter"]){let l=f.getAttribute(C);if(l&&l.startsWith("url(#")){let g=l.match(/url\(#([^)]+)\)/);if(g){let n=g[1];if(!W.has(n)){let G0=O(n);if(G0)f.setAttribute(C,`url(#${G0})`),q.push({type:"url_ref_fixed",element:f.tagName.toLowerCase(),attr:C,oldValue:l,newValue:`url(#${G0})`,reason:`ID '${n}' not found, fixed to similar ID '${G0}'`})}}}}for(let C of f.children)if(a(C))V(C)},M=(f)=>{if(!H)return;let C=["animate","animateTransform","animateMotion","animateColor","set"],l=f.tagName.toLowerCase();if(C.includes(l)){let g=f.getAttribute("dur"),n=f.getAttribute("repeatCount");if(g==="0"||g==="0s"){if(!f.getAttribute("keyTimes"))q.push({type:"timing_warning",element:l,attr:"dur",value:g,reason:'dur="0" may cause animation to not play'})}let G0=f.getAttribute("begin");if(G0){let L0=G0;if(G0==="0")L0="0s",f.setAttribute("begin",L0),q.push({type:"timing_normalized",element:l,attr:"begin",oldValue:G0,newValue:L0,reason:"Normalized begin value to include time unit"})}}for(let g of f.children)if(a(g))M(g)},Y=new Set(["font-face-format","font-face-name","glyphref","hkern","vkern"]),X=new Set(["animate","animateTransform","animateMotion","animateColor","set"]),w=(f)=>{let C=f.tagName.toLowerCase();if(Y.has(C)){let l=[];for(let g of Array.from(f.children))if(a(g)&&X.has(g.tagName.toLowerCase()))l.push(g);if(l.length>0){let g=f.getAttribute("id");if(!g)g=`_fix_${C}_${Math.random().toString(36).substring(2,8)}`,f.setAttribute("id",g),q.push({type:"id_generated",element:C,id:g,reason:"Generated ID for animation targeting after moving animate element"});for(let n of l){if(f.removeChild(n),!n.hasAttribute("href")&&!n.hasAttribute("xlink:href"))n.setAttribute("href",`#${g}`);let G0=f.parentNode;if(G0){let L0=f.nextSibling;if(L0)G0.insertBefore(n,L0);else G0.appendChild(n)}q.push({type:"animation_moved_from_empty_element",element:n.tagName.toLowerCase(),parentElement:C,targetId:g,reason:`SVG 1.1: <${C}> has EMPTY content model and cannot have children. Animation moved outside and targets element via href="#${g}".`})}}}for(let l of Array.from(f.children))if(a(l))w(l)},R=/^([+-]?\d*\.?\d+(?:[Ee][+-]?\d+)?)(EM|EX|PX|IN|CM|MM|PT|PC|DEG|GRAD|RAD|S|MS|HZ|KHZ|%)$/i,I=new Set(["x","y","width","height","rx","ry","cx","cy","r","fx","fy","x1","y1","x2","y2","dx","dy","textLength","startOffset","stroke-width","stroke-dashoffset","font-size","baseline-shift","kerning","letter-spacing","word-spacing","markerWidth","markerHeight","refX","refY","stdDeviation","radius"]),b=(f)=>{for(let C of f.getAttributeNames()){if(!I.has(C)&&!C.includes("-"))continue;let l=f.getAttribute(C);if(!l)continue;let g=l.match(R);if(g){let[,n,G0]=g,L0=G0.toLowerCase();if(G0!==L0){let P0=n+L0;f.setAttribute(C,P0),q.push({type:"unit_normalized",element:f.tagName.toLowerCase(),attr:C,oldValue:l,newValue:P0,reason:"SVG 1.1: Unit identifiers in attributes must be lowercase"})}}}for(let C of f.children)if(a(C))b(C)},u=/[\u00A0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/g,m=new Set(["points","viewBox","preserveAspectRatio","transform","d","values","keyTimes","keySplines","keyPoints","rotate","stroke-dasharray","baseFrequency","kernelMatrix","tableValues","filterRes","stdDeviation","radius","origin"]),S=(f)=>{for(let C of f.getAttributeNames()){if(!m.has(C)&&C!=="style")continue;let l=f.getAttribute(C);if(!l)continue;if(u.test(l)){let g=l.replace(u," ");f.setAttribute(C,g),q.push({type:"whitespace_normalized",element:f.tagName.toLowerCase(),attr:C,reason:"SVG 1.1: Replaced invalid Unicode whitespace with standard space (0x20)"})}}for(let C of f.children)if(a(C))S(C)},x=(f)=>{for(let C of f.getAttributeNames()){let l=f.getAttribute(C);if(!l)continue;let g=l,n=!1;if(/\d\.$/.test(g)||/\d\.(?=[,\s;)])/.test(g))g=g.replace(/(\d)\.(?=$|[,\s;)])/g,"$1"),n=!0;if(g=g.replace(/(^|[,\s;(])\.(\d)/g,"$10.$2"),g=g.replace(/(^|[,\s;(])-\.(\d)/g,"$1-0.$2"),g!==l)n=!0;if(/\.\.+/.test(g))g=g.replace(/\.\.+/g,"."),n=!0;if(n)f.setAttribute(C,g),q.push({type:"number_format_fixed",element:f.tagName.toLowerCase(),attr:C,oldValue:l,newValue:g,reason:"SVG 1.1: Fixed invalid number format"})}for(let C of f.children)if(a(C))x(C)},h=340000000000000000000000000000000000000,E=-340000000000000000000000000000000000000,d=/[+-]?\d*\.?\d+(?:[Ee][+-]?\d+)?/g,c=(f)=>{for(let C of f.getAttributeNames()){let l=f.getAttribute(C);if(!l)continue;if(C==="id"||C==="class"||C.startsWith("xmlns")||C==="href"||C==="xlink:href"||C==="style")continue;let g=l.match(d);if(!g)continue;for(let n of g){let G0=parseFloat(n);if(!isFinite(G0))q.push({type:"invalid_number_detected",element:f.tagName.toLowerCase(),attr:C,value:n,reason:"SVG 1.1: Invalid number (Infinity or NaN)"});else if(G0>h||G0<E)q.push({type:"out_of_range_detected",element:f.tagName.toLowerCase(),attr:C,value:n,reason:"SVG 1.1: Number exceeds single-precision float range"})}}for(let C of f.children)if(a(C))c(C)},p=(f)=>{let C=f.tagName,l=C.toLowerCase();if(C.includes(":")||G6.has(C)||H8.has(l));else{let g=C6(C,G6);if(g)q.push({type:"mistyped_element_detected",element:C,suggestion:g,reason:`Unknown element <${C}> - did you mean <${g}>?`});else q.push({type:"unknown_element_detected",element:C,reason:`Unknown element <${C}> - not in SVG 1.1 spec`})}for(let g of f.children)if(a(g))p(g)},N=(f)=>{for(let C of f.getAttributeNames()){if(C.startsWith("xmlns")||C.startsWith("data-"))continue;let l=C.toLowerCase();if(F6.has(C)||z8.has(l))continue;if(C.startsWith("-webkit-")||C.startsWith("-moz-")||C.startsWith("-ms-")||C.startsWith("-o-"))continue;if(C.includes(":")&&!C.startsWith("xlink:")&&!C.startsWith("xml:"))continue;let g=C6(C,F6);if(g)q.push({type:"mistyped_attribute_detected",element:f.tagName.toLowerCase(),attr:C,suggestion:g,reason:`Unknown attribute '${C}' on <${f.tagName.toLowerCase()}> - did you mean '${g}'?`})}for(let C of f.children)if(a(C))N(C)},y={a:["href"],animate:["attributeName"],animateColor:["attributeName"],animateTransform:["attributeName"],circle:["r"],"color-profile":["name"],cursor:["href"],ellipse:["rx","ry"],feBlend:["in2"],feComposite:["in2"],feConvolveMatrix:["kernelMatrix"],feDisplacementMap:["in2"],feFuncA:["type"],feFuncB:["type"],feFuncG:["type"],feFuncR:["type"],feImage:["href"],font:["horiz-adv-x"],"font-face-uri":["href"],foreignObject:["width","height"],hkern:["k"],image:["href","width","height"],mpath:["href"],path:["d"],polygon:["points"],polyline:["points"],rect:["width","height"],script:["type"],set:["attributeName"],stop:["offset"],style:["type"],textPath:["href"],tref:["href"],use:["href"],vkern:["k"]},B=["href","xlink:href"],e=(f)=>{let C=f.tagName.toLowerCase(),l=y[C];if(l){for(let g of l)if(g==="href"){if(!B.some((G0)=>f.hasAttribute(G0)))q.push({type:"missing_required_attribute",element:C,attr:g,reason:`Element <${C}> is missing required attribute '${g}' (or 'xlink:href')`})}else if(!f.hasAttribute(g))q.push({type:"missing_required_attribute",element:C,attr:g,reason:`Element <${C}> is missing required attribute '${g}'`})}for(let g of f.children)if(a(g))e(g)},r={circle:new Set(["desc","title","metadata","animate","animatecolor","animatemotion","animatetransform","set"]),ellipse:new Set(["desc","title","metadata","animate","animatecolor","animatemotion","animatetransform","set"]),line:new Set(["desc","title","metadata","animate","animatecolor","animatemotion","animatetransform","set"]),path:new Set(["desc","title","metadata","animate","animatecolor","animatemotion","animatetransform","set"]),polygon:new Set(["desc","title","metadata","animate","animatecolor","animatemotion","animatetransform","set"]),polyline:new Set(["desc","title","metadata","animate","animatecolor","animatemotion","animatetransform","set"]),rect:new Set(["desc","title","metadata","animate","animatecolor","animatemotion","animatetransform","set"]),use:new Set(["desc","title","metadata","animate","animatecolor","animatemotion","animatetransform","set"]),image:new Set(["desc","title","metadata","animate","animatecolor","animatemotion","animatetransform","set"]),animate:new Set(["desc","title","metadata"]),animatecolor:new Set(["desc","title","metadata"]),animatemotion:new Set(["desc","title","metadata","mpath"]),animatetransform:new Set(["desc","title","metadata"]),set:new Set(["desc","title","metadata"]),lineargradient:new Set(["desc","title","metadata","animate","animatetransform","set","stop"]),radialgradient:new Set(["desc","title","metadata","animate","animatetransform","set","stop"]),filter:new Set(["desc","title","metadata","animate","set","feblend","fecolormatrix","fecomponenttransfer","fecomposite","feconvolvematrix","fediffuselighting","fedisplacementmap","feflood","fegaussianblur","feimage","femerge","femorphology","feoffset","fespecularlighting","fetile","feturbulence"]),stop:new Set(["animate","animatecolor","set"])},s=(f)=>{let C=f.tagName.toLowerCase(),l=r[C];if(l){for(let g of f.children)if(a(g)){let n=g.tagName.toLowerCase();if(!n.includes(":")&&!l.has(n))q.push({type:"invalid_child_element",parent:C,child:n,reason:`Element <${n}> is not a valid child of <${C}> per SVG 1.1 DTD`})}}for(let g of f.children)if(a(g))s(g)},z0={"alignment-baseline":["auto","baseline","before-edge","text-before-edge","middle","central","after-edge","text-after-edge","ideographic","alphabetic","hanging","mathematical","inherit"],"clip-rule":["nonzero","evenodd","inherit"],"color-interpolation":["auto","sRGB","linearRGB","inherit"],"color-interpolation-filters":["auto","sRGB","linearRGB","inherit"],"color-rendering":["auto","optimizeSpeed","optimizeQuality","inherit"],direction:["ltr","rtl","inherit"],display:["inline","block","list-item","run-in","compact","marker","table","inline-table","table-row-group","table-header-group","table-footer-group","table-row","table-column-group","table-column","table-cell","table-caption","none","inherit"],"dominant-baseline":["auto","use-script","no-change","reset-size","ideographic","alphabetic","hanging","mathematical","central","middle","text-after-edge","text-before-edge","inherit"],"fill-rule":["nonzero","evenodd","inherit"],"font-stretch":["normal","wider","narrower","ultra-condensed","extra-condensed","condensed","semi-condensed","semi-expanded","expanded","extra-expanded","ultra-expanded","inherit"],"font-style":["normal","italic","oblique","inherit"],"font-variant":["normal","small-caps","inherit"],"font-weight":["normal","bold","bolder","lighter","100","200","300","400","500","600","700","800","900","inherit"],"image-rendering":["auto","optimizeSpeed","optimizeQuality","inherit"],overflow:["visible","hidden","scroll","auto","inherit"],"pointer-events":["visiblePainted","visibleFill","visibleStroke","visible","painted","fill","stroke","all","none","inherit"],"shape-rendering":["auto","optimizeSpeed","crispEdges","geometricPrecision","inherit"],"stroke-linecap":["butt","round","square","inherit"],"stroke-linejoin":["miter","round","bevel","inherit"],"text-anchor":["start","middle","end","inherit"],"text-rendering":["auto","optimizeSpeed","optimizeLegibility","geometricPrecision","inherit"],"unicode-bidi":["normal","embed","bidi-override","inherit"],visibility:["visible","hidden","collapse","inherit"],"writing-mode":["lr-tb","rl-tb","tb-rl","lr","rl","tb","inherit"],"xml:space":["default","preserve"],additive:["replace","sum"],accumulate:["none","sum"],calcMode:["discrete","linear","paced","spline"],fill:["freeze","remove"],restart:["always","whenNotActive","never"],attributeType:["CSS","XML","auto"],edgeMode:["duplicate","wrap","none"],operator:["over","in","out","atop","xor","arithmetic","erode","dilate"],mode:["normal","multiply","screen","darken","lighten"],type:["translate","scale","rotate","skewX","skewY","matrix","saturate","hueRotate","luminanceToAlpha","identity","table","discrete","linear","gamma","fractalNoise","turbulence"],spreadMethod:["pad","reflect","repeat"],gradientUnits:["userSpaceOnUse","objectBoundingBox"],patternUnits:["userSpaceOnUse","objectBoundingBox"],patternContentUnits:["userSpaceOnUse","objectBoundingBox"],clipPathUnits:["userSpaceOnUse","objectBoundingBox"],maskUnits:["userSpaceOnUse","objectBoundingBox"],maskContentUnits:["userSpaceOnUse","objectBoundingBox"],filterUnits:["userSpaceOnUse","objectBoundingBox"],primitiveUnits:["userSpaceOnUse","objectBoundingBox"],markerUnits:["strokeWidth","userSpaceOnUse"],method:["align","stretch"],spacing:["auto","exact"],lengthAdjust:["spacing","spacingAndGlyphs"],preserveAspectRatio:["none","xMinYMin","xMidYMin","xMaxYMin","xMinYMid","xMidYMid","xMaxYMid","xMinYMax","xMidYMax","xMaxYMax"],zoomAndPan:["disable","magnify"],externalResourcesRequired:["true","false"]},T=new Set(["preserveAspectRatio"]),P=(f)=>{let C=f.tagName.toLowerCase();for(let l of f.getAttributeNames()){let g=z0[l];if(g){let n=f.getAttribute(l);if(T.has(l)&&n)n=n.split(/\s+/)[0];if(l==="fill"&&!["animate","animatecolor","animatemotion","animatetransform","set"].includes(C))continue;if(!g.includes(n)&&n!=="inherit")q.push({type:"invalid_enum_value",element:C,attr:l,value:n,validValues:g.slice(0,5).join(", ")+(g.length>5?"...":""),reason:`Invalid value '${n}' for attribute '${l}' - must be one of: ${g.slice(0,5).join(", ")}${g.length>5?"...":""}`})}}for(let l of f.children)if(a(l))P(l)},t={opacity:{min:0,max:1,type:"number"},"fill-opacity":{min:0,max:1,type:"number"},"stroke-opacity":{min:0,max:1,type:"number"},"stop-opacity":{min:0,max:1,type:"number"},"flood-opacity":{min:0,max:1,type:"number"},"stroke-width":{min:0,type:"length"},"stroke-miterlimit":{min:1,type:"number"},"font-size":{min:0,type:"length"},r:{min:0,type:"length"},rx:{min:0,type:"length"},ry:{min:0,type:"length"},width:{min:0,type:"length"},height:{min:0,type:"length"},stdDeviation:{min:0,type:"number"},scale:{type:"number"},baseFrequency:{min:0,type:"number"},numOctaves:{min:1,type:"integer"},seed:{min:0,type:"number"},repeatCount:{min:0,type:"number"}},$0=(f)=>{let C=f.tagName.toLowerCase();for(let l of f.getAttributeNames()){let g=t[l];if(g){let n=f.getAttribute(l);if(n==="inherit"||n==="none"||n==="indefinite"||n==="auto")continue;let G0=n.match(/^([+-]?\d*\.?\d+)/);if(G0){let L0=parseFloat(G0[1]);if(isNaN(L0))q.push({type:"invalid_numeric_value",element:C,attr:l,value:n,reason:`Invalid numeric value '${n}' for attribute '${l}'`});else{if(g.min!==void 0&&L0<g.min)q.push({type:"numeric_out_of_range",element:C,attr:l,value:n,constraint:`min: ${g.min}`,reason:`Value '${n}' for '${l}' is below minimum (${g.min})`});if(g.max!==void 0&&L0>g.max)q.push({type:"numeric_out_of_range",element:C,attr:l,value:n,constraint:`max: ${g.max}`,reason:`Value '${n}' for '${l}' exceeds maximum (${g.max})`});if(g.type==="integer"&&!Number.isInteger(L0))q.push({type:"invalid_numeric_value",element:C,attr:l,value:n,reason:`Attribute '${l}' requires an integer value, got '${n}'`})}}}}for(let l of f.children)if(a(l))$0(l)},Q0=(f)=>{let C=new Map,l=(g)=>{let n=g.getAttribute("id");if(n){if(!C.has(n))C.set(n,[]);C.get(n).push(g.tagName.toLowerCase())}for(let G0 of g.children)if(a(G0))l(G0)};l(f);for(let[g,n]of C)if(n.length>1)q.push({type:"duplicate_id",id:g,count:n.length,elements:n.join(", "),reason:`Duplicate ID '${g}' found on ${n.length} elements: ${n.join(", ")}`})},U0=(f)=>{let C=new Set,l=(L0)=>{let P0=L0.getAttribute("id");if(P0)C.add(P0);for(let E0 of L0.children)if(a(E0))l(E0)};l(f);let g=/url\(\s*['"]?#([^'")]+)['"]?\s*\)/g,n=/^#(.+)$/,G0=(L0)=>{let P0=L0.tagName.toLowerCase();for(let E0 of L0.getAttributeNames()){let U7=L0.getAttribute(E0),b6;g.lastIndex=0;while((b6=g.exec(U7))!==null){let b7=b6[1];if(!C.has(b7))q.push({type:"broken_reference",element:P0,attr:E0,refId:b7,reason:`Broken reference: url(#${b7}) points to non-existent ID`})}if(E0==="href"||E0==="xlink:href"){let b7=U7.match(n);if(b7){let _6=b7[1];if(!C.has(_6))q.push({type:"broken_reference",element:P0,attr:E0,refId:_6,reason:`Broken reference: ${E0}="#${_6}" points to non-existent ID`})}}}for(let E0 of L0.children)if(a(E0))G0(E0)};G0($)},N0=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]),h0=new Set(["fill","stroke","color","stop-color","flood-color","lighting-color","solid-color"]),o=(f)=>{let C=f.toLowerCase().trim();if(C==="none"||C==="inherit"||C==="currentcolor")return!0;if(N0.has(C))return!0;if(C.startsWith("url("))return!0;if(/^#[0-9a-f]{3}$/.test(C)||/^#[0-9a-f]{6}$/.test(C))return!0;if(/^rgb\(\s*\d{1,3}%?\s*,\s*\d{1,3}%?\s*,\s*\d{1,3}%?\s*\)$/.test(C))return!0;if(/^rgba\(\s*\d{1,3}%?\s*,\s*\d{1,3}%?\s*,\s*\d{1,3}%?\s*,\s*[\d.]+%?\s*\)$/.test(C))return!0;return!1},J0=(f)=>{let C=f.tagName.toLowerCase();for(let l of f.getAttributeNames())if(h0.has(l)){let g=f.getAttribute(l);if(!o(g))q.push({type:"invalid_color",element:C,attr:l,value:g,reason:`Invalid color value '${g}' for attribute '${l}'`})}for(let l of f.children)if(a(l))J0(l)},F0=(f)=>{let C=f.tagName.toLowerCase();if(["svg","symbol","marker","pattern","view"].includes(C)){let n=f.getAttribute("viewBox");if(n){let G0=n.trim().split(/[\s,]+/);if(G0.length!==4)q.push({type:"malformed_viewbox",element:C,value:n,reason:`viewBox must have exactly 4 values (min-x, min-y, width, height), got ${G0.length}`});else{for(let E0=0;E0<G0.length;E0++)if(!/^[+-]?\d*\.?\d+([Ee][+-]?\d+)?$/.test(G0[E0])){q.push({type:"malformed_viewbox",element:C,value:n,reason:`viewBox contains invalid number '${G0[E0]}' at position ${E0+1}`});break}let L0=parseFloat(G0[2]),P0=parseFloat(G0[3]);if(isNaN(L0)||isNaN(P0)||L0<0||P0<0)q.push({type:"invalid_viewbox_dimensions",element:C,value:n,reason:`viewBox width and height must be valid non-negative numbers, got ${L0}x${P0}`})}}}let l=f.getAttribute("preserveAspectRatio");if(l){if(!/^(none|xMinYMin|xMidYMin|xMaxYMin|xMinYMid|xMidYMid|xMaxYMid|xMinYMax|xMidYMax|xMaxYMax)(\s+(meet|slice))?$/.test(l.trim()))q.push({type:"malformed_preserveaspectratio",element:C,value:l,reason:`Invalid preserveAspectRatio format '${l}'`})}if(["polygon","polyline"].includes(C)){let n=f.getAttribute("points");if(n){let G0=n.trim().split(/[\s,]+/);if(G0.length>0&&G0.length%2!==0)q.push({type:"malformed_points",element:C,value:n.slice(0,50)+(n.length>50?"...":""),reason:`points attribute must have even number of values (x,y pairs), got ${G0.length}`})}}let g=f.getAttribute("transform");if(g){if(!/^(\s{0,20}(matrix|translate|scale|rotate|skewX|skewY)\s{0,20}\([^)]*\)\s{0,20})+$/.test(g.trim())){if(!/^[\s\w(),.\-+]+$/.test(g))q.push({type:"malformed_transform",element:C,value:g.slice(0,50)+(g.length>50?"...":""),reason:"Potentially malformed transform attribute"})}}for(let n of f.children)if(a(n))F0(n)},O0=(f)=>{let C=f.tagName,l=C.toLowerCase();if(C.includes(":")||G6.has(C)||H8.has(l)){for(let n of Array.from(f.children))if(a(n))O0(n);return}let g=C6(C,G6);if(g){let n=f.ownerDocument.createElement(g);for(let G0 of f.getAttributeNames())n.setAttribute(G0,f.getAttribute(G0));while(f.firstChild)n.appendChild(f.firstChild);if(f.parentNode)f.parentNode.replaceChild(n,f);q.push({type:"element_typo_fixed",oldName:C,newName:g,reason:`Fixed element typo: <${C}> -> <${g}>`});for(let G0 of Array.from(n.children))if(a(G0))O0(G0)}else for(let n of Array.from(f.children))if(a(n))O0(n)},R0=(f)=>{for(let C of Array.from(f.getAttributeNames())){if(C.startsWith("xmlns")||C.startsWith("data-"))continue;if(C.startsWith("-webkit-")||C.startsWith("-moz-"))continue;if(C.includes(":")&&!C.startsWith("xlink:")&&!C.startsWith("xml:"))continue;if(F6.has(C)||z8.has(C.toLowerCase()))continue;let l=C6(C,F6);if(l){let g=f.getAttribute(C);f.removeAttribute(C),f.setAttribute(l,g),q.push({type:"attr_typo_fixed",element:f.tagName.toLowerCase(),oldAttr:C,newAttr:l,reason:`Fixed attribute typo: '${C}' -> '${l}'`})}}for(let C of f.children)if(a(C))R0(C)},I0=(f)=>{let C=new Map,l=new Set,g=(L0)=>{let P0=L0.getAttribute("id");if(P0)C.set(P0,(C.get(P0)||0)+1),l.add(P0);for(let E0 of L0.children)if(a(E0))g(E0)};g(f);let n=new Set,G0=(L0)=>{let P0=L0.getAttribute("id");if(P0)if(n.has(P0)){let E0=P0,U7=2;while(l.has(E0)||n.has(E0))E0=`${P0}_${U7++}`;L0.setAttribute("id",E0),l.add(E0),n.add(E0),q.push({type:"duplicate_id_renamed",oldId:P0,newId:E0,element:L0.tagName.toLowerCase(),reason:`Renamed duplicate ID: '${P0}' -> '${E0}'`})}else n.add(P0);for(let E0 of L0.children)if(a(E0))G0(E0)};G0(f)};if(_($),U(),V($),M($),w($),b($),S($),x($),O0($),R0($),I0($),c($),e($),s($),P($),$0($),U0($),J0($),F0($),$.setAttribute("data-fixes-applied",String(q.length)),z&&q.length>0)$.setAttribute("data-fix-report",JSON.stringify(q));return $}),C0={ERROR:"error",WARNING:"warning"},cz={broken_reference:C0.ERROR,broken_url_reference:C0.ERROR,duplicate_id:C0.ERROR,missing_required_attribute:C0.ERROR,invalid_child_element:C0.ERROR,animation_in_empty_element:C0.ERROR,malformed_viewbox:C0.ERROR,malformed_points:C0.ERROR,malformed_transform:C0.ERROR,invalid_enum_value:C0.ERROR,invalid_numeric_constraint:C0.ERROR,invalid_attr_on_element:C0.WARNING,missing_namespace:C0.WARNING,invalid_timing:C0.WARNING,uppercase_unit:C0.WARNING,invalid_whitespace:C0.WARNING,invalid_number:C0.WARNING,mistyped_element_detected:C0.WARNING,unknown_element_detected:C0.WARNING,mistyped_attribute_detected:C0.WARNING,unknown_attribute_detected:C0.WARNING,invalid_color:C0.WARNING,circular_reference:C0.WARNING,deep_nesting:C0.WARNING,empty_defs:C0.WARNING,gradient_stop_order:C0.WARNING,path_complexity:C0.WARNING,external_resource:C0.WARNING,script_content:C0.WARNING,event_handler:C0.WARNING,missing_title:C0.WARNING,missing_desc:C0.WARNING,invalid_aria:C0.WARNING,missing_lang:C0.WARNING},lz=new Set(["onabort","onactivate","onbegin","oncancel","oncanplay","oncanplaythrough","onchange","onclick","onclose","oncuechange","ondblclick","ondrag","ondragend","ondragenter","ondragleave","ondragover","ondragstart","ondrop","ondurationchange","onemptied","onend","onended","onerror","onfocus","onfocusin","onfocusout","oninput","oninvalid","onkeydown","onkeypress","onkeyup","onload","onloadeddata","onloadedmetadata","onloadstart","onmousedown","onmouseenter","onmouseleave","onmousemove","onmouseout","onmouseover","onmouseup","onmousewheel","onpause","onplay","onplaying","onprogress","onratechange","onrepeat","onreset","onresize","onscroll","onseeked","onseeking","onselect","onshow","onstalled","onsubmit","onsuspend","ontimeupdate","ontoggle","onunload","onvolumechange","onwaiting","onwheel"]),nz=new Set(["aria-activedescendant","aria-atomic","aria-autocomplete","aria-busy","aria-checked","aria-colcount","aria-colindex","aria-colspan","aria-controls","aria-current","aria-describedby","aria-details","aria-disabled","aria-dropeffect","aria-errormessage","aria-expanded","aria-flowto","aria-grabbed","aria-haspopup","aria-hidden","aria-invalid","aria-keyshortcuts","aria-label","aria-labelledby","aria-level","aria-live","aria-modal","aria-multiline","aria-multiselectable","aria-orientation","aria-owns","aria-placeholder","aria-posinset","aria-pressed","aria-readonly","aria-relevant","aria-required","aria-roledescription","aria-rowcount","aria-rowindex","aria-rowspan","aria-selected","aria-setsize","aria-sort","aria-valuemax","aria-valuemin","aria-valuenow","aria-valuetext"]),yK=new Set(["img","graphics-document","graphics-object","graphics-symbol","group","list","listitem","none","presentation","application"]);function sz($){let J={elements:new Map,lines:[]},Z=0;J.lines.push(0);for(let Y=0;Y<$.length;Y++)if($[Y]===`
351
- `)J.lines.push(Y+1);let K=[],Q=/<!\[CDATA\[([\s\S]*?)\]\]>/g,H;while((H=Q.exec($))!==null)K.push({start:H.index,end:H.index+H[0].length});let z=/<!--[\s\S]*?-->/g,q;while((q=z.exec($))!==null)K.push({start:q.index,end:q.index+q[0].length});let W=/<script[^>]*>([\s\S]*?)<\/script>/gi,j;while((j=W.exec($))!==null){let Y=j.index+j[0].indexOf(">")+1,X=j.index+j[0].lastIndexOf("<");if(X>Y)K.push({start:Y,end:X})}let G=/<style[^>]*>([\s\S]*?)<\/style>/gi,F;while((F=G.exec($))!==null){let Y=F.index+F[0].indexOf(">")+1,X=F.index+F[0].lastIndexOf("<");if(X>Y)K.push({start:Y,end:X})}K.sort((Y,X)=>Y.start-X.start);let _=(Y)=>{for(let X of K){if(Y>=X.start&&Y<X.end)return!0;if(X.start>Y)break}return!1},U=(Y)=>{let X=1;for(let I=0;I<J.lines.length;I++){if(J.lines[I]>Y){X=I;break}X=I+1}let w=J.lines[X-1]||0,R=Y-w+1;return{line:X,column:R}},O=/<([a-zA-Z][a-zA-Z0-9:_-]*)\s*([^>]*?)(\/?)\s*>/g,V=/([a-zA-Z][a-zA-Z0-9:_-]*)\s*=\s*["']([^"']*)["']/g,M;while((M=O.exec($))!==null){if(_(M.index))continue;let Y=M[1].toLowerCase(),X=M[2],w=M.index,R=M.index+M[0].length,{line:I,column:b}=U(w),u=X?M[0].indexOf(X):0,m=new Map;V.lastIndex=0;let S;while((S=V.exec(X))!==null){let x=S[1],h=S[2],E=w+u+S.index,d=U(E);m.set(x.toLowerCase(),{name:x,value:h,line:d.line,column:d.column})}if(!J.elements.has(Y))J.elements.set(Y,[]);J.elements.get(Y).push({line:I,column:b,endColumn:b+M[0].length-1,attrs:m})}return J.getElementPosition=(Y,X=0)=>{let w=J.elements.get(Y.toLowerCase());if(w&&w[X]){let R=w[X];return{line:R.line,column:R.column}}return{line:1,column:1}},J.getAttributePosition=(Y,X,w=0)=>{let R=J.elements.get(Y.toLowerCase());if(R&&R[w]){let I=R[w],b=I.attrs.get(X.toLowerCase());if(b)return{line:b.line,column:b.column};return{line:I.line,column:I.column}}return{line:1,column:1}},J}async function sK($,J={}){vz();let Z=J.errorsOnly===!0,K=J.outputFile||null,Q=(J.outputFormat||"json").toLowerCase(),H=J.includeSource===!0,z=["text","json","xml","yaml"];if(K&&!z.includes(Q))throw new Error(`Invalid outputFormat '${Q}'. Must be one of: ${z.join(", ")}`);let q="",W;try{if(W=A6($),W===S0.SVG_STRING)q=$;else if(W===S0.FILE_PATH){let D=await import("node:fs/promises"),i=(await Promise.resolve().then(() => (I6(),N6))).normalize($);try{q=await D.readFile(i,"utf8")}catch(v){throw new Error(`Failed to read file '${$}': ${v.message}`)}}else if(W===S0.URL)try{let D=await fetch($);if(!D.ok)throw new Error(`HTTP ${D.status}: ${D.statusText}`);q=await D.text()}catch(D){throw new Error(`Failed to fetch URL '${$}': ${D.message}`)}else if(W===S0.DOM_ELEMENT)if(typeof XMLSerializer!=="undefined")q=new XMLSerializer().serializeToString($);else if($.outerHTML)q=$.outerHTML;else throw new Error("Cannot serialize DOM element: XMLSerializer not available");else throw new Error(`Unknown input type: ${typeof $}`)}catch(D){return{issues:[{type:"input_error",severity:C0.ERROR,reason:D.message,line:0,column:0}],isValid:!1,hasErrors:!0,hasWarnings:!1,errorCount:1,warningCount:0,summary:{input_error:1}}}let j=H?q.split(`
352
- `):null,G=sz(q),F,_=[],U=(D)=>{let A=D.match(/line\s*:?\s*(\d+)/i)||D.match(/:(\d+):/);return A?parseInt(A[1],10):1},O=(D)=>{let A=D.match(/column\s*:?\s*(\d+)/i)||D.match(/:\d+:(\d+)/);return A?parseInt(A[1],10):1},V=(D)=>{let A=D,i=[],v="￾_VALID_ENTITY_￾",K0=/&(amp|lt|gt|quot|apos|#\d{1,7}|#x[\da-fA-F]{1,6});/g,V0=A.replace(K0,v+"$1;").replace(/&/g,"&amp;").replace(new RegExp(v,"g"),"&");if(V0!==A)A=V0,i.push("Escaped unencoded ampersands");let T0=A.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g,"");if(T0!==A)A=T0,i.push("Removed invalid control characters");if(A.charCodeAt(0)===65279)A=A.slice(1),i.push("Removed UTF-8 BOM");let u0=A.replace(/="([^"]*)<([^"]*)"(?!\s*>)/g,(j7,t0,s0)=>{if(!s0.includes(">"))return`="${t0}&lt;${s0}"`;return j7});if(u0!==A)A=u0,i.push("Escaped < in attribute values");return{fixed:A,appliedFixes:i}};try{F=await E6($,W)}catch(D){let A=D.message||String(D),i=U(A),v=O(A),{fixed:K0,appliedFixes:q0}=V(q);if(q0.length>0&&K0!==q)try{let{JSDOM:H0}=await import("jsdom");F=new H0(K0,{contentType:"image/svg+xml"}).window.document.documentElement,_.push({type:"parse_recovery",severity:C0.WARNING,reason:`Recovered from parse error. Applied fixes: ${q0.join("; ")}`,line:i,column:v}),_.push({type:"original_parse_error",severity:C0.ERROR,reason:`Original parse error: ${A}`,line:i,column:v})}catch(H0){return{issues:[{type:"parse_error",severity:C0.ERROR,reason:`Failed to parse SVG: ${A}`,line:i,column:v},{type:"recovery_failed",severity:C0.WARNING,reason:`Recovery attempted (${q0.join("; ")}) but still failed: ${H0.message}`,line:i,column:v}],isValid:!1,hasErrors:!0,hasWarnings:!0,errorCount:1,warningCount:1,summary:{parse_error:1,recovery_failed:1}}}else return{issues:[{type:"parse_error",severity:C0.ERROR,reason:`Failed to parse SVG: ${A}`,line:i,column:v}],isValid:!1,hasErrors:!0,hasWarnings:!1,errorCount:1,warningCount:0,summary:{parse_error:1}}}let M=[];if(_.length>0)M.push(..._);let Y=new Map,X=(D)=>{let A=D.toLowerCase(),i=Y.get(A)||0;return Y.set(A,i+1),i},w=()=>{Y.clear()},R=(D,A,i=null,v=null)=>{let K0;if(i)K0=G.getAttributePosition(A,i,v||0);else K0=G.getElementPosition(A,v||0);let q0=cz[D.type]||C0.WARNING,H0={...D,severity:q0,line:K0.line,column:K0.column};if(H&&j&&K0.line>0&&K0.line<=j.length)H0.sourceLine=j[K0.line-1];return H0},I=new Set,b=(D)=>{if(!D)return;let A=D.getAttribute("id");if(A)I.add(A);for(let i of D.children)if(a(i))b(i)};b(F);let u=["x","y","width","height","cx","cy","r","rx","ry","x1","y1","x2","y2","d","points"],m=(D)=>{let A=D.tagName.toLowerCase(),i=X(A);if(A==="g"){for(let v of u)if(D.hasAttribute(v))M.push(R({type:"invalid_attr_on_element",element:A,attr:v,value:D.getAttribute(v),reason:`SVG 1.1: <g> elements do not support '${v}' attribute`},A,v,i))}for(let v of D.children)if(a(v))m(v)},S=()=>{let D=!1,A=null,i=null,v=(K0)=>{for(let q0 of K0.getAttributeNames())if(q0.startsWith("xlink:")){D=!0,A=K0.tagName.toLowerCase(),i=q0;return}for(let q0 of K0.children){if(a(q0))v(q0);if(D)return}};if(v(F),D&&!F.hasAttribute("xmlns:xlink")){let K0=G.getAttributePosition(A,i,0);M.push({type:"missing_namespace",namespace:"xmlns:xlink",reason:"Document uses xlink:* attributes but missing xmlns:xlink namespace declaration",line:K0.line,column:K0.column})}},x=(D)=>{let A=D.tagName.toLowerCase(),i=X(A);for(let v of["xlink:href","href"]){let K0=D.getAttribute(v);if(K0&&K0.startsWith("#")){let q0=K0.slice(1);if(q0&&!I.has(q0))M.push(R({type:"broken_reference",element:A,attr:v,referencedId:q0,reason:`Reference to non-existent ID '${q0}'`},A,v,i))}}for(let v of D.children)if(a(v))x(v)},h=["begin","end","dur","repeatDur","min","max"],E=new Set(["animate","animateTransform","animateMotion","animateColor","set"]),d=(D)=>{let A=D.tagName.toLowerCase(),i=X(A);if(E.has(A))for(let v of h){let K0=D.getAttribute(v);if(K0){let q0=K0.trim();if(q0!==K0)M.push(R({type:"invalid_timing",element:A,attr:v,value:K0,reason:"Timing value has leading/trailing whitespace"},A,v,i));if(/[;,]/.test(q0)&&!/^[\d\w\s.;,+-]+$/.test(q0))M.push(R({type:"invalid_timing",element:A,attr:v,value:K0,reason:"Timing value may contain invalid characters"},A,v,i))}}for(let v of D.children)if(a(v))d(v)},c=new Set(["font-face-format","font-face-name","glyphref","hkern","vkern"]),p=(D)=>{let A=D.tagName.toLowerCase(),i=X(A);if(c.has(A)){for(let v of D.children)if(a(v)){let K0=v.tagName.toLowerCase();if(E.has(K0))M.push(R({type:"animation_in_empty_element",element:A,child:K0,reason:`Animation element <${K0}> inside <${A}> which has EMPTY content model per SVG 1.1 DTD`},A,null,i))}}for(let v of D.children)if(a(v))p(v)},N=/(\d+\.?\d*)(PX|EM|EX|PT|PC|CM|MM|IN|%)/gi,y=["width","height","x","y","x1","y1","x2","y2","cx","cy","r","rx","ry","stroke-width","font-size","letter-spacing","word-spacing","stroke-dashoffset"],B=(D)=>{let A=D.tagName.toLowerCase(),i=X(A);for(let v of y){let K0=D.getAttribute(v);if(K0){let q0=K0.match(N);if(q0)for(let H0 of q0){let V0=H0.replace(/[\d.]+/,"");if(V0!==V0.toLowerCase())M.push(R({type:"uppercase_unit",element:A,attr:v,value:K0,reason:`Unit '${V0}' should be lowercase '${V0.toLowerCase()}'`},A,v,i))}}}for(let v of D.children)if(a(v))B(v)},e=["points","viewBox","d","values","keyTimes","keySplines","rotate"],r=(D)=>{let A=D.tagName.toLowerCase(),i=X(A);for(let v of e){let K0=D.getAttribute(v);if(K0){if(/[\t\n\r]/.test(K0)||/ +/.test(K0))M.push(R({type:"invalid_whitespace",element:A,attr:v,reason:"List attribute contains tabs, newlines, or multiple consecutive spaces"},A,v,i))}}for(let v of D.children)if(a(v))r(v)},s=["width","height","x","y","x1","y1","x2","y2","cx","cy","r","rx","ry","stroke-width","stroke-miterlimit","stroke-dashoffset","opacity","fill-opacity","stroke-opacity","font-size"],z0=(D)=>{let A=D.tagName.toLowerCase(),i=X(A);for(let v of s){let K0=D.getAttribute(v);if(K0){let q0=K0.trim();if(/^0\d/.test(q0.replace(/[a-z%]+$/i,"")))M.push(R({type:"invalid_number",element:A,attr:v,value:K0,reason:"Number has unnecessary leading zeros"},A,v,i));if(/\.$/.test(q0.replace(/[a-z%]+$/i,"")))M.push(R({type:"invalid_number",element:A,attr:v,value:K0,reason:"Number has trailing decimal point"},A,v,i))}}for(let v of D.children)if(a(v))z0(v)},T=(D,A=!1)=>{let i=D.tagName,v=i.toLowerCase(),K0=X(v),q0=i.includes(":"),H0=A||TK.has(v)||q0;if(!H0){if(!G6.has(i)&&!H8.has(v)){if(!bz(v)){let V0=C6(i,G6);if(V0)M.push(R({type:"mistyped_element_detected",element:i,suggestion:V0,reason:`Unknown element <${i}> - did you mean <${V0}>?`},v,null,K0));else M.push(R({type:"unknown_element_detected",element:i,reason:`Unknown element <${i}> - not in SVG 1.1 spec`},v,null,K0))}}}for(let V0 of D.children)if(a(V0))T(V0,H0)},P=(D,A=!1)=>{let i=D.tagName.toLowerCase(),v=X(i),K0=D.tagName.includes(":"),q0=A||TK.has(i)||K0;if(!q0)for(let H0 of D.getAttributeNames()){if(H0.startsWith("data-")||H0.startsWith("aria-"))continue;if(H0==="xmlns"||H0.startsWith("xmlns:"))continue;if(H0.includes(":")&&!H0.startsWith("xlink:")&&!H0.startsWith("xml:"))continue;if(fz(H0))continue;if(!F6.has(H0)&&!z8.has(H0.toLowerCase())){let V0=C6(H0,F6);if(V0)M.push(R({type:"mistyped_attribute_detected",element:i,attr:H0,suggestion:V0,reason:`Unknown attribute '${H0}' - did you mean '${V0}'?`},i,H0,v));else M.push(R({type:"unknown_attribute_detected",element:i,attr:H0,reason:`Unknown attribute '${H0}' on <${i}> - not in SVG 1.1 spec`},i,H0,v))}}for(let H0 of D.children)if(a(H0))P(H0,q0)},t={use:["xlink:href","href"],image:["xlink:href","href"],feImage:["xlink:href","href"],textPath:["xlink:href","href"],mpath:["xlink:href","href"],animate:["attributeName"],animateTransform:["attributeName","type"],animateMotion:[],animateColor:["attributeName"],set:["attributeName"],feBlend:["in2"],feComposite:["in2"],feDisplacementMap:["in2","scale"],feMorphology:["operator"],feTurbulence:["type"],feConvolveMatrix:["kernelMatrix"],feFuncR:["type"],feFuncG:["type"],feFuncB:["type"],feFuncA:["type"],linearGradient:[],radialGradient:[],stop:["offset"]},$0=(D)=>{let A=D.tagName.toLowerCase(),i=X(A),v=t[A];if(v&&v.length>0){if(v.includes("xlink:href")&&v.includes("href")){if(!D.hasAttribute("xlink:href")&&!D.hasAttribute("href"))M.push(R({type:"missing_required_attribute",element:A,attrs:["href","xlink:href"],reason:`<${A}> requires 'href' or 'xlink:href' attribute`},A,null,i))}else for(let K0 of v)if(!D.hasAttribute(K0))M.push(R({type:"missing_required_attribute",element:A,attr:K0,reason:`<${A}> requires '${K0}' attribute per SVG 1.1 DTD`},A,K0,i))}for(let K0 of D.children)if(a(K0))$0(K0)},Q0={linearGradient:new Set(["stop","animate","animateTransform","set"]),radialGradient:new Set(["stop","animate","animateTransform","set"]),stop:new Set(["animate","set"]),clipPath:new Set(["path","text","rect","circle","ellipse","line","polyline","polygon","use","animate","animateTransform","set","desc","title"]),mask:new Set(["path","text","rect","circle","ellipse","line","polyline","polygon","use","g","defs","image","switch","a","animate","animateTransform","set","desc","title"])},U0=(D)=>{let A=D.tagName.toLowerCase(),i=X(A),v=Q0[A];if(v){for(let K0 of D.children)if(a(K0)){let q0=K0.tagName.toLowerCase();if(!q0.includes(":")&&!v.has(q0))M.push(R({type:"invalid_child_element",element:A,child:q0,reason:`<${q0}> is not a valid child of <${A}> per SVG 1.1 DTD`},A,null,i))}}for(let K0 of D.children)if(a(K0))U0(K0)},N0={spreadMethod:new Set(["pad","reflect","repeat"]),gradientUnits:new Set(["userSpaceOnUse","objectBoundingBox"]),clipPathUnits:new Set(["userSpaceOnUse","objectBoundingBox"]),maskUnits:new Set(["userSpaceOnUse","objectBoundingBox"]),maskContentUnits:new Set(["userSpaceOnUse","objectBoundingBox"]),filterUnits:new Set(["userSpaceOnUse","objectBoundingBox"]),primitiveUnits:new Set(["userSpaceOnUse","objectBoundingBox"]),patternUnits:new Set(["userSpaceOnUse","objectBoundingBox"]),patternContentUnits:new Set(["userSpaceOnUse","objectBoundingBox"]),markerUnits:new Set(["strokeWidth","userSpaceOnUse"]),"fill-rule":new Set(["nonzero","evenodd","inherit"]),"clip-rule":new Set(["nonzero","evenodd","inherit"]),"stroke-linecap":new Set(["butt","round","square","inherit"]),"stroke-linejoin":new Set(["miter","round","bevel","inherit"]),"text-anchor":new Set(["start","middle","end","inherit"]),"dominant-baseline":new Set(["auto","use-script","no-change","reset-size","ideographic","alphabetic","hanging","mathematical","central","middle","text-after-edge","text-before-edge","inherit"]),"alignment-baseline":new Set(["auto","baseline","before-edge","text-before-edge","middle","central","after-edge","text-after-edge","ideographic","alphabetic","hanging","mathematical","inherit"]),visibility:new Set(["visible","hidden","collapse","inherit"]),display:new Set(["inline","block","list-item","run-in","compact","marker","table","inline-table","table-row-group","table-header-group","table-footer-group","table-row","table-column-group","table-column","table-cell","table-caption","none","inherit"]),overflow:new Set(["visible","hidden","scroll","auto","inherit"])},h0=(D)=>{let A=D.tagName.toLowerCase(),i=X(A);for(let[v,K0]of Object.entries(N0)){let q0=D.getAttribute(v);if(q0&&!K0.has(q0))M.push(R({type:"invalid_enum_value",element:A,attr:v,value:q0,validValues:[...K0],reason:`Invalid value '${q0}' for '${v}'. Valid values: ${[...K0].join(", ")}`},A,v,i))}for(let v of D.children)if(a(v))h0(v)},o={opacity:{min:0,max:1,type:"number"},"fill-opacity":{min:0,max:1,type:"number"},"stroke-opacity":{min:0,max:1,type:"number"},"stop-opacity":{min:0,max:1,type:"number"},"flood-opacity":{min:0,max:1,type:"number"},"stroke-width":{min:0,type:"length"},"stroke-miterlimit":{min:1,type:"number"},r:{min:0,type:"length"},rx:{min:0,type:"length"},ry:{min:0,type:"length"}},J0=(D)=>{let A=D.tagName.toLowerCase(),i=X(A);for(let[v,K0]of Object.entries(o)){let q0=D.getAttribute(v);if(q0){let H0=parseFloat(q0);if(!isNaN(H0)){if(K0.min!==void 0&&H0<K0.min)M.push(R({type:"invalid_numeric_constraint",element:A,attr:v,value:q0,reason:`Value ${H0} is below minimum ${K0.min}`},A,v,i));if(K0.max!==void 0&&H0>K0.max)M.push(R({type:"invalid_numeric_constraint",element:A,attr:v,value:q0,reason:`Value ${H0} is above maximum ${K0.max}`},A,v,i))}}}for(let v of D.children)if(a(v))J0(v)},F0=(D)=>{let A=new Map,i=new Map,v=(K0)=>{let q0=K0.tagName.toLowerCase(),H0=X(q0),V0=K0.getAttribute("id");if(V0){if(!A.has(V0))A.set(V0,[]),i.set(V0,{tagName:q0,occIdx:H0});A.get(V0).push(q0)}for(let T0 of K0.children)if(a(T0))v(T0)};v(D);for(let[K0,q0]of A)if(q0.length>1){let H0=i.get(K0);M.push(R({type:"duplicate_id",id:K0,elements:q0,count:q0.length,reason:`ID '${K0}' is used ${q0.length} times (on ${q0.join(", ")})`},H0.tagName,"id",H0.occIdx))}},O0=/url\(#([^)]+)\)/g,R0=["fill","stroke","clip-path","mask","filter","color-profile","marker","marker-start","marker-mid","marker-end"],I0=(D)=>{let A=D.tagName.toLowerCase(),i=X(A);for(let v of R0){let K0=D.getAttribute(v);if(K0){let q0;O0.lastIndex=0;while((q0=O0.exec(K0))!==null){let H0=q0[1];if(!I.has(H0))M.push(R({type:"broken_url_reference",element:A,attr:v,referencedId:H0,reason:`url(#${H0}) references non-existent ID`},A,v,i))}}}for(let v of D.children)if(a(v))I0(v)},f=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen","currentcolor","inherit","none","transparent"]),C=["fill","stroke","color","stop-color","flood-color","lighting-color","solid-color"],l=(D)=>{let A=D.toLowerCase().trim();if(f.has(A))return!0;if(/^#[0-9a-f]{3}$/i.test(A))return!0;if(/^#[0-9a-f]{4}$/i.test(A))return!0;if(/^#[0-9a-f]{6}$/i.test(A))return!0;if(/^#[0-9a-f]{8}$/i.test(A))return!0;if(/^rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*(,\s*[\d.]+\s*)?\)$/i.test(A))return!0;if(/^rgba?\(\s*\d+%\s*,\s*\d+%\s*,\s*\d+%\s*(,\s*[\d.]+%?\s*)?\)$/i.test(A))return!0;if(/^hsla?\(\s*\d+\s*,\s*\d+%\s*,\s*\d+%\s*(,\s*[\d.]+\s*)?\)$/i.test(A))return!0;if(/^url\(#[^)]+\)$/i.test(A))return!0;return!1},g=(D)=>{let A=D.tagName.toLowerCase(),i=X(A);for(let v of C){let K0=D.getAttribute(v);if(K0&&!l(K0))M.push(R({type:"invalid_color",element:A,attr:v,value:K0,reason:`Invalid color value '${K0}'`},A,v,i))}for(let v of D.children)if(a(v))g(v)},n=(D)=>{let A=D.tagName.toLowerCase(),i=X(A),v=D.getAttribute("viewBox");if(v){let H0=v.trim().split(/[\s,]+/);if(H0.length!==4||!H0.every((V0)=>!isNaN(parseFloat(V0))))M.push(R({type:"malformed_viewbox",element:A,value:v,reason:"viewBox must be exactly 4 numbers (min-x, min-y, width, height)"},A,"viewBox",i))}let K0=D.getAttribute("points");if(K0){let H0=K0.trim().split(/[\s,]+/).filter((V0)=>V0);if(H0.length%2!==0||!H0.every((V0)=>!isNaN(parseFloat(V0))))M.push(R({type:"malformed_points",element:A,value:K0.length>50?K0.substring(0,50)+"...":K0,reason:"points must be pairs of numbers"},A,"points",i))}let q0=D.getAttribute("transform");if(q0){let H0=/^\s{0,20}(matrix|translate|scale|rotate|skewX|skewY)\s{0,20}\([^)]*\)\s{0,20},?\s{0,20}/,V0=q0.trim();while(V0.length>0){let T0=V0.match(H0);if(T0&&T0[0].length>0)V0=V0.substring(T0[0].length);else if(!T0){M.push(R({type:"malformed_transform",element:A,value:q0.length>50?q0.substring(0,50)+"...":q0,reason:`Invalid transform syntax near '${V0.substring(0,20)}'`},A,"transform",i));break}else V0=V0.substring(1)}}if(A==="path"){let H0=D.getAttribute("d");if(H0){let V0=H0.trim();if(V0.length>0){if(!/^[Mm]/.test(V0))M.push(R({type:"malformed_path_data",element:"path",value:H0.length>50?H0.substring(0,50)+"...":H0,reason:"Path data must start with M or m command"},"path","d",i));let T0=V0.replace(/[MmZzLlHhVvCcSsQqTtAa\d\s,.\-+eE]/g,"");if(T0.length>0)M.push(R({type:"malformed_path_data",element:"path",value:H0.length>50?H0.substring(0,50)+"...":H0,reason:`Path data contains invalid characters: '${T0.substring(0,10)}'`},"path","d",i))}}}for(let H0 of D.children)if(a(H0))n(H0)},G0=()=>{let D=new Map,A=(H0)=>{let V0=H0.getAttribute("id");if(V0)D.set(V0,H0);for(let T0 of H0.children)if(a(T0))A(T0)};A(F);let i=["href","xlink:href","mask","clip-path","filter","fill","stroke"],v=(H0)=>{if(!H0)return null;let V0=H0.match(/url\(#([^)]+)\)/);if(V0)return V0[1];let T0=H0.match(/^#(.+)$/);if(T0)return T0[1];return null},K0=(H0,V0=new Set)=>{if(V0.has(H0))return!0;let T0=D.get(H0);if(!T0)return!1;V0.add(H0);let u0=(t0)=>{for(let s0 of i){let NJ=v(t0.getAttribute(s0));if(NJ&&K0(NJ,V0))return!0}for(let s0 of t0.children)if(a(s0)&&u0(s0))return!0;return!1},j7=u0(T0);return V0.delete(H0),j7},q0=["clipPath","mask","filter","symbol","pattern","marker"];for(let[H0,V0]of D){let T0=V0.tagName.toLowerCase();if(q0.includes(T0)){if(K0(H0)){w();let u0=X(T0);M.push(R({type:"circular_reference",element:T0,attr:"id",value:H0,reason:`Circular reference detected: '${H0}' directly or indirectly references itself`},T0,"id",u0))}}}},L0=50,P0=(D,A=0)=>{if(A>L0){let i=D.tagName.toLowerCase(),v=X(i);M.push(R({type:"deep_nesting",element:i,value:String(A),reason:`Element nesting depth (${A}) exceeds ${L0} levels`},i,null,v));return}for(let i of D.children)if(a(i))P0(i,A+1)},E0=(D)=>{let A=D.tagName.toLowerCase();if(A==="defs"){let i=!1;for(let v of D.childNodes)if(a(v)){i=!0;break}if(!i){let v=X(A);M.push(R({type:"empty_defs",element:A,reason:"Empty <defs> element (can be removed)"},A,null,v))}}for(let i of D.children)if(a(i))E0(i)},U7=(D)=>{let A=D.tagName.toLowerCase();if(A==="lineargradient"||A==="radialgradient"){let i=Array.from(D.children).filter((v)=>a(v)&&v.tagName.toLowerCase()==="stop");if(i.length>=2){let v=-1;for(let K0 of i){let q0=K0.getAttribute("offset")||"0",H0=parseFloat(q0);if(q0.includes("%"))H0=H0/100;if(!isNaN(H0)&&H0<v){let V0=X(A);M.push(R({type:"gradient_stop_order",element:A,reason:`Gradient stops not in ascending offset order (${v} followed by ${H0})`},A,null,V0));break}if(!isNaN(H0))v=H0}}}for(let i of D.children)if(a(i))U7(i)},b6=1e4,b7=(D)=>{let A=D.tagName.toLowerCase();if(A==="path"){let i=D.getAttribute("d");if(i){let v=i.match(/[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/g);if(v&&v.length>b6){let K0=X(A);M.push(R({type:"path_complexity",element:A,attr:"d",value:`${v.length} coordinates`,reason:`Path has ${v.length} coordinates (>${b6}), may cause slow rendering`},A,"d",K0))}}}for(let i of D.children)if(a(i))b7(i)},_6=(D)=>{let A=D.tagName.toLowerCase(),i=X(A),v=["href","xlink:href"];for(let K0 of v){let q0=D.getAttribute(K0);if(q0&&(q0.startsWith("http://")||q0.startsWith("https://")||q0.startsWith("//")))M.push(R({type:"external_resource",element:A,attr:K0,value:q0.length>60?q0.substring(0,60)+"...":q0,reason:"External resource reference detected (potential security/CORS issue)"},A,K0,i))}if(A==="style"&&D.textContent){let K0=D.textContent.match(/@import\s+url\s*\(\s*['"]?(https?:\/\/[^'")\s]+)/i);if(K0)M.push(R({type:"external_resource",element:A,value:K0[1],reason:"External CSS import detected in style element"},A,null,i))}for(let K0 of D.children)if(a(K0))_6(K0)},wJ=(D)=>{let A=D.tagName.toLowerCase();if(A==="script"){let i=X(A);M.push(R({type:"script_content",element:A,reason:"Script element detected (potential security issue in untrusted SVGs)"},A,null,i))}for(let i of D.children)if(a(i))wJ(i)},RJ=(D)=>{let A=D.tagName.toLowerCase(),i=X(A);for(let v of D.getAttributeNames())if(lz.has(v.toLowerCase()))M.push(R({type:"event_handler",element:A,attr:v,reason:`Event handler attribute '${v}' detected (potential XSS vector)`},A,v,i));for(let v of D.children)if(a(v))RJ(v)},tK=()=>{let D=!1,A=!1,i=!1,v=F.hasAttribute("lang")||F.hasAttribute("xml:lang"),K0=(T0)=>{for(let u0 of T0.children){if(!a(u0))continue;let j7=u0.tagName.toLowerCase();if(j7==="title")D=!0;if(j7==="desc")A=!0;if(j7==="text"||j7==="tspan"||j7==="textpath")i=!0;K0(u0)}};if(K0(F),!D)M.push(R({type:"missing_title",element:"svg",reason:"Missing <title> element (recommended for accessibility)"},"svg",null,0));let q0=0,H0=(T0)=>{q0++;for(let u0 of T0.children)if(a(u0))H0(u0)};if(H0(F),!A&&q0>10)M.push(R({type:"missing_desc",element:"svg",reason:`Missing <desc> element (recommended for complex SVGs with ${q0} elements)`},"svg",null,0));if(i&&!v)M.push(R({type:"missing_lang",element:"svg",reason:"Missing lang attribute on SVG with text content"},"svg",null,0));let V0=(T0)=>{let u0=T0.tagName.toLowerCase(),j7=X(u0);for(let t0 of T0.getAttributeNames()){if(t0.startsWith("aria-")&&!nz.has(t0.toLowerCase()))M.push(R({type:"invalid_aria",element:u0,attr:t0,reason:`Unknown ARIA attribute '${t0}'`},u0,t0,j7));if(t0==="role"){let s0=T0.getAttribute("role");if(s0&&!yK.has(s0.toLowerCase()))M.push(R({type:"invalid_aria",element:u0,attr:"role",value:s0,reason:`Invalid role value '${s0}' (valid: ${Array.from(yK).slice(0,5).join(", ")}...)`},u0,"role",j7))}if(t0==="aria-hidden"){let s0=T0.getAttribute("aria-hidden");if(s0&&s0!=="true"&&s0!=="false")M.push(R({type:"invalid_aria",element:u0,attr:"aria-hidden",value:s0,reason:`aria-hidden must be 'true' or 'false', got '${s0}'`},u0,"aria-hidden",j7))}}for(let t0 of T0.children)if(a(t0))V0(t0)};w(),V0(F)};w(),m(F),S(),w(),x(F),w(),d(F),w(),p(F),w(),B(F),w(),r(F),w(),z0(F),w(),T(F),w(),P(F),w(),$0(F),w(),U0(F),w(),h0(F),w(),J0(F),w(),F0(F),w(),I0(F),w(),g(F),w(),n(F),w(),G0(),w(),P0(F),w(),E0(F),w(),U7(F),w(),b7(F),w(),_6(F),w(),wJ(F),w(),RJ(F),tK(),M.sort((D,A)=>{if(D.line!==A.line)return D.line-A.line;return D.column-A.column});let H$=M;if(Z)H$=M.filter((D)=>D.severity===C0.ERROR);let z9=M.filter((D)=>D.severity===C0.ERROR).length,BJ=M.filter((D)=>D.severity===C0.WARNING).length,q9={};for(let D of H$)q9[D.type]=(q9[D.type]||0)+1;let J6={issues:H$,isValid:z9===0,hasErrors:z9>0,hasWarnings:BJ>0,errorCount:z9,warningCount:BJ,issueCount:H$.length,summary:q9};if(K)try{let D=await import("node:fs/promises"),A=await Promise.resolve().then(() => (I6(),N6)),i;switch(Q){case"json":i=JSON.stringify(J6,null,2);break;case"yaml":i=iz(J6);break;case"xml":i=rz(J6);break;case"text":default:i=oz(J6);break}let v=A.normalize(K);await D.writeFile(v,i,"utf8"),J6.outputFile=v}catch(D){J6.exportError=`Failed to write report to '${K}': ${D.message}`}return J6}function oz($){let J=["=".repeat(60),"SVG VALIDATION REPORT","=".repeat(60),"",`Status: ${$.isValid?"VALID":"INVALID"}`,`Errors: ${$.errorCount}`,`Warnings: ${$.warningCount}`,`Total Issues: ${$.issueCount}`,""];if($.issues.length>0){J.push("-".repeat(60)),J.push("ISSUES:"),J.push("-".repeat(60)),J.push("");for(let Z of $.issues){let K=Z.severity.toUpperCase(),Q=`${Z.line}:${Z.column}`;if(J.push(`[${K}] Line ${Q}: ${Z.type}`),Z.element)J.push(` Element: <${Z.element}>`);if(Z.attr)J.push(` Attribute: ${Z.attr}`);if(Z.value)J.push(` Value: ${Z.value}`);if(J.push(` ${Z.reason}`),Z.sourceLine)J.push(` Source: ${Z.sourceLine.trim()}`);J.push("")}}J.push("=".repeat(60)),J.push("SUMMARY BY TYPE:"),J.push("-".repeat(60));for(let[Z,K]of Object.entries($.summary))J.push(` ${Z}: ${K}`);return J.push("=".repeat(60)),J.join(`
353
- `)}function iz($){let J=["validation_result:",` is_valid: ${$.isValid}`,` has_errors: ${$.hasErrors}`,` has_warnings: ${$.hasWarnings}`,` error_count: ${$.errorCount}`,` warning_count: ${$.warningCount}`,` issue_count: ${$.issueCount}`,""," summary:"];for(let[K,Q]of Object.entries($.summary))J.push(` ${K}: ${Q}`);J.push(""),J.push(" issues:");let Z=(K)=>String(K).replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t");for(let K of $.issues){if(J.push(` - type: ${K.type}`),J.push(` severity: ${K.severity}`),J.push(` line: ${K.line}`),J.push(` column: ${K.column}`),K.element)J.push(` element: "${Z(K.element)}"`);if(K.attr)J.push(` attr: "${Z(K.attr)}"`);if(K.value)J.push(` value: "${Z(K.value)}"`);if(J.push(` reason: "${Z(K.reason)}"`),K.sourceLine)J.push(` source_line: "${Z(K.sourceLine)}"`)}return J.join(`
354
- `)}function rz($){let J=(K)=>String(K).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;"),Z=['<?xml version="1.0" encoding="UTF-8"?>',"<validation_result>",` <is_valid>${$.isValid}</is_valid>`,` <has_errors>${$.hasErrors}</has_errors>`,` <has_warnings>${$.hasWarnings}</has_warnings>`,` <error_count>${$.errorCount}</error_count>`,` <warning_count>${$.warningCount}</warning_count>`,` <issue_count>${$.issueCount}</issue_count>`," <summary>"];for(let[K,Q]of Object.entries($.summary))Z.push(` <${K}>${Q}</${K}>`);Z.push(" </summary>"),Z.push(" <issues>");for(let K of $.issues){if(Z.push(" <issue>"),Z.push(` <type>${J(K.type)}</type>`),Z.push(` <severity>${J(K.severity)}</severity>`),Z.push(` <line>${K.line}</line>`),Z.push(` <column>${K.column}</column>`),K.element)Z.push(` <element>${J(K.element)}</element>`);if(K.attr)Z.push(` <attr>${J(K.attr)}</attr>`);if(K.value)Z.push(` <value>${J(K.value)}</value>`);if(Z.push(` <reason>${J(K.reason)}</reason>`),K.sourceLine)Z.push(` <source_line>${J(K.sourceLine)}</source_line>`);Z.push(" </issue>")}return Z.push(" </issues>"),Z.push("</validation_result>"),Z.join(`
355
- `)}function oK($){let J=1;for(let Z of $.children)if(a(Z))J+=oK(Z);return J}var _J=j0(async($,J={})=>{let Z=B7($,{minify:J.minify!==!1}),K=await R6(Z,{precision:J.precision||6,curveSegments:J.curveSegments||20,resolveUse:!0,resolveMarkers:!0,resolvePatterns:!0,resolveMasks:!0,resolveClipPaths:!0,flattenTransforms:!0,bakeGradients:!0,removeUnusedDefs:!0,...J});return d0(K.svg)}),UJ=j0(($,J={})=>{let Z=$.getElementsByTagName("path");for(let K of Z){let Q=K.getAttribute("d");if(!Q)continue;try{let H=y6(Q),z=B9(H,J.precision||6);K.setAttribute("d",z)}catch(H){console.warn(`Failed to simplify path: ${H.message}`,{pathData:Q.substring(0,100)})}}return $}),VJ=j0(($,J={})=>{return RK($,{precision:J.precision??3,removeLinearSplines:J.removeLinearSplines!==!1,optimizeValues:J.optimizeValues!==!1}),$}),MJ=j0(($,J={})=>{return BK($,{floatPrecision:J.floatPrecision??J.precision??3,straightCurves:J.straightCurves!==!1,lineShorthands:J.lineShorthands!==!1,convertToZ:J.convertToZ!==!1,utilizeAbsolute:J.utilizeAbsolute!==!1,straightTolerance:J.straightTolerance??0.5}),$}),OJ=j0(($,J={})=>{let Z=J.tolerance??1,K=J.algorithm??"douglas-peucker",Q=J.respectStroke!==!1,H=i7($),z=(q)=>{if(q.tagName?.toLowerCase()==="path"){let j=q.getAttribute("d");if(j){let G=Z;if(Q){let U=m6(q),O=x6(q,U,H);if(O.hasStroke&&O.strokeWidth.greaterThan(0)){let V=O.strokeWidth.div(4).toNumber();G=Math.min(Z,V)}}let F=l0(j),_=$8(F,G,K);if(_.simplified){let U=n0(_.commands,J.precision??3);q.setAttribute("d",U)}}}for(let j of q.children||[])z(j)};return z($),$}),YJ=j0(($,J={})=>{let Z=(K)=>{let Q=K.getAttribute("transform");if(Q){let H=$7(Q),z=pJ(H);K.setAttribute("data-decomposed",JSON.stringify({translateX:z.translateX.toNumber(),translateY:z.translateY.toNumber(),rotation:z.rotation.toNumber(),scaleX:z.scaleX.toNumber(),scaleY:z.scaleY.toNumber(),skewX:z.skewX.toNumber()}))}for(let H of K.children)if(a(H))Z(H)};return Z($),$});function r$($,J){let Z=$.tagName.toLowerCase();try{if(Z==="path"){let K=$.getAttribute("d");if(!K)return null;let Q=y6(K),H=[],z=0,q=0;for(let W of Q)if(W.command==="M"||W.command==="L")z=W.args[0].toNumber(),q=W.args[1].toNumber(),H.push({x:z,y:q});return H}if(Z==="rect"){let K=$.getAttribute("x")||"0",Q=$.getAttribute("y")||"0",H=$.getAttribute("width")||"0",z=$.getAttribute("height")||"0";if(m7(K)||m7(Q)||m7(H)||m7(z))return null;let q=parseFloat(K),W=parseFloat(Q),j=parseFloat(H),G=parseFloat(z);if(isNaN(q)||isNaN(W)||isNaN(j)||isNaN(G))return null;return[{x:q,y:W},{x:q+j,y:W},{x:q+j,y:W+G},{x:q,y:W+G}]}if(Z==="circle"){let K=parseFloat($.getAttribute("cx")||"0"),Q=parseFloat($.getAttribute("cy")||"0"),H=parseFloat($.getAttribute("r")||"0");if(isNaN(K)||isNaN(Q)||isNaN(H))return null;let z=[];for(let q=0;q<J;q++){let W=q/J*2*Math.PI;z.push({x:K+H*Math.cos(W),y:Q+H*Math.sin(W)})}return z}return null}catch(K){return console.warn(`getShapePolygon failed for ${Z}:`,K.message),null}}var az={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".webp":"image/webp",".avif":"image/avif",".ico":"image/x-icon",".bmp":"image/bmp",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject",".wav":"audio/wav",".mp3":"audio/mpeg",".ogg":"audio/ogg",".m4a":"audio/mp4",".aac":"audio/aac",".flac":"audio/flac",".webm":"audio/webm",".mp4":"video/mp4",".ogv":"video/ogg",".mov":"video/quicktime",".css":"text/css",".js":"text/javascript"};function XJ(){return typeof process!=="undefined"&&process.versions?.node}function uK($){if(!$||typeof $!=="string")return!1;if($.startsWith("#"))return!1;if($.startsWith("data:"))return!1;return!0}function tz($){let J=$.indexOf("#");if(J===-1)return{path:$,fragment:null};return{path:$.substring(0,J),fragment:$.substring(J+1)}}function a$($){let J=($.match(/\.[a-z0-9]+$/i)||[""])[0].toLowerCase();return az[J]||"application/octet-stream"}function g7($,J){if(!$)return $;if($.match(/^https?:\/\//i))return $;if($.startsWith("data:"))return $;if($.startsWith("file://"))return $;if(!J)return $;if(J.match(/^https?:\/\//i))try{return new URL($,J).href}catch(K){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${K.message}`);return $}if(XJ())try{let K=(I6(),AJ(N6)),Q=J.endsWith("/")?J:K.dirname(J),H=K.resolve(Q,$),z=K.resolve(Q);if(!H.startsWith(z+K.sep)&&H!==z)return console.warn(`Path traversal blocked: ${$} escapes base directory`),$;return H}catch(K){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${K.message}`);let Q=J.endsWith("/")?J:J.substring(0,J.lastIndexOf("/")+1);if($.includes("..")||$.startsWith("/"))return console.warn(`Unsafe path pattern blocked in fallback: ${$}`),$;return Q+$}let Z=J.endsWith("/")?J:J.substring(0,J.lastIndexOf("/")+1);if($.includes("..")||$.startsWith("/"))return console.warn(`Unsafe path pattern blocked: ${$}`),$;return Z+$}async function x7($,J="text",Z=30000){if(XJ()&&!$.match(/^https?:\/\//i)){let H=await import("node:fs/promises");return{content:J==="binary"?await H.readFile($):await H.readFile($,"utf8"),contentType:a$($)}}let K=new AbortController,Q=setTimeout(()=>K.abort(),Z);try{let H=await fetch($,{signal:K.signal});if(!H.ok)throw new Error(`HTTP ${H.status}: ${H.statusText}`);let z=H.headers.get("content-type")||a$($);return{content:J==="binary"?await H.arrayBuffer():await H.text(),contentType:z}}finally{clearTimeout(Q)}}function a6($,J){let Z;if(XJ())Z=Buffer.from($).toString("base64");else{let K=new Uint8Array($),Q="";for(let H=0;H<K.length;H++)Q+=String.fromCharCode(K[H]);Z=btoa(Q)}return`data:${J};base64,${Z}`}function Q8($){let J=[],Z=[],K=/@import\s+(?:url\(\s*["']?([^"')]+)["']?\s*\)|["']([^"']+)["'])/gi,Q,H=0;while((Q=K.exec($))!==null){if(Q.index===H&&Q[0].length===0){console.error("Regex matched empty string in @import, breaking to prevent infinite loop");break}H=Q.index+Math.max(1,Q[0].length),J.push({url:Q[1]||Q[2],fullMatch:Q[0],index:Q.index})}let z=/url\(\s*["']?([^"')]+)["']?\s*\)/gi,q=0;while((Q=z.exec($))!==null){if(Q.index===q&&Q[0].length===0){console.error("Regex matched empty string in url(), breaking to prevent infinite loop");break}if(q=Q.index+Math.max(1,Q[0].length),$.substring(Math.max(0,Q.index-10),Q.index).includes("@import"))continue;if(Q[1].startsWith("#"))continue;if(Q[1].startsWith("data:"))continue;Z.push({url:Q[1],fullMatch:Q[0],index:Q.index})}return{imports:J,urls:Z}}function q8($,J,Z=new Map){if(!$)return Z;let K=$.getAttribute?.("id");if(K){let z=J+K;Z.set(K,z),$.setAttribute("id",z)}let Q=["href","xlink:href","fill","stroke","clip-path","mask","filter","marker-start","marker-mid","marker-end"];for(let z of Q){let q=$.getAttribute?.(z);if(!q)continue;if(q.includes("url(#")){let W=q.replace(/url\(#([^)]+)\)/g,(j,G)=>{return`url(#${Z.get(G)||J+G})`});$.setAttribute(z,W)}else if(q.startsWith("#")){let W=q.substring(1);$.setAttribute(z,"#"+(Z.get(W)||J+W))}}let H=$.getAttribute?.("style");if(H&&H.includes("url(#")){let z=H.replace(/url\(#([^)]+)\)/g,(q,W)=>{return`url(#${Z.get(W)||J+W})`});$.setAttribute("style",z)}if($.children)for(let z of $.children)q8(z,J,Z);return Z}function iK($,J,Z){if(!$){console.warn("setCDATAContent called with null element");return}let K=0,Q=1e4;while($.firstChild&&K++<Q){let z=$.firstChild;if($.removeChild(z),$.firstChild===z){console.error("removeChild failed to remove child in setCDATAContent, breaking to prevent infinite loop");break}}if(K>=Q)console.error(`Safety limit reached in setCDATAContent: ${Q} children processed`);let H=J.includes("<")||J.includes("&")||J.includes("]]>");if(H&&typeof Z.createCDATASection==="function")if(J.includes("]]>")){let z=J.split("]]>");for(let q=0;q<z.length;q++)if(q===0)$.appendChild(Z.createCDATASection(z[q]+"]]"));else if(q===z.length-1)$.appendChild(Z.createCDATASection(">"+z[q]));else $.appendChild(Z.createCDATASection(">"+z[q]+"]]"))}else $.appendChild(Z.createCDATASection(J));else if(H){let z=J.replace(/\]\]>/g,"]]]]><![CDATA[>");$.setAttribute("data-cdata-pending","true"),$.textContent=z}else $.textContent=J}var ez={audio:[".wav",".mp3",".ogg",".webm",".m4a",".aac",".flac"],image:[".png",".jpg",".jpeg",".gif",".svg",".webp",".avif",".ico",".bmp"],video:[".mp4",".webm",".ogv",".avi",".mov"],data:[".json",".xml",".txt",".csv",".tsv"],font:[".woff",".woff2",".ttf",".otf",".eot"]},$q=Object.values(ez).flat();function Jq($){let J=new Set,Z=$q.map((H)=>H.replace(".","\\.")).join("|"),K=new RegExp(`["'\`]([^"'\`]*(?:${Z}))["'\`]`,"gi"),Q;while((Q=K.exec($))!==null){let H=Q[1];if(H&&!H.startsWith("data:")&&!H.match(/^https?:\/\/(?!localhost)/)&&H.length>0)J.add(H)}return J}function Kq($){if($.size===0)return"";let J={};for(let[Z,K]of $)J[Z]=K;return`
350
+ `;return YJ({title:"SVG Compatibility Matrix",subtitle:"What problems will your SVG have in each configuration?",columns:Z,rowLevels:K,rowData:Q,getCellContent:H,additionalSections:[{title:"SERVER-SIDE SVG RENDERERS (no HTML embedding)",content:q,height:z.length*30+20}],legend:W,options:{fontFamily:J,minCellWidth:220,legendHeight:1020,...$}})}var XJ=G0(($,J={})=>{let Z=J.fixInvalidGroupAttrs!==!1,K=J.fixMissingNamespaces!==!1,Q=J.fixBrokenRefs!==!1,H=J.fixAnimationTiming!==!1,z=J.verbose||!1,q=[],j=new Set,W=(f)=>{let P=f.getAttribute("id");if(P)j.add(P);for(let l of f.children)if(i(l))W(l)};W($);let G=["x","y","width","height","cx","cy","r","rx","ry","x1","y1","x2","y2","d","points"],F=new Set(["svg","rect","image","foreignObject","use","symbol","pattern","mask","filter","clipPath"]),_=(f)=>{let P=f.tagName.toLowerCase();if(P==="g"&&Z){for(let l of G)if(f.hasAttribute(l)){let g=f.getAttribute(l);f.removeAttribute(l),q.push({type:"invalid_attr_removed",element:P,attr:l,value:g,reason:`SVG 1.1: <g> elements do not support '${l}' attribute`})}}for(let l of f.children)if(i(l))_(l)},U=()=>{if(!K)return;let f=!1,P=(l)=>{for(let g of l.getAttributeNames())if(g.startsWith("xlink:")){f=!0;return}for(let g of l.children){if(i(g))P(g);if(f)return}};if(P($),f&&!$.hasAttribute("xmlns:xlink"))$.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),q.push({type:"namespace_added",namespace:"xmlns:xlink",value:"http://www.w3.org/1999/xlink",reason:"SVG 1.1: xmlns:xlink required when xlink:* attributes are present"})},M=(f)=>{let P=[f,f.replace(/^FRAME(\d+)$/,"FRAME0$1"),f.replace(/^FRAME0(\d+)$/,"FRAME00$1"),f.replace(/^FRAME00(\d+)$/,"FRAME000$1"),f.replace(/^FRAME0+(\d+)$/,"FRAME$1"),f.replace(/^FRAME(\d)$/,"FRAME0000$1"),f.replace(/^FRAME(\d{2})$/,"FRAME000$1"),f.replace(/^FRAME(\d{3})$/,"FRAME00$1"),f.replace(/^FRAME(\d{4})$/,"FRAME0$1")];for(let n of P)if(j.has(n)&&n!==f)return n;let l=null,g=1/0;for(let n of j)if(n.toLowerCase().includes(f.toLowerCase())||f.toLowerCase().includes(n.toLowerCase())){let q0=Math.abs(n.length-f.length);if(q0<g&&q0<=2)g=q0,l=n}return l},V=(f)=>{if(!Q)return;for(let P of["href","xlink:href"]){let l=f.getAttribute(P);if(l&&l.startsWith("#")){let g=l.substring(1);if(!j.has(g)){let n=M(g);if(n)f.setAttribute(P,`#${n}`),q.push({type:"ref_fixed",element:f.tagName.toLowerCase(),attr:P,oldValue:l,newValue:`#${n}`,reason:`ID '${g}' not found, fixed to similar ID '${n}'`})}}}if(f.tagName.toLowerCase()==="animate"){let P=f.getAttribute("attributeName");if(P==="href"||P==="xlink:href"){let l=f.getAttribute("values");if(l){let g=l.split(";"),n=!1,q0=g.map((L0)=>{let E0=L0.trim();if(E0.startsWith("#")){let T0=E0.substring(1);if(!j.has(T0)){let V7=M(T0);if(V7)return n=!0,`#${V7}`}}return E0});if(n){let L0=q0.join(";");f.setAttribute("values",L0),q.push({type:"animate_values_fixed",oldValue:l,newValue:L0,reason:"Fixed broken ID references in animate values"})}}}}for(let P of["fill","stroke","clip-path","mask","filter"]){let l=f.getAttribute(P);if(l&&l.startsWith("url(#")){let g=l.match(/url\(#([^)]+)\)/);if(g){let n=g[1];if(!j.has(n)){let q0=M(n);if(q0)f.setAttribute(P,`url(#${q0})`),q.push({type:"url_ref_fixed",element:f.tagName.toLowerCase(),attr:P,oldValue:l,newValue:`url(#${q0})`,reason:`ID '${n}' not found, fixed to similar ID '${q0}'`})}}}}for(let P of f.children)if(i(P))V(P)},Y=(f)=>{if(!H)return;let P=["animate","animateTransform","animateMotion","animateColor","set"],l=f.tagName.toLowerCase();if(P.includes(l)){let g=f.getAttribute("dur"),n=f.getAttribute("repeatCount");if(g==="0"||g==="0s"){if(!f.getAttribute("keyTimes"))q.push({type:"timing_warning",element:l,attr:"dur",value:g,reason:'dur="0" may cause animation to not play'})}let q0=f.getAttribute("begin");if(q0){let L0=q0;if(q0==="0")L0="0s",f.setAttribute("begin",L0),q.push({type:"timing_normalized",element:l,attr:"begin",oldValue:q0,newValue:L0,reason:"Normalized begin value to include time unit"})}}for(let g of f.children)if(i(g))Y(g)},O=new Set(["font-face-format","font-face-name","glyphref","hkern","vkern"]),X=new Set(["animate","animateTransform","animateMotion","animateColor","set"]),w=(f)=>{let P=f.tagName.toLowerCase();if(O.has(P)){let l=[];for(let g of Array.from(f.children))if(i(g)&&X.has(g.tagName.toLowerCase()))l.push(g);if(l.length>0){let g=f.getAttribute("id");if(!g)g=`_fix_${P}_${Math.random().toString(36).substring(2,8)}`,f.setAttribute("id",g),q.push({type:"id_generated",element:P,id:g,reason:"Generated ID for animation targeting after moving animate element"});for(let n of l){if(f.removeChild(n),!n.hasAttribute("href")&&!n.hasAttribute("xlink:href"))n.setAttribute("href",`#${g}`);let q0=f.parentNode;if(q0){let L0=f.nextSibling;if(L0)q0.insertBefore(n,L0);else q0.appendChild(n)}q.push({type:"animation_moved_from_empty_element",element:n.tagName.toLowerCase(),parentElement:P,targetId:g,reason:`SVG 1.1: <${P}> has EMPTY content model and cannot have children. Animation moved outside and targets element via href="#${g}".`})}}}for(let l of Array.from(f.children))if(i(l))w(l)},R=/^([+-]?\d*\.?\d+(?:[Ee][+-]?\d+)?)(EM|EX|PX|IN|CM|MM|PT|PC|DEG|GRAD|RAD|S|MS|HZ|KHZ|%)$/i,B=new Set(["x","y","width","height","rx","ry","cx","cy","r","fx","fy","x1","y1","x2","y2","dx","dy","textLength","startOffset","stroke-width","stroke-dashoffset","font-size","baseline-shift","kerning","letter-spacing","word-spacing","markerWidth","markerHeight","refX","refY","stdDeviation","radius"]),I=(f)=>{for(let P of f.getAttributeNames()){if(!B.has(P)&&!P.includes("-"))continue;let l=f.getAttribute(P);if(!l)continue;let g=l.match(R);if(g){let[,n,q0]=g,L0=q0.toLowerCase();if(q0!==L0){let E0=n+L0;f.setAttribute(P,E0),q.push({type:"unit_normalized",element:f.tagName.toLowerCase(),attr:P,oldValue:l,newValue:E0,reason:"SVG 1.1: Unit identifiers in attributes must be lowercase"})}}}for(let P of f.children)if(i(P))I(P)},h=/[\u00A0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/g,m=new Set(["points","viewBox","preserveAspectRatio","transform","d","values","keyTimes","keySplines","keyPoints","rotate","stroke-dasharray","baseFrequency","kernelMatrix","tableValues","filterRes","stdDeviation","radius","origin"]),v=(f)=>{for(let P of f.getAttributeNames()){if(!m.has(P)&&P!=="style")continue;let l=f.getAttribute(P);if(!l)continue;if(h.test(l)){let g=l.replace(h," ");f.setAttribute(P,g),q.push({type:"whitespace_normalized",element:f.tagName.toLowerCase(),attr:P,reason:"SVG 1.1: Replaced invalid Unicode whitespace with standard space (0x20)"})}}for(let P of f.children)if(i(P))v(P)},x=(f)=>{for(let P of f.getAttributeNames()){let l=f.getAttribute(P);if(!l)continue;let g=l,n=!1;if(/\d\.$/.test(g)||/\d\.(?=[,\s;)])/.test(g))g=g.replace(/(\d)\.(?=$|[,\s;)])/g,"$1"),n=!0;if(g=g.replace(/(^|[,\s;(])\.(\d)/g,"$10.$2"),g=g.replace(/(^|[,\s;(])-\.(\d)/g,"$1-0.$2"),g!==l)n=!0;if(/\.\.+/.test(g))g=g.replace(/\.\.+/g,"."),n=!0;if(n)f.setAttribute(P,g),q.push({type:"number_format_fixed",element:f.tagName.toLowerCase(),attr:P,oldValue:l,newValue:g,reason:"SVG 1.1: Fixed invalid number format"})}for(let P of f.children)if(i(P))x(P)},y=340000000000000000000000000000000000000,T=-340000000000000000000000000000000000000,d=/[+-]?\d*\.?\d+(?:[Ee][+-]?\d+)?/g,p=(f)=>{for(let P of f.getAttributeNames()){let l=f.getAttribute(P);if(!l)continue;if(P==="id"||P==="class"||P.startsWith("xmlns")||P==="href"||P==="xlink:href"||P==="style")continue;let g=l.match(d);if(!g)continue;for(let n of g){let q0=parseFloat(n);if(!isFinite(q0))q.push({type:"invalid_number_detected",element:f.tagName.toLowerCase(),attr:P,value:n,reason:"SVG 1.1: Invalid number (Infinity or NaN)"});else if(q0>y||q0<T)q.push({type:"out_of_range_detected",element:f.tagName.toLowerCase(),attr:P,value:n,reason:"SVG 1.1: Number exceeds single-precision float range"})}}for(let P of f.children)if(i(P))p(P)},c=(f)=>{let P=f.tagName,l=P.toLowerCase();if(P.includes(":")||_6.has(P)||F8.has(l));else{let g=A6(P,_6);if(g)q.push({type:"mistyped_element_detected",element:P,suggestion:g,reason:`Unknown element <${P}> - did you mean <${g}>?`});else q.push({type:"unknown_element_detected",element:P,reason:`Unknown element <${P}> - not in SVG 1.1 spec`})}for(let g of f.children)if(i(g))c(g)},C=(f)=>{for(let P of f.getAttributeNames()){if(P.startsWith("xmlns")||P.startsWith("data-"))continue;let l=P.toLowerCase();if(U6.has(P)||_8.has(l))continue;if(P.startsWith("-webkit-")||P.startsWith("-moz-")||P.startsWith("-ms-")||P.startsWith("-o-"))continue;if(P.includes(":")&&!P.startsWith("xlink:")&&!P.startsWith("xml:"))continue;let g=A6(P,U6);if(g)q.push({type:"mistyped_attribute_detected",element:f.tagName.toLowerCase(),attr:P,suggestion:g,reason:`Unknown attribute '${P}' on <${f.tagName.toLowerCase()}> - did you mean '${g}'?`})}for(let P of f.children)if(i(P))C(P)},u={a:["href"],animate:["attributeName"],animateColor:["attributeName"],animateTransform:["attributeName"],circle:["r"],"color-profile":["name"],cursor:["href"],ellipse:["rx","ry"],feBlend:["in2"],feComposite:["in2"],feConvolveMatrix:["kernelMatrix"],feDisplacementMap:["in2"],feFuncA:["type"],feFuncB:["type"],feFuncG:["type"],feFuncR:["type"],feImage:["href"],font:["horiz-adv-x"],"font-face-uri":["href"],foreignObject:["width","height"],hkern:["k"],image:["href","width","height"],mpath:["href"],path:["d"],polygon:["points"],polyline:["points"],rect:["width","height"],script:["type"],set:["attributeName"],stop:["offset"],style:["type"],textPath:["href"],tref:["href"],use:["href"],vkern:["k"]},N=["href","xlink:href"],e=(f)=>{let P=f.tagName.toLowerCase(),l=u[P];if(l){for(let g of l)if(g==="href"){if(!N.some((q0)=>f.hasAttribute(q0)))q.push({type:"missing_required_attribute",element:P,attr:g,reason:`Element <${P}> is missing required attribute '${g}' (or 'xlink:href')`})}else if(P==="stop"&&g==="offset"){let n=f.parentNode,q0=!1;while(n&&n.tagName){let L0=n.tagName.toLowerCase();if(L0==="meshpatch"||L0==="meshgradient"){q0=!0;break}n=n.parentNode}if(!q0&&!f.hasAttribute(g))q.push({type:"missing_required_attribute",element:P,attr:g,reason:`Element <${P}> is missing required attribute '${g}'`})}else if(!f.hasAttribute(g))q.push({type:"missing_required_attribute",element:P,attr:g,reason:`Element <${P}> is missing required attribute '${g}'`})}for(let g of f.children)if(i(g))e(g)},a={circle:new Set(["desc","title","metadata","animate","animatecolor","animatemotion","animatetransform","set"]),ellipse:new Set(["desc","title","metadata","animate","animatecolor","animatemotion","animatetransform","set"]),line:new Set(["desc","title","metadata","animate","animatecolor","animatemotion","animatetransform","set"]),path:new Set(["desc","title","metadata","animate","animatecolor","animatemotion","animatetransform","set"]),polygon:new Set(["desc","title","metadata","animate","animatecolor","animatemotion","animatetransform","set"]),polyline:new Set(["desc","title","metadata","animate","animatecolor","animatemotion","animatetransform","set"]),rect:new Set(["desc","title","metadata","animate","animatecolor","animatemotion","animatetransform","set"]),use:new Set(["desc","title","metadata","animate","animatecolor","animatemotion","animatetransform","set"]),image:new Set(["desc","title","metadata","animate","animatecolor","animatemotion","animatetransform","set"]),animate:new Set(["desc","title","metadata"]),animatecolor:new Set(["desc","title","metadata"]),animatemotion:new Set(["desc","title","metadata","mpath"]),animatetransform:new Set(["desc","title","metadata"]),set:new Set(["desc","title","metadata"]),lineargradient:new Set(["desc","title","metadata","animate","animatetransform","set","stop"]),radialgradient:new Set(["desc","title","metadata","animate","animatetransform","set","stop"]),filter:new Set(["desc","title","metadata","animate","set","feblend","fecolormatrix","fecomponenttransfer","fecomposite","feconvolvematrix","fediffuselighting","fedisplacementmap","feflood","fegaussianblur","feimage","femerge","femorphology","feoffset","fespecularlighting","fetile","feturbulence"]),stop:new Set(["animate","animatecolor","set"])},s=(f)=>{let P=f.tagName.toLowerCase(),l=a[P];if(l){for(let g of f.children)if(i(g)){let n=g.tagName.toLowerCase();if(!n.includes(":")&&!l.has(n))q.push({type:"invalid_child_element",parent:P,child:n,reason:`Element <${n}> is not a valid child of <${P}> per SVG 1.1 DTD`})}}for(let g of f.children)if(i(g))s(g)},H0={"alignment-baseline":["auto","baseline","before-edge","text-before-edge","middle","central","after-edge","text-after-edge","ideographic","alphabetic","hanging","mathematical","inherit"],"clip-rule":["nonzero","evenodd","inherit"],"color-interpolation":["auto","sRGB","linearRGB","inherit"],"color-interpolation-filters":["auto","sRGB","linearRGB","inherit"],"color-rendering":["auto","optimizeSpeed","optimizeQuality","inherit"],direction:["ltr","rtl","inherit"],display:["inline","block","list-item","run-in","compact","marker","table","inline-table","table-row-group","table-header-group","table-footer-group","table-row","table-column-group","table-column","table-cell","table-caption","none","inherit"],"dominant-baseline":["auto","use-script","no-change","reset-size","ideographic","alphabetic","hanging","mathematical","central","middle","text-after-edge","text-before-edge","inherit"],"fill-rule":["nonzero","evenodd","inherit"],"font-stretch":["normal","wider","narrower","ultra-condensed","extra-condensed","condensed","semi-condensed","semi-expanded","expanded","extra-expanded","ultra-expanded","inherit"],"font-style":["normal","italic","oblique","inherit"],"font-variant":["normal","small-caps","inherit"],"font-weight":["normal","bold","bolder","lighter","100","200","300","400","500","600","700","800","900","inherit"],"image-rendering":["auto","optimizeSpeed","optimizeQuality","inherit"],overflow:["visible","hidden","scroll","auto","inherit"],"pointer-events":["visiblePainted","visibleFill","visibleStroke","visible","painted","fill","stroke","all","none","inherit"],"shape-rendering":["auto","optimizeSpeed","crispEdges","geometricPrecision","inherit"],"stroke-linecap":["butt","round","square","inherit"],"stroke-linejoin":["miter","round","bevel","inherit"],"text-anchor":["start","middle","end","inherit"],"text-rendering":["auto","optimizeSpeed","optimizeLegibility","geometricPrecision","inherit"],"unicode-bidi":["normal","embed","bidi-override","inherit"],visibility:["visible","hidden","collapse","inherit"],"writing-mode":["lr-tb","rl-tb","tb-rl","lr","rl","tb","inherit"],"xml:space":["default","preserve"],additive:["replace","sum"],accumulate:["none","sum"],calcMode:["discrete","linear","paced","spline"],fill:["freeze","remove"],restart:["always","whenNotActive","never"],attributeType:["CSS","XML","auto"],edgeMode:["duplicate","wrap","none"],operator:["over","in","out","atop","xor","arithmetic","erode","dilate"],mode:["normal","multiply","screen","darken","lighten"],type:["translate","scale","rotate","skewX","skewY","matrix","saturate","hueRotate","luminanceToAlpha","identity","table","discrete","linear","gamma","fractalNoise","turbulence"],spreadMethod:["pad","reflect","repeat"],gradientUnits:["userSpaceOnUse","objectBoundingBox"],patternUnits:["userSpaceOnUse","objectBoundingBox"],patternContentUnits:["userSpaceOnUse","objectBoundingBox"],clipPathUnits:["userSpaceOnUse","objectBoundingBox"],maskUnits:["userSpaceOnUse","objectBoundingBox"],maskContentUnits:["userSpaceOnUse","objectBoundingBox"],filterUnits:["userSpaceOnUse","objectBoundingBox"],filterPrimitiveUnits:["userSpaceOnUse","objectBoundingBox"],primitiveUnits:["userSpaceOnUse","objectBoundingBox"],markerUnits:["strokeWidth","userSpaceOnUse"],method:["align","stretch"],spacing:["auto","exact"],lengthAdjust:["spacing","spacingAndGlyphs"],preserveAspectRatio:["none","xMinYMin","xMidYMin","xMaxYMin","xMinYMid","xMidYMid","xMaxYMid","xMinYMax","xMidYMax","xMaxYMax"],zoomAndPan:["disable","magnify"],externalResourcesRequired:["true","false"]},S=new Set(["preserveAspectRatio"]),E=(f)=>{let P=f.tagName.toLowerCase();for(let l of f.getAttributeNames()){let g=H0[l];if(g){let n=f.getAttribute(l);if(S.has(l)&&n)n=n.split(/\s+/)[0];if(l==="fill"&&!["animate","animatecolor","animatemotion","animatetransform","set"].includes(P))continue;if(!g.includes(n)&&n!=="inherit")q.push({type:"invalid_enum_value",element:P,attr:l,value:n,validValues:g.slice(0,5).join(", ")+(g.length>5?"...":""),reason:`Invalid value '${n}' for attribute '${l}' - must be one of: ${g.slice(0,5).join(", ")}${g.length>5?"...":""}`})}}for(let l of f.children)if(i(l))E(l)},t={opacity:{min:0,max:1,type:"number"},"fill-opacity":{min:0,max:1,type:"number"},"stroke-opacity":{min:0,max:1,type:"number"},"stop-opacity":{min:0,max:1,type:"number"},"flood-opacity":{min:0,max:1,type:"number"},"stroke-width":{min:0,type:"length"},"stroke-miterlimit":{min:1,type:"number"},"font-size":{min:0,type:"length"},r:{min:0,type:"length"},rx:{min:0,type:"length"},ry:{min:0,type:"length"},width:{min:0,type:"length"},height:{min:0,type:"length"},stdDeviation:{min:0,type:"number"},scale:{type:"number"},baseFrequency:{min:0,type:"number"},numOctaves:{min:1,type:"integer"},seed:{min:0,type:"number"},repeatCount:{min:0,type:"number"}},$0=(f)=>{let P=f.tagName.toLowerCase();for(let l of f.getAttributeNames()){let g=t[l];if(g){let n=f.getAttribute(l);if(n==="inherit"||n==="none"||n==="indefinite"||n==="auto")continue;let q0=n.match(/^([+-]?\d*\.?\d+)/);if(q0){let L0=parseFloat(q0[1]);if(isNaN(L0))q.push({type:"invalid_numeric_value",element:P,attr:l,value:n,reason:`Invalid numeric value '${n}' for attribute '${l}'`});else{if(g.min!==void 0&&L0<g.min)q.push({type:"numeric_out_of_range",element:P,attr:l,value:n,constraint:`min: ${g.min}`,reason:`Value '${n}' for '${l}' is below minimum (${g.min})`});if(g.max!==void 0&&L0>g.max)q.push({type:"numeric_out_of_range",element:P,attr:l,value:n,constraint:`max: ${g.max}`,reason:`Value '${n}' for '${l}' exceeds maximum (${g.max})`});if(g.type==="integer"&&!Number.isInteger(L0))q.push({type:"invalid_numeric_value",element:P,attr:l,value:n,reason:`Attribute '${l}' requires an integer value, got '${n}'`})}}}}for(let l of f.children)if(i(l))$0(l)},Q0=(f)=>{let P=new Map,l=(g)=>{let n=g.getAttribute("id");if(n){if(!P.has(n))P.set(n,[]);P.get(n).push(g.tagName.toLowerCase())}for(let q0 of g.children)if(i(q0))l(q0)};l(f);for(let[g,n]of P)if(n.length>1)q.push({type:"duplicate_id",id:g,count:n.length,elements:n.join(", "),reason:`Duplicate ID '${g}' found on ${n.length} elements: ${n.join(", ")}`})},U0=(f)=>{let P=new Set,l=(L0)=>{let E0=L0.getAttribute("id");if(E0)P.add(E0);for(let T0 of L0.children)if(i(T0))l(T0)};l(f);let g=/url\(\s*['"]?#([^'")]+)['"]?\s*\)/g,n=/^#(.+)$/,q0=(L0)=>{let E0=L0.tagName.toLowerCase();for(let T0 of L0.getAttributeNames()){let V7=L0.getAttribute(T0),S6;g.lastIndex=0;while((S6=g.exec(V7))!==null){let S7=S6[1];if(!P.has(S7))q.push({type:"broken_reference",element:E0,attr:T0,refId:S7,reason:`Broken reference: url(#${S7}) points to non-existent ID`})}if(T0==="href"||T0==="xlink:href"){let S7=V7.match(n);if(S7){let V6=S7[1];if(!P.has(V6))q.push({type:"broken_reference",element:E0,attr:T0,refId:V6,reason:`Broken reference: ${T0}="#${V6}" points to non-existent ID`})}}}for(let T0 of L0.children)if(i(T0))q0(T0)};q0($)},C0=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]),y0=new Set(["fill","stroke","color","stop-color","flood-color","lighting-color","solid-color"]),o=(f)=>{let P=f.toLowerCase().trim();if(P==="none"||P==="inherit"||P==="currentcolor")return!0;if(C0.has(P))return!0;if(P.startsWith("url("))return!0;if(/^#[0-9a-f]{3}$/.test(P)||/^#[0-9a-f]{6}$/.test(P))return!0;if(/^rgb\(\s*\d{1,3}%?\s*,\s*\d{1,3}%?\s*,\s*\d{1,3}%?\s*\)$/.test(P))return!0;if(/^rgba\(\s*\d{1,3}%?\s*,\s*\d{1,3}%?\s*,\s*\d{1,3}%?\s*,\s*[\d.]+%?\s*\)$/.test(P))return!0;return!1},K0=(f)=>{let P=f.tagName.toLowerCase();for(let l of f.getAttributeNames())if(y0.has(l)){let g=f.getAttribute(l);if(!o(g))q.push({type:"invalid_color",element:P,attr:l,value:g,reason:`Invalid color value '${g}' for attribute '${l}'`})}for(let l of f.children)if(i(l))K0(l)},F0=(f)=>{let P=f.tagName.toLowerCase();if(["svg","symbol","marker","pattern","view"].includes(P)){let n=f.getAttribute("viewBox");if(n){let q0=n.trim().split(/[\s,]+/);if(q0.length!==4)q.push({type:"malformed_viewbox",element:P,value:n,reason:`viewBox must have exactly 4 values (min-x, min-y, width, height), got ${q0.length}`});else{for(let T0=0;T0<q0.length;T0++)if(!/^[+-]?\d*\.?\d+([Ee][+-]?\d+)?$/.test(q0[T0])){q.push({type:"malformed_viewbox",element:P,value:n,reason:`viewBox contains invalid number '${q0[T0]}' at position ${T0+1}`});break}let L0=parseFloat(q0[2]),E0=parseFloat(q0[3]);if(isNaN(L0)||isNaN(E0)||L0<0||E0<0)q.push({type:"invalid_viewbox_dimensions",element:P,value:n,reason:`viewBox width and height must be valid non-negative numbers, got ${L0}x${E0}`})}}}let l=f.getAttribute("preserveAspectRatio");if(l){if(!/^(none|xMinYMin|xMidYMin|xMaxYMin|xMinYMid|xMidYMid|xMaxYMid|xMinYMax|xMidYMax|xMaxYMax)(\s+(meet|slice))?$/.test(l.trim()))q.push({type:"malformed_preserveaspectratio",element:P,value:l,reason:`Invalid preserveAspectRatio format '${l}'`})}if(["polygon","polyline"].includes(P)){let n=f.getAttribute("points");if(n){let q0=n.trim().split(/[\s,]+/);if(q0.length>0&&q0.length%2!==0)q.push({type:"malformed_points",element:P,value:n.slice(0,50)+(n.length>50?"...":""),reason:`points attribute must have even number of values (x,y pairs), got ${q0.length}`})}}let g=f.getAttribute("transform");if(g){if(!/^(\s{0,20}(matrix|translate|scale|rotate|skewX|skewY)\s{0,20}\([^)]*\)\s{0,20})+$/.test(g.trim())){if(!/^[\s\w(),.\-+]+$/.test(g))q.push({type:"malformed_transform",element:P,value:g.slice(0,50)+(g.length>50?"...":""),reason:"Potentially malformed transform attribute"})}}for(let n of f.children)if(i(n))F0(n)},M0=(f)=>{let P=f.tagName,l=P.toLowerCase();if(P.includes(":")||_6.has(P)||F8.has(l)){for(let n of Array.from(f.children))if(i(n))M0(n);return}let g=A6(P,_6);if(g){let n=f.ownerDocument.createElement(g);for(let q0 of f.getAttributeNames())n.setAttribute(q0,f.getAttribute(q0));while(f.firstChild)n.appendChild(f.firstChild);if(f.parentNode)f.parentNode.replaceChild(n,f);q.push({type:"element_typo_fixed",oldName:P,newName:g,reason:`Fixed element typo: <${P}> -> <${g}>`});for(let q0 of Array.from(n.children))if(i(q0))M0(q0)}else for(let n of Array.from(f.children))if(i(n))M0(n)},N0=(f)=>{for(let P of Array.from(f.getAttributeNames())){if(P.startsWith("xmlns")||P.startsWith("data-"))continue;if(P.startsWith("-webkit-")||P.startsWith("-moz-"))continue;if(P.includes(":")&&!P.startsWith("xlink:")&&!P.startsWith("xml:"))continue;if(U6.has(P)||_8.has(P.toLowerCase()))continue;let l=A6(P,U6);if(l){let g=f.getAttribute(P);f.removeAttribute(P),f.setAttribute(l,g),q.push({type:"attr_typo_fixed",element:f.tagName.toLowerCase(),oldAttr:P,newAttr:l,reason:`Fixed attribute typo: '${P}' -> '${l}'`})}}for(let P of f.children)if(i(P))N0(P)},I0=(f)=>{let P=new Map,l=new Set,g=(L0)=>{let E0=L0.getAttribute("id");if(E0)P.set(E0,(P.get(E0)||0)+1),l.add(E0);for(let T0 of L0.children)if(i(T0))g(T0)};g(f);let n=new Set,q0=(L0)=>{let E0=L0.getAttribute("id");if(E0)if(n.has(E0)){let T0=E0,V7=2;while(l.has(T0)||n.has(T0))T0=`${E0}_${V7++}`;L0.setAttribute("id",T0),l.add(T0),n.add(T0),q.push({type:"duplicate_id_renamed",oldId:E0,newId:T0,element:L0.tagName.toLowerCase(),reason:`Renamed duplicate ID: '${E0}' -> '${T0}'`})}else n.add(E0);for(let T0 of L0.children)if(i(T0))q0(T0)};q0(f)};if(_($),U(),V($),Y($),w($),I($),v($),x($),M0($),N0($),I0($),p($),e($),s($),E($),$0($),U0($),K0($),F0($),$.setAttribute("data-fixes-applied",String(q.length)),z&&q.length>0)$.setAttribute("data-fix-report",JSON.stringify(q));return $}),R0={ERROR:"error",WARNING:"warning"},zq={broken_reference:R0.ERROR,broken_url_reference:R0.ERROR,duplicate_id:R0.ERROR,missing_required_attribute:R0.ERROR,invalid_child_element:R0.ERROR,animation_in_empty_element:R0.ERROR,malformed_viewbox:R0.ERROR,malformed_points:R0.ERROR,malformed_transform:R0.ERROR,invalid_enum_value:R0.ERROR,invalid_numeric_constraint:R0.ERROR,invalid_attr_on_element:R0.WARNING,missing_namespace:R0.WARNING,invalid_timing:R0.WARNING,uppercase_unit:R0.WARNING,invalid_whitespace:R0.WARNING,invalid_number:R0.WARNING,mistyped_element_detected:R0.WARNING,unknown_element_detected:R0.WARNING,mistyped_attribute_detected:R0.WARNING,unknown_attribute_detected:R0.WARNING,invalid_color:R0.WARNING,circular_reference:R0.WARNING,deep_nesting:R0.WARNING,empty_defs:R0.WARNING,gradient_stop_order:R0.WARNING,path_complexity:R0.WARNING,external_resource:R0.WARNING,script_content:R0.WARNING,event_handler:R0.WARNING,missing_title:R0.WARNING,missing_desc:R0.WARNING,invalid_aria:R0.WARNING,missing_lang:R0.WARNING},qq=new Set(["onabort","onactivate","onbegin","oncancel","oncanplay","oncanplaythrough","onchange","onclick","onclose","oncuechange","ondblclick","ondrag","ondragend","ondragenter","ondragleave","ondragover","ondragstart","ondrop","ondurationchange","onemptied","onend","onended","onerror","onfocus","onfocusin","onfocusout","oninput","oninvalid","onkeydown","onkeypress","onkeyup","onload","onloadeddata","onloadedmetadata","onloadstart","onmousedown","onmouseenter","onmouseleave","onmousemove","onmouseout","onmouseover","onmouseup","onmousewheel","onpause","onplay","onplaying","onprogress","onratechange","onrepeat","onreset","onresize","onscroll","onseeked","onseeking","onselect","onshow","onstalled","onsubmit","onsuspend","ontimeupdate","ontoggle","onunload","onvolumechange","onwaiting","onwheel"]),Wq=new Set(["aria-activedescendant","aria-atomic","aria-autocomplete","aria-busy","aria-checked","aria-colcount","aria-colindex","aria-colspan","aria-controls","aria-current","aria-describedby","aria-details","aria-disabled","aria-dropeffect","aria-errormessage","aria-expanded","aria-flowto","aria-grabbed","aria-haspopup","aria-hidden","aria-invalid","aria-keyshortcuts","aria-label","aria-labelledby","aria-level","aria-live","aria-modal","aria-multiline","aria-multiselectable","aria-orientation","aria-owns","aria-placeholder","aria-posinset","aria-pressed","aria-readonly","aria-relevant","aria-required","aria-roledescription","aria-rowcount","aria-rowindex","aria-rowspan","aria-selected","aria-setsize","aria-sort","aria-valuemax","aria-valuemin","aria-valuenow","aria-valuetext"]),iK=new Set(["img","graphics-document","graphics-object","graphics-symbol","group","list","listitem","none","presentation","application"]);function jq($){let J={elements:new Map,lines:[]},Z=0;J.lines.push(0);for(let O=0;O<$.length;O++)if($[O]===`
351
+ `)J.lines.push(O+1);let K=[],Q=/<!\[CDATA\[([\s\S]*?)\]\]>/g,H;while((H=Q.exec($))!==null)K.push({start:H.index,end:H.index+H[0].length});let z=/<!--[\s\S]*?-->/g,q;while((q=z.exec($))!==null)K.push({start:q.index,end:q.index+q[0].length});let j=/<script[^>]*>([\s\S]*?)<\/script>/gi,W;while((W=j.exec($))!==null){let O=W.index+W[0].indexOf(">")+1,X=W.index+W[0].lastIndexOf("<");if(X>O)K.push({start:O,end:X})}let G=/<style[^>]*>([\s\S]*?)<\/style>/gi,F;while((F=G.exec($))!==null){let O=F.index+F[0].indexOf(">")+1,X=F.index+F[0].lastIndexOf("<");if(X>O)K.push({start:O,end:X})}K.sort((O,X)=>O.start-X.start);let _=(O)=>{for(let X of K){if(O>=X.start&&O<X.end)return!0;if(X.start>O)break}return!1},U=(O)=>{let X=1;for(let B=0;B<J.lines.length;B++){if(J.lines[B]>O){X=B;break}X=B+1}let w=J.lines[X-1]||0,R=O-w+1;return{line:X,column:R}},M=/<([a-zA-Z][a-zA-Z0-9:_-]*)\s*([^>]*?)(\/?)\s*>/g,V=/([a-zA-Z][a-zA-Z0-9:_-]*)\s*=\s*["']([^"']*)["']/g,Y;while((Y=M.exec($))!==null){if(_(Y.index))continue;let O=Y[1].toLowerCase(),X=Y[2],w=Y.index,R=Y.index+Y[0].length,{line:B,column:I}=U(w),h=X?Y[0].indexOf(X):0,m=new Map;V.lastIndex=0;let v;while((v=V.exec(X))!==null){let x=v[1],y=v[2],T=w+h+v.index,d=U(T);m.set(x.toLowerCase(),{name:x,value:y,line:d.line,column:d.column})}if(!J.elements.has(O))J.elements.set(O,[]);J.elements.get(O).push({line:B,column:I,endColumn:I+Y[0].length-1,attrs:m})}return J.getElementPosition=(O,X=0)=>{let w=J.elements.get(O.toLowerCase());if(w&&w[X]){let R=w[X];return{line:R.line,column:R.column}}return{line:1,column:1}},J.getAttributePosition=(O,X,w=0)=>{let R=J.elements.get(O.toLowerCase());if(R&&R[w]){let B=R[w],I=B.attrs.get(X.toLowerCase());if(I)return{line:I.line,column:I.column};return{line:B.line,column:B.column}}return{line:1,column:1}},J}async function HZ($,J={}){rz();let Z=J.errorsOnly===!0,K=J.outputFile||null,Q=(J.outputFormat||"json").toLowerCase(),H=J.includeSource===!0,z=J.validateInkscape===!0,q=J.inkscapeStrict===!0,j=["text","json","xml","yaml"];if(K&&!j.includes(Q))throw new Error(`Invalid outputFormat '${Q}'. Must be one of: ${j.join(", ")}`);let W="",G;try{if(G=T6($),G===v0.SVG_STRING)W=$;else if(G===v0.FILE_PATH){let b=await import("node:fs/promises"),r=(await Promise.resolve().then(() => (P6(),I6))).normalize($);try{W=await b.readFile(r,"utf8")}catch(D){throw new Error(`Failed to read file '${$}': ${D.message}`)}}else if(G===v0.URL)try{let b=await fetch($);if(!b.ok)throw new Error(`HTTP ${b.status}: ${b.statusText}`);W=await b.text()}catch(b){throw new Error(`Failed to fetch URL '${$}': ${b.message}`)}else if(G===v0.DOM_ELEMENT)if(typeof XMLSerializer!=="undefined")W=new XMLSerializer().serializeToString($);else if($.outerHTML)W=$.outerHTML;else throw new Error("Cannot serialize DOM element: XMLSerializer not available");else throw new Error(`Unknown input type: ${typeof $}`)}catch(b){return{issues:[{type:"input_error",severity:R0.ERROR,reason:b.message,line:0,column:0}],isValid:!1,hasErrors:!0,hasWarnings:!1,errorCount:1,warningCount:0,summary:{input_error:1}}}let F=H?W.split(`
352
+ `):null,_=jq(W),U,M=[],V=(b)=>{let A=b.match(/line\s*:?\s*(\d+)/i)||b.match(/:(\d+):/);return A?parseInt(A[1],10):1},Y=(b)=>{let A=b.match(/column\s*:?\s*(\d+)/i)||b.match(/:\d+:(\d+)/);return A?parseInt(A[1],10):1},O=(b)=>{let A=b,r=[],D="￾_VALID_ENTITY_￾",J0=/&(amp|lt|gt|quot|apos|#\d{1,7}|#x[\da-fA-F]{1,6});/g,O0=A.replace(J0,D+"$1;").replace(/&/g,"&amp;").replace(new RegExp(D,"g"),"&");if(O0!==A)A=O0,r.push("Escaped unencoded ampersands");let b0=A.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g,"");if(b0!==A)A=b0,r.push("Removed invalid control characters");if(A.charCodeAt(0)===65279)A=A.slice(1),r.push("Removed UTF-8 BOM");let P0=A.replace(/="([^"]*)<([^"]*)"(?!\s*>)/g,(u0,e0,o0)=>{if(!o0.includes(">"))return`="${e0}&lt;${o0}"`;return u0});if(P0!==A)A=P0,r.push("Escaped < in attribute values");return{fixed:A,appliedFixes:r}};try{U=await b6($,G)}catch(b){let A=b.message||String(b),r=V(A),D=Y(A),{fixed:J0,appliedFixes:z0}=O(W);if(z0.length>0&&J0!==W)try{let{JSDOM:W0}=await import("jsdom");U=new W0(J0,{contentType:"image/svg+xml"}).window.document.documentElement,M.push({type:"parse_recovery",severity:R0.WARNING,reason:`Recovered from parse error. Applied fixes: ${z0.join("; ")}`,line:r,column:D}),M.push({type:"original_parse_error",severity:R0.ERROR,reason:`Original parse error: ${A}`,line:r,column:D})}catch(W0){return{issues:[{type:"parse_error",severity:R0.ERROR,reason:`Failed to parse SVG: ${A}`,line:r,column:D},{type:"recovery_failed",severity:R0.WARNING,reason:`Recovery attempted (${z0.join("; ")}) but still failed: ${W0.message}`,line:r,column:D}],isValid:!1,hasErrors:!0,hasWarnings:!0,errorCount:1,warningCount:1,summary:{parse_error:1,recovery_failed:1}}}else return{issues:[{type:"parse_error",severity:R0.ERROR,reason:`Failed to parse SVG: ${A}`,line:r,column:D}],isValid:!1,hasErrors:!0,hasWarnings:!1,errorCount:1,warningCount:0,summary:{parse_error:1}}}let X=[];if(M.length>0)X.push(...M);let w=new Map,R=(b)=>{let A=b.toLowerCase(),r=w.get(A)||0;return w.set(A,r+1),r},B=()=>{w.clear()},I=(b,A,r=null,D=null)=>{let J0;if(r)J0=_.getAttributePosition(A,r,D||0);else J0=_.getElementPosition(A,D||0);let z0=zq[b.type]||R0.WARNING,W0={...b,severity:z0,line:J0.line,column:J0.column};if(H&&F&&J0.line>0&&J0.line<=F.length)W0.sourceLine=F[J0.line-1];return W0},h=new Set,m=(b)=>{if(!b)return;let A=b.getAttribute("id");if(A)h.add(A);for(let r of b.children)if(i(r))m(r)};m(U);let v=["x","y","width","height","cx","cy","r","rx","ry","x1","y1","x2","y2","d","points"],x=(b)=>{let A=b.tagName.toLowerCase(),r=R(A);if(A==="g"){for(let D of v)if(b.hasAttribute(D))X.push(I({type:"invalid_attr_on_element",element:A,attr:D,value:b.getAttribute(D),reason:`SVG 1.1: <g> elements do not support '${D}' attribute`},A,D,r))}for(let D of b.children)if(i(D))x(D)},y=()=>{let b=!1,A=null,r=null,D=(J0)=>{for(let z0 of J0.getAttributeNames())if(z0.startsWith("xlink:")){b=!0,A=J0.tagName.toLowerCase(),r=z0;return}for(let z0 of J0.children){if(i(z0))D(z0);if(b)return}};if(D(U),b&&!U.hasAttribute("xmlns:xlink")){let J0=_.getAttributePosition(A,r,0);X.push({type:"missing_namespace",namespace:"xmlns:xlink",reason:"Document uses xlink:* attributes but missing xmlns:xlink namespace declaration",line:J0.line,column:J0.column})}},T=(b)=>{let A=b.tagName.toLowerCase(),r=R(A);for(let D of["xlink:href","href"]){let J0=b.getAttribute(D);if(J0&&J0.startsWith("#")){let z0=J0.slice(1);if(z0&&!h.has(z0))X.push(I({type:"broken_reference",element:A,attr:D,referencedId:z0,reason:`Reference to non-existent ID '${z0}'`},A,D,r))}}for(let D of b.children)if(i(D))T(D)},d=["begin","end","dur","repeatDur","min","max"],p=new Set(["animate","animateTransform","animateMotion","animateColor","set"]),c=(b)=>{let A=b.tagName.toLowerCase(),r=R(A);if(p.has(A))for(let D of d){let J0=b.getAttribute(D);if(J0){let z0=J0.trim();if(z0!==J0)X.push(I({type:"invalid_timing",element:A,attr:D,value:J0,reason:"Timing value has leading/trailing whitespace"},A,D,r));if(/[;,]/.test(z0)&&!/^[\d\w\s.;,+-]+$/.test(z0))X.push(I({type:"invalid_timing",element:A,attr:D,value:J0,reason:"Timing value may contain invalid characters"},A,D,r))}}for(let D of b.children)if(i(D))c(D)},C=new Set(["font-face-format","font-face-name","glyphref","hkern","vkern"]),u=(b)=>{let A=b.tagName.toLowerCase(),r=R(A);if(C.has(A)){for(let D of b.children)if(i(D)){let J0=D.tagName.toLowerCase();if(p.has(J0))X.push(I({type:"animation_in_empty_element",element:A,child:J0,reason:`Animation element <${J0}> inside <${A}> which has EMPTY content model per SVG 1.1 DTD`},A,null,r))}}for(let D of b.children)if(i(D))u(D)},N=/(\d+\.?\d*)(PX|EM|EX|PT|PC|CM|MM|IN|%)/gi,e=["width","height","x","y","x1","y1","x2","y2","cx","cy","r","rx","ry","stroke-width","font-size","letter-spacing","word-spacing","stroke-dashoffset"],a=(b)=>{let A=b.tagName.toLowerCase(),r=R(A);for(let D of e){let J0=b.getAttribute(D);if(J0){let z0=J0.match(N);if(z0)for(let W0 of z0){let O0=W0.replace(/[\d.]+/,"");if(O0!==O0.toLowerCase())X.push(I({type:"uppercase_unit",element:A,attr:D,value:J0,reason:`Unit '${O0}' should be lowercase '${O0.toLowerCase()}'`},A,D,r))}}}for(let D of b.children)if(i(D))a(D)},s=["points","viewBox","d","values","keyTimes","keySplines","rotate"],H0=(b)=>{let A=b.tagName.toLowerCase(),r=R(A);for(let D of s){let J0=b.getAttribute(D);if(J0){if(/[\t\n\r]/.test(J0)||/ +/.test(J0))X.push(I({type:"invalid_whitespace",element:A,attr:D,reason:"List attribute contains tabs, newlines, or multiple consecutive spaces"},A,D,r))}}for(let D of b.children)if(i(D))H0(D)},S=["width","height","x","y","x1","y1","x2","y2","cx","cy","r","rx","ry","stroke-width","stroke-miterlimit","stroke-dashoffset","opacity","fill-opacity","stroke-opacity","font-size"],E=(b)=>{let A=b.tagName.toLowerCase(),r=R(A);for(let D of S){let J0=b.getAttribute(D);if(J0){let z0=J0.trim();if(/^0\d/.test(z0.replace(/[a-z%]+$/i,"")))X.push(I({type:"invalid_number",element:A,attr:D,value:J0,reason:"Number has unnecessary leading zeros"},A,D,r));if(/\.$/.test(z0.replace(/[a-z%]+$/i,"")))X.push(I({type:"invalid_number",element:A,attr:D,value:J0,reason:"Number has trailing decimal point"},A,D,r))}}for(let D of b.children)if(i(D))E(D)},t=(b,A=!1)=>{let r=b.tagName,D=r.toLowerCase(),J0=R(D),z0=r.includes(":"),W0=b.namespaceURI&&b.namespaceURI!=="http://www.w3.org/2000/svg",O0=b.getAttribute?b.getAttribute("xmlns"):null,b0=O0&&O0!=="http://www.w3.org/2000/svg",P0=A||dK.has(D)||z0||W0||b0;if(!P0){if(!_6.has(r)&&!F8.has(D)){if(!sz(D)){let u0=A6(r,_6);if(u0)X.push(I({type:"mistyped_element_detected",element:r,suggestion:u0,reason:`Unknown element <${r}> - did you mean <${u0}>?`},D,null,J0));else X.push(I({type:"unknown_element_detected",element:r,reason:`Unknown element <${r}> - not in SVG 1.1 spec`},D,null,J0))}}}for(let u0 of b.children)if(i(u0))t(u0,P0)},$0=(b,A=!1)=>{let r=b.tagName.toLowerCase(),D=R(r),J0=b.tagName.includes(":"),z0=b.namespaceURI&&b.namespaceURI!=="http://www.w3.org/2000/svg",W0=b.getAttribute?b.getAttribute("xmlns"):null,O0=W0&&W0!=="http://www.w3.org/2000/svg",b0=A||dK.has(r)||J0||z0||O0;if(!b0)for(let P0 of b.getAttributeNames()){if(P0.startsWith("data-")||P0.startsWith("aria-"))continue;if(P0==="xmlns"||P0.startsWith("xmlns:"))continue;if(P0.includes(":")&&!P0.startsWith("xlink:")&&!P0.startsWith("xml:"))continue;if(oz(P0))continue;if(!U6.has(P0)&&!_8.has(P0.toLowerCase())){let u0=A6(P0,U6);if(u0)X.push(I({type:"mistyped_attribute_detected",element:r,attr:P0,suggestion:u0,reason:`Unknown attribute '${P0}' - did you mean '${u0}'?`},r,P0,D));else X.push(I({type:"unknown_attribute_detected",element:r,attr:P0,reason:`Unknown attribute '${P0}' on <${r}> - not in SVG 1.1 spec`},r,P0,D))}}for(let P0 of b.children)if(i(P0))$0(P0,b0)},Q0={use:["xlink:href","href"],image:["xlink:href","href"],feImage:["xlink:href","href"],textPath:["xlink:href","href"],mpath:["xlink:href","href"],animate:["attributeName"],animateTransform:["attributeName","type"],animateMotion:[],animateColor:["attributeName"],set:["attributeName"],feBlend:["in2"],feComposite:["in2"],feDisplacementMap:["in2","scale"],feMorphology:["operator"],feTurbulence:["type"],feConvolveMatrix:["kernelMatrix"],feFuncR:["type"],feFuncG:["type"],feFuncB:["type"],feFuncA:["type"],linearGradient:[],radialGradient:[],stop:["offset"]},U0=(b)=>{let A=b.tagName.toLowerCase(),r=R(A),D=Q0[A];if(D&&D.length>0)if(D.includes("xlink:href")&&D.includes("href")){if(!b.hasAttribute("xlink:href")&&!b.hasAttribute("href"))X.push(I({type:"missing_required_attribute",element:A,attrs:["href","xlink:href"],reason:`<${A}> requires 'href' or 'xlink:href' attribute`},A,null,r))}else for(let J0 of D){if(A==="stop"&&J0==="offset"){let z0=b.parentNode,W0=!1;while(z0&&z0.tagName){let O0=z0.tagName.toLowerCase();if(O0==="meshpatch"||O0==="meshgradient"){W0=!0;break}z0=z0.parentNode}if(W0)continue}if(!b.hasAttribute(J0))X.push(I({type:"missing_required_attribute",element:A,attr:J0,reason:`<${A}> requires '${J0}' attribute per SVG 1.1 DTD`},A,J0,r))}for(let J0 of b.children)if(i(J0))U0(J0)},C0={linearGradient:new Set(["stop","animate","animateTransform","set"]),radialGradient:new Set(["stop","animate","animateTransform","set"]),stop:new Set(["animate","set"]),clipPath:new Set(["path","text","rect","circle","ellipse","line","polyline","polygon","use","animate","animateTransform","set","desc","title"]),mask:new Set(["path","text","rect","circle","ellipse","line","polyline","polygon","use","g","defs","image","switch","a","animate","animateTransform","set","desc","title"])},y0=(b)=>{let A=b.tagName.toLowerCase(),r=R(A),D=C0[A];if(D){for(let J0 of b.children)if(i(J0)){let z0=J0.tagName.toLowerCase();if(!z0.includes(":")&&!D.has(z0))X.push(I({type:"invalid_child_element",element:A,child:z0,reason:`<${z0}> is not a valid child of <${A}> per SVG 1.1 DTD`},A,null,r))}}for(let J0 of b.children)if(i(J0))y0(J0)},o={spreadMethod:new Set(["pad","reflect","repeat"]),gradientUnits:new Set(["userSpaceOnUse","objectBoundingBox"]),clipPathUnits:new Set(["userSpaceOnUse","objectBoundingBox"]),maskUnits:new Set(["userSpaceOnUse","objectBoundingBox"]),maskContentUnits:new Set(["userSpaceOnUse","objectBoundingBox"]),filterUnits:new Set(["userSpaceOnUse","objectBoundingBox"]),filterPrimitiveUnits:new Set(["userSpaceOnUse","objectBoundingBox"]),primitiveUnits:new Set(["userSpaceOnUse","objectBoundingBox"]),patternUnits:new Set(["userSpaceOnUse","objectBoundingBox"]),patternContentUnits:new Set(["userSpaceOnUse","objectBoundingBox"]),markerUnits:new Set(["strokeWidth","userSpaceOnUse"]),"fill-rule":new Set(["nonzero","evenodd","inherit"]),"clip-rule":new Set(["nonzero","evenodd","inherit"]),"stroke-linecap":new Set(["butt","round","square","inherit"]),"stroke-linejoin":new Set(["miter","round","bevel","inherit"]),"text-anchor":new Set(["start","middle","end","inherit"]),"dominant-baseline":new Set(["auto","use-script","no-change","reset-size","ideographic","alphabetic","hanging","mathematical","central","middle","text-after-edge","text-before-edge","inherit"]),"alignment-baseline":new Set(["auto","baseline","before-edge","text-before-edge","middle","central","after-edge","text-after-edge","ideographic","alphabetic","hanging","mathematical","inherit"]),visibility:new Set(["visible","hidden","collapse","inherit"]),display:new Set(["inline","block","list-item","run-in","compact","marker","table","inline-table","table-row-group","table-header-group","table-footer-group","table-row","table-column-group","table-column","table-cell","table-caption","none","inherit"]),overflow:new Set(["visible","hidden","scroll","auto","inherit"])},K0=(b)=>{let A=b.tagName.toLowerCase(),r=R(A);for(let[D,J0]of Object.entries(o)){let z0=b.getAttribute(D);if(z0&&!J0.has(z0))X.push(I({type:"invalid_enum_value",element:A,attr:D,value:z0,validValues:[...J0],reason:`Invalid value '${z0}' for '${D}'. Valid values: ${[...J0].join(", ")}`},A,D,r))}for(let D of b.children)if(i(D))K0(D)},F0={opacity:{min:0,max:1,type:"number"},"fill-opacity":{min:0,max:1,type:"number"},"stroke-opacity":{min:0,max:1,type:"number"},"stop-opacity":{min:0,max:1,type:"number"},"flood-opacity":{min:0,max:1,type:"number"},"stroke-width":{min:0,type:"length"},"stroke-miterlimit":{min:1,type:"number"},r:{min:0,type:"length"},rx:{min:0,type:"length"},ry:{min:0,type:"length"}},M0=(b)=>{let A=b.tagName.toLowerCase(),r=R(A);for(let[D,J0]of Object.entries(F0)){let z0=b.getAttribute(D);if(z0){let W0=parseFloat(z0);if(!isNaN(W0)){if(J0.min!==void 0&&W0<J0.min)X.push(I({type:"invalid_numeric_constraint",element:A,attr:D,value:z0,reason:`Value ${W0} is below minimum ${J0.min}`},A,D,r));if(J0.max!==void 0&&W0>J0.max)X.push(I({type:"invalid_numeric_constraint",element:A,attr:D,value:z0,reason:`Value ${W0} is above maximum ${J0.max}`},A,D,r))}}}for(let D of b.children)if(i(D))M0(D)},N0=(b)=>{let A=new Map,r=new Map,D=(J0)=>{let z0=J0.tagName.toLowerCase(),W0=R(z0),O0=J0.getAttribute("id");if(O0){if(!A.has(O0))A.set(O0,[]),r.set(O0,{tagName:z0,occIdx:W0});A.get(O0).push(z0)}for(let b0 of J0.children)if(i(b0))D(b0)};D(b);for(let[J0,z0]of A)if(z0.length>1){let W0=r.get(J0);X.push(I({type:"duplicate_id",id:J0,elements:z0,count:z0.length,reason:`ID '${J0}' is used ${z0.length} times (on ${z0.join(", ")})`},W0.tagName,"id",W0.occIdx))}},I0=/url\(#([^)]+)\)/g,f=["fill","stroke","clip-path","mask","filter","color-profile","marker","marker-start","marker-mid","marker-end"],P=(b)=>{let A=b.tagName.toLowerCase(),r=R(A);for(let D of f){let J0=b.getAttribute(D);if(J0){let z0;I0.lastIndex=0;while((z0=I0.exec(J0))!==null){let W0=z0[1];if(!h.has(W0))X.push(I({type:"broken_url_reference",element:A,attr:D,referencedId:W0,reason:`url(#${W0}) references non-existent ID`},A,D,r))}}}for(let D of b.children)if(i(D))P(D)},l=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen","currentcolor","inherit","none","transparent"]),g=["fill","stroke","color","stop-color","flood-color","lighting-color","solid-color"],n=(b)=>{let A=b.toLowerCase().trim();if(l.has(A))return!0;if(/^#[0-9a-f]{3}$/i.test(A))return!0;if(/^#[0-9a-f]{4}$/i.test(A))return!0;if(/^#[0-9a-f]{6}$/i.test(A))return!0;if(/^#[0-9a-f]{8}$/i.test(A))return!0;if(/^rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*(,\s*[\d.]+\s*)?\)$/i.test(A))return!0;if(/^rgba?\(\s*\d+%\s*,\s*\d+%\s*,\s*\d+%\s*(,\s*[\d.]+%?\s*)?\)$/i.test(A))return!0;if(/^hsla?\(\s*\d+\s*,\s*\d+%\s*,\s*\d+%\s*(,\s*[\d.]+\s*)?\)$/i.test(A))return!0;if(/^url\(#[^)]+\)$/i.test(A))return!0;return!1},q0=(b)=>{let A=b.tagName.toLowerCase(),r=R(A);for(let D of g){let J0=b.getAttribute(D);if(J0&&!n(J0))X.push(I({type:"invalid_color",element:A,attr:D,value:J0,reason:`Invalid color value '${J0}'`},A,D,r))}for(let D of b.children)if(i(D))q0(D)},L0=(b)=>{let A=b.tagName.toLowerCase(),r=R(A),D=b.getAttribute("viewBox");if(D){let W0=D.trim().split(/[\s,]+/);if(W0.length!==4||!W0.every((O0)=>!isNaN(parseFloat(O0))))X.push(I({type:"malformed_viewbox",element:A,value:D,reason:"viewBox must be exactly 4 numbers (min-x, min-y, width, height)"},A,"viewBox",r))}let J0=b.getAttribute("points");if(J0){let W0=J0.trim().split(/[\s,]+/).filter((O0)=>O0);if(W0.length%2!==0||!W0.every((O0)=>!isNaN(parseFloat(O0))))X.push(I({type:"malformed_points",element:A,value:J0.length>50?J0.substring(0,50)+"...":J0,reason:"points must be pairs of numbers"},A,"points",r))}let z0=b.getAttribute("transform");if(z0){let W0=/^\s{0,20}(matrix|translate|scale|rotate|skewX|skewY)\s{0,20}\([^)]*\)\s{0,20},?\s{0,20}/,O0=z0.trim();while(O0.length>0){let b0=O0.match(W0);if(b0&&b0[0].length>0)O0=O0.substring(b0[0].length);else if(!b0){X.push(I({type:"malformed_transform",element:A,value:z0.length>50?z0.substring(0,50)+"...":z0,reason:`Invalid transform syntax near '${O0.substring(0,20)}'`},A,"transform",r));break}else O0=O0.substring(1)}}if(A==="path"){let W0=b.getAttribute("d");if(W0){let O0=W0.trim();if(O0.length>0){if(!/^[Mm]/.test(O0))X.push(I({type:"malformed_path_data",element:"path",value:W0.length>50?W0.substring(0,50)+"...":W0,reason:"Path data must start with M or m command"},"path","d",r));let b0=O0.replace(/[MmZzLlHhVvCcSsQqTtAa\d\s,.\-+eE]/g,"");if(b0.length>0)X.push(I({type:"malformed_path_data",element:"path",value:W0.length>50?W0.substring(0,50)+"...":W0,reason:`Path data contains invalid characters: '${b0.substring(0,10)}'`},"path","d",r))}}}for(let W0 of b.children)if(i(W0))L0(W0)},E0=()=>{let b=new Map,A=(W0)=>{let O0=W0.getAttribute("id");if(O0)b.set(O0,W0);for(let b0 of W0.children)if(i(b0))A(b0)};A(U);let r=["href","xlink:href","mask","clip-path","filter","fill","stroke"],D=(W0)=>{if(!W0)return null;let O0=W0.match(/url\(#([^)]+)\)/);if(O0)return O0[1];let b0=W0.match(/^#(.+)$/);if(b0)return b0[1];return null},J0=(W0,O0=new Set)=>{if(O0.has(W0))return!0;let b0=b.get(W0);if(!b0)return!1;O0.add(W0);let P0=(e0)=>{for(let o0 of r){let SJ=D(e0.getAttribute(o0));if(SJ&&J0(SJ,O0))return!0}for(let o0 of e0.children)if(i(o0)&&P0(o0))return!0;return!1},u0=P0(b0);return O0.delete(W0),u0},z0=["clipPath","mask","filter","symbol","pattern","marker"];for(let[W0,O0]of b){let b0=O0.tagName.toLowerCase();if(z0.includes(b0)){if(J0(W0)){B();let P0=R(b0);X.push(I({type:"circular_reference",element:b0,attr:"id",value:W0,reason:`Circular reference detected: '${W0}' directly or indirectly references itself`},b0,"id",P0))}}}},T0=50,V7=(b,A=0)=>{if(A>T0){let r=b.tagName.toLowerCase(),D=R(r);X.push(I({type:"deep_nesting",element:r,value:String(A),reason:`Element nesting depth (${A}) exceeds ${T0} levels`},r,null,D));return}for(let r of b.children)if(i(r))V7(r,A+1)},S6=(b)=>{let A=b.tagName.toLowerCase();if(A==="defs"){let r=!1;for(let D of b.childNodes)if(i(D)){r=!0;break}if(!r){let D=R(A);X.push(I({type:"empty_defs",element:A,reason:"Empty <defs> element (can be removed)"},A,null,D))}}for(let r of b.children)if(i(r))S6(r)},S7=(b)=>{let A=b.tagName.toLowerCase();if(A==="lineargradient"||A==="radialgradient"){let r=Array.from(b.children).filter((D)=>i(D)&&D.tagName.toLowerCase()==="stop");if(r.length>=2){let D=-1;for(let J0 of r){let z0=J0.getAttribute("offset")||"0",W0=parseFloat(z0);if(z0.includes("%"))W0=W0/100;if(!isNaN(W0)&&W0<D){let O0=R(A);X.push(I({type:"gradient_stop_order",element:A,reason:`Gradient stops not in ascending offset order (${D} followed by ${W0})`},A,null,O0));break}if(!isNaN(W0))D=W0}}}for(let r of b.children)if(i(r))S7(r)},V6=1e4,AJ=(b)=>{let A=b.tagName.toLowerCase();if(A==="path"){let r=b.getAttribute("d");if(r){let D=r.match(/[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/g);if(D&&D.length>V6){let J0=R(A);X.push(I({type:"path_complexity",element:A,attr:"d",value:`${D.length} coordinates`,reason:`Path has ${D.length} coordinates (>${V6}), may cause slow rendering`},A,"d",J0))}}}for(let r of b.children)if(i(r))AJ(r)},EJ=(b)=>{let A=b.tagName.toLowerCase(),r=R(A),D=["href","xlink:href"];for(let J0 of D){let z0=b.getAttribute(J0);if(z0&&(z0.startsWith("http://")||z0.startsWith("https://")||z0.startsWith("//")))X.push(I({type:"external_resource",element:A,attr:J0,value:z0.length>60?z0.substring(0,60)+"...":z0,reason:"External resource reference detected (potential security/CORS issue)"},A,J0,r))}if(A==="style"&&b.textContent){let J0=b.textContent.match(/@import\s+url\s*\(\s*['"]?(https?:\/\/[^'")\s]+)/i);if(J0)X.push(I({type:"external_resource",element:A,value:J0[1],reason:"External CSS import detected in style element"},A,null,r))}for(let J0 of b.children)if(i(J0))EJ(J0)},TJ=(b)=>{let A=b.tagName.toLowerCase();if(A==="script"){let r=R(A);X.push(I({type:"script_content",element:A,reason:"Script element detected (potential security issue in untrusted SVGs)"},A,null,r))}for(let r of b.children)if(i(r))TJ(r)},bJ=(b)=>{let A=b.tagName.toLowerCase(),r=R(A);for(let D of b.getAttributeNames())if(qq.has(D.toLowerCase()))X.push(I({type:"event_handler",element:A,attr:D,reason:`Event handler attribute '${D}' detected (potential XSS vector)`},A,D,r));for(let D of b.children)if(i(D))bJ(D)},GZ=()=>{let b=!1,A=!1,r=!1,D=U.hasAttribute("lang")||U.hasAttribute("xml:lang"),J0=(b0)=>{for(let P0 of b0.children){if(!i(P0))continue;let u0=P0.tagName.toLowerCase();if(u0==="title")b=!0;if(u0==="desc")A=!0;if(u0==="text"||u0==="tspan"||u0==="textpath")r=!0;J0(P0)}};if(J0(U),!b)X.push(I({type:"missing_title",element:"svg",reason:"Missing <title> element (recommended for accessibility)"},"svg",null,0));let z0=0,W0=(b0)=>{z0++;for(let P0 of b0.children)if(i(P0))W0(P0)};if(W0(U),!A&&z0>10)X.push(I({type:"missing_desc",element:"svg",reason:`Missing <desc> element (recommended for complex SVGs with ${z0} elements)`},"svg",null,0));if(r&&!D)X.push(I({type:"missing_lang",element:"svg",reason:"Missing lang attribute on SVG with text content"},"svg",null,0));let O0=(b0)=>{let P0=b0.tagName.toLowerCase(),u0=R(P0);for(let e0 of b0.getAttributeNames()){if(e0.startsWith("aria-")&&!Wq.has(e0.toLowerCase()))X.push(I({type:"invalid_aria",element:P0,attr:e0,reason:`Unknown ARIA attribute '${e0}'`},P0,e0,u0));if(e0==="role"){let o0=b0.getAttribute("role");if(o0&&!iK.has(o0.toLowerCase()))X.push(I({type:"invalid_aria",element:P0,attr:"role",value:o0,reason:`Invalid role value '${o0}' (valid: ${Array.from(iK).slice(0,5).join(", ")}...)`},P0,"role",u0))}if(e0==="aria-hidden"){let o0=b0.getAttribute("aria-hidden");if(o0&&o0!=="true"&&o0!=="false")X.push(I({type:"invalid_aria",element:P0,attr:"aria-hidden",value:o0,reason:`aria-hidden must be 'true' or 'false', got '${o0}'`},P0,"aria-hidden",u0))}}for(let e0 of b0.children)if(i(e0))O0(e0)};B(),O0(U)};B(),x(U),y(),B(),T(U),B(),c(U),B(),u(U),B(),a(U),B(),H0(U),B(),E(U),B(),t(U),B(),$0(U),B(),U0(U),B(),y0(U),B(),K0(U),B(),M0(U),B(),N0(U),B(),P(U),B(),q0(U),B(),L0(U),B(),E0(),B(),V7(U),B(),S6(U),B(),S7(U),B(),AJ(U),B(),EJ(U),B(),TJ(U),B(),bJ(U),GZ();let C7=null;if(z&&U){C7=bK(U,{strict:!0,warnFlowText:!0,checkPolyfillNeeds:!0});for(let b of C7.issues){let A=R0.INFO;if(b.severity===K7.ERROR)A=R0.ERROR;else if(b.severity===K7.WARNING)A=R0.WARNING;X.push({type:`inkscape-${b.type}`,reason:b.message,severity:A,line:b.line||1,column:b.column||1,element:b.element||null,attribute:b.attribute||null,context:b.context||null})}}X.sort((b,A)=>{if(b.line!==A.line)return b.line-A.line;return b.column-A.column});let q$=X;if(Z)q$=X.filter((b)=>b.severity===R0.ERROR);let W9=X.filter((b)=>b.severity===R0.ERROR).length,fJ=X.filter((b)=>b.severity===R0.WARNING).length,j9={};for(let b of q$)j9[b.type]=(j9[b.type]||0)+1;let c7={issues:q$,isValid:W9===0,hasErrors:W9>0,hasWarnings:fJ>0,errorCount:W9,warningCount:fJ,issueCount:q$.length,summary:j9};if(C7)c7.inkscape={isInkscapeDocument:C7.isInkscape,inkscapeVersion:C7.version||null,polyfillsNeeded:C7.polyfillsNeeded||[],hasFlowText:C7.hasFlowText||!1,inkscapeIssueCount:C7.issues.length,inkscapeErrorCount:C7.summary.errors,inkscapeWarningCount:C7.summary.warnings};if(K)try{let b=await import("node:fs/promises"),A=await Promise.resolve().then(() => (P6(),I6)),r;switch(Q){case"json":r=JSON.stringify(c7,null,2);break;case"yaml":r=Fq(c7);break;case"xml":r=_q(c7);break;case"text":default:r=Gq(c7);break}let D=A.normalize(K);await b.writeFile(D,r,"utf8"),c7.outputFile=D}catch(b){c7.exportError=`Failed to write report to '${K}': ${b.message}`}return c7}function Gq($){let J=["=".repeat(60),"SVG VALIDATION REPORT","=".repeat(60),"",`Status: ${$.isValid?"VALID":"INVALID"}`,`Errors: ${$.errorCount}`,`Warnings: ${$.warningCount}`,`Total Issues: ${$.issueCount}`,""];if($.issues.length>0){J.push("-".repeat(60)),J.push("ISSUES:"),J.push("-".repeat(60)),J.push("");for(let Z of $.issues){let K=Z.severity.toUpperCase(),Q=`${Z.line}:${Z.column}`;if(J.push(`[${K}] Line ${Q}: ${Z.type}`),Z.element)J.push(` Element: <${Z.element}>`);if(Z.attr)J.push(` Attribute: ${Z.attr}`);if(Z.value)J.push(` Value: ${Z.value}`);if(J.push(` ${Z.reason}`),Z.sourceLine)J.push(` Source: ${Z.sourceLine.trim()}`);J.push("")}}J.push("=".repeat(60)),J.push("SUMMARY BY TYPE:"),J.push("-".repeat(60));for(let[Z,K]of Object.entries($.summary))J.push(` ${Z}: ${K}`);return J.push("=".repeat(60)),J.join(`
353
+ `)}function Fq($){let J=["validation_result:",` is_valid: ${$.isValid}`,` has_errors: ${$.hasErrors}`,` has_warnings: ${$.hasWarnings}`,` error_count: ${$.errorCount}`,` warning_count: ${$.warningCount}`,` issue_count: ${$.issueCount}`,""," summary:"];for(let[K,Q]of Object.entries($.summary))J.push(` ${K}: ${Q}`);J.push(""),J.push(" issues:");let Z=(K)=>String(K).replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t");for(let K of $.issues){if(J.push(` - type: ${K.type}`),J.push(` severity: ${K.severity}`),J.push(` line: ${K.line}`),J.push(` column: ${K.column}`),K.element)J.push(` element: "${Z(K.element)}"`);if(K.attr)J.push(` attr: "${Z(K.attr)}"`);if(K.value)J.push(` value: "${Z(K.value)}"`);if(J.push(` reason: "${Z(K.reason)}"`),K.sourceLine)J.push(` source_line: "${Z(K.sourceLine)}"`)}return J.join(`
354
+ `)}function _q($){let J=(K)=>String(K).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;"),Z=['<?xml version="1.0" encoding="UTF-8"?>',"<validation_result>",` <is_valid>${$.isValid}</is_valid>`,` <has_errors>${$.hasErrors}</has_errors>`,` <has_warnings>${$.hasWarnings}</has_warnings>`,` <error_count>${$.errorCount}</error_count>`,` <warning_count>${$.warningCount}</warning_count>`,` <issue_count>${$.issueCount}</issue_count>`," <summary>"];for(let[K,Q]of Object.entries($.summary))Z.push(` <${K}>${Q}</${K}>`);Z.push(" </summary>"),Z.push(" <issues>");for(let K of $.issues){if(Z.push(" <issue>"),Z.push(` <type>${J(K.type)}</type>`),Z.push(` <severity>${J(K.severity)}</severity>`),Z.push(` <line>${K.line}</line>`),Z.push(` <column>${K.column}</column>`),K.element)Z.push(` <element>${J(K.element)}</element>`);if(K.attr)Z.push(` <attr>${J(K.attr)}</attr>`);if(K.value)Z.push(` <value>${J(K.value)}</value>`);if(Z.push(` <reason>${J(K.reason)}</reason>`),K.sourceLine)Z.push(` <source_line>${J(K.sourceLine)}</source_line>`);Z.push(" </issue>")}return Z.push(" </issues>"),Z.push("</validation_result>"),Z.join(`
355
+ `)}function zZ($){let J=1;for(let Z of $.children)if(i(Z))J+=zZ(Z);return J}var LJ=G0(async($,J={})=>{let Z=N7($,{minify:J.minify!==!1}),K=await N6(Z,{precision:J.precision||6,curveSegments:J.curveSegments||20,resolveUse:!0,resolveMarkers:!0,resolvePatterns:!0,resolveMasks:!0,resolveClipPaths:!0,flattenTransforms:!0,bakeGradients:!0,removeUnusedDefs:!0,...J});return p0(K.svg)}),kJ=G0(($,J={})=>{let Z=$.getElementsByTagName("path");for(let K of Z){let Q=K.getAttribute("d");if(!Q)continue;try{let H=g6(Q),z=C9(H,J.precision||6);K.setAttribute("d",z)}catch(H){console.warn(`Failed to simplify path: ${H.message}`,{pathData:Q.substring(0,100)})}}return $}),wJ=G0(($,J={})=>{return vK($,{precision:J.precision??3,removeLinearSplines:J.removeLinearSplines!==!1,optimizeValues:J.optimizeValues!==!1}),$}),RJ=G0(($,J={})=>{return DK($,{floatPrecision:J.floatPrecision??J.precision??3,straightCurves:J.straightCurves!==!1,lineShorthands:J.lineShorthands!==!1,convertToZ:J.convertToZ!==!1,utilizeAbsolute:J.utilizeAbsolute!==!1,straightTolerance:J.straightTolerance??0.5}),$}),BJ=G0(($,J={})=>{let Z=J.tolerance??1,K=J.algorithm??"douglas-peucker",Q=J.respectStroke!==!1,H=t7($),z=(q)=>{if(q.tagName?.toLowerCase()==="path"){let W=q.getAttribute("d");if(W){let G=Z;if(Q){let U=p6(q),M=d6(q,U,H);if(M.hasStroke&&M.strokeWidth.greaterThan(0)){let V=M.strokeWidth.div(4).toNumber();G=Math.min(Z,V)}}let F=n0(W),_=z8(F,G,K);if(_.simplified){let U=s0(_.commands,J.precision??3);q.setAttribute("d",U)}}}for(let W of q.children||[])z(W)};return z($),$}),NJ=G0(($,J={})=>{let Z=(K)=>{let Q=K.getAttribute("transform");if(Q){let H=J7(Q),z=tJ(H);K.setAttribute("data-decomposed",JSON.stringify({translateX:z.translateX.toNumber(),translateY:z.translateY.toNumber(),rotation:z.rotation.toNumber(),scaleX:z.scaleX.toNumber(),scaleY:z.scaleY.toNumber(),skewX:z.skewX.toNumber()}))}for(let H of K.children)if(i(H))Z(H)};return Z($),$});function t$($,J){let Z=$.tagName.toLowerCase();try{if(Z==="path"){let K=$.getAttribute("d");if(!K)return null;let Q=g6(K),H=[],z=0,q=0;for(let j of Q)if(j.command==="M"||j.command==="L")z=j.args[0].toNumber(),q=j.args[1].toNumber(),H.push({x:z,y:q});return H}if(Z==="rect"){let K=$.getAttribute("x")||"0",Q=$.getAttribute("y")||"0",H=$.getAttribute("width")||"0",z=$.getAttribute("height")||"0";if(p7(K)||p7(Q)||p7(H)||p7(z))return null;let q=parseFloat(K),j=parseFloat(Q),W=parseFloat(H),G=parseFloat(z);if(isNaN(q)||isNaN(j)||isNaN(W)||isNaN(G))return null;return[{x:q,y:j},{x:q+W,y:j},{x:q+W,y:j+G},{x:q,y:j+G}]}if(Z==="circle"){let K=parseFloat($.getAttribute("cx")||"0"),Q=parseFloat($.getAttribute("cy")||"0"),H=parseFloat($.getAttribute("r")||"0");if(isNaN(K)||isNaN(Q)||isNaN(H))return null;let z=[];for(let q=0;q<J;q++){let j=q/J*2*Math.PI;z.push({x:K+H*Math.cos(j),y:Q+H*Math.sin(j)})}return z}return null}catch(K){return console.warn(`getShapePolygon failed for ${Z}:`,K.message),null}}var Uq={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".webp":"image/webp",".avif":"image/avif",".ico":"image/x-icon",".bmp":"image/bmp",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject",".wav":"audio/wav",".mp3":"audio/mpeg",".ogg":"audio/ogg",".m4a":"audio/mp4",".aac":"audio/aac",".flac":"audio/flac",".webm":"audio/webm",".mp4":"video/mp4",".ogv":"video/ogg",".mov":"video/quicktime",".css":"text/css",".js":"text/javascript"};function CJ(){return typeof process!=="undefined"&&process.versions?.node}function rK($){if(!$||typeof $!=="string")return!1;if($.startsWith("#"))return!1;if($.startsWith("data:"))return!1;return!0}function Vq($){let J=$.indexOf("#");if(J===-1)return{path:$,fragment:null};return{path:$.substring(0,J),fragment:$.substring(J+1)}}function e$($){let J=($.match(/\.[a-z0-9]+$/i)||[""])[0].toLowerCase();return Uq[J]||"application/octet-stream"}function m7($,J){if(!$)return $;if($.match(/^https?:\/\//i))return $;if($.startsWith("data:"))return $;if($.startsWith("file://"))return $;if(!J)return $;if(J.match(/^https?:\/\//i))try{return new URL($,J).href}catch(K){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${K.message}`);return $}if(CJ())try{let K=(P6(),yJ(I6)),Q=J.endsWith("/")?J:K.dirname(J),H=K.resolve(Q,$),z=K.resolve(Q);if(!H.startsWith(z+K.sep)&&H!==z)return console.warn(`Path traversal blocked: ${$} escapes base directory`),$;return H}catch(K){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${K.message}`);let Q=J.endsWith("/")?J:J.substring(0,J.lastIndexOf("/")+1);if($.includes("..")||$.startsWith("/"))return console.warn(`Unsafe path pattern blocked in fallback: ${$}`),$;return Q+$}let Z=J.endsWith("/")?J:J.substring(0,J.lastIndexOf("/")+1);if($.includes("..")||$.startsWith("/"))return console.warn(`Unsafe path pattern blocked: ${$}`),$;return Z+$}async function d7($,J="text",Z=30000){if(CJ()&&!$.match(/^https?:\/\//i)){let H=await import("node:fs/promises");return{content:J==="binary"?await H.readFile($):await H.readFile($,"utf8"),contentType:e$($)}}let K=new AbortController,Q=setTimeout(()=>K.abort(),Z);try{let H=await fetch($,{signal:K.signal});if(!H.ok)throw new Error(`HTTP ${H.status}: ${H.statusText}`);let z=H.headers.get("content-type")||e$($);return{content:J==="binary"?await H.arrayBuffer():await H.text(),contentType:z}}finally{clearTimeout(Q)}}function e6($,J){let Z;if(CJ())Z=Buffer.from($).toString("base64");else{let K=new Uint8Array($),Q="";for(let H=0;H<K.length;H++)Q+=String.fromCharCode(K[H]);Z=btoa(Q)}return`data:${J};base64,${Z}`}function G8($){let J=[],Z=[],K=/@import\s+(?:url\(\s*["']?([^"')]+)["']?\s*\)|["']([^"']+)["'])/gi,Q,H=0;while((Q=K.exec($))!==null){if(Q.index===H&&Q[0].length===0){console.error("Regex matched empty string in @import, breaking to prevent infinite loop");break}H=Q.index+Math.max(1,Q[0].length),J.push({url:Q[1]||Q[2],fullMatch:Q[0],index:Q.index})}let z=/url\(\s*["']?([^"')]+)["']?\s*\)/gi,q=0;while((Q=z.exec($))!==null){if(Q.index===q&&Q[0].length===0){console.error("Regex matched empty string in url(), breaking to prevent infinite loop");break}if(q=Q.index+Math.max(1,Q[0].length),$.substring(Math.max(0,Q.index-10),Q.index).includes("@import"))continue;if(Q[1].startsWith("#"))continue;if(Q[1].startsWith("data:"))continue;Z.push({url:Q[1],fullMatch:Q[0],index:Q.index})}return{imports:J,urls:Z}}function U8($,J,Z=new Map){if(!$)return Z;let K=$.getAttribute?.("id");if(K){let z=J+K;Z.set(K,z),$.setAttribute("id",z)}let Q=["href","xlink:href","fill","stroke","clip-path","mask","filter","marker-start","marker-mid","marker-end"];for(let z of Q){let q=$.getAttribute?.(z);if(!q)continue;if(q.includes("url(#")){let j=q.replace(/url\(#([^)]+)\)/g,(W,G)=>{return`url(#${Z.get(G)||J+G})`});$.setAttribute(z,j)}else if(q.startsWith("#")){let j=q.substring(1);$.setAttribute(z,"#"+(Z.get(j)||J+j))}}let H=$.getAttribute?.("style");if(H&&H.includes("url(#")){let z=H.replace(/url\(#([^)]+)\)/g,(q,j)=>{return`url(#${Z.get(j)||J+j})`});$.setAttribute("style",z)}if($.children)for(let z of $.children)U8(z,J,Z);return Z}function qZ($,J,Z){if(!$){console.warn("setCDATAContent called with null element");return}let K=0,Q=1e4;while($.firstChild&&K++<Q){let z=$.firstChild;if($.removeChild(z),$.firstChild===z){console.error("removeChild failed to remove child in setCDATAContent, breaking to prevent infinite loop");break}}if(K>=Q)console.error(`Safety limit reached in setCDATAContent: ${Q} children processed`);let H=J.includes("<")||J.includes("&")||J.includes("]]>");if(H&&typeof Z.createCDATASection==="function")if(J.includes("]]>")){let z=J.split("]]>");for(let q=0;q<z.length;q++)if(q===0)$.appendChild(Z.createCDATASection(z[q]+"]]"));else if(q===z.length-1)$.appendChild(Z.createCDATASection(">"+z[q]));else $.appendChild(Z.createCDATASection(">"+z[q]+"]]"))}else $.appendChild(Z.createCDATASection(J));else if(H){let z=J.replace(/\]\]>/g,"]]]]><![CDATA[>");$.setAttribute("data-cdata-pending","true"),$.textContent=z}else $.textContent=J}var Mq={audio:[".wav",".mp3",".ogg",".webm",".m4a",".aac",".flac"],image:[".png",".jpg",".jpeg",".gif",".svg",".webp",".avif",".ico",".bmp"],video:[".mp4",".webm",".ogv",".avi",".mov"],data:[".json",".xml",".txt",".csv",".tsv"],font:[".woff",".woff2",".ttf",".otf",".eot"]},Oq=Object.values(Mq).flat();function Yq($){let J=new Set,Z=Oq.map((H)=>H.replace(".","\\.")).join("|"),K=new RegExp(`["'\`]([^"'\`]*(?:${Z}))["'\`]`,"gi"),Q;while((Q=K.exec($))!==null){let H=Q[1];if(H&&!H.startsWith("data:")&&!H.match(/^https?:\/\/(?!localhost)/)&&H.length>0)J.add(H)}return J}function Xq($){if($.size===0)return"";let J={};for(let[Z,K]of $)J[Z]=K;return`
356
356
  // ===== EMBEDDED RESOURCES INTERCEPTOR (auto-generated) =====
357
357
  (function() {
358
358
  var __EMBEDDED_RESOURCES__ = ${JSON.stringify(J,null,0)};
@@ -489,5 +489,5 @@ ${z}
489
489
  })();
490
490
  // ===== END EMBEDDED RESOURCES INTERCEPTOR =====
491
491
 
492
- `}function Zq($){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 Qq($){let J=[...$].sort().join("");return encodeURIComponent(J)}function Hq($){return $&&($.includes("fonts.googleapis.com")||$.includes("fonts.gstatic.com"))}function zq($){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 qq($,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 H9=j0(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,b=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||!uK(p))continue;try{let N=g7(p,Z),{content:y,contentType:B}=await x7(N,"binary",O),e=a6(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||!uK(N))continue;let{path:y,fragment:B}=tz(N);if(!y)continue;let e=g7(y,Z);if(w.has(e)){R.push(`Circular reference detected: ${e}`);continue}w.add(e);try{let{content:r}=await x7(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 H9(s,{...J,basePath:e,maxRecursionDepth:U-1,_visitedURLs:w});b++;let T=`${Y}${b}_`;if(H==="extract"&&B){let P=s.getElementById(B);if(P){let t=P.clone?P.clone():JSON.parse(JSON.stringify(P));q8(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;q8(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?Zq($):null;for(let c=0;c<E.length;c++){let p=E[c],N=p.textContent||"";if(z){let{imports:y}=Q8(N);for(let B of y.reverse())try{let e=B.url;if(d&&Hq(e)){let P=zq(e);if(P&&d.has(P)){let t=Qq(d.get(P));if(e=qq(e,t),F)console.log(`Font subsetting: ${P} -> ${d.get(P).size} chars`)}}let r=g7(e,Z),{content:s}=await x7(r,"text",O),z0=s,T=Q8(s).imports;if(T.length>0)for(let P of T.reverse())try{let t=g7(P.url,r),$0=await x7(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}=Q8(N);for(let B of y.reverse()){let e=a$(B.url),r=e.startsWith("font/")||e.includes("fontobject");if(r&&!q)continue;if(!r&&!z)continue;try{let s=g7(B.url,Z),{content:z0,contentType:T}=await x7(s,"binary",O),t=`url("${a6(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=g7(p,Z),{content:y}=await x7(N,"text",O);c.removeAttribute("src"),c.removeAttribute("href"),c.removeAttribute("xlink:href"),iK(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=g7(p,Z),{content:B,contentType:e}=await x7(y,"binary",O),r=e.split(";")[0]||"audio/mpeg",s=a6(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=g7(B,Z),{content:r,contentType:s}=await x7(e,"binary",O),z0=s.split(";")[0]||y.getAttribute("type")||"audio/mpeg",T=a6(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=Jq(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=g7(B,Z),{content:r,contentType:s}=await x7(e,"binary",O),z0=s.split(";")[0]||a$(B),T=a6(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=Kq(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(B7($).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 $}),Wq={"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 $6($,J,Z,K=null){let Q=Wq[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 kJ($,J={}){let Z=A6($),K=await E6($,Z),Q=J.outputFormat||(Z===S0.DOM_ELEMENT?W7.DOM_ELEMENT:W7.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,b=(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(() => (I6(),N6));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(!b(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=$6(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(!b(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=$6(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=$6(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(!b(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=$6(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=$6(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(!b(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=$6(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(!b(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=$6(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');
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=$6(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");iK(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 jq={MAX_PRECISION:P6,DEFAULT_PRECISION:t6,PRECISION_LEVELS:W8,formatPrecision:G8,InputType:S0,OutputFormat:W7,OutputTarget:q7,detectInputType:A6,detectOutputTarget:t$,loadInput:E6,generateOutput:T6,saveOutput:F8,createOperation:j0,cleanupIds:e$,cleanupNumericValues:e6,cleanupListOfValues:_8,cleanupAttributes:U8,cleanupEnableBackground:V8,removeUnknownsAndDefaults:M8,removeNonInheritableGroupAttrs:O8,removeUselessDefs:Y8,removeHiddenElements:$$,removeEmptyText:X8,removeEmptyContainers:J$,removeDoctype:k8,removeXMLProcInst:L8,removeComments:K$,removeMetadata:Z$,removeTitle:w8,removeDesc:R8,removeEditorsNSData:$9,removeEmptyAttrs:B8,removeViewBox:N8,removeXMLNS:I8,removeRasterImages:C8,removeScriptElement:P8,convertShapesToPath:A8,convertPathData:E8,convertTransform:T8,convertColors:Q$,convertStyleToAttrs:J9,convertEllipseToCircle:b8,collapseGroups:f8,mergePaths:S8,moveGroupAttrsToElems:v8,moveElemsAttrsToGroup:D8,minifyStyles:K9,inlineStyles:h8,sortAttrs:y8,sortDefsChildren:u8,reusePaths:g8,removeOffCanvasPath:x8,removeStyleElement:m8,removeXlink:d8,addAttributesToSVGElement:p8,addClassesToSVGElement:c8,prefixIds:l8,removeDimensions:n8,removeAttributesBySelector:s8,removeAttrs:o8,removeElementsByAttr:i8,presetDefault:Z9,presetNone:Q9,applyPreset:r8,optimize:a8,createConfig:t8,flattenClipPaths:e8,flattenMasks:$J,flattenGradients:JJ,flattenPatterns:KJ,flattenFilters:ZJ,flattenUseElements:QJ,imageToPath:HJ,detectCollisions:zJ,measureDistance:qJ,validateXML:WJ,validateSVG:jJ,fixInvalidSVG:FJ,ValidationSeverity:C0,flattenAll:_J,simplifyPath:UJ,decomposeTransform:YJ,optimizeAnimationTiming:VJ,optimizePaths:MJ,simplifyPaths:OJ,embedExternalDependencies:H9,exportEmbeddedResources:kJ,convertPathDataAdvanced:r9,parsePathCommands:l0,serializePathCommands:n0,formatPathNumber:T7,douglasPeucker:i6,visvalingamWhyatt:a9,simplifyPolyline:t9,simplifyPolylinePath:$8,isPurePolyline:e9,optimizeKeySplines:l9,optimizeKeyTimes:n9,optimizeAnimationValues:T$,formatSplineValue:o6,parseKeySplines:b$,serializeKeySplines:p9,isLinearSpline:f$,areAllSplinesLinear:wK,identifyStandardEasing:c9,STANDARD_EASINGS:d9,removeLeadingZero:v$,negativeExtraSpace:D$,convertToRelative:h$,convertToAbsolute:y$,lineShorthands:u$,convertToZ:g$,straightCurves:x$,collapseRepeated:m$,floatPrecision:d$,removeUselessCommands:p$,convertCubicToQuadratic:c$,convertQuadraticToSmooth:l$,convertCubicToSmooth:n$,arcShorthands:s$};var rK="1.3.4",aK={VERSION:rK,...LJ},Fq=aK;if(typeof window!=="undefined")window.SVGToolbox=aK;})();
492
+ `}function Lq($){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 j of H)q.add(j)},K=(Q)=>{if(!Q)return;let z=(Q.getAttribute?.("style")||"").match(/font-family:\s*([^;]+)/i),q=z?z[1]:null,j=Q.getAttribute?.("font-family"),W=Q.getAttribute?.("face"),G=q||j||W,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 M=(Q.parentNode.getAttribute?.("style")||"").match(/font-family:\s*([^;]+)/i);_=M?M[1]:Q.parentNode.getAttribute?.("font-family")}if(_&&F.trim())Z(_,F)}if(Q.children)for(let _ of Q.children)K(_)};return K($),J}function kq($){let J=[...$].sort().join("");return encodeURIComponent(J)}function wq($){return $&&($.includes("fonts.googleapis.com")||$.includes("fonts.gstatic.com"))}function Rq($){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 Bq($,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 q9=G0(async($,J={})=>{let{basePath:Z="",embedImages:K=!0,embedExternalSVGs:Q=!0,externalSVGMode:H="extract",embedCSS:z=!0,embedFonts:q=!0,embedScripts:j=!0,embedAudio:W=!1,subsetFonts:G=!0,verbose:F=!1,recursive:_=!0,maxRecursionDepth:U=10,timeout:M=30000,onMissingResource:V="warn",onProgress:Y=null,idPrefix:O="ext_",_visitedURLs:X=null}=J,w=X||new Set,R=[],B=new Map,I=0,h=(y)=>{if(!y||!y.attributes)return;let T=["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/"],p=y.attributes;for(let c=0;c<p.length;c++){let C=p[c];if(C.name.startsWith("xmlns:")){let u=C.name.substring(6),N=C.value;if(T.some((e)=>N.startsWith(e))||!d.includes(N))B.set(u,N)}}},m=(y,T)=>{let d=`Failed to fetch resource: ${y} - ${T.message}`;if(V==="fail")throw new Error(d);else if(V==="warn")R.push(d),console.warn("embedExternalDependencies:",d);return null};if(K){let T=[...$.getElementsByTagName("image")];if(Y)Y("images",0,T.length);for(let d=0;d<T.length;d++){let p=T[d],c=p.getAttribute("href")||p.getAttribute("xlink:href");if(!c||!rK(c))continue;try{let C=m7(c,Z),{content:u,contentType:N}=await d7(C,"binary",M),e=e6(u,N.split(";")[0]);if(p.getAttribute("href"))p.setAttribute("href",e);if(p.getAttribute("xlink:href"))p.setAttribute("xlink:href",e)}catch(C){m(c,C)}if(Y)Y("images",d+1,T.length)}}if(Q){let T=[...$.getElementsByTagName("use")];if(Y)Y("externalSVGs",0,T.length);let d=$.querySelector("defs");if(!d){let p=$.documentElement||$;if(!p){if(R.push("Cannot add defs: document has no root SVG element"),Y)Y("externalSVGs",T.length,T.length)}else if(d=new B0("defs",{},[]),typeof p.insertBefore==="function"&&p.firstChild)p.insertBefore(d,p.firstChild);else if(typeof p.appendChild==="function")p.appendChild(d);else if(p.children&&Array.isArray(p.children))p.children.unshift(d),d.parentNode=p}if(d)for(let p=0;p<T.length;p++){let c=T[p],C=c.getAttribute("href")||c.getAttribute("xlink:href");if(!C||!rK(C))continue;let{path:u,fragment:N}=Vq(C);if(!u)continue;let e=m7(u,Z);if(w.has(e)){R.push(`Circular reference detected: ${e}`);continue}w.add(e);try{let{content:a}=await d7(e,"text",M),s=p0(a);if(!s){m(u,new Error("Failed to parse SVG"));continue}let H0=s.documentElement||s;if(h(H0),_&&U>0)await q9(s,{...J,basePath:e,maxRecursionDepth:U-1,_visitedURLs:w});I++;let S=`${O}${I}_`;if(H==="extract"&&N){let E=s.getElementById(N);if(E){let t=E.clone?E.clone():JSON.parse(JSON.stringify(E));U8(t,S),d.children.push(t);let $0=S+N;if(c.getAttribute("href"))c.setAttribute("href","#"+$0);if(c.getAttribute("xlink:href"))c.setAttribute("xlink:href","#"+$0)}else m(C,new Error(`Fragment #${N} not found in ${u}`))}else{let E=s.documentElement||s;U8(E,S);let t=S+"svg";E.setAttribute("id",t),d.children.push(E);let $0=N?"#"+S+N:"#"+t;if(c.getAttribute("href"))c.setAttribute("href",$0);if(c.getAttribute("xlink:href"))c.setAttribute("xlink:href",$0)}}catch(a){m(u,a)}if(Y)Y("externalSVGs",p+1,T.length)}}if(z||q){let T=[...$.getElementsByTagName("style")];if(Y)Y("stylesheets",0,T.length);let d=G?Lq($):null;for(let p=0;p<T.length;p++){let c=T[p],C=c.textContent||"";if(z){let{imports:u}=G8(C);for(let N of u.reverse())try{let e=N.url;if(d&&wq(e)){let E=Rq(e);if(E&&d.has(E)){let t=kq(d.get(E));if(e=Bq(e,t),F)console.log(`Font subsetting: ${E} -> ${d.get(E).size} chars`)}}let a=m7(e,Z),{content:s}=await d7(a,"text",M),H0=s,S=G8(s).imports;if(S.length>0)for(let E of S.reverse())try{let t=m7(E.url,a),$0=await d7(t,"text",M);H0=H0.substring(0,E.index)+$0.content+H0.substring(E.index+E.fullMatch.length)}catch(t){m(E.url,t)}C=C.substring(0,N.index)+H0+C.substring(N.index+N.fullMatch.length)}catch(e){m(N.url,e)}}if(z||q){let{urls:u}=G8(C);for(let N of u.reverse()){let e=e$(N.url),a=e.startsWith("font/")||e.includes("fontobject");if(a&&!q)continue;if(!a&&!z)continue;try{let s=m7(N.url,Z),{content:H0,contentType:S}=await d7(s,"binary",M),t=`url("${e6(H0,S.split(";")[0])}")`;C=C.substring(0,N.index)+t+C.substring(N.index+N.fullMatch.length)}catch(s){m(N.url,s)}}}if(c.textContent=C,Y)Y("stylesheets",p+1,T.length)}}if(j){let T=[...$.getElementsByTagName("script")];if(Y)Y("scripts",0,T.length);for(let d=0;d<T.length;d++){let p=T[d],c=p.getAttribute("src")||p.getAttribute("href")||p.getAttribute("xlink:href");if(!c)continue;if(c.startsWith("data:"))continue;try{let C=m7(c,Z),{content:u}=await d7(C,"text",M);p.removeAttribute("src"),p.removeAttribute("href"),p.removeAttribute("xlink:href"),qZ(p,u,$)}catch(C){m(c,C)}if(Y)Y("scripts",d+1,T.length)}}if(W){let T=[...$.getElementsByTagName("audio")];if(Y)Y("audio",0,T.length);for(let d=0;d<T.length;d++){let p=T[d],c=p.getAttribute("src");if(c&&!c.startsWith("data:"))try{let u=m7(c,Z),{content:N,contentType:e}=await d7(u,"binary",M),a=e.split(";")[0]||"audio/mpeg",s=e6(N,a);p.setAttribute("src",s)}catch(u){m(c,u)}let C=p.getElementsByTagName("source");for(let u of C){let N=u.getAttribute("src");if(N&&!N.startsWith("data:"))try{let e=m7(N,Z),{content:a,contentType:s}=await d7(e,"binary",M),H0=s.split(";")[0]||u.getAttribute("type")||"audio/mpeg",S=e6(a,H0);u.setAttribute("src",S)}catch(e){m(N,e)}}if(Y)Y("audio",d+1,T.length)}}if(j){let y=[],T=$.getElementsByTagName("script");for(let C of T)if(C.textContent)y.push(C.textContent);let d=$.getElementsByTagName("style");for(let C of d)if(C.textContent)y.push(C.textContent);let p=$.getElementsByTagName("foreignObject");for(let C of p){let u=C.textContent||"";if(u)y.push(u)}let c=new Set;for(let C of y){let u=Yq(C);for(let N of u)c.add(N)}if(c.size>0){let C=new Map;if(Y)Y("resources",0,c.size);let u=0;for(let N of c){try{let e=m7(N,Z),{content:a,contentType:s}=await d7(e,"binary",M),H0=s.split(";")[0]||e$(N),S=e6(a,H0);if(C.set(N,S),F){let E=(a.length/1024).toFixed(1);console.log(`Embedded resource: ${N} (${E} KB)`)}}catch(e){m(N,e)}if(u++,Y)Y("resources",u,c.size)}if(C.size>0){let N=Xq(C),e=T[0];if(e){let a=e.textContent||"";if(N.includes("<")||N.includes("&")||a.includes("<")||a.includes("&"))e.setAttribute("data-cdata-pending","true");e.textContent=N+a}else{let a=$.createElement("script");a.setAttribute("type","text/javascript"),a.setAttribute("data-cdata-pending","true"),a.textContent=N;let s=$.documentElement||$;if(s.firstChild)s.insertBefore(a,s.firstChild);else s.appendChild(a)}if(F)console.log(`Injected resource interceptor for ${C.size} embedded resources`)}}}let v=$.documentElement||$;if(!v.getAttribute("xmlns"))v.setAttribute("xmlns","http://www.w3.org/2000/svg");if(N7($).includes("xlink:")&&!v.getAttribute("xmlns:xlink"))v.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink");for(let[y,T]of B){let d=`xmlns:${y}`;if(!v.getAttribute(d))v.setAttribute(d,T)}if(R.length>0)$._embedWarnings=R;return $}),Nq={"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 G6($){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 F6($){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 Z6($,J,Z,K=null){let Q=Nq[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 IJ($,J={}){let Z=T6($),K=await b6($,Z),Q=J.outputFormat||(Z===v0.DOM_ELEMENT?G7.DOM_ELEMENT:G7.SVG_STRING),{outputDir:H=null,filenamePrefix:z="resource",extractImages:q=!0,extractFonts:j=!0,extractScripts:W=!0,extractStyles:G=!0,extractAudio:F=!0,extractVideo:_=!0,elementIds:U=null,restoreGoogleFonts:M=!0,dryRun:V=!1,extractOnly:Y=!1,onProgress:O=null}=J,X=[],w=[],R=0,B=U?new Set(Array.isArray(U)?U:[U]):null,I=(v)=>{if(!B)return!0;let x=v;while(x&&x.getAttribute){let y=x.getAttribute("id");if(y&&B.has(y))return!0;x=x.parentNode}return!1},h=async(v,x,y)=>{let T=0;if(typeof Buffer!=="undefined"&&Buffer.isBuffer(x))T=x.length;else if(typeof Buffer!=="undefined")T=Buffer.byteLength(x,"utf8");else if(typeof Blob!=="undefined")T=new Blob([x]).size;else T=x.length||0;let d={filename:v,path:H?`${H}/${v}`:v,mimeType:y,size:T};if(!V&&H)try{let p=await import("node:fs/promises"),c=await Promise.resolve().then(() => (P6(),I6));await p.mkdir(H,{recursive:!0});let C=c.join(H,v);if(typeof Buffer!=="undefined"&&Buffer.isBuffer(x))await p.writeFile(C,x);else await p.writeFile(C,x,"utf8");d.path=C,X.push(d)}catch(p){w.push(`Failed to save ${v}: ${p.message}`),d.error=p.message}else X.push(d);return d};if(q){let x=[...K.getElementsByTagName("image")];if(O)O("images",0,x.length);for(let y=0;y<x.length;y++){let T=x[y];if(!I(T))continue;let d=T.getAttribute("href")||T.getAttribute("xlink:href");if(!d||!d.startsWith("data:"))continue;let p=G6(d);if(!p)continue;if(!p.mimeType.startsWith("image/"))continue;R++;let c=Z6(z,p.mimeType,R),C=F6(p),u=await h(c,C,p.mimeType);if(u.type="image",u.elementId=T.getAttribute("id"),!Y){let N=`./${c}`;if(T.getAttribute("href"))T.setAttribute("href",N);if(T.getAttribute("xlink:href"))T.setAttribute("xlink:href",N)}if(O)O("images",y+1,x.length)}}if(F){let x=[...K.getElementsByTagName("audio")];if(O)O("audio",0,x.length);for(let y=0;y<x.length;y++){let T=x[y];if(!I(T))continue;let d=T.getAttribute("src");if(d&&d.startsWith("data:")){let c=G6(d);if(c&&c.mimeType.startsWith("audio/")){R++;let C=Z6(z,c.mimeType,R),u=F6(c),N=await h(C,u,c.mimeType);if(N.type="audio",N.elementId=T.getAttribute("id"),!Y)T.setAttribute("src",`./${C}`)}}let p=T.getElementsByTagName("source");for(let c of p){let C=c.getAttribute("src");if(C&&C.startsWith("data:")){let u=G6(C);if(u&&u.mimeType.startsWith("audio/")){R++;let N=Z6(z,u.mimeType,R),e=F6(u),a=await h(N,e,u.mimeType);if(a.type="audio",!Y)c.setAttribute("src",`./${N}`)}}}if(O)O("audio",y+1,x.length)}}if(_){let x=[...K.getElementsByTagName("video")];if(O)O("video",0,x.length);for(let y=0;y<x.length;y++){let T=x[y];if(!I(T))continue;let d=T.getAttribute("src");if(d&&d.startsWith("data:")){let c=G6(d);if(c&&c.mimeType.startsWith("video/")){R++;let C=Z6(z,c.mimeType,R),u=F6(c),N=await h(C,u,c.mimeType);if(N.type="video",N.elementId=T.getAttribute("id"),!Y)T.setAttribute("src",`./${C}`)}}let p=T.getElementsByTagName("source");for(let c of p){let C=c.getAttribute("src");if(C&&C.startsWith("data:")){let u=G6(C);if(u&&u.mimeType.startsWith("video/")){R++;let N=Z6(z,u.mimeType,R),e=F6(u),a=await h(N,e,u.mimeType);if(a.type="video",!Y)c.setAttribute("src",`./${N}`)}}}if(O)O("video",y+1,x.length)}}if(W){let x=[...K.getElementsByTagName("script")];if(O)O("scripts",0,x.length);for(let y=0;y<x.length;y++){let T=x[y];if(!I(T))continue;let d=T.getAttribute("href")||T.getAttribute("xlink:href");if(d&&!d.startsWith("data:"))continue;let p="";if(d&&d.startsWith("data:")){let u=G6(d);if(u){let N=F6(u);p=typeof N==="string"?N:N.toString("utf8")}}else if(p=T.textContent||"",T.firstChild&&T.firstChild.nodeType===4)p=T.firstChild.nodeValue||"";if(!p.trim())continue;R++;let c=Z6(z,"application/javascript",R),C=await h(c,p,"application/javascript");if(C.type="script",C.elementId=T.getAttribute("id"),!Y){let u=0;while(T.firstChild&&u++<1e4){let N=T.firstChild;if(T.removeChild(N),T.firstChild===N)break}if(u>=1e4)console.error("Safety limit reached removing script children: 10000 iterations");T.setAttribute("href",`./${c}`)}if(O)O("scripts",y+1,x.length)}}if(G||j){let x=[...K.getElementsByTagName("style")];if(O)O("styles",0,x.length);for(let y=0;y<x.length;y++){let T=x[y];if(!I(T))continue;let d=T.textContent||"";if(T.firstChild&&T.firstChild.nodeType===4)d=T.firstChild.nodeValue||"";if(!d.trim())continue;let p=!1;if(j){let c=/@font-face\s*\{[^}]*\}/gi,C=d.match(c)||[];for(let u of C){let N=u.match(/src:\s*url\(["']?(data:[^"')]+)["']?\)/);if(N){let e=N[1],a=G6(e);if(a){R++;let s=Z6(z,a.mimeType,R),H0=F6(a),S=await h(s,H0,a.mimeType);S.type="font";let E=u.match(/font-family:\s*["']?([^"';]+)["']?/);if(E)S.fontFamily=E[1].trim();if(!Y)d=d.replace(e,`./${s}`),p=!0}}}if(M){let u=[],N=/font-family:\s*["']?([^"';,]+)/gi,e;while((e=N.exec(d))!==null){let a=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((H0)=>a.toLowerCase().includes(H0.toLowerCase())))u.push(a)}if(u.length>0&&!Y){let a=[...new Set(u)],s=`@import url('https://fonts.googleapis.com/css2?family=${a.map((H0)=>H0.replace(/\s+/g,"+")).join("&family=")}&display=swap');
493
+ `;if(!d.includes("fonts.googleapis.com"))d=s+d,p=!0,w.push(`Restored Google Fonts import for: ${a.join(", ")}`)}}}if(G&&d.trim()){R++;let c=Z6(z,"text/css",R),C=await h(c,d,"text/css");if(C.type="stylesheet",C.elementId=T.getAttribute("id"),!Y){let u=0;while(T.firstChild&&u++<1e4){let N=T.firstChild;if(T.removeChild(N),T.firstChild===N)break}if(u>=1e4)console.error("Safety limit reached removing style children: 10000 iterations");T.textContent=`@import url('./${c}');`,p=!0}}else if(p&&!Y){let c=0;while(T.firstChild&&c++<1e4){let C=T.firstChild;if(T.removeChild(C),T.firstChild===C)break}if(c>=1e4)console.error("Safety limit reached updating style children: 10000 iterations");qZ(T,d,K)}if(O)O("styles",y+1,x.length)}}if(!Y){if(K._exportedResources=X,w.length>0)K._exportWarnings=w}return{doc:Y?null:f6(K,Q,J),extractedFiles:X,warnings:w,summary:{totalExtracted:X.length,images:X.filter((v)=>v.type==="image").length,audio:X.filter((v)=>v.type==="audio").length,video:X.filter((v)=>v.type==="video").length,scripts:X.filter((v)=>v.type==="script").length,fonts:X.filter((v)=>v.type==="font").length,stylesheets:X.filter((v)=>v.type==="stylesheet").length,totalSize:X.reduce((v,x)=>v+x.size,0)}}}var Cq={MAX_PRECISION:E6,DEFAULT_PRECISION:$$,PRECISION_LEVELS:V8,formatPrecision:O8,InputType:v0,OutputFormat:G7,OutputTarget:j7,detectInputType:T6,detectOutputTarget:$9,loadInput:b6,generateOutput:f6,saveOutput:Y8,createOperation:G0,cleanupIds:J9,cleanupNumericValues:J$,cleanupListOfValues:X8,cleanupAttributes:L8,cleanupEnableBackground:k8,removeUnknownsAndDefaults:w8,removeNonInheritableGroupAttrs:R8,removeUselessDefs:B8,removeHiddenElements:K$,removeEmptyText:N8,removeEmptyContainers:Z$,removeDoctype:C8,removeXMLProcInst:I8,removeComments:Q$,removeMetadata:H$,removeTitle:P8,removeDesc:A8,removeEditorsNSData:K9,removeEmptyAttrs:E8,removeViewBox:b8,removeXMLNS:f8,removeRasterImages:S8,removeScriptElement:v8,convertToPlainSVG:T8,convertShapesToPath:D8,convertPathData:h8,convertTransform:y8,convertColors:z$,convertStyleToAttrs:Z9,convertEllipseToCircle:u8,collapseGroups:g8,mergePaths:x8,moveGroupAttrsToElems:m8,moveElemsAttrsToGroup:d8,minifyStyles:Q9,inlineStyles:p8,sortAttrs:c8,sortDefsChildren:l8,reusePaths:n8,removeOffCanvasPath:s8,removeStyleElement:o8,removeXlink:i8,addAttributesToSVGElement:r8,addClassesToSVGElement:a8,prefixIds:t8,removeDimensions:e8,removeAttributesBySelector:$J,removeAttrs:JJ,removeElementsByAttr:KJ,presetDefault:H9,presetNone:z9,applyPreset:ZJ,optimize:QJ,createConfig:HJ,flattenClipPaths:zJ,flattenMasks:qJ,flattenGradients:WJ,flattenPatterns:jJ,flattenFilters:GJ,flattenUseElements:FJ,imageToPath:_J,detectCollisions:UJ,measureDistance:VJ,validateXML:MJ,validateSVG:OJ,fixInvalidSVG:XJ,ValidationSeverity:R0,flattenAll:LJ,simplifyPath:kJ,decomposeTransform:NJ,optimizeAnimationTiming:wJ,optimizePaths:RJ,simplifyPaths:BJ,embedExternalDependencies:q9,exportEmbeddedResources:IJ,convertPathDataAdvanced:K8,parsePathCommands:n0,serializePathCommands:s0,formatPathNumber:f7,douglasPeucker:a6,visvalingamWhyatt:Z8,simplifyPolyline:Q8,simplifyPolylinePath:z8,isPurePolyline:H8,optimizeKeySplines:a9,optimizeKeyTimes:t9,optimizeAnimationValues:f$,formatSplineValue:r6,parseKeySplines:S$,serializeKeySplines:i9,isLinearSpline:v$,areAllSplinesLinear:SK,identifyStandardEasing:r9,STANDARD_EASINGS:o9,removeLeadingZero:h$,negativeExtraSpace:y$,convertToRelative:u$,convertToAbsolute:g$,lineShorthands:x$,convertToZ:m$,straightCurves:d$,collapseRepeated:p$,floatPrecision:c$,removeUselessCommands:l$,convertCubicToQuadratic:n$,convertQuadraticToSmooth:s$,convertCubicToSmooth:o$,arcShorthands:i$};var WZ="1.3.6",jZ={VERSION:WZ,...PJ},Pq=jZ;if(typeof window!=="undefined")window.SVGToolbox=jZ;})();