@emasoft/svg-matrix 1.3.1 → 1.3.2

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,4 +1,4 @@
1
- /*! svg-matrix v1.3.1 | MIT License | https://github.com/Emasoft/svg-matrix */
1
+ /*! svg-matrix v1.3.2 | MIT License | https://github.com/Emasoft/svg-matrix */
2
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});/*!
3
3
  * decimal.js v10.6.0
4
4
  * An arbitrary-precision Decimal type for JavaScript.
@@ -14,7 +14,7 @@ ${this.textContent}
14
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
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(`
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(_),f=X.mul(X),u=w.mul(w),m=f.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(f));if(S=S.div(R.mul(u).plus(I.mul(f))),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 i0(-z*X,-q*w).mul(w7(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 i0(O,V).mul(w7(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=i0($.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(i0(G-Q.x*j,F-Q.y*j)),K=K.mul(w7(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(i0(Z.x,Z.y)),K=K.mul(w7(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 _=i0(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=i0(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 X=O6(O);_=_.mul(X)}let V=1,M=1;if(G==="strokeWidth")V=K,M=K;if(F){let{width:X,height:w}=F;if(X>0&&w>0&&isFinite(X)&&isFinite(w)){let R=H/X,I=z/w;if(isFinite(R)&&isFinite(I)){let f=Math.min(R,I);V*=f,M*=f;let u=i0(-F.x,-F.y);_=_.mul(u)}}}if(V!==1||M!==1){let X=w7(V,M);_=_.mul(X)}let Y=i0(-q,-W);return _=_.mul(Y),_}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 Y7=($)=>$ 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 f=l6(q);for(let[m,S]of Object.entries(f))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 f=w6(I,Z.precision);if(f)O+=(O?" ":"")+f}}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:Y7(I.x),y:I.y instanceof k?I.y:Y7(I.y)})),R=Y.map((I)=>({x:I.x instanceof k?I.x:Y7(I.x),y:I.y instanceof k?I.y:Y7(I.y)}));if(X&&X.length>2){let I=X.map((x)=>({x:x.x instanceof k?x.x:Y7(x.x),y:x.y instanceof k?x.y:Y7(x.y)})),f=$K(w,R,I);if(K.verifications.polygons.push({element:q.tagName,clipPathId:j,...f}),f.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),f=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),f=u}f.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:Y7(V.x),y:V.y instanceof k?V.y:Y7(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:Y7((Q+z)/2),y:Y7((H+q)/2)};let U=((Q-W)*(j-F)-(H-j)*(W-G))/_;return{x:Y7(Q+U*(z-Q)),y:Y7(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+$/,"");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}}k.set({precision:80});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 X7($,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=X7(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=X7(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=X7(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=X7(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=X7(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 _=X7(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=X7(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=X7(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=X7(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=X7(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=X7(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
+ `;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(_),f=X.mul(X),u=w.mul(w),m=f.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(f));if(S=S.div(R.mul(u).plus(I.mul(f))),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 i0(-z*X,-q*w).mul(w7(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 i0(O,V).mul(w7(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=i0($.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(i0(G-Q.x*j,F-Q.y*j)),K=K.mul(w7(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(i0(Z.x,Z.y)),K=K.mul(w7(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 _=i0(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=i0(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 X=O6(O);_=_.mul(X)}let V=1,M=1;if(G==="strokeWidth")V=K,M=K;if(F){let{width:X,height:w}=F;if(X>0&&w>0&&isFinite(X)&&isFinite(w)){let R=H/X,I=z/w;if(isFinite(R)&&isFinite(I)){let f=Math.min(R,I);V*=f,M*=f;let u=i0(-F.x,-F.y);_=_.mul(u)}}}if(V!==1||M!==1){let X=w7(V,M);_=_.mul(X)}let Y=i0(-q,-W);return _=_.mul(Y),_}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 Y7=($)=>$ 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 f=l6(q);for(let[m,S]of Object.entries(f))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 f=w6(I,Z.precision);if(f)O+=(O?" ":"")+f}}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:Y7(I.x),y:I.y instanceof k?I.y:Y7(I.y)})),R=Y.map((I)=>({x:I.x instanceof k?I.x:Y7(I.x),y:I.y instanceof k?I.y:Y7(I.y)}));if(X&&X.length>2){let I=X.map((x)=>({x:x.x instanceof k?x.x:Y7(x.x),y:x.y instanceof k?x.y:Y7(x.y)})),f=$K(w,R,I);if(K.verifications.polygons.push({element:q.tagName,clipPathId:j,...f}),f.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),f=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),f=u}f.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:Y7(V.x),y:V.y instanceof k?V.y:Y7(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:Y7((Q+z)/2),y:Y7((H+q)/2)};let U=((Q-W)*(j-F)-(H-j)*(W-G))/_;return{x:Y7(Q+U*(z-Q)),y:Y7(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 X7($,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=X7(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=X7(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=X7(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=X7(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=X7(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 _=X7(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=X7(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=X7(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=X7(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=X7(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=X7(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[
18
18
  ${z}
19
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,f=Array.from($.querySelectorAll("style")).some((u)=>u.textContent&&u.textContent.trim().length>0);if(I||f)return $}let q=(I)=>{if(H.includes(I))return!0;if(z.some((f)=>I.startsWith(f)))return!0;return!1},W=(I)=>{try{return decodeURI(I)}catch(f){if(process.env.DEBUG)console.warn(`[svg-toolbox] ${f.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 f=I.getAttribute("id");if(f){if(!F.has(f))F.set(f,I)}for(let u of I.children)if(a(u))_(u)};_($);let U=new Set,O=new Set,V=(I)=>{let f=I.getAttribute("id");if(f){if(U.has(f))O.add(f);U.add(f)}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 f=I.getAttribute("id");if(f){if(O.has(f)){if(M.has(f)){I.removeAttribute("id");return}M.add(f)}let u=W(f),m=G.has(f)||G.has(u);if(q(f));else if(!m&&K)I.removeAttribute("id");else if(Z&&m){let S=w();if(Y.set(f,S),u!==f)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 f=(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=f(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 f=U[Y.tagName.toLowerCase()]||{};for(let[u,m]of Object.entries(f))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 f of q6){let u=Y.getAttribute(f);if(u!==null)w[f]=u}let R=Y.tagName.toLowerCase(),I=s6[R]||s6[G(R)];for(let f of[...Y.children])if(a(f)){if(f.tagName.includes(":"))continue;let u=f.tagName.toLowerCase(),m=f.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(f)&&!S){Y.removeChild(f);continue}}if(I&&!I.has(u)&&!I.has(G(u))){if(!x(f)&&!S){Y.removeChild(f);continue}}M(f,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),f=X.getAttribute("style")||"";if(f&&I.size===0){let m=f.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
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 f of R.children||[])if(f&&f.tagName)w(f)};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 f=X.getAttribute("onbegin"),u=X.getAttribute("onend");if(f||u){if(Q.smil.hasInteractiveAnimations=!0,f?.includes("play()")||u?.includes("play()"))Q.info.push(`Animation uses JavaScript to trigger audio playback via ${f?"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(`
@@ -490,4 +490,4 @@ ${z}
490
490
  // ===== END EMBEDDED RESOURCES INTERCEPTOR =====
491
491
 
492
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,f=0,u=(h)=>{if(!h||!h.attributes)return;let E=["http://www.inkscape.org/namespaces/inkscape","http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd","http://ns.adobe.com/AdobeIllustrator/","http://ns.adobe.com/AdobeSVGViewerExtensions/","http://www.bohemiancoding.com/sketch/ns","http://www.figma.com/figma/ns","http://www.serif.com/","http://www.vecta.io/nano"],d=["http://www.w3.org/2000/svg","http://www.w3.org/1999/xlink","http://www.w3.org/XML/1998/namespace","http://www.w3.org/2000/xmlns/"],c=h.attributes;for(let p=0;p<c.length;p++){let N=c[p];if(N.name.startsWith("xmlns:")){let y=N.name.substring(6),B=N.value;if(E.some((e)=>B.startsWith(e))||!d.includes(B))I.set(y,B)}}},m=(h,E)=>{let d=`Failed to fetch resource: ${h} - ${E.message}`;if(V==="fail")throw new Error(d);else if(V==="warn")R.push(d),console.warn("embedExternalDependencies:",d);return null};if(K){let E=[...$.getElementsByTagName("image")];if(M)M("images",0,E.length);for(let d=0;d<E.length;d++){let c=E[d],p=c.getAttribute("href")||c.getAttribute("xlink:href");if(!p||!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});f++;let T=`${Y}${f}_`;if(H==="extract"&&B){let P=s.getElementById(B);if(P){let t=P.clone?P.clone():JSON.parse(JSON.stringify(P));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,f=(S)=>{if(!I)return!0;let x=S;while(x&&x.getAttribute){let h=x.getAttribute("id");if(h&&I.has(h))return!0;x=x.parentNode}return!1},u=async(S,x,h)=>{let E=0;if(typeof Buffer!=="undefined"&&Buffer.isBuffer(x))E=x.length;else if(typeof Buffer!=="undefined")E=Buffer.byteLength(x,"utf8");else if(typeof Blob!=="undefined")E=new Blob([x]).size;else E=x.length||0;let d={filename:S,path:H?`${H}/${S}`:S,mimeType:h,size:E};if(!V&&H)try{let c=await import("node:fs/promises"),p=await Promise.resolve().then(() => (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(!f(E))continue;let d=E.getAttribute("href")||E.getAttribute("xlink:href");if(!d||!d.startsWith("data:"))continue;let c=W6(d);if(!c)continue;if(!c.mimeType.startsWith("image/"))continue;R++;let p=$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(!f(E))continue;let d=E.getAttribute("src");if(d&&d.startsWith("data:")){let p=W6(d);if(p&&p.mimeType.startsWith("audio/")){R++;let N=$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(!f(E))continue;let d=E.getAttribute("src");if(d&&d.startsWith("data:")){let p=W6(d);if(p&&p.mimeType.startsWith("video/")){R++;let N=$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(!f(E))continue;let d=E.getAttribute("href")||E.getAttribute("xlink:href");if(d&&!d.startsWith("data:"))continue;let c="";if(d&&d.startsWith("data:")){let y=W6(d);if(y){let B=j6(y);c=typeof B==="string"?B:B.toString("utf8")}}else if(c=E.textContent||"",E.firstChild&&E.firstChild.nodeType===4)c=E.firstChild.nodeValue||"";if(!c.trim())continue;R++;let p=$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(!f(E))continue;let d=E.textContent||"";if(E.firstChild&&E.firstChild.nodeType===4)d=E.firstChild.nodeValue||"";if(!d.trim())continue;let c=!1;if(W){let p=/@font-face\s*\{[^}]*\}/gi,N=d.match(p)||[];for(let y of N){let B=y.match(/src:\s*url\(["']?(data:[^"')]+)["']?\)/);if(B){let e=B[1],r=W6(e);if(r){R++;let s=$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.1",aK={VERSION:rK,...LJ},Fq=aK;if(typeof window!=="undefined")window.SVGToolbox=aK;})();
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.2",aK={VERSION:rK,...LJ},Fq=aK;if(typeof window!=="undefined")window.SVGToolbox=aK;})();