@svgsketch/core 2.3.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,20 +1,84 @@
1
- var er=(C=>(C.LINEAR="linear",C.EASE="ease",C.EASE_IN="ease-in",C.EASE_OUT="ease-out",C.EASE_IN_OUT="ease-in-out",C.EASE_IN_QUAD="ease-in-quad",C.EASE_OUT_QUAD="ease-out-quad",C.EASE_IN_OUT_QUAD="ease-in-out-quad",C.EASE_IN_CUBIC="ease-in-cubic",C.EASE_OUT_CUBIC="ease-out-cubic",C.EASE_IN_OUT_CUBIC="ease-in-out-cubic",C.EASE_IN_QUART="ease-in-quart",C.EASE_OUT_QUART="ease-out-quart",C.EASE_IN_OUT_QUART="ease-in-out-quart",C.EASE_IN_SINE="ease-in-sine",C.EASE_OUT_SINE="ease-out-sine",C.EASE_IN_OUT_SINE="ease-in-out-sine",C.EASE_IN_QUINT="ease-in-quint",C.EASE_OUT_QUINT="ease-out-quint",C.EASE_IN_OUT_QUINT="ease-in-out-quint",C.EASE_IN_EXPO="ease-in-expo",C.EASE_OUT_EXPO="ease-out-expo",C.EASE_IN_OUT_EXPO="ease-in-out-expo",C.EASE_IN_CIRC="ease-in-circ",C.EASE_OUT_CIRC="ease-out-circ",C.EASE_IN_OUT_CIRC="ease-in-out-circ",C.EASE_IN_BACK="ease-in-back",C.EASE_OUT_BACK="ease-out-back",C.EASE_IN_OUT_BACK="ease-in-out-back",C.CUSTOM_BEZIER="custom-bezier",C.LINEAR_FUNCTION="linear-function",C.STEPS="steps",C))(er||{}),tr={linear:null,ease:[.25,.1,.25,1],"ease-in":[.42,0,1,1],"ease-out":[0,0,.58,1],"ease-in-out":[.42,0,.58,1],"ease-in-quad":[.55,.085,.68,.53],"ease-out-quad":[.25,.46,.45,.94],"ease-in-out-quad":[.455,.03,.515,.955],"ease-in-cubic":[.55,.055,.675,.19],"ease-out-cubic":[.215,.61,.355,1],"ease-in-out-cubic":[.645,.045,.355,1],"ease-in-quart":[.895,.03,.685,.22],"ease-out-quart":[.165,.84,.44,1],"ease-in-out-quart":[.77,0,.175,1],"ease-in-sine":[.47,0,.745,.715],"ease-out-sine":[.39,.575,.565,1],"ease-in-out-sine":[.445,.05,.55,.95],"ease-in-quint":[.755,.05,.855,.06],"ease-out-quint":[.23,1,.32,1],"ease-in-out-quint":[.86,0,.07,1],"ease-in-expo":[.95,.05,.795,.035],"ease-out-expo":[.19,1,.22,1],"ease-in-out-expo":[1,0,0,1],"ease-in-circ":[.6,.04,.98,.335],"ease-out-circ":[.075,.82,.165,1],"ease-in-out-circ":[.785,.135,.15,.86],"ease-in-back":[.6,-.28,.735,.045],"ease-out-back":[.175,.885,.32,1.275],"ease-in-out-back":[.68,-.55,.265,1.55],"custom-bezier":null,"linear-function":null,steps:null};function Pp(n){let e=tr[n];return e?`cubic-bezier(${e.join(", ")})`:"linear"}var Rs=(a=>(a.LINEAR="linear",a.QUADRATIC="quadratic",a.CUBIC="cubic",a.CATMULL_ROM="catmull-rom",a.ARC="arc",a.BASIS="basis",a.MIXED="mixed",a))(Rs||{}),bl=(r=>(r.SMOOTH="smooth",r.CORNER="corner",r.SYMMETRIC="symmetric",r))(bl||{});function Ap(n){return n==="color"?"live":"stamped"}var As=["transformMatrix","scaleX","scaleY","translateX","translateY","rotation","skewX","skewY","customPivot","rawTransform","ancestorTransform","layerName","fillColor","borderColor","borderWidth","opacity","fillOpacity","strokeOpacity","locked","visible","fillType","fillGradient","strokeType","strokeGradient","fillRule","strokeLinejoin","strokeLinecap","strokeMiterlimit","lineStyle","dashLength","gapLength","dashOffset","strokeDasharray","colorInterpolation","filters","filterColorInterpolation","filterUnits","primitiveUnits","filterX","filterY","filterWidth","filterHeight","metadata","cssClipPath","cssMaskProperties","groupId","structural","displayMode","display","visibility","inheritFill","inheritStroke","preserveFillOpacity","preserveStrokeOpacity","fillLibraryId","strokeLibraryId","filterLibraryIds","fillRuleExplicit","paintOrder","vectorEffect","transformBox","pathLength","markerStart","markerMid","markerEnd","blendMode","shapeRendering","textRendering","imageRendering","colorRendering","systemLanguage","requiredExtensions","inlineStyle","authoredAttributes","bindings","scripts","lastSolidFillColor","lastSolidStrokeColor","connectionPoints","isRootSvg","x","y","width","height","rx","ry","cornerRadius","cornerShape","cornerMode","cornerRadiusTL","cornerRadiusTR","cornerRadiusBL","cornerRadiusBR","cornerShapeTL","cornerShapeTR","cornerShapeBL","cornerShapeBR","size","radius","cx","cy","shiftAngle","x1","y1","x2","y2","startEndpoint","endEndpoint","routingMode","sourceRef","targetRef","sourcePoint","targetPoint","waypoints","label","labelPosition","labelOffset","mermaidEdgeStyle","textX","textY","fontSize","text","fontFamily","fontWeight","fontStyle","fontVariant","fontVariantLigatures","fontVariantPosition","fontVariantCaps","fontVariantNumeric","fontVariantEastAsian","textDecoration","textTransform","baselineShift","dominantBaseline","writingMode","textAnchor","letterSpacing","wordSpacing","lineHeight","inlineSize","overflowWrap","whiteSpace","textDirection","unicodeBidi","useRichText","richTextRuns","richTextData","charOffsets","fontVariationSettings","linePositions","textLength","lengthAdjust","shapeInsideRef","shapePadding","isTextPath","textPathPoints","textPathStartOffset","textPathStartOffsetUnit","textPathSide","textPathMethod","textPathSpacing","textPathLengthAdjust","textPathLength","textPathLengthUnit","textPathPathLength","textPathCurveType","textPathInlineFormat","textPathRefShapeId","textPathImportRefId","href","originalWidth","originalHeight","preserveAspectRatio","specPreserveAspectRatio","imageOpacity","pathPoints","pathArcParams","pathControlBounds","pathCurveType","pathClosed","pathTension","polylinePoints","polylineClosed","sides","arms","innerRadiusPercent","armWidthPercent","turns","thicknessPercent","spiralDirection","teeth","toothDepthPercent","holeRadiusPercent","headWidthPercent","headLengthPercent","shaftWidthPercent","tailAngleDeg","tailLengthPercent","tailWidthPercent","lobeRadiusPercent","cleftDepthPercent","boltSegments","boltJaggednessPercent","boltWidthPercent","cloudBumps","cloudPuffinessPercent","slantPercent","topWidthPercent","capHeightPercent","waveAmplitudePercent","symbolId","symbolOverrides","variantKey","instancePresentation","scaleContentToViewport","groupData","mediaKind","mediaMimeType","naturalDuration","begin","trimStart","trimEnd","volume","muted","loop","playbackRate","mediaOpacity","fadeInDuration","fadeOutDuration","posterHref","sourceRect","hrefXlink","linkTarget","linkRel","linkDownload","linkPing","linkHreflang","linkType","linkReferrerPolicy","containerPresentation","targetShapeId","offsetX","offsetY","targetWidth","targetHeight","broken","switchSystemLanguage","switchRequiredExtensions","svgX","svgY","svgWidth","svgHeight","svgViewBoxX","svgViewBoxY","svgViewBoxWidth","svgViewBoxHeight","svgPreserveAspectRatio","viewBoxX","viewBoxY","viewBoxWidth","viewBoxHeight","viewName","viewPreserveAspectRatio","viewZoomAndPan","viewTarget","isHomeView","children","viewLinkedSvgId"],ve=6;var Is=["transformMatrix","scaleX","scaleY","translateX","translateY","rotation","skewX","skewY","customPivot","rawTransform"],qt=["transformMatrix","scaleX","scaleY","translateX","translateY","rotation","skewX","skewY"],Ms={transformMatrix:null,translateX:0,translateY:0,rotation:0,skewX:0,skewY:0,customPivot:null,rawTransform:null};var Fe="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",Jt=Fe.length,Ee=Fe[0],Cs=Fe[Jt-1],Fs=Fe[Math.floor(Jt/2)],nr=97,Sl=122;function ut(n){let e=Fe.indexOf(n);if(e===-1)throw new Error(`order-key: invalid digit '${n}'`);return e}function xl(n){let e=n.charCodeAt(0);if(e<nr||e>Sl)throw new Error(`order-key: invalid head '${n}'`);return e-nr+1}function Ve(n){if(n<1||n>26)throw new Error(`order-key: integer length ${n} out of range`);return String.fromCharCode(nr+n-1)}function Rt(n){let e=xl(n[0]);if(n.length<1+e)throw new Error(`order-key: '${n}' shorter than its integer part`);let t=n.slice(1,1+e),r=n.slice(1+e);for(let i of t)ut(i);for(let i of r)ut(i);return{integer:t,fraction:r}}function Zt(n){for(let e of n)if(e!==Ee)return!1;return!0}function Qt(n){if(n.length===0)return!1;try{let{integer:e,fraction:t}=Rt(n);return!(t.endsWith(Ee)||Zt(e)&&t.length===0||e.length>1&&e[0]===Ee)}catch{return!1}}function Ds(n,e){if(!Qt(n))throw new Error(`order-key: invalid ${e} '${n}'`)}function en(n,e){return n<e?-1:n>e?1:0}function $l(n){let e=n.split("");for(let t=e.length-1;t>=0;t--){let r=ut(e[t]);if(r<Jt-1){e[t]=Fe[r+1];for(let i=t+1;i<e.length;i++)e[i]=Ee;return e.join("")}}return null}function rr(n){let{integer:e}=Rt(n),t=$l(e);if(t!==null)return Ve(e.length)+t;let r="1"+Ee.repeat(e.length);return Ve(r.length)+r}function vl(n){let e=n.split("");for(let t=e.length-1;t>=0;t--){let r=ut(e[t]);if(r>0){e[t]=Fe[r-1];for(let i=t+1;i<e.length;i++)e[i]=Cs;return e.join("")}e[t]=Cs}throw new Error(`order-key: cannot decrement zero integer '${n}'`)}function kl(n){let e=0;for(;e<n.length-1&&n[e]===Ee;)e++;return n.slice(e)}function Tl(n){let{integer:e,fraction:t}=Rt(n);if(!Zt(e)){let r=vl(e);if(!Zt(r)){let i=kl(r);return Ve(i.length)+i}return Ve(1)+Ee+Fs}return Ve(1)+Ee+At("",t)}function At(n,e){if(e!==null){if(e.length===0||n>=e)throw new Error(`order-key: fraction bounds out of order ('${n}' >= '${e}')`);let i=0;for(;i<e.length&&(n[i]??Ee)===e[i];)i++;if(i>0)return e.slice(0,i)+At(n.slice(i),e.slice(i))}let t=n.length>0?ut(n[0]):0,r=e!==null?ut(e[0]):Jt;return r-t>1?Fe[Math.floor((t+r)/2)]:Fe[t]+At(n.slice(1),null)}function It(n,e){if(n!==null&&Ds(n,"lower bound"),e!==null&&Ds(e,"upper bound"),n!==null&&e!==null&&n>=e)throw new Error(`order-key: bounds out of order ('${n}' >= '${e}')`);if(n===null&&e===null)return Ve(1)+"1";if(n===null)return Tl(e);if(e===null)return rr(n);let t=Rt(n),r=Rt(e),i=Ve(t.integer.length)+t.integer,s=Ve(r.integer.length)+r.integer;if(i===s)return i+At(t.fraction,r.fraction);let o=rr(i+(Zt(t.integer)?Fs:""));return en(o,e)<0?o:i+At(t.fraction,null)}function ir(n,e,t){if(t<=0)return[];let r=[],i=n;for(let s=0;s<t;s++){let o=It(i,e);r.push(o),i=o}return r}function sr(n){if(n<=0)return[];let e=[],t=It(null,null);e.push(t);for(let r=1;r<n;r++)t=rr(t),e.push(t);return e}var tn=class{schemas=new Map;register(e,t){this.schemas.set(e,t)}get(e){return this.schemas.get(e)}typeIds(){return[...this.schemas.keys()]}getDefaults(e){let t=this.schemas.get(e);if(!t)return{};let r={};for(let i of Object.keys(t))r[i]=t[i].default;return r}validate(e,t,r){let i=this.schemas.get(e);if(!i)return r;let s=i[t];return s?.validate?s.validate(r):r}},E=n=>Math.max(0,n),ct=n=>Math.max(0,Math.min(1,n)),ee=n=>Math.max(0,Math.min(100,n)),wl=n=>Math.max(1,n),Pl=n=>Math.max(3,Math.min(100,Math.floor(n))),_l=n=>Math.max(3,Math.min(50,Math.floor(n))),Rl=n=>Math.max(3,Math.min(30,Math.floor(n))),Al=n=>Math.max(1,Math.min(10,n));function Il(n){return Object.fromEntries(Object.entries(n).map(([e,t])=>[e,{default:t}]))}var Ml=Il(Ms),te={layerName:{default:null},fillColor:{default:"#ffffff"},borderColor:{default:"#000000"},borderWidth:{default:1},opacity:{default:1,validate:ct},fillOpacity:{default:1,validate:ct},strokeOpacity:{default:1,validate:ct},...Ml,locked:{default:!1},visible:{default:!0},fillType:{default:"solid"},fillGradient:{default:null},strokeType:{default:"solid"},strokeGradient:{default:null},fillRule:{default:"nonzero"},strokeLinejoin:{default:"miter"},strokeLinecap:{default:"butt"},strokeMiterlimit:{default:4,validate:wl},lineStyle:{default:"solid"},dashLength:{default:8},gapLength:{default:4},dashOffset:{default:0},strokeDasharray:{default:null},colorInterpolation:{default:null},filters:{default:[]},filterColorInterpolation:{default:null},filterUnits:{default:null},primitiveUnits:{default:null},filterX:{default:null},filterY:{default:null},filterWidth:{default:null},filterHeight:{default:null},metadata:{default:null},cssClipPath:{default:null},cssMaskProperties:{default:null},groupId:{default:null}},ke={...te,cx:{default:0},cy:{default:0},radius:{default:50,validate:E},cornerRadius:{default:0,validate:E},shiftAngle:{default:0}},dt={...te,x:{default:0},y:{default:0},width:{default:100,validate:E},height:{default:60,validate:E}},Es={...te,x:{default:0},y:{default:0},width:{default:0,validate:E},height:{default:0,validate:E},href:{default:""},mediaMimeType:{default:""},originalWidth:{default:0},originalHeight:{default:0},naturalDuration:{default:0},preserveAspectRatio:{default:!0},begin:{default:0},trimStart:{default:0},volume:{default:1,validate:ct},muted:{default:!1},loop:{default:!1},playbackRate:{default:1},mediaOpacity:{default:1,validate:ct},fadeInDuration:{default:0,validate:E},fadeOutDuration:{default:0,validate:E},posterHref:{default:""},sourceRect:{default:null}},O=new tn;O.register("rectangle",{...te,x:{default:0},y:{default:0},width:{default:100,validate:E},height:{default:100,validate:E},rx:{default:0,validate:E},ry:{default:0,validate:E},cornerRadius:{default:0,validate:E},cornerShape:{default:"round"},cornerMode:{default:"uniform"},cornerRadiusTL:{default:0,validate:E},cornerRadiusTR:{default:0,validate:E},cornerRadiusBL:{default:0,validate:E},cornerRadiusBR:{default:0,validate:E},cornerShapeTL:{default:"round"},cornerShapeTR:{default:"round"},cornerShapeBL:{default:"round"},cornerShapeBR:{default:"round"}});O.register("square",{...te,x:{default:0},y:{default:0},width:{default:100,validate:E},height:{default:100,validate:E},rx:{default:0,validate:E},ry:{default:0,validate:E},cornerRadius:{default:0,validate:E},cornerShape:{default:"round"},cornerMode:{default:"uniform"},cornerRadiusTL:{default:0,validate:E},cornerRadiusTR:{default:0,validate:E},cornerRadiusBL:{default:0,validate:E},cornerRadiusBR:{default:0,validate:E},cornerShapeTL:{default:"round"},cornerShapeTR:{default:"round"},cornerShapeBL:{default:"round"},cornerShapeBR:{default:"round"}});O.register("circle",{...te,x:{default:0},y:{default:0},radius:{default:50,validate:E}});O.register("ellipse",{...te,cx:{default:0},cy:{default:0},rx:{default:50,validate:E},ry:{default:30,validate:E}});O.register("line",{...te,x1:{default:0},y1:{default:0},x2:{default:100},y2:{default:0},startEndpoint:{default:"none"},endEndpoint:{default:"none"}});O.register("text",{...te,x:{default:0},y:{default:0},width:{default:0,validate:E},height:{default:0,validate:E},textX:{default:0},textY:{default:0},fontSize:{default:24},text:{default:""},fontFamily:{default:"Arial"},fontWeight:{default:"normal"},fontStyle:{default:"normal"},fontVariant:{default:""},fontVariantLigatures:{default:""},fontVariantPosition:{default:""},fontVariantCaps:{default:""},fontVariantNumeric:{default:""},fontVariantEastAsian:{default:""},textDecoration:{default:{}},textTransform:{default:"none"},baselineShift:{default:"baseline"},dominantBaseline:{default:"auto"},writingMode:{default:"horizontal-tb"},textAnchor:{default:"start"},letterSpacing:{default:0},wordSpacing:{default:0},lineHeight:{default:1.2},inlineSize:{default:0},overflowWrap:{default:"normal"},whiteSpace:{default:"pre-wrap"},textDirection:{default:"ltr"},unicodeBidi:{default:"normal"},scaleX:{default:1},scaleY:{default:1},scaleAnchor:{default:null},useRichText:{default:!1},richTextRuns:{default:null},richTextData:{default:null},charOffsets:{default:null},fontVariationSettings:{default:{}},isTextPath:{default:!1},textPathPoints:{default:null},textPathStartOffset:{default:0},textPathSide:{default:"left"},shapeInsideRef:{default:null},shapePadding:{default:0}});O.register("image",{...te,x:{default:0},y:{default:0},width:{default:100,validate:E},height:{default:100,validate:E},href:{default:""},originalWidth:{default:0},originalHeight:{default:0},preserveAspectRatio:{default:!0},imageOpacity:{default:1,validate:ct}});O.register("path",{...te,x:{default:0},y:{default:0},width:{default:0,validate:E},height:{default:0,validate:E},pathPoints:{default:[]},pathArcParams:{default:[]},pathControlBounds:{default:null},startEndpoint:{default:"none"},endEndpoint:{default:"none"}});O.register("polyline",{...te,x:{default:0},y:{default:0},width:{default:0,validate:E},height:{default:0,validate:E},polylinePoints:{default:[]},polylineClosed:{default:!1}});O.register("triangle",{...ke,sides:{default:3}});O.register("ngon",{...ke,sides:{default:6,validate:Pl}});O.register("star",{...ke,arms:{default:5,validate:_l},innerRadiusPercent:{default:40,validate:ee}});O.register("cross",{...ke,armWidthPercent:{default:30,validate:ee}});O.register("ring",{...ke,innerRadiusPercent:{default:50,validate:ee}});O.register("spiral",{...ke,turns:{default:3,validate:Al},thicknessPercent:{default:15,validate:ee},spiralDirection:{default:1}});O.register("gear",{...ke,teeth:{default:8,validate:Rl},toothDepthPercent:{default:25,validate:ee},holeRadiusPercent:{default:20,validate:ee}});O.register("arrow",{...ke,headWidthPercent:{default:100,validate:ee},headLengthPercent:{default:40,validate:ee},shaftWidthPercent:{default:40,validate:ee}});O.register("symbol-instance",{...te,x:{default:0},y:{default:0},width:{default:100,validate:E},height:{default:100,validate:E},symbolId:{default:""}});O.register("group",{...te,groupId:{default:null}});O.register("cloud",{...ke,cloudBumps:{default:5},cloudPuffinessPercent:{default:60,validate:ee}});O.register("heart",{...ke,lobeRadiusPercent:{default:50,validate:ee},cleftDepthPercent:{default:25,validate:ee}});O.register("lightning",{...ke,boltSegments:{default:3},boltWidthPercent:{default:30,validate:ee},boltJaggednessPercent:{default:40,validate:ee}});O.register("speechBubble",{...ke,tailAngleDeg:{default:45},tailLengthPercent:{default:40,validate:ee},tailWidthPercent:{default:25,validate:ee}});O.register("diamond",{...dt});O.register("parallelogram",{...dt,slantPercent:{default:20,validate:ee}});O.register("trapezoid",{...dt,topWidthPercent:{default:70,validate:ee}});O.register("terminator",{...dt});O.register("cylinder",{...dt,capHeightPercent:{default:15,validate:ee}});O.register("document-shape",{...dt,waveAmplitudePercent:{default:15,validate:ee}});O.register("hyperlink",{...te,href:{default:""},hrefXlink:{default:""},linkTarget:{default:""},linkPing:{default:""},linkRel:{default:""},linkHreflang:{default:""},linkType:{default:""},linkReferrerPolicy:{default:""}});O.register("switch",{...te,switchSystemLanguage:{default:null},switchRequiredExtensions:{default:null}});O.register("svg",{...te,svgX:{default:0},svgY:{default:0},svgWidth:{default:0,validate:E},svgHeight:{default:0,validate:E},svgViewBoxX:{default:0},svgViewBoxY:{default:0},svgViewBoxWidth:{default:0,validate:E},svgViewBoxHeight:{default:0,validate:E},svgPreserveAspectRatio:{default:""}});O.register("view",{...te,viewBoxX:{default:0},viewBoxY:{default:0},viewBoxWidth:{default:0,validate:E},viewBoxHeight:{default:0,validate:E},viewName:{default:""},viewPreserveAspectRatio:{default:""},viewTarget:{default:""}});O.register("shape-reference",{...te,targetShapeId:{default:""},offsetX:{default:0},offsetY:{default:0},targetWidth:{default:0,validate:E},targetHeight:{default:0,validate:E},broken:{default:!1}});O.register("video",{...Es,mediaKind:{default:"video"}});O.register("audio",{...Es,mediaKind:{default:"audio"}});O.register("document",{});function Cl(){let n=new Set(As);for(let e of Is)n.add(e);for(let e of O.typeIds())for(let t of Object.keys(O.getDefaults(e)))n.add(t);return n.delete("scaleAnchor"),n.delete("extra"),n}var Os=Cl(),Dl=new Set(["scaleAnchor","displayAttr"]);function ar(n){let e=n.extra&&typeof n.extra=="object"&&!Array.isArray(n.extra)?n.extra:void 0;for(let t of Object.keys(n)){if(t==="extra"||Os.has(t))continue;let r=n[t];delete n[t],r!==void 0&&((e??={})[t]=r)}return e&&Object.keys(e).length>0?n.extra=e:delete n.extra,n}function ft(n){if(!n?.state||typeof n.state!="object")return n;let e=n.state,t=e.children;if(Array.isArray(t))for(let i of t)ft(i);let r=e.symbolOverrides;if(r&&typeof r=="object"&&!Array.isArray(r))for(let i of Object.values(r))i&&typeof i=="object"&&!Array.isArray(i)&&ar(i);return ar(e),n}function nn(n){if(!n?.state||typeof n.state!="object")return n;let e=n.state,t=e.children;if(Array.isArray(t))for(let i of t)nn(i);let r=e.symbolOverrides;if(r&&typeof r=="object"&&!Array.isArray(r))for(let i of Object.values(r))i&&typeof i=="object"&&!Array.isArray(i)&&Ue(i);return Ue(e),n}function Ue(n){let e=n.extra;if(!e||typeof e!="object"||Array.isArray(e))return delete n.extra,n;for(let[t,r]of Object.entries(e))t!=="extra"&&(t in n||(n[t]=r));return delete n.extra,n}function pt(n,e,t,r="verbatim"){if(r==="verbatim")return new We(n,e,t&&"extra"in t?Ue({...t}):t);let i={...O.getDefaults(e),...t},s=O.get(e);if(s)for(let o of Object.keys(i)){let a=s[o];a?.validate&&i[o]!==void 0&&(i[o]=a.validate(i[o]))}return new We(n,e,i)}var We=class n{static writeHook=null;static _baseReadDepth=0;static withBaseProps(e){n._baseReadDepth++;try{return e()}finally{n._baseReadDepth--}}id;type;parent=null;children=[];onChange=null;_props;_dirty=new Set;_overlay=null;_propTimestamps=new Map;constructor(e,t,r){this.id=e,this.type=t,this._props=r?{...r}:{}}get(e){return this._overlay!==null&&n._baseReadDepth===0&&this._overlay.has(e)?this._overlay.get(e):this._props[e]}set(e,t){this._props[e]!==t&&(n.writeHook?.(this,e),this._props[e]=t,this._dirty.add(e),this.onChange?.(this,this._dirty))}getProp(e){return this._overlay!==null&&n._baseReadDepth===0&&this._overlay.has(e)?this._overlay.get(e):this._props[e]}getBaseProp(e){return this._props[e]}setProp(e,t){this._props[e]!==t&&(n.writeHook?.(this,e),this._props[e]=t,this._dirty.add(e),this.onChange?.(this,this._dirty))}deleteProp(e){e in this._props&&(n.writeHook?.(this,e),delete this._props[e],this._dirty.add(e),this.onChange?.(this,this._dirty))}setMany(e){let t=!1;for(let[r,i]of Object.entries(e))this._props[r]!==i&&(n.writeHook?.(this,r),this._props[r]=i,this._dirty.add(r),t=!0);t&&this.onChange?.(this,this._dirty)}setOverlayValue(e,t){this._overlay===null&&(this._overlay=new Map),this._overlay.set(e,t)}deleteOverlayValue(e){if(this._overlay===null)return!1;let t=this._overlay.delete(e);return this._overlay.size===0&&(this._overlay=null),t}getOverlayValue(e){return this._overlay?.get(e)}hasOverlayValue(e){return this._overlay?.has(e)??!1}overlayKeys(){return this._overlay?[...this._overlay.keys()]:[]}clearOverlay(){if(this._overlay===null)return[];let e=[...this._overlay.keys()];return this._overlay=null,e}get hasOverlay(){return this._overlay!==null}getDirtyKeys(){return this._dirty}clearDirty(){this._dirty.clear()}isDirty(){return this._dirty.size>0}getProps(){return this._props}snapshotProps(){return structuredClone(this._props)}restoreProps(e){this._props=structuredClone(e);for(let t of Object.keys(this._props))this._dirty.add(t);this.onChange?.(this,this._dirty)}getPropStamp(e){return this._propTimestamps.get(e)??null}stampProp(e,t,r){this._propTimestamps.set(e,{ts:t,clientId:r})}stampProps(e,t,r){let i={ts:t,clientId:r};for(let s of e)this._propTimestamps.set(s,i)}getPropStampsForKeys(e){let t={};for(let r of e){let i=this._propTimestamps.get(r);i&&(t[r]=i.ts)}return t}setPropIfWins(e,t,r,i){let s=this._propTimestamps.get(e),o=s?.ts??0,a=s?.clientId??"";return r>o||r===o&&i>a?(t===null?delete this._props[e]:this._props[e]=t,this._propTimestamps.set(e,{ts:r,clientId:i}),this._dirty.add(e),!0):!1}snapshotPropTimestamps(){return new Map(this._propTimestamps)}restorePropTimestamps(e){this._propTimestamps=new Map(e)}toSerialized(){return{id:this.id,type:this.type,state:{...this._props}}}static fromSerialized(e){return pt(e.id,e.type,e.state,"verbatim")}static create(e,t,r){return pt(e,t,r,"authoring")}};var Fl=5e3,El=1e4;function Ol(n){return n===null||n.size===0?"":[...n.entries()].sort((e,t)=>t[1].count-e[1].count).slice(0,5).map(([e,t])=>`${e.type}#${e.id} x${t.count} keys=[${[...t.keys].join(",")}]`).join("; ")}var or=class n{static _pendingGraphs=new Set;static flushAllPending(){if(n._pendingGraphs.size!==0)for(let e of[...n._pendingGraphs])e.flushBatched()}static get pendingGraphCount(){return n._pendingGraphs.size}root;_nodesById=new Map;_batchDepth=0;_batchDirtyNodes=new Map;_draining=!1;_changeListeners=[];_structureListeners=[];constructor(){this.root=pt("__root__","document"),this._nodesById.set(this.root.id,this.root)}onNodeChange(e){return this._changeListeners.push(e),()=>{let t=this._changeListeners.indexOf(e);t>=0&&this._changeListeners.splice(t,1)}}onStructureChange(e){return this._structureListeners.push(e),()=>{let t=this._structureListeners.indexOf(e);t>=0&&this._structureListeners.splice(t,1)}}addNode(e,t,r){let i=t??this.root;r!==void 0&&r>=0&&r<i.children.length?i.children.splice(r,0,e):i.children.push(e),e.parent=i,this._nodesById.set(e.id,e),e.onChange=this._handleNodeChange.bind(this),this._emitStructure("add",e,null,i)}removeNode(e){let t=this._nodesById.get(e);if(!t||t===this.root)return null;let r=t.parent,i=null;if(r){let s=r.children.indexOf(t);i={parentId:r===this.root?null:r.id,index:s},s>=0&&r.children.splice(s,1)}return t.parent=null,t.onChange=null,this._nodesById.delete(e),this._batchDirtyNodes.delete(t),this._removeDescendants(t),this._batchDirtyNodes.size===0&&n._pendingGraphs.delete(this),this._emitStructure("remove",t,r,null,i),t}getNode(e){return this._nodesById.get(e)??null}moveNode(e,t,r){let i=this._nodesById.get(e);if(!i||i===this.root)return;let s=i.parent,o=null;if(s){let a=s.children.indexOf(i);o={parentId:s===this.root?null:s.id,index:a},a>=0&&s.children.splice(a,1)}r!==void 0&&r>=0&&r<t.children.length?t.children.splice(r,0,i):t.children.push(i),i.parent=t,this._emitStructure("move",i,s,t,o)}moveNodeToParentId(e,t,r){let i=t?this._nodesById.get(t):this.root;i&&this.moveNode(e,i,r)}getChildren(e){let t=e?this._nodesById.get(e):this.root;return t?[...t.children]:[]}getRootShapes(){return[...this.root.children]}getParentId(e){let t=this._nodesById.get(e);return!t||!t.parent||t.parent===this.root?null:t.parent.id}getSiblingIndex(e){let t=this._nodesById.get(e);return!t||!t.parent?-1:t.parent.children.indexOf(t)}getAncestorIds(e){let t=[],r=this.getParentId(e);for(;r;)t.push(r),r=this.getParentId(r);return t}isAncestor(e,t){if(e===t)return!1;let r=this.getParentId(t);for(;r;){if(r===e)return!0;r=this.getParentId(r)}return!1}isDocumentRootNode(e){let t=this._nodesById.get(e);return!!t&&t!==this.root&&t.getProp("isRootSvg")===!0}contains(e,t){if(e===t)return!1;if(this.isDocumentRootNode(e)){let r=this._nodesById.get(t);return!!r&&r!==this.root&&!this.isDocumentRootNode(t)}return this.isAncestor(e,t)}getDepth(e){let t=this._nodesById.get(e);if(!t||t===this.root)return-1;let r=0,i=t.parent;for(;i&&i!==this.root;)r++,i=i.parent;return r}getAllNodes(){let e=[];for(let t of this._nodesById.values())t!==this.root&&e.push(t);return e}getDirtyNodes(){let e=[];for(let t of this._nodesById.values())t.isDirty()&&e.push(t);return e}clearAllDirty(){for(let e of this._nodesById.values())e.clearDirty()}beginBatch(){this._batchDepth++}commitBatch(){this._batchDepth=Math.max(0,this._batchDepth-1),this._batchDepth===0&&this._drainBatched()}flushBatched(){this._batchDirtyNodes.size>0&&this._drainBatched()}get hasPendingBatched(){return this._batchDirtyNodes.size>0}get isBatching(){return this._batchDepth>0}get isDraining(){return this._draining}dispose(){n._pendingGraphs.delete(this),this._batchDirtyNodes.clear(),this._changeListeners.length=0,this._structureListeners.length=0}notifyNodeChanged(e,t){this._handleNodeChange(e,t)}_handleNodeChange(e,t){if(this._batchDepth>0){let r=this._batchDirtyNodes.get(e);r||(r=new Set,this._batchDirtyNodes.set(e,r),n._pendingGraphs.add(this));for(let i of t)r.add(i);return}this._fireChangeListeners(e,t)}_drainBatched(){if(this._draining)return;this._draining=!0;let e=0,t=null;try{for(;this._batchDirtyNodes.size>0;){if(++e>El){console.error("[SceneGraph] batched-notification drain did not converge \u2014 render loop?",Ol(t)),this._batchDirtyNodes.clear();break}let[r,i]=this._batchDirtyNodes.entries().next().value;if(this._batchDirtyNodes.delete(r),this._batchDirtyNodes.size===0&&n._pendingGraphs.delete(this),e>Fl){t===null&&(t=new Map);let s=t.get(r);if(s){s.count++;for(let o of i)s.keys.add(o)}else t.set(r,{count:1,keys:new Set(i)})}this._fireChangeListeners(r,i)}}finally{this._draining=!1,this._batchDirtyNodes.size===0&&n._pendingGraphs.delete(this)}}_fireChangeListeners(e,t){let r=[...this._changeListeners];for(let i of r)i(e,t)}_emitStructure(e,t,r,i,s=null){let o=[...this._structureListeners];for(let a of o)a(e,t,r,i,s)}_removeDescendants(e){for(let t of e.children)t.onChange=null,this._nodesById.delete(t.id),this._batchDirtyNodes.delete(t),this._removeDescendants(t)}serializeShapes(){let e=[],t=r=>{for(let i of r)i.type!=="document"&&i.type!=="group"&&i.getProp("structural")!==!0&&e.push(i.toSerialized()),i.children.length>0&&t(i.children)};return t(this.root.children),e}static fromShapes(e){let t=new n;for(let r of e){let i=We.fromSerialized(r);t.addNode(i)}return t}};var G=["updatedAt","clientId"];function z(n,e,t){n.push({path:e,message:t})}function Ys(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}function U(n,e,t){return Ys(n)?n:(z(t,e,"must be an object"),null)}function I(n,e,t,r=[],i,s=!0){let o=new Set([...s?["type"]:[],...t,...r]);for(let a of t)Object.hasOwn(n,a)||z(i,`${e}.${a}`,"is required");for(let a of Object.keys(n))o.has(a)||z(i,`${e}.${a}`,"is not allowed")}function A(n,e,t,r=!1){return typeof n!="string"||!r&&n.length===0?(z(t,e,r?"must be a string":"must be a non-empty string"),!1):!0}function ae(n,e,t,r){return typeof n!="number"||!Number.isFinite(n)?(z(t,e,"must be a finite number"),!1):r!==void 0&&n<r?(z(t,e,`must be at least ${r}`),!1):!0}function we(n,e,t,r=0){return ae(n,e,t,r)?Number.isInteger(n)?!0:(z(t,e,"must be an integer"),!1):!1}function mt(n,e,t){return typeof n!="boolean"?(z(t,e,"must be a boolean"),!1):!0}function J(n,e,t,r,i=!1){n[e]!==void 0&&A(n[e],`${t}.${e}`,r,i)}function lr(n,e,t,r,i){n[e]!==void 0&&ae(n[e],`${t}.${e}`,r,i)}function se(n,e,t,r,i=0){n[e]!==void 0&&we(n[e],`${t}.${e}`,r,i)}function rn(n,e,t,r){n[e]!==void 0&&mt(n[e],`${t}.${e}`,r)}function qe(n,e,t){return Array.isArray(n)?(n.forEach((r,i)=>A(r,`${e}[${i}]`,t)),!0):(z(t,e,"must be an array"),!1)}function X(n,e,t,r){return Array.isArray(n)?(n.forEach((i,s)=>r(i,`${e}[${s}]`,t)),!0):(z(t,e,"must be an array"),!1)}function re(n,e,t){let r=[{value:n,path:e,depth:0}],i=0;for(;r.length>0;){let s=r.pop();if(i++,i>25e4){z(t,e,"exceeds the 250000-node validation limit");return}if(s.depth>64){z(t,s.path,"exceeds the 64-level nesting limit");continue}let o=s.value;if(!(o===null||typeof o=="string"||typeof o=="boolean")){if(typeof o=="number"){Number.isFinite(o)||z(t,s.path,"must be a finite JSON number");continue}if(Array.isArray(o)){o.forEach((a,l)=>r.push({value:a,path:`${s.path}[${l}]`,depth:s.depth+1}));continue}if(Ys(o)){for(let[a,l]of Object.entries(o))r.push({value:l,path:`${s.path}.${a}`,depth:s.depth+1});continue}z(t,s.path,"must be JSON-serializable")}}}function V(n,e,t){lr(n,"updatedAt",e,t,0),J(n,"clientId",e,t)}function sn(n,e,t){let r=U(n,e,t);if(r)for(let[i,s]of Object.entries(r))A(s,`${e}.${i}`,t,!0)}function Mt(n,e,t,r=0){if(r>64){z(t,e,"exceeds the 64-level shape nesting limit");return}let i=U(n,e,t);if(!i)return;I(i,e,["id","type","state"],[],t),A(i.id,`${e}.id`,t),A(i.type,`${e}.type`,t);let s=U(i.state,`${e}.state`,t);s&&(Object.hasOwn(s,"extra")&&z(t,`${e}.state.extra`,"is an at-rest field and is not allowed in operations"),re(s,`${e}.state`,t),s.children!==void 0&&X(s.children,`${e}.state.children`,t,(o,a,l)=>Mt(o,a,l,r+1)))}function Ll(n,e,t){let r=U(n,e,t);r&&(Object.hasOwn(r,"extra")&&z(t,`${e}.extra`,"is an at-rest field and is not allowed in operations"),re(r,e,t),r.children!==void 0&&X(r.children,`${e}.children`,t,(i,s,o)=>Mt(i,s,o)))}function ur(n,e,t){let r=U(n,e,t);r&&(A(r.id,`${e}.id`,t),r.parentId!==null&&A(r.parentId,`${e}.parentId`,t),se(r,"siblingIndex",e,t),J(r,"pluginId",e,t),J(r,"pluginData",e,t,!0),r.attributes!==void 0&&sn(r.attributes,`${e}.attributes`,t),re(r,e,t))}function Ls(n,e,t){let r=U(n,e,t);r&&(A(r.id,`${e}.id`,t),r.type!=="clip"&&r.type!=="mask"&&z(t,`${e}.type`,'must be "clip" or "mask"'),r.clipShapeIds!==void 0&&qe(r.clipShapeIds,`${e}.clipShapeIds`,t),r.clipShapeId!==void 0&&J(r,"clipShapeId",e,t),r.clipShapeIds===void 0&&r.clipShapeId===void 0&&z(t,`${e}.clipShapeIds`,"or clipShapeId is required"),qe(r.contentShapeIds,`${e}.contentShapeIds`,t),r.parentId!==null&&A(r.parentId,`${e}.parentId`,t),se(r,"siblingIndex",e,t),re(r,e,t))}function Ns(n,e,t){let r=U(n,e,t);if(!r)return;A(r.id,`${e}.id`,t);let i=r.orientation==="horizontal"||r.orientation==="vertical",s=r.axis==="x"||r.axis==="y";!i&&!s&&z(t,`${e}.orientation`,'must be "horizontal" or "vertical" (legacy axis "x" or "y" is also accepted)'),ae(r.position,`${e}.position`,t),i&&ae(r.controlPointOffset,`${e}.controlPointOffset`,t),J(r,"color",e,t,!0),lr(r,"opacity",e,t),re(r,e,t)}function Bs(n,e,t){let r=U(n,e,t);if(!r)return;A(r.id,`${e}.id`,t);let i=r.type==="distance"||r.type==="angle",s=["startX","startY","endX","endY"].every(o=>typeof r[o]=="number"&&Number.isFinite(r[o]));i?(X(r.points,`${e}.points`,t,(o,a,l)=>{let c=U(o,a,l);c&&(ae(c.x,`${a}.x`,l),ae(c.y,`${a}.y`,l))}),mt(r.visible,`${e}.visible`,t),we(r.snapDivisions,`${e}.snapDivisions`,t,1)):s||z(t,e,"must be a current or legacy measurement payload"),J(r,"color",e,t,!0),lr(r,"opacity",e,t),re(r,e,t)}var zs=["title","description","author","keywords","license","licenseUrl","language","customMetadata","rawMetadata","rawDescription","rawHtmlMetadata","coordinatePrecision"];function Gs(n,e,t,r){let i=U(n,e,t);if(!i)return;I(i,e,r?[]:["title","description","author","keywords","license","licenseUrl","language","customMetadata"],r?zs:zs.slice(8),t,!1);for(let o of["title","description","author","license","licenseUrl","language"])(!r||i[o]!==void 0)&&A(i[o],`${e}.${o}`,t,!0);(!r||i.keywords!==void 0)&&qe(i.keywords,`${e}.keywords`,t),(!r||i.customMetadata!==void 0)&&sn(i.customMetadata,`${e}.customMetadata`,t),J(i,"rawMetadata",e,t,!0),J(i,"rawDescription",e,t,!0),J(i,"rawHtmlMetadata",e,t,!0),se(i,"coordinatePrecision",e,t)}function Vs(n,e,t){let r=U(n,e,t);r&&(A(r.id,`${e}.id`,t),r.source!=="inline"&&r.source!=="external"&&z(t,`${e}.source`,'must be "inline" or "external"'),A(r.content,`${e}.content`,t,!0),A(r.type,`${e}.type`,t,!0),J(r,"svgId",e,t,!0),J(r,"href",e,t,!0),rn(r,"async",e,t),rn(r,"defer",e,t),r.customAttrs!==void 0&&sn(r.customAttrs,`${e}.customAttrs`,t),re(r,e,t))}function Us(n,e,t){let r=U(n,e,t);r&&(A(r.id,`${e}.id`,t),A(r.css,`${e}.css`,t,!0),mt(r.preserved,`${e}.preserved`,t),J(r,"svgId",e,t,!0),J(r,"type",e,t,!0),J(r,"media",e,t,!0),r.customAttrs!==void 0&&sn(r.customAttrs,`${e}.customAttrs`,t),re(r,e,t))}function Ws(n,e,t){let r=U(n,e,t);if(r){if(A(r.name,`${e}.name`,t),["string","color","number"].includes(String(r.type))||z(t,`${e}.type`,'must be "string", "color", or "number"'),A(r.defaultValue,`${e}.defaultValue`,t,!0),J(r,"label",e,t,!0),J(r,"description",e,t,!0),r.mode!==void 0&&r.mode!=="live"&&r.mode!=="stamped"&&z(t,`${e}.mode`,'must be "live" or "stamped"'),r.source!==void 0){let i=U(r.source,`${e}.source`,t);i&&i.kind!=="user"&&z(t,`${e}.source.kind`,'must be "user"')}re(r,e,t)}}function Hs(n,e,t){let r=U(n,e,t);r&&(A(r.id,`${e}.id`,t),A(r.filename,`${e}.filename`,t,!0),A(r.format,`${e}.format`,t),re(r,e,t))}function Nl(n,e,t){let r=U(n,e,t);r&&(we(r.glyphId,`${e}.glyphId`,t),Array.isArray(r.codepoints)?r.codepoints.forEach((i,s)=>we(i,`${e}.codepoints[${s}]`,t)):z(t,`${e}.codepoints`,"must be an array"),A(r.svgDocument,`${e}.svgDocument`,t,!0),J(r,"glyphName",e,t,!0),se(r,"advanceWidth",e,t),J(r,"sourceFamily",e,t,!0),se(r,"sourceGlyphId",e,t),J(r,"label",e,t,!0),re(r,e,t))}function js(n,e,t){let r=U(n,e,t);r&&(A(r.id,`${e}.id`,t),A(r.name,`${e}.name`,t,!0),A(r.svgContent,`${e}.svgContent`,t,!0),ae(r.width,`${e}.width`,t,0),ae(r.height,`${e}.height`,t,0),re(r,e,t))}function Ks(n,e,t){let r=U(n,e,t);r&&(A(r.id,`${e}.id`,t),["mask","clipPath","filter","linearGradient","radialGradient","pattern","symbol"].includes(String(r.type))||z(t,`${e}.type`,"is not a supported paint-server type"),A(r.markup,`${e}.markup`,t),rn(r,"passthrough",e,t),re(r,e,t))}function Xs(n,e,t){let r=U(n,e,t);if(!r)return;A(r.id,`${e}.id`,t),A(r.name,`${e}.name`,t,!0);let i=r.kind;if(["symbol","marker","linear-gradient","radial-gradient","pattern","filter"].includes(String(i))||z(t,`${e}.kind`,"is not a supported library kind"),(i==="symbol"||i==="marker")&&(X(r.shapes,`${e}.shapes`,t,Mt),r.groups!==void 0&&X(r.groups,`${e}.groups`,t,ur)),i==="symbol"&&A(r.viewBox,`${e}.viewBox`,t,!0),i==="marker"){for(let s of["refX","refY","markerWidth","markerHeight"])ae(r[s],`${e}.${s}`,t);r.markerUnits!=="strokeWidth"&&r.markerUnits!=="userSpaceOnUse"&&z(t,`${e}.markerUnits`,'must be "strokeWidth" or "userSpaceOnUse"'),r.orient!=="auto"&&r.orient!=="auto-start-reverse"&&!(typeof r.orient=="number"&&Number.isFinite(r.orient))&&z(t,`${e}.orient`,"must be an orientation keyword or finite number")}(i==="linear-gradient"||i==="radial-gradient")&&U(r.gradient,`${e}.gradient`,t),i==="pattern"&&U(r.pattern,`${e}.pattern`,t),i==="filter"&&X(r.filters,`${e}.filters`,t,(s,o,a)=>{U(s,o,a)}),re(r,e,t)}function Bl(n,e,t){let r=U(n,e,t);r&&(A(r.id,`${e}.id`,t),J(r,"viewBox",e,t,!0),r.shapes!==void 0&&X(r.shapes,`${e}.shapes`,t,Mt),r.groups!==void 0&&X(r.groups,`${e}.groups`,t,ur),re(r,e,t))}function qs(n,e,t,r){let i=U(n,e,t);i&&((r||i.id!==void 0)&&A(i.id,`${e}.id`,t),ae(i.time,`${e}.time`,t,0),typeof i.value!="string"&&!(typeof i.value=="number"&&Number.isFinite(i.value))&&!(Array.isArray(i.value)&&i.value.every(s=>typeof s=="number"&&Number.isFinite(s)))&&z(t,`${e}.value`,"must be a string, finite number, or finite number array"),A(i.easing,`${e}.easing`,t),re(i,e,t))}function Zs(n,e,t){let r=U(n,e,t);r&&(A(r.id,`${e}.id`,t),A(r.shapeId,`${e}.shapeId`,t),A(r.property,`${e}.property`,t),mt(r.enabled,`${e}.enabled`,t),rn(r,"locked",e,t),X(r.keyframes,`${e}.keyframes`,t,(i,s,o)=>qs(i,s,o,!1)),re(r,e,t))}function zl(n,e,t){let r=U(n,e,t);r&&(ae(r.duration,`${e}.duration`,t,0),mt(r.loop,`${e}.loop`,t),ae(r.playbackSpeed,`${e}.playbackSpeed`,t,0),X(r.tracks,`${e}.tracks`,t,Zs))}function Gl(n,e,t){let r=U(n,e,t);if(!r)return;we(r.start,`${e}.start`,t),we(r.end,`${e}.end`,t),typeof r.start=="number"&&typeof r.end=="number"&&r.end<=r.start&&z(t,`${e}.end`,"must be greater than start");let i=U(r.style,`${e}.style`,t);i&&Object.keys(i).length===0&&z(t,`${e}.style`,"must not be empty"),re(r,e,t)}function Vl(n,e,t){let r=U(n,e,t);r&&(I(r,e,["start","deleteCount","insert"],[],t,!1),we(r.start,`${e}.start`,t),we(r.deleteCount,`${e}.deleteCount`,t),A(r.insert,`${e}.insert`,t,!0))}var Js={"shape:add":(n,e,t)=>{I(n,e,["shape"],[],t),Mt(n.shape,`${e}.shape`,t)},"shape:update":(n,e,t)=>{if(I(n,e,["id","state"],["propTimestamps","clientId","textSplices","baseSeq"],t),A(n.id,`${e}.id`,t),Ll(n.state,`${e}.state`,t),n.propTimestamps!==void 0){let r=U(n.propTimestamps,`${e}.propTimestamps`,t);if(r)for(let[i,s]of Object.entries(r))ae(s,`${e}.propTimestamps.${i}`,t,0)}J(n,"clientId",e,t),n.textSplices!==void 0&&X(n.textSplices,`${e}.textSplices`,t,Vl),se(n,"baseSeq",e,t)},"shape:remove":(n,e,t)=>{I(n,e,["id"],[],t),A(n.id,`${e}.id`,t)},"text:format":(n,e,t)=>{I(n,e,["id","ranges"],["baseSeq",...G],t),A(n.id,`${e}.id`,t),X(n.ranges,`${e}.ranges`,t,Gl),se(n,"baseSeq",e,t),V(n,e,t)},"scene:move":(n,e,t)=>{I(n,e,["id","parentId","index"],G,t),A(n.id,`${e}.id`,t),n.parentId!==null&&A(n.parentId,`${e}.parentId`,t),we(n.index,`${e}.index`,t),V(n,e,t)},"scene:place":(n,e,t)=>{I(n,e,["id","parentId","orderKey"],G,t),A(n.id,`${e}.id`,t),n.parentId!==null&&A(n.parentId,`${e}.parentId`,t),A(n.orderKey,`${e}.orderKey`,t),V(n,e,t)},"shapes:reorder":(n,e,t)=>{I(n,e,["ids"],[],t),qe(n.ids,`${e}.ids`,t)},"groups:set":(n,e,t)=>{I(n,e,["groups"],[],t),X(n.groups,`${e}.groups`,t,ur)},"clipmasks:set":(n,e,t)=>{I(n,e,["clipMaskGroups"],[],t),X(n.clipMaskGroups,`${e}.clipMaskGroups`,t,Ls)},"clipMask:upsert":(n,e,t)=>{I(n,e,["clipMaskGroup"],["index",...G],t),Ls(n.clipMaskGroup,`${e}.clipMaskGroup`,t),se(n,"index",e,t),V(n,e,t)},"clipMask:remove":(n,e,t)=>{I(n,e,["id"],G,t),A(n.id,`${e}.id`,t),V(n,e,t)},"guides:set":(n,e,t)=>{I(n,e,["guides"],[],t),X(n.guides,`${e}.guides`,t,Ns)},"guide:upsert":(n,e,t)=>{I(n,e,["guide"],["index",...G],t),Ns(n.guide,`${e}.guide`,t),se(n,"index",e,t),V(n,e,t)},"guide:remove":(n,e,t)=>{I(n,e,["id"],G,t),A(n.id,`${e}.id`,t),V(n,e,t)},"guide:move":(n,e,t)=>{I(n,e,["id","index"],G,t),A(n.id,`${e}.id`,t),we(n.index,`${e}.index`,t),V(n,e,t)},"measurements:set":(n,e,t)=>{I(n,e,["measurements"],[],t),X(n.measurements,`${e}.measurements`,t,Bs)},"measurement:upsert":(n,e,t)=>{I(n,e,["measurement"],["index",...G],t),Bs(n.measurement,`${e}.measurement`,t),se(n,"index",e,t),V(n,e,t)},"measurement:remove":(n,e,t)=>{I(n,e,["id"],G,t),A(n.id,`${e}.id`,t),V(n,e,t)},"measurement:move":(n,e,t)=>{I(n,e,["id","index"],G,t),A(n.id,`${e}.id`,t),we(n.index,`${e}.index`,t),V(n,e,t)},"metadata:set":(n,e,t)=>{I(n,e,["metadata"],[],t),Gs(n.metadata,`${e}.metadata`,t,!1)},"metadata:patch":(n,e,t)=>{I(n,e,["patch"],["removeKeys",...G],t),Gs(n.patch,`${e}.patch`,t,!0),n.removeKeys!==void 0&&qe(n.removeKeys,`${e}.removeKeys`,t),V(n,e,t)},"documentScripts:set":(n,e,t)=>{I(n,e,["documentScripts"],[],t),X(n.documentScripts,`${e}.documentScripts`,t,Vs)},"documentScript:upsert":(n,e,t)=>{I(n,e,["documentScript"],["index",...G],t),Vs(n.documentScript,`${e}.documentScript`,t),se(n,"index",e,t),V(n,e,t)},"documentScript:remove":(n,e,t)=>{I(n,e,["id"],G,t),A(n.id,`${e}.id`,t),V(n,e,t)},"documentStyles:set":(n,e,t)=>{I(n,e,["documentStyles"],[],t),X(n.documentStyles,`${e}.documentStyles`,t,Us)},"documentStyle:upsert":(n,e,t)=>{I(n,e,["documentStyle"],["index",...G],t),Us(n.documentStyle,`${e}.documentStyle`,t),se(n,"index",e,t),V(n,e,t)},"documentStyle:remove":(n,e,t)=>{I(n,e,["id"],G,t),A(n.id,`${e}.id`,t),V(n,e,t)},"templateVariables:set":(n,e,t)=>{I(n,e,["templateVariables"],G,t),X(n.templateVariables,`${e}.templateVariables`,t,Ws),V(n,e,t)},"templateVariable:upsert":(n,e,t)=>{I(n,e,["templateVariable"],["index",...G],t),Ws(n.templateVariable,`${e}.templateVariable`,t),se(n,"index",e,t),V(n,e,t)},"templateVariable:remove":(n,e,t)=>{I(n,e,["name"],G,t),A(n.name,`${e}.name`,t),V(n,e,t)},"exportItems:set":(n,e,t)=>{I(n,e,["exportItems"],G,t),X(n.exportItems,`${e}.exportItems`,t,Hs),V(n,e,t)},"exportItem:upsert":(n,e,t)=>{I(n,e,["exportItem"],["index",...G],t),Hs(n.exportItem,`${e}.exportItem`,t),se(n,"index",e,t),V(n,e,t)},"exportItem:remove":(n,e,t)=>{I(n,e,["id"],G,t),A(n.id,`${e}.id`,t),V(n,e,t)},"colorGlyphLibrary:set":(n,e,t)=>{if(I(n,e,["colorGlyphLibrary"],G,t),n.colorGlyphLibrary!==null){let r=U(n.colorGlyphLibrary,`${e}.colorGlyphLibrary`,t);r&&(r.version!==1&&z(t,`${e}.colorGlyphLibrary.version`,"must be 1"),X(r.entries,`${e}.colorGlyphLibrary.entries`,t,Nl),re(r,`${e}.colorGlyphLibrary`,t))}V(n,e,t)},"animation:set":(n,e,t)=>{I(n,e,["animationTimeline"],[],t),n.animationTimeline!==void 0&&zl(n.animationTimeline,`${e}.animationTimeline`,t)},"animation:config":(n,e,t)=>{I(n,e,["config"],G,t);let r=U(n.config,`${e}.config`,t);r&&(I(r,`${e}.config`,["duration","loop","playbackSpeed"],[],t,!1),ae(r.duration,`${e}.config.duration`,t,0),mt(r.loop,`${e}.config.loop`,t),ae(r.playbackSpeed,`${e}.config.playbackSpeed`,t,0)),V(n,e,t)},"animation:clear":(n,e,t)=>{I(n,e,[],G,t),V(n,e,t)},"animationTrack:upsert":(n,e,t)=>{I(n,e,["track"],["index",...G],t),Zs(n.track,`${e}.track`,t),se(n,"index",e,t),V(n,e,t)},"animationTrack:remove":(n,e,t)=>{I(n,e,["id"],G,t),A(n.id,`${e}.id`,t),V(n,e,t)},"animationKeyframe:upsert":(n,e,t)=>{I(n,e,["trackId","keyframe"],G,t),A(n.trackId,`${e}.trackId`,t),qs(n.keyframe,`${e}.keyframe`,t,!0),V(n,e,t)},"animationKeyframe:remove":(n,e,t)=>{I(n,e,["trackId","keyframeId"],G,t),A(n.trackId,`${e}.trackId`,t),A(n.keyframeId,`${e}.keyframeId`,t),V(n,e,t)},"symbols:set":(n,e,t)=>{I(n,e,["symbols"],[],t),X(n.symbols,`${e}.symbols`,t,Bl)},"customPatterns:set":(n,e,t)=>{I(n,e,["customPatterns"],[],t),X(n.customPatterns,`${e}.customPatterns`,t,js)},"customPattern:upsert":(n,e,t)=>{I(n,e,["customPattern"],["index",...G],t),js(n.customPattern,`${e}.customPattern`,t),se(n,"index",e,t),V(n,e,t)},"customPattern:remove":(n,e,t)=>{I(n,e,["id"],G,t),A(n.id,`${e}.id`,t),V(n,e,t)},"library:set":(n,e,t)=>{I(n,e,["library"],[],t),X(n.library,`${e}.library`,t,Xs)},"library:upsert":(n,e,t)=>{I(n,e,["def"],["index",...G],t),Xs(n.def,`${e}.def`,t),se(n,"index",e,t),V(n,e,t)},"library:remove":(n,e,t)=>{I(n,e,["id"],G,t),A(n.id,`${e}.id`,t),V(n,e,t)},"rawPaintServerDefs:set":(n,e,t)=>{I(n,e,["rawPaintServerDefs"],[],t),qe(n.rawPaintServerDefs,`${e}.rawPaintServerDefs`,t)},"paintServerDefs:set":(n,e,t)=>{I(n,e,["paintServerDefs"],[],t),X(n.paintServerDefs,`${e}.paintServerDefs`,t,Ks)},"paintServerDef:upsert":(n,e,t)=>{I(n,e,["paintServerDef"],["index",...G],t),Ks(n.paintServerDef,`${e}.paintServerDef`,t),se(n,"index",e,t),V(n,e,t)},"paintServerDef:remove":(n,e,t)=>{I(n,e,["id"],G,t),A(n.id,`${e}.id`,t),V(n,e,t)},"presence:cursor":(n,e,t)=>{I(n,e,["position"],[],t);let r=U(n.position,`${e}.position`,t);r&&(I(r,`${e}.position`,["x","y"],[],t,!1),ae(r.x,`${e}.position.x`,t),ae(r.y,`${e}.position.y`,t))},"presence:selection":(n,e,t)=>{I(n,e,["shapeIds"],[],t),qe(n.shapeIds,`${e}.shapeIds`,t)}},Ul=new Set(Object.keys(Js)),Qs=new Set(["presence:cursor","presence:selection"]);function cr(n,e="operation"){let t=[],r=U(n,e,t);return r?!A(r.type,`${e}.type`,t)||!Ul.has(r.type)?(typeof r.type=="string"&&r.type.length>0&&z(t,`${e}.type`,`unknown operation type "${r.type}"`),{valid:!1,issues:t}):(Js[r.type](r,e,t),t.length===0?{valid:!0,value:r}:{valid:!1,issues:t}):{valid:!1,issues:t}}function Wl(n,e={}){let t=[];if(!Array.isArray(n))return{valid:!1,issues:[{path:"ops",message:"must be an array"}]};let r=e.minItems??1,i=e.maxItems??5e3;(n.length<r||n.length>i)&&z(t,"ops",`must contain ${r}-${i} operations`);let s=[];return n.forEach((o,a)=>{let l=cr(o,`ops[${a}]`);if(!l.valid){t.push(...l.issues);return}if(Qs.has(l.value.type)){z(t,`ops[${a}].type`,"presence operations are not document operations");return}s.push(l.value)}),t.length===0?{valid:!0,value:s}:{valid:!1,issues:t}}function Hl(n){let e=cr(n,"op");return e.valid?Qs.has(e.value.type)?{valid:!0,value:e.value}:{valid:!1,issues:[{path:"op.type",message:"must be a presence operation"}]}:e}function jl(n){return n.slice(0,5).map(({path:e,message:t})=>`${e} ${t}`).join("; ")}function dr(n,e,t,r){let i=e[t],s=typeof i=="string"?i:"",o=(n??[]).filter(l=>l[t]!==s),a=typeof r=="number"&&Number.isFinite(r)?Math.max(0,Math.min(r,o.length)):o.length;return o.splice(a,0,e),o}function fr(n,e,t){return(n??[]).filter(r=>r[e]!==t)}function ye(n,e,t){return dr(n,e,"id",t)}function be(n,e){return fr(n,"id",e)}function pr(n,e,t){return dr(n,e,"name",t)}function mr(n,e){return fr(n,"name",e)}function Kl(n,e){if(n===e)return null;let t=0,r=Math.min(n.length,e.length);for(;t<r&&n.charCodeAt(t)===e.charCodeAt(t);)t++;let i=0,s=Math.min(n.length,e.length)-t;for(;i<s&&n.charCodeAt(n.length-1-i)===e.charCodeAt(e.length-1-i);)i++;return{start:t,deleteCount:n.length-t-i,insert:e.slice(t,e.length-i)}}function Xl(n,e){return n.slice(0,e.start)+e.insert+n.slice(e.start+e.deleteCount)}function an(n,e){let t=e.start,r=e.start+e.deleteCount,i=e.insert.length-e.deleteCount,s=n.start,o=n.start+n.deleteCount;return r<=s?{start:s+i,deleteCount:n.deleteCount,insert:n.insert}:t>=o?{start:s,deleteCount:n.deleteCount,insert:n.insert}:t<=s&&r>=o?{start:t+e.insert.length,deleteCount:0,insert:n.insert}:t>=s&&r<=o?{start:s,deleteCount:n.deleteCount+i,insert:n.insert}:t<s?{start:t+e.insert.length,deleteCount:n.deleteCount-(r-s),insert:n.insert}:{start:s,deleteCount:t-s,insert:n.insert}}var on=Object.freeze({fontFamily:"Arial",fontSize:16,fontWeight:"normal",fontStyle:"normal",fontVariant:"",fontVariantLigatures:"",fontVariantPosition:"",fontVariantCaps:"",fontVariantNumeric:"",fontVariantEastAsian:"",textDecoration:Object.freeze({underline:!1,strikethrough:!1,overline:!1}),textTransform:"none",baselineShift:"baseline",dominantBaseline:"auto",writingMode:"horizontal-tb",whiteSpace:"pre-wrap",direction:"ltr",unicodeBidi:"normal",textAnchor:"start",letterSpacing:0,wordSpacing:0,lineHeight:1.2,fontVariationSettings:Object.freeze({}),fill:"#000000",fillOpacity:1,stroke:"none",strokeWidth:0,strokeOpacity:1}),Ct=Object.keys(on);function Ne(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function Oe(n){return typeof n=="string"?n:void 0}function oe(n){if(typeof n=="number")return Number.isFinite(n)?n:void 0;if(typeof n=="string"&&n.trim()!==""){let e=Number.parseFloat(n);return Number.isFinite(e)?e:void 0}}function He(n){return e=>typeof e=="string"&&n.includes(e)?e:void 0}function Yl(n){return n==="normal"||n==="bold"?n:oe(n)}function ql(n){return n==="baseline"||n==="super"||n==="sub"?n:oe(n)}function ta(n){if(typeof n=="string"){let t=n.toLowerCase();return{underline:t.includes("underline"),strikethrough:t.includes("line-through")||t.includes("strikethrough"),overline:t.includes("overline")}}if(!Ne(n))return;let e={};return typeof n.underline=="boolean"&&(e.underline=n.underline),typeof n.strikethrough=="boolean"&&(e.strikethrough=n.strikethrough),typeof n.overline=="boolean"&&(e.overline=n.overline),e}function na(n){if(!Ne(n))return;let e={};for(let[t,r]of Object.entries(n)){let i=oe(r);i!==void 0&&(e[t]=i)}return e}var ra={fontFamily:Oe,fontSize:oe,fontWeight:Yl,fontStyle:He(["normal","italic","oblique"]),fontVariant:Oe,fontVariantLigatures:Oe,fontVariantPosition:Oe,fontVariantCaps:Oe,fontVariantNumeric:Oe,fontVariantEastAsian:Oe,textTransform:He(["none","capitalize","uppercase","lowercase"]),baselineShift:ql,dominantBaseline:He(["auto","alphabetic","central","middle","hanging","ideographic","mathematical","text-top","text-bottom"]),writingMode:He(["horizontal-tb","vertical-rl","vertical-lr"]),whiteSpace:He(["normal","nowrap","pre","pre-wrap","pre-line","break-spaces"]),direction:He(["ltr","rtl"]),unicodeBidi:He(["normal","embed","bidi-override","isolate","isolate-override","plaintext"]),textAnchor:He(["start","middle","end"]),letterSpacing:oe,wordSpacing:oe,lineHeight:oe,fill:Oe,fillOpacity:oe,stroke:Oe,strokeWidth:oe,strokeOpacity:oe};function hr(n,e){return{...n,...e,textDecoration:{...n.textDecoration,...e.textDecoration??{}},fontVariationSettings:{...e.fontVariationSettings??n.fontVariationSettings}}}function Sr(n,e){let t=Object.keys(n);return t.length!==Object.keys(e).length?!1:t.every(r=>Object.prototype.hasOwnProperty.call(e,r)&&n[r]===e[r])}function xr(n,e){for(let t of Ct)if(t==="textDecoration"){if(n.textDecoration.underline!==e.textDecoration.underline||n.textDecoration.strikethrough!==e.textDecoration.strikethrough||n.textDecoration.overline!==e.textDecoration.overline)return!1}else if(t==="fontVariationSettings"){if(!Sr(n.fontVariationSettings,e.fontVariationSettings))return!1}else if(n[t]!==e[t])return!1;return!0}function $r(n,e){let t=Object.keys(n).sort(),r=Object.keys(e).sort();if(t.length!==r.length||t.some((i,s)=>i!==r[s]))return!1;for(let i of t)if(i==="textDecoration"){let s=n.textDecoration??{},o=e.textDecoration??{},a=new Set([...Object.keys(s),...Object.keys(o)]);for(let l of a){let c=l;if(s[c]!==o[c])return!1}}else if(i==="fontVariationSettings"){if(!Sr(n.fontVariationSettings??{},e.fontVariationSettings??{}))return!1}else{let s=i;if(n[s]!==e[s])return!1}return!0}function gr(n,e){let t={};for(let i of Ct)i==="textDecoration"||i==="fontVariationSettings"||n[i]!==e[i]&&(t[i]=n[i]);let r={};return n.textDecoration.underline!==e.textDecoration.underline&&(r.underline=n.textDecoration.underline),n.textDecoration.strikethrough!==e.textDecoration.strikethrough&&(r.strikethrough=n.textDecoration.strikethrough),n.textDecoration.overline!==e.textDecoration.overline&&(r.overline=n.textDecoration.overline),Object.keys(r).length>0&&(t.textDecoration=r),Sr(n.fontVariationSettings,e.fontVariationSettings)||(t.fontVariationSettings={...n.fontVariationSettings}),t}function Le(n,e=on){let t=Ne(n)?n:{},r={...e};for(let i of Ct){if(i==="textDecoration"||i==="fontVariationSettings")continue;let s=ra[i](t[i]);s!==void 0&&(r[i]=s)}return r.textDecoration={...e.textDecoration,...ta(t.textDecoration)??{}},r.fontVariationSettings={...na(t.fontVariationSettings)??e.fontVariationSettings},r}function ln(n){let e=Ne(n)?n:{},t={};for(let r of Ct){if(r==="textDecoration"||r==="fontVariationSettings"||e[r]===void 0)continue;let i=ra[r](e[r]);i!==void 0&&(t[r]=i)}if(e.textDecoration!==void 0){let r=ta(e.textDecoration);r&&Object.keys(r).length>0&&(t.textDecoration=r)}if(e.fontVariationSettings!==void 0){let r=na(e.fontVariationSettings);r&&(t.fontVariationSettings=r)}return t}function ia(n){let e=[],t=0;for(;;){let r=n.indexOf(`
2
- `,t);if(r===-1)return e.push({text:n.slice(t),start:t,end:n.length}),e;e.push({text:n.slice(t,r),start:t,end:r}),t=r+1}}function Zl(n,e,t){return n.start===n.end?t&&n.start===e:n.start<=e&&e<n.end}function yr(n,e,t,r){let i=n;for(let s of e)Zl(s,t,r)&&(i=hr(i,s.style));return i===n?hr(n,{}):i}function Jl(n,e,t={}){let r=Le(n.baseStyle),i=typeof n.text=="string"?n.text:"";return yr(r,vr(n.runs,i.length),e,t.collapsed===!0)}function ht(n,e=on){let t=Ne(n)?n:{},r=Le(t.baseStyle,e),i=typeof t.text=="string"?t.text:"";return{text:i,runs:vr(t.runs,i.length),baseStyle:r,lineHeight:oe(t.lineHeight)??r.lineHeight}}function vr(n,e){if(!Array.isArray(n))return[];let t=[];for(let r of n){if(!Ne(r))continue;let i=oe(r.start),s=oe(r.end);if(i===void 0||s===void 0)continue;let o=Math.min(Math.max(Math.trunc(i),0),e),a=Math.min(Math.max(Math.trunc(s),0),e);o>a||t.push({start:o,end:a,style:ln(r.style)})}return t}function je(n){let e=typeof n.text=="string"?n.text:"",t=Le(n.baseStyle),r=vr(n.runs,e.length),i=oe(n.lineHeight)??t.lineHeight;return{lines:ia(e).map(o=>{if(o.text.length===0)return{segments:[{text:"",style:yr(t,r,o.start,!0)}]};let a=new Set([o.start,o.end]);for(let f of r)f.start!==f.end&&(f.start>o.start&&f.start<o.end&&a.add(f.start),f.end>o.start&&f.end<o.end&&a.add(f.end));let l=[...a].sort((f,d)=>f-d),c=[];for(let f=0;f<l.length-1;f++){let d=l[f],p=l[f+1],m=yr(t,r,d,!1),h=c[c.length-1];h&&xr(h.style,m)?h.text+=e.slice(d,p):c.push({text:e.slice(d,p),style:m})}return{segments:c}}),baseStyle:t,lineHeight:i}}function gt(n){let e=Le(n?.baseStyle),t=oe(n?.lineHeight)??e.lineHeight,r=Array.isArray(n?.lines)?n.lines:[],i=r.length>0?r:[{segments:[]}],s=[],o=[],a=0;for(let f=0;f<i.length;f++){f>0&&(s.push(`
3
- `),a+=1);let d=i[f]?.segments,p=Array.isArray(d)?d:[],m=a;for(let h of p){let g=typeof h?.text=="string"?h.text:"";if(g.length===0)continue;let b=Le(h?.style,e),$=gr(b,e);Object.keys($).length>0&&o.push({start:a,end:a+g.length,style:$}),s.push(g),a+=g.length}if(a===m){let h=Le(p[0]?.style,e),g=gr(h,e);Object.keys(g).length>0&&o.push({start:m,end:m,style:g})}}let l=s.join(""),c=[];for(let f of o){let d=c[c.length-1];d!==void 0&&d.start!==d.end&&f.start!==f.end&&(d.end===f.start||d.end+1===f.start&&l.charAt(d.end)===`
4
- `)&&$r(d.style,f.style)&&d?d.end=f.end:c.push({start:f.start,end:f.end,style:f.style})}return{text:l,runs:c,baseStyle:e,lineHeight:t}}function kr(n){let e=n.richTextRuns;if(Ne(e))return ht(e);let t=n.richTextData;return Ne(t)&&Array.isArray(t.lines)&&t.lines.length>0?gt(t):null}function br(n){let e=new Set;for(let t of Object.keys(n))if(t==="textDecoration")for(let r of Object.keys(n.textDecoration??{}))e.add(`textDecoration.${r}`);else e.add(t);return e}function Ql(n,e){if(n.start===n.end||e.start>=e.end||n.start<e.start||n.end>e.end)return!1;let t=br(e.style);for(let r of br(n.style))if(!t.has(r))return!1;return!0}function un(n,e){let t=[...n];for(let r of e)r.start>=r.end||Object.keys(r.style).length!==0&&(t=t.filter(i=>!Ql(i,r)),t.push({start:r.start,end:r.end,style:r.style}));return t}function Tr(n,e){if(!Array.isArray(n))return[];let t=[];for(let r of n){if(!Ne(r))continue;let i=oe(r.start),s=oe(r.end);if(i===void 0||s===void 0)continue;let o=Math.min(Math.max(Math.trunc(i),0),e),a=Math.min(Math.max(Math.trunc(s),0),e);if(o>=a)continue;let l=ln(r.style);Object.keys(l).length!==0&&t.push({start:o,end:a,style:l})}return t}function eu(n,e){let t=[];for(let r of n){let i=an({start:r.start,deleteCount:r.end-r.start,insert:""},e),s=i.start,o=s+i.deleteCount;s>=o||t.push({start:s,end:o,style:r.style})}return t}function ea(n,e){return n.start===e.start&&n.end===e.end&&$r(n.style,e.style)}function tu(n,e){if(n.text!==e.text||n.lineHeight!==e.lineHeight||!xr(Le(n.baseStyle),Le(e.baseStyle)))return null;let t=Array.isArray(n.runs)?n.runs:[],r=Array.isArray(e.runs)?e.runs:[],i=0,s=0;for(;s<r.length;){let l=-1;for(let c=i;c<t.length;c++)if(ea(t[c],r[s])){l=c;break}if(l===-1)break;i=l+1,s++}let o=r.slice(s);if(o.length===0)return null;for(let l of o)if(l.start>=l.end||Object.keys(l.style).length===0)return null;let a=un(t,o);if(a.length!==r.length)return null;for(let l=0;l<a.length;l++)if(!ea(a[l],r[l]))return null;return o.map(l=>({start:l.start,end:l.end,style:ln(l.style)}))}function nu(n,e){let t=e===0||n.charAt(e-1)===`
5
- `,r=e===n.length||n.charAt(e)===`
6
- `;return t&&r}function ru(n,e,t){let r=[];for(let i of n){let s=i.start===i.end,o=an({start:i.start,deleteCount:i.end-i.start,insert:""},e),a=o.start,l=o.start+o.deleteCount;a===l&&(!s||!nu(t,a))||r.push({start:a,end:l,style:i.style})}return r}function Ke(n,e=n.id){return{kind:"pattern",id:e,name:n.name??e,pattern:{type:"pattern",svgContent:n.svgContent,width:n.width,height:n.height,patternType:"custom",color:"#000000",backgroundColor:"transparent",scale:1,rotation:0,opacity:1,patternUnits:"userSpaceOnUse"}}}function cn(n){if(n.builtIn)return!1;let e=n.pattern;return!e||typeof e!="object"?!1:e.patternType==="custom"&&typeof e.svgContent=="string"}function sa(n){let e=(n.viewBox??"").trim().split(/[\s,]+/).filter(s=>s.length>0).map(Number),t=e.length===4&&e.every(s=>Number.isFinite(s)),r=t&&e[2]>0?e[2]:n.width??10,i=t&&e[3]>0?e[3]:n.height??10;return{width:r,height:i}}function Dt(n){if(!cn(n))return null;let{width:e,height:t}=sa(n.pattern);return{id:n.id,name:n.name,svgContent:n.pattern.svgContent??"",width:e,height:t}}function Ae(n){let e=[...n].sort((i,s)=>i.index-s.index);if(!e.some(i=>i.orderKey))return e;let t=sr(e.length),r=new Map;return e.forEach((i,s)=>{r.set(i.id,i.orderKey??t[s])}),e.sort((i,s)=>{let o=en(r.get(i.id)??"",r.get(s.id)??"");return o!==0?o:i.id<s.id?-1:i.id>s.id?1:0})}var iu=/^structural:(clip|mask):(.+):(group|path|content)$/;function aa(n,e){let t=`structural:${n}:${e}`;return{group:`${t}:group`,path:`${t}:path`,content:`${t}:content`}}function oa(n,e){for(let t of n){e.add(t.id);let r=t.state.children;Array.isArray(r)&&oa(r,e)}}function la(n,e=null){let t=[];return n.forEach((r,i)=>{t.push({id:r.id,parentId:e,index:i});let s=r.state.children;Array.isArray(s)&&t.push(...la(s,r.id))}),t}function dn(n){let e=n.sceneTree&&n.sceneTree.length>0?n.sceneTree:la(n.shapes),t=new Map(e.map(S=>[S.id,S])),r=new Map;for(let S of e){let x=r.get(S.parentId)??[];x.push(S),r.set(S.parentId,x)}for(let[S,x]of r)r.set(S,Ae(x));let i=S=>iu.test(S),s=new Set(e.filter(S=>!i(S.id)).map(S=>S.id)),o=new Set;oa(n.shapes,o);let a=new Map,l=new Set,c=(S,x)=>{let v=[];for(let w of r.get(S)??[]){if(!i(w.id)){l.has(w.id)||(l.add(w.id),v.push(w.id));continue}if(x.has(w.id))continue;let T=new Set(x);T.add(w.id),v.push(...c(w.id,T))}return v},f=[null,...s];for(let S of f){let x=c(S,new Set);x.length>0&&a.set(S,x)}for(let S of s){if(l.has(S))continue;let x=t.get(S)?.parentId??null,v=x!==null&&s.has(x)?x:null,w=a.get(v)??[];w.push(S),a.set(v,w),l.add(S)}let d=S=>{for(let[x,v]of a){let w=v.indexOf(S);if(w>=0)return{parentId:x,index:w}}return null},p=S=>{for(let x of a.values()){let v=x.indexOf(S);v>=0&&x.splice(v,1)}},m=n.clipMaskGroups??[],h=new Map(m.map(S=>[aa(S.type,S.id).content,S])),g=(S,x=new Set)=>{if(x.has(S.id))return Number.MAX_SAFE_INTEGER;let v=S.parentId?h.get(S.parentId):void 0;if(!v)return 0;let w=new Set(x);return w.add(S.id),1+g(v,w)},b=[...m].sort((S,x)=>g(S)-g(x)||(S.siblingIndex??0)-(x.siblingIndex??0)),$=new Map;for(let S of b){let x=(S.clipShapeIds.length>0?S.clipShapeIds:S.clipShapeId?[S.clipShapeId]:[]).filter(L=>o.has(L)),v=S.contentShapeIds.filter(L=>o.has(L));if(v.length===0||x.length===0&&!S.rawDefinition)continue;let w=[...v,...x].map(d).filter(L=>L!==null),T=w[0]?.parentId??null,P=w.length>0?Math.min(...w.map(L=>L.index)):void 0,R=S.parentId===null||s.has(S.parentId)||h.has(S.parentId)?S.parentId:T;for(let L of[...x,...v])p(L);let M=aa(S.type,S.id),N=a.get(R)??[],B=S.siblingIndex??P??N.length,D=Math.min(Math.max(0,B),N.length);N.splice(D,0,M.group),a.set(R,N),a.set(M.group,[M.path,M.content]),a.set(M.path,[...x]),a.set(M.content,[...v]),$.set(M.group,{id:M.group,parentId:R,index:0}),$.set(M.path,{id:M.path,parentId:M.group,index:0}),$.set(M.content,{id:M.content,parentId:M.group,index:1})}let k=[];for(let[S,x]of a)x.forEach((v,w)=>{let T=$.get(v);if(T){k.push({...T,parentId:S,index:w});return}let P=t.get(v);P&&P.parentId===S?k.push({...P,index:w}):k.push({id:v,parentId:S,index:w})});n.sceneTree=k}function Se(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function wr(n){return Se(n)&&typeof n.updatedAt=="number"&&Number.isSafeInteger(n.updatedAt)&&n.updatedAt>=0&&typeof n.clientId=="string"}function Ze(n,e){return{updatedAt:typeof n=="number"&&Number.isSafeInteger(n)&&n>=0?n:0,clientId:e??""}}function Ft(n,e){return wr(e)?n.updatedAt>e.updatedAt||n.updatedAt===e.updatedAt&&n.clientId>=e.clientId:!0}function ua(n){return Se(n.collaborationState)||(n.collaborationState={}),n.collaborationState}function ca(n,e){let t=ua(n);Se(t.shapeProps)||(t.shapeProps={});let r=t.shapeProps;return Se(r[e])||(r[e]={}),r[e]}function Et(n,e){let t=n.collaborationState?.shapeProps;if(!Se(t))return{};let r=t[e];return Se(r)?r:{}}function da(n,e,t,r){if(t.length===0)return;let i=ca(n,e);for(let s of t)Ft(r,i[s])&&(i[s]=r)}function Pr(n,e){let t=n.collaborationState?.shapeProps;if(Se(t)){for(let r of e)delete t[r];su(n)}}function su(n){let e=n.collaborationState;if(Se(e)){for(let t of["shapeProps","resources"]){let r=e[t];Se(r)&&Object.keys(r).length===0&&delete e[t]}Object.keys(e).length===0&&delete n.collaborationState}}function fa(n){switch(n.type){case"guide:upsert":return`guide:${n.guide.id}`;case"guide:remove":case"guide:move":return`guide:${n.id}`;case"measurement:upsert":return`measurement:${n.measurement.id}`;case"measurement:remove":case"measurement:move":return`measurement:${n.id}`;case"metadata:patch":return"metadata:document";case"documentScript:upsert":return`documentScript:${n.documentScript.id}`;case"documentScript:remove":return`documentScript:${n.id}`;case"documentStyle:upsert":return`documentStyle:${n.documentStyle.id}`;case"documentStyle:remove":return`documentStyle:${n.id}`;case"templateVariable:upsert":return`templateVariable:${n.templateVariable.name}`;case"templateVariable:remove":return`templateVariable:${n.name}`;case"exportItem:upsert":return`exportItem:${n.exportItem.id}`;case"exportItem:remove":return`exportItem:${n.id}`;case"colorGlyphLibrary:set":return"colorGlyphLibrary";case"animation:config":case"animation:clear":case"animationTrack:upsert":case"animationTrack:remove":return"animation:timeline";case"animationKeyframe:upsert":return`animationKeyframe:${n.trackId}:${n.keyframe.id}`;case"animationKeyframe:remove":return`animationKeyframe:${n.trackId}:${n.keyframeId}`;case"clipMask:upsert":return`clipMask:${n.clipMaskGroup.id}`;case"clipMask:remove":return`clipMask:${n.id}`;case"library:upsert":return`library:${n.def.id}`;case"library:remove":return`library:${n.id}`;case"customPattern:upsert":return`customPattern:${n.customPattern.id}`;case"customPattern:remove":return`customPattern:${n.id}`;case"paintServerDef:upsert":return`paintServerDef:${n.paintServerDef.id}`;case"paintServerDef:remove":return`paintServerDef:${n.id}`;default:return null}}function pa(n,e,t){if(e.type==="shape:update"&&e.propTimestamps){if(!t)return null;let a=Et(n,e.id),l={},c={},f=[];for(let[p,m]of Object.entries(e.state)){let h=Ze(e.propTimestamps[p],e.clientId);Ft(h,a[p])&&(l[p]=m,c[p]=h.updatedAt,f.push([p,h]))}if(f.length===0)return null;let d=ca(n,e.id);for(let[p,m]of f)d[p]=m;return{...e,state:l,propTimestamps:c}}let r=fa(e);if(r===null||!("updatedAt"in e)||e.updatedAt===void 0)return e;let i=Ze(e.updatedAt,e.clientId),s=ua(n);Se(s.resources)||(s.resources={});let o=s.resources;return Ft(i,o[r])?(o[r]=i,{...e,updatedAt:i.updatedAt,clientId:i.clientId}):null}function au(n){let e=0,t=n.collaborationState?.shapeProps;if(Se(t)){for(let i of Object.values(t))if(Se(i))for(let s of Object.values(i))wr(s)&&(e=Math.max(e,s.updatedAt))}let r=n.collaborationState?.resources;if(Se(r))for(let i of Object.values(r))wr(i)&&(e=Math.max(e,i.updatedAt));for(let i of n.sceneTree??[])typeof i.updatedAt=="number"&&Number.isSafeInteger(i.updatedAt)&&i.updatedAt>=0&&(e=Math.max(e,i.updatedAt));return e}function ou(n,e){let t=Object.keys(e.state);if(t.length===0)return;let r=Et(n,e.id),i=0;for(let o of t){let a=Ze(e.propTimestamps?.[o],e.clientId);i=Math.max(i,r[o]?.updatedAt??0,a.updatedAt)}let s=i+1;e.propTimestamps=Object.fromEntries(t.map(o=>[o,s]))}function Je(n){n.symbols!==void 0&&(n.symbols=(n.library??[]).filter(e=>e.kind==="symbol").map(({kind:e,...t})=>t)),n.customPatterns!==void 0&&(n.customPatterns=(n.library??[]).filter(e=>e.kind==="pattern").map(e=>Dt(e)).filter(e=>e!==null))}function Sa(n,e=null){let t=[];return n.forEach((r,i)=>{t.push({id:r.id,parentId:e,index:i});let s=r.state.children;Array.isArray(s)&&t.push(...Sa(s,r.id))}),t}function pe(n,e){if(n===e)return!0;let t=n??ma,r=e??ma;if(t.length!==r.length)return!1;for(let i=0;i<t.length;i++)if(t[i]!==r[i])return!1;return!0}var ma=[];function Ot(n){return n.sceneTree&&n.sceneTree.length>0?n.sceneTree:Sa(n.shapes)}function lu(n,e){let t=n,r=new Set(n.map(o=>o.id)),i=(o,a,l)=>{r.has(o.id)||(t=Rr(t,{id:o.id,parentId:a,index:l}),r.add(o.id)),yt(o)?.forEach((f,d)=>i(f,o.id,d))},s=t.filter(o=>o.parentId===null).length;return i(e,null,s),t}function xa(n){let e=new Map;for(let r of n){let i=e.get(r.parentId)??[];i.push(r),e.set(r.parentId,i)}let t=[];for(let r of e.values())Ae(r).forEach((i,s)=>t.push({...i,index:s}));return t}function pn(n,e){let t=n.filter(l=>l.parentId===e);if(t.every(l=>l.orderKey))return n;let r=Ae(t),i=new Map,s=[],o=null,a=l=>{if(s.length===0)return;let c=ir(o,l,s.length);s.forEach((f,d)=>i.set(f.id,c[d])),s=[]};for(let l of r)l.orderKey?(a(l.orderKey),o=l.orderKey):s.push(l);return a(null),n.map(l=>i.has(l.id)?{...l,orderKey:i.get(l.id)}:l)}function Rr(n,e){let t,r=[],i=[],s=!1;for(let l of n){if(l.id===e.id){if(t=l,!Ir(e,t))return n;continue}l.parentId===e.parentId?(r.push(l),l.orderKey&&(s=!0)):i.push(l)}if(s){let l=pn([...i,...r],e.parentId),c=Ae(l.filter(h=>h.parentId===e.parentId)),f=Math.min(Math.max(0,e.index),c.length),d=f>0?c[f-1].orderKey??null:null,p=f<c.length?c[f].orderKey??null:null,m=d!==null&&p!==null&&d>=p?d:It(d,p);return[...i,...c,{...e,orderKey:m}]}let o=r.sort((l,c)=>l.index-c.index).map((l,c)=>({...l,index:c})),a=Math.min(Math.max(0,e.index),o.length);return[...i,...o,{...e,index:a-.5}]}function Ar(n,e,t){let r=n?[...n]:[],i=r.find(s=>s.id===e);return i?ye(r,i,t):r}function uu(n){n.keyframes.sort((e,t)=>{if(e.time!==t.time)return e.time-t.time;let r=e.id??"",i=t.id??"";return r<i?-1:r>i?1:0})}function $a(n,e){let t=n.keyframes.findIndex(r=>r.id===e.id);t>=0?n.keyframes[t]=e:n.keyframes.push(e),uu(n)}function va(n,e){n.keyframes=n.keyframes.filter(t=>t.id!==e)}function ha(n,e){let t=n.animationTimeline?.tracks;return Array.isArray(t)?t.find(r=>r.id===e)??null:null}function Ir(n,e){let t=n.updatedAt??0,r=e.updatedAt??0;return t!==r?t>r:(n.clientId??"")>=(e.clientId??"")}function yt(n){let e=n.state.children;return Array.isArray(e)?e:void 0}var _r=new Set(["group","hyperlink","switch","container","svg"]);function ka(n,e,t,r){for(let i of n){t.set(i.id,e),r.set(i.id,i);let s=yt(i);s&&ka(s,i.id,t,r)}}function Ta(n){let e=n.sceneTree;if(!e||e.length===0)return;let t=new Map,r=new Map;if(ka(n.shapes,null,t,r),r.size===0)return;for(let d of r.values())delete d.state.groupId;let i=new Map;for(let d of e){let p=i.get(d.parentId)??[];p.push(d),i.set(d.parentId,p)}let s=new Map,o=(d,p)=>{let m=s.get(d);m?m.push(p):s.set(d,[p])},a=new Set,l=new Set,c=(d,p)=>{for(let m of Ae(i.get(d)??[])){if(l.has(m.id))continue;l.add(m.id);let h=r.get(m.id);if(!h){c(m.id,p);continue}o(p,h),a.add(h.id),_r.has(h.type)&&c(m.id,h.id)}};if(c(null,null),a.size===0)return;let f=d=>{let p=t.get(d)??null,m=new Set;for(;p!==null&&!m.has(p);){m.add(p);let h=r.get(p);if(h&&_r.has(h.type))return p;p=t.get(p)??null}return null};for(let[d,p]of r)a.has(d)||o(f(d),p);for(let[d,p]of r){if(!_r.has(p.type))continue;let m=p.state,h=s.get(d);h&&h.length>0?m.children=h:"children"in m&&delete m.children}n.shapes=s.get(null)??[]}function cu(n){let e=`structural:${n.type}:${n.id}`;return{group:`${e}:group`,path:`${e}:path`,content:`${e}:content`}}function Lt(n){let e=n.clipMaskGroups;if(!e||e.length===0)return;let t=n.sceneTree;if(!t||t.length===0)return;let r=new Set(t.map(o=>o.id)),i=new Map;for(let o of t){if(o.parentId===null)continue;let a=i.get(o.parentId);a?a.push(o):i.set(o.parentId,[o])}let s=o=>Ae(i.get(o)??[]).map(a=>a.id).filter(a=>!a.startsWith("structural:"));n.clipMaskGroups=e.map(o=>{let a=cu(o);if(!r.has(a.group))return o;let l=r.has(a.path)?s(a.path):o.clipShapeIds,c=r.has(a.content)?s(a.content):o.contentShapeIds;if(ga(l,o.clipShapeIds)&&ga(c,o.contentShapeIds))return o;let f={...o,clipShapeIds:l,contentShapeIds:c};return(f.clipShapeId!==void 0||l.length>0)&&(f.clipShapeId=l[0]),f})}function ga(n,e){return!e||n.length!==e.length?!1:n.every((t,r)=>t===e[r])}function Cr(n,e){e.add(n.id);let t=yt(n);if(t)for(let r of t)Cr(r,e)}function Mr(n,e){for(let t of n){e.set(t.id,t);let r=yt(t);r&&Mr(r,e)}}var fn=class{constructor(e,t){this.snapshot=e;this.indexed=t}snapshot;indexed;shapeIndex=null;inlineProjectionPending=!1;sceneTreeNormalizePending=!1;memoId=null;memoShape=null;findShape(e){if(this.memoId===e)return this.memoShape;let t;return this.indexed?(this.shapeIndex===null&&(this.shapeIndex=new Map,Mr(this.snapshot.shapes,this.shapeIndex)),t=this.shapeIndex.get(e)??null):t=bt(this.snapshot.shapes,e),this.memoId=e,this.memoShape=t,t}noteShapesAdded(e){this.memoId=null,this.memoShape=null,this.shapeIndex!==null&&Mr([e],this.shapeIndex)}noteShapesRemoved(){this.shapeIndex=null,this.memoId=null,this.memoShape=null}requestInlineProjection(){this.inlineProjectionPending=!0}requestSceneTreeNormalize(){this.sceneTreeNormalizePending=!0}settle(){if(this.sceneTreeNormalizePending){this.sceneTreeNormalizePending=!1;let e=this.snapshot.sceneTree;e&&e.length>0&&(this.snapshot.sceneTree=xa(e))}this.inlineProjectionPending&&(this.inlineProjectionPending=!1,Ta(this.snapshot))}};function bt(n,e){for(let t of n){if(t.id===e)return t;let r=yt(t);if(!r)continue;let i=bt(r,e);if(i)return i}return null}function Qe(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function du(n){let e=n.richTextRuns;return!Qe(e)||typeof e.text!="string"?null:ht(e)}function fu(n,e){let t=n.state;"extra"in t&&Ue(t);let r=new Set;for(let[i,s]of Object.entries(e))s===null?r.add(i):t[i]=s;if(r.size>0){let i={};for(let[s,o]of Object.entries(t))r.has(s)||(i[s]=o);n.state=i}}function wa(n,e,t){let r=[];for(let i of n){if(i.id===e){Cr(i,t);continue}let s=yt(i);if(s){let o=wa(s,e,t),a=i.state;o.length>0?a.children=o:delete a.children}r.push(i)}return r}function Pa(n,e){let t=n.snapshot,r=t,i=pa(t,e,e.type!=="shape:update"||n.findShape(e.id)!==null);if(i===null)return null;let s=i,o=s;switch(s.type){case"shape:add":{if(!(n.findShape(s.shape.id)!==null)){let l=Ot(r),c=nn(structuredClone(s.shape));r.shapes.push(c),r.sceneTree=lu(l,c),n.noteShapesAdded(c),n.requestSceneTreeNormalize(),n.requestInlineProjection();let f=new Set;Cr(c,f),Pr(t,f)}break}case"shape:update":{let a=n.findShape(s.id);if(!a)return null;fu(a,s.state);break}case"text:format":{let a=n.findShape(s.id);if(!a)return null;let l=a.state;"extra"in l&&Ue(l);let c=du(l);if(!c)return null;let f=Tr(s.ranges,c.text.length);if(f.length===0)return null;let d={...c,runs:un(c.runs,f)};l.richTextRuns=d;let p=["richTextRuns"];if(Qe(l.richTextData)&&(l.richTextData=je(d),p.push("richTextData")),s.updatedAt!==void 0){let m=Ze(s.updatedAt,s.clientId),h=Et(t,s.id);if(p.some(b=>!Ft(m,h?.[b]))){let b=Math.max(0,...p.map($=>h?.[$]?.updatedAt??0));m={updatedAt:Math.max(m.updatedAt,b)+1,clientId:m.clientId},o={...s,updatedAt:m.updatedAt,clientId:m.clientId}}da(t,s.id,p,m)}break}case"shape:remove":{let a=new Set,l=wa(r.shapes,s.id,a),c=a.size>0;c||a.add(s.id);let f=Ot(r),d=f.filter(p=>!a.has(p.id));if(!c&&d.length===f.length)return null;r.shapes=l,r.sceneTree=d,n.noteShapesRemoved(),Pr(t,a),Lt(r);break}case"scene:move":{let a=Ot(r),l=a.find(d=>d.id===s.id),c=s.updatedAt===void 0?void 0:Ze(s.updatedAt,s.clientId),f={id:s.id,parentId:s.parentId,index:s.index,updatedAt:c?.updatedAt,clientId:c?.clientId};if(l&&!Ir(f,l))return null;r.sceneTree=Rr(a,f),n.requestSceneTreeNormalize(),c&&(o={...s,...c}),n.requestInlineProjection(),Lt(r);break}case"scene:place":{if(!Qt(s.orderKey))return null;let a=Ot(r),l=a.find(p=>p.id===s.id),c=s.updatedAt===void 0?void 0:Ze(s.updatedAt,s.clientId),f={id:s.id,parentId:s.parentId,index:l?.index??Number.MAX_SAFE_INTEGER,orderKey:s.orderKey,updatedAt:c?.updatedAt,clientId:c?.clientId};if(l&&!Ir(f,l))return null;let d=pn(a,s.parentId);r.sceneTree=[...d.filter(p=>p.id!==s.id),f],n.requestSceneTreeNormalize(),n.requestInlineProjection(),Lt(r),c&&(o={...s,...c});break}case"shapes:reorder":{let a=Ot(r);s.ids.forEach((l,c)=>{a.some(f=>f.id===l&&f.parentId===null)&&(a=Rr(a,{id:l,parentId:null,index:c}))}),r.sceneTree=a,n.requestSceneTreeNormalize(),n.requestInlineProjection(),Lt(r);break}case"groups:set":r.groups=s.groups;break;case"clipmasks:set":r.clipMaskGroups=s.clipMaskGroups,dn(r);break;case"clipMask:upsert":r.clipMaskGroups=ye(r.clipMaskGroups,s.clipMaskGroup,s.index),dn(r);break;case"clipMask:remove":{let a=be(r.clipMaskGroups,s.id);if(pe(r.clipMaskGroups,a))return null;r.clipMaskGroups=a,dn(r);break}case"guides:set":r.guides=s.guides;break;case"guide:upsert":r.guides=ye(r.guides,s.guide,s.index);break;case"guide:remove":{let a=be(r.guides,s.id);if(pe(r.guides,a))return null;r.guides=a;break}case"guide:move":{let a=Ar(r.guides,s.id,s.index);if(pe(r.guides,a))return null;r.guides=a;break}case"measurements:set":r.measurements=s.measurements;break;case"measurement:upsert":r.measurements=ye(r.measurements,s.measurement,s.index);break;case"measurement:remove":{let a=be(r.measurements,s.id);if(pe(r.measurements,a))return null;r.measurements=a;break}case"measurement:move":{let a=Ar(r.measurements,s.id,s.index);if(pe(r.measurements,a))return null;r.measurements=a;break}case"metadata:set":r.documentMetadata=s.metadata;break;case"metadata:patch":{let a=Object.fromEntries(Object.entries({...r.documentMetadata??{},...s.patch}).filter(([l])=>!(s.removeKeys??[]).includes(l)));r.documentMetadata=a;break}case"documentScripts:set":r.documentScripts=s.documentScripts;break;case"documentScript:upsert":r.documentScripts=ye(r.documentScripts,s.documentScript,s.index);break;case"documentScript:remove":{let a=be(r.documentScripts,s.id);if(pe(r.documentScripts,a))return null;r.documentScripts=a;break}case"documentStyles:set":r.documentStyles=s.documentStyles;break;case"documentStyle:upsert":r.documentStyles=ye(r.documentStyles,s.documentStyle,s.index);break;case"documentStyle:remove":{let a=be(r.documentStyles,s.id);if(pe(r.documentStyles,a))return null;r.documentStyles=a;break}case"templateVariables:set":r.templateVariables=s.templateVariables;break;case"templateVariable:upsert":r.templateVariables=pr(r.templateVariables,s.templateVariable,s.index);break;case"templateVariable:remove":{let a=mr(r.templateVariables,s.name);if(pe(r.templateVariables,a))return null;r.templateVariables=a;break}case"exportItems:set":r.exportItems=s.exportItems;break;case"exportItem:upsert":r.exportItems=ye(r.exportItems,s.exportItem,s.index);break;case"exportItem:remove":{let a=be(r.exportItems,s.id);if(pe(r.exportItems,a))return null;r.exportItems=a;break}case"colorGlyphLibrary:set":s.colorGlyphLibrary===null?delete r.colorGlyphLibrary:r.colorGlyphLibrary=s.colorGlyphLibrary;break;case"animation:set":r.animationTimeline=s.animationTimeline;break;case"animation:config":r.animationTimeline={duration:s.config.duration,loop:s.config.loop,playbackSpeed:s.config.playbackSpeed,tracks:Array.isArray(r.animationTimeline?.tracks)?r.animationTimeline.tracks:[]};break;case"animation:clear":delete r.animationTimeline;break;case"animationTrack:upsert":r.animationTimeline={duration:typeof r.animationTimeline?.duration=="number"?r.animationTimeline.duration:0,loop:typeof r.animationTimeline?.loop=="boolean"?r.animationTimeline.loop:!1,playbackSpeed:typeof r.animationTimeline?.playbackSpeed=="number"?r.animationTimeline.playbackSpeed:1,tracks:ye(Array.isArray(r.animationTimeline?.tracks)?r.animationTimeline.tracks:[],s.track,s.index)};break;case"animationTrack:remove":{let a=Array.isArray(r.animationTimeline?.tracks)?r.animationTimeline.tracks:[],l=be(a,s.id);if(pe(a,l)&&!r.animationTimeline)return null;l.length>0&&r.animationTimeline?r.animationTimeline={...r.animationTimeline,tracks:l}:delete r.animationTimeline;break}case"animationKeyframe:upsert":{let a=ha(r,s.trackId);if(!a)return null;$a(a,structuredClone(s.keyframe));break}case"animationKeyframe:remove":{let a=ha(r,s.trackId);if(!a)return null;let l=a.keyframes;if(va(a,s.keyframeId),pe(l,a.keyframes))return null;break}case"symbols:set":{r.symbols=s.symbols;let a=s.symbols.map(c=>({...c,kind:"symbol"})),l=(r.library??[]).filter(c=>c.kind!=="symbol");r.library=[...a,...l],Je(r);break}case"customPatterns:set":r.customPatterns=s.customPatterns;{let a=new Set(s.customPatterns.map(c=>c.id)),l=(r.library??[]).filter(c=>!a.has(c.id)&&(c.kind!=="pattern"||!cn(c)));r.library=[...l,...s.customPatterns.map(c=>Ke(c))]}Je(r);break;case"customPattern:upsert":{r.customPatterns=ye(r.customPatterns,s.customPattern,s.index);let a=Ke(s.customPattern),l=[...r.library??[]],c=l.findIndex(f=>f.id===a.id);c>=0?l[c]=a:l.push(a),r.library=l,Je(r);break}case"customPattern:remove":{let a=be(r.customPatterns,s.id),l=be(r.library,s.id);if(pe(r.customPatterns,a)&&pe(r.library,l))return null;r.customPatterns=a,r.library=l,Je(r);break}case"library:set":r.library=s.library,Je(r);break;case"library:upsert":r.library=ye(r.library,s.def,s.index),Je(r);break;case"library:remove":{let a=be(r.library,s.id);if(pe(r.library,a))return null;r.library=a,Je(r);break}case"rawPaintServerDefs:set":r.rawPaintServerDefs=s.rawPaintServerDefs,delete r.paintServerDefs;break;case"paintServerDefs:set":r.paintServerDefs=s.paintServerDefs,r.rawPaintServerDefs=s.paintServerDefs.map(a=>a.markup);break;case"paintServerDef:upsert":r.paintServerDefs=ye(r.paintServerDefs,s.paintServerDef,s.index),r.rawPaintServerDefs=r.paintServerDefs.map(a=>a.markup);break;case"paintServerDef:remove":{let a=be(r.paintServerDefs,s.id);if(pe(r.paintServerDefs,a))return null;r.paintServerDefs=a,r.rawPaintServerDefs=a.map(l=>l.markup);break}case"presence:cursor":case"presence:selection":break;default:{let a=s;return null}}return o}function pu(n,e,t){if(e.type==="shape:update"&&e.propTimestamps){let r=t?.type==="shape:update"?new Set(Object.keys(t.state)):new Set,i=Object.keys(e.state).filter(s=>!r.has(s));return ya(n,e.id,i)}if(e.type==="text:format"&&t?.type==="text:format"){if(!(t.updatedAt!==e.updatedAt||t.clientId!==e.clientId))return[];let i=bt(n.shapes,e.id)?.state,s=i&&Qe(_a(i,"richTextData"))?["richTextRuns","richTextData"]:["richTextRuns"];return ya(n,e.id,s)}return[]}function _a(n,e){if(e in n)return n[e];let t=n.extra;return Qe(t)?t[e]:void 0}function mu(n,e){if(e in n)return!0;let t=n.extra;return Qe(t)&&e in t}function ya(n,e,t){if(t.length===0)return[];let r=bt(n.shapes,e);if(!r)return[];let i=r.state,s=Et(n,e),o=new Map;for(let l of t){let c=s[l];if(!c)continue;let f=o.get(c.clientId);f?f.push(l):o.set(c.clientId,[l])}let a=[];for(let[l,c]of o){let f={},d={};for(let p of c)f[p]=mu(i,p)?structuredClone(_a(i,p)):null,d[p]=s[p].updatedAt;a.push({type:"shape:update",id:e,state:f,propTimestamps:d,clientId:l})}return a}function hu(n,e){let t=new fn(n,!1),r=Pa(t,e);return t.settle(),r}function Ra(n,e){let t=new fn(n,e.length>1),r=[];for(let i of e){let s=Pa(t,i);s&&r.push(s)}return t.settle(),r}function Aa(n,e){let t=structuredClone(n);return{snapshot:t,acceptedOps:Ra(t,e)}}function gu(n,e){return Aa(n,e).snapshot}function yu(n){if(!n||n.length===0||n.every(t=>t.orderKey))return n;let e=n;for(let t of new Set(n.map(r=>r.parentId)))e=pn(e,t);return xa(e)}function bu(n,e){if(!n.some(r=>r.type==="scene:place"))return n;let t=new Map((e??[]).map(r=>[r.id,r]));return n.map(r=>{if(r.type!=="scene:place")return r;let i=t.get(r.id);return{type:"scene:move",id:r.id,parentId:i?.parentId??r.parentId,index:i?.index??0,updatedAt:r.updatedAt,clientId:r.clientId}})}function Su(n,e){if(!n.some(i=>i.type==="animationKeyframe:upsert"||i.type==="animationKeyframe:remove"))return n;let t=Array.isArray(e?.tracks)?e.tracks:[],r=[];for(let i of n){if(i.type!=="animationKeyframe:upsert"&&i.type!=="animationKeyframe:remove"){r.push(i);continue}let s=t.findIndex(o=>o.id===i.trackId);s!==-1&&r.push({type:"animationTrack:upsert",track:structuredClone(t[s]),index:s,updatedAt:i.updatedAt,clientId:i.clientId})}return r}function xu(n,e){if(!n.some(r=>r.type==="text:format"))return n;let t=[];for(let r of n){if(r.type!=="text:format"){t.push(r);continue}let i=bt(e,r.id);if(!i)continue;let s=i.state.richTextRuns;if(!Qe(s))continue;let o={richTextRuns:structuredClone(s)},a=i.state.richTextData;Qe(a)&&(o.richTextData=structuredClone(a)),t.push({type:"shape:update",id:r.id,state:o,...typeof r.updatedAt=="number"?{propTimestamps:Object.fromEntries(Object.keys(o).map(l=>[l,r.updatedAt]))}:{},...r.clientId!==void 0?{clientId:r.clientId}:{}})}return t}function $u(n,e){if(!n.some(r=>r.type==="guide:move"||r.type==="measurement:move"))return n;let t=[];for(let r of n)if(r.type==="guide:move"){let i=e.guides??[],s=i.findIndex(o=>o.id===r.id);if(s===-1)continue;t.push({type:"guide:upsert",guide:structuredClone(i[s]),index:s,updatedAt:r.updatedAt,clientId:r.clientId})}else if(r.type==="measurement:move"){let i=e.measurements??[],s=i.findIndex(o=>o.id===r.id);if(s===-1)continue;t.push({type:"measurement:upsert",measurement:structuredClone(i[s]),index:s,updatedAt:r.updatedAt,clientId:r.clientId})}else t.push(r);return t}var vu=6,ba=new Set(["templateVariables:set","templateVariable:upsert","templateVariable:remove","exportItems:set","exportItem:upsert","exportItem:remove","colorGlyphLibrary:set"]);function ku(n){return n.some(e=>ba.has(e.type))?n.filter(e=>!ba.has(e.type)):n}var hn=Object.freeze([1,0,0,1,0,0]);function Xe(n,e,t,r,i,s){return[n,e,t,r,i,s]}function Dr(n){return Xe(n[0]??1,n[1]??0,n[2]??0,n[3]??1,n[4]??0,n[5]??0)}function et(n){return[n[0],n[1],n[2],n[3],n[4],n[5]]}function Bt(n){return Array.isArray(n)&&n.length>=6&&n.slice(0,6).every(Number.isFinite)}function Fa(n,e=1e-9){return Math.abs((n[0]??1)-1)<=e&&Math.abs(n[1]??0)<=e&&Math.abs(n[2]??0)<=e&&Math.abs((n[3]??1)-1)<=e&&Math.abs(n[4]??0)<=e&&Math.abs(n[5]??0)<=e}function Nm(n,e,t=1e-9){for(let r=0;r<6;r++)if(Math.abs(n[r]-e[r])>t)return!1;return!0}function ie(n,e){return Xe(n[0]*e[0]+n[2]*e[1],n[1]*e[0]+n[3]*e[1],n[0]*e[2]+n[2]*e[3],n[1]*e[2]+n[3]*e[3],n[0]*e[4]+n[2]*e[5]+n[4],n[1]*e[4]+n[3]*e[5]+n[5])}function Bm(n){let e=n[0]*n[3]-n[2]*n[1];if(Math.abs(e)<1e-10)return null;let t=1/e;return Xe(n[3]*t,-n[1]*t,-n[2]*t,n[0]*t,(n[2]*n[5]-n[3]*n[4])*t,(n[1]*n[4]-n[0]*n[5])*t)}function zm(n,e){return{x:n[0]*e.x+n[2]*e.y+n[4],y:n[1]*e.x+n[3]*e.y+n[5]}}function Gm(n,e){return{x:n[0]*e.x+n[2]*e.y,y:n[1]*e.x+n[3]*e.y}}function Ie(n,e=0){return Xe(1,0,0,1,n,e)}function gn(n,e=n){return Xe(n,0,0,e,0,0)}function zt(n){let e=n*Math.PI/180,t=Math.cos(e),r=Math.sin(e);return Xe(t,r,-r,t,0,0)}function yn(n){return Xe(1,0,Math.tan(n*Math.PI/180),1,0,0)}function bn(n){return Xe(1,Math.tan(n*Math.PI/180),0,1,0,0)}function Ea(n,e){return ie(ie(Ie(n.x,n.y),e),Ie(-n.x,-n.y))}var Tu=9,wu=10,Pu=12,_u=13,Ru=32,Ia=43,Au=44,Ma=45,Iu=46,Mu=48,Cu=57,Du=40,Fu=41,Eu=69,Ou=101,Lu=0,Nu=1,Oa=2,Bu=new Map([["matrix",[6]],["translate",[1,2]],["scale",[1,2]],["rotate",[1,3]],["skewX",[1]],["skewY",[1]]]);function zu(n){return n===Ru||n===Tu||n===wu||n===_u||n===Pu}function mn(n){return n>=Mu&&n<=Cu}function Gu(n){let e=n>=65&&n<=90,t=n>=97&&n<=122;return e||t||mn(n)}function St(n){for(;n.pos<n.src.length&&zu(n.src.charCodeAt(n.pos));)n.pos++}function La(n){let e=n.pos;return St(n),n.src.charCodeAt(n.pos)===Au?(n.pos++,St(n),Oa):n.pos>e?Nu:Lu}function Ca(n){let e=n.src,t=n.pos,r=t,i=e.charCodeAt(r);(i===Ia||i===Ma)&&r++;let s=!1;for(;r<e.length&&mn(e.charCodeAt(r));)r++,s=!0;if(e.charCodeAt(r)===Iu){let l=r+1;for(;l<e.length&&mn(e.charCodeAt(l));)l++;l>r+1&&(r=l,s=!0)}if(!s)return null;let o=e.charCodeAt(r);if(o===Ou||o===Eu){let l=r+1,c=e.charCodeAt(l);(c===Ia||c===Ma)&&l++;let f=l;for(;f<e.length&&mn(e.charCodeAt(f));)f++;f>l&&(r=f)}let a=Number(e.slice(t,r));return Number.isFinite(a)?(n.pos=r,a):null}function Vu(n,e){switch(n){case"matrix":return Dr(e);case"translate":return Ie(e[0],e[1]??0);case"scale":return gn(e[0],e[1]??e[0]);case"rotate":return e.length===3?Ea({x:e[1],y:e[2]},zt(e[0])):zt(e[0]);case"skewX":return yn(e[0]);case"skewY":return bn(e[0]);default:return null}}function Uu(n){let e=n.src,t=n.pos;for(;n.pos<e.length&&Gu(e.charCodeAt(n.pos));)n.pos++;if(n.pos===t)return null;let r=e.slice(t,n.pos),i=Bu.get(r);if(!i||(St(n),e.charCodeAt(n.pos)!==Du))return null;n.pos++,St(n);let s=i[i.length-1],o=Ca(n);if(o===null)return null;let a=[o];for(;;){let l=n.pos;La(n);let c=Ca(n);if(c===null){n.pos=l;break}if(a.push(c),a.length>s)return null}return St(n),e.charCodeAt(n.pos)!==Fu||(n.pos++,!i.includes(a.length))?null:Vu(r,a)}function Wu(n){let e={src:n,pos:0};if(St(e),e.pos>=n.length)return hn;let t=hn;for(;;){let r=Uu(e);if(r===null)return null;t=ie(t,r);let i=La(e);if(e.pos>=n.length)return i===Oa?null:t}}var Hu=2048,Nt=new Map;function ju(n){if(!n)return hn;let e=Nt.get(n);if(e!==void 0)return e;let t=Wu(n),r=t===null?null:Object.freeze(t);if(Nt.size>=Hu){let i=Nt.keys().next().value;i!==void 0&&Nt.delete(i)}return Nt.set(n,r),r}function Fr(n){return ju(n)??hn}function Vm(n){let e=n[0],t=n[1],r=n[2],i=n[3],s=Math.sqrt(e*e+t*t);if(s<1e-12)return{rotation:0,scaleX:0,scaleY:Math.sqrt(r*r+i*i),skewX:0};let o=Math.atan2(t,e),l=(e*i-t*r)/s,c=l!==0?(e*r+t*i)/(s*s):0,f=Math.atan(c),d=180/Math.PI;return{rotation:o*d,scaleX:s,scaleY:l,skewX:f*d}}function Da(n){return!Bt(n)||Fa(n)?null:`matrix(${n[0]}, ${n[1]}, ${n[2]}, ${n[3]}, ${n[4]}, ${n[5]})`}function Sn(n,e){let t=n.translateX??0,r=n.translateY??0,i=typeof n.rawTransform=="string"?n.rawTransform:"",s=n.rotation??0,o=n.skewX??0,a=n.skewY??0,l=n.scaleX??1,c=n.scaleY??1,f=Ie(t,r);if(i)return ie(f,Fr(i));if(s===0&&o===0&&a===0&&l===1&&c===1)return f;let d=n.customPivot??e;if(!d)return f;let p=ie(ie(ie(zt(s),gn(l,c)),yn(o)),bn(a));return ie(f,Ea(d,p))}function Gt(n,e){let t=Da(n.transformMatrix);return t||(Da(et(Sn(n,e)))??null)}function Na(n,e){let t=n.ancestorTransform;if(!Bt(t)){delete n.ancestorTransform;return}if(Fa(t)){delete n.ancestorTransform;return}let r=Bt(n.transformMatrix)?Dr(n.transformMatrix):Sn(n,e);n.transformMatrix=et(ie(Dr(t),r)),delete n.ancestorTransform}function Ba(n,e,t){let r=Gt(n,{x:e,y:t});return r?`${r} translate(${e}, ${t})`:`translate(${e}, ${t})`}function Va(n){let e=n.customPivot;if(e)return e;let t=n.x,r=n.y,i=n.width,s=n.height;if(typeof t=="number"&&typeof r=="number"&&typeof i=="number"&&typeof s=="number")return{x:t+i/2,y:r+s/2};let o=n.radius;if(typeof t=="number"&&typeof r=="number"&&typeof o=="number")return{x:t,y:r};let a=n.cx,l=n.cy;if(typeof a=="number"&&typeof l=="number")return{x:a,y:l};let c=n.x1,f=n.y1,d=n.x2,p=n.y2;if(typeof c=="number"&&typeof f=="number"&&typeof d=="number"&&typeof p=="number")return{x:(c+d)/2,y:(f+p)/2};let m=n.pathPoints;if(m?.[0])return{x:m[0].x,y:m[0].y};let h=n.polylinePoints;if(h?.[0])return{x:h[0].x,y:h[0].y}}function Vt(n){if(Array.isArray(n))for(let e of n){let t=e.state;Na(t,Va(t));let r=e.state.children;Vt(r)}}function Ku(n){Vt(n.shapes);for(let e of n.library??[])if(e.kind==="symbol"){Vt(e.shapes);for(let t of Object.values(e.variants??{}))Vt(t)}else e.kind==="marker"&&Vt(e.shapes);return n.schemaVersion=3,n}function Er(n){let e=n;return e&&typeof e.x=="number"&&Number.isFinite(e.x)&&typeof e.y=="number"&&Number.isFinite(e.y)?{x:e.x,y:e.y}:null}function Xu(n,e){let t=n.translateX??0,r=n.translateY??0,i=typeof n.rawTransform=="string"?n.rawTransform:"",s=Ie(t,r);if(i)return et(ie(s,Fr(i)));let o=n.rotation??0,a=n.skewX??0,l=n.skewY??0;if(o!==0||a!==0||l!==0){let d=Er(n.customPivot)??e??Er(n.scaleAnchor);d&&(s=ie(s,Ie(d.x,d.y)),o!==0&&(s=ie(s,zt(o))),a!==0&&(s=ie(s,yn(a))),l!==0&&(s=ie(s,bn(l))),s=ie(s,Ie(-d.x,-d.y)))}let c=n.scaleX??1,f=n.scaleY??1;if(c!==1||f!==1){let d=Er(n.scaleAnchor)??e;d&&(s=ie(s,Ie(d.x,d.y)),s=ie(s,gn(c,f)),s=ie(s,Ie(-d.x,-d.y)))}return et(s)}function Ut(n){if(Array.isArray(n))for(let e of n){let t=e.state;"scaleAnchor"in t&&(e.type==="text"&&!Bt(t.transformMatrix)&&(t.transformMatrix=Xu(t,Va(t))),delete t.scaleAnchor);let r=e.state.children;Ut(r)}}function Yu(n){Ut(n.shapes);for(let e of n.library??[])if(e.kind==="symbol"){Ut(e.shapes);for(let t of Object.values(e.variants??{}))Ut(t)}else e.kind==="marker"&&Ut(e.shapes);return n.schemaVersion=4,n}function qu(n){let e=Array.isArray(n.library)?[...n.library]:[],t=new Set(e.map(l=>l.id));if(Array.isArray(n.symbols))for(let l of n.symbols)!l||t.has(l.id)||(e.push({...l,kind:"symbol"}),t.add(l.id));if(Array.isArray(n.markers))for(let l of n.markers)!l||t.has(l.id)||(e.push({...l,kind:"marker"}),t.add(l.id));let r=new Map,i=(l,c)=>{let{id:f,sourceId:d,...p}=l,m=JSON.stringify({kind:c,...p}),h=r.get(m);if(h)return h;let g=t.has(l.id)?`grd-${xn()}`:l.id;t.add(g),r.set(m,g);let b=c==="linear-gradient"?{kind:"linear-gradient",id:g,name:l.sourceId??g,sourceId:l.sourceId,gradient:za(l)}:{kind:"radial-gradient",id:g,name:l.sourceId??g,sourceId:l.sourceId,gradient:za(l)};return e.push(b),g},s=new Map;if(Array.isArray(n.customPatterns))for(let l of n.customPatterns){if(!l)continue;let c=t.has(l.id)?`pat-${xn()}`:l.id;t.add(c),s.set(l.id,c),e.push(Ke(l,c))}let o=l=>{if(l.customPatternId){let $=s.get(l.customPatternId);if($)return $}let{id:c,sourceId:f,customPatternId:d,...p}=l,m=JSON.stringify({kind:"pattern",...p}),h=r.get(m);if(h)return h;let g=t.has(l.id)?`pat-${xn()}`:l.id;t.add(g),r.set(m,g);let b={kind:"pattern",id:g,name:l.sourceId??g,sourceId:l.sourceId,pattern:p};return e.push(b),g};for(let l of n.shapes??[]){let c=l.state;if(!c)continue;let f=c.fillGradient;f&&(f.type==="linear-gradient"||f.type==="radial-gradient"?c.fillLibraryId=i(f,f.type):f.type==="pattern"&&(c.fillLibraryId=o(f)));let d=c.strokeGradient;d&&(d.type==="linear-gradient"||d.type==="radial-gradient"?c.strokeLibraryId=i(d,d.type):d.type==="pattern"&&(c.strokeLibraryId=o(d)));let p=c.filters;if(Array.isArray(p)&&p.length>0){let m=a(p,c,l.id);c.filterLibraryIds=[m]}}return n.library=e,n;function a(l,c,f){let d={filters:l,colorInterpolation:c.filterColorInterpolation,filterUnits:c.filterUnits,primitiveUnits:c.primitiveUnits,x:c.filterX,y:c.filterY,width:c.filterWidth,height:c.filterHeight},p=JSON.stringify({kind:"filter",...d}),m=r.get(p);if(m)return m;let h=`filter-${f}`,g=t.has(h)?`flt-${xn()}`:h;t.add(g),r.set(p,g);let b={kind:"filter",id:g,name:g,filters:d.filters,...d.colorInterpolation?{colorInterpolation:d.colorInterpolation}:{},...d.filterUnits?{filterUnits:d.filterUnits}:{},...d.primitiveUnits?{primitiveUnits:d.primitiveUnits}:{},...d.x!==void 0?{x:d.x}:{},...d.y!==void 0?{y:d.y}:{},...d.width!==void 0?{width:d.width}:{},...d.height!==void 0?{height:d.height}:{}};return e.push(b),g}}function za(n){let{id:e,sourceId:t,...r}=n;return r}var Or=0;function xn(){return Or=Or+1&65535,`${Date.now().toString(36)}-${Or.toString(36)}`}function Zu(n){let e=t=>{if(Array.isArray(t))for(let r of t)ft(r)};e(n.shapes);for(let t of n.library??[])if(t.kind==="symbol"){e(t.shapes);for(let r of Object.values(t.variants??{}))e(r)}else t.kind==="marker"&&e(t.shapes);return n.schemaVersion=5,n}function Ga(n){if(!n||typeof n!="object"||Array.isArray(n))return;let e=n;if(e.richTextRuns!==void 0&&e.richTextRuns!==null)return;let t=e.richTextData;!t||typeof t!="object"||Array.isArray(t)||Array.isArray(t.lines)&&(e.richTextRuns=gt(t))}function Ua(n){if(!n?.state||typeof n.state!="object")return;let e=n.state,t=e.children;if(Array.isArray(t))for(let i of t)Ua(i);let r=e.symbolOverrides;if(r&&typeof r=="object"&&!Array.isArray(r))for(let i of Object.values(r))Ga(i);Ga(e)}function Ju(n){let e=t=>{if(Array.isArray(t))for(let r of t)Ua(r)};e(n.shapes);for(let t of n.library??[])if(t.kind==="symbol"){e(t.shapes);for(let r of Object.values(t.variants??{}))e(r)}else t.kind==="marker"&&e(t.shapes);return n.schemaVersion=6,n}var Wa=Object.freeze({1:qu,2:Ku,3:Yu,4:Zu,5:Ju});function Qu(n){let e=n.schemaVersion;return typeof e!="number"||!Number.isFinite(e)||e<1?1:Math.floor(e)}function Lr(n,e=Wa){let t=JSON.parse(JSON.stringify(n)),r=Qu(t);if(r>ve)return t;if(r===ve)return t.schemaVersion=ve,t;for(;r<ve;){let i=e[r];if(!i)throw new Error(`[svgsketch/core] No migration registered for schema version ${r} \u2192 ${r+1}. Cannot safely upgrade this document to version ${ve}.`);t=i(t),r+=1}return t.schemaVersion=ve,t}function tt(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}async function Br(n,e,t,r){let i=n[e];typeof i=="string"&&(n[e]=await r(i,t))}async function Nr(n,e){tt(n)&&await Br(n,"svgContent","svgMarkup",e)}async function zr(n,e){if(!tt(n))return;await Br(n,"href","href",e),await Nr(n.fillGradient,e),await Nr(n.strokeGradient,e);let t=n.children;if(Array.isArray(t))for(let r of t)tt(r)&&await zr(r.state,e)}async function ec(n,e){if(!tt(n))return;let t=n.shapes;if(Array.isArray(t))for(let s of t)tt(s)&&await zr(s.state,e);let r=n.library;if(Array.isArray(r))for(let s of r)tt(s)&&s.kind==="pattern"&&await Nr(s.pattern,e);let i=n.customPatterns;if(Array.isArray(i))for(let s of i)tt(s)&&await Br(s,"svgContent","svgMarkup",e)}var tc=new Set(["circle","rectangle","square","ellipse","text","triangle","ngon","star","cross","ring","spiral","gear","arrow","line","path","polyline","image"]);function $n(n){let e=[],t=[];if(n==null||typeof n!="object")return e.push({path:"",message:"Snapshot must be a non-null object",severity:"error"}),{valid:!1,errors:e,warnings:t};let r=n;if(r.schemaVersion!==void 0&&(typeof r.schemaVersion!="number"||!Number.isInteger(r.schemaVersion)?e.push({path:"schemaVersion",message:"schemaVersion must be an integer",severity:"error"}):r.schemaVersion>ve&&t.push({path:"schemaVersion",message:`schemaVersion ${r.schemaVersion} is newer than supported (${ve})`,severity:"warning"})),!Array.isArray(r.shapes))e.push({path:"shapes",message:"shapes must be an array",severity:"error"});else{let i=new Set;r.shapes.forEach((s,o)=>{ac(s,`shapes[${o}]`,e,t,i)})}if(!Array.isArray(r.viewboxes))e.push({path:"viewboxes",message:"viewboxes must be an array",severity:"error"});else{let i=new Set;r.viewboxes.forEach((s,o)=>{uc(s,`viewboxes[${o}]`,e,t,i)})}if(r.guides!==void 0&&(Array.isArray(r.guides)?r.guides.forEach((i,s)=>{cc(i,`guides[${s}]`,e,t)}):e.push({path:"guides",message:"guides must be an array",severity:"error"})),r.groups!==void 0&&(Array.isArray(r.groups)?r.groups.forEach((i,s)=>{dc(i,`groups[${s}]`,e)}):e.push({path:"groups",message:"groups must be an array",severity:"error"})),r.sceneTree!==void 0)if(!Array.isArray(r.sceneTree))e.push({path:"sceneTree",message:"sceneTree must be an array",severity:"error"});else{let i=nc(r.shapes),s=new Set;r.sceneTree.forEach((o,a)=>{rc(o,`sceneTree[${a}]`,e,t,i,s)})}if(r.clipMaskGroups!==void 0&&(Array.isArray(r.clipMaskGroups)?r.clipMaskGroups.forEach((i,s)=>{fc(i,`clipMaskGroups[${s}]`,e)}):e.push({path:"clipMaskGroups",message:"clipMaskGroups must be an array",severity:"error"})),r.paintServerDefs!==void 0)if(!Array.isArray(r.paintServerDefs))e.push({path:"paintServerDefs",message:"paintServerDefs must be an array",severity:"error"});else{let i=new Set;r.paintServerDefs.forEach((s,o)=>{sc(s,`paintServerDefs[${o}]`,e,i)})}return r.measurements!==void 0&&(Array.isArray(r.measurements)||e.push({path:"measurements",message:"measurements must be an array",severity:"error"})),{valid:e.length===0,errors:e,warnings:t}}function nc(n){let e=new Set;if(!Array.isArray(n))return e;let t=r=>{if(r===null||typeof r!="object")return;let i=r;typeof i.id=="string"&&i.id.length>0&&e.add(i.id);let o=i.state?.children;if(Array.isArray(o))for(let a of o)t(a)};for(let r of n)t(r);return e}function Ha(n){return n.startsWith("structural:")}function rc(n,e,t,r,i,s){if(n===null||typeof n!="object"){t.push({path:e,message:"Scene tree entry must be a non-null object",severity:"error"});return}let o=n;typeof o.id!="string"||o.id.length===0?t.push({path:`${e}.id`,message:"Scene tree id must be a non-empty string",severity:"error"}):(s.has(o.id)&&t.push({path:`${e}.id`,message:`Duplicate scene tree id: "${o.id}"`,severity:"error"}),s.add(o.id),!i.has(o.id)&&!Ha(o.id)&&r.push({path:`${e}.id`,message:`Scene tree id "${o.id}" is not present in shapes`,severity:"warning"})),o.parentId!==null&&typeof o.parentId!="string"?t.push({path:`${e}.parentId`,message:"Scene tree parentId must be a string or null",severity:"error"}):typeof o.parentId=="string"&&!i.has(o.parentId)&&!Ha(o.parentId)&&r.push({path:`${e}.parentId`,message:`Scene tree parentId "${o.parentId}" is not present in shapes`,severity:"warning"}),(typeof o.index!="number"||!Number.isInteger(o.index)||o.index<0)&&t.push({path:`${e}.index`,message:"Scene tree index must be a non-negative integer",severity:"error"}),o.updatedAt!==void 0&&(typeof o.updatedAt!="number"||!Number.isFinite(o.updatedAt)||o.updatedAt<0)&&t.push({path:`${e}.updatedAt`,message:"Scene tree updatedAt must be a non-negative finite number",severity:"error"}),o.clientId!==void 0&&typeof o.clientId!="string"&&t.push({path:`${e}.clientId`,message:"Scene tree clientId must be a string",severity:"error"})}var ic=new Set(["mask","clipPath","filter","linearGradient","radialGradient","pattern","symbol"]);function sc(n,e,t,r){if(n===null||typeof n!="object"){t.push({path:e,message:"Paint server def must be a non-null object",severity:"error"});return}let i=n;typeof i.id!="string"||i.id.length===0?t.push({path:`${e}.id`,message:"Paint server def id must be a non-empty string",severity:"error"}):r.has(i.id)?t.push({path:`${e}.id`,message:`Duplicate paint server def id: "${i.id}"`,severity:"error"}):r.add(i.id),(typeof i.type!="string"||!ic.has(i.type))&&t.push({path:`${e}.type`,message:"Paint server def type must be a supported SVG defs element type",severity:"error"}),(typeof i.markup!="string"||i.markup.length===0)&&t.push({path:`${e}.markup`,message:"Paint server def markup must be a non-empty string",severity:"error"}),i.passthrough!==void 0&&typeof i.passthrough!="boolean"&&t.push({path:`${e}.passthrough`,message:"Paint server def passthrough must be a boolean when present",severity:"error"})}function ac(n,e,t,r,i){if(n===null||typeof n!="object"){t.push({path:e,message:"Shape must be a non-null object",severity:"error"});return}let s=n;typeof s.id!="string"||s.id.length===0?t.push({path:`${e}.id`,message:"Shape id must be a non-empty string",severity:"error"}):i.has(s.id)?t.push({path:`${e}.id`,message:`Duplicate shape id: "${s.id}"`,severity:"error"}):i.add(s.id),typeof s.type!="string"?t.push({path:`${e}.type`,message:"Shape type must be a string",severity:"error"}):tc.has(s.type)||r.push({path:`${e}.type`,message:`Unknown shape type: "${s.type}"`,severity:"warning"}),s.state===void 0||s.state===null||typeof s.state!="object"?t.push({path:`${e}.state`,message:"Shape state must be a non-null object",severity:"error"}):lc(s.state,`${e}.state`,t,r)}var oc=/^\s*\{\{\s*[\w.\-]+\s*\}\}\s*$/;function ja(n){return typeof n=="number"?isFinite(n):typeof n=="string"?oc.test(n):!1}function lc(n,e,t,r){let i=["x","y","width","height","radius","rx","ry","fontSize"];for(let o of i)n[o]!==void 0&&!ja(n[o])&&t.push({path:`${e}.${o}`,message:`${o} must be a finite number or a {{variable}} reference`,severity:"error"});for(let o of qt){let a=n[o];if(a!=null){if(o==="transformMatrix"){(!Array.isArray(a)||a.length<6||!a.slice(0,6).every(l=>typeof l=="number"&&Number.isFinite(l)))&&t.push({path:`${e}.${o}`,message:`${o} must be a 6-element finite affine matrix`,severity:"error"});continue}ja(a)||t.push({path:`${e}.${o}`,message:`${o} must be a finite number or a {{variable}} reference`,severity:"error"})}}let s=["width","height","radius","fontSize"];for(let o of s){let a=n[o];typeof a=="number"&&a<=0&&r.push({path:`${e}.${o}`,message:`${o} should be positive (got ${a})`,severity:"warning"})}}function uc(n,e,t,r,i){if(n===null||typeof n!="object"){t.push({path:e,message:"Viewbox must be a non-null object",severity:"error"});return}let s=n;typeof s.id!="string"||s.id.length===0?t.push({path:`${e}.id`,message:"Viewbox id must be a non-empty string",severity:"error"}):i.has(s.id)?t.push({path:`${e}.id`,message:`Duplicate viewbox id: "${s.id}"`,severity:"error"}):i.add(s.id);for(let o of["x","y","width","height"])(typeof s[o]!="number"||!isFinite(s[o]))&&t.push({path:`${e}.${o}`,message:`${o} must be a finite number`,severity:"error"});typeof s.width=="number"&&s.width<=0&&t.push({path:`${e}.width`,message:"Viewbox width must be positive",severity:"error"}),typeof s.height=="number"&&s.height<=0&&t.push({path:`${e}.height`,message:"Viewbox height must be positive",severity:"error"})}function cc(n,e,t,r){if(n===null||typeof n!="object"){t.push({path:e,message:"Guide must be a non-null object",severity:"error"});return}let i=n;(typeof i.id!="string"||i.id.length===0)&&t.push({path:`${e}.id`,message:"Guide id must be a non-empty string",severity:"error"}),i.orientation!=="horizontal"&&i.orientation!=="vertical"&&t.push({path:`${e}.orientation`,message:'Guide orientation must be "horizontal" or "vertical"',severity:"error"}),(typeof i.position!="number"||!isFinite(i.position))&&t.push({path:`${e}.position`,message:"Guide position must be a finite number",severity:"error"})}function dc(n,e,t){if(n===null||typeof n!="object"){t.push({path:e,message:"Group must be a non-null object",severity:"error"});return}let r=n;(typeof r.id!="string"||r.id.length===0)&&t.push({path:`${e}.id`,message:"Group id must be a non-empty string",severity:"error"}),r.parentId!==null&&typeof r.parentId!="string"&&t.push({path:`${e}.parentId`,message:"Group parentId must be a string or null",severity:"error"})}function fc(n,e,t){if(n===null||typeof n!="object"){t.push({path:e,message:"ClipMaskGroup must be a non-null object",severity:"error"});return}let r=n;(typeof r.id!="string"||r.id.length===0)&&t.push({path:`${e}.id`,message:"ClipMaskGroup id must be a non-empty string",severity:"error"}),r.type!=="clip"&&r.type!=="mask"&&t.push({path:`${e}.type`,message:'ClipMaskGroup type must be "clip" or "mask"',severity:"error"}),(typeof r.clipShapeId!="string"||r.clipShapeId.length===0)&&t.push({path:`${e}.clipShapeId`,message:"clipShapeId must be a non-empty string",severity:"error"}),Array.isArray(r.contentShapeIds)||t.push({path:`${e}.contentShapeIds`,message:"contentShapeIds must be an array",severity:"error"})}function _(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`id-${crypto.randomUUID()}`:`id-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}function Gr(n={}){let e={schemaVersion:ve,shapes:n.shapes?n.shapes.map(t=>({...t})):[],viewboxes:n.viewboxes?n.viewboxes.map(t=>({...t})):[]};return n.metadata&&(e.documentMetadata={title:"",description:"",author:"",keywords:[],license:"",licenseUrl:"",language:"en",customMetadata:{},...n.metadata}),e}function pc(n){let{type:e,id:t,...r}=n,i={};for(let[s,o]of Object.entries(r))o!==void 0&&(i[s]=o);return{id:t??_(),type:e,state:i}}function vn(n,e,t,r,i){return{id:i??_(),x:n,y:e,width:t,height:r}}var mc=["schemaVersion","documentMetadata","documentScripts","documentStyles","templateVariables","viewboxes","guides","measurements","groups","sceneTree","clipMaskGroups","customPatterns","symbols","markers","library","colorGlyphLibrary","paintServerDefs","rawPaintServerDefs","animationTimeline","shapes"];function Vr(n,e={}){let{indent:t=2,trailingNewline:r=!0,validate:i=!1}=e;if(i){let a=$n(n);if(!a.valid){let l=a.errors.map(c=>` ${c.path}: ${c.message}`).join(`
7
- `);throw new Error(`Invalid document:
8
- ${l}`)}}let s={};for(let a of mc){let l=n[a];if(l!==void 0)switch(a){case"shapes":s[a]=l.map(c=>gc(ft(structuredClone(c))));break;case"viewboxes":case"guides":case"measurements":case"groups":case"sceneTree":case"clipMaskGroups":case"symbols":case"markers":case"customPatterns":case"library":case"paintServerDefs":case"rawPaintServerDefs":s[a]=Array.isArray(l)&&typeof l[0]=="string"?l:hc(l).map(nt);break;case"documentMetadata":s[a]=nt(l);break;case"animationTimeline":s[a]=nt(l);break;case"colorGlyphLibrary":s[a]=nt(l);break;default:s[a]=l}}let o=JSON.stringify(s,null,t);return r?o+`
9
- `:o}function Ur(n,e={}){let{validate:t=!0,migrate:r=!0}=e,i;try{i=JSON.parse(n)}catch(o){throw new Error(`Failed to parse .svgs document: ${o.message}`)}if(i===null||typeof i!="object"||Array.isArray(i))throw new Error("Invalid .svgs document: root must be a JSON object");let s=i;if(r&&(s=Lr(s)),t){let o=$n(s);if(!o.valid){let a=o.errors.map(l=>` ${l.path}: ${l.message}`).join(`
1
+ var nr=(M=>(M.LINEAR="linear",M.EASE="ease",M.EASE_IN="ease-in",M.EASE_OUT="ease-out",M.EASE_IN_OUT="ease-in-out",M.EASE_IN_QUAD="ease-in-quad",M.EASE_OUT_QUAD="ease-out-quad",M.EASE_IN_OUT_QUAD="ease-in-out-quad",M.EASE_IN_CUBIC="ease-in-cubic",M.EASE_OUT_CUBIC="ease-out-cubic",M.EASE_IN_OUT_CUBIC="ease-in-out-cubic",M.EASE_IN_QUART="ease-in-quart",M.EASE_OUT_QUART="ease-out-quart",M.EASE_IN_OUT_QUART="ease-in-out-quart",M.EASE_IN_SINE="ease-in-sine",M.EASE_OUT_SINE="ease-out-sine",M.EASE_IN_OUT_SINE="ease-in-out-sine",M.EASE_IN_QUINT="ease-in-quint",M.EASE_OUT_QUINT="ease-out-quint",M.EASE_IN_OUT_QUINT="ease-in-out-quint",M.EASE_IN_EXPO="ease-in-expo",M.EASE_OUT_EXPO="ease-out-expo",M.EASE_IN_OUT_EXPO="ease-in-out-expo",M.EASE_IN_CIRC="ease-in-circ",M.EASE_OUT_CIRC="ease-out-circ",M.EASE_IN_OUT_CIRC="ease-in-out-circ",M.EASE_IN_BACK="ease-in-back",M.EASE_OUT_BACK="ease-out-back",M.EASE_IN_OUT_BACK="ease-in-out-back",M.CUSTOM_BEZIER="custom-bezier",M.LINEAR_FUNCTION="linear-function",M.STEPS="steps",M))(nr||{}),ui={linear:null,ease:[.25,.1,.25,1],"ease-in":[.42,0,1,1],"ease-out":[0,0,.58,1],"ease-in-out":[.42,0,.58,1],"ease-in-quad":[.55,.085,.68,.53],"ease-out-quad":[.25,.46,.45,.94],"ease-in-out-quad":[.455,.03,.515,.955],"ease-in-cubic":[.55,.055,.675,.19],"ease-out-cubic":[.215,.61,.355,1],"ease-in-out-cubic":[.645,.045,.355,1],"ease-in-quart":[.895,.03,.685,.22],"ease-out-quart":[.165,.84,.44,1],"ease-in-out-quart":[.77,0,.175,1],"ease-in-sine":[.47,0,.745,.715],"ease-out-sine":[.39,.575,.565,1],"ease-in-out-sine":[.445,.05,.55,.95],"ease-in-quint":[.755,.05,.855,.06],"ease-out-quint":[.23,1,.32,1],"ease-in-out-quint":[.86,0,.07,1],"ease-in-expo":[.95,.05,.795,.035],"ease-out-expo":[.19,1,.22,1],"ease-in-out-expo":[1,0,0,1],"ease-in-circ":[.6,.04,.98,.335],"ease-out-circ":[.075,.82,.165,1],"ease-in-out-circ":[.785,.135,.15,.86],"ease-in-back":[.6,-.28,.735,.045],"ease-out-back":[.175,.885,.32,1.275],"ease-in-out-back":[.68,-.55,.265,1.55],"custom-bezier":null,"linear-function":null,steps:null};function Lz(t){let e=ui[t];return e?`cubic-bezier(${e.join(", ")})`:"linear"}var Xm=(a=>(a.LINEAR="linear",a.QUADRATIC="quadratic",a.CUBIC="cubic",a.CATMULL_ROM="catmull-rom",a.ARC="arc",a.BASIS="basis",a.MIXED="mixed",a))(Xm||{}),fI=(r=>(r.SMOOTH="smooth",r.CORNER="corner",r.SYMMETRIC="symmetric",r))(fI||{});function Vz(t){return t==="color"?"live":"stamped"}var Ym=["transformMatrix","scaleX","scaleY","translateX","translateY","rotation","skewX","skewY","customPivot","rawTransform","layerName","leadingComments","fillColor","borderColor","borderWidth","opacity","fillOpacity","strokeOpacity","locked","visible","fillType","fillGradient","strokeType","strokeGradient","fillRule","strokeLinejoin","strokeLinecap","strokeMiterlimit","lineStyle","dashLength","gapLength","dashOffset","strokeDasharray","colorInterpolation","filters","filterColorInterpolation","filterUnits","primitiveUnits","filterX","filterY","filterWidth","filterHeight","metadata","cssClipPath","cssMaskProperties","structural","displayMode","display","visibility","inheritFill","inheritStroke","preserveOpacity","preserveFillOpacity","preserveStrokeOpacity","fillLibraryId","strokeLibraryId","filterLibraryIds","fillRuleExplicit","paintOrder","vectorEffect","transformBox","pathLength","markerStart","markerMid","markerEnd","blendMode","shapeRendering","textRendering","imageRendering","colorRendering","systemLanguage","requiredExtensions","inlineStyle","authoredAttributes","bindings","scripts","lastSolidFillColor","lastSolidStrokeColor","connectionPoints","isRootSvg","x","y","width","height","rx","ry","cornerRadius","cornerShape","cornerMode","cornerRadiusTL","cornerRadiusTR","cornerRadiusBL","cornerRadiusBR","cornerShapeTL","cornerShapeTR","cornerShapeBL","cornerShapeBR","size","radius","cx","cy","shiftAngle","x1","y1","x2","y2","startEndpoint","endEndpoint","routingMode","sourceRef","targetRef","sourcePoint","targetPoint","waypoints","label","labelPosition","labelOffset","mermaidEdgeStyle","textX","textY","authoredTextPosition","authoredTextStructure","fontSize","text","fontFamily","fontWeight","fontStyle","fontVariant","fontVariantLigatures","fontVariantPosition","fontVariantCaps","fontVariantNumeric","fontVariantEastAsian","textDecoration","textTransform","baselineShift","dominantBaseline","writingMode","textAnchor","letterSpacing","wordSpacing","lineHeight","inlineSize","overflowWrap","whiteSpace","textDirection","unicodeBidi","useRichText","richTextRuns","charOffsets","fontVariationSettings","linePositions","textLength","lengthAdjust","shapeInsideRef","shapeInsideImportRefId","shapePadding","isTextPath","textPathPoints","textPathStartOffset","textPathStartOffsetUnit","textPathSide","textPathMethod","textPathSpacing","textPathLengthAdjust","textPathLength","textPathLengthUnit","textPathPathLength","textPathCurveType","textPathInlineFormat","textPathRefShapeId","textPathImportRefId","href","originalWidth","originalHeight","preserveAspectRatio","specPreserveAspectRatio","imageOpacity","pathPoints","pathArcParams","pathControlBounds","pathCurveType","pathClosed","pathTension","polylinePoints","polylineClosed","sides","arms","innerRadiusPercent","armWidthPercent","turns","thicknessPercent","spiralDirection","teeth","toothDepthPercent","holeRadiusPercent","headWidthPercent","headLengthPercent","shaftWidthPercent","tailAngleDeg","tailLengthPercent","tailWidthPercent","lobeRadiusPercent","cleftDepthPercent","boltSegments","boltJaggednessPercent","boltWidthPercent","cloudBumps","cloudPuffinessPercent","slantPercent","topWidthPercent","capHeightPercent","waveAmplitudePercent","symbolId","authoredUseGeometry","symbolOverrides","variantKey","instancePresentation","scaleContentToViewport","groupData","mediaKind","mediaMimeType","naturalDuration","begin","trimStart","trimEnd","volume","muted","loop","playbackRate","mediaOpacity","fadeInDuration","fadeOutDuration","posterHref","sourceRect","rawContent","hrefXlink","linkTarget","linkRel","linkDownload","linkPing","linkHreflang","linkType","linkReferrerPolicy","containerPresentation","targetShapeId","offsetX","offsetY","targetWidth","targetHeight","broken","switchSystemLanguage","switchRequiredExtensions","svgX","svgY","svgWidth","svgHeight","svgViewBoxX","svgViewBoxY","svgViewBoxWidth","svgViewBoxHeight","svgPreserveAspectRatio","viewBoxX","viewBoxY","viewBoxWidth","viewBoxHeight","viewName","viewPreserveAspectRatio","viewZoomAndPan","viewTarget","children"],Lt=13;var qm=["transformMatrix","scaleX","scaleY","translateX","translateY","rotation","skewX","skewY","customPivot","rawTransform"],Cs=["transformMatrix","scaleX","scaleY","translateX","translateY","rotation","skewX","skewY"],Zm={transformMatrix:null,translateX:0,translateY:0,rotation:0,skewX:0,skewY:0,customPivot:null,rawTransform:null};var Ln="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",Ns=Ln.length,Bn=Ln[0],Jm=Ln[Ns-1],eg=Ln[Math.floor(Ns/2)],$l=97,mI=122;function pi(t){let e=Ln.indexOf(t);if(e===-1)throw new Error(`order-key: invalid digit '${t}'`);return e}function gI(t){let e=t.charCodeAt(0);if(e<$l||e>mI)throw new Error(`order-key: invalid head '${t}'`);return e-$l+1}function rr(t){if(t<1||t>26)throw new Error(`order-key: integer length ${t} out of range`);return String.fromCharCode($l+t-1)}function go(t){let e=gI(t[0]);if(t.length<1+e)throw new Error(`order-key: '${t}' shorter than its integer part`);let n=t.slice(1,1+e),r=t.slice(1+e);for(let i of n)pi(i);for(let i of r)pi(i);return{integer:n,fraction:r}}function $s(t){for(let e of t)if(e!==Bn)return!1;return!0}function As(t){if(t.length===0)return!1;try{let{integer:e,fraction:n}=go(t);return!(n.endsWith(Bn)||$s(e)&&n.length===0||e.length>1&&e[0]===Bn)}catch{return!1}}function Qm(t,e){if(!As(t))throw new Error(`order-key: invalid ${e} '${t}'`)}function Es(t,e){return t<e?-1:t>e?1:0}function hI(t){let e=t.split("");for(let n=e.length-1;n>=0;n--){let r=pi(e[n]);if(r<Ns-1){e[n]=Ln[r+1];for(let i=n+1;i<e.length;i++)e[i]=Bn;return e.join("")}}return null}function Nl(t){let{integer:e}=go(t),n=hI(e);if(n!==null)return rr(e.length)+n;let r="1"+Bn.repeat(e.length);return rr(r.length)+r}function yI(t){let e=t.split("");for(let n=e.length-1;n>=0;n--){let r=pi(e[n]);if(r>0){e[n]=Ln[r-1];for(let i=n+1;i<e.length;i++)e[i]=Jm;return e.join("")}e[n]=Jm}throw new Error(`order-key: cannot decrement zero integer '${t}'`)}function SI(t){let e=0;for(;e<t.length-1&&t[e]===Bn;)e++;return t.slice(e)}function bI(t){let{integer:e,fraction:n}=go(t);if(!$s(e)){let r=yI(e);if(!$s(r)){let i=SI(r);return rr(i.length)+i}return rr(1)+Bn+eg}return rr(1)+Bn+ho("",n)}function ho(t,e){if(e!==null){if(e.length===0||t>=e)throw new Error(`order-key: fraction bounds out of order ('${t}' >= '${e}')`);let i=0;for(;i<e.length&&(t[i]??Bn)===e[i];)i++;if(i>0)return e.slice(0,i)+ho(t.slice(i),e.slice(i))}let n=t.length>0?pi(t[0]):0,r=e!==null?pi(e[0]):Ns;return r-n>1?Ln[Math.floor((n+r)/2)]:Ln[n]+ho(t.slice(1),null)}function yo(t,e){if(t!==null&&Qm(t,"lower bound"),e!==null&&Qm(e,"upper bound"),t!==null&&e!==null&&t>=e)throw new Error(`order-key: bounds out of order ('${t}' >= '${e}')`);if(t===null&&e===null)return rr(1)+"1";if(t===null)return bI(e);if(e===null)return Nl(t);let n=go(t),r=go(e),i=rr(n.integer.length)+n.integer,o=rr(r.integer.length)+r.integer;if(i===o)return i+ho(n.fraction,r.fraction);let s=Nl(i+($s(n.integer)?eg:""));return Es(s,e)<0?s:i+ho(n.fraction,null)}function Al(t,e,n){if(n<=0)return[];let r=[],i=t;for(let o=0;o<n;o++){let s=yo(i,e);r.push(s),i=s}return r}function El(t){if(t<=0)return[];let e=[],n=yo(null,null);e.push(n);for(let r=1;r<t;r++)n=Nl(n),e.push(n);return e}var Ms=class{schemas=new Map;register(e,n){this.schemas.set(e,n)}get(e){return this.schemas.get(e)}typeIds(){return[...this.schemas.keys()]}getDefaults(e){let n=this.schemas.get(e);if(!n)return{};let r={};for(let i of Object.keys(n))r[i]=n[i].default;return r}validate(e,n,r){let i=this.schemas.get(e);if(!i)return r;let o=i[n];return o?.validate?o.validate(r):r}},ge=t=>Math.max(0,t),fi=t=>Math.max(0,Math.min(1,t)),nt=t=>Math.max(0,Math.min(100,t)),vI=t=>Math.max(1,t),xI=t=>Math.max(3,Math.min(100,Math.floor(t))),II=t=>Math.max(3,Math.min(50,Math.floor(t))),wI=t=>Math.max(3,Math.min(30,Math.floor(t))),kI=t=>Math.max(1,Math.min(10,t));function PI(t){return Object.fromEntries(Object.entries(t).map(([e,n])=>[e,{default:n}]))}var TI=PI(Zm),Je={layerName:{default:null},fillColor:{default:"#ffffff"},borderColor:{default:"#000000"},borderWidth:{default:1},opacity:{default:1,validate:fi},fillOpacity:{default:1,validate:fi},strokeOpacity:{default:1,validate:fi},...TI,locked:{default:!1},visible:{default:!0},fillType:{default:"solid"},fillGradient:{default:null},strokeType:{default:"solid"},strokeGradient:{default:null},fillRule:{default:"nonzero"},strokeLinejoin:{default:"miter"},strokeLinecap:{default:"butt"},strokeMiterlimit:{default:4,validate:vI},lineStyle:{default:"solid"},dashLength:{default:8},gapLength:{default:4},dashOffset:{default:0},strokeDasharray:{default:null},colorInterpolation:{default:null},filters:{default:[]},filterColorInterpolation:{default:null},filterUnits:{default:null},primitiveUnits:{default:null},filterX:{default:null},filterY:{default:null},filterWidth:{default:null},filterHeight:{default:null},metadata:{default:null},cssClipPath:{default:null},cssMaskProperties:{default:null}},nn={...Je,cx:{default:0},cy:{default:0},radius:{default:50,validate:ge},cornerRadius:{default:0,validate:ge},shiftAngle:{default:0}},mi={...Je,x:{default:0},y:{default:0},width:{default:100,validate:ge},height:{default:60,validate:ge}},tg={...Je,x:{default:0},y:{default:0},width:{default:0,validate:ge},height:{default:0,validate:ge},href:{default:""},mediaMimeType:{default:""},originalWidth:{default:0},originalHeight:{default:0},naturalDuration:{default:0},preserveAspectRatio:{default:!0},begin:{default:0},trimStart:{default:0},volume:{default:1,validate:fi},muted:{default:!1},loop:{default:!1},playbackRate:{default:1},mediaOpacity:{default:1,validate:fi},fadeInDuration:{default:0,validate:ge},fadeOutDuration:{default:0,validate:ge},posterHref:{default:""},sourceRect:{default:null}},pe=new Ms;pe.register("rectangle",{...Je,x:{default:0},y:{default:0},width:{default:100,validate:ge},height:{default:100,validate:ge},rx:{default:0,validate:ge},ry:{default:0,validate:ge},cornerRadius:{default:0,validate:ge},cornerShape:{default:"round"},cornerMode:{default:"uniform"},cornerRadiusTL:{default:0,validate:ge},cornerRadiusTR:{default:0,validate:ge},cornerRadiusBL:{default:0,validate:ge},cornerRadiusBR:{default:0,validate:ge},cornerShapeTL:{default:"round"},cornerShapeTR:{default:"round"},cornerShapeBL:{default:"round"},cornerShapeBR:{default:"round"}});pe.register("square",{...Je,x:{default:0},y:{default:0},size:{default:100,validate:ge},width:{default:100,validate:ge},height:{default:100,validate:ge},rx:{default:0,validate:ge},ry:{default:0,validate:ge},cornerRadius:{default:0,validate:ge},cornerShape:{default:"round"},cornerMode:{default:"uniform"},cornerRadiusTL:{default:0,validate:ge},cornerRadiusTR:{default:0,validate:ge},cornerRadiusBL:{default:0,validate:ge},cornerRadiusBR:{default:0,validate:ge},cornerShapeTL:{default:"round"},cornerShapeTR:{default:"round"},cornerShapeBL:{default:"round"},cornerShapeBR:{default:"round"}});pe.register("circle",{...Je,x:{default:0},y:{default:0},radius:{default:50,validate:ge}});pe.register("ellipse",{...Je,cx:{default:0},cy:{default:0},rx:{default:50,validate:ge},ry:{default:30,validate:ge}});pe.register("line",{...Je,x1:{default:0},y1:{default:0},x2:{default:100},y2:{default:0},startEndpoint:{default:"none"},endEndpoint:{default:"none"}});pe.register("text",{...Je,x:{default:0},y:{default:0},width:{default:0,validate:ge},height:{default:0,validate:ge},textX:{default:0},textY:{default:0},fontSize:{default:24},text:{default:""},fontFamily:{default:"Arial"},fontWeight:{default:"normal"},fontStyle:{default:"normal"},fontVariant:{default:""},fontVariantLigatures:{default:""},fontVariantPosition:{default:""},fontVariantCaps:{default:""},fontVariantNumeric:{default:""},fontVariantEastAsian:{default:""},textDecoration:{default:{}},textTransform:{default:"none"},baselineShift:{default:"baseline"},dominantBaseline:{default:"auto"},writingMode:{default:"horizontal-tb"},textAnchor:{default:"start"},letterSpacing:{default:0},wordSpacing:{default:0},lineHeight:{default:1.2},inlineSize:{default:0},overflowWrap:{default:"normal"},whiteSpace:{default:"pre-wrap"},textDirection:{default:"ltr"},unicodeBidi:{default:"normal"},scaleX:{default:1},scaleY:{default:1},scaleAnchor:{default:null},useRichText:{default:!1},richTextRuns:{default:null},charOffsets:{default:null},fontVariationSettings:{default:{}},isTextPath:{default:!1},textPathPoints:{default:null},textPathStartOffset:{default:0},textPathSide:{default:"left"},shapeInsideRef:{default:null},shapePadding:{default:0}});pe.register("image",{...Je,x:{default:0},y:{default:0},width:{default:100,validate:ge},height:{default:100,validate:ge},href:{default:""},originalWidth:{default:0},originalHeight:{default:0},preserveAspectRatio:{default:!0},imageOpacity:{default:1,validate:fi}});pe.register("path",{...Je,x:{default:0},y:{default:0},width:{default:0,validate:ge},height:{default:0,validate:ge},pathPoints:{default:[]},pathArcParams:{default:[]},pathControlBounds:{default:null},startEndpoint:{default:"none"},endEndpoint:{default:"none"}});pe.register("polyline",{...Je,x:{default:0},y:{default:0},width:{default:0,validate:ge},height:{default:0,validate:ge},polylinePoints:{default:[]},polylineClosed:{default:!1}});pe.register("triangle",{...nn,sides:{default:3}});pe.register("ngon",{...nn,sides:{default:6,validate:xI}});pe.register("star",{...nn,arms:{default:5,validate:II},innerRadiusPercent:{default:40,validate:nt}});pe.register("cross",{...nn,armWidthPercent:{default:30,validate:nt}});pe.register("ring",{...nn,innerRadiusPercent:{default:50,validate:nt}});pe.register("spiral",{...nn,turns:{default:3,validate:kI},thicknessPercent:{default:15,validate:nt},spiralDirection:{default:1}});pe.register("gear",{...nn,teeth:{default:8,validate:wI},toothDepthPercent:{default:25,validate:nt},holeRadiusPercent:{default:20,validate:nt}});pe.register("arrow",{...nn,headWidthPercent:{default:100,validate:nt},headLengthPercent:{default:40,validate:nt},shaftWidthPercent:{default:40,validate:nt}});pe.register("symbol-instance",{...Je,x:{default:0},y:{default:0},width:{default:100,validate:ge},height:{default:100,validate:ge},symbolId:{default:""}});pe.register("group",{...Je});pe.register("container",{...Je});pe.register("cloud",{...nn,cloudBumps:{default:5},cloudPuffinessPercent:{default:60,validate:nt}});pe.register("heart",{...nn,lobeRadiusPercent:{default:50,validate:nt},cleftDepthPercent:{default:25,validate:nt}});pe.register("lightning",{...nn,boltSegments:{default:3},boltWidthPercent:{default:30,validate:nt},boltJaggednessPercent:{default:40,validate:nt}});pe.register("speechBubble",{...nn,tailAngleDeg:{default:45},tailLengthPercent:{default:40,validate:nt},tailWidthPercent:{default:25,validate:nt}});pe.register("diamond",{...mi});pe.register("parallelogram",{...mi,slantPercent:{default:20,validate:nt}});pe.register("trapezoid",{...mi,topWidthPercent:{default:70,validate:nt}});pe.register("terminator",{...mi});pe.register("cylinder",{...mi,capHeightPercent:{default:15,validate:nt}});pe.register("document-shape",{...mi,waveAmplitudePercent:{default:15,validate:nt}});pe.register("hyperlink",{...Je,href:{default:""},hrefXlink:{default:""},linkTarget:{default:""},linkPing:{default:""},linkRel:{default:""},linkHreflang:{default:""},linkType:{default:""},linkReferrerPolicy:{default:""}});pe.register("switch",{...Je,switchSystemLanguage:{default:null},switchRequiredExtensions:{default:null}});pe.register("svg",{...Je});pe.register("view",{...Je,viewBoxX:{default:0},viewBoxY:{default:0},viewBoxWidth:{default:0,validate:ge},viewBoxHeight:{default:0,validate:ge},viewName:{default:""},viewPreserveAspectRatio:{default:""},viewTarget:{default:""}});pe.register("shape-reference",{...Je,targetShapeId:{default:""},offsetX:{default:0},offsetY:{default:0},targetWidth:{default:0,validate:ge},targetHeight:{default:0,validate:ge},broken:{default:!1}});pe.register("foreign-object",{...Je,x:{default:0},y:{default:0},width:{default:0,validate:ge},height:{default:0,validate:ge},rawContent:{default:""}});pe.register("video",{...tg,mediaKind:{default:"video"}});pe.register("audio",{...tg,mediaKind:{default:"audio"}});pe.register("document",{});function Or(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function mn(t,e,n=""){if(!Or(t))return;e.onShape?.(t,n);let r=t.state;if(!Or(r))return;let i=r.children;if(Array.isArray(i)&&i.forEach((o,s)=>{mn(o,e,`${n}.state.children[${s}]`)}),e.onState){let o=r.symbolOverrides;if(Or(o))for(let[s,a]of Object.entries(o))Or(a)&&e.onState(a,`${n}.state.symbolOverrides[${s}]`);e.onState(r,`${n}.state`)}}function Os(t,e,n){Array.isArray(t)&&t.forEach((r,i)=>mn(r,e,`${n}[${i}]`))}function rt(t,e){Or(t)&&(Os(t.shapes,e,"shapes"),Array.isArray(t.library)&&t.library.forEach((n,r)=>{if(Or(n))if(n.kind==="symbol"){if(Os(n.shapes,e,`library[${r}].shapes`),Or(n.variants))for(let[i,o]of Object.entries(n.variants))Os(o,e,`library[${r}].variants[${i}]`)}else n.kind==="marker"&&Os(n.shapes,e,`library[${r}].shapes`)}))}function RI(){let t=new Set(Ym);for(let e of qm)t.add(e);for(let e of pe.typeIds())for(let n of Object.keys(pe.getDefaults(e)))t.add(n);return t.delete("scaleAnchor"),t.delete("extra"),t}var ng=RI(),CI=new Set(["scaleAnchor","displayAttr"]);function Ds(t){let e=t.extra&&typeof t.extra=="object"&&!Array.isArray(t.extra)?t.extra:void 0;for(let n of Object.keys(t)){if(n==="extra"||ng.has(n))continue;let r=t[n];delete t[n],r!==void 0&&((e??={})[n]=r)}return e&&Object.keys(e).length>0?t.extra=e:delete t.extra,t}function Ml(t){return mn(t,{onState:e=>{Ds(e)}}),t}function Ol(t){return mn(t,{onState:e=>{Dr(e)}}),t}function Dr(t){let e=t.extra;if(!e||typeof e!="object"||Array.isArray(e))return delete t.extra,t;for(let[n,r]of Object.entries(e))n!=="extra"&&(n in t||(t[n]=r));return delete t.extra,t}function gi(t,e,n,r="verbatim"){if(r==="verbatim")return new rn(t,e,n&&"extra"in n?Dr({...n}):n);let i={...pe.getDefaults(e),...n},o=pe.get(e);if(o)for(let s of Object.keys(i)){let a=o[s];a?.validate&&i[s]!==void 0&&(i[s]=a.validate(i[s]))}return new rn(t,e,i)}var rn=class t{static writeHook=null;static _baseReadDepth=0;static withBaseProps(e){t._baseReadDepth++;try{return e()}finally{t._baseReadDepth--}}id;type;parent=null;children=[];onChange=null;_props;_dirty=new Set;_preservedSerializedState=null;_overlay=null;_propTimestamps=new Map;constructor(e,n,r){this.id=e,this.type=n,this._props=r?{...r}:{}}get(e){return this._overlay!==null&&t._baseReadDepth===0&&this._overlay.has(e)?this._overlay.get(e):this._props[e]}set(e,n){this._props[e]!==n&&(this._preservedSerializedState=null,t.writeHook?.(this,e),this._props[e]=n,this._dirty.add(e),this.onChange?.(this,this._dirty))}getProp(e){return this._overlay!==null&&t._baseReadDepth===0&&this._overlay.has(e)?this._overlay.get(e):this._props[e]}getBaseProp(e){return this._props[e]}setProp(e,n){this._props[e]!==n&&(this._preservedSerializedState=null,t.writeHook?.(this,e),this._props[e]=n,this._dirty.add(e),this.onChange?.(this,this._dirty))}deleteProp(e){e in this._props&&(this._preservedSerializedState=null,t.writeHook?.(this,e),delete this._props[e],this._dirty.add(e),this.onChange?.(this,this._dirty))}setMany(e){let n=!1;for(let[r,i]of Object.entries(e))this._props[r]!==i&&(this._preservedSerializedState=null,t.writeHook?.(this,r),this._props[r]=i,this._dirty.add(r),n=!0);n&&this.onChange?.(this,this._dirty)}setOverlayValue(e,n){this._overlay===null&&(this._overlay=new Map),this._overlay.set(e,n)}deleteOverlayValue(e){if(this._overlay===null)return!1;let n=this._overlay.delete(e);return this._overlay.size===0&&(this._overlay=null),n}getOverlayValue(e){return this._overlay?.get(e)}hasOverlayValue(e){return this._overlay?.has(e)??!1}overlayKeys(){return this._overlay?[...this._overlay.keys()]:[]}clearOverlay(){if(this._overlay===null)return[];let e=[...this._overlay.keys()];return this._overlay=null,e}get hasOverlay(){return this._overlay!==null}getDirtyKeys(){return this._dirty}clearDirty(){this._dirty.clear()}isDirty(){return this._dirty.size>0}getProps(){return this._props}snapshotProps(){return structuredClone(this._props)}restoreProps(e){this._preservedSerializedState=null,this._props=structuredClone(e);for(let n of Object.keys(this._props))this._dirty.add(n);this.onChange?.(this,this._dirty)}getPropStamp(e){return this._propTimestamps.get(e)??null}stampProp(e,n,r){this._propTimestamps.set(e,{ts:n,clientId:r})}stampProps(e,n,r){let i={ts:n,clientId:r};for(let o of e)this._propTimestamps.set(o,i)}getPropStampsForKeys(e){let n={};for(let r of e){let i=this._propTimestamps.get(r);i&&(n[r]=i.ts)}return n}snapshotPropTimestamps(){return new Map(this._propTimestamps)}restorePropTimestamps(e){this._propTimestamps=new Map(e)}preserveSerializedState(e){this._preservedSerializedState=structuredClone(e)}hasPreservedSerializedState(){return this._preservedSerializedState!==null}toSerialized(){return{id:this.id,type:this.type,state:this._preservedSerializedState?structuredClone(this._preservedSerializedState):{...this._props}}}static fromSerialized(e){return gi(e.id,e.type,structuredClone(e.state),"verbatim")}static create(e,n,r){return gi(e,n,r,"authoring")}};var $I=5e3,NI=1e4;function AI(t){return t===null||t.size===0?"":[...t.entries()].sort((e,n)=>n[1].count-e[1].count).slice(0,5).map(([e,n])=>`${e.type}#${e.id} x${n.count} keys=[${[...n.keys].join(",")}]`).join("; ")}var zr=class t{static _activeInstanceCount=0;static _createdInstanceCount=0;static _disposedInstanceCount=0;static _pendingGraphs=new Set;static flushAllPending(){if(t._pendingGraphs.size!==0)for(let e of[...t._pendingGraphs])e.flushBatched()}static get pendingGraphCount(){return t._pendingGraphs.size}static get activeInstanceCount(){return t._activeInstanceCount}static get createdInstanceCount(){return t._createdInstanceCount}static get disposedInstanceCount(){return t._disposedInstanceCount}root;_nodesById=new Map;_batchDepth=0;_batchDirtyNodes=new Map;_draining=!1;_changeListeners=[];_structureListeners=[];_disposed=!1;constructor(){t._activeInstanceCount++,t._createdInstanceCount++,this.root=gi("__root__","document"),this._nodesById.set(this.root.id,this.root)}onNodeChange(e){return this._disposed?()=>{}:(this._changeListeners.push(e),()=>{let n=this._changeListeners.indexOf(e);n>=0&&this._changeListeners.splice(n,1)})}onStructureChange(e){return this._disposed?()=>{}:(this._structureListeners.push(e),()=>{let n=this._structureListeners.indexOf(e);n>=0&&this._structureListeners.splice(n,1)})}addNode(e,n,r){if(this._disposed)return;let i=n??this.root;r!==void 0&&r>=0&&r<i.children.length?i.children.splice(r,0,e):i.children.push(e),e.parent=i,this._nodesById.set(e.id,e),e.onChange=this._handleNodeChange.bind(this),this._emitStructure("add",e,null,i)}removeNode(e){if(this._disposed)return null;let n=this._nodesById.get(e);if(!n||n===this.root)return null;let r=n.parent,i=null;if(r){let o=r.children.indexOf(n);i={parentId:r===this.root?null:r.id,index:o},o>=0&&r.children.splice(o,1)}return n.parent=null,n.onChange=null,this._nodesById.delete(e),this._batchDirtyNodes.delete(n),this._removeDescendants(n),this._batchDirtyNodes.size===0&&t._pendingGraphs.delete(this),this._emitStructure("remove",n,r,null,i),n}getNode(e){return this._nodesById.get(e)??null}moveNode(e,n,r){if(this._disposed)return;let i=this._nodesById.get(e);if(!i||i===this.root)return;if(n===i||this.isAncestor(e,n.id))throw new Error(`Cannot move scene node "${e}" below itself or one of its descendants.`);let o=i.parent,s=null;if(o){let a=o.children.indexOf(i);s={parentId:o===this.root?null:o.id,index:a},a>=0&&o.children.splice(a,1)}r!==void 0&&r>=0&&r<n.children.length?n.children.splice(r,0,i):n.children.push(i),i.parent=n,this._emitStructure("move",i,o,n,s)}moveNodeToParentId(e,n,r){if(this._disposed)return;let i=n?this._nodesById.get(n):this.root;i&&this.moveNode(e,i,r)}getChildren(e){let n=e?this._nodesById.get(e):this.root;return n?[...n.children]:[]}getRootShapes(){return[...this.root.children]}getParentId(e){let n=this._nodesById.get(e);return!n||!n.parent||n.parent===this.root?null:n.parent.id}getSiblingIndex(e){let n=this._nodesById.get(e);return!n||!n.parent?-1:n.parent.children.indexOf(n)}getAncestorIds(e){let n=[],r=new Set,i=this.getParentId(e);for(;i;){if(r.has(i))throw new Error(`Scene graph cycle detected while resolving ancestors of "${e}".`);r.add(i),n.push(i),i=this.getParentId(i)}return n}isAncestor(e,n){if(e===n)return!1;let r=new Set,i=this.getParentId(n);for(;i;){if(i===e)return!0;if(r.has(i))throw new Error(`Scene graph cycle detected while resolving ancestry of "${n}".`);r.add(i),i=this.getParentId(i)}return!1}isDocumentRootNode(e){let n=this._nodesById.get(e);return!!n&&n!==this.root&&n.getProp("isRootSvg")===!0}contains(e,n){if(e===n)return!1;if(this.isDocumentRootNode(e)){let r=this._nodesById.get(n);return!!r&&r!==this.root&&!this.isDocumentRootNode(n)}return this.isAncestor(e,n)}getDepth(e){let n=this._nodesById.get(e);if(!n||n===this.root)return-1;let r=0,i=n.parent;for(;i&&i!==this.root;)r++,i=i.parent;return r}getAllNodes(){let e=[];for(let n of this._nodesById.values())n!==this.root&&e.push(n);return e}getDirtyNodes(){let e=[];for(let n of this._nodesById.values())n.isDirty()&&e.push(n);return e}clearAllDirty(){for(let e of this._nodesById.values())e.clearDirty()}beginBatch(){this._disposed||this._batchDepth++}commitBatch(){this._disposed||(this._batchDepth=Math.max(0,this._batchDepth-1),this._batchDepth===0&&this._drainBatched())}flushBatched(){this._disposed||this._batchDirtyNodes.size>0&&this._drainBatched()}get hasPendingBatched(){return this._batchDirtyNodes.size>0}get isBatching(){return this._batchDepth>0}get isDraining(){return this._draining}get isDisposed(){return this._disposed}get listenerCount(){return this._changeListeners.length+this._structureListeners.length}dispose(){if(!this._disposed){this._disposed=!0,t._activeInstanceCount--,t._disposedInstanceCount++,t._pendingGraphs.delete(this),this._batchDirtyNodes.clear(),this._batchDepth=0,this._draining=!1,this._changeListeners.length=0,this._structureListeners.length=0;for(let e of this._nodesById.values())e.onChange=null}}notifyNodeChanged(e,n){this._disposed||this._handleNodeChange(e,n)}_handleNodeChange(e,n){if(!this._disposed){if(this._batchDepth>0){let r=this._batchDirtyNodes.get(e);r||(r=new Set,this._batchDirtyNodes.set(e,r),t._pendingGraphs.add(this));for(let i of n)r.add(i);return}this._fireChangeListeners(e,n)}}_drainBatched(){if(this._disposed||this._draining)return;this._draining=!0;let e=0,n=null;try{for(;this._batchDirtyNodes.size>0;){if(++e>NI){console.error("[SceneGraph] batched-notification drain did not converge \u2014 render loop?",AI(n)),this._batchDirtyNodes.clear();break}let[r,i]=this._batchDirtyNodes.entries().next().value;if(this._batchDirtyNodes.delete(r),this._batchDirtyNodes.size===0&&t._pendingGraphs.delete(this),e>$I){n===null&&(n=new Map);let o=n.get(r);if(o){o.count++;for(let s of i)o.keys.add(s)}else n.set(r,{count:1,keys:new Set(i)})}this._fireChangeListeners(r,i)}}finally{this._draining=!1,this._batchDirtyNodes.size===0&&t._pendingGraphs.delete(this)}}_fireChangeListeners(e,n){if(this._disposed)return;let r=[...this._changeListeners];for(let i of r)i(e,n)}_emitStructure(e,n,r,i,o=null){if(this._disposed)return;let s=[...this._structureListeners];for(let a of s)a(e,n,r,i,o)}_removeDescendants(e){for(let n of e.children)n.onChange=null,this._nodesById.delete(n.id),this._batchDirtyNodes.delete(n),this._removeDescendants(n)}serializeShapes(){let e=[],n=r=>{for(let i of r)i.type!=="document"&&i.type!=="group"&&i.getProp("structural")!==!0&&e.push(i.toSerialized()),i.children.length>0&&n(i.children)};return n(this.root.children),e}static fromShapes(e){let n=new t;for(let r of e){let i=rn.fromSerialized(r);n.addNode(i)}return n}clone(){let e=new t,n=(r,i)=>{for(let o of r.children){let s=o.toSerialized(),a=rn.fromSerialized(s);o.hasPreservedSerializedState()&&a.preserveSerializedState(s.state),a.restorePropTimestamps(o.snapshotPropTimestamps()),e.addNode(a,i),n(o,a)}};return n(this.root,e.root),e}};var Ne=["updatedAt","clientId"];function ue(t,e,n){t.push({path:e,message:n})}function fg(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function ke(t,e,n){return fg(t)?t:(ue(n,e,"must be an object"),null)}function le(t,e,n,r=[],i,o=!0){let s=new Set([...o?["type"]:[],...n,...r]);for(let a of n)Object.hasOwn(t,a)||ue(i,`${e}.${a}`,"is required");for(let a of Object.keys(t))s.has(a)||ue(i,`${e}.${a}`,"is not allowed")}function Q(t,e,n,r=!1){return typeof t!="string"||!r&&t.length===0?(ue(n,e,r?"must be a string":"must be a non-empty string"),!1):!0}function Tt(t,e,n,r){return typeof t!="number"||!Number.isFinite(t)?(ue(n,e,"must be a finite number"),!1):r!==void 0&&t<r?(ue(n,e,`must be at least ${r}`),!1):!0}function gn(t,e,n,r=0){return Tt(t,e,n,r)?Number.isInteger(t)?!0:(ue(n,e,"must be an integer"),!1):!1}function hi(t,e,n){return typeof t!="boolean"?(ue(n,e,"must be a boolean"),!1):!0}function Qe(t,e,n,r,i=!1){t[e]!==void 0&&Q(t[e],`${n}.${e}`,r,i)}function _r(t,e,n,r,i){t[e]!==void 0&&Tt(t[e],`${n}.${e}`,r,i)}function Pt(t,e,n,r,i=0){t[e]!==void 0&&gn(t[e],`${n}.${e}`,r,i)}function So(t,e,n,r){t[e]!==void 0&&hi(t[e],`${n}.${e}`,r)}function Fr(t,e,n){return Array.isArray(t)?(t.forEach((r,i)=>Q(r,`${e}[${i}]`,n)),!0):(ue(n,e,"must be an array"),!1)}function it(t,e,n,r){return Array.isArray(t)?(t.forEach((i,o)=>r(i,`${e}[${o}]`,n)),!0):(ue(n,e,"must be an array"),!1)}function pt(t,e,n){let r=[{value:t,path:e,depth:0}],i=0;for(;r.length>0;){let o=r.pop();if(i++,i>25e4){ue(n,e,"exceeds the 250000-node validation limit");return}if(o.depth>64){ue(n,o.path,"exceeds the 64-level nesting limit");continue}let s=o.value;if(!(s===null||typeof s=="string"||typeof s=="boolean")){if(typeof s=="number"){Number.isFinite(s)||ue(n,o.path,"must be a finite JSON number");continue}if(Array.isArray(s)){s.forEach((a,c)=>r.push({value:a,path:`${o.path}[${c}]`,depth:o.depth+1}));continue}if(fg(s)){for(let[a,c]of Object.entries(s))r.push({value:c,path:`${o.path}.${a}`,depth:o.depth+1});continue}ue(n,o.path,"must be JSON-serializable")}}}function Ae(t,e,n){_r(t,"updatedAt",e,n,0),Qe(t,"clientId",e,n)}function Dl(t,e,n){let r=ke(t,e,n);if(r)for(let[i,o]of Object.entries(r))Q(o,`${e}.${i}`,n,!0)}function zs(t,e,n,r=0){if(r>64){ue(n,e,"exceeds the 64-level shape nesting limit");return}let i=ke(t,e,n);if(!i)return;le(i,e,["id","type","state"],[],n),Q(i.id,`${e}.id`,n),Q(i.type,`${e}.type`,n);let o=ke(i.state,`${e}.state`,n);o&&(Object.hasOwn(o,"extra")&&ue(n,`${e}.state.extra`,"is an at-rest field and is not allowed in operations"),pt(o,`${e}.state`,n),o.children!==void 0&&it(o.children,`${e}.state.children`,n,(s,a,c)=>zs(s,a,c,r+1)))}function EI(t,e,n){let r=ke(t,e,n);r&&(Object.hasOwn(r,"extra")&&ue(n,`${e}.extra`,"is an at-rest field and is not allowed in operations"),pt(r,e,n),r.children!==void 0&&it(r.children,`${e}.children`,n,(i,o,s)=>zs(i,o,s)))}function MI(t,e,n){let r=ke(t,e,n);r&&(Q(r.id,`${e}.id`,n),r.type!=="clip"&&r.type!=="mask"&&ue(n,`${e}.type`,'must be "clip" or "mask"'),Fr(r.clipShapeIds,`${e}.clipShapeIds`,n),Fr(r.contentShapeIds,`${e}.contentShapeIds`,n),r.parentId!==null&&Q(r.parentId,`${e}.parentId`,n),Pt(r,"siblingIndex",e,n),pt(r,e,n))}function rg(t,e,n){let r=ke(t,e,n);r&&(Q(r.id,`${e}.id`,n),r.orientation!=="horizontal"&&r.orientation!=="vertical"&&ue(n,`${e}.orientation`,'must be "horizontal" or "vertical"'),Tt(r.position,`${e}.position`,n),Tt(r.controlPointOffset,`${e}.controlPointOffset`,n),Qe(r,"color",e,n,!0),_r(r,"opacity",e,n),pt(r,e,n))}function ig(t,e,n){let r=ke(t,e,n);r&&(Q(r.id,`${e}.id`,n),r.type!=="distance"&&r.type!=="angle"&&ue(n,`${e}.type`,'must be "distance" or "angle"'),it(r.points,`${e}.points`,n,(i,o,s)=>{let a=ke(i,o,s);a&&(Tt(a.x,`${o}.x`,s),Tt(a.y,`${o}.y`,s))}),hi(r.visible,`${e}.visible`,n),gn(r.snapDivisions,`${e}.snapDivisions`,n,1),Qe(r,"color",e,n,!0),_r(r,"opacity",e,n),pt(r,e,n))}var og=["title","description","author","keywords","license","licenseUrl","language","customMetadata","rawMetadata","rawMetadataAuthoritative","rawDescription","rawHtmlMetadata","descriptiveElements","coordinatePrecision"];function sg(t,e,n,r){let i=ke(t,e,n);if(!i)return;le(i,e,r?[]:["title","description","author","keywords","license","licenseUrl","language","customMetadata"],r?og:og.slice(8),n,!1);for(let s of["title","description","author","license","licenseUrl","language"])(!r||i[s]!==void 0)&&Q(i[s],`${e}.${s}`,n,!0);(!r||i.keywords!==void 0)&&Fr(i.keywords,`${e}.keywords`,n),(!r||i.customMetadata!==void 0)&&Dl(i.customMetadata,`${e}.customMetadata`,n),Qe(i,"rawMetadata",e,n,!0),So(i,"rawMetadataAuthoritative",e,n),Qe(i,"rawDescription",e,n,!0),Qe(i,"rawHtmlMetadata",e,n,!0),i.descriptiveElements!==void 0&&it(i.descriptiveElements,`${e}.descriptiveElements`,n,(s,a,c)=>{let l=ke(s,a,c);l&&(le(l,a,["kind","language","text","rawXml"],[],c,!1),l.kind!=="title"&&l.kind!=="desc"&&ue(c,`${a}.kind`,'must be "title" or "desc"'),l.language!==null&&Q(l.language,`${a}.language`,c,!0),Q(l.text,`${a}.text`,c,!0),Q(l.rawXml,`${a}.rawXml`,c,!0))}),Pt(i,"coordinatePrecision",e,n)}function ag(t,e,n){let r=ke(t,e,n);r&&(Q(r.id,`${e}.id`,n),r.source!=="inline"&&r.source!=="external"&&ue(n,`${e}.source`,'must be "inline" or "external"'),Q(r.content,`${e}.content`,n,!0),Q(r.type,`${e}.type`,n,!0),Qe(r,"svgId",e,n,!0),Qe(r,"href",e,n,!0),So(r,"async",e,n),So(r,"defer",e,n),r.customAttrs!==void 0&&Dl(r.customAttrs,`${e}.customAttrs`,n),pt(r,e,n))}function cg(t,e,n){let r=ke(t,e,n);r&&(Q(r.id,`${e}.id`,n),Q(r.css,`${e}.css`,n,!0),hi(r.preserved,`${e}.preserved`,n),Qe(r,"svgId",e,n,!0),Qe(r,"type",e,n,!0),Qe(r,"media",e,n,!0),r.customAttrs!==void 0&&Dl(r.customAttrs,`${e}.customAttrs`,n),pt(r,e,n))}function lg(t,e,n){let r=ke(t,e,n);if(r){if(Q(r.name,`${e}.name`,n),["string","color","number"].includes(String(r.type))||ue(n,`${e}.type`,'must be "string", "color", or "number"'),Q(r.defaultValue,`${e}.defaultValue`,n,!0),Qe(r,"label",e,n,!0),Qe(r,"description",e,n,!0),r.mode!==void 0&&r.mode!=="live"&&r.mode!=="stamped"&&ue(n,`${e}.mode`,'must be "live" or "stamped"'),r.source!==void 0){let i=ke(r.source,`${e}.source`,n);i&&i.kind!=="user"&&ue(n,`${e}.source.kind`,'must be "user"')}pt(r,e,n)}}function dg(t,e,n){let r=ke(t,e,n);r&&(Q(r.id,`${e}.id`,n),Q(r.filename,`${e}.filename`,n,!0),Q(r.format,`${e}.format`,n),pt(r,e,n))}function OI(t,e,n){let r=ke(t,e,n);r&&(gn(r.glyphId,`${e}.glyphId`,n),Array.isArray(r.codepoints)?r.codepoints.forEach((i,o)=>gn(i,`${e}.codepoints[${o}]`,n)):ue(n,`${e}.codepoints`,"must be an array"),Q(r.svgDocument,`${e}.svgDocument`,n,!0),Qe(r,"glyphName",e,n,!0),Pt(r,"advanceWidth",e,n),Qe(r,"sourceFamily",e,n,!0),Pt(r,"sourceGlyphId",e,n),Qe(r,"label",e,n,!0),pt(r,e,n))}function ug(t,e,n){let r=ke(t,e,n);if(!r)return;Q(r.id,`${e}.id`,n);let i=["mask","clipPath","filter","linearGradient","radialGradient","pattern","symbol"],o=r.role===void 0?"resource":String(r.role);o!=="resource"&&o!=="referenced-fragment"&&ue(n,`${e}.role`,"is not a supported raw SVG definition role");let s=String(r.type);(o==="resource"&&!i.includes(s)||o==="referenced-fragment"&&!/^[A-Za-z][\w.-]*$/u.test(s))&&ue(n,`${e}.type`,"is not a supported paint-server type"),Q(r.markup,`${e}.markup`,n),r.definitionChildIds!==void 0&&Fr(r.definitionChildIds,`${e}.definitionChildIds`,n),r.sourceDefinitionChildIds!==void 0&&Fr(r.sourceDefinitionChildIds,`${e}.sourceDefinitionChildIds`,n),Array.isArray(r.definitionChildIds)&&Array.isArray(r.sourceDefinitionChildIds)&&r.definitionChildIds.length!==r.sourceDefinitionChildIds.length&&ue(n,e,"definition child id arrays must have equal lengths"),So(r,"passthrough",e,n),pt(r,e,n)}function pg(t,e,n){let r=ke(t,e,n);if(!r)return;Q(r.id,`${e}.id`,n),Q(r.name,`${e}.name`,n,!0),r.metadata!==void 0&&pt(r.metadata,`${e}.metadata`,n);let i=r.kind;if(["symbol","marker","linear-gradient","radial-gradient","pattern","filter"].includes(String(i))||ue(n,`${e}.kind`,"is not a supported library kind"),(i==="symbol"||i==="marker")&&it(r.shapes,`${e}.shapes`,n,zs),i==="symbol"){r.defKind!==void 0&&!["symbol","group","shape"].includes(String(r.defKind))&&ue(n,`${e}.defKind`,'must be "symbol", "group", or "shape"'),r.defKind==="shape"&&(!Array.isArray(r.shapes)||r.shapes.length!==1)&&ue(n,`${e}.shapes`,"must contain exactly one native root shape");for(let o of["viewBox","preserveAspectRatio","x","y","width","height","refX","refY"])Qe(r,o,e,n,!0);if(r.rootAttributes!==void 0){let o=ke(r.rootAttributes,`${e}.rootAttributes`,n);if(o)for(let[s,a]of Object.entries(o))["viewBox","preserveAspectRatio","x","y","width","height","refX","refY"].includes(s)&&ue(n,`${e}.rootAttributes.${s}`,"must use its typed symbol field"),Q(a,`${e}.rootAttributes.${s}`,n,!0)}for(let o of["wrapperAttrs","groups","overflow"])r[o]!==void 0&&ue(n,`${e}.${o}`,"is schema-v7 migration input only")}if(i==="marker"){Qe(r,"viewBox",e,n,!0),Qe(r,"preserveAspectRatio",e,n,!0);for(let o of["refX","refY","markerWidth","markerHeight"])Tt(r[o],`${e}.${o}`,n);if(r.markerUnits!=="strokeWidth"&&r.markerUnits!=="userSpaceOnUse"&&ue(n,`${e}.markerUnits`,'must be "strokeWidth" or "userSpaceOnUse"'),r.orient!=="auto"&&r.orient!=="auto-start-reverse"&&!(typeof r.orient=="number"&&Number.isFinite(r.orient))&&ue(n,`${e}.orient`,"must be an orientation keyword or finite number"),r.authoredGeometry!==void 0){let o=ke(r.authoredGeometry,`${e}.authoredGeometry`,n);if(o)for(let s of["refX","refY","markerWidth","markerHeight","markerUnits","orient"])Qe(o,s,`${e}.authoredGeometry`,n,!0)}if(r.rootAttributes!==void 0){let o=ke(r.rootAttributes,`${e}.rootAttributes`,n);if(o)for(let[s,a]of Object.entries(o))["id","viewBox","preserveAspectRatio","refX","refY","markerWidth","markerHeight","markerUnits","orient"].includes(s)&&ue(n,`${e}.rootAttributes.${s}`,"must use its typed marker field"),Q(a,`${e}.rootAttributes.${s}`,n,!0)}}if(i==="linear-gradient"||i==="radial-gradient"){let o=`${e}.gradient`,s=ke(r.gradient,o,n);if(s){let a=i==="linear-gradient"?["x1","y1","x2","y2","opacity"]:["cx","cy","fx","fy","r","ry","rotation","opacity"];for(let c of a)_r(s,c,o,n);if(_r(s,"fr",o,n),s.authoredGeometry!==void 0){let c=`${o}.authoredGeometry`,l=ke(s.authoredGeometry,c,n);if(l){let d=new Set(i==="linear-gradient"?["x1","y1","x2","y2","gradientTransform"]:["cx","cy","fx","fy","r","fr","gradientTransform"]);for(let[u,p]of Object.entries(l))d.has(u)?Q(p,`${c}.${u}`,n,!0):ue(n,`${c}.${u}`,"is not allowed")}}if(s.gradientTransform!==void 0){let c=s.gradientTransform;(!Array.isArray(c)||c.length!==6||!c.every(l=>typeof l=="number"&&Number.isFinite(l)))&&ue(n,`${o}.gradientTransform`,"must be a 6-element finite affine matrix")}it(s.stops,`${o}.stops`,n,(c,l,d)=>{let u=ke(c,l,d);u&&(Tt(u.offset,`${l}.offset`,d),Q(u.color,`${l}.color`,d,!0),_r(u,"opacity",l,d))})}}if(i==="pattern"){let o=`${e}.pattern`,s=ke(r.pattern,o,n);if(s){for(let a of["x","y","width","height","scale","rotation","opacity"])_r(s,a,o,n);s.patternUnits!==void 0&&s.patternUnits!=="userSpaceOnUse"&&s.patternUnits!=="objectBoundingBox"&&ue(n,`${o}.patternUnits`,'must be "userSpaceOnUse" or "objectBoundingBox"'),s.patternContentUnits!==void 0&&s.patternContentUnits!=="userSpaceOnUse"&&s.patternContentUnits!=="objectBoundingBox"&&ue(n,`${o}.patternContentUnits`,'must be "userSpaceOnUse" or "objectBoundingBox"');for(let a of["svgContent","patternTransform","viewBox","preserveAspectRatio"])Qe(s,a,o,n,!0);if(s.authoredGeometry!==void 0){let a=`${o}.authoredGeometry`,c=ke(s.authoredGeometry,a,n);if(c)for(let[l,d]of Object.entries(c))["x","y","width","height"].includes(l)?Q(d,`${a}.${l}`,n,!0):ue(n,`${a}.${l}`,"is not a supported authored pattern field")}}}i==="filter"&&it(r.filters,`${e}.filters`,n,(o,s,a)=>{ke(o,s,a)}),pt(r,e,n)}function mg(t,e,n,r){let i=ke(t,e,n);i&&((r||i.id!==void 0)&&Q(i.id,`${e}.id`,n),Tt(i.time,`${e}.time`,n,0),typeof i.value!="string"&&!(typeof i.value=="number"&&Number.isFinite(i.value))&&!(Array.isArray(i.value)&&i.value.every(o=>typeof o=="number"&&Number.isFinite(o)))&&ue(n,`${e}.value`,"must be a string, finite number, or finite number array"),Q(i.easing,`${e}.easing`,n),pt(i,e,n))}function gg(t,e,n){let r=ke(t,e,n);r&&(Q(r.id,`${e}.id`,n),Q(r.shapeId,`${e}.shapeId`,n),Q(r.property,`${e}.property`,n),hi(r.enabled,`${e}.enabled`,n),So(r,"locked",e,n),it(r.keyframes,`${e}.keyframes`,n,(i,o,s)=>mg(i,o,s,!0)),pt(r,e,n))}function DI(t,e,n){let r=ke(t,e,n);r&&(Tt(r.duration,`${e}.duration`,n,0),hi(r.loop,`${e}.loop`,n),Tt(r.playbackSpeed,`${e}.playbackSpeed`,n,0),it(r.tracks,`${e}.tracks`,n,gg))}function zI(t,e,n){let r=ke(t,e,n);if(!r)return;gn(r.start,`${e}.start`,n),gn(r.end,`${e}.end`,n),typeof r.start=="number"&&typeof r.end=="number"&&r.end<=r.start&&ue(n,`${e}.end`,"must be greater than start");let i=ke(r.style,`${e}.style`,n);i&&Object.keys(i).length===0&&ue(n,`${e}.style`,"must not be empty"),pt(r,e,n)}function _I(t,e,n){let r=ke(t,e,n);r&&(le(r,e,["start","deleteCount","insert"],[],n,!1),gn(r.start,`${e}.start`,n),gn(r.deleteCount,`${e}.deleteCount`,n),Q(r.insert,`${e}.insert`,n,!0))}var hg={"shape:add":(t,e,n)=>{le(t,e,["shape"],[],n),zs(t.shape,`${e}.shape`,n)},"shape:update":(t,e,n)=>{if(le(t,e,["id","state"],["propTimestamps","clientId","textSplices","baseSeq"],n),Q(t.id,`${e}.id`,n),EI(t.state,`${e}.state`,n),t.propTimestamps!==void 0){let r=ke(t.propTimestamps,`${e}.propTimestamps`,n);if(r)for(let[i,o]of Object.entries(r))Tt(o,`${e}.propTimestamps.${i}`,n,0)}Qe(t,"clientId",e,n),t.textSplices!==void 0&&it(t.textSplices,`${e}.textSplices`,n,_I),Pt(t,"baseSeq",e,n)},"shape:remove":(t,e,n)=>{le(t,e,["id"],[],n),Q(t.id,`${e}.id`,n)},"text:format":(t,e,n)=>{le(t,e,["id","ranges"],["baseSeq",...Ne],n),Q(t.id,`${e}.id`,n),it(t.ranges,`${e}.ranges`,n,zI),Pt(t,"baseSeq",e,n),Ae(t,e,n)},"scene:move":(t,e,n)=>{le(t,e,["id","parentId","index"],Ne,n),Q(t.id,`${e}.id`,n),t.parentId!==null&&Q(t.parentId,`${e}.parentId`,n),gn(t.index,`${e}.index`,n),Ae(t,e,n)},"scene:place":(t,e,n)=>{le(t,e,["id","parentId","orderKey"],Ne,n),Q(t.id,`${e}.id`,n),t.parentId!==null&&Q(t.parentId,`${e}.parentId`,n),Q(t.orderKey,`${e}.orderKey`,n),Ae(t,e,n)},"clipMask:upsert":(t,e,n)=>{le(t,e,["clipMaskGroup"],["index",...Ne],n),MI(t.clipMaskGroup,`${e}.clipMaskGroup`,n),Pt(t,"index",e,n),Ae(t,e,n)},"clipMask:remove":(t,e,n)=>{le(t,e,["id"],Ne,n),Q(t.id,`${e}.id`,n),Ae(t,e,n)},"guides:set":(t,e,n)=>{le(t,e,["guides"],[],n),it(t.guides,`${e}.guides`,n,rg)},"guide:upsert":(t,e,n)=>{le(t,e,["guide"],["index",...Ne],n),rg(t.guide,`${e}.guide`,n),Pt(t,"index",e,n),Ae(t,e,n)},"guide:remove":(t,e,n)=>{le(t,e,["id"],Ne,n),Q(t.id,`${e}.id`,n),Ae(t,e,n)},"guide:move":(t,e,n)=>{le(t,e,["id","index"],Ne,n),Q(t.id,`${e}.id`,n),gn(t.index,`${e}.index`,n),Ae(t,e,n)},"measurements:set":(t,e,n)=>{le(t,e,["measurements"],[],n),it(t.measurements,`${e}.measurements`,n,ig)},"measurement:upsert":(t,e,n)=>{le(t,e,["measurement"],["index",...Ne],n),ig(t.measurement,`${e}.measurement`,n),Pt(t,"index",e,n),Ae(t,e,n)},"measurement:remove":(t,e,n)=>{le(t,e,["id"],Ne,n),Q(t.id,`${e}.id`,n),Ae(t,e,n)},"measurement:move":(t,e,n)=>{le(t,e,["id","index"],Ne,n),Q(t.id,`${e}.id`,n),gn(t.index,`${e}.index`,n),Ae(t,e,n)},"metadata:set":(t,e,n)=>{le(t,e,["metadata"],[],n),sg(t.metadata,`${e}.metadata`,n,!1)},"metadata:patch":(t,e,n)=>{le(t,e,["patch"],["removeKeys",...Ne],n),sg(t.patch,`${e}.patch`,n,!0),t.removeKeys!==void 0&&Fr(t.removeKeys,`${e}.removeKeys`,n),Ae(t,e,n)},"documentScripts:set":(t,e,n)=>{le(t,e,["documentScripts"],[],n),it(t.documentScripts,`${e}.documentScripts`,n,ag)},"documentScript:upsert":(t,e,n)=>{le(t,e,["documentScript"],["index",...Ne],n),ag(t.documentScript,`${e}.documentScript`,n),Pt(t,"index",e,n),Ae(t,e,n)},"documentScript:remove":(t,e,n)=>{le(t,e,["id"],Ne,n),Q(t.id,`${e}.id`,n),Ae(t,e,n)},"documentStyles:set":(t,e,n)=>{le(t,e,["documentStyles"],[],n),it(t.documentStyles,`${e}.documentStyles`,n,cg)},"documentStyle:upsert":(t,e,n)=>{le(t,e,["documentStyle"],["index",...Ne],n),cg(t.documentStyle,`${e}.documentStyle`,n),Pt(t,"index",e,n),Ae(t,e,n)},"documentStyle:remove":(t,e,n)=>{le(t,e,["id"],Ne,n),Q(t.id,`${e}.id`,n),Ae(t,e,n)},"templateVariables:set":(t,e,n)=>{le(t,e,["templateVariables"],Ne,n),it(t.templateVariables,`${e}.templateVariables`,n,lg),Ae(t,e,n)},"templateVariable:upsert":(t,e,n)=>{le(t,e,["templateVariable"],["index",...Ne],n),lg(t.templateVariable,`${e}.templateVariable`,n),Pt(t,"index",e,n),Ae(t,e,n)},"templateVariable:remove":(t,e,n)=>{le(t,e,["name"],Ne,n),Q(t.name,`${e}.name`,n),Ae(t,e,n)},"exportItems:set":(t,e,n)=>{le(t,e,["exportItems"],Ne,n),it(t.exportItems,`${e}.exportItems`,n,dg),Ae(t,e,n)},"exportItem:upsert":(t,e,n)=>{le(t,e,["exportItem"],["index",...Ne],n),dg(t.exportItem,`${e}.exportItem`,n),Pt(t,"index",e,n),Ae(t,e,n)},"exportItem:remove":(t,e,n)=>{le(t,e,["id"],Ne,n),Q(t.id,`${e}.id`,n),Ae(t,e,n)},"colorGlyphLibrary:set":(t,e,n)=>{if(le(t,e,["colorGlyphLibrary"],Ne,n),t.colorGlyphLibrary!==null){let r=ke(t.colorGlyphLibrary,`${e}.colorGlyphLibrary`,n);r&&(r.version!==1&&ue(n,`${e}.colorGlyphLibrary.version`,"must be 1"),it(r.entries,`${e}.colorGlyphLibrary.entries`,n,OI),pt(r,`${e}.colorGlyphLibrary`,n))}Ae(t,e,n)},"animation:set":(t,e,n)=>{le(t,e,["animationTimeline"],[],n),t.animationTimeline!==void 0&&DI(t.animationTimeline,`${e}.animationTimeline`,n)},"animation:config":(t,e,n)=>{le(t,e,["config"],Ne,n);let r=ke(t.config,`${e}.config`,n);r&&(le(r,`${e}.config`,["duration","loop","playbackSpeed"],[],n,!1),Tt(r.duration,`${e}.config.duration`,n,0),hi(r.loop,`${e}.config.loop`,n),Tt(r.playbackSpeed,`${e}.config.playbackSpeed`,n,0)),Ae(t,e,n)},"animation:clear":(t,e,n)=>{le(t,e,[],Ne,n),Ae(t,e,n)},"animationTrack:upsert":(t,e,n)=>{le(t,e,["track"],["index",...Ne],n),gg(t.track,`${e}.track`,n),Pt(t,"index",e,n),Ae(t,e,n)},"animationTrack:remove":(t,e,n)=>{le(t,e,["id"],Ne,n),Q(t.id,`${e}.id`,n),Ae(t,e,n)},"animationKeyframe:upsert":(t,e,n)=>{le(t,e,["trackId","keyframe"],Ne,n),Q(t.trackId,`${e}.trackId`,n),mg(t.keyframe,`${e}.keyframe`,n,!0),Ae(t,e,n)},"animationKeyframe:remove":(t,e,n)=>{le(t,e,["trackId","keyframeId"],Ne,n),Q(t.trackId,`${e}.trackId`,n),Q(t.keyframeId,`${e}.keyframeId`,n),Ae(t,e,n)},"library:set":(t,e,n)=>{le(t,e,["library"],[],n),it(t.library,`${e}.library`,n,pg)},"library:upsert":(t,e,n)=>{le(t,e,["def"],["index",...Ne],n),pg(t.def,`${e}.def`,n),Pt(t,"index",e,n),Ae(t,e,n)},"library:remove":(t,e,n)=>{le(t,e,["id"],Ne,n),Q(t.id,`${e}.id`,n),Ae(t,e,n)},"paintServerDefs:set":(t,e,n)=>{le(t,e,["paintServerDefs"],[],n),it(t.paintServerDefs,`${e}.paintServerDefs`,n,ug)},"paintServerDef:upsert":(t,e,n)=>{le(t,e,["paintServerDef"],["index",...Ne],n),ug(t.paintServerDef,`${e}.paintServerDef`,n),Pt(t,"index",e,n),Ae(t,e,n)},"paintServerDef:remove":(t,e,n)=>{le(t,e,["id"],Ne,n),Q(t.id,`${e}.id`,n),Ae(t,e,n)},"presence:cursor":(t,e,n)=>{le(t,e,["position"],[],n);let r=ke(t.position,`${e}.position`,n);r&&(le(r,`${e}.position`,["x","y"],[],n,!1),Tt(r.x,`${e}.position.x`,n),Tt(r.y,`${e}.position.y`,n))},"presence:selection":(t,e,n)=>{le(t,e,["shapeIds"],[],n),Fr(t.shapeIds,`${e}.shapeIds`,n)}},FI=new Set(Object.keys(hg)),yg=new Set(["presence:cursor","presence:selection"]);function zl(t,e="operation"){let n=[],r=ke(t,e,n);return r?!Q(r.type,`${e}.type`,n)||!FI.has(r.type)?(typeof r.type=="string"&&r.type.length>0&&ue(n,`${e}.type`,`unknown operation type "${r.type}"`),{valid:!1,issues:n}):(hg[r.type](r,e,n),n.length===0?{valid:!0,value:r}:{valid:!1,issues:n}):{valid:!1,issues:n}}function LI(t,e={}){let n=[];if(!Array.isArray(t))return{valid:!1,issues:[{path:"ops",message:"must be an array"}]};let r=e.minItems??1,i=e.maxItems??5e3;(t.length<r||t.length>i)&&ue(n,"ops",`must contain ${r}-${i} operations`);let o=[];return t.forEach((s,a)=>{let c=zl(s,`ops[${a}]`);if(!c.valid){n.push(...c.issues);return}if(yg.has(c.value.type)){ue(n,`ops[${a}].type`,"presence operations are not document operations");return}o.push(c.value)}),n.length===0?{valid:!0,value:o}:{valid:!1,issues:n}}function BI(t){let e=zl(t,"op");return e.valid?yg.has(e.value.type)?{valid:!0,value:e.value}:{valid:!1,issues:[{path:"op.type",message:"must be a presence operation"}]}:e}function GI(t){return t.slice(0,5).map(({path:e,message:n})=>`${e} ${n}`).join("; ")}function _l(t,e,n,r){let i=e[n],o=typeof i=="string"?i:"",s=(t??[]).filter(c=>c[n]!==o),a=typeof r=="number"&&Number.isFinite(r)?Math.max(0,Math.min(r,s.length)):s.length;return s.splice(a,0,e),s}function Fl(t,e,n){return(t??[]).filter(r=>r[e]!==n)}function Mt(t,e,n){return _l(t,e,"id",n)}function Bt(t,e){return Fl(t,"id",e)}function Ll(t,e,n){return _l(t,e,"name",n)}function Bl(t,e){return Fl(t,"name",e)}function Sg(t,e){return JSON.stringify(t)===JSON.stringify(e)}function bo(t,e,n){let r=t?[...t]:[],i=r.find(o=>o.id===e);return i?Mt(r,i,n):r}function bg(t,e,n,r,i){let o=[],s=new Map(t.map(l=>[l.id,l])),a=new Set(e.map(l=>l.id)),c=[...t];for(let l of t)a.has(l.id)||(o.push(r(l.id)),c=Bt(c,l.id));return e.forEach((l,d)=>{let u=s.get(l.id);(!u||!Sg(u,l))&&(o.push(n(l,d)),c=Mt(c,l,d))}),e.forEach((l,d)=>{c[d]?.id!==l.id&&(o.push(i(l.id,d)),c=bo(c,l.id,d))}),o}function VI(t,e){return bg(t,e,(n,r)=>({type:"guide:upsert",guide:n,index:r}),n=>({type:"guide:remove",id:n}),(n,r)=>({type:"guide:move",id:n,index:r}))}function jI(t,e){return bg(t,e,(n,r)=>({type:"measurement:upsert",measurement:n,index:r}),n=>({type:"measurement:remove",id:n}),(n,r)=>({type:"measurement:move",id:n,index:r}))}function UI(t,e){let n=t??{},r=e??{},i={},o=[];for(let[s,a]of Object.entries(r))Sg(n[s],a)||(i[s]=a);for(let s of Object.keys(n))s in r||o.push(s);return Object.keys(i).length>0||o.length>0?[{type:"metadata:patch",patch:i,removeKeys:o.length>0?o:void 0}]:[]}function _s(t,e){switch(e.type){case"guide:upsert":return Mt(t,e.guide,e.index);case"guide:remove":return Bt(t,e.id);case"guide:move":return bo(t,e.id,e.index)}}function Fs(t,e){switch(e.type){case"measurement:upsert":return Mt(t,e.measurement,e.index);case"measurement:remove":return Bt(t,e.id);case"measurement:move":return bo(t,e.id,e.index)}}function HI(t,e){let n=new Set(e.removeKeys??[]),r={};for(let[i,o]of Object.entries({...t??{},...e.patch}))n.has(i)||(r[i]=o);return r}function WI(t,e){if(t===e)return null;let n=0,r=Math.min(t.length,e.length);for(;n<r&&t.charCodeAt(n)===e.charCodeAt(n);)n++;let i=0,o=Math.min(t.length,e.length)-n;for(;i<o&&t.charCodeAt(t.length-1-i)===e.charCodeAt(e.length-1-i);)i++;return{start:n,deleteCount:t.length-n-i,insert:e.slice(n,e.length-i)}}function KI(t,e){return t.slice(0,e.start)+e.insert+t.slice(e.start+e.deleteCount)}function Ls(t,e){let n=e.start,r=e.start+e.deleteCount,i=e.insert.length-e.deleteCount,o=t.start,s=t.start+t.deleteCount;return r<=o?{start:o+i,deleteCount:t.deleteCount,insert:t.insert}:n>=s?{start:o,deleteCount:t.deleteCount,insert:t.insert}:n<=o&&r>=s?{start:n+e.insert.length,deleteCount:0,insert:t.insert}:n>=o&&r<=s?{start:o,deleteCount:t.deleteCount+i,insert:t.insert}:n<o?{start:n+e.insert.length,deleteCount:t.deleteCount-(r-o),insert:t.insert}:{start:o,deleteCount:n-o,insert:t.insert}}var yi=Object.freeze({fontFamily:"Arial",fontSize:16,fontWeight:"normal",fontStyle:"normal",fontVariant:"",fontVariantLigatures:"",fontVariantPosition:"",fontVariantCaps:"",fontVariantNumeric:"",fontVariantEastAsian:"",textDecoration:Object.freeze({underline:!1,strikethrough:!1,overline:!1}),textTransform:"none",baselineShift:"baseline",dominantBaseline:"auto",writingMode:"horizontal-tb",whiteSpace:"pre-wrap",direction:"ltr",unicodeBidi:"normal",textAnchor:"start",letterSpacing:0,wordSpacing:0,lineHeight:1.2,fontVariationSettings:Object.freeze({}),fill:"#000000",fillOpacity:1,stroke:"none",strokeWidth:0,strokeOpacity:1}),xo=Object.keys(yi);function or(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Gn(t){return typeof t=="string"?t:void 0}function ft(t){if(typeof t=="number")return Number.isFinite(t)?t:void 0;if(typeof t=="string"&&t.trim()!==""){let e=Number.parseFloat(t);return Number.isFinite(e)?e:void 0}}function ir(t){return e=>typeof e=="string"&&t.includes(e)?e:void 0}function XI(t){if(t==="normal"||t==="bold")return t;let e=ft(t);return e===400?"normal":e===700?"bold":e}function YI(t){return t==="baseline"||t==="super"||t==="sub"?t:ft(t)}function xg(t){if(typeof t=="string"){let n=t.toLowerCase();return{underline:n.includes("underline"),strikethrough:n.includes("line-through")||n.includes("strikethrough"),overline:n.includes("overline")}}if(!or(t))return;let e={};return typeof t.underline=="boolean"&&(e.underline=t.underline),typeof t.strikethrough=="boolean"&&(e.strikethrough=t.strikethrough),typeof t.overline=="boolean"&&(e.overline=t.overline),e}function Ig(t){if(!or(t))return;let e={};for(let[n,r]of Object.entries(t)){let i=ft(r);i!==void 0&&(e[n]=i)}return e}var wg={fontFamily:Gn,fontSize:ft,fontWeight:XI,fontStyle:ir(["normal","italic","oblique"]),fontVariant:Gn,fontVariantLigatures:Gn,fontVariantPosition:Gn,fontVariantCaps:Gn,fontVariantNumeric:Gn,fontVariantEastAsian:Gn,textTransform:ir(["none","capitalize","uppercase","lowercase"]),baselineShift:YI,dominantBaseline:ir(["auto","alphabetic","central","middle","hanging","ideographic","mathematical","text-top","text-bottom"]),writingMode:ir(["horizontal-tb","vertical-rl","vertical-lr"]),whiteSpace:ir(["normal","nowrap","pre","pre-wrap","pre-line","break-spaces"]),direction:ir(["ltr","rtl"]),unicodeBidi:ir(["normal","embed","bidi-override","isolate","isolate-override","plaintext"]),textAnchor:ir(["start","middle","end"]),letterSpacing:ft,wordSpacing:ft,lineHeight:ft,fill:Gn,fillOpacity:ft,stroke:Gn,strokeWidth:ft,strokeOpacity:ft};function vo(t,e){return{...t,...e,textDecoration:{...t.textDecoration,...e.textDecoration??{}},fontVariationSettings:{...e.fontVariationSettings??t.fontVariationSettings}}}function Ul(t,e){let n=Object.keys(t);return n.length!==Object.keys(e).length?!1:n.every(r=>Object.prototype.hasOwnProperty.call(e,r)&&t[r]===e[r])}function sr(t,e){for(let n of xo)if(n==="textDecoration"){if(t.textDecoration.underline!==e.textDecoration.underline||t.textDecoration.strikethrough!==e.textDecoration.strikethrough||t.textDecoration.overline!==e.textDecoration.overline)return!1}else if(n==="fontVariationSettings"){if(!Ul(t.fontVariationSettings,e.fontVariationSettings))return!1}else if(t[n]!==e[n])return!1;return!0}function Hl(t,e){let n=Object.keys(t).sort(),r=Object.keys(e).sort();if(n.length!==r.length||n.some((i,o)=>i!==r[o]))return!1;for(let i of n)if(i==="textDecoration"){let o=t.textDecoration??{},s=e.textDecoration??{},a=new Set([...Object.keys(o),...Object.keys(s)]);for(let c of a){let l=c;if(o[l]!==s[l])return!1}}else if(i==="fontVariationSettings"){if(!Ul(t.fontVariationSettings??{},e.fontVariationSettings??{}))return!1}else{let o=i;if(t[o]!==e[o])return!1}return!0}function Gl(t,e){let n={};for(let i of xo)i==="textDecoration"||i==="fontVariationSettings"||t[i]!==e[i]&&(n[i]=t[i]);let r={};return t.textDecoration.underline!==e.textDecoration.underline&&(r.underline=t.textDecoration.underline),t.textDecoration.strikethrough!==e.textDecoration.strikethrough&&(r.strikethrough=t.textDecoration.strikethrough),t.textDecoration.overline!==e.textDecoration.overline&&(r.overline=t.textDecoration.overline),Object.keys(r).length>0&&(n.textDecoration=r),Ul(t.fontVariationSettings,e.fontVariationSettings)||(n.fontVariationSettings={...t.fontVariationSettings}),n}function Vn(t,e=yi){let n=or(t)?t:{},r={...e};for(let i of xo){if(i==="textDecoration"||i==="fontVariationSettings")continue;let o=wg[i](n[i]);o!==void 0&&(r[i]=o)}return r.textDecoration={...e.textDecoration,...xg(n.textDecoration)??{}},r.fontVariationSettings={...Ig(n.fontVariationSettings)??e.fontVariationSettings},r}function Bs(t){let e=or(t)?t:{},n={};for(let r of xo){if(r==="textDecoration"||r==="fontVariationSettings"||e[r]===void 0)continue;let i=wg[r](e[r]);i!==void 0&&(n[r]=i)}if(e.textDecoration!==void 0){let r=xg(e.textDecoration);r&&Object.keys(r).length>0&&(n.textDecoration=r)}if(e.fontVariationSettings!==void 0){let r=Ig(e.fontVariationSettings);r&&(n.fontVariationSettings=r)}return n}function kg(t){let e=[],n=0;for(;;){let r=t.indexOf(`
2
+ `,n);if(r===-1)return e.push({text:t.slice(n),start:n,end:t.length}),e;e.push({text:t.slice(n,r),start:n,end:r}),n=r+1}}function qI(t,e,n){return t.start===t.end?n&&t.start===e:t.start<=e&&e<t.end}function Vl(t,e,n,r){let i=t;for(let o of e)qI(o,n,r)&&(i=vo(i,o.style));return i===t?vo(t,{}):i}function ZI(t,e,n={}){let r=Vn(t.baseStyle),i=typeof t.text=="string"?t.text:"";return Vl(r,Wl(t.runs,i.length),e,n.collapsed===!0)}function Si(t,e=yi){let n=or(t)?t:{},r=Vn(n.baseStyle,e),i=typeof n.text=="string"?n.text:"";return{text:i,runs:Wl(n.runs,i.length),baseStyle:r,lineHeight:ft(n.lineHeight)??r.lineHeight}}function Wl(t,e){if(!Array.isArray(t))return[];let n=[];for(let r of t){if(!or(r))continue;let i=ft(r.start),o=ft(r.end);if(i===void 0||o===void 0)continue;let s=Math.min(Math.max(Math.trunc(i),0),e),a=Math.min(Math.max(Math.trunc(o),0),e);s>a||n.push({start:s,end:a,style:Bs(r.style)})}return n}function Kl(t){let e=typeof t.text=="string"?t.text:"",n=Vn(t.baseStyle),r=Wl(t.runs,e.length),i=ft(t.lineHeight)??n.lineHeight;return{lines:kg(e).map(s=>{if(s.text.length===0)return{segments:[{text:"",style:Vl(n,r,s.start,!0)}]};let a=new Set([s.start,s.end]);for(let d of r)d.start!==d.end&&(d.start>s.start&&d.start<s.end&&a.add(d.start),d.end>s.start&&d.end<s.end&&a.add(d.end));let c=[...a].sort((d,u)=>d-u),l=[];for(let d=0;d<c.length-1;d++){let u=c[d],p=c[d+1],f=Vl(n,r,u,!1),m=l[l.length-1];m&&sr(m.style,f)?m.text+=e.slice(u,p):l.push({text:e.slice(u,p),style:f})}return{segments:l}}),baseStyle:n,lineHeight:i}}function ar(t){let e=Vn(t?.baseStyle),n=ft(t?.lineHeight)??e.lineHeight,r=Array.isArray(t?.lines)?t.lines:[],i=r.length>0?r:[{segments:[]}],o=[],s=[],a=0;for(let d=0;d<i.length;d++){d>0&&(o.push(`
3
+ `),a+=1);let u=i[d]?.segments,p=Array.isArray(u)?u:[],f=a;for(let m of p){let g=typeof m?.text=="string"?m.text:"";if(g.length===0)continue;let h=Vn(m?.style,e),y=Gl(h,e);Object.keys(y).length>0&&s.push({start:a,end:a+g.length,style:y}),o.push(g),a+=g.length}if(a===f){let m=Vn(p[0]?.style,e),g=Gl(m,e);Object.keys(g).length>0&&s.push({start:f,end:f,style:g})}}let c=o.join(""),l=[];for(let d of s){let u=l[l.length-1];u!==void 0&&u.start!==u.end&&d.start!==d.end&&(u.end===d.start||u.end+1===d.start&&c.charAt(u.end)===`
4
+ `)&&Hl(u.style,d.style)&&u?u.end=d.end:l.push({start:d.start,end:d.end,style:d.style})}return{text:c,runs:l,baseStyle:e,lineHeight:n}}function bi(t){let e=t.richTextRuns;return or(e)?Si(e):null}function jl(t){let e=new Set;for(let n of Object.keys(t))if(n==="textDecoration")for(let r of Object.keys(t.textDecoration??{}))e.add(`textDecoration.${r}`);else e.add(n);return e}function JI(t,e){if(t.start===t.end||e.start>=e.end||t.start<e.start||t.end>e.end)return!1;let n=jl(e.style);for(let r of jl(t.style))if(!n.has(r))return!1;return!0}function Gs(t,e){let n=[...t];for(let r of e)r.start>=r.end||Object.keys(r.style).length!==0&&(n=n.filter(i=>!JI(i,r)),n.push({start:r.start,end:r.end,style:r.style}));return n}function Xl(t,e){if(!Array.isArray(t))return[];let n=[];for(let r of t){if(!or(r))continue;let i=ft(r.start),o=ft(r.end);if(i===void 0||o===void 0)continue;let s=Math.min(Math.max(Math.trunc(i),0),e),a=Math.min(Math.max(Math.trunc(o),0),e);if(s>=a)continue;let c=Bs(r.style);Object.keys(c).length!==0&&n.push({start:s,end:a,style:c})}return n}function QI(t,e){let n=[];for(let r of t){let i=Ls({start:r.start,deleteCount:r.end-r.start,insert:""},e),o=i.start,s=o+i.deleteCount;o>=s||n.push({start:o,end:s,style:r.style})}return n}function vg(t,e){return t.start===e.start&&t.end===e.end&&Hl(t.style,e.style)}function ew(t,e){if(t.text!==e.text||t.lineHeight!==e.lineHeight||!sr(Vn(t.baseStyle),Vn(e.baseStyle)))return null;let n=Array.isArray(t.runs)?t.runs:[],r=Array.isArray(e.runs)?e.runs:[],i=0,o=0;for(;o<r.length;){let c=-1;for(let l=i;l<n.length;l++)if(vg(n[l],r[o])){c=l;break}if(c===-1)break;i=c+1,o++}let s=r.slice(o);if(s.length===0)return null;for(let c of s)if(c.start>=c.end||Object.keys(c.style).length===0)return null;let a=Gs(n,s);if(a.length!==r.length)return null;for(let c=0;c<a.length;c++)if(!vg(a[c],r[c]))return null;return s.map(c=>({start:c.start,end:c.end,style:Bs(c.style)}))}function tw(t,e){let n=e===0||t.charAt(e-1)===`
5
+ `,r=e===t.length||t.charAt(e)===`
6
+ `;return n&&r}function nw(t,e,n){let r=[];for(let i of t){let o=i.start===i.end,s=Ls({start:i.start,deleteCount:i.end-i.start,insert:""},e),a=s.start,c=s.start+s.deleteCount;a===c&&(!o||!tw(n,a))||r.push({start:a,end:c,style:i.style})}return r}function mt(t){let e=[...t].sort((i,o)=>i.index-o.index);if(!e.some(i=>i.orderKey))return e;let n=El(e.length),r=new Map;return e.forEach((i,o)=>{r.set(i.id,i.orderKey??n[o])}),e.sort((i,o)=>{let s=Es(r.get(i.id)??"",r.get(o.id)??"");return s!==0?s:i.id<o.id?-1:i.id>o.id?1:0})}function Ot(t){return t.definitionId??`${t.type}-${t.id}`}function Yl(t){return t.rawDefinition!==void 0?!0:t.clipShapeIds.length===0}function ql(t){let e=Yl(t);return t.type==="clip"?{type:"clip",...t.clipPathUnits!==void 0?{clipPathUnits:t.clipPathUnits}:{},...!e&&t.clipRule!==void 0?{clipRule:t.clipRule}:{},...e&&t.rawDefinition!==void 0?{rawDefinition:t.rawDefinition}:{}}:{type:"mask",...t.maskUnits!==void 0?{maskUnits:t.maskUnits}:{},...t.maskContentUnits!==void 0?{maskContentUnits:t.maskContentUnits}:{},...t.maskType!==void 0?{maskType:t.maskType}:{},...t.maskBounds!==void 0?{maskBounds:structuredClone(t.maskBounds)}:{},...e&&t.rawDefinition!==void 0?{rawDefinition:t.rawDefinition}:{}}}function vi(t,e,n){let{clipPathUnits:r,clipRule:i,maskUnits:o,maskContentUnits:s,maskType:a,maskBounds:c,rawDefinition:l,...d}=structuredClone(t),u=e.rawDefinition!==void 0||Yl(t);return t.type==="clip"?{...d,type:"clip",...e.clipPathUnits!==void 0?{clipPathUnits:e.clipPathUnits}:{},...!u&&e.clipRule!==void 0?{clipRule:e.clipRule}:{},...u&&n&&e.rawDefinition!==void 0?{rawDefinition:e.rawDefinition}:{}}:{...d,type:"mask",...e.maskUnits!==void 0?{maskUnits:e.maskUnits}:{},...e.maskContentUnits!==void 0?{maskContentUnits:e.maskContentUnits}:{},...e.maskType!==void 0?{maskType:e.maskType}:{},...e.maskBounds!==void 0?{maskBounds:structuredClone(e.maskBounds)}:{},...u&&n&&e.rawDefinition!==void 0?{rawDefinition:e.rawDefinition}:{}}}function jn(t){let e=new Map;for(let n of t??[]){let r=Ot(n),i=ql(n),o=e.get(r);i.rawDefinition===void 0&&o?.rawDefinition!==void 0&&(i.rawDefinition=o.rawDefinition),e.set(r,i)}return e}function Tn(t){let e=structuredClone(t??[]),n=jn(e),r=new Set;return e.map(i=>{let o=Ot(i),s=n.get(o)??ql(i),a=s.rawDefinition!==void 0&&!r.has(o);return a&&r.add(o),vi(i,s,a)})}function cr(t,e){let n=structuredClone(t??[]);if(e.type==="clipMask:remove"){let c=n.find(f=>f.id===e.id);if(!c)return Tn(n);let l=Ot(c),d=jn(n).get(l),u=n.filter(f=>f.id!==e.id),p=u.findIndex(f=>Ot(f)===l);return d&&p>=0&&(u[p]=vi(u[p],d,!0)),Tn(u)}let r=n.findIndex(c=>c.id===e.clipMaskGroup.id),i=r>=0?n[r]:void 0,o=i?jn(n).get(Ot(i)):void 0;r>=0&&n.splice(r,1);let s=Math.min(Math.max(0,e.index??n.length),n.length),a=structuredClone(e.clipMaskGroup);return o?.rawDefinition!==void 0&&a.rawDefinition===void 0&&Ot(i)===Ot(a)&&(a=vi(a,o,!0)),n.splice(s,0,a),Tn(n)}function Zl(t,e,n,r){if(!t.some(o=>o.id===e))throw new Error(`Unknown clip/mask group: ${e}`);let i=t.map(o=>o.id===e?vi({...o,definitionId:n},r,r.rawDefinition!==void 0):Ot(o)!==n?structuredClone(o):vi(o,r,!1));return Tn(i)}var rw=/^structural:(clip|mask):(.+):(group|path|content)$/;function Pg(t,e){let n=`structural:${t}:${e}`;return{group:`${n}:group`,path:`${n}:path`,content:`${n}:content`}}function Tg(t,e){for(let n of t){e.add(n.id);let r=n.state.children;Array.isArray(r)&&Tg(r,e)}}function Rg(t,e=null){let n=[];return t.forEach((r,i)=>{n.push({id:r.id,parentId:e,index:i});let o=r.state.children;Array.isArray(o)&&n.push(...Rg(o,r.id))}),n}function lr(t){let e=t.sceneTree&&t.sceneTree.length>0?t.sceneTree:Rg(t.shapes),n=new Map(e.map(I=>[I.id,I])),r=new Map;for(let I of e){let x=r.get(I.parentId)??[];x.push(I),r.set(I.parentId,x)}for(let[I,x]of r)r.set(I,mt(x));let i=I=>rw.test(I),o=new Set(e.filter(I=>!i(I.id)).map(I=>I.id)),s=new Set;Tg(t.shapes,s);let a=new Map,c=new Set,l=(I,x)=>{let k=[];for(let T of r.get(I)??[]){if(!i(T.id)){c.has(T.id)||(c.add(T.id),k.push(T.id));continue}if(x.has(T.id))continue;let w=new Set(x);w.add(T.id),k.push(...l(T.id,w))}return k},d=[null,...o];for(let I of d){let x=l(I,new Set);x.length>0&&a.set(I,x)}for(let I of o){if(c.has(I))continue;let x=n.get(I)?.parentId??null,k=x!==null&&o.has(x)?x:null,T=a.get(k)??[];T.push(I),a.set(k,T),c.add(I)}let u=I=>{for(let[x,k]of a){let T=k.indexOf(I);if(T>=0)return{parentId:x,index:T}}return null},p=I=>{for(let x of a.values()){let k=x.indexOf(I);k>=0&&x.splice(k,1)}},f=t.clipMaskGroups??[],m=jn(f),g=new Map(f.map(I=>[Pg(I.type,I.id).content,I])),h=(I,x=new Set)=>{if(x.has(I.id))return Number.MAX_SAFE_INTEGER;let k=I.parentId?g.get(I.parentId):void 0;if(!k)return 0;let T=new Set(x);return T.add(I.id),1+h(k,T)},y=[...f].sort((I,x)=>h(I)-h(x)||(I.siblingIndex??0)-(x.siblingIndex??0)),b=new Map;for(let I of y){let x=I.clipShapeIds.filter(M=>s.has(M)),k=I.contentShapeIds.filter(M=>s.has(M)),T=m.get(Ot(I));if(k.length===0||x.length===0&&!T?.rawDefinition)continue;let w=[...k,...x].map(u).filter(M=>M!==null),P=w[0]?.parentId??null,N=w.length>0?Math.min(...w.map(M=>M.index)):void 0,R=I.parentId===null||o.has(I.parentId)||g.has(I.parentId)?I.parentId:P;for(let M of[...x,...k])p(M);let $=Pg(I.type,I.id),A=a.get(R)??[],O=I.siblingIndex??N??A.length,G=Math.min(Math.max(0,O),A.length);A.splice(G,0,$.group),a.set(R,A),a.set($.group,[$.path,$.content]),a.set($.path,[...x]),a.set($.content,[...k]),b.set($.group,{id:$.group,parentId:R,index:0}),b.set($.path,{id:$.path,parentId:$.group,index:0}),b.set($.content,{id:$.content,parentId:$.group,index:1})}let v=[];for(let[I,x]of a)x.forEach((k,T)=>{let w=b.get(k);if(w){v.push({...w,parentId:I,index:T});return}let P=n.get(k);P&&P.parentId===I?v.push({...P,index:T}):v.push({id:k,parentId:I,index:T})});t.sceneTree=v}function Ht(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Jl(t){return Ht(t)&&typeof t.updatedAt=="number"&&Number.isSafeInteger(t.updatedAt)&&t.updatedAt>=0&&typeof t.clientId=="string"}function Lr(t,e){return{updatedAt:typeof t=="number"&&Number.isSafeInteger(t)&&t>=0?t:0,clientId:e??""}}function Io(t,e){return Jl(e)?t.updatedAt>e.updatedAt||t.updatedAt===e.updatedAt&&t.clientId>=e.clientId:!0}function Cg(t){return Ht(t.collaborationState)||(t.collaborationState={}),t.collaborationState}function $g(t,e){let n=Cg(t);Ht(n.shapeProps)||(n.shapeProps={});let r=n.shapeProps;return Ht(r[e])||(r[e]={}),r[e]}function wo(t,e){let n=t.collaborationState?.shapeProps;if(!Ht(n))return{};let r=n[e];return Ht(r)?r:{}}function Ng(t,e,n,r){if(n.length===0)return;let i=$g(t,e);for(let o of n)Io(r,i[o])&&(i[o]=r)}function Ql(t,e){let n=t.collaborationState?.shapeProps;if(Ht(n)){for(let r of e)delete n[r];iw(t)}}function iw(t){let e=t.collaborationState;if(Ht(e)){for(let n of["shapeProps","resources"]){let r=e[n];Ht(r)&&Object.keys(r).length===0&&delete e[n]}Object.keys(e).length===0&&delete t.collaborationState}}function Ag(t){switch(t.type){case"guide:upsert":return`guide:${t.guide.id}`;case"guide:remove":case"guide:move":return`guide:${t.id}`;case"measurement:upsert":return`measurement:${t.measurement.id}`;case"measurement:remove":case"measurement:move":return`measurement:${t.id}`;case"metadata:patch":return"metadata:document";case"documentScript:upsert":return`documentScript:${t.documentScript.id}`;case"documentScript:remove":return`documentScript:${t.id}`;case"documentStyle:upsert":return`documentStyle:${t.documentStyle.id}`;case"documentStyle:remove":return`documentStyle:${t.id}`;case"templateVariable:upsert":return`templateVariable:${t.templateVariable.name}`;case"templateVariable:remove":return`templateVariable:${t.name}`;case"exportItem:upsert":return`exportItem:${t.exportItem.id}`;case"exportItem:remove":return`exportItem:${t.id}`;case"colorGlyphLibrary:set":return"colorGlyphLibrary";case"animation:config":case"animation:clear":case"animationTrack:upsert":case"animationTrack:remove":return"animation:timeline";case"animationKeyframe:upsert":return`animationKeyframe:${t.trackId}:${t.keyframe.id}`;case"animationKeyframe:remove":return`animationKeyframe:${t.trackId}:${t.keyframeId}`;case"clipMask:upsert":return`clipMask:${t.clipMaskGroup.id}`;case"clipMask:remove":return`clipMask:${t.id}`;case"library:upsert":return`library:${t.def.id}`;case"library:remove":return`library:${t.id}`;case"paintServerDef:upsert":return`paintServerDef:${t.paintServerDef.id}`;case"paintServerDef:remove":return`paintServerDef:${t.id}`;default:return null}}function Eg(t,e,n){if(e.type==="shape:update"&&e.propTimestamps){if(!n)return null;let a=wo(t,e.id),c={},l={},d=[];for(let[p,f]of Object.entries(e.state)){let m=Lr(e.propTimestamps[p],e.clientId);Io(m,a[p])&&(c[p]=f,l[p]=m.updatedAt,d.push([p,m]))}if(d.length===0)return null;let u=$g(t,e.id);for(let[p,f]of d)u[p]=f;return{...e,state:c,propTimestamps:l}}let r=Ag(e);if(r===null||!("updatedAt"in e)||e.updatedAt===void 0)return e;let i=Lr(e.updatedAt,e.clientId),o=Cg(t);Ht(o.resources)||(o.resources={});let s=o.resources;return Io(i,s[r])?(s[r]=i,{...e,updatedAt:i.updatedAt,clientId:i.clientId}):null}function ow(t){let e=0,n=t.collaborationState?.shapeProps;if(Ht(n)){for(let i of Object.values(n))if(Ht(i))for(let o of Object.values(i))Jl(o)&&(e=Math.max(e,o.updatedAt))}let r=t.collaborationState?.resources;if(Ht(r))for(let i of Object.values(r))Jl(i)&&(e=Math.max(e,i.updatedAt));for(let i of t.sceneTree??[])typeof i.updatedAt=="number"&&Number.isSafeInteger(i.updatedAt)&&i.updatedAt>=0&&(e=Math.max(e,i.updatedAt));return e}function sw(t,e){let n=Object.keys(e.state);if(n.length===0)return;let r=wo(t,e.id),i=0;for(let s of n){let a=Lr(e.propTimestamps?.[s],e.clientId);i=Math.max(i,r[s]?.updatedAt??0,a.updatedAt)}let o=i+1;e.propTimestamps=Object.fromEntries(n.map(s=>[s,o]))}function _g(t,e=null){let n=[];return t.forEach((r,i)=>{n.push({id:r.id,parentId:e,index:i});let o=r.state.children;Array.isArray(o)&&n.push(..._g(o,r.id))}),n}function Rn(t,e){if(t===e)return!0;let n=t??Mg,r=e??Mg;if(n.length!==r.length)return!1;for(let i=0;i<n.length;i++)if(n[i]!==r[i])return!1;return!0}var Mg=[];function Vs(t){return t.sceneTree&&t.sceneTree.length>0?t.sceneTree:_g(t.shapes)}function aw(t,e){let n=t,r=new Set(t.map(s=>s.id)),i=(s,a,c)=>{r.has(s.id)||(n=Lg(n,{id:s.id,parentId:a,index:c}),r.add(s.id)),xi(s)?.forEach((d,u)=>i(d,s.id,u))},o=n.filter(s=>s.parentId===null).length;return i(e,null,o),n}function Fg(t){let e=new Map;for(let r of t){let i=e.get(r.parentId)??[];i.push(r),e.set(r.parentId,i)}let n=[];for(let r of e.values())mt(r).forEach((i,o)=>n.push({...i,index:o}));return n}function Ws(t,e){let n=t.filter(c=>c.parentId===e);if(n.every(c=>c.orderKey))return t;let r=mt(n),i=new Map,o=[],s=null,a=c=>{if(o.length===0)return;let l=Al(s,c,o.length);o.forEach((d,u)=>i.set(d.id,l[u])),o=[]};for(let c of r)c.orderKey?(a(c.orderKey),s=c.orderKey):o.push(c);return a(null),t.map(c=>i.has(c.id)?{...c,orderKey:i.get(c.id)}:c)}function Lg(t,e){let n,r=[],i=[],o=!1;for(let c of t){if(c.id===e.id){if(n=c,!ed(e,n))return t;continue}c.parentId===e.parentId?(r.push(c),c.orderKey&&(o=!0)):i.push(c)}if(o){let c=Ws([...i,...r],e.parentId),l=mt(c.filter(m=>m.parentId===e.parentId)),d=Math.min(Math.max(0,e.index),l.length),u=d>0?l[d-1].orderKey??null:null,p=d<l.length?l[d].orderKey??null:null,f=u!==null&&p!==null&&u>=p?u:yo(u,p);return[...i,...l,{...e,orderKey:f}]}let s=r.sort((c,l)=>c.index-l.index).map((c,l)=>({...c,index:l})),a=Math.min(Math.max(0,e.index),s.length);return[...i,...s,{...e,index:a-.5}]}function cw(t){t.keyframes.sort((e,n)=>{if(e.time!==n.time)return e.time-n.time;let r=e.id??"",i=n.id??"";return r<i?-1:r>i?1:0})}function Bg(t,e){let n=t.keyframes.findIndex(r=>r.id===e.id);n>=0?t.keyframes[n]=e:t.keyframes.push(e),cw(t)}function Gg(t,e){t.keyframes=t.keyframes.filter(n=>n.id!==e)}function Og(t,e){let n=t.animationTimeline?.tracks;return Array.isArray(n)?n.find(r=>r.id===e)??null:null}function ed(t,e){let n=t.updatedAt??0,r=e.updatedAt??0;return n!==r?n>r:(t.clientId??"")>=(e.clientId??"")}function xi(t){let e=t.state.children;return Array.isArray(e)?e:void 0}var js=new Set(["group","hyperlink","switch","container","svg"]);function Vg(t,e,n,r){for(let i of t){n.set(i.id,e),r.set(i.id,i);let o=xi(i);o&&Vg(o,i.id,n,r)}}function Ii(t){let e=t.sceneTree;if(!e||e.length===0)return;let n=new Map,r=new Map;if(Vg(t.shapes,null,n,r),r.size===0)return;let i=new Map;for(let u of e){let p=i.get(u.parentId)??[];p.push(u),i.set(u.parentId,p)}let o=new Map,s=(u,p)=>{let f=o.get(u);f?f.push(p):o.set(u,[p])},a=new Set,c=new Set,l=(u,p)=>{for(let f of mt(i.get(u)??[])){if(c.has(f.id))continue;c.add(f.id);let m=r.get(f.id);if(!m){l(f.id,p);continue}s(p,m),a.add(m.id),js.has(m.type)&&l(f.id,m.id)}};if(l(null,null),a.size===0)return;let d=u=>{let p=n.get(u)??null,f=new Set;for(;p!==null&&!f.has(p);){f.add(p);let m=r.get(p);if(m&&js.has(m.type))return p;p=n.get(p)??null}return null};for(let[u,p]of r)a.has(u)||s(d(u),p);for(let[u,p]of r){if(!js.has(p.type))continue;let f=p.state,m=o.get(u);m&&m.length>0?f.children=m:"children"in f&&delete f.children}t.shapes=o.get(null)??[]}function lw(t){let e=`structural:${t.type}:${t.id}`;return{group:`${e}:group`,path:`${e}:path`,content:`${e}:content`}}function Us(t){let e=t.clipMaskGroups;if(!e||e.length===0)return;let n=t.sceneTree;if(!n||n.length===0)return;let r=new Set(n.map(a=>a.id)),i=new Map;for(let a of n){if(a.parentId===null)continue;let c=i.get(a.parentId);c?c.push(a):i.set(a.parentId,[a])}let o=a=>mt(i.get(a)??[]).map(c=>c.id).filter(c=>!c.startsWith("structural:")),s=new Map(n.map(a=>[a.id,a]));t.clipMaskGroups=e.map(a=>{let c=lw(a);if(!r.has(c.group))return a;let l=r.has(c.path)?o(c.path):a.clipShapeIds,d=r.has(c.content)?o(c.content):a.contentShapeIds,u=s.get(c.group),p=a.parentId,f=a.siblingIndex;if(u){p=u.parentId;let g=u.parentId===null?n.filter(y=>y.parentId===null):i.get(u.parentId)??[],h=mt(g).findIndex(y=>y.id===c.group);f=h>=0?h:u.index}return Dg(l,a.clipShapeIds)&&Dg(d,a.contentShapeIds)&&p===a.parentId&&f===a.siblingIndex?a:{...a,clipShapeIds:l,contentShapeIds:d,parentId:p,siblingIndex:f}})}function Dg(t,e){return!e||t.length!==e.length?!1:t.every((n,r)=>n===e[r])}function nd(t,e){e.add(t.id);let n=xi(t);if(n)for(let r of n)nd(r,e)}function td(t,e){for(let n of t){e.set(n.id,n);let r=xi(n);r&&td(r,e)}}var Hs=class{constructor(e,n){this.snapshot=e;this.indexed=n}snapshot;indexed;shapeIndex=null;inlineProjectionPending=!1;sceneTreeNormalizePending=!1;memoId=null;memoShape=null;findShape(e){if(this.memoId===e)return this.memoShape;let n;return this.indexed?(this.shapeIndex===null&&(this.shapeIndex=new Map,td(this.snapshot.shapes,this.shapeIndex)),n=this.shapeIndex.get(e)??null):n=Ks(this.snapshot.shapes,e),this.memoId=e,this.memoShape=n,n}noteShapesAdded(e){this.memoId=null,this.memoShape=null,this.shapeIndex!==null&&td([e],this.shapeIndex)}noteShapesRemoved(){this.shapeIndex=null,this.memoId=null,this.memoShape=null}requestInlineProjection(){this.inlineProjectionPending=!0}requestSceneTreeNormalize(){this.sceneTreeNormalizePending=!0}settle(){if(this.sceneTreeNormalizePending){this.sceneTreeNormalizePending=!1;let e=this.snapshot.sceneTree;e&&e.length>0&&(this.snapshot.sceneTree=Fg(e))}this.inlineProjectionPending&&(this.inlineProjectionPending=!1,Ii(this.snapshot))}};function Ks(t,e){for(let n of t){if(n.id===e)return n;let r=xi(n);if(!r)continue;let i=Ks(r,e);if(i)return i}return null}function rd(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function dw(t){let e=t.richTextRuns;return!rd(e)||typeof e.text!="string"?null:Si(e)}function uw(t,e){let n=t.state;"extra"in n&&Dr(n);let r=new Set;for(let[i,o]of Object.entries(e))o===null?r.add(i):n[i]=o;if(r.size>0){let i={};for(let[o,s]of Object.entries(n))r.has(o)||(i[o]=s);t.state=i}}function jg(t,e,n){let r=[];for(let i of t){if(i.id===e){nd(i,n);continue}let o=xi(i);if(o){let s=jg(o,e,n),a=i.state;s.length>0?a.children=s:delete a.children}r.push(i)}return r}function Ug(t,e){let n=t.snapshot,r=n,i=Eg(n,e,e.type!=="shape:update"||t.findShape(e.id)!==null);if(i===null)return null;let o=i,s=o;switch(o.type){case"shape:add":{if(!(t.findShape(o.shape.id)!==null)){let c=Vs(r),l=Ol(structuredClone(o.shape));r.shapes.push(l),r.sceneTree=aw(c,l),t.noteShapesAdded(l),t.requestSceneTreeNormalize(),t.requestInlineProjection();let d=new Set;nd(l,d),Ql(n,d)}break}case"shape:update":{let a=t.findShape(o.id);if(!a)return null;uw(a,o.state);break}case"text:format":{let a=t.findShape(o.id);if(!a)return null;let c=a.state;"extra"in c&&Dr(c);let l=dw(c);if(!l)return null;let d=Xl(o.ranges,l.text.length);if(d.length===0)return null;let u={...l,runs:Gs(l.runs,d)};c.richTextRuns=u;let p=["richTextRuns"];if(o.updatedAt!==void 0){let f=Lr(o.updatedAt,o.clientId),m=wo(n,o.id);if(p.some(h=>!Io(f,m?.[h]))){let h=Math.max(0,...p.map(y=>m?.[y]?.updatedAt??0));f={updatedAt:Math.max(f.updatedAt,h)+1,clientId:f.clientId},s={...o,updatedAt:f.updatedAt,clientId:f.clientId}}Ng(n,o.id,p,f)}break}case"shape:remove":{let a=new Set,c=jg(r.shapes,o.id,a),l=a.size>0;l||a.add(o.id);let d=Vs(r),u=d.filter(p=>!a.has(p.id));if(!l&&u.length===d.length)return null;r.shapes=c,r.sceneTree=u,t.noteShapesRemoved(),Ql(n,a),Us(r);break}case"scene:move":{let a=Vs(r),c=a.find(u=>u.id===o.id),l=o.updatedAt===void 0?void 0:Lr(o.updatedAt,o.clientId),d={id:o.id,parentId:o.parentId,index:o.index,updatedAt:l?.updatedAt,clientId:l?.clientId};if(c&&!ed(d,c))return null;r.sceneTree=Lg(a,d),t.requestSceneTreeNormalize(),l&&(s={...o,...l}),t.requestInlineProjection(),Us(r);break}case"scene:place":{if(!As(o.orderKey))return null;let a=Vs(r),c=a.find(p=>p.id===o.id),l=o.updatedAt===void 0?void 0:Lr(o.updatedAt,o.clientId),d={id:o.id,parentId:o.parentId,index:c?.index??Number.MAX_SAFE_INTEGER,orderKey:o.orderKey,updatedAt:l?.updatedAt,clientId:l?.clientId};if(c&&!ed(d,c))return null;let u=Ws(a,o.parentId);r.sceneTree=[...u.filter(p=>p.id!==o.id),d],t.requestSceneTreeNormalize(),t.requestInlineProjection(),Us(r),l&&(s={...o,...l});break}case"clipMask:upsert":r.clipMaskGroups=cr(r.clipMaskGroups,o),lr(r);break;case"clipMask:remove":{if(!(r.clipMaskGroups??[]).some(c=>c.id===o.id))return null;let a=cr(r.clipMaskGroups,o);r.clipMaskGroups=a,lr(r);break}case"guides:set":r.guides=o.guides;break;case"guide:upsert":r.guides=_s(r.guides,o);break;case"guide:remove":case"guide:move":{let a=_s(r.guides,o);if(Rn(r.guides,a))return null;r.guides=a;break}case"measurements:set":r.measurements=o.measurements;break;case"measurement:upsert":r.measurements=Fs(r.measurements,o);break;case"measurement:remove":case"measurement:move":{let a=Fs(r.measurements,o);if(Rn(r.measurements,a))return null;r.measurements=a;break}case"metadata:set":r.documentMetadata=o.metadata;break;case"metadata:patch":{let a=Object.fromEntries(Object.entries({...r.documentMetadata??{},...o.patch}).filter(([c])=>!(o.removeKeys??[]).includes(c)));r.documentMetadata=a;break}case"documentScripts:set":r.documentScripts=o.documentScripts;break;case"documentScript:upsert":r.documentScripts=Mt(r.documentScripts,o.documentScript,o.index);break;case"documentScript:remove":{let a=Bt(r.documentScripts,o.id);if(Rn(r.documentScripts,a))return null;r.documentScripts=a;break}case"documentStyles:set":r.documentStyles=o.documentStyles;break;case"documentStyle:upsert":r.documentStyles=Mt(r.documentStyles,o.documentStyle,o.index);break;case"documentStyle:remove":{let a=Bt(r.documentStyles,o.id);if(Rn(r.documentStyles,a))return null;r.documentStyles=a;break}case"templateVariables:set":r.templateVariables=o.templateVariables;break;case"templateVariable:upsert":r.templateVariables=Ll(r.templateVariables,o.templateVariable,o.index);break;case"templateVariable:remove":{let a=Bl(r.templateVariables,o.name);if(Rn(r.templateVariables,a))return null;r.templateVariables=a;break}case"exportItems:set":r.exportItems=o.exportItems;break;case"exportItem:upsert":r.exportItems=Mt(r.exportItems,o.exportItem,o.index);break;case"exportItem:remove":{let a=Bt(r.exportItems,o.id);if(Rn(r.exportItems,a))return null;r.exportItems=a;break}case"colorGlyphLibrary:set":o.colorGlyphLibrary===null?delete r.colorGlyphLibrary:r.colorGlyphLibrary=o.colorGlyphLibrary;break;case"animation:set":r.animationTimeline=o.animationTimeline;break;case"animation:config":r.animationTimeline={duration:o.config.duration,loop:o.config.loop,playbackSpeed:o.config.playbackSpeed,tracks:Array.isArray(r.animationTimeline?.tracks)?r.animationTimeline.tracks:[]};break;case"animation:clear":delete r.animationTimeline;break;case"animationTrack:upsert":r.animationTimeline={duration:typeof r.animationTimeline?.duration=="number"?r.animationTimeline.duration:0,loop:typeof r.animationTimeline?.loop=="boolean"?r.animationTimeline.loop:!1,playbackSpeed:typeof r.animationTimeline?.playbackSpeed=="number"?r.animationTimeline.playbackSpeed:1,tracks:Mt(Array.isArray(r.animationTimeline?.tracks)?r.animationTimeline.tracks:[],o.track,o.index)};break;case"animationTrack:remove":{let a=Array.isArray(r.animationTimeline?.tracks)?r.animationTimeline.tracks:[],c=Bt(a,o.id);if(Rn(a,c)&&!r.animationTimeline)return null;c.length>0&&r.animationTimeline?r.animationTimeline={...r.animationTimeline,tracks:c}:delete r.animationTimeline;break}case"animationKeyframe:upsert":{let a=Og(r,o.trackId);if(!a)return null;Bg(a,structuredClone(o.keyframe));break}case"animationKeyframe:remove":{let a=Og(r,o.trackId);if(!a)return null;let c=a.keyframes;if(Gg(a,o.keyframeId),Rn(c,a.keyframes))return null;break}case"library:set":r.library=o.library;break;case"library:upsert":r.library=Mt(r.library,o.def,o.index);break;case"library:remove":{let a=Bt(r.library,o.id);if(Rn(r.library,a))return null;r.library=a;break}case"paintServerDefs:set":r.paintServerDefs=o.paintServerDefs;break;case"paintServerDef:upsert":r.paintServerDefs=Mt(r.paintServerDefs,o.paintServerDef,o.index);break;case"paintServerDef:remove":{let a=Bt(r.paintServerDefs,o.id);if(Rn(r.paintServerDefs,a))return null;r.paintServerDefs=a;break}case"presence:cursor":case"presence:selection":break;default:{let a=o;return null}}return s}function pw(t,e,n){if(e.type==="shape:update"&&e.propTimestamps){let r=n?.type==="shape:update"?new Set(Object.keys(n.state)):new Set,i=Object.keys(e.state).filter(o=>!r.has(o));return zg(t,e.id,i)}return e.type==="text:format"&&n?.type==="text:format"?n.updatedAt!==e.updatedAt||n.clientId!==e.clientId?zg(t,e.id,["richTextRuns"]):[]:[]}function fw(t,e){if(e in t)return t[e];let n=t.extra;return rd(n)?n[e]:void 0}function mw(t,e){if(e in t)return!0;let n=t.extra;return rd(n)&&e in n}function zg(t,e,n){if(n.length===0)return[];let r=Ks(t.shapes,e);if(!r)return[];let i=r.state,o=wo(t,e),s=new Map;for(let c of n){let l=o[c];if(!l)continue;let d=s.get(l.clientId);d?d.push(c):s.set(l.clientId,[c])}let a=[];for(let[c,l]of s){let d={},u={};for(let p of l)d[p]=mw(i,p)?structuredClone(fw(i,p)):null,u[p]=o[p].updatedAt;a.push({type:"shape:update",id:e,state:d,propTimestamps:u,clientId:c})}return a}function id(t,e){let n=new Hs(t,!1),r=Ug(n,e);return n.settle(),r}function Hg(t,e){let n=new Hs(t,e.length>1),r=[];for(let i of e){let o=Ug(n,i);o&&r.push(o)}return n.settle(),r}function Wg(t,e){let n=structuredClone(t);return{snapshot:n,acceptedOps:Hg(n,e)}}function gw(t,e){return Wg(t,e).snapshot}function hw(t){if(!t||t.length===0||t.every(n=>n.orderKey))return t;let e=t;for(let n of new Set(t.map(r=>r.parentId)))e=Ws(e,n);return Fg(e)}var yw=6;function Sw(t,e){if(t.length===0)return;let n=new Map;for(let o of t){let s=n.get(o.parentId)??[];s.push(o),n.set(o.parentId,s)}let r=new Set,i=o=>{if(r.has(o)||(r.add(o),o!==null&&!e.hasNode(o)))return;let s=n.get(o);if(!s)return;let a=0;for(let c of mt(s)){if(!e.hasNode(c.id))continue;let l=a++;(e.getParentId(c.id)!==o||e.getSiblingIndex(c.id)!==l)&&e.move(c.id,o,l),i(c.id)}};i(null);for(let o of n.keys())o!==null&&i(o)}var Xs="data-svgsketch-passthrough",bw=new Set(["mask","clipPath","filter","linearGradient","radialGradient","pattern","symbol"]),vw=/^<([A-Za-z][\w:-]*)\b[^>]*>/;function Kg(t){return vw.exec(t.trimStart())}function Ys(t){let e=Kg(t);if(!e)return null;let n=/\bid\s*=\s*(?:"([^"]*)"|'([^']*)')/.exec(e[0]);return n?n[1]??n[2]:null}function xw(t){let e=Kg(t);if(!e)return null;let n=e[1],r=n.lastIndexOf(":");return r>=0?n.slice(r+1):n}var Iw=new RegExp(`\\s+${Xs}\\s*=\\s*(?:"[^"]*"|'[^']*')`);function qs(t){let e=t.markup.indexOf(">");if(e<0)return t;let n=t.markup.slice(0,e+1),r=Iw.exec(n);if(!r)return t;let i=n.slice(0,r.index)+n.slice(r.index+r[0].length);return{...t,markup:i+t.markup.slice(e+1),passthrough:!0}}function Xg(t){let e=[];for(let n of t){if(typeof n!="string")continue;let r=Ys(n);if(!r)continue;let i=xw(n),o=i&&bw.has(i)?i:"mask";e.push(qs({id:r,type:o,markup:n}))}return e}var od={schemaVersion:{kind:"stamped",note:"Serializer stamps CURRENT_SCHEMA_VERSION; no live state."},shapes:{kind:"graph",note:"SceneNode props on graph-owned nodes; the editor Shape registry is the interaction adapter."},viewboxes:{kind:"shape-derived",note:"Projected from `view` shapes on every read (DocumentRootManager.getViewboxes)."},guides:{kind:"aggregate"},measurements:{kind:"aggregate"},sceneTree:{kind:"graph",note:"Serialized by walking the SceneGraph; inline state.children is its projection."},clipMaskGroups:{kind:"aggregate"},documentMetadata:{kind:"aggregate"},documentScripts:{kind:"aggregate"},documentStyles:{kind:"aggregate"},templateVariables:{kind:"aggregate"},animationTimeline:{kind:"aggregate"},library:{kind:"aggregate"},paintServerDefs:{kind:"aggregate"},colorGlyphLibrary:{kind:"aggregate"},exportItems:{kind:"aggregate"},unknownFields:{kind:"aggregate"}},Yg=Object.keys(od).filter(t=>od[t].kind==="aggregate");function Un(t,e){return JSON.stringify(t)===JSON.stringify(e)}function ad(){return{title:"",description:"",author:"",keywords:[],license:"",licenseUrl:"",language:"",customMetadata:{}}}function qg(t){return{...ad(),...t??{}}}function Zs(t){return{guides:structuredClone(t.guides??[]),measurements:structuredClone(t.measurements??[]),clipMaskGroups:Tn(t.clipMaskGroups??[]),documentMetadata:structuredClone(qg(t.documentMetadata)),documentScripts:structuredClone(t.documentScripts??[]),documentStyles:structuredClone(t.documentStyles??[]),templateVariables:structuredClone(t.templateVariables??[]),animationTimeline:t.animationTimeline===void 0?null:structuredClone(t.animationTimeline),exportItems:structuredClone(t.exportItems??[]),colorGlyphLibrary:t.colorGlyphLibrary===void 0||t.colorGlyphLibrary===null?null:structuredClone(t.colorGlyphLibrary),library:structuredClone(t.library??[]),paintServerDefs:structuredClone(t.paintServerDefs??[]),unknownFields:structuredClone(t.unknownFields??{})}}var sd=["symbol","marker","linear-gradient","radial-gradient","pattern","filter"];function Zg(t){let e=t.filter(i=>i.builtIn!==!0),n=sd.map(()=>[]),r=[];for(let i of e){let o=sd.indexOf(i.kind);o>=0?n[o].push(i):r.push(i)}return[...n.flat(),...r]}var Br=class t{graph;sections={guides:[],measurements:[],clipMaskGroups:[],documentMetadata:ad(),documentScripts:[],documentStyles:[],templateVariables:[],animationTimeline:null,exportItems:[],colorGlyphLibrary:null,library:[],paintServerDefs:[],unknownFields:{}};listeners=new Set;unsubscribeGraphStructure=null;disposed=!1;constructor(e=new zr){this.graph=e,this.unsubscribeGraphStructure=this.graph.onStructureChange((n,r)=>{this.foldGraphStructureIntoClipMaskGroups(n,r.id)})}foldGraphStructureIntoClipMaskGroups(e,n){if(this.sections.clipMaskGroups.length===0)return;let r=e==="remove"?/^structural:(clip|mask):(.+):group$/.exec(n):null,i=r?cr(this.sections.clipMaskGroups,{type:"clipMask:remove",id:r[2]}):this.sections.clipMaskGroups;i=i.map(s=>{let a=`structural:${s.type}:${s.id}`,c=this.graph.getNode(`${a}:group`);if(!c)return s;let l=this.graph.getNode(`${a}:path`),d=this.graph.getNode(`${a}:content`),u=l?this.graph.getChildren(l.id).filter(g=>g.getProp("structural")!==!0).map(g=>g.id):s.clipShapeIds,p=d?this.graph.getChildren(d.id).filter(g=>g.getProp("structural")!==!0).map(g=>g.id):s.contentShapeIds,f=this.graph.getSiblingIndex(c.id);return{...s,clipShapeIds:u,contentShapeIds:p,parentId:this.graph.getParentId(c.id),...f>=0?{siblingIndex:f}:{}}});let o=Tn(i);Un(this.sections.clipMaskGroups,o)||(this.sections.clipMaskGroups=o,this.notify("clipMaskGroups"))}onSectionChange(e){return this.disposed?()=>{}:(this.listeners.add(e),()=>this.listeners.delete(e))}notify(e){if(!this.disposed)for(let n of[...this.listeners])n(e)}get isDisposed(){return this.disposed}get sectionListenerCount(){return this.listeners.size}getGuides(){return structuredClone(this.sections.guides)}setGuides(e){this.sections.guides=structuredClone(e),this.notify("guides")}getMeasurements(){return structuredClone(this.sections.measurements)}setMeasurements(e){this.sections.measurements=structuredClone(e),this.notify("measurements")}getDocumentMetadata(){return structuredClone(this.sections.documentMetadata)}setDocumentMetadata(e){this.sections.documentMetadata=structuredClone(qg(e)),this.notify("documentMetadata")}getDocumentScripts(){return structuredClone(this.sections.documentScripts)}setDocumentScripts(e){this.sections.documentScripts=structuredClone(e),this.notify("documentScripts")}getDocumentStyles(){return structuredClone(this.sections.documentStyles)}setDocumentStyles(e){this.sections.documentStyles=structuredClone(e),this.notify("documentStyles")}getTemplateVariables(){return structuredClone(this.sections.templateVariables)}setTemplateVariables(e){this.sections.templateVariables=structuredClone(e),this.notify("templateVariables")}getAnimationTimeline(){return this.sections.animationTimeline===null?null:structuredClone(this.sections.animationTimeline)}setAnimationTimeline(e){this.sections.animationTimeline=e==null?null:structuredClone(e),this.notify("animationTimeline")}getExportItems(){return structuredClone(this.sections.exportItems)}setExportItems(e){this.sections.exportItems=structuredClone(e),this.notify("exportItems")}getColorGlyphLibrary(){return this.sections.colorGlyphLibrary===null?null:structuredClone(this.sections.colorGlyphLibrary)}setColorGlyphLibrary(e){this.sections.colorGlyphLibrary=e===null?null:structuredClone(e),this.notify("colorGlyphLibrary")}getLibrary(){return structuredClone(this.sections.library)}setLibrary(e){this.sections.library=structuredClone(e),this.notify("library")}upsertLibraryDef(e,n){let r=this.sections.library.findIndex(s=>s.id===e.id),i=n??(r>=0?r:void 0),o=Mt(this.sections.library,structuredClone(e),i);Un(this.sections.library,o)||(this.sections.library=o,this.notify("library"))}removeLibraryDef(e){let n=Bt(this.sections.library,e);Un(this.sections.library,n)||(this.sections.library=n,this.notify("library"))}assembleLibrary(){return Zg(this.getLibrary())}getPaintServerDefs(){return structuredClone(this.sections.paintServerDefs)}setPaintServerDefs(e){this.sections.paintServerDefs=structuredClone(e).map(n=>qs(n)),this.notify("paintServerDefs")}getClipMaskGroups(){return structuredClone(this.sections.clipMaskGroups)}setClipMaskGroups(e){this.sections.clipMaskGroups=Tn(e),this.notify("clipMaskGroups")}getClipMaskDefinition(e){let n=jn(this.sections.clipMaskGroups).get(e);return n?structuredClone(n):null}getClipMaskDefinitions(){return structuredClone(Object.fromEntries(jn(this.sections.clipMaskGroups)))}upsertClipMaskDefinition(e,n,r){let i=Zl(this.sections.clipMaskGroups,e,n,r);Un(this.sections.clipMaskGroups,i)||(this.sections.clipMaskGroups=i,this.notify("clipMaskGroups"))}upsertClipMaskGroup(e){let n=this.sections.clipMaskGroups.findIndex(i=>i.id===e.id),r=cr(this.sections.clipMaskGroups,{type:"clipMask:upsert",clipMaskGroup:e,...n>=0?{index:n}:{}});Un(this.sections.clipMaskGroups,r)||(this.sections.clipMaskGroups=r,this.notify("clipMaskGroups"))}unbindClipMaskGroup(e){let n=cr(this.sections.clipMaskGroups,{type:"clipMask:remove",id:e});Un(this.sections.clipMaskGroups,n)||(this.sections.clipMaskGroups=n,this.notify("clipMaskGroups"))}removeClipMaskDefinition(e){let n=Tn(this.sections.clipMaskGroups.filter(r=>Ot(r)!==e));Un(this.sections.clipMaskGroups,n)||(this.sections.clipMaskGroups=n,this.notify("clipMaskGroups"))}getUnknownFields(){return Object.keys(this.sections.unknownFields).length>0?structuredClone(this.sections.unknownFields):void 0}setUnknownFields(e){this.sections.unknownFields=structuredClone(e??{}),this.notify("unknownFields")}adoptReducerSnapshot(e){let n=this.sections,r=Zs(e),i=Yg.filter(o=>!Un(n[o],r[o]));this.sections=r;for(let o of i)this.notify(o);return i}snapshotForReducer(){let e=structuredClone(this.sections.paintServerDefs);return{schemaVersion:Lt,shapes:[],viewboxes:[],guides:structuredClone(this.sections.guides),measurements:structuredClone(this.sections.measurements),clipMaskGroups:structuredClone(this.sections.clipMaskGroups),documentMetadata:structuredClone(this.sections.documentMetadata),documentScripts:structuredClone(this.sections.documentScripts),documentStyles:structuredClone(this.sections.documentStyles),templateVariables:structuredClone(this.sections.templateVariables),...this.sections.animationTimeline===null?{}:{animationTimeline:structuredClone(this.sections.animationTimeline)},exportItems:structuredClone(this.sections.exportItems),...this.sections.colorGlyphLibrary===null?{}:{colorGlyphLibrary:structuredClone(this.sections.colorGlyphLibrary)},library:structuredClone(this.sections.library),paintServerDefs:e,unknownFields:structuredClone(this.sections.unknownFields)}}applyOps(e){let n=this.snapshotForReducer(),r=[],i=new Set;for(let o of e){let s=Zs(n);id(n,o);let a=Zs(n);for(let c of Yg)i.has(c)||Un(s[c],a[c])||(i.add(c),r.push(c))}this.sections=Zs(n);for(let o of r)this.notify(o);return r}loadSections(e,n){let r=i=>n===void 0||n.includes(i);r("guides")&&this.setGuides(e.guides??[]),r("measurements")&&this.setMeasurements(e.measurements??[]),r("clipMaskGroups")&&this.setClipMaskGroups(e.clipMaskGroups??[]),r("documentMetadata")&&this.setDocumentMetadata(e.documentMetadata),r("documentScripts")&&this.setDocumentScripts(e.documentScripts??[]),r("documentStyles")&&this.setDocumentStyles(e.documentStyles??[]),r("templateVariables")&&this.setTemplateVariables(e.templateVariables??[]),r("animationTimeline")&&this.setAnimationTimeline(e.animationTimeline??null),r("exportItems")&&this.setExportItems(e.exportItems??[]),r("colorGlyphLibrary")&&this.setColorGlyphLibrary(e.colorGlyphLibrary??null),r("library")&&this.setLibrary(e.library??[]),r("paintServerDefs")&&this.setPaintServerDefs(e.paintServerDefs??[]),r("unknownFields")&&this.setUnknownFields(e.unknownFields)}clearSections(){this.setClipMaskGroups([]),this.setGuides([]),this.setMeasurements([]),this.setDocumentMetadata(void 0),this.setDocumentScripts([]),this.setDocumentStyles([]),this.setTemplateVariables([]),this.setAnimationTimeline(null),this.setExportItems([]),this.setColorGlyphLibrary(null),this.setLibrary([]),this.setPaintServerDefs([]),this.setUnknownFields(void 0)}toSnapshotSections(){let e=this.getTemplateVariables(),n=this.getAnimationTimeline(),r=this.getExportItems(),i=this.getColorGlyphLibrary(),o=this.assembleLibrary(),s=this.getPaintServerDefs(),a=this.getUnknownFields();return{guides:this.getGuides(),measurements:this.getMeasurements(),clipMaskGroups:this.getClipMaskGroups(),documentMetadata:this.getDocumentMetadata(),documentScripts:this.getDocumentScripts(),documentStyles:this.getDocumentStyles(),...e.length>0?{templateVariables:e}:{},...n!==null&&n.tracks.length>0?{animationTimeline:n}:{},...r.length>0?{exportItems:r}:{},...i!==null?{colorGlyphLibrary:i}:{},...o.length>0?{library:o}:{},...s.length>0?{paintServerDefs:s}:{},...a!==void 0?{unknownFields:a}:{}}}cloneOwned(){let e=new t(this.graph.clone());return e.sections=structuredClone(this.sections),e}dispose(){this.disposed||(this.disposed=!0,this.unsubscribeGraphStructure?.(),this.unsubscribeGraphStructure=null,this.listeners.clear(),this.graph.dispose())}};var ww=1;function cd(){return`canonical-document-${ww++}`}var wi=class t{constructor(e,n){this.model=e;this.identity=n}model;identity;disposed=!1;static empty(e=cd()){return new t(new Br,e)}static own(e,n=cd()){if(e.isDisposed)throw new Error("Cannot own a disposed DocumentModel.");return new t(e,n)}get graph(){return this.model.graph}get isDisposed(){return this.disposed}assertCoherent(){if(this.model.graph!==this.graph)throw new Error("Canonical document model and graph identity diverged.");if(this.disposed!==this.model.isDisposed||this.disposed!==this.graph.isDisposed)throw new Error("Canonical document disposal state diverged.")}clone(e=cd()){if(this.disposed)throw new Error("Cannot clone a disposed canonical document.");return t.own(this.model.cloneOwned(),e)}dispose(){this.disposed||(this.disposed=!0,this.model.dispose())}},ld=class{constructor(e=wi.empty()){this.activeDocument=e;if(e.isDisposed)throw new Error("Cannot start a document session with a disposed document.");e.assertCoherent();let n=this;this.view=Object.freeze({get current(){return n.current},get model(){return n.model},get graph(){return n.graph},get version(){return n.version},get isDisposed(){return n.isDisposed},get replacementListenerCount(){return n.replacementListenerCount},onReplacement:r=>n.onReplacement(r)})}activeDocument;listeners=new Set;replacing=!1;disposed=!1;_version=0;view;get current(){return this.activeDocument}get model(){return this.activeDocument.model}get graph(){return this.activeDocument.graph}get version(){return this._version}get isDisposed(){return this.disposed}get replacementListenerCount(){return this.listeners.size}onReplacement(e){return this.disposed?()=>{}:(this.listeners.add(e),()=>this.listeners.delete(e))}replace(e,n={}){if(this.disposed)throw new Error("Cannot replace a disposed document session.");if(this.replacing)throw new Error("Document replacement is already in progress.");if(e===this.activeDocument)throw new Error("Replacement document is already active.");if(e.isDisposed)throw new Error("Cannot install a disposed canonical document.");e.assertCoherent();let r=this.activeDocument,i=this._version,o=Object.freeze({previous:r,next:e,previousVersion:i,version:i+1});this.replacing=!0,this.activeDocument=e,this._version=o.version;try{n.commit?.(o),n.beforeNotify?.(o)}catch(a){this.activeDocument=r,this._version=i;let c=[a];try{n.rollback?.(o)}catch(l){c.push(l)}try{e.dispose()}catch(l){c.push(l)}throw this.replacing=!1,c.length>1?new AggregateError(c,"Document replacement rejection cleanup failed.",{cause:a}):a}let s=[];for(let a of[...this.listeners])try{a(o)}catch(c){s.push(c)}try{n.finalize?.(o)}catch(a){s.push(a)}try{r.dispose()}catch(a){s.push(a)}return this.replacing=!1,{event:o,postCommitErrors:s}}dispose(){if(!this.disposed){if(this.replacing)throw new Error("Cannot dispose a document session during replacement.");this.disposed=!0,this.listeners.clear(),this.activeDocument.dispose()}}};var Jg=Object.freeze({linear:"linear",ease:"ease","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"});function kw(t,e,n,r,i=1e-4){if(Math.abs(t)<i&&Math.abs(e)<i&&Math.abs(n-1)<i&&Math.abs(r-1)<i)return"linear";for(let[o,s]of Object.entries(ui))if(s&&Math.abs(t-s[0])<i&&Math.abs(e-s[1])<i&&Math.abs(n-s[2])<i&&Math.abs(r-s[3])<i)return o;return null}function dd(t,e,n,r){let i=kw(t,e,n,r);return i===null?{easing:"custom-bezier",customBezier:[t,e,n,r]}:{easing:i}}function Pw(t){let e=[],n=0,r="";for(let i of t)i==="("?n++:i===")"&&n--,i===","&&n===0?(e.push(r.trim()),r=""):r+=i;return(r.trim()!==""||e.length>0)&&e.push(r.trim()),e}function Tw(t){switch(t){case"jump-start":case"start":return"jump-start";case"jump-end":case"end":return"jump-end";case"jump-none":return"jump-none";case"jump-both":return"jump-both";default:return null}}function Rw(t){let e=[];for(let i of t)i.positions.length===0?e.push({value:i.value,position:null}):(e.push({value:i.value,position:i.positions[0]}),i.positions.length===2&&e.push({value:i.value,position:i.positions[1]}));if(e.length<2)return null;e[0].position===null&&(e[0].position=0),e[e.length-1].position===null&&(e[e.length-1].position=1);let n=0;for(;n<e.length;){if(e[n].position!==null){n++;continue}let i=n;for(;i<e.length&&e[i].position===null;)i++;let o=e[n-1].position,s=e[i]?.position??1,a=i-n+1;for(let c=0;c<i-n;c++)e[n+c].position=o+(s-o)*(c+1)/a;n=i}let r=e[0].position;return e.map(i=>{let o=Math.max(r,i.position);return r=o,{value:i.value,position:o}})}function ki(t){let e=t.trim().toLowerCase();if(!e)return null;if(e==="step-start")return{kind:"steps",count:1,position:"jump-start"};if(e==="step-end")return{kind:"steps",count:1,position:"jump-end"};if(e in Jg)return{kind:"keyword",easing:Jg[e]};let n=/^cubic-bezier\s*\(([^)]*)\)$/u.exec(e);if(n){let c=n[1].split(",").map(f=>Number(f.trim()));if(c.length!==4||c.some(f=>!Number.isFinite(f)))return null;let[l,d,u,p]=c;return l<0||l>1||u<0||u>1?null:{kind:"cubic-bezier",points:[l,d,u,p]}}let r=/^steps\s*\(([^)]*)\)$/u.exec(e);if(r){let c=r[1].split(",").map(u=>u.trim());if(c.length<1||c.length>2||!/^\d+$/u.test(c[0]))return null;let l=Number(c[0]);if(!Number.isInteger(l)||l<1)return null;let d=Tw(c[1]??"jump-end");return!d||d==="jump-none"&&l<2?null:{kind:"steps",count:l,position:d}}let i=/^linear\s*\(([\s\S]*)\)$/u.exec(e);if(!i)return null;let o=Pw(i[1]);if(o.length===0)return null;let s=[];for(let c of o){let l=c.split(/\s+/u).filter(Boolean);if(l.length===0)return null;let d=Number(l[0]);if(!Number.isFinite(d))return null;let u=[];for(let p of l.slice(1)){if(!p.endsWith("%"))return null;let f=Number(p.slice(0,-1));if(!Number.isFinite(f))return null;u.push(f/100)}if(u.length>2)return null;s.push({value:d,positions:u})}let a=Rw(s);return a&&a.length>=2?{kind:"linear",points:a}:null}function th(t,e){switch(delete t.customBezier,delete t.linearPoints,delete t.stepsParams,e.kind){case"keyword":t.easing=e.easing;return;case"cubic-bezier":{let n=dd(...e.points);t.easing=n.easing,n.customBezier&&(t.customBezier=n.customBezier);return}case"steps":t.easing="steps",t.stepsParams={count:e.count,position:e.position};return;case"linear":t.easing="linear-function",t.linearPoints=[...e.points]}}function Qg(t,e,n){let r=1-t;return 3*r*r*t*e+3*r*t*t*n+t*t*t}function eh(t,e){let n=Math.max(0,Math.min(1,t)),r=0,i=1,o=n;for(let s=0;s<24;s++){let a=Qg(o,e[0],e[2]);if(Math.abs(a-n)<=1e-8)break;a<n?r=o:i=o,o=(r+i)/2}return Qg(o,e[1],e[3])}function nh(t,e){let n=Math.max(0,Math.min(1,e));if(!t)return n;switch(t.kind){case"keyword":{let r=ui[t.easing];return r?eh(n,r):n}case"cubic-bezier":return eh(n,t.points);case"steps":{let{count:r,position:i}=t,o=Math.floor(n*r);(i==="jump-start"||i==="jump-both")&&o++;let s=i==="jump-none"?r-1:i==="jump-both"?r+1:r;return Math.max(0,Math.min(1,(o+(i==="jump-none"?-1:0))/s))}case"linear":{let r=t.points;if(n<=r[0].position)return r[0].value;for(let i=1;i<r.length;i++){if(n>r[i].position)continue;let o=r[i-1],s=r[i],a=s.position-o.position;return a<=0?s.value:o.value+(s.value-o.value)*(n-o.position)/a}return r.at(-1).value}}}function dr(t){let e=t.trim(),n=/^(\d+):(\d{2}):(\d{2}(?:\.\d+)?)$/u.exec(e);if(n)return Number(n[1])*3600+Number(n[2])*60+Number(n[3]);let r=/^(\d{2}):(\d{2}(?:\.\d+)?)$/u.exec(e);if(r)return Number(r[1])*60+Number(r[2]);let i=/^([+-]?\d+(?:\.\d+)?)\s*(h|min|ms|s)?$/u.exec(e);if(i){let s=Number(i[1]);switch(i[2]??"s"){case"h":return s*3600;case"min":return s*60;case"ms":return s/1e3;default:return s}}let o=Number.parseFloat(e);return Number.isNaN(o)?0:o}function rh(t,e){switch(t){case"reverse":return!0;case"alternate":return e%2===1;case"alternate-reverse":return e%2===0;default:return!1}}function ih(t){if(t.cycleDuration!==void 0)return Math.max(0,t.cycleDuration);if(t.keyframes.length<2)return 0;let e=t.keyframes[0]?.time??0,n=t.keyframes[t.keyframes.length-1]?.time??e;return Math.max(0,n-e)}function oh(t){let e=t.keyframes[0]?.time??0;if(!t.beginTrigger)return e;if(t.beginTrigger.type!=="time")return null;let n=Number.parseFloat(t.beginTrigger.value);return Number.isFinite(n)?n:null}function sh(t){if(t.cycleInfinite)return null;let e=oh(t);return e===null?null:e+ih(t)*Math.max(0,t.cycleRepeats??1)}function Js(t,e,n,r,i){return t+(rh(n,r)?e-i:i)}function xF(t,e){let n=t.keyframes[0]?.time??0,r=oh(t);if(r===null)return null;let i=ih(t);if(i<=0)return e>=r||t.fillBackwards?n:null;let o=t.cycleBehavior??"restart",s=e-r;if(s<0)return t.fillBackwards?Js(n,i,o,0,0):null;let a=Math.max(0,t.cycleRepeats??1),c=t.cycleInfinite??!1,l=c?1/0:i*a;if(!c&&s>=l){if(t.fill==="remove")return null;if(a<=0)return Js(n,i,o,0,0);let p=Math.floor(a),f=a-p,m=f>Number.EPSILON?p:p-1,g=f>Number.EPSILON?f*i:i;return Js(n,i,o,m,g)}let d=Math.floor(s/i),u=s-d*i;return Js(n,i,o,d,u)}function ah(t){if(!t.fillBackwards||t.keyframes.length===0)return null;let e=t.keyframes[0].time,n=t.beginTrigger?.type==="time"?Number.parseFloat(t.beginTrigger.value):Number.NaN,r=Number.isFinite(n)?Math.max(0,n):e;if(!(r>0))return null;let o=rh(t.cycleBehavior??"restart",0)?t.keyframes.at(-1):t.keyframes[0],s=Array.isArray(o.value)?[...o.value]:o.value;return{...t,id:`${t.id}:backwards-fill`,keyframes:[{time:0,value:s,easing:"linear"},{time:r,value:s,easing:"linear"}],beginTrigger:void 0,endTrigger:void 0,cycleDuration:r,cycleRepeats:void 0,cycleInfinite:!1,cycleBehavior:"restart",fill:"remove",fillBackwards:!1,sourceSmilId:void 0,template:void 0}}var Cw=new Set(["ease","ease-in","ease-out","ease-in-out","linear","step-start","step-end"]),$w=new Set(["normal","reverse","alternate","alternate-reverse"]),Nw=new Set(["none","forwards","backwards","both"]),Aw=new Set(["running","paused"]),ud="(?:\\d+(?:\\.\\d+)?|\\.\\d+)",lh=`[+-]?${ud}`,Ew=new RegExp(`^${ud}(?:s|ms)$`,"u"),Mw=new RegExp(`^${lh}(?:s|ms)$`,"u"),Ow=new RegExp(`^${ud}$`,"u");function dh(t){switch(t.kind){case"keyword":return t.easing;case"cubic-bezier":return"custom-bezier";case"steps":return"steps";case"linear":return"linear-function"}}function Qs(t){if(!t)return[];let e=[],n=0,r=null,i=!1,o=0;for(let s=0;s<t.length;s++){let a=t[s];if(i){i=!1;continue}if(a==="\\"){i=!0;continue}if(r){a===r&&(r=null);continue}if(a==='"'||a==="'"){r=a;continue}a==="("?n++:a===")"?n=Math.max(0,n-1):a===","&&n===0&&(e.push(t.slice(o,s).trim()),o=s+1)}return e.push(t.slice(o).trim()),e}function ea(t,e){let n=Qs(t);return n.length===0?"":n[e%n.length]}function pd(t){let n=t.trim().replace(/\w+\([^)]*\)/gu,f=>f.replace(/\s+/gu,"")).split(/\s+/u).filter(Boolean);if(n.length===0)return null;let r=0,i=0,o="linear",s=null,a="normal",c="1",l="none",d="",u=!1,p=!1;for(let f of n){if(!u&&Ew.test(f)){r=f.endsWith("ms")?Number(f.slice(0,-2))/1e3:Number(f.slice(0,-1)),u=!0;continue}if(u&&!p&&Mw.test(f)){i=f.endsWith("ms")?Number(f.slice(0,-2))/1e3:Number(f.slice(0,-1)),p=!0;continue}if(/^(?:cubic-bezier|steps|linear)\(/u.test(f)||Cw.has(f)){let m=ki(f);m&&(s=m,o=dh(m));continue}if($w.has(f)){a=f;continue}if(f==="infinite"){c=f;continue}if(Ow.test(f)){c=f;continue}if(Nw.has(f)){l=f;continue}Aw.has(f)||d||(d=f)}return!d||r<=0?null:{name:d,duration:r,delay:i,easing:o,parsedEasing:s,direction:a,iterationCount:c,fillMode:l}}function ch(t){let e=new RegExp(`^(${lh})\\s*(s|ms)$`,"iu").exec(t.trim());if(!e)return null;let n=Number(e[1]);return e[2].toLowerCase()==="ms"?n/1e3:n}function uh(t,e,n){let r=u=>ea(e[u],n),i=ch(r("animation-delay"));i!==null&&(t.delay=i);let o=ch(r("animation-duration"));o!==null&&o>0&&(t.duration=o);let s=ki(r("animation-timing-function"));s&&(t.parsedEasing=s,t.easing=dh(s));let a=r("animation-direction");a&&(t.direction=a);let c=r("animation-iteration-count");c&&(t.iterationCount=c);let l=r("animation-fill-mode");l&&(t.fillMode=l);let d=r("animation-name");d&&d!=="none"&&(t.name=d)}function ph(t){let e=Qs(t["animation-name"]);if(e.length===0||e.every(r=>!r||r==="none"))return"";let n=["animation-duration","animation-timing-function","animation-delay","animation-iteration-count","animation-direction","animation-fill-mode","animation-play-state"];return e.map((r,i)=>{let o=n.map(s=>ea(t[s],i)).filter(Boolean);return o.push(r),o.join(" ")}).join(", ")}function fh(t){let e=t.fillMode==="forwards"||t.fillMode==="both",n=t.fillMode==="backwards"||t.fillMode==="both";return{...e?{}:{fill:"remove"},...n?{fillBackwards:!0}:{}}}function na(t){return/[\t\n\f\r ]/u.test(t??"")}function ko(t,e){if(t[e]!=="/"||t[e+1]!=="*")return e;let n=t.indexOf("*/",e+2);return n<0?t.length:n+2}function ta(t,e){let n=e;for(;n<t.length;){if(na(t[n])){n++;continue}let r=ko(t,n);if(r===n)break;n=r}return n}function Po(t){let e="";for(let n=0;n<t.length;n++){let r=t[n];if(r!=="\\"){e+=r;continue}n++;let i=t[n];if(i===void 0)return null;if(i===`
7
+ `||i==="\r"||i==="\f"){i==="\r"&&t[n+1]===`
8
+ `&&n++;continue}if(/[0-9a-f]/iu.test(i)){let o=i;for(;o.length<6&&/[0-9a-f]/iu.test(t[n+1]??"");)o+=t[++n];na(t[n+1])&&n++;let s=Number.parseInt(o,16);e+=s===0||s>1114111||s>=55296&&s<=57343?"\uFFFD":String.fromCodePoint(s);continue}e+=i}return e}function Hn(t,e,n=!1){let r=[],i=0,o=null,s=!1,a=0;for(let c=0;c<t.length;c++){let l=t[c];if(o){s?s=!1:l==="\\"?s=!0:l===o&&(o=null);continue}if(l==="/"&&t[c+1]==="*"){c=Math.max(c,ko(t,c)-1);continue}if(l==='"'||l==="'"){o=l;continue}if(l==="("||l==="["||l==="{")a++;else if(l===")"||l==="]"||l==="}")a=Math.max(0,a-1);else if(l===e&&a===0&&(r.push(Object.freeze({start:i,end:c})),i=c+1,n))break}return r.push(Object.freeze({start:i,end:t.length})),r}function Pi(t,e){return Hn(t,e,e===":").map(n=>t.slice(n.start,n.end))}function Dw(t){return!!(t&&(/[-_a-z]/iu.test(t)||t==="\\"))}function zw(t){return!!(t&&(/[-_a-z0-9]/iu.test(t)||t==="\\"))}function _w(t,e){let n=e;for(;n<t.length;){let r=t[n];if(r!=="\\"){if(!zw(r))break;n++;continue}n++;let i=t[n];if(i===void 0||i===`
9
+ `||i==="\r"||i==="\f")break;if(!/[0-9a-f]/iu.test(i)){n++;continue}let o=0;for(;o<6&&/[0-9a-f]/iu.test(t[n]??"");)o++,n++;na(t[n])&&n++}return n}function Cn(t){let e=[],n=null,r=!1;for(let i=0;i<t.length;i++){let o=t[i];if(n){r?r=!1:o==="\\"?r=!0:o===n&&(n=null);continue}if(o==="/"&&t[i+1]==="*"){i=Math.max(i,ko(t,i)-1);continue}if(o==='"'||o==="'"){n=o;continue}if(!Dw(o))continue;let s=i,a=_w(t,i);if(t[a]!=="("){i=a-1;continue}let c=a+1,l=1,d=null,u=!1,p=c;for(;p<t.length;p++){let f=t[p];if(d){u?u=!1:f==="\\"?u=!0:f===d&&(d=null);continue}if(f==="/"&&t[p+1]==="*"){p=Math.max(p,ko(t,p)-1);continue}if(f==='"'||f==="'"){d=f;continue}if(f==="(")l++;else if(f===")"&&--l===0)break}if(l!==0){i=a;continue}e.push(Object.freeze({name:Po(t.slice(s,a))?.toLowerCase()??t.slice(s,a).toLowerCase(),tokenStart:s,tokenEnd:p+1,argumentsStart:c,argumentsEnd:p})),i=p}return Object.freeze(e)}function Fw(t,e){if(t.slice(e,e+3).toLowerCase()!=="url"||t[e+3]!=="(")return!1;let n=t[e-1];return!n||!/[-_a-z0-9]/iu.test(n)}function Wn(t){let e=[],n=null,r=!1;for(let i=0;i<t.length;i++){let o=t[i];if(n){r?r=!1:o==="\\"?r=!0:o===n&&(n=null);continue}if(o==="/"&&t[i+1]==="*"){i=Math.max(i,ko(t,i)-1);continue}if(o==='"'||o==="'"){n=o;continue}if(!Fw(t,i))continue;let s=i,a=ta(t,i+4),c=t[a]==='"'||t[a]==="'"?t[a++]:null;if(a=ta(t,a),t[a]!=="#")continue;a++;let l=a,d=a,u=!1,p=!1;for(;a<t.length;a++){let m=t[a];if(p){p=!1,d=a+1;continue}if(m==="\\"){p=!0,d=a+1;continue}if(c){if(m===c){a=ta(t,a+1),u=t[a]===")";break}d=a+1;continue}if(m===")"){u=!0;break}if(na(m)||m==="/"&&t[a+1]==="*"){a=ta(t,a),u=t[a]===")";break}d=a+1}if(!u||d<=l)continue;let f=Po(t.slice(l,d));f&&(e.push(Object.freeze({targetAuthoredId:f,tokenStart:s,tokenEnd:a+1,targetStart:l,targetEnd:d})),i=a)}return Object.freeze(e)}var gh=String.raw`[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?`,hh="px|pt|pc|in|cm|mm|q|em|rem|%|ex|ch|vw|vh|vmin|vmax",Lw=new RegExp(String.raw`^(${gh})\s*(${hh})?$`,"i"),mh=new RegExp(`(${gh})(${hh})?`,"gi");function gt(t){if(t===null||t.trim().length===0)return null;let e=Lw.exec(t.trim());if(!e)return null;let n=Number(e[1]);return Number.isFinite(n)?Object.freeze({value:n,unit:(e[2]??"").toLowerCase()}):null}function Ti(t){if(!t)return Object.freeze([]);mh.lastIndex=0;let e=[],n;for(;(n=mh.exec(t))!==null;){let r=Number(n[1]);Number.isFinite(r)&&e.push(Object.freeze({value:r,unit:(n[2]??"").toLowerCase()}))}return Object.freeze(e)}function ur(t,e){let n=t.value;if(Number.isFinite(n))switch(t.unit.toLowerCase()){case"%":return e.percentBasis===void 0?void 0:n*e.percentBasis/100;case"vw":return e.viewportWidth===void 0?void 0:n*e.viewportWidth/100;case"vh":return e.viewportHeight===void 0?void 0:n*e.viewportHeight/100;case"vmin":return e.viewportWidth===void 0||e.viewportHeight===void 0?void 0:n*Math.min(e.viewportWidth,e.viewportHeight)/100;case"vmax":return e.viewportWidth===void 0||e.viewportHeight===void 0?void 0:n*Math.max(e.viewportWidth,e.viewportHeight)/100;case"em":return e.fontSize===void 0?void 0:n*e.fontSize;case"rem":return e.rootFontSize===void 0?void 0:n*e.rootFontSize;case"ex":return e.xHeight!==void 0?n*e.xHeight:e.fontSize===void 0?void 0:n*.5*e.fontSize;case"ch":return e.chWidth!==void 0?n*e.chWidth:e.fontSize===void 0?void 0:n*.5*e.fontSize;case"":case"px":return n;case"pt":return n*(4/3);case"pc":return n*16;case"in":return n*96;case"cm":return n*(96/2.54);case"mm":return n*(96/25.4);case"q":return n*(96/101.6);default:return}}function Re(t,e){let n=gt(t);return n?ur(n,e):void 0}function Wt(t){let e=gt(t);if(!(!e||["em","rem","%","ex","ch","vw","vh","vmin","vmax"].includes(e.unit)))return ur(e,{})}var _e=Object.freeze([1,0,0,1,0,0]);function ht(t,e,n,r,i,o){return[t,e,n,r,i,o]}function ia(t){return ht(t[0]??1,t[1]??0,t[2]??0,t[3]??1,t[4]??0,t[5]??0)}function ot(t){return[t[0],t[1],t[2],t[3],t[4],t[5]]}function pr(t){return Array.isArray(t)&&t.length>=6&&t.slice(0,6).every(Number.isFinite)}function Dt(t,e=1e-9){return Math.abs((t[0]??1)-1)<=e&&Math.abs(t[1]??0)<=e&&Math.abs(t[2]??0)<=e&&Math.abs((t[3]??1)-1)<=e&&Math.abs(t[4]??0)<=e&&Math.abs(t[5]??0)<=e}function CF(t,e,n=1e-9){for(let r=0;r<6;r++)if(Math.abs(t[r]-e[r])>n)return!1;return!0}function he(t,e){return ht(t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5])}function $F(t){let e=t[0]*t[3]-t[2]*t[1];if(Math.abs(e)<1e-10)return null;let n=1/e;return ht(t[3]*n,-t[1]*n,-t[2]*n,t[0]*n,(t[2]*t[5]-t[3]*t[4])*n,(t[1]*t[4]-t[0]*t[5])*n)}function Ye(t,e){return{x:t[0]*e.x+t[2]*e.y+t[4],y:t[1]*e.x+t[3]*e.y+t[5]}}function fd(t,e){return{x:t[0]*e.x+t[2]*e.y,y:t[1]*e.x+t[3]*e.y}}function qe(t,e=0){return ht(1,0,0,1,t,e)}function Ci(t,e=t){return ht(t,0,0,e,0,0)}function Ro(t){let e=t*Math.PI/180,n=Math.cos(e),r=Math.sin(e);return ht(n,r,-r,n,0,0)}function oa(t){return ht(1,0,Math.tan(t*Math.PI/180),1,0,0)}function sa(t){return ht(1,Math.tan(t*Math.PI/180),0,1,0,0)}function vh(t,e){return he(he(qe(t.x,t.y),e),qe(-t.x,-t.y))}var Bw=9,Gw=10,Vw=12,jw=13,Uw=32,yh=43,Hw=44,Sh=45,Ww=46,Kw=48,Xw=57,Yw=40,qw=41,Zw=69,Jw=101,Qw=0,ek=1,xh=2,tk=new Map([["matrix",[6]],["translate",[1,2]],["scale",[1,2]],["rotate",[1,3]],["skewX",[1]],["skewY",[1]]]);function nk(t){return t===Uw||t===Bw||t===Gw||t===jw||t===Vw}function ra(t){return t>=Kw&&t<=Xw}function rk(t){let e=t>=65&&t<=90,n=t>=97&&t<=122;return e||n||ra(t)}function Ri(t){for(;t.pos<t.src.length&&nk(t.src.charCodeAt(t.pos));)t.pos++}function Ih(t){let e=t.pos;return Ri(t),t.src.charCodeAt(t.pos)===Hw?(t.pos++,Ri(t),xh):t.pos>e?ek:Qw}function bh(t){let e=t.src,n=t.pos,r=n,i=e.charCodeAt(r);(i===yh||i===Sh)&&r++;let o=!1;for(;r<e.length&&ra(e.charCodeAt(r));)r++,o=!0;if(e.charCodeAt(r)===Ww){let c=r+1;for(;c<e.length&&ra(e.charCodeAt(c));)c++;c>r+1&&(r=c,o=!0)}if(!o)return null;let s=e.charCodeAt(r);if(s===Jw||s===Zw){let c=r+1,l=e.charCodeAt(c);(l===yh||l===Sh)&&c++;let d=c;for(;d<e.length&&ra(e.charCodeAt(d));)d++;d>c&&(r=d)}let a=Number(e.slice(n,r));return Number.isFinite(a)?(t.pos=r,a):null}function ik(t,e){switch(t){case"matrix":return ia(e);case"translate":return qe(e[0],e[1]??0);case"scale":return Ci(e[0],e[1]??e[0]);case"rotate":return e.length===3?vh({x:e[1],y:e[2]},Ro(e[0])):Ro(e[0]);case"skewX":return oa(e[0]);case"skewY":return sa(e[0]);default:return null}}function ok(t){let e=t.src,n=t.pos;for(;t.pos<e.length&&rk(e.charCodeAt(t.pos));)t.pos++;if(t.pos===n)return null;let r=e.slice(n,t.pos),i=tk.get(r);if(!i||(Ri(t),e.charCodeAt(t.pos)!==Yw))return null;t.pos++,Ri(t);let o=i[i.length-1],s=bh(t);if(s===null)return null;let a=[s];for(;;){let c=t.pos;Ih(t);let l=bh(t);if(l===null){t.pos=c;break}if(a.push(l),a.length>o)return null}return Ri(t),e.charCodeAt(t.pos)!==qw||(t.pos++,!i.includes(a.length))?null:ik(r,a)}function sk(t){let e={src:t,pos:0};if(Ri(e),e.pos>=t.length)return _e;let n=_e;for(;;){let r=ok(e);if(r===null)return null;n=he(n,r);let i=Ih(e);if(e.pos>=t.length)return i===xh?null:n}}var ak=2048,To=new Map;function on(t){if(!t)return _e;let e=To.get(t);if(e!==void 0)return e;let n=sk(t),r=n===null?null:Object.freeze(n);if(To.size>=ak){let i=To.keys().next().value;i!==void 0&&To.delete(i)}return To.set(t,r),r}function Kt(t){return on(t)??_e}function aa(t){let e=t[0],n=t[1],r=t[2],i=t[3],o=Math.sqrt(e*e+n*n);if(o<1e-12)return{rotation:0,scaleX:0,scaleY:Math.sqrt(r*r+i*i),skewX:0};let s=Math.atan2(n,e),c=(e*i-n*r)/o,l=c!==0?(e*r+n*i)/(o*o):0,d=Math.atan(l),u=180/Math.PI;return{rotation:s*u,scaleX:o,scaleY:c,skewX:d*u}}function ca(t){return!pr(t)||Dt(t)?null:`matrix(${t[0]}, ${t[1]}, ${t[2]}, ${t[3]}, ${t[4]}, ${t[5]})`}function la(t,e){let n=t.translateX??0,r=t.translateY??0,i=typeof t.rawTransform=="string"?t.rawTransform:"",o=t.rotation??0,s=t.skewX??0,a=t.skewY??0,c=t.scaleX??1,l=t.scaleY??1,d=qe(n,r);if(i)return he(d,Kt(i));if(o===0&&s===0&&a===0&&c===1&&l===1)return d;let u=t.customPivot??e;if(!u)return d;let p=he(he(he(Ro(o),Ci(c,l)),oa(s)),sa(a));return he(d,vh(u,p))}function Rt(t,e){return ca(hn(t,e))}function hn(t,e){let n=t.transformMatrix;return pr(n)&&!Dt(n)?ia(n):la(t,e)}function wh(t,e){let n=t.ancestorTransform;if(!pr(n)){delete t.ancestorTransform;return}if(Dt(n)){delete t.ancestorTransform;return}let r=pr(t.transformMatrix)?ia(t.transformMatrix):la(t,e);t.transformMatrix=ot(he(ia(n),r)),delete t.ancestorTransform}function kh(t,e,n){let r=Rt(t,{x:e,y:n});return r?`${r} translate(${e}, ${n})`:`translate(${e}, ${n})`}var ck=Object.freeze({left:0,center:50,right:100}),lk=Object.freeze({top:0,center:50,bottom:100});function mr(t,e,n){let r=gt(t);return!r||r.unit===""&&r.value!==0?null:ur(r,{...n,percentBasis:e==="x"?n.boxWidth:e==="y"?n.boxHeight:void 0})??null}function Ph(t,e,n){let r=t.trim().toLowerCase(),i=e==="horizontal"?ck:lk;if(Object.hasOwn(i,r))return{kind:"percentage",value:i[r]};let o=gt(r);if(!o||o.unit===""&&o.value!==0)return null;if(o.unit==="%")return{kind:"percentage",value:o.value};let s=ur(o,n);return s===void 0?null:{kind:"length",value:s}}function Th(t,e,n){return t.kind==="length"?e+t.value:n===void 0?null:e+t.value*n/100}function fa(t,e={}){let n=t.trim().split(/\s+/u).filter(Boolean);if(n.length===0||n.length>3)return null;let r=0;if(n.length===3){let d=mr(n[2],"z",e);if(d===null||n[2].includes("%"))return null;r=d}let i,o;if(n.length===1){let d=n[0].toLowerCase();d==="top"||d==="bottom"?(i="center",o=n[0]):(i=n[0],o="center")}else{i=n[0],o=n[1];let d=i.toLowerCase(),u=o.toLowerCase(),p=d==="top"||d==="bottom",f=u==="left"||u==="right";p&&(f||u==="center")?[i,o]=[o,i]:d==="center"&&f&&([i,o]=[o,i])}let s=Ph(i,"horizontal",e),a=Ph(o,"vertical",e);if(!s||!a)return null;let c=Th(s,e.boxX??0,e.boxWidth),l=Th(a,e.boxY??0,e.boxHeight);return c===null||l===null?null:Object.freeze(r===0?{x:c,y:l}:{x:c,y:l,z:r})}var ma=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),dk=new Set(["matrix3d","perspective","rotate3d","rotatex","rotatey","rotatez","scale3d","scalez","translate3d","translatez"]),uk=/^([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?)\s*(deg|grad|rad|turn)?$/iu;function Rh(t){return t.replace(/\/\*[\s\S]*?\*\//gu,"").trim()===""}function pk(t){let e=[],n="",r=0,i=null,o=!1,s=!1,a=()=>{let c=n.trim();return n="",c?(e.push(c),!0):!1};for(let c=0;c<t.length;c++){let l=t[c];if(i){n+=l,o?o=!1:l==="\\"?o=!0:l===i&&(i=null);continue}if(l==='"'||l==="'"){i=l,n+=l;continue}if(l==="/"&&t[c+1]==="*"){let d=t.indexOf("*/",c+2);if(d<0)return null;n+=" ",c=d+1;continue}if(l==="("){r++,n+=l;continue}if(l===")"){if(r===0)return null;r--,n+=l;continue}if(r===0&&l===","){if(!a())return null;s=!0;continue}if(r===0&&/\s/u.test(l)&&!s){n.trim()&&a();continue}n+=l}return r!==0||i||n.trim()===""&&s||n.trim()&&!a()?null:Object.freeze(e)}function Oh(t){if(t.trim().toLowerCase()==="none")return Object.freeze([]);let e=Cn(t);if(e.length===0)return null;let n=[],r=0;for(let i of e){if(!Rh(t.slice(r,i.tokenStart)))return null;let o=pk(t.slice(i.argumentsStart,i.argumentsEnd));if(!o)return null;n.push(Object.freeze({name:i.name,args:o})),r=i.tokenEnd}return Rh(t.slice(r))?Object.freeze(n):null}function yn(t){if(t===void 0||t.trim()==="")return null;let e=Number(t);return Number.isFinite(e)?e:null}function sn(t){if(t===void 0)return null;let e=uk.exec(t.trim());if(!e)return null;let n=Number(e[1]);if(!Number.isFinite(n)||!e[2]&&n!==0)return null;switch(e[2]?.toLowerCase()){case"grad":return n*Math.PI/200;case"rad":return n;case"turn":return n*2*Math.PI;default:return n*Math.PI/180}}function Vr(t,e){let n=new Array(16).fill(0);for(let r=0;r<4;r++)for(let i=0;i<4;i++)for(let o=0;o<4;o++)n[r*4+i]+=t[r*4+o]*e[o*4+i];return n}function jr(t,e,n){return[1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1]}function Co(t,e,n){return[t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1]}function gr(t,e,n,r){let i=Math.hypot(t,e,n);if(i===0)return r===0?ma:null;t/=i,e/=i,n/=i;let o=Math.cos(r),s=Math.sin(r),a=1-o;return[t*t*a+o,t*e*a-n*s,t*n*a+e*s,0,e*t*a+n*s,e*e*a+o,e*n*a-t*s,0,n*t*a-e*s,n*e*a+t*s,n*n*a+o,0,0,0,0,1]}function Xt(t,...e){return e.includes(t.length)}function ga(t,e){let n=t.args;switch(t.name){case"translate":{if(!Xt(n,1,2))return null;let r=mr(n[0],"x",e),i=mr(n[1]??"0","y",e);return r===null||i===null?null:jr(r,i,0)}case"translatex":case"translatey":case"translatez":{if(!Xt(n,1))return null;let r=t.name.at(-1),i=mr(n[0],r,e);return i===null?null:jr(r==="x"?i:0,r==="y"?i:0,r==="z"?i:0)}case"translate3d":{if(!Xt(n,3))return null;let r=mr(n[0],"x",e),i=mr(n[1],"y",e),o=mr(n[2],"z",e);return r===null||i===null||o===null?null:jr(r,i,o)}case"scale":{if(!Xt(n,1,2))return null;let r=yn(n[0]),i=n.length===1?r:yn(n[1]);return r===null||i===null?null:Co(r,i,1)}case"scalex":case"scaley":case"scalez":{if(!Xt(n,1))return null;let r=yn(n[0]);return r===null?null:Co(t.name==="scalex"?r:1,t.name==="scaley"?r:1,t.name==="scalez"?r:1)}case"scale3d":{if(!Xt(n,3))return null;let r=n.map(yn);return r.some(i=>i===null)?null:Co(r[0],r[1],r[2])}case"rotate":case"rotatex":case"rotatey":case"rotatez":{if(!Xt(n,1))return null;let r=sn(n[0]);return r===null?null:t.name==="rotatex"?gr(1,0,0,r):t.name==="rotatey"?gr(0,1,0,r):gr(0,0,1,r)}case"rotate3d":{if(!Xt(n,4))return null;let r=yn(n[0]),i=yn(n[1]),o=yn(n[2]),s=sn(n[3]);return r===null||i===null||o===null||s===null?null:gr(r,i,o,s)}case"skew":{if(!Xt(n,1,2))return null;let r=sn(n[0]),i=sn(n[1]??"0deg");return r===null||i===null?null:[1,Math.tan(r),0,0,Math.tan(i),1,0,0,0,0,1,0,0,0,0,1]}case"skewx":case"skewy":{if(!Xt(n,1))return null;let r=sn(n[0]);return r===null?null:t.name==="skewx"?[1,Math.tan(r),0,0,0,1,0,0,0,0,1,0,0,0,0,1]:[1,0,0,0,Math.tan(r),1,0,0,0,0,1,0,0,0,0,1]}case"matrix":{if(!Xt(n,6))return null;let r=n.map(yn);return r.some(i=>i===null)?null:[r[0],r[2],0,r[4],r[1],r[3],0,r[5],0,0,1,0,0,0,0,1]}case"matrix3d":{if(!Xt(n,16))return null;let r=n.map(yn);if(r.some(o=>o===null))return null;let i=[r[0],r[4],r[8],r[12],r[1],r[5],r[9],r[13],r[2],r[6],r[10],r[14],r[3],r[7],r[11],r[15]];return i[12]===0&&i[13]===0&&i[14]===0&&i[15]===1?i:"perspective"}case"perspective":return Xt(n,1)&&mr(n[0],"z",e)!==null?"perspective":null;default:return null}}function Dh(t,e){let n=ma;for(let r of t){let i=ga(r,e);if(!i||i==="perspective")return i;n=Vr(n,i)}return n}function zh(t){let e=Oh(t);if(!e)return"invalid";let n=Dh(e,{boxWidth:100,boxHeight:100,viewportWidth:100,viewportHeight:100,fontSize:16,rootFontSize:16,xHeight:8,chWidth:8});return n==="perspective"?"unsupported-perspective":n===null?"invalid":null}function ua(t){return t.startsWith("translate")?"translate":t.startsWith("scale")?"scale":t.startsWith("rotate")?"rotate":t.startsWith("skew")?"skew":"matrix"}function Ch(t){let e=t.name;return e==="perspective"?null:e.startsWith("translate")?Object.freeze({name:e,args:Object.freeze(t.args.map(()=>"0px"))}):e.startsWith("scale")?Object.freeze({name:e,args:Object.freeze(t.args.map(()=>"1"))}):e==="rotate3d"?Object.freeze({name:e,args:Object.freeze(["0","0","1","0deg"])}):e.startsWith("rotate")||e.startsWith("skew")?Object.freeze({name:e,args:Object.freeze(t.args.map(()=>"0deg"))}):e==="matrix"?Object.freeze({name:e,args:Object.freeze(["1","0","0","1","0","0"])}):e==="matrix3d"?Object.freeze({name:e,args:Object.freeze(ma.map(String))}):null}function fk(t,e){let n=[...t],r=[...e],i=Math.max(n.length,r.length);for(let o=0;o<i;o++){if(!n[o]&&r[o]){let s=Ch(r[o]);if(!s)return null;n[o]=s}if(!r[o]&&n[o]){let s=Ch(n[o]);if(!s)return null;r[o]=s}}return[n,r]}function $h(t,e){let n=ga(t,e);return!n||n==="perspective"?null:[n[3],n[7],n[11]]}function Nh(t){let e=ga(t,{});return!e||e==="perspective"?null:[e[0],e[5],e[10]]}function st(t,e,n){return t+(e-t)*n}function mk(t,e,n,r){let i=ua(t.name);if(i!==ua(e.name))return null;if(i==="translate"){let o=$h(t,r),s=$h(e,r);return o&&s?jr(st(o[0],s[0],n),st(o[1],s[1],n),st(o[2],s[2],n)):null}if(i==="scale"){let o=Nh(t),s=Nh(e);return o&&s?Co(st(o[0],s[0],n),st(o[1],s[1],n),st(o[2],s[2],n)):null}if(i==="rotate"&&t.name===e.name){if(t.name==="rotate3d"){let c=t.args.slice(0,3).map(yn),l=e.args.slice(0,3).map(yn),d=sn(t.args[3]),u=sn(e.args[3]);if(c.some(y=>y===null)||l.some(y=>y===null)||d===null||u===null)return null;let p=Math.hypot(c[0],c[1],c[2]),f=Math.hypot(l[0],l[1],l[2]);if(p===0||f===0)return null;let m=[c[0]/p,c[1]/p,c[2]/p],g=[l[0]/f,l[1]/f,l[2]/f],h=m[0]*g[0]+m[1]*g[1]+m[2]*g[2];return Math.abs(Math.abs(h)-1)>1e-10?null:gr(m[0],m[1],m[2],st(d,h<0?-u:u,n))}let o=sn(t.args[0]),s=sn(e.args[0]);if(o===null||s===null)return null;let a=st(o,s,n);return t.name==="rotatex"?gr(1,0,0,a):t.name==="rotatey"?gr(0,1,0,a):gr(0,0,1,a)}if(i==="skew"&&t.name===e.name&&t.args.length===e.args.length){let o=t.args.map(sn),s=e.args.map(sn);return o.some(a=>a===null)||s.some(a=>a===null)?null:ga({name:t.name,args:o.map((a,c)=>`${st(a,s[c],n)}rad`)},r)}return null}function gk(t,e,n,r){let i=fk(t,e);if(!i)return null;let o=ma;for(let s=0;s<i[0].length;s++){let a=mk(i[0][s],i[1][s],n,r);if(!a)return null;o=Vr(o,a)}return o}function pa(t){return Math.abs(t[12])>1e-10||Math.abs(t[13])>1e-10||Math.abs(t[14])>1e-10||Math.abs(t[15]-1)>1e-10?null:ht(t[0],t[4],t[1],t[5],t[3],t[7])}function hk(t){return[t[0],t[2],0,t[4],t[1],t[3],0,t[5],0,0,1,0,0,0,0,1]}function da(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function md(t){return Math.hypot(t[0],t[1],t[2])}function Gr(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function gd(t,e){return[t[0]-e[0],t[1]-e[1],t[2]-e[2]]}function yk(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function Sk(t,e,n){let r=t[0],i=e[0],o=n[0],s=t[1],a=e[1],c=n[1],l=t[2],d=e[2],u=n[2],p=r+a+u,f,m,g,h;if(p>0){let b=Math.sqrt(p+1)*2;h=b/4,f=(d-c)/b,m=(o-l)/b,g=(s-i)/b}else if(r>a&&r>u){let b=Math.sqrt(1+r-a-u)*2;h=(d-c)/b,f=b/4,m=(i+s)/b,g=(o+l)/b}else if(a>u){let b=Math.sqrt(1+a-r-u)*2;h=(o-l)/b,f=(i+s)/b,m=b/4,g=(c+d)/b}else{let b=Math.sqrt(1+u-r-a)*2;h=(s-i)/b,f=(o+l)/b,m=(c+d)/b,g=b/4}let y=Math.hypot(f,m,g,h);return[f/y,m/y,g/y,h/y]}function Ah(t){if(Math.abs(t[12])>1e-10||Math.abs(t[13])>1e-10||Math.abs(t[14])>1e-10||Math.abs(t[15]-1)>1e-10)return null;let e=[t[0],t[4],t[8]],n=[t[1],t[5],t[9]],r=[t[2],t[6],t[10]],i=md(e);if(i<1e-12)return null;e=Gr(e,1/i);let o=da(e,n);n=gd(n,Gr(e,o));let s=md(n);if(s<1e-12)return null;n=Gr(n,1/s),o/=s;let a=da(e,r);r=gd(r,Gr(e,a));let c=da(n,r);r=gd(r,Gr(n,c));let l=md(r);return l<1e-12?null:(r=Gr(r,1/l),a/=l,c/=l,da(e,yk(n,r))<0&&(i=-i,e=Gr(e,-1)),{translate:[t[3],t[7],t[11]],scale:[i,s,l],skew:[o,a,c],quaternion:Sk(e,n,r)})}function bk(t,e,n){let r=[...e],i=t.reduce((l,d,u)=>l+d*r[u],0);if(i<0&&(r=r.map(l=>-l),i=-i),i>.9995){let l=t.map((u,p)=>st(u,r[p],n)),d=Math.hypot(...l);return l.map(u=>u/d)}let o=Math.acos(Math.max(-1,Math.min(1,i))),s=Math.sin(o),a=Math.sin((1-n)*o)/s,c=Math.sin(n*o)/s;return t.map((l,d)=>l*a+r[d]*c)}function vk(t){let[e,n,r,i]=t;return[1-2*(n*n+r*r),2*(e*n-r*i),2*(e*r+n*i),0,2*(e*n+r*i),1-2*(e*e+r*r),2*(n*r-e*i),0,2*(e*r-n*i),2*(n*r+e*i),1-2*(e*e+n*n),0,0,0,0,1]}function xk(t,e,n){let r=Ah(t),i=Ah(e);if(!r||!i)return null;let o=r.translate.map((d,u)=>st(d,i.translate[u],n)),s=r.scale.map((d,u)=>st(d,i.scale[u],n)),a=r.skew.map((d,u)=>st(d,i.skew[u],n)),c=vk(bk(r.quaternion,i.quaternion,n)),l=[1,a[0],a[1],0,0,1,a[2],0,0,0,1,0,0,0,0,1];return Vr(Vr(jr(o[0],o[1],o[2]),Vr(c,l)),Co(s[0],s[1],s[2]))}function Eh(t){return Math.abs(t[2])<1e-10&&Math.abs(t[6])<1e-10&&Math.abs(t[8])<1e-10&&Math.abs(t[9])<1e-10&&Math.abs(t[10]-1)<1e-10&&Math.abs(t[11])<1e-10}function Ik(t,e,n){let r=pa(t),i=pa(e);if(!r||!i)return null;let o=aa(r),s=aa(i),a=s.rotation;for(;a-o.rotation>180;)a-=360;for(;a-o.rotation<-180;)a+=360;let c=st(o.rotation,a,n)*Math.PI/180,l=st(o.skewX,s.skewX,n)*Math.PI/180,d=st(o.scaleX,s.scaleX,n),u=st(o.scaleY,s.scaleY,n),p=Math.cos(c),f=Math.sin(c),m=Math.tan(l);return hk(ht(p*d,f*d,p*d*m-f*u,f*d*m+p*u,st(r[4],i[4],n),st(r[5],i[5],n)))}function wk(t,e,n,r,i,o){let s=gk(t,e,i,o);return s||(Eh(n)&&Eh(r)?Ik(n,r,i):xk(n,r,i))}function Mh(t,e){return Vr(Vr(jr(e.x,e.y,e.z??0),t),jr(-e.x,-e.y,-(e.z??0)))}function fr(t){return!Number.isFinite(t)||Math.abs(t)<1e-9?0:Number(t.toFixed(10))}function kk(t){return t.every(e=>e.length===1&&(e[0].name==="rotate"||e[0].name==="rotatez"))}function Pk(t,e,n){let r=new Set;for(let i of t)for(let o of i)o.name.startsWith("translate")?(o.name!=="translatey"&&o.name!=="translatez"&&r.add("translateX"),o.name!=="translatex"&&o.name!=="translatez"&&r.add("translateY")):o.name.startsWith("scale")?(o.name!=="scaley"&&o.name!=="scalez"&&r.add("scaleX"),o.name!=="scalex"&&o.name!=="scalez"&&r.add("scaleY")):o.name.startsWith("rotate")?r.add("rotation"):o.name==="skew"||o.name==="skewx"?r.add("skewX"):o.name==="skewy"?r.add("skewY"):(o.name==="matrix"||o.name==="matrix3d")&&(r.add("translateX"),r.add("translateY"),r.add("scaleX"),r.add("scaleY"),r.add("rotation"),r.add("skewX"));return e&&(r.add("translateX"),r.add("translateY"),r.add("scaleX"),r.add("scaleY"),r.add("rotation")),n.some(i=>i.skewX!==0)&&r.add("skewX"),Object.freeze([...r])}function ha(t,e={},n=16){if(t.length===0||!Number.isInteger(n)||n<1)return Object.freeze({status:"invalid",stops:Object.freeze([]),sampled:!1,pureRotation:!1,channels:Object.freeze([])});let r=t.map(g=>Oh(g.transform));if(r.some(g=>g===null))return Object.freeze({status:"invalid",stops:Object.freeze([]),sampled:!1,pureRotation:!1,channels:Object.freeze([])});let i=r.map(g=>Dh(g,e));if(i.some(g=>g==="perspective"))return Object.freeze({status:"unsupported-perspective",stops:Object.freeze([]),sampled:!1,pureRotation:!1,channels:Object.freeze([])});if(i.some(g=>g===null))return Object.freeze({status:"invalid",stops:Object.freeze([]),sampled:!1,pureRotation:!1,channels:Object.freeze([])});let o=r,s=i,a=e.transformOrigin,c=kk(o),l=e.retainPureRotationOrigin===!0&&c,d=c?o.map(g=>sn(g[0].args[0])*180/Math.PI):null,u=o.some(g=>g.some(h=>dk.has(h.name)))||a!==void 0&&!l&&c||o.some((g,h)=>h>0&&g.length!==o[h-1].length)||o.some((g,h)=>h>0&&g.some((y,b)=>ua(y.name)!==ua(o[h-1][b]?.name??"matrix"))),p=[];for(let g=0;g<t.length;g++){let h=a&&!l?Mh(s[g],a):s[g],y=pa(h);if(!y)return Object.freeze({status:"unsupported-perspective",stops:Object.freeze([]),sampled:!1,pureRotation:!1,channels:Object.freeze([])});p.push({offset:t[g].offset,matrix:y,...d?{rotation:d[g]}:{}});let b=t[g+1];if(!(!b||!u))for(let v=1;v<n;v++){let I=v/n,x=Math.max(0,Math.min(1,e.progressForInterval?.(g,I)??I)),k=wk(o[g],o[g+1],s[g],s[g+1],x,e);if(!k)return Object.freeze({status:"invalid",stops:Object.freeze([]),sampled:!1,pureRotation:!1,channels:Object.freeze([])});let T=a&&!l?Mh(k,a):k,w=pa(T);if(!w)return Object.freeze({status:"unsupported-perspective",stops:Object.freeze([]),sampled:!1,pureRotation:!1,channels:Object.freeze([])});p.push({offset:t[g].offset+(b.offset-t[g].offset)*I,matrix:w,...d?{rotation:st(d[g],d[g+1],x)}:{}})}}let f=null,m=p.sort((g,h)=>g.offset-h.offset).map(({offset:g,matrix:h,rotation:y})=>{let b=aa(h),v=y??b.rotation;if(y===void 0&&f!==null){for(;v-f>180;)v-=360;for(;v-f<-180;)v+=360}f=v;let I=ht(...h.map(fr));return Object.freeze({offset:fr(g),matrix:I,translateX:fr(I[4]),translateY:fr(I[5]),rotation:fr(v),scaleX:fr(b.scaleX),scaleY:fr(b.scaleY),skewX:fr(b.skewX),skewY:0})});return Object.freeze({status:"projected",stops:Object.freeze(m),sampled:u,pureRotation:l,channels:Pk(o,u,m)})}function Sa(t,e,n=-90){let r=[],i=n*Math.PI/180;for(let o=0;o<t;o++){let s=i+o*2*Math.PI/t;r.push({x:e*Math.cos(s),y:e*Math.sin(s)})}return r}function Sd(t,e,n,r=-90){let i=[],o=e*(n/100),s=r*Math.PI/180;for(let a=0;a<t*2;a++){let c=s+a*Math.PI/t,l=a%2===0?e:o;i.push({x:l*Math.cos(c),y:l*Math.sin(c)})}return i}function bd(t,e,n=0){let r=t*(e/100)/2,i=[{x:-r,y:-t},{x:r,y:-t},{x:r,y:-r},{x:t,y:-r},{x:t,y:r},{x:r,y:r},{x:r,y:t},{x:-r,y:t},{x:-r,y:r},{x:-t,y:r},{x:-t,y:-r},{x:-r,y:-r}];if(n===0)return i;let o=Math.cos(n*Math.PI/180),s=Math.sin(n*Math.PI/180);return i.map(a=>({x:a.x*o-a.y*s,y:a.x*s+a.y*o}))}function vd(t,e,n,r,i=-90){let s=t*2*(n/100),a=t*(e/100),c=a*(r/100),l=[{x:t,y:0},{x:t-s,y:-a/2},{x:t-s,y:-c/2},{x:-t,y:-c/2},{x:-t,y:c/2},{x:t-s,y:c/2},{x:t-s,y:a/2}];if(i===0)return l;let d=Math.cos(i*Math.PI/180),u=Math.sin(i*Math.PI/180);return l.map(p=>({x:p.x*d-p.y*u,y:p.x*u+p.y*d}))}function xd(t,e,n,r,i=0){let o=t,s=o*(n/100),a=o*(r/100),c=a/2,l=e*Math.PI/180,d=Math.cos(l),u=Math.sin(l),p=Math.abs(d),f=Math.abs(u),m=Math.max(p,f)||1,g={x:d*(o/m),y:u*(o/m)},h={x:g.x+d*s,y:g.y+u*s},y=Math.min(a,o-c),b=-o+c+y,v=o-c-y,I={x:-o,y:-o},x={x:o,y:-o},k={x:o,y:o},T={x:-o,y:o},w;if(p>=f&&d>0){let R=Math.max(b,Math.min(v,g.y)),$={x:o,y:R-c},A={x:o,y:R+c};w=[I,x,$,h,A,k,T]}else if(p>=f&&d<=0){let R=Math.max(b,Math.min(v,g.y)),$={x:-o,y:R+c},A={x:-o,y:R-c};w=[I,x,k,T,$,h,A]}else if(u<0){let R=Math.max(b,Math.min(v,g.x)),$={x:R-c,y:-o},A={x:R+c,y:-o};w=[I,$,h,A,x,k,T]}else{let R=Math.max(b,Math.min(v,g.x)),$={x:R+c,y:o},A={x:R-c,y:o};w=[I,x,k,$,h,A,T]}if(i===0)return w;let P=Math.cos(i*Math.PI/180),N=Math.sin(i*Math.PI/180);return w.map(R=>({x:R.x*P-R.y*N,y:R.x*N+R.y*P}))}function Id(t,e,n,r,i=0){let o=Math.max(2,Math.round(e)),s=t*(n/100),a=t*(r/100)/2,c=o+1,l=[];for(let g=0;g<c;g++){let h=g/(c-1),y=-t+h*2*t,b=0;g>0&&g<c-1&&(b=g%2===1?s:-s),l.push({x:b,y})}let d=[],u=[];for(let g=0;g<c;g++){if(g===0||g===c-1){d.push({...l[g]}),u.push({...l[g]});continue}let h=l[g-1],y=l[g],b=l[g+1],v=y.x-h.x,I=y.y-h.y,x=Math.hypot(v,I)||1,k=v/x,T=I/x,w=b.x-y.x,P=b.y-y.y,N=Math.hypot(w,P)||1,R=w/N,$=P/N,A=(k+R)/2,O=(T+$)/2,G=Math.hypot(A,O),M,V;G<1e-6?(M=-T,V=k):(M=-O/G,V=A/G),d.push({x:y.x-M*a,y:y.y-V*a}),u.push({x:y.x+M*a,y:y.y+V*a})}let p=[];p.push(d[0]);for(let g=1;g<c-1;g++)p.push(u[g]);p.push(d[c-1]);for(let g=c-2;g>=1;g--)p.push(d[g]);if(i===0)return p;let f=Math.cos(i*Math.PI/180),m=Math.sin(i*Math.PI/180);return p.map(g=>({x:g.x*f-g.y*m,y:g.x*m+g.y*f}))}function wd(t,e,n,r=0){let i=t,o=Math.max(.3,Math.min(.9,e/100)),s=-i*(n/100),a={x:0,y:i},c={x:0,y:s},l={x:-i*o,y:i*.4},d={x:-i*o,y:-i},u={x:i*o,y:-i},p={x:i*o,y:i*.4},f=[a,l,d,c,u,p,a],m=r===0?f:(()=>{let x=Math.cos(r*Math.PI/180),k=Math.sin(r*Math.PI/180);return f.map(T=>({x:T.x*x-T.y*k,y:T.x*k+T.y*x}))})(),[g,h,y,b,v,I]=m;return`M ${g.x} ${g.y} C ${h.x} ${h.y} ${y.x} ${y.y} ${b.x} ${b.y} C ${v.x} ${v.y} ${I.x} ${I.y} ${g.x} ${g.y} Z`}function kd(t,e,n,r=0){let i=Math.max(3,Math.round(e)),o=Math.max(.3,Math.min(1,n/100)),s=t,a=s*1.7,c=s*1.15,l=[];for(let T=0;T<i;T++){let P=(90+T/i*360)*Math.PI/180;l.push({x:a/2*Math.cos(P),y:-(c/2)*Math.sin(P)})}let d=.15,u=0;for(let T=0;T<i;T++){let w=l[T],P=l[(T+1)%i];u=Math.max(u,Math.hypot(P.x-w.x,P.y-w.y))}let p=u/(2*(1-d))+.001,f=Math.max(p,u*(.68+o*.35)),m=l.map(T=>{let w=T.y/(c/2);return f*(1-d*w)});function g(T){let w=l[T],P=l[(T+1)%i],N=m[T],R=m[(T+1)%i],$=P.x-w.x,A=P.y-w.y,O=Math.hypot($,A)||1,G=(N*N-R*R+O*O)/(2*O),M=Math.sqrt(Math.max(0,N*N-G*G)),V=w.x+G/O*$,K=w.y+G/O*A,X=-A/O,U=$/O,te={x:V+X*M,y:K+U*M},Z={x:V-X*M,y:K-U*M};return te.x*te.x+te.y*te.y>Z.x*Z.x+Z.y*Z.y?te:Z}let h=[];for(let T=0;T<i;T++)h.push(g(T));let y=14,b=[];for(let T=0;T<i;T++){let w=l[T],P=m[T],N=h[(T-1+i)%i],R=h[T],$=Math.atan2(N.y-w.y,N.x-w.x),O=Math.atan2(R.y-w.y,R.x-w.x)-$;O<=0&&(O+=2*Math.PI);let G=2*Math.PI-O,M=$+O/2,V=$-G/2,K={x:w.x+P*Math.cos(M),y:w.y+P*Math.sin(M)},X={x:w.x+P*Math.cos(V),y:w.y+P*Math.sin(V)},te=K.x*K.x+K.y*K.y>X.x*X.x+X.y*X.y?O:-G;for(let Z=0;Z<y;Z++){let ne=Z/y,F=$+ne*te;b.push({x:w.x+P*Math.cos(F),y:w.y+P*Math.sin(F)})}}let v=0;for(let T of b){let w=Math.max(Math.abs(T.x),Math.abs(T.y));w>v&&(v=w)}if(v>0&&v!==s){let T=s/v;for(let w of b)w.x*=T,w.y*=T}let I=T=>{if(r===0)return T;let w=Math.cos(r*Math.PI/180),P=Math.sin(r*Math.PI/180);return{x:T.x*w-T.y*P,y:T.x*P+T.y*w}},x=b.map(I),k=`M ${x[0].x} ${x[0].y}`;for(let T=1;T<x.length;T++)k+=` L ${x[T].x} ${x[T].y}`;return k+=" Z",k}function $n(t,e=0,n=0){if(t.length<3)return"";if(e<=0)return t.map((o,s)=>(s===0?"M":"L")+`${o.x},${o.y}`).join(" ")+" Z";let r=Math.min(e,n*.4),i="";for(let o=0;o<t.length;o++){let s=t[(o-1+t.length)%t.length],a=t[o],c=t[(o+1)%t.length],l={x:s.x-a.x,y:s.y-a.y},d=Math.hypot(l.x,l.y);l.x/=d,l.y/=d;let u={x:c.x-a.x,y:c.y-a.y},p=Math.hypot(u.x,u.y);u.x/=p,u.y/=p;let f=Math.min(r,d/2),m=Math.min(r,p/2),g={x:a.x+l.x*f,y:a.y+l.y*f},h={x:a.x+u.x*m,y:a.y+u.y*m};i+=o===0?`M${g.x},${g.y}`:` L${g.x},${g.y}`,i+=` Q${a.x},${a.y} ${h.x},${h.y}`}return i+" Z"}function Pd(t,e,n="evenodd"){let r=t*(e/100),i=n==="nonzero"?1:0;return`M ${t} 0 A ${t} ${t} 0 1 1 ${-t} 0 A ${t} ${t} 0 1 1 ${t} 0 Z M ${r} 0 A ${r} ${r} 0 1 ${i} ${-r} 0 A ${r} ${r} 0 1 ${i} ${r} 0 Z`}function Td(t,e,n,r=1,i=0){let o=t*(n/100),a=Math.round(e*36),c=e*2*Math.PI,l=(t-o/2)/c,d=i*Math.PI/180,u=[],p=[];for(let g=0;g<=a;g++){let h=g/a,y=h*c*r+d,b=l*(h*c)+o/2,v=o/2;u.push({x:(b+v*.3)*Math.cos(y),y:(b+v*.3)*Math.sin(y)}),p.push({x:Math.max(0,b-v*.3)*Math.cos(y),y:Math.max(0,b-v*.3)*Math.sin(y)})}let f=`M ${u[0].x} ${u[0].y}`;for(let g=1;g<u.length;g++)f+=` L ${u[g].x} ${u[g].y}`;let m=p[p.length-1];f+=` L ${m.x} ${m.y}`;for(let g=p.length-2;g>=0;g--)f+=` L ${p[g].x} ${p[g].y}`;return f+=" Z",f}var Tk=.2;function _h(t,e,n,r=0){let i=e*(n/100),o=e,s=e-i,a=2*Math.PI/t,c=a*Tk/2,l=a/4,d=r*Math.PI/180,u=[];for(let p=0;p<t;p++){let f=d+p*a;u.push({x:s*Math.cos(f),y:s*Math.sin(f)}),u.push({x:o*Math.cos(f+l-c),y:o*Math.sin(f+l-c)}),u.push({x:o*Math.cos(f+l+c),y:o*Math.sin(f+l+c)}),u.push({x:s*Math.cos(f+a/2),y:s*Math.sin(f+a/2)})}return u}function Rd(t,e,n,r=0,i=0,o="evenodd",s=0){let a=_h(t,e,n,s),c=Math.min(r,e*.1),l=$n(a,c,e);if(i>0){let d=e*(i/100),u=o==="nonzero"?1:0;l+=` M ${d} 0 A ${d} ${d} 0 1 ${u} ${-d} 0 A ${d} ${d} 0 1 ${u} ${d} 0 Z`}return l}function Cd(t,e,n,r,i,o="round",s="uniform",a){let c=Math.min(n,r)/2,l,d,u,p,f,m,g,h;if(s==="non-uniform"&&a?(l=Math.min(a.radiusTL??i,c),d=Math.min(a.radiusTR??i,c),u=Math.min(a.radiusBR??i,c),p=Math.min(a.radiusBL??i,c),f=a.shapeTL??o,m=a.shapeTR??o,g=a.shapeBR??o,h=a.shapeBL??o):(l=d=u=p=Math.min(i,c),f=m=g=h=o),!(o!=="round"||s==="non-uniform"||l>0&&f!=="round"||d>0&&m!=="round"||u>0&&g!=="round"||p>0&&h!=="round")&&l===d&&d===u&&u===p)return null;let b=`M${t+l},${e}`;return b+=` L${t+n-d},${e}`,b+=ya(m,d,t+n,e,"tr"),b+=` L${t+n},${e+r-u}`,b+=ya(g,u,t+n,e+r,"br"),b+=` L${t+p},${e+r}`,b+=ya(h,p,t,e+r,"bl"),b+=` L${t},${e+l}`,b+=ya(f,l,t,e,"tl"),b+=" Z",b}function ya(t,e,n,r,i){if(e<=0)return"";switch(t){case"round":switch(i){case"tr":return` A${e},${e} 0 0 1 ${n},${r+e}`;case"br":return` A${e},${e} 0 0 1 ${n-e},${r}`;case"bl":return` A${e},${e} 0 0 1 ${n},${r-e}`;case"tl":return` A${e},${e} 0 0 1 ${n+e},${r}`}break;case"scoop":switch(i){case"tr":return` A${e},${e} 0 0 0 ${n},${r+e}`;case"br":return` A${e},${e} 0 0 0 ${n-e},${r}`;case"bl":return` A${e},${e} 0 0 0 ${n},${r-e}`;case"tl":return` A${e},${e} 0 0 0 ${n+e},${r}`}break;case"bevel":switch(i){case"tr":return` L${n},${r+e}`;case"br":return` L${n-e},${r}`;case"bl":return` L${n},${r-e}`;case"tl":return` L${n+e},${r}`}break;case"notch":switch(i){case"tr":return` L${n-e},${r+e} L${n},${r+e}`;case"br":return` L${n-e},${r-e} L${n-e},${r}`;case"bl":return` L${n+e},${r-e} L${n},${r-e}`;case"tl":return` L${n+e},${r+e} L${n+e},${r}`}break}return""}function $d(t,e,n,r,i,o={}){let s=e+r/2,a=n+i/2;switch(t){case"diamond":return`M${s},${n} L${e+r},${a} L${s},${n+i} L${e},${a} Z`;case"parallelogram":{let c=(o.slantPercent??20)/100*r;return`M${e+c},${n} L${e+r},${n} L${e+r-c},${n+i} L${e},${n+i} Z`}case"trapezoid":{let c=(o.topWidthPercent??70)/100*r,l=(r-c)/2;return`M${e+l},${n} L${e+l+c},${n} L${e+r},${n+i} L${e},${n+i} Z`}case"terminator":{let c=i/2;return`M${e+c},${n} L${e+r-c},${n} A${c},${c} 0 0 1 ${e+r-c},${n+i} L${e+c},${n+i} A${c},${c} 0 0 1 ${e+c},${n} Z`}case"cylinder":{let c=r/2,l=Math.min((o.capHeightPercent??15)/100*i,i/2);return`M${e},${n+l} A${c},${l} 0 0 1 ${e+r},${n+l} A${c},${l} 0 0 1 ${e},${n+l} L${e},${n+i-l} A${c},${l} 0 0 0 ${e+r},${n+i-l} L${e+r},${n+l} M${s-c},${n+l} A${c},${l} 0 0 0 ${s+c},${n+l}`}case"document-shape":{let c=(o.waveAmplitudePercent??15)/100*i;return`M${e},${n} L${e+r},${n} L${e+r},${n+i} C${e+r*.75},${n+i-c*2} ${s+r*.25},${n+i+c} ${s},${n+i} C${s-r*.25},${n+i-c} ${e+r*.25},${n+i+c*.5} ${e},${n+i} Z`}}}function Ur(t,e,n=!1,r=.5,i){if(t.length<2)return t.length===1?`M ${t[0].x} ${t[0].y}`:"";switch(e){case"CATMULL_ROM":case"catmull-rom":return Nk(t,n,r);case"BASIS":case"basis":return Ak(t,n);case"ARC":case"arc":return i&&i.length>0?Rk(t,n,i):$o(t,n,"CUBIC");case"LINEAR":case"linear":return $o(t,n,"LINEAR");case"QUADRATIC":case"quadratic":return $o(t,n,"QUADRATIC");case"CUBIC":case"cubic":return $o(t,n,"CUBIC");default:return $o(t,n)}}function Rk(t,e,n){let r=`M ${t[0].x} ${t[0].y}`,i=0,o={rx:50,ry:50,rotation:0,largeArc:!1,sweep:!0};for(let s=0;s<t.length-1;s++){let a=t[s+1];if(a.isSubpathStart){if(e&&s-i>=1){let l=t[i],d=n?.[s]??o;r+=` A ${d.rx} ${d.ry} ${d.rotation} ${d.largeArc?1:0} ${d.sweep?1:0} ${l.x} ${l.y} Z`}r+=` M ${a.x} ${a.y}`,i=s+1;continue}let c=n?.[s]??o;r+=` A ${c.rx} ${c.ry} ${c.rotation} ${c.largeArc?1:0} ${c.sweep?1:0} ${a.x} ${a.y}`}if(e&&t.length-i>1){let s=t[i],a=n?.[t.length-1]??o;r+=` A ${a.rx} ${a.ry} ${a.rotation} ${a.largeArc?1:0} ${a.sweep?1:0} ${s.x} ${s.y} Z`}return r}function $o(t,e,n){let r=`M ${t[0].x} ${t[0].y}`,i=0,o=null,s=null;for(let a=0;a<t.length-1;a++){let c=t[a],l=t[a+1];if(l.isSubpathStart){if(e&&a-i>=1){let u=t[i];r+=hd(c,u,u.segmentType,o,s,n),r+=" Z"}r+=` M ${l.x} ${l.y}`,i=a+1,o=null,s=null;continue}r+=hd(c,l,l.segmentType,o,s,n);let d=$k(l.segmentType??n,c,l);o=d,d==="quad"?s=c.handleOut??null:s=null}if(e&&t.length-i>1){let a=t[t.length-1],c=t[i],l=(c.segmentType??n??(a.handleOut||c.handleIn?"CUBIC":"LINEAR")).toUpperCase();l==="LINEAR"||l==="HORIZONTAL"||l==="VERTICAL"||(r+=hd(a,c,c.segmentType,o,s,n)),r+=" Z"}return r}var Ck=.001;function $i(t,e){return Math.abs(t-e)<Ck}function $k(t,e,n){let r=(t??(e.handleOut||n.handleIn?"CUBIC":"LINEAR")).toUpperCase();return r==="CUBIC"||r==="SMOOTH_CUBIC"?"cubic":r==="QUADRATIC"||r==="SMOOTH_QUADRATIC"?"quad":null}function hd(t,e,n,r,i,o){let s=(n??o??(t.handleOut||e.handleIn?"CUBIC":"LINEAR")).toUpperCase();if(s==="LINEAR"||s==="HORIZONTAL"||s==="VERTICAL")return(s==="HORIZONTAL"||s==="LINEAR")&&$i(t.y,e.y)?` H ${e.x}`:(s==="VERTICAL"||s==="LINEAR")&&$i(t.x,e.x)?` V ${e.y}`:` L ${e.x} ${e.y}`;if(s==="ARC"){let l=e.arcParams;return l?` A ${l.rx} ${l.ry} ${l.rotation} ${l.largeArc?1:0} ${l.sweep?1:0} ${e.x} ${e.y}`:` L ${e.x} ${e.y}`}if(s==="QUADRATIC"||s==="SMOOTH_QUADRATIC"){let l=t.handleOut??{x:(t.x+e.x)/2,y:(t.y+e.y)/2};return r==="quad"&&i&&$i(l.x,2*t.x-i.x)&&$i(l.y,2*t.y-i.y)?` T ${e.x} ${e.y}`:` Q ${l.x} ${l.y} ${e.x} ${e.y}`}let a=t.handleOut??{x:t.x,y:t.y},c=e.handleIn??{x:e.x,y:e.y};return r==="cubic"&&t.handleIn&&t.handleOut&&$i(t.handleOut.x,2*t.x-t.handleIn.x)&&$i(t.handleOut.y,2*t.y-t.handleIn.y)?` S ${c.x} ${c.y} ${e.x} ${e.y}`:` C ${a.x} ${a.y} ${c.x} ${c.y} ${e.x} ${e.y}`}function Nk(t,e,n){if(t.length<2)return t.length===1?`M ${t[0].x} ${t[0].y}`:"";let r=n,i=e?[t[t.length-1],...t,t[0],t[1]]:[t[0],...t,t[t.length-1]],o=`M ${t[0].x} ${t[0].y}`,s=e?t.length:t.length-1;for(let a=0;a<s;a++){let c=i[a],l=i[a+1],d=i[a+2],u=i[a+3],p=Math.hypot(d.x-l.x,d.y-l.y),f=Math.hypot(l.x-c.x,l.y-c.y),m=Math.hypot(u.x-d.x,u.y-d.y),g=Math.pow(f,r),h=Math.pow(p,r),y=Math.pow(m,r),b=Math.pow(f,2*r),v=Math.pow(p,2*r),I=Math.pow(m,2*r),x,k,T,w;f<1e-8?(x=l.x,k=l.y):(x=(b*d.x-v*c.x+(2*b+3*g*h+v)*l.x)/(3*g*(g+h)),k=(b*d.y-v*c.y+(2*b+3*g*h+v)*l.y)/(3*g*(g+h))),m<1e-8?(T=d.x,w=d.y):(T=(I*l.x-v*u.x+(2*I+3*y*h+v)*d.x)/(3*y*(y+h)),w=(I*l.y-v*u.y+(2*I+3*y*h+v)*d.y)/(3*y*(y+h))),o+=` C ${x} ${k} ${T} ${w} ${d.x} ${d.y}`}return e&&(o+=" Z"),o}function Ak(t,e){let n=t.length;if(n<2)return n===1?`M ${t[0].x} ${t[0].y}`:"";if(n===2)return`M ${t[0].x} ${t[0].y} L ${t[1].x} ${t[1].y}`;if(e){let o=(t[0].x+4*t[1].x+t[2].x)/6,s=(t[0].y+4*t[1].y+t[2].y)/6,a=`M ${o} ${s}`;for(let c=0;c<n;c++){let l=t[(c+1)%n],d=t[(c+2)%n],u=t[(c+3)%n];a+=yd(l,d,u)}return a+=" Z",a}let r=t,i=`M ${r[0].x} ${r[0].y}`;i+=` L ${(5*r[0].x+r[1].x)/6} ${(5*r[0].y+r[1].y)/6}`;for(let o=0;o<=n-3;o++)i+=yd(r[o],r[o+1],r[o+2]);return i+=yd(r[n-2],r[n-1],r[n-1]),i+=` L ${r[n-1].x} ${r[n-1].y}`,i}function yd(t,e,n){return` C ${(2*t.x+e.x)/3} ${(2*t.y+e.y)/3} ${(t.x+2*e.x)/3} ${(t.y+2*e.y)/3} ${(t.x+4*e.x+n.x)/6} ${(t.y+4*e.y+n.y)/6}`}function Nd(t,e,n){let r=Number.isFinite(e)?Math.max(1,e):8,i=Number.isFinite(n)?Math.max(1,n):4;switch(t){case"dashed":case"dotted":case"custom":return`${r} ${i}`;default:return null}}var Ek={bearing:!0,catmullRom:!0},Fh={M:["number","number"],m:["number","number"],L:["number","number"],l:["number","number"],H:["number"],h:["number"],V:["number"],v:["number"],C:["number","number","number","number","number","number"],c:["number","number","number","number","number","number"],S:["number","number","number","number"],s:["number","number","number","number"],Q:["number","number","number","number"],q:["number","number","number","number"],T:["number","number"],t:["number","number"],A:["number","number","number","flag","flag","number","number"],a:["number","number","number","flag","flag","number","number"],Z:[],z:[]},Mk=new Set(Object.keys(Fh));function Ok(t){return t===32||t===9||t===10||t===12||t===13}function va(t){return t>=48&&t<=57}function Lh(t){return t>=65&&t<=90||t>=97&&t<=122}var Ed=class{constructor(e){this.source=e}source;position=0;get length(){return this.source.length}skipWhitespace(){for(;this.position<this.length&&Ok(this.source.charCodeAt(this.position));)this.position++}skipOptionalCommaWhitespace(){this.skipWhitespace(),this.source.charCodeAt(this.position)===44&&(this.position++,this.skipWhitespace())}readNumber(){let e=this.position,n=e,r=this.source.charCodeAt(n);(r===43||r===45)&&n++;let i=0;for(;n<this.length&&va(this.source.charCodeAt(n));)n++,i++;if(this.source.charCodeAt(n)===46){let a=n;n++;let c=0;for(;n<this.length&&va(this.source.charCodeAt(n));)n++,c++;if(c===0){if(i===0)return null;n=a}}else if(i===0)return null;let o=this.source.charCodeAt(n);if(o===101||o===69){let a=n;n++;let c=this.source.charCodeAt(n);(c===43||c===45)&&n++;let l=0;for(;n<this.length&&va(this.source.charCodeAt(n));)n++,l++;l===0&&(n=a)}let s=Number(this.source.slice(e,n));return Number.isFinite(s)?(this.position=n,s):null}readFlag(){let e=this.source[this.position];return e!=="0"&&e!=="1"?null:(this.position++,e==="1"?1:0)}};function Bh(t,e){return Mk.has(t)||(t==="B"||t==="b")&&e.bearing?!0:(t==="R"||t==="r")&&e.catmullRom===!0}function Dk(t){if(!t)return!1;let e=t.charCodeAt(0);return va(e)||t==="+"||t==="-"||t==="."||t===","}function zk(t,e,n,r){return{code:t,offset:e.position,command:n,message:r}}function Ad(t,e,n){let r=[];for(let i=0;i<e.length;i++){i>0||n?t.skipOptionalCommaWhitespace():t.skipWhitespace();let o=e[i]==="flag"?t.readFlag():t.readNumber();if(o===null)return null;r.push(o)}return r}function ba(t,e){if(t.skipWhitespace(),t.position>=t.length)return"end";let n=t.source[t.position];return Bh(n,e)?"command":Dk(n)?"parameter":Lh(n.charCodeAt(0))?"unsupported-command":"unexpected"}function Nn(t,e={}){let n=new Ed(t),r=e.extensions??{},i=[],o=!0,s=(a,c,l)=>({commands:i,error:zk(a,n,c,l)});for(;;){if(n.skipWhitespace(),n.position>=n.length)return{commands:i,error:null};let a=n.position,c=n.source[n.position];if(!Bh(c,r)){let f=Lh(c.charCodeAt(0))?"unsupported-command":"unexpected-content";return s(f,null,`Unexpected path content '${c}'`)}n.position++;let l=c;if(o&&l!=="M"&&l!=="m")return s("initial-moveto-required",l,"Path data must begin with moveto");if(o=!1,l==="Z"||l==="z"){i.push({type:l,params:[],offset:a});let f=ba(n,r);if(f==="end"||f==="command")continue;return s(f==="unsupported-command"?"unsupported-command":"unexpected-content",l,"Closepath cannot be implicitly repeated")}if(l==="B"||l==="b"){let f=[];for(;;){let m=Ad(n,["number"],f.length>0);if(!m){if(f.length===0)return s("missing-parameter",l,"Bearing requires at least one angle");break}f.push(m[0]);let g=ba(n,r);if(g!=="parameter"){if(g==="end"||g==="command")break;return i.push({type:l,params:f,offset:a}),s(g==="unsupported-command"?"unsupported-command":"unexpected-content",l,"Invalid bearing command content")}}i.push({type:l,params:f,offset:a});continue}if(l==="R"||l==="r"){let f=[];for(;;){let m=Ad(n,["number","number"],f.length>0);if(!m)return s("missing-parameter",l,"Catmull-Rom requires complete coordinate pairs");f.push(...m);let g=ba(n,r);if(g!=="parameter"){if(g==="end"||g==="command")break;return s(g==="unsupported-command"?"unsupported-command":"unexpected-content",l,"Invalid Catmull-Rom command content")}}if(f.length<6)return s("missing-parameter",l,`R/r: needs at least 3 coordinate pairs, got ${f.length/2}`);i.push({type:l,params:f,offset:a});continue}let u=Fh[l],p=0;for(;;){let f=Ad(n,u,p>0);if(!f)return s("missing-parameter",l,`Incomplete ${l} command parameters`);let m=p>0&&(l==="M"||l==="m")?l==="M"?"L":"l":l;i.push({type:m,params:f,offset:a}),p++;let g=ba(n,r);if(g==="end"||g==="command")break;if(g!=="parameter")return s(g==="unsupported-command"?"unsupported-command":"unexpected-content",l,`Unexpected content in ${l} command`)}}}function Md(t){return t.map(e=>e.params.length===0?e.type:`${e.type} ${e.params.join(" ")}`).join(" ")}function _k(t,e,n){let r=[...t.params];if(t.type!==t.type.toUpperCase())return r;switch(t.type){case"M":case"L":case"T":case"C":case"S":case"Q":case"R":for(let i=0;i<r.length;i+=2)r[i]+=e,r[i+1]+=n;break;case"H":r[0]+=e;break;case"V":r[0]+=n;break;case"A":r[5]+=e,r[6]+=n;break}return r}function Fk(t,e,n){let r=Nn(t);return r.error?null:Md(r.commands.map((i,o)=>{let s=_k(i,e,n);return o===0&&i.type==="m"&&(s[0]+=e,s[1]+=n),{...i,params:s}}))}function Lk(t,e){let n=Nn(t);if(n.error)return null;let[r,i,o,s,a,c]=e,l=[],d=0,u=0,p=0,f=0,m=(h,y)=>[r*h+o*y+a,i*h+s*y+c],g=(h,y,b)=>{l.push({type:h,params:y,offset:b})};for(let h of n.commands){let y=h.type===h.type.toLowerCase(),b=h.type.toUpperCase(),v=h.params,I=d,x=u;if(b==="A")return null;if(b==="Z"){g("Z",[],h.offset),d=p,u=f;continue}if(b==="H"){d=y?d+v[0]:v[0],g("L",m(d,u),h.offset);continue}if(b==="V"){u=y?u+v[0]:v[0],g("L",m(d,u),h.offset);continue}let k=T=>[(y?I:0)+v[T],(y?x:0)+v[T+1]];switch(b){case"M":case"L":case"T":{let T=k(0);d=T[0],u=T[1],b==="M"&&(p=d,f=u),g(b,m(d,u),h.offset);break}case"C":{let T=m(...k(0)),w=m(...k(2)),P=k(4);d=P[0],u=P[1],g("C",[...T,...w,...m(...P)],h.offset);break}case"S":case"Q":{let T=m(...k(0)),w=k(2);d=w[0],u=w[1],g(b,[...T,...m(...w)],h.offset);break}}}return Md(l)}var Ni=Math.PI*2;function Bk(t,e,n,r){let i=e*e-4*t*n;if(!(i>=0))return;let o=Math.sqrt(i),s=-.5*(e+(e>=0?o:-o));if(t!==0){let a=s/t;a>0&&a<1&&r.push(a)}if(s!==0){let a=n/s;a>0&&a<1&&r.push(a)}}function Gk(t,e,n,r,i){let o=1-i;return o*o*o*t+3*o*o*i*e+3*o*i*i*n+i*i*i*r}function Vk(t,e,n,r){let i=1-r;return i*i*t+2*i*r*e+r*r*n}function Od(t,e,n,r){let i=t<r?t:r,o=t>r?t:r,s=-t+3*e-3*n+r,a=2*(t-2*e+n),c=e-t,l=[];Bk(s,a,c,l);for(let d of l){let u=Gk(t,e,n,r,d);u<i&&(i=u),u>o&&(o=u)}return{min:i,max:o}}function Dd(t,e,n){let r=t<n?t:n,i=t>n?t:n,o=t-2*e+n;if(o!==0){let s=(t-e)/o;if(s>0&&s<1){let a=Vk(t,e,n,s);a<r&&(r=a),a>i&&(i=a)}}return{min:r,max:i}}function Gh(t,e,n,r){let i=t*r-e*n>=0?1:-1,o=Math.sqrt((t*t+e*e)*(n*n+r*r));if(o===0)return 0;let s=(t*n+e*r)/o;return s<-1?s=-1:s>1&&(s=1),i*Math.acos(s)}function Ia(t,e,n,r,i,o,s,a,c){if(t===a&&e===c||n===0||r===0)return null;let l=Math.abs(n),d=Math.abs(r),u=i%360*Math.PI/180,p=Math.cos(u),f=Math.sin(u),m=(t-a)/2,g=(e-c)/2,h=p*m+f*g,y=-f*m+p*g,b=h*h,v=y*y,I=l*l,x=d*d,k=b/I+v/x;if(k>1){let U=Math.sqrt(k);l*=U,d*=U,I=l*l,x=d*d}let T=I*v+x*b;if(T===0)return null;let w=(I*x-T)/T;w<0&&(w=0);let P=Math.sqrt(w);o===s&&(P=-P);let N=P*(l*y/d),R=P*(-(d*h)/l),$=p*N-f*R+(t+a)/2,A=f*N+p*R+(e+c)/2,O=(h-N)/l,G=(y-R)/d,M=(-h-N)/l,V=(-y-R)/d,K=Gh(1,0,O,G),X=Gh(O,G,M,V);return!s&&X>0?X-=Ni:s&&X<0&&(X+=Ni),{cx:$,cy:A,rx:l,ry:d,phi:u,theta1:K,deltaTheta:X}}function jk(t,e){let n=Math.cos(t.phi),r=Math.sin(t.phi),i=e?Ye(e,{x:t.cx,y:t.cy}):{x:t.cx,y:t.cy},o=e?fd(e,{x:t.rx*n,y:t.rx*r}):{x:t.rx*n,y:t.rx*r},s=e?fd(e,{x:-t.ry*r,y:t.ry*n}):{x:-t.ry*r,y:t.ry*n};return{cx:i.x,cy:i.y,ux:o.x,uy:o.y,vx:s.x,vy:s.y}}function Uk(t,e){let n=Math.cos(e),r=Math.sin(e);return{x:t.cx+t.ux*n+t.vx*r,y:t.cy+t.uy*n+t.vy*r}}function Hk(t,e,n){if(n>=0){let i=(t-e)%Ni;return i<0&&(i+=Ni),i<=n}let r=(e-t)%Ni;return r<0&&(r+=Ni),r<=-n}function Uh(t,e,n,r,i,o,s,a,c,l){let d=l?Ye(l,{x:t,y:e}):{x:t,y:e},u=l?Ye(l,{x:a,y:c}):{x:a,y:c},p={minX:Math.min(d.x,u.x),minY:Math.min(d.y,u.y),maxX:Math.max(d.x,u.x),maxY:Math.max(d.y,u.y)},f=Ia(t,e,n,r,i,o,s,a,c);if(!f)return p;let m=jk(f,l),g=Math.atan2(m.vx,m.ux),h=Math.atan2(m.vy,m.uy),y=[g,g+Math.PI,h,h+Math.PI];for(let b of y){if(!Hk(b,f.theta1,f.deltaTheta))continue;let v=Uk(m,b);v.x<p.minX&&(p.minX=v.x),v.x>p.maxX&&(p.maxX=v.x),v.y<p.minY&&(p.minY=v.y),v.y>p.maxY&&(p.maxY=v.y)}return p}var zd=class{constructor(e){this.params=e}params;index=0;readNumber(){return this.params[this.index++]??null}readFlag(){let e=this.readNumber();return e===null?null:e===1}};function xa(t,e,n,r){let i=r?Ye(r,{x:e,y:n}):{x:e,y:n};i.x<t.minX&&(t.minX=i.x),i.x>t.maxX&&(t.maxX=i.x),i.y<t.minY&&(t.minY=i.y),i.y>t.maxY&&(t.maxY=i.y),t.any=!0}function _d(t,e){e.minX<t.minX&&(t.minX=e.minX),e.maxX>t.maxX&&(t.maxX=e.maxX),e.minY<t.minY&&(t.minY=e.minY),e.maxY>t.maxY&&(t.maxY=e.maxY),t.any=!0}function Vh(t,e,n,r,i,o,s,a,c,l){let d=l?Ye(l,{x:e,y:n}):{x:e,y:n},u=l?Ye(l,{x:r,y:i}):{x:r,y:i},p=l?Ye(l,{x:o,y:s}):{x:o,y:s},f=l?Ye(l,{x:a,y:c}):{x:a,y:c},m=Od(d.x,u.x,p.x,f.x),g=Od(d.y,u.y,p.y,f.y);_d(t,{minX:m.min,maxX:m.max,minY:g.min,maxY:g.max})}function jh(t,e,n,r,i,o,s,a){let c=a?Ye(a,{x:e,y:n}):{x:e,y:n},l=a?Ye(a,{x:r,y:i}):{x:r,y:i},d=a?Ye(a,{x:o,y:s}):{x:o,y:s},u=Dd(c.x,l.x,d.x),p=Dd(c.y,l.y,d.y);_d(t,{minX:u.min,maxX:u.max,minY:p.min,maxY:p.max})}function Sn(t,e){if(!t)return null;let n=Nn(t),r={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,any:!1},i=0,o=0,s=0,a=0,c=0,l=0,d=null,u="",p=()=>r.any?{minX:r.minX,minY:r.minY,maxX:r.maxX,maxY:r.maxY}:null;for(let f of n.commands){u=f.type;let m=new zd(f.params),g=u>="a"&&u<="z";switch(u){case"M":case"m":{let h=m.readNumber(),y=m.readNumber();if(h===null||y===null)return p();i=g?i+h:h,o=g?o+y:y,s=i,a=o,xa(r,i,o,e),d=null,u=g?"l":"L";break}case"L":case"l":{let h=m.readNumber(),y=m.readNumber();if(h===null||y===null)return p();i=g?i+h:h,o=g?o+y:y,xa(r,i,o,e),d=null;break}case"H":case"h":{let h=m.readNumber();if(h===null)return p();i=g?i+h:h,xa(r,i,o,e),d=null;break}case"V":case"v":{let h=m.readNumber();if(h===null)return p();o=g?o+h:h,xa(r,i,o,e),d=null;break}case"C":case"c":{let h=m.readNumber(),y=m.readNumber(),b=m.readNumber(),v=m.readNumber(),I=m.readNumber(),x=m.readNumber();if(h===null||y===null||b===null||v===null||I===null||x===null)return p();let k=g?i+h:h,T=g?o+y:y,w=g?i+b:b,P=g?o+v:v,N=g?i+I:I,R=g?o+x:x;Vh(r,i,o,k,T,w,P,N,R,e),c=w,l=P,d="cubic",i=N,o=R;break}case"S":case"s":{let h=m.readNumber(),y=m.readNumber(),b=m.readNumber(),v=m.readNumber();if(h===null||y===null||b===null||v===null)return p();let I=d==="cubic"?2*i-c:i,x=d==="cubic"?2*o-l:o,k=g?i+h:h,T=g?o+y:y,w=g?i+b:b,P=g?o+v:v;Vh(r,i,o,I,x,k,T,w,P,e),c=k,l=T,d="cubic",i=w,o=P;break}case"Q":case"q":{let h=m.readNumber(),y=m.readNumber(),b=m.readNumber(),v=m.readNumber();if(h===null||y===null||b===null||v===null)return p();let I=g?i+h:h,x=g?o+y:y,k=g?i+b:b,T=g?o+v:v;jh(r,i,o,I,x,k,T,e),c=I,l=x,d="quad",i=k,o=T;break}case"T":case"t":{let h=m.readNumber(),y=m.readNumber();if(h===null||y===null)return p();let b=d==="quad"?2*i-c:i,v=d==="quad"?2*o-l:o,I=g?i+h:h,x=g?o+y:y;jh(r,i,o,b,v,I,x,e),c=b,l=v,d="quad",i=I,o=x;break}case"A":case"a":{let h=m.readNumber(),y=m.readNumber(),b=m.readNumber(),v=m.readFlag(),I=m.readFlag(),x=m.readNumber(),k=m.readNumber();if(h===null||y===null||b===null||v===null||I===null||x===null||k===null)return p();let T=g?i+x:x,w=g?o+k:k;_d(r,Uh(i,o,h,y,b,v,I,T,w,e)),i=T,o=w,d=null;break}case"Z":case"z":{i=s,o=a,d=null;break}default:return p()}}return p()}function Wk(t,e,n=!1,r=.5,i,o){return t.length===0?null:Sn(Ur(t,e,n,r,i),o)}function Hh(t){return t.replace(/[^a-zA-Z0-9_-]/g,"_")}function Kk(t){let e=t.state.symbolOverrides;return!!e&&Object.keys(e).length>0}function Fd(t){return t===null||typeof t!="object"?JSON.stringify(t)??"null":Array.isArray(t)?`[${t.map(Fd).join(",")}]`:`{${Object.entries(t).sort(([e],[n])=>e.localeCompare(n)).map(([e,n])=>`${JSON.stringify(e)}:${Fd(n)}`).join(",")}}`}function Xk(t){let e=new Map,n=r=>{for(let i of r)e.set(i.id,(e.get(i.id)??0)+1),Array.isArray(i.state.children)&&n(i.state.children)};return n(t),e}function Wh(t,e,n){return t.map(r=>{let i=n.has(r.id)?e[r.id]:void 0,o=i?{...r.state,...i}:{...r.state},s=o.children;return Array.isArray(s)&&(o.children=Wh(s,e,n)),i!==void 0||o.children!==r.state.children?{...r,state:o}:r})}function Ai(t,e){let n=String(e.state.variantKey??""),r=n?t.variants?.[n]:void 0,i=r?n:"",o=r??t.shapes,s=[];n&&!r&&s.push({code:"unknown-symbol-variant",shapeId:e.id,message:`Symbol instance ${e.id} requests unknown variant ${n} from ${t.id}; the base definition is used.`});let a=e.state.symbolOverrides??{},c=Object.entries(a),l=o;if(c.length>0){let f=Xk(o),m=new Set;for(let[g]of c){let h=f.get(g)??0;h===1?m.add(g):s.push({code:h>1?"ambiguous-symbol-override-target":"unresolved-symbol-override-target",shapeId:e.id,message:h>1?`Symbol instance ${e.id} override target ${g} is ambiguous in ${t.id}.`:`Symbol instance ${e.id} override target ${g} is absent from ${t.id}.`})}l=Wh(o,a,m)}let d=i!==""||c.length>0,u=c.length>0?`${t.id}--ovr-${e.id}`:i?`${t.id}--${Hh(i)}`:t.id,p=`${t.id}\0${i}\0${Fd(a)}`;return{shapes:l,requestedVariantKey:n,effectiveVariantKey:i,candidateTargetId:u,materializationKey:p,materialized:d,diagnostics:s}}function No(t,e=!1){let n=t.state.symbolId??"",r=t.state.variantKey??"";return e||Kk(t)?`${n}--ovr-${t.id}`:r?`${n}--${Hh(r)}`:n}function Yk(t,e){return[...Ai(t,e).shapes]}function Pe(t,e,n){return Object.freeze({type:t,renderer:e,resolve:n})}function qk(t){let e=t.state,n=e.x??0,r=e.y??0;return{kind:"circle",shapeType:"circle",cx:n,cy:r,r:e.radius??50,defaultPivot:{x:n,y:r}}}function Zk(t){let e=t.state,n=e.cx??e.x??0,r=e.cy??e.y??0;return{kind:"ellipse",shapeType:"ellipse",cx:n,cy:r,rx:e.rx??50,ry:e.ry??30,pathLength:e.pathLength,defaultPivot:{x:n,y:r}}}function Kh(t){let e=t.state,n=e,r=e.x??0,i=e.y??0,o=t.type==="square"?e.size:void 0,s=o??e.width??100,a=o??e.height??100,c=e.cornerRadius??0,l=e.rx,d=e.ry,u=l!==void 0&&l>=0?l:void 0,p=d!==void 0&&d>=0?d:void 0,f=Math.max(0,c),m=u??p??f,g=u??m,h=p??m,y=Math.min(Math.max(0,g),Math.max(0,s)/2),b=Math.min(Math.max(0,h),Math.max(0,a)/2),v=n.cornerShape??"round",I=n.cornerMode??"uniform",x=null;return(v!=="round"||I==="non-uniform")&&(x=Cd(r,i,s,a,c,v,I,I==="non-uniform"?{radiusTL:n.cornerRadiusTL,radiusTR:n.cornerRadiusTR,radiusBR:n.cornerRadiusBR,radiusBL:n.cornerRadiusBL,shapeTL:n.cornerShapeTL,shapeTR:n.cornerShapeTR,shapeBR:n.cornerShapeBR,shapeBL:n.cornerShapeBL}:void 0)||null),{kind:"rectangle",shapeType:t.type,x:r,y:i,width:s,height:a,rx:y,ry:b,pathData:x,defaultPivot:{x:r+s/2,y:i+a/2}}}function Jk(t){let e=t.state,n=e.x1??0,r=e.y1??0,i=e.x2??0,o=e.y2??0;return{kind:"line",shapeType:"line",x1:n,y1:r,x2:i,y2:o,boundsPolicy:e.sourceRef||e.targetRef||e.routingMode?"linked-line":"analytic",defaultPivot:{x:(n+i)/2,y:(r+o)/2}}}function Qk(t){let e=t.state.textX??t.state.x??0,n=t.state.textY??t.state.y??0;return{kind:"text",shapeType:"text",x:e,y:n,boundsPolicy:"measure-text",defaultPivot:{x:e,y:n}}}function e0(t){let e=t.state,n=e.pathPoints??[],r=Ur(n,e.pathCurveType??"CUBIC",e.pathClosed??!1,e.pathTension??.5,e.pathArcParams),i=n.length>0?e.customPivot??{x:n[0].x,y:n[0].y}:null;return{kind:"path",shapeType:"path",role:"spline",d:r,placement:null,fillRule:null,defaultPivot:i}}function t0(t){let e=t.state,n=e.polylinePoints??[];return{kind:"polyline",shapeType:"polyline",points:n,closed:e.polylineClosed??!1,defaultPivot:n.length>0?e.customPivot??{x:n[0].x,y:n[0].y}:null}}function wa(t,e,n,r){let i=t.state,o=i.x??0,s=i.y??0,a=i.width??n,c=i.height??r;return{kind:"positioning-rect",shapeType:t.type,role:e,x:o,y:s,width:a,height:c,defaultPivot:{x:o+a/2,y:s+c/2}}}function an(t,e,n=!1){let r=t.state,i=r.cx??0,o=r.cy??0,s={radius:r.radius??50,cornerRadius:r.cornerRadius??0,shiftAngle:r.shiftAngle??-90,fillRule:r.fillRule??"nonzero"};return{kind:"path",shapeType:t.type,role:"polygon",d:e(r,s),placement:{x:i,y:o},fillRule:n?s.fillRule:null,defaultPivot:{x:i,y:o}}}function Ei(t,e){let n=t.state,r=n.x??0,i=n.y??0,o=n.width??100,s=n.height??60;return{kind:"path",shapeType:e,role:"flowchart",d:$d(e,r,i,o,s,{slantPercent:n.slantPercent,topWidthPercent:n.topWidthPercent,capHeightPercent:n.capHeightPercent,waveAmplitudePercent:n.waveAmplitudePercent}),placement:null,fillRule:null,defaultPivot:{x:r+o/2,y:i+s/2}}}function ka(t,e){return{kind:"container",shapeType:t.type,role:e,boundsPolicy:"children",defaultPivot:null}}function n0(t){let e=t.state;return{kind:"embedded-svg",shapeType:"svg",x:e.svgX,y:e.svgY,width:e.svgWidth,height:e.svgHeight,viewBoxX:e.svgViewBoxX,viewBoxY:e.svgViewBoxY,viewBoxWidth:e.svgViewBoxWidth,viewBoxHeight:e.svgViewBoxHeight,preserveAspectRatio:e.svgPreserveAspectRatio,boundsPolicy:"children",defaultPivot:null}}function r0(t){let e=t.state;return{kind:"view",shapeType:"view",viewBoxX:e.viewBoxX,viewBoxY:e.viewBoxY,viewBoxWidth:e.viewBoxWidth,viewBoxHeight:e.viewBoxHeight,preserveAspectRatio:e.viewPreserveAspectRatio,boundsPolicy:"none",defaultPivot:null}}function i0(t){let e=t.state;return{kind:"shape-reference",shapeType:"shape-reference",targetShapeId:e.targetShapeId,offsetX:e.offsetX??0,offsetY:e.offsetY??0,width:e.width,height:e.height,boundsPolicy:"reference",defaultPivot:null}}function o0(t){let e=t.state;return{kind:"symbol-instance",shapeType:"symbol-instance",symbolId:e.symbolId??"",targetId:No(t),x:e.x??0,y:e.y??0,width:e.width??100,height:e.height??100,boundsPolicy:"symbol",defaultPivot:null}}var Yh=Object.freeze({rectangle:Pe("rectangle","rectangle",Kh),square:Pe("square","rectangle",Kh),circle:Pe("circle","circle",qk),ellipse:Pe("ellipse","ellipse",Zk),line:Pe("line","line",Jk),text:Pe("text","text",Qk),image:Pe("image","image",t=>wa(t,"image",100,100)),path:Pe("path","path",e0),polyline:Pe("polyline","polyline",t0),triangle:Pe("triangle","polygon",t=>an(t,(e,n)=>$n(Sa(3,n.radius,n.shiftAngle),n.cornerRadius,n.radius))),ngon:Pe("ngon","polygon",t=>an(t,(e,n)=>$n(Sa(e.sides??6,n.radius,n.shiftAngle),n.cornerRadius,n.radius))),star:Pe("star","polygon",t=>an(t,(e,n)=>$n(Sd(e.arms??5,n.radius,e.innerRadiusPercent??50,n.shiftAngle),n.cornerRadius,n.radius))),cross:Pe("cross","polygon",t=>an(t,(e,n)=>$n(bd(n.radius,e.armWidthPercent??40,n.shiftAngle),n.cornerRadius,n.radius))),ring:Pe("ring","polygon",t=>an(t,(e,n)=>Pd(n.radius,e.innerRadiusPercent??50,n.fillRule),!0)),spiral:Pe("spiral","polygon",t=>an(t,(e,n)=>Td(n.radius,e.turns??3,e.thicknessPercent??20,e.spiralDirection??1,n.shiftAngle))),gear:Pe("gear","polygon",t=>an(t,(e,n)=>Rd(e.teeth??8,n.radius,e.toothDepthPercent??30,n.cornerRadius,e.holeRadiusPercent??0,n.fillRule,n.shiftAngle),!0)),arrow:Pe("arrow","polygon",t=>an(t,(e,n)=>$n(vd(n.radius,e.headWidthPercent??100,e.headLengthPercent??30,e.shaftWidthPercent??40,n.shiftAngle),n.cornerRadius,n.radius))),"symbol-instance":Pe("symbol-instance","symbol-instance",o0),group:Pe("group","container",t=>ka(t,"group")),container:Pe("container","container",t=>ka(t,"group")),cloud:Pe("cloud","polygon",t=>an(t,(e,n)=>kd(n.radius,e.cloudBumps??5,e.cloudPuffinessPercent??60,n.shiftAngle))),heart:Pe("heart","polygon",t=>an(t,(e,n)=>wd(n.radius,e.lobeRadiusPercent??50,e.cleftDepthPercent??25,n.shiftAngle))),lightning:Pe("lightning","polygon",t=>an(t,(e,n)=>$n(Id(n.radius,e.boltSegments??3,e.boltJaggednessPercent??40,e.boltWidthPercent??30,n.shiftAngle),n.cornerRadius,n.radius))),speechBubble:Pe("speechBubble","polygon",t=>an(t,(e,n)=>$n(xd(n.radius,e.tailAngleDeg??45,e.tailLengthPercent??40,e.tailWidthPercent??25,n.shiftAngle),n.cornerRadius,n.radius))),diamond:Pe("diamond","flowchart",t=>Ei(t,"diamond")),parallelogram:Pe("parallelogram","flowchart",t=>Ei(t,"parallelogram")),trapezoid:Pe("trapezoid","flowchart",t=>Ei(t,"trapezoid")),terminator:Pe("terminator","flowchart",t=>Ei(t,"terminator")),cylinder:Pe("cylinder","flowchart",t=>Ei(t,"cylinder")),"document-shape":Pe("document-shape","flowchart",t=>Ei(t,"document-shape")),hyperlink:Pe("hyperlink","hyperlink",t=>ka(t,"hyperlink")),switch:Pe("switch","switch",t=>ka(t,"switch")),svg:Pe("svg","svg",n0),view:Pe("view","view",r0),"shape-reference":Pe("shape-reference","shape-reference",i0),video:Pe("video","media",t=>wa(t,"video",320,180)),audio:Pe("audio","media",t=>wa(t,"audio",320,180)),"foreign-object":Pe("foreign-object","foreign-object",t=>wa(t,"foreign-object",100,100))}),s0=Object.freeze(Object.keys(Yh));function a0(){return s0}function Ao(t){return Yh[t]}function cn(t){return Ao(t.type)?.resolve(t)??null}function Xh(t,e,n,r){return n<0||r<0?null:{minX:t,minY:e,maxX:t+n,maxY:e+r}}function c0(t){if(t.length===0)return{minX:0,minY:0,maxX:0,maxY:0};let e=t[0].x,n=t[0].y,r=t[0].x,i=t[0].y;for(let o=1;o<t.length;o++){let s=t[o];s.x<e&&(e=s.x),s.x>r&&(r=s.x),s.y<n&&(n=s.y),s.y>i&&(i=s.y)}return{minX:e,minY:n,maxX:r,maxY:i}}function Pa(t,e){let n=cn(t);if(!n)return null;switch(n.kind){case"circle":return n.r<0?null:{minX:n.cx-n.r,minY:n.cy-n.r,maxX:n.cx+n.r,maxY:n.cy+n.r};case"ellipse":return n.rx<0||n.ry<0?null:{minX:n.cx-n.rx,minY:n.cy-n.ry,maxX:n.cx+n.rx,maxY:n.cy+n.ry};case"rectangle":return n.pathData?Sn(n.pathData):Xh(n.x,n.y,n.width,n.height);case"line":return n.boundsPolicy==="linked-line"?null:{minX:Math.min(n.x1,n.x2),minY:Math.min(n.y1,n.y2),maxX:Math.max(n.x1,n.x2),maxY:Math.max(n.y1,n.y2)};case"text":return e?.measureText?.(t,n)??null;case"path":return Sn(n.d,n.placement?qe(n.placement.x,n.placement.y):void 0);case"polyline":return c0(n.points);case"positioning-rect":return Xh(n.x,n.y,n.width,n.height);case"container":case"embedded-svg":case"view":case"shape-reference":case"symbol-instance":return null}}function Ld(t,e){let n=Pa(t,e);return n?{x:(n.minX+n.maxX)/2,y:(n.minY+n.maxY)/2}:null}var qh=/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:[eE][+-]?\d+)?$/u,l0=/[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:[eE][+-]?\d+)?/gu;function Ra(t){return(t.match(l0)??[]).map(Number).filter(Number.isFinite)}function d0(t){let e=Ra(t),n=e.length-e.length%2,r=[];for(let i=0;i<n;i+=2)r.push(`${e[i]},${e[i+1]}`);return r.join(" ")}function Ta(t,e){let n=Ra(t),r=Ra(e),i=n.length-n.length%2,o=r.length-r.length%2;if(i!==o)return null;if(i===0)return"";let s=[];for(let a=0;a<i;a+=2)s.push(`${n[a]+r[a]},${n[a+1]+r[a+1]}`);return s.join(" ")}function Bd(t){return t.additive==="sum"||t.values==null&&t.from==null&&t.to==null&&t.by!=null?"sum":"replace"}function Hr(t,e,n="number"){if(n==="points"){let r=a=>d0(a.trim()),i=Bd(t)==="sum",o=e===void 0?void 0:r(e),s=a=>{if(!i||o===void 0)return[...a];let c=a.map(l=>Ta(o,l));return c.every(l=>l!==null)?c:null};if(t.values){let a=t.values.split(";").map(c=>c.trim()).filter(Boolean).map(r);return a.length===0?null:s(a)}if(t.from!=null&&t.to!=null)return s([r(t.from),r(t.to)]);if(t.from!=null&&t.by!=null){let a=r(t.from),c=Ta(a,r(t.by));return c===null?null:s([a,c])}if(t.to!=null&&o!==void 0){let a=r(t.to);if(!i)return[o,a];let c=Ta(o,a);return c===null?null:[o,c]}if(t.by!=null&&o!==void 0){let a=Ta(o,r(t.by));return a===null?null:[o,a]}return null}if(t.values){let r=t.values.split(";").map(i=>i.trim()).filter(Boolean);return r.length===0?null:r}if(t.from!=null&&t.to!=null)return[t.from.trim(),t.to.trim()];if(t.from!=null&&t.by!=null){let r=Number(t.from),i=Number(t.by);return Number.isFinite(r)&&Number.isFinite(i)?[String(r),String(r+i)]:null}if(t.to!=null&&e!==void 0)return[e.trim(),t.to.trim()];if(t.by!=null){let r=Number(t.by);return Number.isFinite(r)?["0",String(r)]:null}return null}function Gd(t){let e=t.dur?.trim();return!e||e==="indefinite"||e==="media"?0:dr(e)}function hr(t,e,n=t.calcMode??"linear"){if(t.keyTimes){let r=t.keyTimes.split(";").map(i=>i.trim());if(r.length===e&&r.every(i=>qh.test(i)))return r.map(Number)}return e<=1?e===1?[0]:[]:n==="discrete"?Array.from({length:e},(r,i)=>i/e):Array.from({length:e},(r,i)=>i/(e-1))}function yr(t){return t.keySplines?t.keySplines.split(";").map(e=>e.trim()).filter(Boolean).map(e=>{let n=Ra(e);return[n[0]??0,n[1]??0,n[2]??0,n[3]??0]}):[]}function Zh(t){if(t.repeatCount==="indefinite")return{cycleInfinite:!0};if(t.repeatCount&&qh.test(t.repeatCount.trim())){let e=Number(t.repeatCount);if(e>1)return{cycleRepeats:Math.round(e)}}if(t.repeatDur==="indefinite")return{cycleInfinite:!0};if(t.repeatDur){let e=dr(t.repeatDur),n=Gd(t);if(e>0&&n>0){let r=Math.max(1,Math.ceil(e/n));if(r>1)return{cycleRepeats:r}}}return{}}function Jh(t){return t.fill==="freeze"?{}:{fill:"remove"}}function An(t,e,n,r,i,o){let s=[];for(let a=0;a<t.length&&a<e.length;a++){let c=t[a].trim(),l=o==="color"||o==="path"||o==="points"||o==="numberList"||o==="discrete",d=Number(c),u={time:e[a]*r,value:l||!Number.isFinite(d)?c:d,easing:"linear"};if(a>0&&i==="spline"&&n[a-1]){let p=dd(...n[a-1]);u.easing=p.easing,p.customBezier&&(u.customBezier=p.customBezier)}else a>0&&i==="discrete"&&(u.easing="steps",u.stepsParams={count:1,position:"jump-end"});s.push(u)}return s}var u0=/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:h|min|s|ms)?$/iu,p0=/^([A-Za-z_][\w.-]*)\.repeat\((\d+)\)\s*([+-]\s*\S+)?$/u,f0=/^([A-Za-z_][\w.-]*)\.(begin|end)\s*([+-]\s*\S+)?$/u,Vd=class{bySourceId=new Map;beginCache=new Map;resolving=new Set;constructor(e){for(let n of e)n.sourceAnimationId&&!this.bySourceId.has(n.sourceAnimationId)&&this.bySourceId.set(n.sourceAnimationId,n)}activations(e){let r=(e.attributes.begin??"0s").split(";").map(c=>c.trim()).filter(Boolean),i=r.flatMap(c=>{let l=this.resolveEntry(c);return l!==null&&Number.isFinite(l)?[{entry:c,time:l}]:[]}),o=new Map;for(let c of i)o.set(c.time,c.entry);let a=r.length>1&&e.kind!=="discard"&&e.additive!=="sum"&&o.size>1?[...o.keys()].sort((c,l)=>c-l):i.length>0?[i[0].time]:[null];return Object.freeze(a.map(c=>{let l=Object.freeze({...e.attributes,...c!==null?{begin:`${c}s`}:{}}),d=e.duration;if(e.attributes.values?.split(";").map(p=>p.trim()).filter(Boolean)?.length===1&&c!==null&&e.attributes.end){let p=this.resolveEntry(e.attributes.end.split(";")[0].trim());p!==null&&Number.isFinite(p)&&p>=c&&(d=p-c)}return Object.freeze({...e,attributes:l,duration:d})}))}resolveCandidateBegin(e){let n=this.beginCache.get(e.animationId);if(n!==void 0)return n;if(this.resolving.has(e.animationId))return null;this.resolving.add(e.animationId);let r=e.attributes.begin?.split(";")[0]?.trim()||"0s",i=this.resolveEntry(r);return this.resolving.delete(e.animationId),i!==null&&this.beginCache.set(e.animationId,i),i}resolveEntry(e){if(!e||e==="0")return 0;if(e==="indefinite")return Number.POSITIVE_INFINITY;if(u0.test(e))return dr(e);let n=e.match(p0);if(n){let i=this.bySourceId.get(n[1]);if(!i)return null;let o=this.resolveCandidateBegin(i);if(o===null||!Number.isFinite(o))return o;let s=Number(n[2]),a=this.repeatEventTime(i,o,s);return a===null||!Number.isFinite(a)?a:a+this.offset(n[3])}let r=e.match(f0);if(r){let i=this.bySourceId.get(r[1]);if(!i)return null;let o=this.resolveCandidateBegin(i);if(o===null||!Number.isFinite(o))return o;let s=this.activeDuration(i),a=r[2]==="end"?s!==null?o+s:null:o;return a===null?null:a+this.offset(r[3])}return null}offset(e){return e?dr(e.replace(/\s+/gu,"")):0}repeatEventTime(e,n,r){if(r<1||e.duration<=0)return Number.POSITIVE_INFINITY;let i=this.activeDuration(e);return i===null||r*e.duration>=i?Number.POSITIVE_INFINITY:n+r*e.duration}activeDuration(e){if(e.duration<=0)return null;let n=e.attributes.repeatCount,r=e.attributes.repeatDur,i=e.duration,o=!1;if(n==="indefinite"&&(i=Number.POSITIVE_INFINITY,o=!0),n&&n!=="indefinite"){let s=Number(n);Number.isFinite(s)&&s>0&&(i=s*e.duration,o=!0)}if(r==="indefinite")o||(i=Number.POSITIVE_INFINITY);else if(r){let s=dr(r);Number.isFinite(s)&&s>=0&&(i=o?Math.min(i,s):s)}return i}},En=Object.freeze({cx:{property:"x",valueType:"number",stateKey:"x"},cy:{property:"y",valueType:"number",stateKey:"y"},d:{property:"pathMorph",valueType:"path",stateKey:"d"},display:{property:"display",valueType:"discrete",stateKey:"display"},fill:{property:"fillColor",valueType:"color",stateKey:"fillColor"},"fill-opacity":{property:"fillOpacity",valueType:"number",stateKey:"fillOpacity"},height:{property:"height",valueType:"number",stateKey:"height"},opacity:{property:"opacity",valueType:"number",stateKey:"opacity"},points:{property:"polylinePoints",valueType:"points",stateKey:"points"},r:{property:"radius",valueType:"number",stateKey:"radius"},rx:{property:"rx",valueType:"number",stateKey:"rx"},ry:{property:"ry",valueType:"number",stateKey:"ry"},stroke:{property:"strokeColor",valueType:"color",stateKey:"borderColor"},target:{property:"linkTarget",valueType:"discrete",stateKey:"linkTarget"},"stroke-dasharray":{property:"strokeDasharray",valueType:"numberList",stateKey:"strokeDasharray"},"stroke-dashoffset":{property:"strokeDashoffset",valueType:"number",stateKey:"strokeDashoffset"},"stroke-linecap":{property:"strokeLinecap",valueType:"discrete",stateKey:"strokeLinecap"},"stroke-linejoin":{property:"strokeLinejoin",valueType:"discrete",stateKey:"strokeLinejoin"},"stroke-miterlimit":{property:"strokeMiterlimit",valueType:"number",stateKey:"strokeMiterlimit"},"stroke-opacity":{property:"strokeOpacity",valueType:"number",stateKey:"strokeOpacity"},"stroke-width":{property:"strokeWidth",valueType:"number",stateKey:"borderWidth"},visibility:{property:"visibility",valueType:"discrete",stateKey:"visibility"},width:{property:"width",valueType:"number",stateKey:"width"},x:{property:"x",valueType:"number",stateKey:"x"},x1:{property:"x1",valueType:"number",stateKey:"x1"},x2:{property:"x2",valueType:"number",stateKey:"x2"},y:{property:"y",valueType:"number",stateKey:"y"},y1:{property:"y1",valueType:"number",stateKey:"y1"},y2:{property:"y2",valueType:"number",stateKey:"y2"}}),m0=Object.freeze({...En,"font-size":{property:"fontSize",valueType:"number",stateKey:"fontSize"}}),g0=/[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:[eE][+-]?\d+)?/gu;function ty(t){return(t.match(g0)??[]).map(Number).filter(Number.isFinite)}function jd(t,e){let n=t?.[e];if(n!=null)return Array.isArray(n)?n.join(" "):String(n)}function ny(t){switch(t.property){case"visibility":return"visible";case"display":return"inline";case"opacity":case"fillOpacity":case"strokeOpacity":return"1";default:return}}function bn(t){let e=t.attributes.begin?.split(";")[0]?.trim();return!e||e==="0"||e==="0s"?{offset:0}:/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:h|min|s|ms)?$/iu.test(e)?{offset:dr(e)}:/^[A-Za-z_][\w.-]*(?:\.[A-Za-z_][\w.-]*)?(?:[+-].+)?$/u.test(e)?{offset:0,beginTrigger:{type:"event",value:e}}:{offset:0,beginTrigger:{type:"expression",value:e}}}function Kr(t){let e=Zh(t.attributes),n=bn(t);return{enabled:!0,cycleBehavior:"restart",...t.duration>0?{cycleDuration:t.duration}:{},...t.additive==="sum"?{additive:"sum"}:{},...e,...Jh(t.attributes),...n.beginTrigger?{beginTrigger:n.beginTrigger}:{}}}function Mi(t,e){return t.map(n=>({...n,time:n.time+e}))}function ry(t,e,n,r,i){let o=t.attributeName?.toLowerCase();if(!o)return null;let s=i?.projection??En[o]??{property:o,valueType:"discrete",stateKey:o},a=t.attributes,c=i?.underlying??jd(n,s.stateKey)??ny(s),l=Hr(a,c,s.valueType);if(!l||l.length===0)return null;let d=t.kind==="set"?"discrete":a.calcMode??"linear",u=t.duration,p=bn(t);if(t.kind==="set"){let h=[{time:p.offset,value:l.at(-1),easing:"linear"}];return u>0&&t.fill==="remove"&&c!==void 0&&h.push({time:p.offset+u,value:c,easing:"linear"}),{id:`svg-animation-${r}`,shapeId:e,property:s.property,enabled:!0,...u>0?{cycleDuration:u}:{},cycleBehavior:"restart",calcMode:"discrete",sourceSmilElement:"set",...t.sourceAnimationId?{sourceSmilId:t.sourceAnimationId}:{},keyframes:h}}if(l.length===1){let h=An(l,[0],[],u,"discrete",s.valueType)[0]?.value;if(h===void 0)return null;let y=[{time:p.offset,value:h,easing:"linear"}];if(u>0&&t.fill==="remove"&&c!==void 0){let b=An([c],[0],[],u,"discrete",s.valueType)[0]?.value;b!==void 0&&y.push({time:p.offset+u,value:b,easing:"linear"})}return{id:`svg-animation-${r}`,shapeId:e,property:s.property,enabled:!0,...u>0?{cycleDuration:u}:{},cycleBehavior:"restart",calcMode:"discrete",sourceSmilElement:"animate",...t.sourceAnimationId?{sourceSmilId:t.sourceAnimationId}:{},keyframes:y}}let f=hr(a,l.length,d),m=yr(a),g=Mi(An(l,f,m,u,d,s.valueType),p.offset);return g.length<2?null:{id:`svg-animation-${r}`,shapeId:e,property:s.property,...Kr(t),...d!=="linear"?{calcMode:d}:{},sourceSmilElement:"animate",...t.sourceAnimationId?{sourceSmilId:t.sourceAnimationId}:{},keyframes:g}}var h0=Object.freeze({"stop-color":{suffix:"Color",valueType:"color"},"stop-opacity":{suffix:"Opacity",valueType:"number"},offset:{suffix:"Offset",valueType:"number"}});function y0(t,e){return e==="stop-color"?t.color:String(e==="stop-opacity"?t.opacity:t.offset)}function S0(t,e,n,r){let i=t.attributeName?.toLowerCase(),o=t.targetSourceNodeId;if(!e||!i||!o)return[];let s=h0[i];if(!s||t.kind!=="animate"&&t.kind!=="set")return[];let a=[],c=new Set;for(let l of e.candidates)l.stops.forEach((d,u)=>{if(!(d.sourceNodeId!==o&&d.correspondingSourceNodeId!==o)){for(let p of e.bindings)if(!(p.gradientSourceNodeId!==l.sourceNodeId||p.propertyName!=="fill"&&p.propertyName!=="stroke"))for(let f of iy(p.occurrenceId,n)){let m=`${p.propertyName}GradientStop${u}${s.suffix}`,g=`${f.shapeId}|${m}`;if(c.has(g))continue;c.add(g);let h=ry(t,f.shapeId,f.state,r+a.length,{projection:{property:m,valueType:s.valueType,stateKey:m},underlying:y0(d,i)});h&&a.push(h)}}});return a}function iy(t,e){let n=e.shapeBindingsForOccurrence?.(t);if(n&&n.length>0)return n;let r=e.shapeIdForOccurrence(t);return r?[{shapeId:r,shapeType:"unknown",state:e.shapeStateForOccurrence(t)}]:[]}var b0=new Set(["clip-path","display","fill","mask","opacity","visibility"]);function v0(t,e){if(t.targetStatus!=="resolved"||!t.targetOccurrenceId)return[];let n=iy(t.targetOccurrenceId,e);if(!n.some(i=>i.shapeType==="group")||t.kind==="animateTransform"||t.kind==="animateMotion"||t.kind==="discard"||b0.has(t.attributeName?.toLowerCase()??""))return n;let r=e.descendantShapeBindingsForOccurrence?.(t.targetOccurrenceId);return r&&r.length>0?r:n}function x0(t,e,n){if(t.kind!=="animate"||t.attributeName?.toLowerCase()!=="viewbox")return[];let r=e.shapeType==="svg"?"svgViewBox":e.shapeType==="view"?"viewBox":null;if(!r||t.duration<=0)return[];let i=Hr(t.attributes,void 0,"numberList");if(!i||i.length<2)return[];let o=i.map(ty);if(o.some(d=>d.length<4))return[];let s=t.attributes.calcMode??"linear",a=hr(t.attributes,o.length,s),c=yr(t.attributes),l=bn(t);return["X","Y","Width","Height"].map((d,u)=>({id:`svg-animation-${n+u}`,shapeId:e.shapeId,property:`${r}${d}`,...Kr(t),...s!=="linear"?{calcMode:s}:{},sourceSmilElement:"animate",...t.sourceAnimationId?{sourceSmilId:t.sourceAnimationId}:{},keyframes:Mi(An(o.map(p=>String(p[u])),a,c,t.duration,s,"number"),l.offset)}))}var I0=Object.freeze([{cssProperty:"fill",projection:En.fill},{cssProperty:"stroke",projection:En.stroke},{cssProperty:"stroke-width",projection:En["stroke-width"]},{cssProperty:"fill-opacity",projection:En["fill-opacity"]},{cssProperty:"stroke-opacity",projection:En["stroke-opacity"]},{cssProperty:"opacity",projection:En.opacity},{cssProperty:"visibility",projection:En.visibility},{cssProperty:"display",projection:En.display}]);function Qh(t,e){if(e==="number"){let n=Number.parseFloat(t);if(Number.isFinite(n))return String(n)}return t.trim().toLowerCase()}function w0(t,e,n,r){if(!t.targetOccurrenceId||t.attributeName?.toLowerCase()!=="class")return[];let i=t.kind==="set"?t.attributes.to===void 0?null:["",t.attributes.to]:Hr(t.attributes,void 0,"discrete");if(!i||i.length<2||t.kind==="animate"&&t.duration<=0)return[];let o=Math.max(t.duration,.001),s=hr(t.attributes,i.length,"discrete"),a=yr(t.attributes),c=bn(t),l=i.map(u=>n.stylesheetValuesWithClass(t.targetOccurrenceId,u)),d=[];for(let{cssProperty:u,projection:p}of I0){let f=jd(e.state,p.stateKey)??ny(p)??"",m=l.map(h=>h[u]??f),g=Qh(f,p.valueType);m.every(h=>Qh(h,p.valueType)===g)||d.push({id:`svg-animation-${r+d.length}`,shapeId:e.shapeId,property:p.property,...Kr(t),calcMode:"discrete",sourceSmilElement:t.kind==="set"?"set":"animate",...t.sourceAnimationId?{sourceSmilId:t.sourceAnimationId}:{},keyframes:Mi(An(m,s,a,o,"discrete",p.valueType),c.offset)})}return d}function k0(t,e,n){let r=t.attributes.type?.trim().toLowerCase();if(!r)return[];let i=t.attributes,o=Hr(i,void 0,"numberList");if(!o||o.length<2)return[];let s=i.calcMode??"linear",a=hr(i,o.length,s),c=yr(i),l=bn(t),d=Kr(t),u=o.map(ty),p=(f,m,g,h)=>{let y=An(o.map((b,v)=>{let I=m(u[v]);return Array.isArray(I)?I.join(" "):String(I)}),a,c,t.duration,s,f==="transformMatrix"?"numberList":"number").map((b,v)=>({...b,time:b.time+l.offset,value:f==="transformMatrix"?u[v].slice(0,6):b.value}));return{id:`svg-animation-${n+g}`,shapeId:e,property:f,...d,additive:t.additive,...t.additive==="replace"&&t.replacesCarrierBase?{replacesCarrierBase:!0}:{},...h?{transformOrigin:h}:{},...t.sourceAnimationId?{sourceSmilId:t.sourceAnimationId}:{},keyframes:y}};if(r==="translate")return[p("translateX",f=>f[0]??0,0),p("translateY",f=>f[1]??0,1)];if(r==="scale")return[p("scaleX",f=>f[0]??1,0),p("scaleY",f=>f[1]??f[0]??1,1)];if(r==="rotate"){let f=u.find(m=>m.length>=3);return[p("rotation",m=>m[0]??0,0,f?{x:f[1],y:f[2]}:{x:0,y:0})]}return r==="skewx"||r==="skewy"?[p(r==="skewx"?"skewX":"skewY",f=>f[0]??0,0)]:r==="matrix"&&u.every(f=>f.length>=6)?[p("transformMatrix",f=>f.slice(0,6),0)]:[]}function oy(t,e,n,r){if(!t.motionPathData||t.duration<=0)return null;let i=t.attributes.keyPoints?.split(";").map(Number).filter(Number.isFinite),o=i&&i.length>=2?i:[0,1],s=t.attributes.calcMode??"paced",a=hr(t.attributes,o.length,s),c=yr(t.attributes),l=bn(t),d=t.attributes.rotate?.trim(),u=d===void 0?Number.NaN:Number(d),p=t.motionPathSourceNodeId?n.shapeIdForSourceNode(t.motionPathSourceNodeId):null;return{id:`svg-animation-${r}`,shapeId:e,property:"pathMotion",...Kr(t),motionPath:t.motionPathData,...p?{motionPathRef:{shapeId:p,mode:"curveTemplate"}}:{},...d==="auto"||d==="auto-reverse"?{motionRotate:d}:Number.isFinite(u)?{motionRotate:u}:{},...t.sourceAnimationId?{sourceSmilId:t.sourceAnimationId}:{},...s!=="linear"&&s!=="paced"?{calcMode:s}:{},keyframes:Mi(An(o.map(String),a,c,t.duration,s,"number"),l.offset)}}var P0=new Set(["cx","cy","r","rx","ry","x","y","x1","y1","x2","y2","width","height","opacity","fill-opacity","stroke-opacity","stop-opacity","stroke-width","stroke-dashoffset","stroke-miterlimit","offset","pathlength","startoffset","fr"]),T0=new Set(["fill","stroke","stop-color","flood-color","lighting-color"]);function Wr(t){return{shapeId:t.shapeId,domTargetSelector:t.selector}}function R0(t,e,n,r){let i=oy(t,e.shapeId,n,r);return i?{...i,property:"domTransformStack",additive:t.additive,...Wr(e),transformFunction:"translate",transformStackIndex:0,transformBaseValue:e.baseTransform}:null}function C0(t,e,n,r){let i=t.attributes.type?.trim();if(i!=="translate"&&i!=="scale"&&i!=="rotate"&&i!=="skewX"&&i!=="skewY"&&i!=="matrix")return null;let o=Hr(t.attributes,void 0,"discrete");if(!o||o.length<2||t.duration<=0)return null;let s=t.attributes.calcMode??"linear",a=hr(t.attributes,o.length,s),c=yr(t.attributes),l=bn(t);return{id:`svg-animation-${n}`,...Wr(e),property:"domTransformStack",...Kr(t),additive:t.additive,...s!=="linear"?{calcMode:s}:{},sourceSmilElement:"animateTransform",...t.sourceAnimationId?{sourceSmilId:t.sourceAnimationId}:{},transformFunction:i,transformStackIndex:r,transformBaseValue:e.baseTransform,keyframes:Mi(An(o,a,c,t.duration,s,"discrete"),l.offset)}}function $0(t,e,n){let r=t.attributeName;if(!r||t.kind!=="animate"&&t.kind!=="set")return null;let i=r.toLowerCase(),o=e.baseAttributes[r]??e.baseAttributes[i]??"",s=t.kind==="animate"&&(i==="display"||i==="visibility"),a=t.kind==="set"?"string":P0.has(i)?"number":T0.has(i)?"color":"string";if(t.kind==="set"){let g=t.attributes.to?.trim();if(g===void 0)return null;let h=bn(t),y=[{time:h.offset,value:g,easing:"linear"}];return t.duration>0&&t.fill==="remove"&&y.push({time:h.offset+t.duration,value:o,easing:"linear"}),{id:`svg-animation-${n}`,...Wr(e),property:"domAttribute",enabled:!0,...t.duration>0?{cycleDuration:t.duration}:{},cycleBehavior:"restart",calcMode:"discrete",sourceSmilElement:"set",...t.sourceAnimationId?{sourceSmilId:t.sourceAnimationId}:{},domAttribute:r,domAttributeValueType:"string",transformBaseValue:o,keyframes:y}}let c=s||a==="string"?"discrete":a,l=Hr(t.attributes,o,c);if(!l||l.length===0||t.duration<=0)return null;let d=s?"discrete":t.attributes.calcMode??"linear",u=hr(t.attributes,l.length,d),p=yr(t.attributes),f=bn(t),m=s?i==="display"?"domDisplay":"domVisibility":"domAttribute";return{id:`svg-animation-${n}`,...Wr(e),property:m,...Kr(t),calcMode:d,sourceSmilElement:"animate",...t.sourceAnimationId?{sourceSmilId:t.sourceAnimationId}:{},...m==="domAttribute"?{domAttribute:r,domAttributeValueType:a}:{},transformBaseValue:o,keyframes:Mi(An(l,u,p,t.duration,d,c),f.offset)}}function N0(t,e,n,r,i){if(t.kind==="animateMotion")return R0(t,e,n,r);if(t.kind==="animateTransform")return C0(t,e,r,i);if(t.kind==="discard"){let o=bn(t);return{id:`svg-animation-${r}`,...Wr(e),property:"discard",enabled:!0,sourceSmilElement:"discard",...t.sourceAnimationId?{sourceSmilId:t.sourceAnimationId}:{},transformBaseValue:e.baseAttributes.display??"",keyframes:[{time:o.offset,value:1,easing:"linear"}]}}return $0(t,e,r)}function A0(t,e,n,r,i){let o=v0(t,n);if(o.length===0&&t.targetOccurrenceId){let a=n.domTargetForOccurrence?.(t.targetOccurrenceId),c=a?N0(t,a,n,r,i):null;return c?[c]:[]}let s=[];for(let a of o){if(t.kind==="animateTransform"){s.push(...k0(t,a.shapeId,r+s.length));continue}if(t.kind==="animateMotion"){let u=oy(t,a.shapeId,n,r+s.length);u&&s.push(u);continue}if(t.kind==="discard"){let u=bn(t);s.push({id:`svg-animation-${r+s.length}`,shapeId:a.shapeId,property:"discard",enabled:!0,sourceSmilElement:"discard",...t.sourceAnimationId?{sourceSmilId:t.sourceAnimationId}:{},keyframes:[{time:u.offset,value:1,easing:"linear"}]});continue}let c=x0(t,a,r+s.length);if(c.length>0){s.push(...c);continue}let l=w0(t,a,e,r+s.length);if(l.length>0){s.push(...l);continue}let d=ry(t,a.shapeId,a.state,r+s.length);d&&s.push(d)}return s}function Ca(t){let e=Number(t.iterationCount);return{enabled:!0,cycleDuration:t.duration,cycleBehavior:t.direction==="reverse"||t.direction==="alternate"||t.direction==="alternate-reverse"?t.direction:"restart",...t.iterationCount==="infinite"?{cycleInfinite:!0}:Number.isFinite(e)&&e>=0&&e!==1?{cycleRepeats:e}:{},...fh(t)}}var E0=Object.freeze([["translateX",0],["translateY",0],["scaleX",1],["scaleY",1],["rotation",0],["skewX",0],["skewY",0]]);function M0(t,e,n,r){let i=n.shapeIdForOccurrence(t.occurrenceId),o=i?null:n.domTargetForOccurrence?.(t.occurrenceId),s=i??o?.shapeId??null;if(!s)return[];let a=e.value(t.occurrenceId,"transform-box")??"view-box",c=n.cssTransformContextForOccurrence?.(t.occurrenceId,a),l=n.shapeBindingsForOccurrence?.(t.occurrenceId)[0],d=(a==="fill-box"||a==="content-box")&&l?.state?Pa({id:l.shapeId,type:l.shapeType,state:l.state}):null,u={...d?{boxX:d.minX,boxY:d.minY,boxWidth:d.maxX-d.minX,boxHeight:d.maxY-d.minY}:{},...c??{}},p=t.keyframes.stops.flatMap(x=>{let k=x.properties.transform??x.properties["-webkit-transform"]??x.properties["-moz-transform"];return k===void 0?[]:[{offset:x.offset,raw:k,timing:x.properties["animation-timing-function"]}]});if(p.length===0)return[];let f=e.value(t.occurrenceId,"transform")??"none";p[0].offset>0&&p.unshift({offset:0,raw:f,timing:void 0}),p.at(-1).offset<1&&p.push({offset:1,raw:f,timing:void 0});let h=e.style(t.occurrenceId)?.cascadedValues["transform-origin"]?fa(e.value(t.occurrenceId,"transform-origin")??"0 0",u):{x:0,y:0},y=ha(p.map(({offset:x,raw:k})=>({offset:x,transform:k})),{...u,...h?{transformOrigin:h}:{},retainPureRotationOrigin:!o,progressForInterval:(x,k)=>{let T=p[x]?.timing;return nh(T?ki(T):t.animation.parsedEasing,k)}});if(y.status!=="projected")return[];if(o)return[{id:`svg-animation-${r}`,...Wr(o),property:"domTransformStack",...Ca(t.animation),additive:"replace",replacesCarrierBase:!0,transformFunction:"matrix",transformStackIndex:0,transformBaseValue:o.baseTransform,template:{name:t.animation.name},keyframes:y.stops.map(x=>$a(x.offset,x.matrix.join(" "),t.animation,y.sampled?"linear":p.findLast(k=>k.offset<x.offset)?.timing))}];let b=y.stops.map(x=>({offset:x.offset,channels:x})),v=new Set(y.channels),I=[];for(let[x,k]of E0){if(!v.has(x))continue;let T=b.flatMap(({offset:w,channels:P})=>{if(!P)return[];let N=P[x]??k,R=p.findLastIndex($=>$.offset<w);return[$a(w,N,t.animation,y.sampled?"linear":p[Math.max(0,R)]?.timing)]});T.length<2||I.push({id:`svg-animation-${r+I.length}`,shapeId:s,property:x,...Ca(t.animation),additive:x==="translateX"||x==="translateY"?"sum":"replace",replacesCarrierBase:!0,...x==="rotation"&&h&&(y.pureRotation||h.x===0&&h.y===0&&(h.z??0)===0)?{transformOrigin:{x:h.x,y:h.y}}:{},template:{name:t.animation.name},keyframes:T})}return I}function ey(t,e){let n=t.trim();if(e!=="number")return n;let r=/^([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?)(?:px)?$/iu.exec(n);if(!r)return null;let i=Number(r[1]);return Number.isFinite(i)?i:null}function $a(t,e,n,r){let i={time:t*n.duration+n.delay,value:e,easing:n.easing},o=r?ki(r):n.parsedEasing;return o&&th(i,o),i}function O0(t,e){if(t.length!==0){if(t[0].offset>0){let n=e();n&&t.unshift({...n,offset:0})}if(t.at(-1).offset<1){let n=e();n&&t.push({...n,offset:1})}}}function D0(t,e,n,r){let i=n.shapeIdForOccurrence(t.occurrenceId),o=i?null:n.domTargetForOccurrence?.(t.occurrenceId),s=i??o?.shapeId??null;if(!s)return[];let a=n.shapeStateForOccurrence(t.occurrenceId),c=new Set(t.keyframes.stops.flatMap(d=>Object.keys(d.properties)));c.delete("animation-timing-function"),c.delete("transform"),c.delete("-webkit-transform"),c.delete("-moz-transform");let l=[];for(let d of c){let u=m0[d];if(!u)continue;let p=t.keyframes.stops.flatMap(m=>{let g=m.properties[d];if(g===void 0)return[];let h=ey(g,u.valueType);return h===null?[]:[{offset:m.offset,value:h,timing:m.properties["animation-timing-function"]}]}),f=e.value(t.occurrenceId,d)??jd(a,u.stateKey)??o?.baseAttributes[d];if(O0(p,()=>{if(f==null)return null;let m=ey(f,u.valueType);return m===null?null:{offset:0,value:m,timing:void 0}}),!(p.length<2)){if(o){l.push({id:`svg-animation-${r+l.length}`,...Wr(o),property:"domAttribute",domAttribute:d,domAttributeValueType:u.valueType==="number"?"number":u.valueType==="color"?"color":"string",...Ca(t.animation),template:{name:t.animation.name},keyframes:p.map((m,g)=>$a(m.offset,m.value,t.animation,g===0?void 0:p[g-1].timing))});continue}l.push({id:`svg-animation-${r+l.length}`,shapeId:s,property:u.property,...Ca(t.animation),template:{name:t.animation.name},keyframes:p.map((m,g)=>$a(m.offset,m.value,t.animation,g===0?void 0:p[g-1].timing))})}}return l}function z0(t){let e=Math.max(0,...t.keyframes.map(n=>n.time));return sh(t)??e}function sy(t,e,n,r){let i=new Vd(t.smil),o=[],s=[],a=[],c=[],l=[],d=new Map,u=new Map;for(let g of t.smil){let h=0;if(g.kind==="animateTransform"&&g.targetOccurrenceId){let y=`${g.targetOccurrenceId}|${g.sourceNodeId}`,b=d.get(y);b!==void 0?h=b:(h=u.get(g.targetOccurrenceId)??0,d.set(y,h),u.set(g.targetOccurrenceId,h+1))}for(let y of i.activations(g)){let b=S0(y,r,n,1),v=b.length>0?b:A0(y,e,n,1,h);g.kind==="animateTransform"?o.push(...v):g.kind==="animateMotion"?s.push(...v):g.kind==="set"?c.push(...v):g.kind==="discard"?l.push(...v):a.push(...v)}}let p=[],f=[];for(let g of t.css)p.push(...M0(g,e,n,1)),f.push(...D0(g,e,n,1));let m=[...o,...s,...a,...c,...l,...p,...f].map((g,h)=>{let y=`svg-animation-${h+1}`;return{...g,id:y,keyframes:g.keyframes.map((b,v)=>({...b,id:b.id??`${y}-kf-${v+1}`}))}});return m.length===0?null:{duration:Math.max(...m.map(z0)),loop:m.some(g=>g.cycleInfinite===!0),playbackSpeed:1,tracks:m}}function Na(t,e){return sy(t.animations,t.styles,e,t.gradients)}var _0=["native-validation-warning","unavailable-shape-descriptor","malformed-source","missing-svg-root","invalid-svg-attribute","duplicate-svg-id","missing-svg-namespace","no-materializable-content","unsupported-svg-element","unsupported-ingest-capability","empty-hyperlink-dropped","nested-hyperlink-flattened","required-features-dropped","unresolved-reference","circular-use-reference","circular-resource-reference","use-expansion-limit-exceeded","external-effect-failed","application-rolled-back"],Eo=["native-document-open","full-snapshot-restore","svg-document-import","external-svg-paste","internal-clipboard-paste","plugin-svg-fragment","pattern-fragment","vectorized-svg-fragment"];var Ea=["geometry","containers","source-order","hierarchy","root-viewport-frame","common-presentation","conditional-processing","authored-attributes","gradients","patterns","filters","paint-server-definitions","markers","symbols","use-and-linked-references","clip-definitions","mask-definitions","clip-mask-membership","smil-animation","css-animation","metadata","scripts","styles","custom-properties","views","embedded-svg","fonts","external-assets"],Kn=t=>({status:"supported",by:t}),Mo=(t,e)=>({status:"diagnosed-unsupported",by:t,reason:e}),ay=(t,e)=>({status:"diagnosed-lossy",by:t,reason:e}),Sr=t=>({status:"exempt",reason:t}),F0="plugin SVG result diagnostic collector",Hd="pattern fragment diagnostic collector",Wd="vectorized SVG result diagnostic collector";function Fe(t,e={}){return{"native-document-open":Kn("native snapshot parse and canonical restore"),"full-snapshot-restore":Kn("canonical full-snapshot restore"),"svg-document-import":Kn(t),"external-svg-paste":Kn(t),"internal-clipboard-paste":Kn("closed clipboard subgraph materializer"),"plugin-svg-fragment":e.plugin??Kn("plugin fragment plan materializer"),"pattern-fragment":e.pattern??Mo(Hd,"Pattern fragments retain only capabilities enrolled by the pattern tile contract."),"vectorized-svg-fragment":e.vectorized??Mo(Wd,"Vectorized ingestion intentionally accepts path-oriented geometry only.")}}var Aa=t=>Mo(F0,t),br=t=>Mo(Hd,t),cy=t=>Mo(Wd,t),Yt=t=>Kn(t),Ud=t=>Kn(t),Kd={geometry:Fe("SVG shape element parser",{pattern:Yt("fragment-scoped pattern shape parser"),vectorized:Ud("vectorized path geometry parser")}),containers:Fe("SVG structural container planner",{pattern:Yt("fragment-scoped pattern hierarchy parser")}),"source-order":Fe("source document order index and SceneGraph placement",{pattern:Yt("pattern source-order materializer"),vectorized:Ud("vectorized path document-order traversal")}),hierarchy:Fe("source DOM hierarchy planner and SceneGraph placement",{pattern:Yt("fragment-scoped pattern hierarchy materializer")}),"root-viewport-frame":Fe("root SVG frame parser and application policy",{plugin:Sr("Plugin fragment framing is consumed only for bounds scaling."),pattern:Sr("Pattern fragments use the explicit tile width and height as their local frame."),vectorized:ay(Wd,"Vectorized source framing is consumed only to scale path geometry into target bounds.")}),"common-presentation":Fe("shared SVG presentation parser",{pattern:Yt("pattern shape presentation parser"),vectorized:Ud("vectorized path presentation parser")}),"conditional-processing":Fe("SVG switch and conditional-processing attribute parser",{pattern:Yt("pattern shape conditional-processing parser"),vectorized:cy("Vectorized ingestion does not preserve SVG conditional-processing branches.")}),"authored-attributes":Fe("authored-attribute preservation parser",{pattern:Yt("pattern authored-attribute preservation parser")}),gradients:Fe("gradient parser and library reference materializer",{pattern:Yt("fragment-scoped pattern gradient resolver")}),patterns:Fe("pattern parser and library reference materializer",{pattern:Yt("fragment-scoped nested-pattern resolver")}),filters:Fe("filter parser and reference materializer"),"paint-server-definitions":Fe("paint-server definition collector and materializer",{pattern:Yt("fragment-scoped pattern paint-server collector")}),markers:Fe("marker definition parser and reference materializer"),symbols:Fe("symbol definition and instance materializer"),"use-and-linked-references":Fe("use resolver and stable reference-edge materializer",{pattern:Yt("fragment-scoped linked-reference resolver")}),"clip-definitions":Fe("clip definition parser and materializer",{pattern:br("Pattern editing omits document clip definitions.")}),"mask-definitions":Fe("mask definition parser and materializer",{pattern:br("Pattern editing omits document mask definitions.")}),"clip-mask-membership":Fe("clip and mask membership materializer",{pattern:br("Pattern editing omits document clip and mask membership.")}),"smil-animation":Fe("SMIL parser and animation-track materializer",{pattern:br("Pattern editing materializes a static tile without SMIL tracks.")}),"css-animation":Fe("CSS keyframe parser and animation-track materializer",{pattern:br("Pattern editing materializes a static tile without CSS animation tracks.")}),metadata:Fe("document metadata parser and field policy",{plugin:Aa("Plugin fragments preserve host document metadata."),pattern:Sr("Pattern fragments have no document metadata scope."),vectorized:Sr("Vectorized fragments have no document metadata scope.")}),scripts:Fe("inert script partitioner and document script materializer",{plugin:Kn("inert plugin fragment script data materializer"),pattern:br("Pattern fragments do not execute or adopt scripts."),vectorized:cy("Vectorized fragments do not execute or adopt scripts.")}),styles:Fe("preserved CSS style collector and materializer",{pattern:Yt("fragment-scoped pattern style resolver")}),"custom-properties":Fe("CSS custom-property collector and materializer",{pattern:Yt("fragment-scoped pattern variable resolver")}),views:Fe("SVG view parser and SceneGraph materializer",{plugin:Aa("Plugin fragments do not alter document navigation views."),pattern:Sr("Pattern fragments have no document navigation view scope."),vectorized:Sr("Vectorized fragments have no document navigation view scope.")}),"embedded-svg":Fe("embedded SVG container parser and materializer",{pattern:ay(Hd,"Pattern editing flattens nested SVG content into the local tile frame.")}),fonts:Fe("declared font-consent effect and approved loader",{plugin:Aa("Plugin fragments do not start an implicit external font consent flow."),pattern:br("Pattern fragments do not start an implicit font consent flow."),vectorized:Sr("Path-only vectorized fragments do not consume font resources.")}),"external-assets":Fe("declared external-asset resolver with proxy policy",{plugin:Aa("Plugin fragments diagnose assets outside the enrolled security policy."),pattern:br("Pattern fragments diagnose external assets instead of fetching them."),vectorized:Sr("Path-only vectorized fragments do not consume external assets.")})};function L0(t,e){return Kd[t][e]}function B0(t=Ea,e=Eo,n=Kd){if(t.length===0)throw new Error("Ingest feature roster must not be empty.");if(e.length===0)throw new Error("Ingress intent roster must not be empty.");if(new Set(t).size!==t.length)throw new Error("Ingest feature roster contains duplicate entries.");if(new Set(e).size!==e.length)throw new Error("Ingress intent roster contains duplicate entries.");for(let r of Object.keys(n))if(!t.includes(r))throw new Error(`Unknown ingest feature ${r} has a capability matrix.`);for(let r of t){let i=n[r];if(!i)throw new Error(`Ingest feature ${r} lacks a capability matrix.`);for(let o of e){let s=i[o];if(!s)throw new Error(`Ingest feature ${r} lacks intent ${o}.`);if((s.status==="exempt"?s.reason:s.by).trim().length<12)throw new Error(`Ingest feature ${o} lacks a substantive owner or reason.`);if((s.status==="diagnosed-lossy"||s.status==="diagnosed-unsupported")&&s.reason.trim().length<24)throw new Error(`Ingest feature ${o} lacks a substantive diagnostic reason.`)}for(let o of Object.keys(i))if(!e.includes(o))throw new Error(`Ingest feature ${r} has unknown intent ${o}.`)}}var Oi=1,Ma="document-root:0";function Oa(t){let e=2166136261;for(let n=0;n<t.length;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return`fnv1a32:${(e>>>0).toString(16).padStart(8,"0")}`}function Da(t){let e=structuredClone(t),n=r=>{if(!(r===null||typeof r!="object"||Object.isFrozen(r))){for(let i of Object.values(r))n(i);Object.freeze(r)}};return n(e),e}function G0(t){if(t instanceof Map)return t;let e=new Map;for(let n of t)e.set(n.id,n);return e}function V0(t){if(t.kind==="marker")return t.shapes;if(t.kind!=="symbol")return[];if(!t.variants)return t.shapes;let e=[...t.shapes];for(let n of Object.values(t.variants))e.push(...n);return e}function ly(t,e,n,r){let i=G0(n),o=new Set,s=[],a=[],c=u=>{if(typeof u!="string"||!u||o.has(u))return;let p=i.get(u);p&&(p.kind!=="symbol"&&p.kind!=="marker"||(o.add(u),s.push(p)))},l=u=>{a.push(u)},d=u=>{let p=u.state;if(!p)return;c(p.symbolId),c(p.markerStart),c(p.markerMid),c(p.markerEnd);let f=p.children;if(Array.isArray(f))for(let g of f)l(g);let m=p.symbolOverrides;if(m&&typeof m=="object"&&!Array.isArray(m))for(let[g,h]of Object.entries(m))!h||typeof h!="object"||Array.isArray(h)||l({id:g,type:"symbol-override",state:h})};for(let u of t)l(u);for(let u of e)c(u);for(;;){let u=a.shift();if(u){r(u),d(u);continue}let p=s.shift();if(!p)break;for(let f of V0(p))l(f)}}var j0=[],U0=[];function _a(t,e,n){ly(t,U0,e,n)}function Xd(t,e,n){ly(j0,t,e,n)}function H0(t,e){if(!t)return;let n=t,r=n.markerStart;typeof r=="string"&&r&&e(r);let i=n.markerMid;typeof i=="string"&&i&&e(i);let o=n.markerEnd;typeof o=="string"&&o&&e(o);let s=n.startEndpoint;typeof s=="string"&&s&&s!=="none"&&e(za(s));let a=n.endEndpoint;typeof a=="string"&&a&&a!=="none"&&e(za(a))}function za(t){return`line-marker-${t}`}var dy=new Set(["fillLibraryId","strokeLibraryId","markerStart","markerMid","markerEnd","symbolId"]);function W0(t,e,n){if(!t)return;let r=t,i=s=>{typeof s=="string"&&s&&n(s)};i(r.fillLibraryId),i(r.strokeLibraryId),i(r.markerStart),i(r.markerMid),i(r.markerEnd),i(r.symbolId);let o=r.filterLibraryIds;if(Array.isArray(o)&&o.length>0)for(let s of o)i(s);else Array.isArray(r.filters)&&r.filters.length>0&&n(`filter-${e}`);r.fillLibraryId||i(r.fillGradient?.id),r.strokeLibraryId||i(r.strokeGradient?.id)}function Di(t,e=[]){let n=new Set,r=new Set;return _a(t,e,i=>{let o=i.state;if(!o)return;typeof o.markerStart=="string"&&o.markerStart&&n.add(o.markerStart),typeof o.markerMid=="string"&&o.markerMid&&n.add(o.markerMid),typeof o.markerEnd=="string"&&o.markerEnd&&n.add(o.markerEnd);let s=o.startEndpoint,a=o.endEndpoint;typeof s=="string"&&s&&s!=="none"&&!o.markerStart&&r.add(s),typeof a=="string"&&a&&a!=="none"&&!o.markerEnd&&r.add(a)}),{ids:n,legacyEndpoints:r}}function K0(t,e){let{ids:n,legacyEndpoints:r}=Di(t,e);for(let i of r)n.add(za(i));return n}var X0=["validate","allocate-identities","document-fields","canonical-nodes","projections","references","commit","external-effects"];function Y0(t){let e=t.map((o,s)=>({node:o,index:s})),n=new Set(t.map(o=>o.id)),r=new Set,i=[];for(;e.length>0;){let s=e.filter(({node:a})=>a.parentId===null||!n.has(a.parentId)||r.has(a.parentId)).sort((a,c)=>a.node.sourceOrder-c.node.sourceOrder||a.index-c.index)[0];if(!s)throw new Error("Ingestion node hierarchy contains a parent cycle.");e.splice(e.indexOf(s),1),i.push(s.node),r.add(s.node.id)}return i}var Fa=class extends Error{diagnostics;constructor(e,n,r){super(e,{cause:r}),this.name="IngestApplicationError",this.diagnostics=n}};function q0(t,e){let n=o=>o==="id"||/(?:Id|Ids)$/.test(o)||o==="shapeInsideRef"||dy.has(o),r=(o,s=!1)=>{if(s){let l=e.get(o);if(l)return l}if(o.startsWith("#")){let l=e.get(o.slice(1));if(l)return`#${l}`}let a=o.replace(/url\(\s*(['"]?)#([^'"\s)]+)\1\s*\)/g,(l,d,u)=>{let p=e.get(u);return p?`url(${d}#${p}${d})`:l});if(!a.includes("<"))return a;let c=a;for(let[l,d]of e){let u=l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),p="(?:&quot;|&apos;|&#34;|&#39;|&#x22;|&#x27;)";c=c.replace(new RegExp(`(\\bid\\s*=\\s*["'])${u}(["'])`,"g"),`$1${d}$2`).replace(new RegExp(`(\\b(?:href|xlink:href)\\s*=\\s*["']#)${u}(["'])`,"g"),`$1${d}$2`).replace(new RegExp(`([uU][rR][lL]\\(\\s*(?:${p})?#)${u}((?:${p})?\\s*\\))`,"gu"),`$1${d}$2`)}return c},i=(o,s=!1)=>{if(Array.isArray(o)){for(let a=0;a<o.length;a++){let c=typeof o[a]=="string"?r(o[a],s):void 0;c!==void 0?o[a]=c:i(o[a],s)}return}if(!(o===null||typeof o!="object"))for(let[a,c]of Object.entries(o)){let l=n(a),d=typeof c=="string"?r(c,l):void 0;d!==void 0?o[a]=d:i(c,l)}};for(let o of t.nodes)i(o.serialized),i(o.groupPath,!0);i(t.documentFields),i(t.referenceEdges),i(t.clipMaskGroups)}function vr(t,e){if(e.injectFailureAfterStage===t)throw new Error(`Injected ingestion failure after ${t}.`)}function Z0(t){let e=[],n=(i,o)=>{typeof i=="string"&&i.length>0&&e.push([i,o])},r=t.documentFields;for(let i of r.library??[])n(i.id,"library-definition");for(let i of r.paintServerDefs??[])n(i.id,"paint-server-definition");for(let i of r.documentStyles??[])n(i.id,"document-style");for(let i of r.documentScripts??[])n(i.id,"document-script");for(let i of r.animationTimeline?.tracks??[]){n(i.id,"animation-track");for(let o of i.keyframes)n(o.id,"animation-keyframe")}for(let i of t.clipMaskGroups)n(i.id,"clip-mask-group");return e}function J0(t,e,n={}){let r=e.captureRollbackState(),i=structuredClone([...t.diagnostics]),o="validate";try{if(t.planVersion!==1)throw new Error(`Unsupported ingestion plan version ${t.planVersion}.`);if(t.diagnostics.some(u=>u.severity==="error"))throw new Error("Ingestion plan contains an error diagnostic.");if(n.warningPolicy==="reject"&&t.diagnostics.some(u=>u.severity==="warning"))throw new Error("Ingestion warnings were rejected by caller policy.");vr("validate",n),o="allocate-identities";let s=structuredClone(t),a=new Map,c=e.resolvePlanIdentity?.(Ma);c&&a.set(Ma,c);for(let u of s.nodes){if(a.has(u.planNodeId))throw new Error(`Duplicate plan node id ${u.planNodeId}.`);a.set(u.planNodeId,s.identityMode==="preserve"?u.planNodeId:e.allocateId(u.planNodeId,u.serialized.type))}for(let[u,p]of Z0(s))a.has(u)||a.set(u,s.identityMode==="preserve"?u:e.allocateId(u,p));q0(s,a);let l={idMap:a,addDiagnostic:u=>i.push(structuredClone(u))};e.preparePlan?.(s,l),vr("allocate-identities",n),o="document-fields";for(let[u,p]of Object.entries(s.documentFields)){let f=La(u,s.intent);f.action==="preserve-host"||f.action==="derived"||f.action==="exempt"||e.applyDocumentField(u,f,structuredClone(p),l)}vr("document-fields",n);let d=Y0(s.nodes.map(u=>({planNodeId:u.planNodeId,id:a.get(u.planNodeId),type:u.serialized.type,state:structuredClone(u.serialized.state),parentId:u.parentPlanNodeId?a.get(u.parentPlanNodeId)??null:null,sourceOrder:u.sourceOrder})));o="canonical-nodes";for(let u of d)e.createCanonicalNode(u,l);if(vr("canonical-nodes",n),o="projections",e.hydrateProjection)for(let u of d)e.hydrateProjection(u,l);return vr("projections",n),o="references",e.applyReferences?.(s,l),vr("references",n),o="commit",e.commit?.(l),vr("commit",n),o="external-effects",n.authorizeExternalEffects&&e.executeExternalEffects?.(s,l),vr("external-effects",n),{value:{createdIds:d.map(u=>u.id),idMap:Object.freeze(Object.fromEntries(a))},diagnostics:i}}catch(s){let a;if(o!=="validate")try{e.restoreRollbackState(r)}catch(u){a=u}let c=s instanceof Error?s.message:String(s),l=a===void 0?"":` Rollback also failed: ${a instanceof Error?a.message:String(a)}`,d={severity:"error",code:"application-rolled-back",source:t.source.kind,entrypoint:t.intent,message:`Ingestion rolled back after ${o}: ${c}.${l}`};throw i.push(d),new Fa(d.message,i,s)}}import{SaxesParser as Q0}from"saxes";var Y="http://www.w3.org/2000/svg",Oo=class extends Error{constructor(n,r,i){super(r);this.hostId=n;this.name="SvgXmlParserHostError",this.cause=i}hostId;cause};function Yd(t,e){let n=null;for(let r=e;r<t.length;r++){let i=t[r];if(n){i===n&&(n=null);continue}if(i==='"'||i==="'")n=i;else if(i===">")return r+1}return t.length}function fy(t){let e=0,n=t.toLowerCase(),r=[];for(;e<t.length;){let s=t.indexOf("<",e);if(s<0)break;if(t.startsWith("<!--",s)){let g=t.indexOf("-->",s+4);if(g<0)break;e=g+3;continue}if(t.startsWith("<![CDATA[",s)){let g=t.indexOf("]]>",s+9);if(g<0)break;e=g+3;continue}if(t.startsWith("<?",s)){let g=t.indexOf("?>",s+2);if(g<0)break;e=g+2;continue}let a=Yd(t,s+1),l=/^<\s*([^\s/>]+)/.exec(t.slice(s,a))?.[1]??"";if(l.split(":").at(-1)?.toLowerCase()!=="style"||t.slice(s,a).startsWith("</")){e=a;continue}let u=`</${l.toLowerCase()}`,p=n.indexOf(u,a);if(p<0)break;let f=t.slice(a,p);if(!f.includes("<")||f.includes("<![CDATA[")){e=Yd(t,p+2);continue}let m=`<![CDATA[${f.replaceAll("]]>","]]]]><![CDATA[>")}]]>`;r.push({start:a,end:p,value:m}),e=Yd(t,p+2)}if(r.length===0)return t;let i="",o=0;for(let s of r)i+=t.slice(o,s.start),i+=s.value,o=s.end;return i+t.slice(o)}var eP=256,tP=64*1024,nP=32*1024*1024,Jd=String.raw`[\p{L}_:][\p{L}\p{N}\p{M}_.:\-]*`,rP=new RegExp(`^${Jd}$`,"u"),iP="http://www.w3.org/1999/xlink",oP=/url\(\s*(['"]?)#([^'")\s]+)\1\s*\)/gu,sP=/(?:^|;)\s*([^\s;]+?)\.(?:begin|end|repeat\(\d+\))/gu,aP=new Set(["aria-labelledby","aria-describedby"]),cP=new RegExp(String.raw`<!ENTITY\s+(?!%)(${Jd})\s+(?:"([^"]*)"|'([^']*)')\s*>`,"gu"),uy=new RegExp(String.raw`&(#x[0-9A-Fa-f]+|#[0-9]+|${Jd});`,"gu"),lP=Object.freeze({amp:"&",apos:"'",gt:">",lt:"<",quot:'"'});function dP(t){let e=t.startsWith("#x")?Number.parseInt(t.slice(2),16):Number.parseInt(t.slice(1),10);return e===9||e===10||e===13||e>=32&&e<=55295||e>=57344&&e<=65533||e>=65536&&e<=1114111?String.fromCodePoint(e):null}function uP(t,e,n){let r=new Map;for(let a of e.matchAll(cP)){if(r.size>=eP)return;r.set(a[1],a[2]??a[3]??"")}let i=new Map,o=(a,c)=>{let l=lP[a];if(l!==void 0)return l;let d=i.get(a);if(d!==void 0)return d;let u=r.get(a);if(u===void 0||c.has(a))return null;let p=new Set(c);p.add(a);let f=!0,m=u.replace(uy,(g,h)=>{let y=h.startsWith("#")?dP(h):o(h,p);return y===null?(f=!1,""):y});return!f||m.length>tP?null:(i.set(a,m),m)};for(let a of r.keys())o(a,new Set);let s=0;for(let a of n.matchAll(uy)){let c=i.get(a[1]);if(c!==void 0&&(s+=c.length,s>nP))return}for(let[a,c]of i)t.ENTITIES[a]=c}function my(t){return t&&t.length>0?t:null}function pP(t,e){return{name:t.name,localName:t.local,prefix:t.prefix.length>0?t.prefix:null,namespaceUri:my(t.uri),value:t.value,span:e}}var gy={id:"saxes",parse(t){let e=[],n=[],r=[],i=0,o=[],s=0,a=0,c=new Q0({xmlns:!0,position:!0}),l=u=>{let p=n.at(-1);p?p.children.push(u):e.push(u)};c.on("error",u=>{r.push(u.message)}),c.on("opentagstart",()=>{i=t.lastIndexOf("<",Math.max(0,c.position-1)),o=[],s=c.position;let u=n.at(-1);u?u.contentOffset=i:a=i}),c.on("attribute",u=>{let p=t.indexOf(u.name,s),f=p>=0&&p<c.position?p:s;o.push({start:f,end:c.position}),s=c.position}),c.on("opentag",u=>{let p=Object.values(u.attributes).map((m,g)=>pP(m,o[g]??{start:i,end:c.position})),f={kind:"element",name:u.name,localName:u.local,prefix:u.prefix.length>0?u.prefix:null,namespaceUri:my(u.uri),attributes:p,children:[],span:{start:i,end:c.position},startOffset:i,contentOffset:c.position};l(f),n.push(f)}),c.on("closetag",()=>{let u=n.pop();if(!u)return;u.rawXml=t.slice(u.startOffset,c.position),u.span.end=c.position;let p=n.at(-1);p?p.contentOffset=c.position:a=c.position});let d=(u,p,f,m)=>{l({kind:u,value:p,span:{start:f,end:m}});let g=n.at(-1);g?g.contentOffset=m:a=m};c.on("text",u=>{let p=n.at(-1)?.contentOffset??a,f=t.lastIndexOf("<",Math.max(0,c.position-1)),m=f>=p?f:c.position;d("text",u,p,m)}),c.on("comment",u=>{let p=t.lastIndexOf("<!--",c.position),f=t.indexOf("-->",Math.max(0,p));d("comment",u,Math.max(0,p),f>=0?f+3:c.position)}),c.on("cdata",u=>{let p=t.lastIndexOf("<![CDATA[",c.position),f=t.indexOf("]]>",Math.max(0,p));d("cdata",u,Math.max(0,p),f>=0?f+3:c.position)}),c.on("processinginstruction",({target:u,body:p})=>{let f=t.lastIndexOf("<?",c.position),m=t.indexOf("?>",Math.max(0,f));d("processing-instruction",p.length>0?`${u} ${p}`:u,Math.max(0,f),m>=0?m+2:c.position)}),c.on("doctype",u=>{uP(c,u,t);let p=t.lastIndexOf("<!DOCTYPE",c.position),f=t.indexOf(">",Math.max(0,p));d("doctype",u,Math.max(0,p),f>=0?f+1:c.position)});try{c.write(t).close()}catch(u){r.push(u instanceof Error?u.message:String(u))}return r.length>0?{error:r[0]}:{nodes:e}}};function py(t,e,n){return{severity:"error",code:e,source:t.source,entrypoint:t.entrypoint,message:n,documentPath:"/",elementName:"svg"}}function qd(t,e,n,r){return{severity:"warning",code:e,source:t.source,entrypoint:t.entrypoint,message:n,capability:"source-envelope",...r}}function Zd(t,e,n){return t.attributes.find(r=>r.localName===e&&r.namespaceUri===n)??null}function Be(t){let e=Zd(t,"href",null);if(e)return{value:e.value,namespace:"svg2"};let n=Zd(t,"href",iP);return n?{value:n.value,namespace:"xlink"}:null}function fP(t){let e=[...t.children].reverse(),n="";for(;e.length>0;){let r=e.pop();r.kind==="text"||r.kind==="cdata"?n+=r.value:r.kind==="element"&&e.push(...[...r.children].reverse())}return n}function mP(t,e){let n=e.filter(g=>g.kind==="element"),r=new Map(n.map(g=>[g.sourceNodeId,g])),i=new Map,o=new Map,s=new Map,a=(g,h)=>{s.set(g.sourceNodeId,h);let y=g.children.filter(v=>v.kind==="element");o.set(g.sourceNodeId,Object.freeze(y));let b=new Map;for(let v of y){i.set(v.sourceNodeId,g);let I=(b.get(v.name)??0)+1;b.set(v.name,I),a(v,`${h}/${v.name}[${I}]`)}};a(t,`/${t.name}[1]`);let c=new Map,l=[];for(let g of n){let h=Zd(g,"id",null)?.value;if(h===void 0)continue;let y=c.get(h)??[],b=Object.freeze({authoredId:h,sourceNodeId:g.sourceNodeId,elementOrder:g.elementOrder,occurrenceIndex:y.length,primary:y.length===0,validXmlId:h.length>0&&!/\s/u.test(h)&&rP.test(h)});y.push(b),c.set(h,y),l.push(b)}let d=[],u=new Map,p=(g,h,y,b,v)=>{let I=c.get(b)??[],x=Object.freeze({sourceReferenceId:`reference:${d.length}`,fromSourceNodeId:g.sourceNodeId,channel:h,...v!==void 0?{attributeName:v}:{},authoredValue:y,targetAuthoredId:b,targetSourceNodeId:I[0]?.sourceNodeId??null,resolution:I.length===0?"missing":I.length===1?"resolved":"ambiguous-first"});d.push(x);let k=u.get(g.sourceNodeId)??[];k.push(x),u.set(g.sourceNodeId,k)},f=(g,h,y,b)=>{for(let v of y.matchAll(oP))p(g,h,y,v[2],b)};for(let g of n){let h=Be(g);h?.value.startsWith("#")&&h.value.length>1&&p(g,h.namespace==="svg2"?"href":"xlink-href",h.value,h.value.slice(1),h.namespace==="svg2"?"href":"xlink:href"),g.localName.toLowerCase()==="style"&&f(g,"stylesheet-url",fP(g));for(let y of g.attributes)if(y.namespaceUri===null){if(y.localName==="style"?f(g,"inline-style-url",y.value,y.name):y.value.includes("url(")&&f(g,"presentation-url",y.value,y.name),y.localName==="begin"||y.localName==="end")for(let b of y.value.matchAll(sP))p(g,"smil-syncbase",y.value,b[1],y.name);if(aP.has(y.localName))for(let b of y.value.trim().split(/\s+/u).filter(Boolean))p(g,"idref-list",y.value,b,y.name)}}for(let g of c.values())Object.freeze(g);for(let g of u.values())Object.freeze(g);return Object.freeze(n),Object.freeze(l),Object.freeze(d),Object.freeze({elements:n,idOccurrences:l,localReferences:d,element(g){return r.get(g)??null},parent(g){return i.get(g)??null},children(g){return o.get(g)??Object.freeze([])},sourcePath(g){return s.get(g)??"/"},occurrences(g){return c.get(g)??Object.freeze([])},resolveAuthoredId(g){return c.get(g)?.[0]??null},referencesFrom(g){return u.get(g)??Object.freeze([])}})}function gP(t){let e=n=>{if(!(n===null||typeof n!="object"||Object.isFrozen(n))){for(let r of Object.values(n))e(r);Object.freeze(n)}};return e(t),t}function ln(t,e,n=gy){let r=fy(t),i;try{i=n.parse(r)}catch(y){throw new Oo(n.id,`SVG XML parser host ${n.id} failed.`,y)}if(i===null||typeof i!="object"||!("error"in i)&&!("nodes"in i))throw new Oo(n.id,`SVG XML parser host ${n.id} returned no result.`);if("error"in i)return{value:null,diagnostics:[py(e,"malformed-source",`SVG XML parsing failed: ${i.error}`)]};let o=i.nodes.find(y=>y.kind==="element"),s=o?.namespaceUri===Y||o?.namespaceUri===null;if(!o||o.localName!=="svg"||!s)return{value:null,diagnostics:[py(e,"missing-svg-root","The XML document element is not an SVG root in the SVG namespace.")]};let a=[],c=0,l=0,d=y=>{let b=c++,v=`source:${b}`;if(y.kind!=="element"){let T={kind:y.kind,sourceNodeId:v,documentOrder:b,value:y.value,span:y.span};return a.push(T),T}let I=l++,x=[],k={kind:"element",sourceNodeId:v,documentOrder:b,elementOrder:I,name:y.name,localName:y.localName,prefix:y.prefix,namespaceUri:y.namespaceUri,attributes:y.attributes.map(T=>({...T})),children:x,span:y.span,...y.rawXml!==void 0?{rawXml:y.rawXml}:{}};return a.push(k),x.push(...y.children.map(d)),k},u=null,p=i.nodes.map(y=>{let b=d(y);return y===o&&(u=b),b});if(!u)throw new Error("The validated SVG document element was not projected.");let f=mP(u,a),m=new Map;for(let y of f.idOccurrences){let b=m.get(y.authoredId)??[];b.push(y.sourceNodeId),m.set(y.authoredId,b)}let g=Object.freeze(Object.fromEntries([...m].map(([y,b])=>[y,Object.freeze(b)]))),h=[];o.namespaceUri===null&&h.push(qd(e,"missing-svg-namespace","The namespace-less SVG root was accepted as compatibility input; authored SVG should declare the SVG namespace.",{documentPath:"/svg[1]",elementName:"svg"}));for(let[y,b]of m){let v=f.occurrences(y);if(v.length>1&&h.push(qd(e,"duplicate-svg-id",`SVG id ${JSON.stringify(y)} occurs ${b.length} times; references resolve to the first element-order occurrence.`,{documentPath:v.map(I=>f.sourcePath(I.sourceNodeId)).join(", "),elementName:f.element(v[0].sourceNodeId)?.name??"svg",sourceId:y})),v.some(I=>!I.validXmlId)){let I=v.find(x=>!x.validXmlId);h.push(qd(e,"invalid-svg-attribute",`SVG id ${JSON.stringify(y)} is not a non-empty XML Name without whitespace; it remains available for exact first-element reference processing.`,{documentPath:f.sourcePath(I.sourceNodeId),elementName:f.element(I.sourceNodeId)?.name??"svg",sourceId:y}))}}return{value:gP({root:u,documentNodes:p,nodes:a,idIndex:g,index:f,rawSource:t,parserSource:r}),diagnostics:h}}function C(t,e){return t.attributes.find(n=>n.namespaceUri===null&&n.localName===e)?.value??null}function yt(t,e){return t.attributes.some(n=>n.namespaceUri===null&&n.localName===e)}var Ba="[+-]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:[eE][+-]?\\d+)?",hP=new RegExp(`^\\s*(${Ba})(?:\\s*,\\s*|\\s+)(${Ba})(?:\\s*,\\s*|\\s+)(${Ba})(?:\\s*,\\s*|\\s+)(${Ba})\\s*$`);function at(t){let e=hP.exec(t);if(!e)return null;let[n,r,i,o]=e.slice(1).map(Number);return[n,r,i,o].every(Number.isFinite)?{x:n,y:r,width:i,height:o}:null}function yP(t){return t==="none"||/^x(Min|Mid|Max)Y(Min|Mid|Max)$/.test(t)}function Do(t){if(t==null)return{align:"xMidYMid",meetOrSlice:"meet"};let e=t.trim().split(/\s+/).filter(Boolean);return e.length<1||e.length>2||!yP(e[0])||e.length===2&&e[1]!=="meet"&&e[1]!=="slice"?{align:"xMidYMid",meetOrSlice:"meet"}:{align:e[0],meetOrSlice:e[1]==="slice"?"slice":"meet"}}function hy(t,e){return t==="none"?0:e==="x"?t.includes("xMax")?1:t.includes("xMid")?.5:0:t.includes("YMax")?1:t.includes("YMid")?.5:0}function yy(t,e){return typeof t=="number"&&Number.isFinite(t)?t:e}function Sy(t,e,n,r){return t==null?e??null:!Number.isFinite(t)||t<0?(r.push({code:"invalid-viewport-length",message:`Nested SVG ${n} ${String(t)} is invalid and falls back to auto (100%).`}),e??null):t}function SP(t,e){return Object.prototype.hasOwnProperty.call(t,e)&&t[e]!==void 0}function bP(t){let e=["viewBoxX","viewBoxY","viewBoxWidth","viewBoxHeight"],n=e.filter(i=>SP(t,i));return n.length===0?"absent":n.length!==e.length||!e.map(i=>t[i]).every(i=>typeof i=="number"&&Number.isFinite(i))?"partial":t.viewBoxWidth<0||t.viewBoxHeight<0?"negative-invalid":t.viewBoxWidth===0||t.viewBoxHeight===0?"zero-disabled":"valid"}function vP(t,e,n){let{align:r,meetOrSlice:i}=Do(n),o=t.width/e.viewBoxWidth,s=t.height/e.viewBoxHeight,a=t.x-e.viewBoxX*o,c=t.y-e.viewBoxY*s;if(r!=="none"){let l=i==="slice"?Math.max(o,s):Math.min(o,s),d=e.viewBoxWidth*l,u=e.viewBoxHeight*l;o=l,s=l,a=t.x+(t.width-d)*hy(r,"x")-e.viewBoxX*l,c=t.y+(t.height-u)*hy(r,"y")-e.viewBoxY*l}return ht(o,0,0,s,a,c)}function zo(t,e){let n=[],r=yy(t.x,0),i=yy(t.y,0),o=Sy(t.width,e?.width,"width",n),s=Sy(t.height,e?.height,"height",n),a=o===null||s===null?null:{x:r,y:i,width:o,height:s},c=bP(t);if((o===0||s===0)&&(c="zero-disabled"),c==="zero-disabled")return{status:c,renders:!1,frame:a,contentMatrix:null,childPercentBasis:null,diagnostics:n};if(c==="partial"?n.push({code:"invalid-viewbox",message:"Nested SVG viewBox is partial or non-finite and is ignored."}):c==="negative-invalid"&&n.push({code:"invalid-viewbox",message:"Nested SVG viewBox has a negative dimension and is ignored."}),c!=="valid")return{status:c,renders:!0,frame:a,contentMatrix:ht(1,0,0,1,r,i),childPercentBasis:a?{width:a.width,height:a.height}:null,diagnostics:n};if(!a)return n.push({code:"unresolved-viewport-size",message:"Nested SVG with a valid viewBox needs a parent viewport to resolve auto dimensions."}),{status:c,renders:!1,frame:null,contentMatrix:null,childPercentBasis:null,diagnostics:n};let l={viewBoxX:t.viewBoxX,viewBoxY:t.viewBoxY,viewBoxWidth:t.viewBoxWidth,viewBoxHeight:t.viewBoxHeight};return{status:c,renders:!0,frame:a,contentMatrix:vP(a,l,t.preserveAspectRatio),childPercentBasis:{width:l.viewBoxWidth,height:l.viewBoxHeight},diagnostics:n}}var xP=new Set(["animate","animatetransform","animatemotion","set"]),IP="http://www.w3.org/1999/xlink";function by(t,e){let n=C(t,"style");if(n){let r=n.replace(/\/\*[\s\S]*?\*\//g,""),i=new RegExp(`(?:^|;)\\s*${e}\\s*:\\s*([^;]*)`,"gi"),o=null,s;for(;(s=i.exec(r))!==null;)o=s[1];if(o!==null){let a=o.replace(/\s*!\s*important\s*$/i,"").trim(),c=gt(a);if(c&&c.value>=0&&(c.unit!==""||c.value===0))return a}}return C(t,e)}function wP(t,e){return{severity:"warning",code:"invalid-svg-attribute",source:t.source,entrypoint:t.entrypoint,message:e,documentPath:"/svg[1]/@viewBox",elementName:"svg",capability:"root-viewport-frame"}}function vy(t){for(let e of t.children)if(e.kind==="element"&&(e.localName.toLowerCase()==="view"||vy(e)))return!0;return!1}function kP(t,e){let n=t.attributes.find(i=>i.localName==="href"&&(i.namespaceUri===null||i.namespaceUri===IP))?.value;if(n===void 0)return!0;let r=C(e,"id");return r!==null&&n===`#${r}`}function Qd(t,e){let n=[],r=Wt(by(t,"width")),i=Wt(by(t,"height")),o=r!==void 0&&r>=0?r:void 0,s=i!==void 0&&i>=0?i:void 0,a=C(t,"preserveAspectRatio"),c=a&&a.trim().length>0?a.trim():void 0,l=yt(t,"viewBox"),d=C(t,"viewBox"),u=d!==null?at(d):null,p=u!==null&&u.width>=0&&u.height>=0?u:null;l&&!p&&n.push(wP(e,`Root SVG viewBox ${JSON.stringify(d)} is invalid per SVG 2 section 8.6 and was ignored.`));let f=t.children.some(v=>v.kind==="element"&&xP.has(v.localName.toLowerCase())&&kP(v,t)),m=p!==null||f||vy(t);if(p)return{value:{viewBoxX:p.x,viewBoxY:p.y,viewBoxWidth:p.width,viewBoxHeight:p.height,...o!==void 0?{width:o}:{},...s!==void 0?{height:s}:{},...c!==void 0?{preserveAspectRatio:c}:{},sizingMode:"explicit",targetedPasteWrapper:m},diagnostics:n};let g=o!==void 0,h=s!==void 0,y=g?o:300,b=h?s:150;return{value:{viewBoxX:0,viewBoxY:0,viewBoxWidth:y,viewBoxHeight:b,...g||h?{width:y,height:b}:{},...c!==void 0?{preserveAspectRatio:c}:{},sizingMode:g||h?"sized":"implicit",targetedPasteWrapper:m},diagnostics:n}}function PP(t){return t.localName.toLowerCase()==="view"&&(t.namespaceUri===Y||t.namespaceUri===null)}function TP(t,e,n,r){let i=C(e,"id");return{severity:"warning",code:"invalid-svg-attribute",source:n.source,entrypoint:n.entrypoint,message:`SVG viewBox ${JSON.stringify(r)} is invalid per SVG 2 section 8.6 and the view was ignored.`,documentPath:`${t.index.sourcePath(e.sourceNodeId)}/@viewBox`,elementName:"view",...i?{sourceId:i}:{},sourceNodeId:e.sourceNodeId,capability:"views"}}function RP(t){return Object.freeze(t.state),Object.freeze(t)}function eu(t,e){let n=[],r=[];for(let i of t.index.elements){if(!PP(i))continue;let o=C(i,"viewBox");if(o===null||o.trim().length===0)continue;let s=at(o);if(!s||s.width<0||s.height<0){r.push(TP(t,i,e,o));continue}let a={viewName:C(i,"id")??"",viewBoxX:s.x,viewBoxY:s.y,viewBoxWidth:s.width,viewBoxHeight:s.height},c=C(i,"preserveAspectRatio");c&&(a.viewPreserveAspectRatio=c);let l=C(i,"zoomAndPan");(l==="disable"||l==="magnify")&&(a.viewZoomAndPan=l);let d=C(i,"viewTarget");d&&(a.viewTarget=d),n.push(RP({sourceNodeId:i.sourceNodeId,elementOrder:i.elementOrder,parentSourceNodeId:t.index.parent(i.sourceNodeId)?.sourceNodeId??null,state:a}))}return{value:Object.freeze(n),diagnostics:Object.freeze(r.map(i=>Object.freeze(i)))}}function Iy(t){return t.localName.toLowerCase()==="svg"&&(t.namespaceUri===Y||t.namespaceUri===null)}function wy(t,e){let n=C(t,"style");if(!n)return null;let r=null;for(let i of Pi(n,";")){let[o,...s]=Pi(i,":");if(o?.trim().toLowerCase()!==e.toLowerCase())continue;let a=s.join(":").trim(),c=/\s*!\s*important\s*$/iu.test(a),l=a.replace(/\s*!\s*important\s*$/iu,"").trim();(!r||c||!r.important)&&(r={value:l,important:c})}return r}function CP(t,e){let n=wy(t,e);if(n){if(n.value.toLowerCase()==="auto")return{kind:"auto"};let r=gt(n.value);if(r&&r.value>=0)return{kind:"value",value:n.value}}return yt(t,e)?{kind:"value",value:C(t,e)??""}:{kind:"absent"}}function $P(t,e){let n=t.index.parent(e.sourceNodeId);for(;n;){let r=Wt(wy(n,"font-size")?.value??null);if(r!==void 0)return r;let i=Wt(C(n,"font-size"));if(i!==void 0)return i;n=t.index.parent(n.sourceNodeId)}return 16}function ky(t,e,n,r,i){let o=C(e,"id");return{severity:"warning",code:"invalid-svg-attribute",source:n.source,entrypoint:n.entrypoint,message:`Embedded SVG ${r} ${JSON.stringify(i)} is invalid and was ignored.`,documentPath:`${t.index.sourcePath(e.sourceNodeId)}/@${r}`,elementName:"svg",...o?{sourceId:o}:{},sourceNodeId:e.sourceNodeId,capability:"embedded-svg"}}function xy(t){let e=t.root,n=C(e,"viewBox"),r=n===null?null:at(n);if(r&&r.width>=0&&r.height>=0)return{width:r.width,height:r.height};let i=a=>{let c=CP(e,a);return c.kind==="value"?Wt(c.value):void 0},o=i("width"),s=i("height");return{width:o!==void 0&&o>=0?o:300,height:s!==void 0&&s>=0?s:150}}function NP(t,e){let n=t.index.parent(e.sourceNodeId);for(;n;){if(Iy(n))return n;n=t.index.parent(n.sourceNodeId)}return null}function Ga(t,e,n,r,i,o){if(!yt(e,n))return;let s=C(e,n)??"",a={percentBasis:n==="x"||n==="width"?r.width:r.height,viewportWidth:r.width,viewportHeight:r.height,fontSize:$P(t,e),rootFontSize:16},c=Re(s,a),l=(n==="width"||n==="height")&&(c??0)<0;if(c===void 0||l){o.push(ky(t,e,i,n,s));return}return c}function tu(t,e){let n=[],r=[],i=new Map([[t.root.sourceNodeId,xy(t)]]);for(let o of t.index.elements){if(!Iy(o)||o.sourceNodeId===t.root.sourceNodeId)continue;let s=NP(t,o),a=(s&&i.get(s.sourceNodeId))??xy(t),c={},l=Ga(t,o,"x",a,e,r),d=Ga(t,o,"y",a,e,r),u=Ga(t,o,"width",a,e,r),p=Ga(t,o,"height",a,e,r);l!==void 0&&(c.svgX=l),d!==void 0&&(c.svgY=d),u!==void 0&&(c.svgWidth=u),p!==void 0&&(c.svgHeight=p);let f=C(o,"viewBox"),m=f===null?null:at(f),g=m&&m.width>=0&&m.height>=0?m:null;f!==null&&!g&&r.push(ky(t,o,e,"viewBox",f)),g&&(c.svgViewBoxX=g.x,c.svgViewBoxY=g.y,c.svgViewBoxWidth=g.width,c.svgViewBoxHeight=g.height),yt(o,"preserveAspectRatio")&&(c.svgPreserveAspectRatio=C(o,"preserveAspectRatio")??"");let h=u??a.width,y=p??a.height;i.set(o.sourceNodeId,{width:g?.width??h,height:g?.height??y}),Object.freeze(c),n.push(Object.freeze({sourceNodeId:o.sourceNodeId,elementOrder:o.elementOrder,parentSourceNodeId:t.index.parent(o.sourceNodeId)?.sourceNodeId??null,state:c}))}return{value:Object.freeze(n),diagnostics:Object.freeze(r.map(o=>Object.freeze(o)))}}function AP(t,e){let n=Math.min(t.length,e.length);for(let r=0;r<n;r++){let i=t[r]-e[r];if(i!==0)return i}return t.length-e.length}function nu(t,e){return AP(t.orderKey,e.orderKey)||t.productIndex-e.productIndex||t.occurrenceId.localeCompare(e.occurrenceId)}function EP(t,e,n){if(n.namespaceUri!==Y||e.role==="definition")return null;let r=n.localName.toLowerCase();return r==="g"?"group":r==="a"?"hyperlink":r==="switch"?"switch":r!=="svg"||e.usePath.length===0&&n.sourceNodeId===t.root.sourceNodeId?null:"embedded-svg"}function Py(t,e,n,r,i,o){return Object.freeze({severity:"warning",code:i,source:r.source,entrypoint:r.entrypoint,capability:i==="empty-hyperlink-dropped"?"containers":"hierarchy",sourceId:C(n,"id")??void 0,sourceNodeId:n.sourceNodeId,occurrenceId:e.occurrenceId,elementName:n.name,documentPath:t.index.sourcePath(n.sourceNodeId),message:o})}function ru(t,e,n){let r=new Map(e.occurrences.map(h=>[h.occurrenceId,h])),i=new Map,o=new Map;for(let h of e.occurrences){let y=t.index.element(h.correspondingSourceNodeId);if(!y)throw new Error(`SVG occurrence ${h.occurrenceId} has no source element.`);i.set(h.occurrenceId,y);let b=EP(t,h,y);b&&o.set(h.occurrenceId,b)}let s=[],a=new Set;for(let h of n.materializedOccurrenceIds){if(a.has(h))continue;a.add(h);let y=r.get(h);if(!y)throw new Error(`Unknown materialized SVG occurrence ${h}.`);if(y.role==="definition")throw new Error(`Definition occurrence ${h} cannot be materialized in the scene.`);s.push(y)}s.sort(nu);for(let h of s){let y=h.parentOccurrenceId,b=new Set;for(;y;){if(b.has(y))throw new Error(`SVG occurrence ancestry contains a cycle at ${y}.`);b.add(y);let v=r.get(y);if(!v)throw new Error(`SVG occurrence ${h.occurrenceId} has unknown parent ${y}.`);v.role==="use-carrier"&&o.set(y,"group"),y=v.parentOccurrenceId}}let c=new Set;for(let h of s){let y=h.parentOccurrenceId,b=new Set;for(;y;){if(b.has(y))throw new Error(`SVG occurrence ancestry contains a cycle at ${y}.`);b.add(y);let v=r.get(y);if(!v)throw new Error(`SVG occurrence ${h.occurrenceId} has unknown parent ${y}.`);o.has(y)&&c.add(y),y=v.parentOccurrenceId}}let l=[],d=new Set,u=[...c].map(h=>r.get(h)).sort(nu),p=h=>{let y=h.parentOccurrenceId,b=new Set;for(;y;){if(b.has(y))return!1;b.add(y);let v=r.get(y);if(!v)return!1;if(o.get(y)==="hyperlink")return!0;y=v.parentOccurrenceId}return!1};for(let h of u){if(o.get(h.occurrenceId)==="hyperlink"&&p(h)){let b=i.get(h.occurrenceId);l.push(Py(t,h,b,n,"nested-hyperlink-flattened","Nested SVG hyperlinks are invalid; the inner hyperlink was flattened."));continue}d.add(h.occurrenceId)}for(let h of e.occurrences){if(o.get(h.occurrenceId)!=="hyperlink"||c.has(h.occurrenceId)||p(h))continue;let y=i.get(h.occurrenceId);l.push(Py(t,h,y,n,"empty-hyperlink-dropped","The SVG hyperlink has no materializable content and was dropped."))}let f=h=>{let y=h.parentOccurrenceId,b=new Set;for(;y;){if(b.has(y))throw new Error(`SVG occurrence ancestry contains a cycle at ${y}.`);if(b.add(y),d.has(y))return y;let v=r.get(y);if(!v)throw new Error(`SVG occurrence ${h.occurrenceId} has unknown parent ${y}.`);y=v.parentOccurrenceId}return null},m=u.filter(h=>d.has(h.occurrenceId)).map(h=>Object.freeze({occurrenceId:h.occurrenceId,sourceNodeId:h.correspondingSourceNodeId,kind:o.get(h.occurrenceId),parentContainerOccurrenceId:f(h),orderKey:Object.freeze([...h.orderKey])})),g=s.map(h=>Object.freeze({occurrenceId:h.occurrenceId,sourceNodeId:h.correspondingSourceNodeId,parentContainerOccurrenceId:f(h),orderKey:Object.freeze([...h.orderKey])}));return l.sort((h,y)=>{let b=h.occurrenceId?r.get(h.occurrenceId):void 0,v=y.occurrenceId?r.get(y.occurrenceId):void 0;return!b||!v?0:nu(b,v)}),Object.freeze({value:Object.freeze({containers:Object.freeze(m),placements:Object.freeze(g)}),diagnostics:Object.freeze(l)})}var Ry="http://www.w3.org/1999/xhtml",Cy="http://www.w3.org/1998/Math/MathML",MP=Object.freeze([Ry,Cy]),ou=Object.freeze(["systemLanguage","requiredExtensions","requiredFeatures"]),OP=/[\t\n\f\r ]+/,DP=/^[\t\n\f\r ]+|[\t\n\f\r ]+$/g;function iu(t,e){return C(t,e)}function zP(t){if(t.namespaceUri!==Y)return null;let e=iu(t,"systemLanguage"),n=iu(t,"requiredExtensions"),r=iu(t,"requiredFeatures");return e===null&&n===null&&r===null?null:Object.freeze({sourceNodeId:t.sourceNodeId,elementName:t.localName,systemLanguage:e,requiredExtensions:n,requiredFeatures:r})}function _P(t,e,n){return Object.freeze({severity:"warning",code:"required-features-dropped",source:n.source,entrypoint:n.entrypoint,capability:"conditional-processing",sourceId:C(e,"id")??void 0,sourceNodeId:e.sourceNodeId,elementName:e.name,documentPath:t.index.sourcePath(e.sourceNodeId),message:"Dropped requiredFeatures because SVG 2 removed the feature test."})}function su(t,e){let n=[],r=[];for(let a of t.index.elements){let c=zP(a);c&&(n.push(c),c.requiredFeatures!==null&&r.push(_P(t,a,e)))}let i=Object.freeze(n),o=new Map(i.map(a=>[a.sourceNodeId,a])),s=Object.freeze({candidates:i,condition:a=>o.get(a)??null});return Object.freeze({value:s,diagnostics:Object.freeze(r)})}function Ty(t){let e=t.replace(DP,"");if(e.length===0)return null;try{return new Intl.Locale(e).toString().toLowerCase()}catch{return null}}function FP(t,e){if(t.requiredExtensions!==null){let i=t.requiredExtensions.split(OP).filter(Boolean);if(i.length===0||!i.every(o=>e.supportedExtensions.has(o)))return!1}if(t.systemLanguage===null)return!0;let n=t.systemLanguage.split(",").map(Ty).filter(i=>i!==null);return n.length===0?!1:e.preferredLanguages.map(Ty).filter(i=>i!==null).some(i=>n.some(o=>o===i||o.startsWith(`${i}-`)))}var LP=new Set(["clippath","mask","lineargradient","radialgradient","pattern","filter","marker","symbol","view"]),BP=new Set(["clippath","mask","lineargradient","radialgradient","pattern","filter","marker","symbol"]),GP=/url\(\s*(['"]?)#([^'")\s]+)\1\s*\)/gu;function $y(t){let e=t.trim();return/^-?[_A-Za-z][\w:.-]*$/u.test(e)?e:e.replace(/[^\w:.-]+/gu,"_").replace(/^[^_A-Za-z]+/u,"")||"svg-resource"}function VP(t,e){let n=1;for(;e.has(`${t}-${n}`);)n++;let r=`${t}-${n}`;return e.add(r),r}function au(t,e,n){let r=t.trim(),i=r.length>0?$y(r):$y(e);return t===i&&!n.has(i)||!n.has(i)?(n.add(i),i):VP(i,n)}function Ny(t,e){return t.replace(GP,(n,r,i)=>{let o=e.get(i);return!o||o===i?n:`url(${r}#${o}${r})`})}function jP(t){let e=[...t.children].reverse(),n="";for(;e.length>0;){let r=e.pop();r.kind==="text"||r.kind==="cdata"?n+=r.value:r.kind==="element"&&e.push(...[...r.children].reverse())}return n}function Ay(t,e){switch(t.localName.toLowerCase()){case"clippath":return"clipPath";case"mask":return"mask";case"lineargradient":return"linearGradient";case"radialgradient":return"radialGradient";case"pattern":return"pattern";case"filter":return"filter";case"marker":return"marker";case"symbol":return"symbol";case"view":return"view";default:return e?"hrefTarget":"other"}}function UP(t){for(let e of t.elementIds)Object.freeze(e);for(let e of t.resourceIds)Object.freeze(e);for(let e of t.generatedIds)Object.freeze(e);for(let e of t.rewrites)Object.freeze(e);return Object.freeze(t.elementOrder),Object.freeze(t.elementIds),Object.freeze(t.resourceIds),Object.freeze(t.generatedIds),Object.freeze(t.rewrites),Object.freeze(t)}function cu(t,e={}){let n=t.index.elements,r=h=>{let y=t.index.parent(h.sourceNodeId);for(;y;){if(y.localName.toLowerCase()==="defs")return!0;y=t.index.parent(y.sourceNodeId)}return!1},i=new Set;for(let h of n)C(h,"id")!==null&&(LP.has(h.localName.toLowerCase())||r(h))&&i.add(h.sourceNodeId);for(let h of t.index.localReferences)h.channel!=="href"&&h.channel!=="xlink-href"||h.targetSourceNodeId&&i.add(h.targetSourceNodeId);let o=new Set(e.claimedIds??[]),s=new Map,a=new Map,c=[];for(let h of n){let y=C(h,"id");if(y===null)continue;let b=Ay(h,r(h)),v=au(y,b,o);s.has(y)||s.set(y,v),a.set(h.sourceNodeId,v),c.push({sourceNodeId:h.sourceNodeId,authoredId:y,liveId:v})}let l=[];for(let h of n){if(!i.has(h.sourceNodeId))continue;let y=C(h,"id");if(y===null)continue;let b=Ay(h,r(h)),v=a.get(h.sourceNodeId);v&&l.push({sourceNodeId:h.sourceNodeId,authoredId:y,sourceId:y.length>0?y:v,liveId:v,kind:b,restoreSourceId:v!==y&&BP.has(h.localName.toLowerCase())})}let d=[],u=new Set,p=0;for(let h of n){if(h.namespaceUri!=="http://www.w3.org/2000/svg")continue;let y=h.localName.toLowerCase();if(!["animate","animatemotion","animatetransform","discard","set"].includes(y)||Be(h))continue;let b=t.index.parent(h.sourceNodeId);if(!b||u.has(b.sourceNodeId))continue;let v=b,I=!1;for(;v;){if(v.namespaceUri==="http://www.w3.org/2000/svg"&&["clippath","mask"].includes(v.localName.toLowerCase())){I=!0;break}v=t.index.parent(v.sourceNodeId)}if(!I||C(b,"id"))continue;let k=`svgsketch-smil-target-${p++}`,T=au(k,"other",o);u.add(b.sourceNodeId),d.push({sourceNodeId:b.sourceNodeId,liveId:T,reason:"clip-mask-animation-target"})}let f=0,m=new Set(e.cssAnimationTargetSourceNodeIds??[]);for(let h of n){if(!m.has(h.sourceNodeId)||u.has(h.sourceNodeId)||C(h,"id"))continue;let y=`svgsketch-css-animation-target-${f++}`,b=au(y,"other",o);u.add(h.sourceNodeId),d.push({sourceNodeId:h.sourceNodeId,liveId:b,reason:"clip-mask-css-animation-target"})}let g=[];for(let h of n){if(h.localName.toLowerCase()==="style"){let b=jP(h),v=Ny(b,s);v!==b&&g.push({sourceNodeId:h.sourceNodeId,target:"text-content",value:v})}let y=Be(h);for(let b of h.attributes){if(b.localName==="id"&&b.namespaceUri===null||b.name==="data-source-id")continue;let v=b.value;if((y?.namespace==="svg2"?b.localName==="href"&&b.namespaceUri===null:y?.namespace==="xlink"?b.localName==="href"&&b.namespaceUri!==null:!1)&&v.startsWith("#")){let x=s.get(v.slice(1));x&&x!==v.slice(1)&&(v=`#${x}`)}else b.namespaceUri===null&&v.includes("url(")&&(v=Ny(v,s));v!==b.value&&g.push({sourceNodeId:h.sourceNodeId,target:"attribute",name:b.name,value:v})}}return UP({elementOrder:n.map(h=>h.sourceNodeId),elementIds:c,resourceIds:l,generatedIds:d,rewrites:g,liveIdForSourceId(h){return s.get(h)},liveIdForSourceNodeId(h){return a.get(h)}})}var Le=t=>({authority:"core",by:t}),Ey={geometry:Le("ingest/svg-leaf-geometry.ts"),containers:Le("ingest/svg-container-hierarchy.ts"),"source-order":Le("ingest/svg-source.ts and ingest/svg-use-occurrences.ts"),hierarchy:Le("ingest/svg-container-hierarchy.ts"),"root-viewport-frame":Le("ingest/root-frame.ts"),"common-presentation":Le("ingest/svg-style-cascade.ts and svg-property-semantics.ts"),"conditional-processing":Le("ingest/svg-conditional-processing.ts"),"authored-attributes":Le("ingest/svg-authored-attributes.ts"),gradients:Le("ingest/svg-gradients.ts"),patterns:Le("ingest/svg-patterns.ts"),filters:Le("ingest/svg-filters.ts"),"paint-server-definitions":Le("ingest/svg-paint-server-definitions.ts"),markers:Le("ingest/svg-markers.ts"),symbols:Le("ingest/svg-symbol-uses.ts"),"use-and-linked-references":Le("ingest/svg-use-occurrences.ts and ingest/svg-symbol-uses.ts"),"clip-definitions":Le("ingest/svg-clip-masks.ts"),"mask-definitions":Le("ingest/svg-clip-masks.ts"),"clip-mask-membership":Le("ingest/svg-clip-masks.ts"),"smil-animation":Le("ingest/svg-animations.ts and smil-value-syntax.ts"),"css-animation":Le("ingest/svg-animations.ts and css-animation-syntax.ts"),metadata:Le("ingest/svg-metadata.ts"),scripts:Le("ingest/svg-scripts.ts"),styles:Le("ingest/svg-style-cascade.ts"),"custom-properties":Le("ingest/svg-style-cascade.ts custom-property environments"),views:Le("ingest/svg-views.ts"),"embedded-svg":Le("ingest/svg-embedded-frames.ts"),fonts:Le("ingest/svg-external-effects.ts"),"external-assets":Le("ingest/svg-external-effects.ts")};function HP(t=Ea,e=Ey){if(t.length===0)throw new Error("SVG import capability roster must not be empty.");if(new Set(t).size!==t.length)throw new Error("SVG import capability roster contains duplicate features.");let n=new Set(t);for(let r of t){let i=e[r];if(!i)throw new Error(`${r} lacks an SVG import parser owner.`);if(i.authority!=="core")throw new Error(`${r} retains noncanonical editor parser authority.`);if(i.by.trim().length<8)throw new Error(`${r} lacks a substantive SVG import parser owner.`)}for(let r of Object.keys(e))if(!n.has(r))throw new Error(`Unknown SVG import capability ${r}.`)}var WP=64,KP=1e5,Va="http://www.w3.org/2000/svg",XP=new Set(["circle","ellipse","line","path","polygon","polyline","rect","text"]);function My(t,e){return t===void 0||!Number.isFinite(t)?e:Math.max(1,Math.floor(t))}var lu=new Set(["defs","clippath","mask","marker","pattern","lineargradient","radialgradient","filter","symbol"]);function YP(t,e){let n=Math.min(t.length,e.length);for(let r=0;r<n;r++){let i=t[r]-e[r];if(i!==0)return i}return t.length-e.length}function qP(t,e){return YP(t.orderKey,e.orderKey)||t.productIndex-e.productIndex||t.occurrenceId.localeCompare(e.occurrenceId)}function Oy(t,e,n){let r=e.map(i=>i.sourceReferenceId).join("/");return`occurrence:${r?`${r}/`:""}${t}:${n}`}function ZP(t,e){let n=Be(e);if(!n?.value.startsWith("#")||n.value.length<=1)return null;let r=n.namespace==="svg2"?"href":"xlink-href";return t.index.referencesFrom(e.sourceNodeId).find(i=>i.channel===r&&i.authoredValue===n.value)??null}function JP(t,e){let n=Be(e);if(!n||n.value.length===0||n.value==="#")return Object.freeze({useSourceNodeId:e.sourceNodeId,sourceReferenceId:null,targetSourceNodeId:null,status:"empty"});if(!n.value.startsWith("#"))return Object.freeze({useSourceNodeId:e.sourceNodeId,sourceReferenceId:null,targetSourceNodeId:null,status:"external"});let r=ZP(t,e),i=r?.targetSourceNodeId?t.index.element(r.targetSourceNodeId):null;return!r||!i?Object.freeze({useSourceNodeId:e.sourceNodeId,sourceReferenceId:r?.sourceReferenceId??null,targetSourceNodeId:null,status:"missing"}):i.namespaceUri!==Va?Object.freeze({useSourceNodeId:e.sourceNodeId,sourceReferenceId:r.sourceReferenceId,targetSourceNodeId:i.sourceNodeId,status:"invalid"}):Object.freeze({useSourceNodeId:e.sourceNodeId,sourceReferenceId:r.sourceReferenceId,targetSourceNodeId:i.sourceNodeId,status:"resolved"})}function QP(t,e){let n=e;for(;n&&n!==t.root;){if(lu.has(n.localName.toLowerCase()))return!0;n=t.index.parent(n.sourceNodeId)}return!1}function zi(t){return t.namespaceUri===Va&&t.localName.toLowerCase()==="use"}function eT(t,e){let n=new Map;for(let v of t.index.idOccurrences){let I=t.index.element(v.sourceNodeId);I&&n.set(I.sourceNodeId,I)}let r=new Map;for(let v of n.keys())r.set(v,new Set);for(let v of t.index.elements){if(v.namespaceUri!==Va||v.localName.toLowerCase()!=="use")continue;let I=e.get(v.sourceNodeId);if(I?.status!=="resolved"||!I.targetSourceNodeId||!n.has(I.targetSourceNodeId))continue;let x=v;for(;x;)n.has(x.sourceNodeId)&&r.get(x.sourceNodeId)?.add(I.targetSourceNodeId),x=t.index.parent(x.sourceNodeId)}let i=(v,I)=>(n.get(v)?.elementOrder??0)-(n.get(I)?.elementOrder??0),o=[...n.keys()].sort(i),s=new Map(o.map(v=>[v,[...r.get(v)??[]].sort(i)])),a=new Map(o.map(v=>[v,[]]));for(let[v,I]of s)for(let x of I)a.get(x)?.push(v);for(let v of a.values())v.sort(i);let c=[],l=new Set;for(let v of o){if(l.has(v))continue;l.add(v);let I=[{sourceNodeId:v,targetIndex:0}];for(;I.length>0;){let x=I[I.length-1],T=(s.get(x.sourceNodeId)??[])[x.targetIndex];if(T!==void 0){x.targetIndex++,l.has(T)||(l.add(T),I.push({sourceNodeId:T,targetIndex:0}));continue}c.push(x.sourceNodeId),I.pop()}}let d=[],u=new Set;for(let v=c.length-1;v>=0;v--){let I=c[v];if(u.has(I))continue;let x=[],k=[I];for(u.add(I);k.length>0;){let T=k.pop();x.push(T);let w=a.get(T)??[];for(let P=w.length-1;P>=0;P--){let N=w[P];u.has(N)||(u.add(N),k.push(N))}}x.sort(i),d.push(x)}let p=new Map;d.forEach((v,I)=>{v.forEach(x=>p.set(x,I))});let f=d.map(()=>new Set);for(let[v,I]of r){let x=p.get(v);for(let k of I){let T=p.get(k);x!==T&&f[x].add(T)}}let m=d.map(v=>n.get(v[0])?.elementOrder??Number.MAX_SAFE_INTEGER),g=(v,I)=>m[v]-m[I],h=d.map((v,I)=>I).sort(g),y=[],b=new Set;for(let v of h){if(b.has(v))continue;b.add(v);let I=[{componentIndex:v,dependencyIndex:0,dependencies:[...f[v]].sort(g)}];for(;I.length>0;){let x=I[I.length-1],k=x.dependencies[x.dependencyIndex];if(k!==void 0){x.dependencyIndex++,b.has(k)||(b.add(k),I.push({componentIndex:k,dependencyIndex:0,dependencies:[...f[k]].sort(g)}));continue}y.push(x.componentIndex),I.pop()}}return y.map(v=>{let I=d[v],x=I.length>1||(r.get(I[0])?.has(I[0])??!1);return Object.freeze({componentId:`definition-component:${I[0]}`,memberSourceNodeIds:Object.freeze([...I]),circular:x})})}function _i(t,e,n,r,i){return Object.freeze({severity:"warning",code:e,source:t.source,entrypoint:t.entrypoint,capability:"use-and-linked-references",sourceId:C(r,"id")??void 0,sourceNodeId:r.sourceNodeId,occurrenceId:i,elementName:r.name,message:n})}function du(t,e){let n=My(e.maxDepth,WP),r=My(e.maxOccurrences,KP),i=t.index.elements.filter(w=>w.namespaceUri===Va&&w.localName.toLowerCase()==="use").map(w=>JP(t,w)),o=new Map(i.map(w=>[w.useSourceNodeId,w])),s=[],a=new Map,c=new Map,l=[],d=[],u=[],p=new Map,f=new Set;for(let w of e.resourceRoots??[]){let P=`${w.capability}\0${w.sourceNodeId}`;if(f.has(P))continue;f.add(P);let N=t.index.element(w.sourceNodeId),R=[];if(N&&w.capability==="clip-path")for(let A of t.index.children(N.sourceNodeId)){if(!zi(A))continue;let O=o.get(A.sourceNodeId),G=O?.targetSourceNodeId?t.index.element(O.targetSourceNodeId):null;(O?.status!=="resolved"||!G||!XP.has(G.localName.toLowerCase()))&&(R.push(A.sourceNodeId),d.push(Object.freeze({severity:"warning",code:"invalid-svg-attribute",source:e.source,entrypoint:e.entrypoint,capability:"clip-definitions",sourceId:C(N,"id")??void 0,sourceNodeId:A.sourceNodeId,elementName:A.name,documentPath:t.index.sourcePath(A.sourceNodeId),message:"A clipPath child use must directly reference a path, text, or basic shape. The clipPath is ignored."})))}let $=Object.freeze({resourceRootSourceNodeId:w.sourceNodeId,capability:w.capability,status:R.length===0?"valid":"invalid",invalidUseSourceNodeIds:Object.freeze(R)});u.push($),p.has(w.sourceNodeId)||p.set(w.sourceNodeId,$)}let m=new Set,g=0,h=!1,y=(w,P,N,R,$)=>{let A=Oy(w.sourceNodeId,P,0),O=a.get(A);if(O)return O;let G=Object.freeze({occurrenceId:A,correspondingSourceNodeId:w.sourceNodeId,usePath:Object.freeze(P.map(M=>Object.freeze({...M}))),role:$,parentOccurrenceId:N,orderKey:Object.freeze([...R]),productIndex:0});return s.push(G),a.set(A,G),P.length===0?c.set(w.sourceNodeId,G):g++,G};for(let w of t.index.elements){let P=t.index.parent(w.sourceNodeId),N=P?Oy(P.sourceNodeId,[],0):null,R=zi(w)?"use-carrier":QP(t,w)?"definition":"source";y(w,[],N,[w.elementOrder],R)}let b=(w,P)=>{h||(h=!0,d.push(_i(e,"use-expansion-limit-exceeded",`SVG use expansion exceeded depth ${n} or ${r} shadow occurrences.`,w,P.occurrenceId)))},v=(w,P,N)=>{if(m.has(P.occurrenceId))return;m.add(P.occurrenceId);let R=Be(w),$=o.get(w.sourceNodeId);if(!$||$.status==="empty"){l.push({useOccurrenceId:P.occurrenceId,useSourceNodeId:w.sourceNodeId,targetSourceNodeId:null,status:"empty"}),d.push(_i(e,"unresolved-reference","The SVG use element has no local target.",w,P.occurrenceId));return}if($.status==="external"){l.push({useOccurrenceId:P.occurrenceId,useSourceNodeId:w.sourceNodeId,targetSourceNodeId:null,status:"external"}),d.push(_i(e,"unresolved-reference",`External SVG use target "${R?.value??""}" is not materialized by local import.`,w,P.occurrenceId));return}if($.status==="missing"){l.push({useOccurrenceId:P.occurrenceId,useSourceNodeId:w.sourceNodeId,targetSourceNodeId:null,status:"missing"}),d.push(_i(e,"unresolved-reference",`SVG use target "${R?.value??""}" does not exist.`,w,P.occurrenceId));return}if($.status==="invalid"){l.push({useOccurrenceId:P.occurrenceId,useSourceNodeId:w.sourceNodeId,targetSourceNodeId:$.targetSourceNodeId,status:"invalid"}),d.push(_i(e,"unresolved-reference",`SVG use target "${R?.value??""}" is outside the SVG namespace.`,w,P.occurrenceId));return}let A=$.targetSourceNodeId?t.index.element($.targetSourceNodeId):null;if(!A||!$.sourceReferenceId)return;let O={sourceReferenceId:$.sourceReferenceId,useSourceNodeId:w.sourceNodeId,targetSourceNodeId:A.sourceNodeId},G=[...P.usePath,O];if(N.has(A.sourceNodeId)){l.push({useOccurrenceId:P.occurrenceId,useSourceNodeId:w.sourceNodeId,targetSourceNodeId:A.sourceNodeId,status:"circular"}),d.push(_i(e,"circular-use-reference",`SVG use target "${R?.value??""}" closes a circular shadow-tree reference.`,w,P.occurrenceId));return}if(G.length>n||g>=r){l.push({useOccurrenceId:P.occurrenceId,useSourceNodeId:w.sourceNodeId,targetSourceNodeId:A.sourceNodeId,status:"limit"}),b(w,P);return}let M={useOccurrenceId:P.occurrenceId,useSourceNodeId:w.sourceNodeId,targetSourceNodeId:A.sourceNodeId,status:"resolved"};l.push(M);let V=()=>{M.status="limit",b(w,P)},K=new Set(N),X=(U,te,Z)=>{if(g>=r){V();return}K.add(U.sourceNodeId);let ne=zi(U)?"use-carrier":"shadow-instance",F=y(U,G,te,Z,ne);if(zi(U))v(U,F,K);else if(!lu.has(U.localName.toLowerCase())||U.localName.toLowerCase()==="symbol"){for(let j of t.index.children(U.sourceNodeId))if(X(j,F.occurrenceId,[...Z,j.elementOrder]),g>=r){V();break}}K.delete(U.sourceNodeId)};X(A,P.occurrenceId,[...P.orderKey,A.elementOrder])},I=(w,P)=>{if(lu.has(w.localName.toLowerCase()))return;let N=new Set(P);N.add(w.sourceNodeId);let R=c.get(w.sourceNodeId);if(zi(w)){v(w,R,P);return}for(let $ of t.index.children(w.sourceNodeId))I($,N)};I(t.root,new Set);let x=(w,P)=>{let N=new Set(P);N.add(w.sourceNodeId);let R=c.get(w.sourceNodeId);if(zi(w)){v(w,R,P);return}for(let $ of t.index.children(w.sourceNodeId))x($,N)};for(let w of e.resourceRoots??[]){if(p.get(w.sourceNodeId)?.status==="invalid")continue;let N=t.index.element(w.sourceNodeId);if(!N)continue;let R=new Set,$=t.index.parent(N.sourceNodeId);for(;$;)R.add($.sourceNodeId),$=t.index.parent($.sourceNodeId);x(N,R)}s.sort(qP);let k=l.map(w=>Object.freeze({...w})),T=eT(t,o);return Object.freeze(i),Object.freeze(s),Object.freeze(k),Object.freeze(T),Object.freeze(u),Object.freeze(d),Object.freeze({occurrences:s,sourceResolutions:i,resolutions:k,definitionComponents:T,resourcePolicies:u,diagnostics:d,occurrence(w){return a.get(w)??null},direct(w){return c.get(w)??null},sourceResolution(w){return o.get(w)??null},resourcePolicy(w){return p.get(w)??null}})}var q="all-svg-elements",Dy=[["alignment-baseline",!1,"auto",q],["baseline-shift",!1,"0",q],["clip",!1,"auto",q],["clip-path",!1,"none",q],["clip-rule",!0,"nonzero",q],["color",!0,"black",q],["color-interpolation",!0,"sRGB",q],["color-interpolation-filters",!0,"linearRGB",q],["color-rendering",!0,"auto",q],["cursor",!0,"auto",q],["direction",!0,"ltr",q],["display",!1,"inline",q],["dominant-baseline",!0,"auto",q],["fill",!0,"black",q],["fill-opacity",!0,"1",q],["fill-rule",!0,"nonzero",q],["filter",!1,"none",q],["flood-color",!1,"black",q],["flood-opacity",!1,"1",q],["font-family",!0,"serif",q],["font-feature-settings",!0,"normal",q],["font-kerning",!0,"auto",q],["font-size",!0,"medium",q],["font-size-adjust",!0,"none",q],["font-stretch",!0,"normal",q],["font-style",!0,"normal",q],["font-variant",!0,"normal",q],["font-variant-caps",!0,"normal",q],["font-variant-east-asian",!0,"normal",q],["font-variant-ligatures",!0,"normal",q],["font-variant-numeric",!0,"normal",q],["font-variant-position",!0,"normal",q],["font-weight",!0,"normal",q],["image-rendering",!0,"auto",q],["letter-spacing",!0,"normal",q],["lighting-color",!1,"white",q],["line-height",!0,"normal",q],["marker-end",!0,"none",q],["marker-mid",!0,"none",q],["marker-start",!0,"none",q],["mask",!1,"none",q],["mask-image",!1,"none",q],["opacity",!1,"1",q],["overflow",!1,"visible",q],["paint-order",!0,"normal",q],["pointer-events",!0,"auto",q],["shape-rendering",!0,"auto",q],["stop-color",!1,"black",q],["stop-opacity",!1,"1",q],["stroke",!0,"none",q],["stroke-dasharray",!0,"none",q],["stroke-dashoffset",!0,"0",q],["stroke-linecap",!0,"butt",q],["stroke-linejoin",!0,"miter",q],["stroke-miterlimit",!0,"4",q],["stroke-opacity",!0,"1",q],["stroke-width",!0,"1px",q],["text-anchor",!0,"start",q],["text-decoration",!1,"none",q],["text-rendering",!0,"auto",q],["text-transform",!0,"none","none"],["transform",!1,"none",q],["transform-box",!1,"view-box","none"],["transform-origin",!1,"50% 50%",q],["unicode-bidi",!1,"normal",q],["vector-effect",!1,"none",q],["visibility",!0,"visible",q],["word-spacing",!0,"normal",q],["writing-mode",!0,"horizontal-tb",q]],tT=new Map(Dy.map(([t,e,n,r="none"])=>[t,Object.freeze({name:t,inherited:e,initialValue:n,presentationAttribute:r})])),ja=Object.freeze(Dy.filter(t=>(t[3]??"none")!=="none").map(t=>t[0]));function Xr(t){return tT.get(t.toLowerCase())??null}function uu(t){return(Xr(t)?.presentationAttribute??"none")!=="none"}var pu=new Set(["circle","ellipse","image","line","path","polygon","polyline","rect","text"]),nT=new Set([...pu,"a","g","use"]),rT=new Set(["clippath","defs","filter","lineargradient","marker","mask","pattern","radialgradient","symbol"]),iT=new Set(["clippath","filter","marker","mask","pattern"]),oT=new Set(["defs"]),zy=new Set([...rT,"flowregion"]),sT=new Set(["class","clip-path","color","display","fill","fill-opacity","fill-rule","filter","mask","opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","visibility"]),aT=new Set(["data-shape-id","height","href","id","style","transform","width","x","xlink:href","xmlns","xmlns:xlink","y"]),cT=["animation","transition","-moz-animation","-moz-transition","-o-animation","-o-transition","-webkit-animation","-webkit-transition"],lT=new Set(["height","id","preserveaspectratio","refx","refy","viewbox","width","x","y"]);function xr(t){return t.localName.toLowerCase()}function Fy(t,e){let n=[],r=new Set,i=t.index.parent(e.sourceNodeId);for(;i&&!r.has(i.sourceNodeId);)r.add(i.sourceNodeId),n.push(i),i=t.index.parent(i.sourceNodeId);return n}function Ha(t,e,n){return Fy(t,e).some(r=>n.has(xr(r)))}function dT(t,e){let n=xr(e);return n==="symbol"?!0:Ha(t,e,oT)?n==="g"||n==="use"||pu.has(n):!1}function _y(t){let e=t.toLowerCase();return cT.some(n=>e===n||e.startsWith(`${n}-`))}function uT(t){let e={};for(let n of["x","y","width","height"])yt(t,n)&&(e[n]=C(t,n)??"");return Object.keys(e).length===0?null:Object.freeze(e)}function pT(t,e,n,r){let i=e;for(;i&&xr(i)!=="svg";)i=t.index.parent(i.sourceNodeId);let o=i?at(C(i,"viewBox")??""):null,s=i?Re(C(i,"width"),{}):void 0,a=i?Re(C(i,"height"),{}):void 0,c=o?.width??s,l=o?.height??a,d=Re(n.value(r,"font-size"),{viewportWidth:c,viewportHeight:l,percentBasis:16,fontSize:16,rootFontSize:16});return{viewportWidth:c,viewportHeight:l,fontSize:d??16,rootFontSize:16}}function fT(t,e){for(let n of Fy(t,e))switch(xr(n)){case"pattern":return C(n,"patternContentUnits")==="objectBoundingBox";case"clippath":return C(n,"clipPathUnits")==="objectBoundingBox";case"mask":return C(n,"maskContentUnits")==="objectBoundingBox";default:break}return!1}function Ua(t,e){if(t===null||t.trim()===""||t.trim().toLowerCase()==="auto")return e;let n=gt(t);return n?n.unit==="%"?n.value/100:n.unit===""?n.value:e:e}function mT(t,e,n,r){let i=fT(t,e),o=pT(t,e,r,n),s=C(e,"x"),a=C(e,"y"),c=i?Ua(s,0):Re(s,{...o,percentBasis:o.viewportWidth})??0,l=i?Ua(a,0):Re(a,{...o,percentBasis:o.viewportHeight})??0,d=C(e,"width"),u=C(e,"height"),p=d===null||d.trim()===""||d.trim().toLowerCase()==="auto"?null:i?Ua(d,0):Re(d,{...o,percentBasis:o.viewportWidth})??null,f=u===null||u.trim()===""||u.trim().toLowerCase()==="auto"?null:i?Ua(u,0):Re(u,{...o,percentBasis:o.viewportHeight})??null;return Object.freeze({authored:uT(e),x:c,y:l,width:p,height:f})}function gT(t,e,n){let r=C(t,"transform"),i=n.style(e)?.cascadedValues.transform?.value??null,o=r??i;if(o===null||o.trim()===""||o.trim().toLowerCase()==="none")return Object.freeze({authored:o,matrix:ht(1,0,0,1,0,0),valid:!0,pureTranslation:!0});let s=on(o),a=s!==null&&Math.abs(s[0]-1)<1e-6&&Math.abs(s[1])<1e-6&&Math.abs(s[2])<1e-6&&Math.abs(s[3]-1)<1e-6;return Object.freeze({authored:o,matrix:s,valid:s!==null,pureTranslation:a})}function hT(t,e,n){let r={};for(let s of t.attributes){let a=s.name;aT.has(a)||s.value===""||_y(a)||(r[a]=s.value)}let i=n.style(e.occurrenceId);for(let[s,a]of Object.entries(i?.cascadedValues??{}))s==="transform"||_y(s)||(r[s]=a.value);let o=e.parentOccurrenceId?n.style(e.parentOccurrenceId):null;for(let[s,a]of Object.entries(i?.resolvedValues??{})){if(r[s]!==void 0||!Xr(s)?.inherited||o?.resolvedValues[s]!==a)continue;o.cascadedValues[s]&&(r[s]=a)}return Object.freeze(r)}function yT(t){let e={};for(let n of t.attributes)n.name==="xmlns"||n.prefix==="xmlns"||n.namespaceUri===null&&lT.has(n.localName.toLowerCase())||(e[n.name]=n.value);return Object.freeze(e)}function ST(t){let e=yT(t),n=xr(t);return n==="g"||n==="symbol"?e:e.transform===void 0?Object.freeze({}):Object.freeze({transform:e.transform})}function bT(t,e){return t.find(n=>n.memberSourceNodeIds.includes(e))??null}function vT(t,e,n,r,i,o){let s=i.get(`${n.occurrenceId}\0${r.sourceNodeId}`);if(!s)return null;let a=bT(e.definitionComponents,r.sourceNodeId),c=o(s.occurrenceId),l=C(r,"viewBox");return Object.freeze({sourceNodeId:r.sourceNodeId,sourceId:C(r,"id"),defKind:xr(r)==="symbol"?"symbol":pu.has(xr(r))?"shape":"group",productKey:`symbol-product:${r.sourceNodeId}:${n.occurrenceId}`,productUseOccurrenceId:n.occurrenceId,productRootOccurrenceId:s.occurrenceId,contentOccurrenceIds:Object.freeze(c),componentId:a?.componentId??null,circular:a?.circular??!1,viewBox:l,parsedViewBox:l===null?null:at(l),preserveAspectRatio:C(r,"preserveAspectRatio"),x:C(r,"x"),y:C(r,"y"),width:C(r,"width"),height:C(r,"height"),refX:C(r,"refX"),refY:C(r,"refY"),rootAttributes:ST(r)})}function xT(t,e,n,r,i,o){if(r.usePath.length!==0||!i.valid||!nT.has(xr(n))||Ha(t,e,zy)||Ha(t,n,zy))return!1;for(let s of sT)if(yt(e,s)||o.style(r.occurrenceId)?.cascadedValues[s])return!1;return!0}function fu(t,e,n,r){let i=new Map,o=new Map;for(let f of e.occurrences){if(!f.parentOccurrenceId)continue;let m=`${f.parentOccurrenceId}\0${f.correspondingSourceNodeId}`;i.has(m)||i.set(m,f);let g=o.get(f.parentOccurrenceId)??[];g.push(f),o.set(f.parentOccurrenceId,g)}let s=new Map,a=f=>{let m=s.get(f);if(m)return m;let g=[],h=[...o.get(f)??[]].reverse(),y=new Set;for(;h.length>0;){let v=h.pop();if(y.has(v.occurrenceId))continue;y.add(v.occurrenceId),g.push(v.occurrenceId);let I=o.get(v.occurrenceId)??[];for(let x=I.length-1;x>=0;x--)h.push(I[x])}let b=Object.freeze(g);return s.set(f,b),b},c=[],l=[],d=new Map,u=new Map;for(let f of e.resolutions){let m=e.occurrence(f.useOccurrenceId),g=t.index.element(f.useSourceNodeId);if(!m||!g||g.namespaceUri!==Y)continue;let h=f.targetSourceNodeId?t.index.element(f.targetSourceNodeId):null,y=mT(t,g,m.occurrenceId,n),b=gT(g,m.occurrenceId,n),v=hT(g,m,n),I=f.status==="resolved"?"flattened":f.status,x=null;if(f.status==="resolved"&&h){let T=Ha(t,g,iT);if(dT(t,h)){let w=vT(t,e,m,h,i,a);w&&(c.push(w),d.set(w.productKey,w),T||(x=w.productKey,I="symbol-instance"))}else!T&&xT(t,g,h,m,b,n)&&(I="linked-reference")}let k=Object.freeze({useOccurrenceId:m.occurrenceId,useSourceNodeId:g.sourceNodeId,targetSourceNodeId:h?.sourceNodeId??null,targetElementName:h?.name??null,status:I,definitionProductKey:x,geometry:y,presentation:v,transform:b,orderKey:Object.freeze([...m.orderKey])});l.push(k),u.set(k.useOccurrenceId,k)}Object.freeze(c),Object.freeze(l);let p=Object.freeze([]);return Object.freeze({definitions:c,uses:l,diagnostics:p,definition(f){return d.get(f)??null},use(f){return u.get(f)??null}})}var IT=new Map([["lineargradient","gradient"],["radialgradient","gradient"],["pattern","pattern"],["filter","filter"],["marker","marker"],["clippath","clip-path"],["mask","mask"]]),Ly=new Map([["clip-path","clip-path"],["mask","mask-image"],["mask-image","mask-image"],["filter","filter"],["fill","paint"],["stroke","paint"],["marker","marker"],["marker-start","marker"],["marker-mid","marker"],["marker-end","marker"]]),wT=new Set(["animate","set"]),kT=new Set(["clippath","defs","desc","lineargradient","marker","mask","metadata","pattern","radialgradient","script","style","symbol","title"]);function By(t){return!t||t.namespaceUri!==Y?null:IT.get(t.localName.toLowerCase())??null}function Gy(t,e,n){if(!n||n.namespaceUri!==Y)return!1;let r=n.localName.toLowerCase();return t==="paint"||t==="smil-animated-resource"&&["fill","stroke"].includes(e??"")?r==="lineargradient"||r==="radialgradient"||r==="pattern":t==="filter"||t==="smil-animated-resource"&&e==="filter"?r==="filter":t==="marker"||t==="smil-animated-resource"&&e?.startsWith("marker")?r==="marker":t==="clip-path"||t==="smil-animated-resource"&&e==="clip-path"?r==="clippath":t==="mask-image"||t==="smil-animated-resource"&&(e==="mask"||e==="mask-image")?r==="mask":t==="gradient-template"?r==="lineargradient"||r==="radialgradient":t==="pattern-template"?r==="pattern":t==="filter-image"}function PT(t){let e=[...t.children].reverse(),n="";for(;e.length>0;){let r=e.pop();r.kind==="text"||r.kind==="cdata"?n+=r.value:r.kind==="element"&&e.push(...[...r.children].reverse())}return n}function Vy(t,e){let n=e;for(;n;){if(By(n))return n;n=t.index.parent(n.sourceNodeId)}return null}function jy(t,e,n){if(!n)return"consumer";if(e.sourceNodeId===n.sourceNodeId)return"resource-product";let r=e;for(;r&&r.sourceNodeId!==n.sourceNodeId;){if(kT.has(r.localName.toLowerCase()))return"parked";r=t.index.parent(r.sourceNodeId)}return r?"resource-product":"parked"}function TT(t){let e=[];for(let n of Hn(t,";")){let r=t.slice(n.start,n.end),i=Hn(r,":",!0);if(i.length<2)continue;let o=r.slice(i[0].start,i[0].end).trim().toLowerCase();if(!o)continue;let s=n.start+i[1].start,a=n.end;for(;s<a&&/\s/u.test(t[s]);)s++;for(;a>s&&/\s/u.test(t[a-1]);)a--;s!==a&&e.push({propertyName:o,valueStart:s,valueEnd:a})}return e}function Uy(t,e,n,r,i,o){let s=t.index.referencesFrom(e.sourceNodeId).find(a=>o.has(a.sourceReferenceId)||a.targetAuthoredId!==n||a.authoredValue!==r?!1:i===null||a.attributeName===i);return s&&o.add(s.sourceReferenceId),s??null}function RT(t,e,n){return(t.get(e)?.elementOrder??Number.MAX_SAFE_INTEGER)-(t.get(n)?.elementOrder??Number.MAX_SAFE_INTEGER)}function CT(t,e,n){let r=(b,v)=>RT(n,b,v),i=[...t].sort(r),o=new Map(i.map(b=>[b,[...e.get(b)??[]].sort(r)])),s=new Map(i.map(b=>[b,[]]));for(let[b,v]of o)for(let I of v)s.get(I)?.push(b);for(let b of s.values())b.sort(r);let a=[],c=new Set;for(let b of i){if(c.has(b))continue;c.add(b);let v=[{nodeId:b,targetIndex:0}];for(;v.length>0;){let I=v[v.length-1],x=o.get(I.nodeId)?.[I.targetIndex];x!==void 0?(I.targetIndex++,c.has(x)||(c.add(x),v.push({nodeId:x,targetIndex:0}))):(a.push(I.nodeId),v.pop())}}let l=[],d=new Set;for(let b=a.length-1;b>=0;b--){let v=a[b];if(d.has(v))continue;let I=[],x=[v];for(d.add(v);x.length>0;){let k=x.pop();I.push(k);let T=s.get(k)??[];for(let w=T.length-1;w>=0;w--){let P=T[w];d.has(P)||(d.add(P),x.push(P))}}I.sort(r),l.push(I)}let u=new Map;l.forEach((b,v)=>{b.forEach(I=>u.set(I,v))});let p=l.map(()=>new Set);for(let[b,v]of e){let I=u.get(b);if(I!==void 0)for(let x of v){let k=u.get(x);k!==void 0&&I!==k&&p[I].add(k)}}let f=l.map(b=>n.get(b[0])?.elementOrder??Number.MAX_SAFE_INTEGER),m=(b,v)=>f[b]-f[v],g=l.map((b,v)=>v).sort(m),h=[],y=new Set;for(let b of g){if(y.has(b))continue;y.add(b);let v=[{component:b,dependencyIndex:0,dependencies:[...p[b]].sort(m)}];for(;v.length>0;){let I=v[v.length-1],x=I.dependencies[I.dependencyIndex];x!==void 0?(I.dependencyIndex++,y.has(x)||(y.add(x),v.push({component:x,dependencyIndex:0,dependencies:[...p[x]].sort(m)}))):(h.push(I.component),v.pop())}}return h.map(b=>{let v=l[b];return Object.freeze({componentId:`resource-component:${v[0]}`,memberSourceNodeIds:Object.freeze([...v]),circular:v.length>1||(e.get(v[0])?.has(v[0])??!1)})})}function Hy(t,e){let n=t.index.occurrences(e),r=n[0]?.sourceNodeId??null;return{targetSourceNodeId:r,target:r?t.index.element(r):null,resolution:n.length===0?"missing":n.length===1?"resolved":"ambiguous-first"}}function Wa(t,e,n,r,i,o,s,a,c,l=n.length,d=null){let u=c??Ly.get(r);if(!u)return[];let p=Vy(t,e);return Wn(n.slice(s,l)).map((f,m)=>{let g=Hy(t,f.targetAuthoredId);return{sourceReferenceId:(i==="authored-direct"?Uy(t,e,f.targetAuthoredId,n,o,a):null)?.sourceReferenceId??null,fromSourceNodeId:e.sourceNodeId,occurrenceId:d,containingResourceSourceNodeId:p?.sourceNodeId??null,participation:jy(t,e,p),binding:i,kind:u,propertyName:r,attributeName:o,authoredValue:n,propertyValue:n.slice(s,l),tokenIndex:m,tokenStart:s+f.targetStart,tokenEnd:s+f.targetEnd,targetAuthoredId:f.targetAuthoredId,targetSourceNodeId:g.targetSourceNodeId,targetElementName:g.target?.localName??null,resolution:g.resolution,validity:g.resolution==="missing"?"missing":Gy(u,r,g.target)?"valid":"invalid-target",componentId:null}})}function mu(t,e,n,r){let i=Be(e);if(!i||!i.value.startsWith("#")||i.value.length<=1)return null;let o=i.value.slice(1),s=Hy(t,o),a=i.namespace==="svg2"?"href":"xlink:href",c=Uy(t,e,o,i.value,a,r),l=Vy(t,e);return{sourceReferenceId:c?.sourceReferenceId??null,fromSourceNodeId:e.sourceNodeId,occurrenceId:null,containingResourceSourceNodeId:l?.sourceNodeId??null,participation:jy(t,e,l),binding:"authored-direct",kind:n,propertyName:null,attributeName:a,authoredValue:i.value,propertyValue:i.value,tokenIndex:0,tokenStart:1,tokenEnd:i.value.length,targetAuthoredId:o,targetSourceNodeId:s.targetSourceNodeId,targetElementName:s.target?.localName??null,resolution:s.resolution,validity:s.resolution==="missing"?"missing":Gy(n,null,s.target)?"valid":"invalid-target",componentId:null}}function gu(t){let e=t.trim().toLowerCase();return Ly.has(e)?e:null}function $T(t,e){let n=[];for(let r of t.index.elements){if(r.namespaceUri!==Y)continue;let i=r.localName.toLowerCase();if(i==="lineargradient"||i==="radialgradient"){let o=mu(t,r,"gradient-template",e);o&&n.push(o)}else if(i==="pattern"){let o=mu(t,r,"pattern-template",e);o&&n.push(o)}else if(i==="feimage"){let o=mu(t,r,"filter-image",e);o&&n.push(o)}if(wT.has(i)){let o=gu(C(r,"attributeName")??"");if(o)for(let s of["values","from","to","by"]){let a=r.attributes.find(c=>c.namespaceUri===null&&c.localName===s);a&&n.push(...Wa(t,r,a.value,o,"authored-direct",a.name,0,e,"smil-animated-resource"))}continue}for(let o of r.attributes){if(o.namespaceUri!==null)continue;if(o.localName==="style"){for(let a of TT(o.value)){let c=gu(a.propertyName);c&&n.push(...Wa(t,r,o.value,c,"authored-direct",o.name,a.valueStart,e,void 0,a.valueEnd))}continue}let s=gu(o.localName);s&&n.push(...Wa(t,r,o.value,s,"authored-direct",o.name,0,e))}}return n}function NT(t,e,n){return e.flatMap(r=>{let i=t.index.element(r.fromSourceNodeId);if(!i)throw new Error(`Applied SVG resource declaration references unknown source node ${r.fromSourceNodeId}.`);return Wa(t,i,r.value,r.propertyName,"applied-css",null,0,n,void 0,r.value.length,r.occurrenceId??null)})}function AT(t){let e=[];for(let n of t.index.elements){if(n.namespaceUri!==Y||n.localName.toLowerCase()!=="style")continue;let r=PT(n);Wn(r).forEach((i,o)=>{e.push(Object.freeze({styleSourceNodeId:n.sourceNodeId,authoredValue:r,tokenIndex:o,tokenStart:i.targetStart,tokenEnd:i.targetEnd,targetAuthoredId:i.targetAuthoredId}))})}return e}function ET(t,e,n){if(t.validity==="valid")return null;let r=t.validity==="circular",i=t.validity==="missing";return Object.freeze({severity:"warning",code:r?"circular-resource-reference":"unresolved-reference",source:e.source,entrypoint:e.entrypoint,capability:t.kind,sourceNodeId:t.fromSourceNodeId,sourceId:n?C(n,"id")??void 0:void 0,elementName:n?.name,message:r?`Circular ${t.kind} reference to #${t.targetAuthoredId} is invalid.`:i?`${t.kind} reference #${t.targetAuthoredId} is unresolved.`:`${t.kind} reference #${t.targetAuthoredId} targets an invalid ${t.targetElementName??"element"}.`})}function hu(t,e){let n=new Map(t.index.elements.map(x=>[x.sourceNodeId,x])),r=t.index.elements.flatMap(x=>{let k=By(x);return k?[Object.freeze({sourceNodeId:x.sourceNodeId,kind:k,authoredId:C(x,"id")})]:[]}),i=new Set(r.map(x=>x.sourceNodeId)),o=new Set,s=[...$T(t,o),...NT(t,e.appliedDeclarations??[],o)],a=new Map(r.map(x=>[x.sourceNodeId,new Set]));for(let x of s)x.validity==="valid"&&x.participation==="resource-product"&&x.containingResourceSourceNodeId&&x.targetSourceNodeId&&i.has(x.targetSourceNodeId)&&a.get(x.containingResourceSourceNodeId)?.add(x.targetSourceNodeId);let c=CT(r.map(x=>x.sourceNodeId),a,n),l=new Map;for(let x of c)for(let k of x.memberSourceNodeIds)l.set(k,x);let d=s.map((x,k)=>{let T=x.containingResourceSourceNodeId?l.get(x.containingResourceSourceNodeId):void 0,w=x.targetSourceNodeId?l.get(x.targetSourceNodeId):void 0,P=!!(x.validity==="valid"&&T?.circular&&T===w);return Object.freeze({resourceReferenceId:`resource-reference:${k}`,...x,validity:P?"circular":x.validity,componentId:T?.componentId??null})}),u=new Map;for(let x of d){let k=u.get(x.fromSourceNodeId)??[];k.push(x),u.set(x.fromSourceNodeId,k)}let p=d.flatMap(x=>{let k=ET(x,e,n.get(x.fromSourceNodeId)??null);return k?[k]:[]}),f=new Map;for(let x of p){if(!x.sourceNodeId)continue;let k=f.get(x.sourceNodeId)??[];k.push(x),f.set(x.sourceNodeId,k)}let m=new Map(d.map(x=>[x.resourceReferenceId,x])),g=new Map;for(let x of d){if(!x.containingResourceSourceNodeId||x.participation!=="resource-product")continue;let k=g.get(x.containingResourceSourceNodeId)??[];k.push(x),g.set(x.containingResourceSourceNodeId,k)}let h=x=>x.validity==="valid"||x.validity==="circular",y=x=>Object.freeze([...new Set(x.flatMap(k=>f.get(k.fromSourceNodeId)??[]))]),b=x=>{let k=x.map(F=>{let j=m.get(F.resourceReferenceId);if(!j)throw new Error(`SVG resource edge ${F.resourceReferenceId} does not belong to this dependency plan.`);return j}),T=new Set,w=new Set,P=new Set,N=new Map,R=[],$=[],A=new Map,O=F=>{if(T.add(F.resourceReferenceId),!(!h(F)||!F.targetSourceNodeId)){if(i.has(F.targetSourceNodeId)){if(w.has(F.targetSourceNodeId))return;w.add(F.targetSourceNodeId),N.set(F.targetSourceNodeId,F.resourceReferenceId),R.push(F.targetSourceNodeId);return}F.kind!=="filter-image"||P.has(F.targetSourceNodeId)||(P.add(F.targetSourceNodeId),N.set(F.targetSourceNodeId,F.resourceReferenceId),$.push(F.targetSourceNodeId))}};for(k.forEach(O);R.length>0||$.length>0;){for(;R.length>0;){let F=R.shift();for(let j of g.get(F)??[])O(j)}for(;$.length>0;){let F=$.shift(),j=[],H=[F],oe=new Set;for(;H.length>0;){let re=H.pop();if(!oe.has(re)){oe.add(re);for(let xe of u.get(re)??[])xe.containingResourceSourceNodeId===null&&(j.push(xe),O(xe));H.push(...t.index.children(re).map(xe=>xe.sourceNodeId))}}A.set(F,j)}}let G=[],M=new Set,V=new Set,K=F=>{!h(F)||!F.targetSourceNodeId||(w.has(F.targetSourceNodeId)?X(F.targetSourceNodeId):P.has(F.targetSourceNodeId)&&U(F.targetSourceNodeId))},X=F=>{let j=`resource:${F}`;if(!(M.has(j)||V.has(j))){V.add(j);for(let H of g.get(F)??[])K(H);V.delete(j),M.add(j),G.push(Object.freeze({sourceNodeId:F,role:"resource",viaResourceReferenceId:N.get(F)??null}))}},U=F=>{let j=`fragment:${F}`;if(!(M.has(j)||V.has(j))){V.add(j);for(let H of A.get(F)??[])K(H);V.delete(j),M.add(j),G.push(Object.freeze({sourceNodeId:F,role:"referenced-fragment",viaResourceReferenceId:N.get(F)??null}))}};for(let F of k)K(F);let te=d.filter(F=>T.has(F.resourceReferenceId)),Z=G.flatMap(F=>F.role==="resource"?[F.sourceNodeId]:[]),ne=c.filter(F=>F.memberSourceNodeIds.some(j=>w.has(j)));return Object.freeze({edges:Object.freeze(te),components:Object.freeze(ne),resourceSourceNodeIds:Object.freeze(Z),materializations:Object.freeze(G),diagnostics:y(te)})};for(let x of u.values())Object.freeze(x);Object.freeze(r),Object.freeze(d),Object.freeze(c),Object.freeze(p);let v=Object.freeze(AT(t));return Object.freeze({resources:r,edges:d,unboundStylesheetReferences:v,components:c,diagnostics:p,direct(x){return u.get(x)??Object.freeze([])},closureFromEdges(x){return b(x)},resolvePropertyValue(x,k,T){return Object.freeze((u.get(x)??[]).filter(w=>w.propertyName===k&&w.propertyValue===T))},templateChain(x){let k=[],T=new Set,w=x;for(;w&&!T.has(w);){T.add(w);let P=(u.get(w)??[]).find(N=>N.fromSourceNodeId===w&&(N.kind==="gradient-template"||N.kind==="pattern-template"));if(!P||(k.push(P),!P.targetSourceNodeId||!i.has(P.targetSourceNodeId)||P.validity==="missing"||P.validity==="invalid-target"))break;w=P.targetSourceNodeId}return Object.freeze(k)},closure(x){let k=x.map(M=>n.get(M)).filter(M=>!!M),T=new Set(k.filter(M=>i.has(M.sourceNodeId)).map(M=>M.sourceNodeId)),w=new Set;for(let M of k){let V=[M];for(;V.length>0;){let K=V.pop();w.has(K.sourceNodeId)||(w.add(K.sourceNodeId),V.push(...t.index.children(K.sourceNodeId)))}}let P=new Set;for(let M of w){i.has(M)&&!T.has(M)&&P.add(M);for(let V of u.get(M)??[])V.validity==="valid"&&V.targetSourceNodeId&&i.has(V.targetSourceNodeId)&&!T.has(V.targetSourceNodeId)&&P.add(V.targetSourceNodeId)}let N=[...T,...P];for(;N.length>0;){let M=N.pop();for(let V of a.get(M)??[])T.has(V)||P.has(V)||(P.add(V),N.push(V))}let R=c.filter(M=>M.memberSourceNodeIds.some(V=>P.has(V))),$=R.flatMap(M=>M.memberSourceNodeIds.filter(V=>P.has(V))),A=new Set([...T,...P]),O=d.filter(M=>w.has(M.fromSourceNodeId)||M.containingResourceSourceNodeId!==null&&A.has(M.containingResourceSourceNodeId)),G=[...new Set(O.flatMap(M=>f.get(M.fromSourceNodeId)??[]))];return Object.freeze({edges:Object.freeze(O),components:Object.freeze(R),resourceSourceNodeIds:Object.freeze($),materializations:Object.freeze($.map(M=>Object.freeze({sourceNodeId:M,role:"resource",viaResourceReferenceId:null}))),diagnostics:Object.freeze(G)})}})}function MT(t,e,n){let r=e.flatMap(s=>{let a=n.get(s.resourceReferenceId);if(a===void 0)return[];if(s.authoredValue!==t)throw new Error(`Resource edge ${s.resourceReferenceId} does not belong to the supplied value.`);return[{start:s.tokenStart,end:s.tokenEnd,replacement:a}]});r.sort((s,a)=>a.start-s.start||a.end-s.end);let i=t,o=t.length;for(let s of r){if(s.start<0||s.end<s.start||s.end>o)throw new Error("Overlapping or invalid SVG resource reference rewrite spans.");i=`${i.slice(0,s.start)}${s.replacement}${i.slice(s.end)}`,o=s.start}return i}var OT="http://www.w3.org/2000/xmlns/",DT="http://www.w3.org/XML/1998/namespace",Wy="http://www.w3.org/1999/xlink",zT=new Set(["class","id","lang","role","tabindex","xml:base","xml:lang","xml:space"]),_T=new Set(["cx","cy","d","dx","dy","height","inline-size","pathlength","points","r","rx","ry","shape-inside","textlength","width","x","x1","x2","y","y1","y2"]),FT=new Set(["crossorigin","decoding","href","preserveaspectratio","refx","refy","requiredextensions","requiredfeatures","systemlanguage","target","type","viewbox","zoomandpan"]);function LT(t,e,n,r){let i=e.toLowerCase(),o=n.toLowerCase();return r===OT||i==="xmlns"||i.startsWith("xmlns:")?"namespace":r!==null&&r!==DT&&r!==Wy||t!==Y&&t!==null?"foreign":zT.has(i)?"metadata":i.startsWith("aria-")?"aria":i.startsWith("data-")?"data":/^on[a-z]/u.test(i)?"event-handler":ou.some(s=>s.toLowerCase()===i)?"conditional":i==="style"?"style":r===null&&uu(i)?"presentation":r===null&&_T.has(o)?"geometry":r===Wy||r===null&&FT.has(o)?"element-specific":"passthrough"}function yu(t){let e=t.index.elements.flatMap(i=>i.attributes.map((o,s)=>Object.freeze({sourceNodeId:i.sourceNodeId,attributeOrder:s,name:o.name,localName:o.localName,prefix:o.prefix,namespaceUri:o.namespaceUri,value:o.value,span:o.span,classification:LT(i.namespaceUri,o.name,o.localName,o.namespaceUri)}))),n=Object.freeze(e),r=new Map;for(let i of n){let o=r.get(i.sourceNodeId)??[];o.push(i),r.set(i.sourceNodeId,o)}for(let[i,o]of r)r.set(i,Object.freeze(o));return Object.freeze({attributes:n,forElement:i=>r.get(i)??Object.freeze([])})}import{compile as BT}from"css-select";import{AttributeAction as Zy,SelectorType as Xn,parse as Jy}from"css-what";import{generate as GT,lexer as VT,parse as Qy}from"css-tree";function Ka(t,e){return`${t}\0${e}`}function jT(t,e){let n=e.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&");return new RegExp(`var\\(\\s*${n}(?:\\s*[,)]|\\s)`,"u").test(t)}function wu(t){let e=[];for(let a of t.rules)for(let c of a.declarations)c.propertyName.startsWith("--")&&e.push({name:c.propertyName,value:c.value});for(let a of t.elements)for(let[c,l]of Object.entries(a.inlineDeclarations))c.startsWith("--")&&e.push({name:c,value:l});let n=new Map;for(let a of e){let c=n.get(a.name)??new Set;c.add(a.value),n.set(a.name,c)}let r=new Set;for(let a of t.elements)for(let[c,l]of Object.entries(a.customProperties))Object.entries(a.specifiedValues).some(([u,p])=>!u.startsWith("--")&&jT(p,c))&&r.add(Ka(c,l));let i=new Map,o={},s=new Map;for(let a of e){let c=Ka(a.name,a.value);if(i.has(c))continue;let l=n.get(a.name)?.size??0,d=t.elements.some(m=>m.inlineDeclarations[a.name]===a.value);if(l>1&&!r.has(c)&&!d)continue;let u=a.name.slice(2),p=s.get(u)??1,f=p===1?u:`${u}-${p}`;s.set(u,p+1),i.set(c,f),o[f]=a.value}return Object.freeze({variableNameByPair:i,variables:Object.freeze(o),assignedName:(a,c)=>i.get(Ka(a,c))??null,rewriteValue(a,c){let l=t.style(a);return!l||!c.includes("var(")?c:c.replace(/var\(\s*(--[A-Za-z_][A-Za-z0-9_-]*)/gu,(d,u)=>{let p=l.customProperties[u];if(p===void 0)return d;let f=i.get(Ka(u,p));return f?`var(--${f}`:d})}})}var eS="\0svgsketch-element-namespace",bu="\0svgsketch-attribute-namespace\0",UT=new Set(["clip-path","mask","mask-image","filter","fill","stroke","marker","marker-start","marker-mid","marker-end"]),tS=new Set(["inherit","initial","unset","revert","revert-layer"]),Li=Object.freeze({a:0,b:0,c:0});function Mn(t){return t?.children?.toArray()??[]}function wr(t){return typeof t=="string"?t:t?GT(t):""}function vu(t,e){let n=Math.max(t.length,e.length);for(let r=0;r<n;r++){let i=(t[r]??-1)-(e[r]??-1);if(i!==0)return i}return 0}function nS(t,e){return t.a-e.a||t.b-e.b||t.c-e.c}function Fi(t,e){return{a:t.a+e.a,b:t.b+e.b,c:t.c+e.c}}function _o(t){return t.reduce((e,n)=>nS(n,e)>0?n:e,Li)}function xu(t){let e=Li;for(let n of t){if(n.type===Xn.Tag||n.type===Xn.PseudoElement){e=Fi(e,{a:0,b:0,c:1});continue}if(n.type===Xn.Attribute){let i=n.name==="id"&&n.action===Zy.Equals&&n.ignoreCase==="quirks";e=Fi(e,i?{a:1,b:0,c:0}:{a:0,b:1,c:0});continue}if(n.type!==Xn.Pseudo)continue;let r=n.name.toLowerCase();if(r!=="where"){if((r==="is"||r==="not"||r==="has")&&Array.isArray(n.data)){e=Fi(e,_o(n.data.map(i=>xu(i))));continue}if((r==="nth-child"||r==="nth-last-child")&&typeof n.data=="string"){let i=Li,o=/\bof\s+(.+)$/iu.exec(n.data);if(o)try{i=_o(Jy(o[1]).map(xu))}catch{i=Li}e=Fi(Fi(e,{a:0,b:1,c:0}),i);continue}e=Fi(e,{a:0,b:1,c:0})}}return e}function HT(t){return{type:Xn.Attribute,name:eS,action:Zy.Equals,value:t,namespace:null,ignoreCase:!1}}function Ky(t,e){if(t==="")return"";let n=e.get(t);if(n===void 0)throw new Error(`Unknown CSS namespace prefix ${t}.`);return n}function rS(t,e){let n=[];for(let r of t){if(r.type===Xn.Tag||r.type===Xn.Universal){let i={...r,namespace:null};n.push(i);let o=r.namespace??(e.has("")?"":null);o!==null&&o!=="*"&&n.push(HT(Ky(o,e)));continue}if(r.type===Xn.Attribute&&r.namespace!==null){if(r.namespace==="*")throw new Error("Wildcard attribute namespaces require an explicit namespace prefix.");let i=Ky(r.namespace,e);n.push({...r,name:`${bu}${i}\0${r.name}`,namespace:null});continue}if(r.type===Xn.Pseudo&&Array.isArray(r.data)&&["is","where","not","has"].includes(r.name.toLowerCase())){n.push({...r,data:r.data.map(i=>rS(i,e))});continue}n.push({...r})}return n}function WT(t){return t.children.filter(e=>e.kind!=="element").map(e=>e.value).join("")}function KT(t,e){let n=new Map;for(let o of e.occurrences){let s=t.index.element(o.correspondingSourceNodeId);s&&n.set(o.occurrenceId,{kind:"element",occurrence:o,element:s,parent:null,children:[]})}let r=[];for(let o of n.values()){let s=o.occurrence.parentOccurrenceId?n.get(o.occurrence.parentOccurrenceId)??null:null;o.parent=s,s?s.children.push(o):r.push(o);for(let a of o.element.children)a.kind!=="element"&&o.children.push({kind:"text",value:a.value,parent:o})}let i=(o,s)=>o.kind==="text"||s.kind==="text"?o.kind===s.kind?0:o.kind==="text"?1:-1:vu(o.occurrence.orderKey,s.occurrence.orderKey);for(let o of n.values())o.children.sort(i);return r.sort((o,s)=>vu(o.occurrence.orderKey,s.occurrence.orderKey)),{roots:Object.freeze(r),byOccurrenceId:n}}function iS(t){return t.kind==="text"?t.value:t.children.map(iS).join("")}function Ya(t){return t.kind==="text"?[]:[t,...t.children.flatMap(Ya)]}function XT(t){let e=new Set(t);return t.filter(n=>{let r=n.parent;for(;r;){if(e.has(r))return!1;r=r.parent}return!0})}function Xy(t,e){if(e===eS)return t.element.namespaceUri??"";if(e.startsWith(bu)){let[n,r]=e.slice(bu.length).split("\0");return t.element.attributes.find(i=>(i.namespaceUri??"")===n&&i.localName===r)?.value}return t.attributeOverrides&&Object.prototype.hasOwnProperty.call(t.attributeOverrides,e)?t.attributeOverrides?.[e]??void 0:t.element.attributes.find(n=>n.namespaceUri===null&&n.localName===e)?.value}function YT(t){return{adapter:{isTag:n=>n.kind==="element",existsOne:(n,r)=>r.some(i=>Ya(i).some(n)),getAttributeValue:Xy,getChildren:n=>n.kind==="element"?n.children:[],getName:n=>n.element.localName,getParent:n=>n.parent,getSiblings:n=>n.parent?.children??[n],prevElementSibling:n=>{let r=n.parent?.children??[],i=r.indexOf(n);for(let o=i-1;o>=0;o--)if(r[o].kind==="element")return r[o];return null},getText:iS,hasAttrib:(n,r)=>Xy(n,r)!==void 0,removeSubsets:XT,findAll:(n,r)=>r.flatMap(Ya).filter(n),findOne:(n,r)=>r.flatMap(Ya).find(n)??null,equals:(n,r)=>n===r,isHovered:n=>t.evaluateStatefulPseudo?.(n.occurrence.occurrenceId,"hover")===!0,isVisited:n=>t.evaluateStatefulPseudo?.(n.occurrence.occurrenceId,"visited")===!0,isActive:n=>t.evaluateStatefulPseudo?.(n.occurrence.occurrenceId,"active")===!0},xmlMode:!0,lowerCaseAttributeNames:!1,lowerCaseTags:!1,cacheResults:!0}}function qT(t,e,n){try{let i=Jy(t).map(o=>{let s=rS(o,e),a=BT([s],n);return Object.freeze({matches:c=>a(c),specificity:Object.freeze(xu(o))})});return Object.freeze(i)}catch{return null}}function ZT(t){let e=[],n=0,r=null,i=!1,o=0,s=a=>{let c=t.slice(n,a).trim();c&&e.push(c)};for(let a=0;a<t.length;a++){let c=t[a];if(r){i?i=!1:c==="\\"?i=!0:c===r&&(r=null);continue}if(c==='"'||c==="'"){r=c;continue}c==="("?o++:c===")"?o=Math.max(0,o-1):o===0&&(/[\t\n\f\r ]/u.test(c)||c==="/")&&(s(a),c==="/"&&e.push("/"),n=a+1)}return s(t.length),e}function JT(t){let e=ZT(t),n=/^(?:xx-small|x-small|small|medium|large|x-large|xx-large|xxx-large|larger|smaller|(?:\d*\.)?\d+(?:%|[a-z]+))$/iu,r=e.findIndex(u=>n.test(u));if(r<0)return null;let i="normal",o="normal",s="normal",a="normal";for(let u of e.slice(0,r)){let p=u.toLowerCase();p==="italic"||p==="oblique"?i=u:p==="small-caps"?o=u:p==="bold"||p==="bolder"||p==="lighter"||/^\d{1,4}$/u.test(p)?s=u:/^(?:ultra-condensed|extra-condensed|condensed|semi-condensed|semi-expanded|expanded|extra-expanded|ultra-expanded)$/u.test(p)&&(a=u)}let c=r+1,l="normal";e[c]==="/"&&(l=e[c+1]??"normal",c+=2);let d=e.slice(c).join(" ").trim();return d?Object.freeze({"font-style":i,"font-variant":o,"font-weight":s,"font-stretch":a,"font-size":e[r],"line-height":l,"font-family":d}):null}function QT(t){let e=t.propertyName;if(e==="marker")return["marker-start","marker-mid","marker-end"].map(n=>({...t,propertyName:n}));if(e==="font"){let n=JT(t.value);return n?Object.entries(n).map(([r,i])=>({...t,propertyName:r,value:i,authoredValue:i})):[]}return e==="all"&&tS.has(t.value.toLowerCase())?ja.map(n=>({...t,propertyName:n})):[t]}function eR(t,e){let n=e.trim().toLowerCase();if(t==="color-rendering")return n==="auto"||n==="optimizespeed"||n==="optimizequality";if(t==="color-interpolation")return n==="auto"||n==="srgb"||n==="linearrgb";if(t!=="clip-path")return!1;if(tS.has(n)||n==="none")return!0;let r="(?:fill-box|stroke-box|view-box|content-box|border-box|margin-box|padding-box)",i="(?:inset|circle|ellipse|polygon|path|shape|rect|xywh)\\([\\s\\S]*\\)";return new RegExp(`^(?:url\\([\\s\\S]*\\)|${i}(?:\\s+${r})?|${r}(?:\\s+${i})?)$`,"iu").test(e.trim())}function ku(t){let e;try{e=Qy(t,{context:"declarationList",positions:!0})}catch{return{declarations:Object.freeze([]),raw:Object.freeze({})}}let n=[],r={};for(let[i,o]of Mn(e).entries()){if(o.type!=="Declaration"||typeof o.property!="string"||!o.value)continue;let s=o.property,a=s.startsWith("--")?s:s.toLowerCase(),c=typeof o.value!="string"&&o.value.loc?t.slice(o.value.loc.start.offset,o.value.loc.end.offset).trim():wr(o.value).trim();r[a]=c;let l=a.startsWith("--"),d=/(?:^|[^-_a-z0-9])var\(/iu.test(c);if(!(l||d||VT.matchProperty(a,o.value).matched||eR(a,c)))continue;let p={propertyName:a,authoredPropertyName:s,value:c,authoredValue:c,important:!!o.important,order:i};n.push(...QT(p))}return{declarations:Object.freeze(n),raw:Object.freeze(r)}}function tR(t){if(!t)return Object.freeze({values:Object.freeze({}),importantProperties:Object.freeze([])});let e=ku(t),n=new Map;for(let o of e.declarations)n.get(o.propertyName)?.important&&!o.important||n.set(o.propertyName,o);let r={...e.raw},i=[];for(let[o,s]of n)r[o]=s.value,s.important&&i.push(o);return Object.freeze({values:Object.freeze(r),importantProperties:Object.freeze(i)})}function Xa(t,e){let n=ku(t),r=n.declarations.map((i,o)=>Object.freeze({...i,declarationId:`${e.ruleId??e.sourceNodeId}:${e.origin}:${i.order}:${o}`,sourceNodeId:e.sourceNodeId,origin:e.origin,sourceOrder:Object.freeze([...e.sourceOrder,i.order,o]),ruleId:e.ruleId,layerRank:e.layerRank}));return{templates:Object.freeze(r),raw:n.raw}}function Su(t,e,n){return Object.freeze({declarationId:t.declarationId,sourceNodeId:t.sourceNodeId,occurrenceId:e,propertyName:t.propertyName,authoredPropertyName:t.authoredPropertyName,value:t.value,authoredValue:t.authoredValue,important:t.important,origin:t.origin,specificity:Object.freeze({...n}),sourceOrder:t.sourceOrder,ruleId:t.ruleId})}function nR(t){let e=Mn(t.prelude);if(e.length===0)return null;let n=e[e.length-1],r=(n.type==="Url"||n.type==="String")&&typeof n.value=="string"?n.value:null;if(r===null)return null;let i=e[0];return{prefix:e.length>1&&i.type==="Identifier"&&typeof i.name=="string"?i.name:"",uri:r}}function rR(t){return wr(t.prelude).split(",").map(e=>e.trim()).filter(Boolean)}var iR=new Set(["default","inherit","initial","none","revert","revert-layer","unset"]);function oR(t){let e=Mn(t.prelude);if(e.length!==1)return null;let n=e[0];return n.type==="String"&&typeof n.value=="string"?n.value===""?null:n.value:n.type!=="Identifier"||typeof n.name!="string"||iR.has(n.name.toLowerCase())?null:n.name}function sR(t){let e=t.trim().toLowerCase();if(e==="from")return 0;if(e==="to")return 1;let n=/^([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?)%$/iu.exec(e);if(!n)return null;let r=Number(n[1]);return Number.isFinite(r)&&r>=0&&r<=100?r/100:null}function aR(t){return t.important?!1:t.propertyName==="animation-timing-function"||t.propertyName!=="animation"&&!t.propertyName.startsWith("animation-")}function cR(t,e,n){let r=oR(t);if(!r||!t.block)return null;let i=`${e.sourceNodeId}:keyframes:${n}`,o=new Map;for(let[a,c]of Mn(t.block).entries()){if(c.type!=="Rule"||!c.prelude||!c.block)continue;let l=wr(c.prelude).split(",").map(sR).filter(p=>p!==null);if(l.length===0)continue;let d=Mn(c.block).filter(p=>p.type==="Declaration").map(p=>wr(p)).join(";"),u=ku(d).declarations.filter(aR);for(let p of l){let f=o.get(p)??new Map;for(let[m,g]of u.entries())f.set(g.propertyName,Object.freeze({declarationId:`${i}:${a}:${g.order}:${m}`,propertyName:g.propertyName,authoredPropertyName:g.authoredPropertyName,value:g.value,authoredValue:g.authoredValue,sourceOrder:Object.freeze([n,a,g.order,m])}));o.set(p,f)}}let s=[...o.entries()].sort(([a],[c])=>a-c).map(([a,c])=>Object.freeze({offset:a,declarations:Object.freeze([...c.values()]),properties:Iu([...c].map(([l,d])=>[l,d.value]))}));return Object.freeze({keyframesId:i,stylesheetSourceNodeId:e.sourceNodeId,name:r,sourceOrder:n,stops:Object.freeze(s)})}function lR(t,e,n,r){return Object.freeze({severity:"warning",code:"invalid-svg-attribute",source:t.source,entrypoint:t.entrypoint,capability:"styles",sourceNodeId:e.sourceNodeId,sourceId:C(e,"id")??void 0,elementName:e.name,documentPath:n.index.sourcePath(e.sourceNodeId),message:r})}function Yy(t,e){return t.matchesMedia(e)===!0}function dR(t,e){return t.supportsCondition(e)===!0}function qy(t,e,n){let r=Number(t.declaration.important)-Number(e.declaration.important);if(r!==0)return r;let i=c=>c.declaration.important?c.layerRank===null?-1:n-c.layerRank:c.layerRank===null?n+1:c.layerRank,o=i(t)-i(e);if(o!==0)return o;let s=t.originRank-e.originRank;return s!==0?s:nS(t.declaration.specificity,e.declaration.specificity)||vu(t.declaration.sourceOrder,e.declaration.sourceOrder)}function uR(t){let e=null,n=!1,r=0;for(let i=0;i<t.length;i++){let o=t[i];if(e){n?n=!1:o==="\\"?n=!0:o===e&&(e=null);continue}if(o==='"'||o==="'")e=o;else if(o==="(")r++;else if(o===")")r=Math.max(0,r-1);else if(o===","&&r===0)return i}return-1}function Ir(t,e,n=new Set){let r=Cn(t);if(r.length===0)return t.trim();let i=t;for(let o of[...r].reverse()){let s=t.slice(o.argumentsStart,o.argumentsEnd),a;if(o.name==="var"){let c=uR(s),l=(c<0?s:s.slice(0,c)).trim(),d=c<0?null:s.slice(c+1).trim();if(!l.startsWith("--")||n.has(l))a=d?Ir(d,e,n):null;else{let u=e[l];if(u===void 0)a=d?Ir(d,e,n):null;else{let p=new Set(n);p.add(l),a=Ir(u,e,p),a===null&&d&&(a=Ir(d,e,n))}}}else{let c=Ir(s,e,n);a=c===null?null:`${t.slice(o.tokenStart,o.argumentsStart)}${c})`}if(a===null)return null;i=`${i.slice(0,o.tokenStart)}${a}${i.slice(o.tokenEnd)}`}return i.trim()}function Iu(t){return Object.freeze(Object.fromEntries(t))}function Pu(t,e,n){let r=[],i=KT(t,e),o=YT(n.environment),s=[],a=[],c=[],l=[],d=new Map,u=0,p=0,f=0,m=P=>{let N=d.get(P);if(N!==void 0)return N;let R=d.size;return d.set(P,R),R},g=(P,N,R,$)=>{for(let A of P){if(A.type==="Atrule"){let Z=A.name?.toLowerCase();if(Z==="keyframes"){let ne=cR(A,N,f++);ne&&(c.push(ne),N.keyframesIds.push(ne.keyframesId));continue}if(Z==="namespace"){let ne=nR(A);ne&&R.set(ne.prefix,ne.uri);continue}if(Z==="layer"){let ne=rR(A);if(!A.block){for(let H of ne)m(H);continue}let F=ne[0]??`__anonymous_${u++}`,j=$?`${$}.${F}`:F;m(j),g(Mn(A.block),N,new Map(R),j);continue}if(Z==="media"){let ne=wr(A.prelude).trim();A.block&&Yy(n.environment,ne)&&g(Mn(A.block),N,new Map(R),$);continue}if(Z==="supports"){let ne=wr(A.prelude).trim();A.block&&dR(n.environment,ne)&&g(Mn(A.block),N,new Map(R),$);continue}continue}if(A.type!=="Rule"||!A.prelude||!A.block)continue;let O=wr(A.prelude).trim(),G=qT(O,R,o);if(!G)continue;let M=`${N.sourceNodeId}:rule:${p}`,V=Mn(A.block).filter(Z=>Z.type==="Declaration").map(Z=>wr(Z)).join(";"),K=$===null?null:m($),X=Xa(V,{sourceNodeId:N.sourceNodeId,origin:"stylesheet",ruleId:M,sourceOrder:[N.sourceNodeId===t.root.sourceNodeId?-1:p,p],layerRank:K}),U=X.templates.map(Z=>Su(Z,"",_o(G.map(ne=>ne.specificity)))),te=Object.freeze({ruleId:M,stylesheetSourceNodeId:N.sourceNodeId,selectorText:O,specificities:Object.freeze(G.map(Z=>Z.specificity)),layer:$,declarations:Object.freeze(U)});a.push(te),l.push(Object.freeze({plan:te,selectors:G,templates:X.templates})),N.ruleIds.push(M),p++}};for(let P of t.index.elements){if(P.namespaceUri!==Y||P.localName.toLowerCase()!=="style")continue;let N=WT(P),R=C(P,"type"),$=C(P,"media"),A=R===null||R.trim()===""||R.trim().toLowerCase()==="text/css",O=$===null||$.trim()===""||Yy(n.environment,$),G=[],M=[],V={sourceNodeId:P.sourceNodeId,authoredText:N,id:C(P,"id"),type:R,media:$,title:C(P,"title"),applicable:A&&O,ruleIds:G,keyframesIds:M};if(s.push(V),!V.applicable){Object.freeze(G),Object.freeze(M),Object.freeze(V);continue}try{let K=Qy(N,{positions:!0});g(Mn(K),V,new Map,null)}catch{r.push(lR(n,P,t,"The SVG style element contains malformed CSS."))}Object.freeze(G),Object.freeze(M),Object.freeze(V)}let h=new Map;for(let P of c)h.set(P.name,P);let y=new Map,b=new Map,v=P=>{let N=y.get(P.occurrence.occurrenceId);if(N)return N;let R=P.parent?v(P.parent):null,$=new Map,A=[],O=[],G=(F,j,H)=>{let oe=Su(F,P.occurrence.occurrenceId,j);A.push(oe);let re=$.get(oe.propertyName)??[];re.push({declaration:oe,layerRank:F.layerRank,originRank:H}),$.set(oe.propertyName,re)};for(let[F,j]of P.element.attributes.entries()){if(j.namespaceUri!==null||!Xr(j.localName))continue;let H={sourceNodeId:P.element.sourceNodeId,origin:"presentation",ruleId:null,sourceOrder:[P.element.elementOrder,-2,F],layerRank:null},oe=Xa(`${j.localName}:${j.value}`,H).templates,re=j.localName==="font-size"?gt(j.value):null;oe.length===0&&re?.unit===""&&re.value>=0&&(oe=Xa(`font-size:${re.value}px`,H).templates.map(xe=>Object.freeze({...xe,value:j.value,authoredValue:j.value})));for(let xe of oe)xe.important||G(xe,Li,0)}for(let F of l){let j=F.selectors.filter(oe=>oe.matches(P));if(j.length===0)continue;O.push(F.plan.ruleId);let H=_o(j.map(oe=>oe.specificity));for(let oe of F.templates)G(oe,H,1)}let M=C(P.element,"style");if(M!==null){let F=Xa(M,{sourceNodeId:P.element.sourceNodeId,origin:"style-attribute",ruleId:null,sourceOrder:[P.element.elementOrder,Number.MAX_SAFE_INTEGER],layerRank:null});b.set(P.occurrence.occurrenceId,F.raw);for(let j of F.templates)G(j,Li,2)}let V=new Map,K=new Map;for(let[F,j]of $){j.sort((oe,re)=>qy(oe,re,d.size)),V.set(F,j[j.length-1].declaration);let H=j.filter(oe=>oe.declaration.origin==="stylesheet");H.length>0&&K.set(F,H[H.length-1].declaration)}let X={...R?.customProperties??{}};for(let[F,j]of V){if(!F.startsWith("--"))continue;let H=j.value.trim().toLowerCase();H==="inherit"||H==="unset"?R?.customProperties[F]===void 0?delete X[F]:X[F]=R.customProperties[F]:H==="initial"||H==="revert"||H==="revert-layer"?delete X[F]:X[F]=j.value}let U={},te={},Z=new Set([...ja,...[...V.keys()].filter(F=>!F.startsWith("--"))]);for(let F of Z){let j=Xr(F),H=V.get(F),oe=R?.resolvedValues[F],re=j?.initialValue,xe;if(H){let et=H.value.trim().toLowerCase();et==="inherit"?xe=oe??re:et==="initial"||et==="revert"||et==="revert-layer"?xe=re:et==="unset"?xe=j?.inherited?oe??re:re:xe=H.value}else j?.inherited?xe=oe??re:xe=re;if(xe===void 0)continue;U[F]=xe;let Ze=Ir(xe,X);Ze===null&&(Ze=j?.inherited?oe??re??null:re??null),Ze!==null&&(Ze.trim().toLowerCase()==="currentcolor"&&(Ze=F==="color"?R?.resolvedValues.color??"black":te.color??R?.resolvedValues.color??"black"),te[F]=Ze)}let ne=Object.freeze({occurrenceId:P.occurrence.occurrenceId,correspondingSourceNodeId:P.occurrence.correspondingSourceNodeId,matchedRuleIds:Object.freeze(O),declarations:Object.freeze(A),cascadedValues:Iu(V),stylesheetCascadedValues:Iu(K),specifiedValues:Object.freeze(U),resolvedValues:Object.freeze(te),customProperties:Object.freeze(X),inlineDeclarations:b.get(P.occurrence.occurrenceId)??Object.freeze({})});return y.set(P.occurrence.occurrenceId,ne),ne};for(let P of i.byOccurrenceId.values())v(P);let I=Object.freeze(e.occurrences.map(P=>y.get(P.occurrenceId)).filter(P=>P!==void 0)),x=new Map;for(let P of e.occurrences){if(P.usePath.length!==0)continue;let N=y.get(P.occurrenceId);N&&x.set(P.correspondingSourceNodeId,N)}let k=[];for(let P of I)for(let[N,R]of Object.entries(P.resolvedValues)){if(!UT.has(N)||!R.toLowerCase().includes("url("))continue;let $=P.cascadedValues[N];k.push(Object.freeze({fromSourceNodeId:P.correspondingSourceNodeId,occurrenceId:P.occurrenceId,propertyName:N,value:R,origin:$?$.origin==="style-attribute"?"inline-style":"matched-stylesheet":"inherited-stylesheet"}))}let T=(P,N)=>{let R=i.byOccurrenceId.get(P);if(!R)return Object.freeze({});let $={...R,attributeOverrides:Object.freeze({class:N})},A=new Map;for(let U of l){let te=U.selectors.filter(ne=>ne.matches($));if(te.length===0)continue;let Z=_o(te.map(ne=>ne.specificity));for(let ne of U.templates){let F=Su(ne,P,Z),j=A.get(F.propertyName)??[];j.push({declaration:F,layerRank:ne.layerRank,originRank:1}),A.set(F.propertyName,j)}}let O=new Map;for(let[U,te]of A)te.sort((Z,ne)=>qy(Z,ne,d.size)),O.set(U,te[te.length-1].declaration);let G=R.parent?y.get(R.parent.occurrence.occurrenceId):null,M={...G?.customProperties??{}};for(let[U,te]of O){if(!U.startsWith("--"))continue;let Z=te.value.trim().toLowerCase();if(Z==="inherit"||Z==="unset"){let ne=G?.customProperties[U];ne===void 0?delete M[U]:M[U]=ne}else Z==="initial"||Z==="revert"||Z==="revert-layer"?delete M[U]:M[U]=te.value}let V={},K=O.get("color"),X=K?Ir(K.value,M):G?.resolvedValues.color??"black";for(let[U,te]of O){if(U.startsWith("--"))continue;let Z=Ir(te.value,M);Z!==null&&(Z.trim().toLowerCase()==="currentcolor"&&(Z=X??"black"),V[U]=Z)}return Object.freeze(V)},w=Object.freeze({stylesheets:Object.freeze(s),rules:Object.freeze(a),keyframes:Object.freeze(c),elements:I,appliedResourceDeclarations:Object.freeze(k),keyframesRule:P=>h.get(P)??null,ownStyle:P=>x.get(P)??null,style:P=>y.get(P)??null,value:(P,N)=>y.get(P)?.resolvedValues[N.toLowerCase()]??null,stylesheetValuesWithClass:T});return Object.freeze({value:w,diagnostics:Object.freeze(r)})}function Tu(t,e,n,r,i,o){if(n<=0||r<=0)return null;if(i<=0||o<=0)return`M${t},${e}h${n}v${r}h${-n}Z`;let s=t+n,a=e+r;return`M${t+i},${e}H${s-i}A${i},${o} 0 0 1 ${s},${e+o}V${a-o}A${i},${o} 0 0 1 ${s-i},${a}H${t+i}A${i},${o} 0 0 1 ${t},${a-o}V${e+o}A${i},${o} 0 0 1 ${t+i},${e}Z`}function oS(t,e,n,r){return n<=0||r<=0?null:`M${t+n},${e}A${n},${r} 0 0 1 ${t},${e+r}A${n},${r} 0 0 1 ${t-n},${e}A${n},${r} 0 0 1 ${t},${e-r}A${n},${r} 0 0 1 ${t+n},${e}Z`}function qa(t){let e=t.state;if(typeof e.d=="string")return e.d;let n=cn(t);if(!n)return null;switch(n.kind){case"path":return n.d||null;case"rectangle":return n.pathData??Tu(n.x,n.y,n.width,n.height,n.rx,n.ry);case"circle":return oS(n.cx,n.cy,n.r,n.r);case"ellipse":return oS(n.cx,n.cy,n.rx,n.ry);case"line":return`M${n.x1},${n.y1}L${n.x2},${n.y2}`;case"polyline":{if(n.points.length<2||n.points.some(i=>!Number.isFinite(i.x)||!Number.isFinite(i.y)))return null;let r=n.points.map((i,o)=>`${o===0?"M":"L"}${i.x},${i.y}`).join("");return n.closed?`${r}Z`:r}default:return null}}var pR=new Map([["animate","animate"],["animatetransform","animateTransform"],["animatemotion","animateMotion"],["set","set"],["discard","discard"]]);function fR(t){return Object.freeze(Object.fromEntries(t.attributes.map(e=>[e.name,e.value])))}function mR(t,e){return t.usePath.length!==e.usePath.length?!1:t.usePath.every((n,r)=>n.sourceReferenceId===e.usePath[r]?.sourceReferenceId)}function gR(t,e,n){return t.occurrences.find(r=>r.correspondingSourceNodeId===n&&mR(r,e))??t.direct(n)}function hR(t,e,n,r){let i=Be(n);if(!i)return null;if(i.value===""||i.value==="#")return{status:"empty",sourceNodeId:null,occurrenceId:null};if(!i.value.startsWith("#"))return{status:"external",sourceNodeId:null,occurrenceId:null};let o=i.value.slice(1),s=t.index.resolveAuthoredId(o);if(!s)return{status:"missing",sourceNodeId:null,occurrenceId:null};let a=t.index.element(s.sourceNodeId);if(!a||a.namespaceUri!==Y&&a.namespaceUri!==null)return{status:"invalid",sourceNodeId:s.sourceNodeId,occurrenceId:null};let c=gR(e,r,a.sourceNodeId);return{status:c?"resolved":"missing",sourceNodeId:a.sourceNodeId,occurrenceId:c?.occurrenceId??null}}function yR(t,e,n){let r=n.parentOccurrenceId?e.occurrence(n.parentOccurrenceId):null,i=r?t.index.element(r.correspondingSourceNodeId):null;return i?.localName.toLowerCase()==="textpath"&&r?.parentOccurrenceId&&(r=e.occurrence(r.parentOccurrenceId),i=r?t.index.element(r.correspondingSourceNodeId):null),i&&r?{status:"resolved",sourceNodeId:i.sourceNodeId,occurrenceId:r.occurrenceId}:{status:"missing",sourceNodeId:null,occurrenceId:null}}function SR(t,e,n,r){let i=t.index.children(n.sourceNodeId).find(u=>(u.namespaceUri===Y||u.namespaceUri===null)&&u.localName.toLowerCase()==="mpath");if(!i)return{sourceNodeId:null,data:C(n,"path")};let o=Be(i);if(!o?.value.startsWith("#")||o.value.length<=1)return{sourceNodeId:null,data:null};let s=t.index.resolveAuthoredId(o.value.slice(1)),a=s?t.index.element(s.sourceNodeId):null;if(!a)return{sourceNodeId:s?.sourceNodeId??null,data:null};if(a.localName.toLowerCase()==="path")return{sourceNodeId:a.sourceNodeId,data:C(a,"d")};let c=e.direct(a.sourceNodeId),l=c?r?.candidate(c.occurrenceId):null;if(!l||l.status!=="materialized"||!l.canonicalType)return{sourceNodeId:a.sourceNodeId,data:null};let d={id:l.occurrenceId,type:l.canonicalType,state:l.state};return{sourceNodeId:a.sourceNodeId,data:qa(d)}}function bR(t,e,n,r){let i=[];for(let o of e.occurrences){let s=t.index.element(o.correspondingSourceNodeId);if(!s||s.namespaceUri!==Y&&s.namespaceUri!==null)continue;let a=pR.get(s.localName.toLowerCase());if(!a)continue;let c=hR(t,e,s,o)??yR(t,e,o),l=fR(s),d={values:l.values,from:l.from,to:l.to,by:l.by,additive:l.additive,dur:l.dur,keyTimes:l.keyTimes,calcMode:l.calcMode,keySplines:l.keySplines,repeatCount:l.repeatCount,repeatDur:l.repeatDur,fill:l.fill},u=a==="animateMotion"?SR(t,e,s,r):null,p=c.sourceNodeId?t.index.element(c.sourceNodeId):null,f=(c.occurrenceId?n.style(c.occurrenceId)?.cascadedValues.transform?.value:void 0)??(p?C(p,"transform"):null),m=Bd(d);i.push(Object.freeze({animationId:`smil:${o.occurrenceId}`,sourceNodeId:s.sourceNodeId,occurrenceId:o.occurrenceId,kind:a,sourceAnimationId:C(s,"id"),targetStatus:c.status,targetSourceNodeId:c.sourceNodeId,targetOccurrenceId:c.occurrenceId,attributeName:C(s,"attributeName"),attributes:l,duration:Gd(d),additive:m,...a==="animateTransform"&&m==="replace"&&f!==null&&f.trim().toLowerCase()!=="none"?{replacesCarrierBase:!0}:{},fill:l.fill==="freeze"?"freeze":"remove",motionPathSourceNodeId:u?.sourceNodeId??null,motionPathData:u?.data??null}))}return Object.freeze(i)}function vR(t){let e=t.parsedEasing?Object.freeze({...t.parsedEasing,..."points"in t.parsedEasing?{points:Object.freeze([...t.parsedEasing.points])}:{}}):null;return Object.freeze({...t,parsedEasing:e})}function xR(t){let e=[];for(let n of t.elements){let r=n.resolvedValues,i=r.animation||ph(r);if(i)for(let[o,s]of Qs(i).entries()){let a=pd(s);if(!a){let l=ea(r["animation-name"],o);l&&l!=="none"&&(a=pd(`${s} ${l}`))}if(!a)continue;uh(a,r,o);let c=t.keyframesRule(a.name);!c||c.stops.length===0||e.push(Object.freeze({animationId:`css:${n.occurrenceId}:${o}`,sourceNodeId:n.correspondingSourceNodeId,occurrenceId:n.occurrenceId,animationIndex:o,animation:vR(a),keyframes:c}))}}return Object.freeze(e)}function sS(t){let e=new Map;for(let n of t){let r=e.get(n.occurrenceId)??[];r.push(n),e.set(n.occurrenceId,r)}for(let n of e.values())Object.freeze(n);return e}function Ru(t,e,n,r){let i=bR(t,e,n,r.leafGeometry),o=xR(n),s=i.filter(d=>d.targetStatus!=="resolved").map(d=>{let u=t.index.element(d.sourceNodeId);return Object.freeze({severity:"warning",code:"unresolved-reference",source:r.source,entrypoint:r.entrypoint,capability:"smil-animation",sourceId:d.sourceAnimationId??void 0,sourceNodeId:d.sourceNodeId,occurrenceId:d.occurrenceId,elementName:u?.name,documentPath:t.index.sourcePath(d.sourceNodeId),message:`The SVG animation target is ${d.targetStatus} and cannot be materialized.`})});for(let d of o)for(let u of d.keyframes.stops){let p=u.properties.transform??u.properties["-webkit-transform"]??u.properties["-moz-transform"];if(p===void 0)continue;let f=zh(p);f&&s.push(Object.freeze({severity:"warning",code:f==="unsupported-perspective"?"unsupported-ingest-capability":"invalid-svg-attribute",source:r.source,entrypoint:r.entrypoint,capability:"css-animation",sourceNodeId:d.sourceNodeId,occurrenceId:d.occurrenceId,documentPath:t.index.sourcePath(d.sourceNodeId),message:f==="unsupported-perspective"?"A projective CSS transform cannot be represented by the native affine timeline.":"A CSS transform keyframe has invalid function syntax and was not materialized."}))}let a=sS(i),c=sS(o),l=Object.freeze({smil:i,css:o,smilForOccurrence:d=>a.get(d)??Object.freeze([]),cssForOccurrence:d=>c.get(d)??Object.freeze([])});return Object.freeze({value:l,diagnostics:Object.freeze(s)})}var IR=new Set(["circle","ellipse","flowroot","foreignobject","image","line","path","polygon","polyline","rect","text"]),wR=Object.freeze({});function Ja(t){if(Array.isArray(t))return Object.freeze(t.map(Ja));if(t&&typeof t=="object"){let e={};for(let[n,r]of Object.entries(t))e[n]=Ja(r);return Object.freeze(e)}return t}function kR(t){return Ja(t)}function PR(t,e){let n=Math.min(t.length,e.length);for(let r=0;r<n;r++){let i=t[r]-e[r];if(i!==0)return i}return t.length-e.length}function TR(t,e){return PR(t.orderKey,e.orderKey)||t.productIndex-e.productIndex||t.occurrenceId.localeCompare(e.occurrenceId)}function RR(t,e,n,r,i){return Object.freeze({severity:"warning",code:"invalid-svg-attribute",source:r.source,entrypoint:r.entrypoint,capability:"geometry",sourceId:C(n,"id")??void 0,sourceNodeId:n.sourceNodeId,occurrenceId:e.occurrenceId,elementName:n.name,documentPath:t.index.sourcePath(n.sourceNodeId),message:i})}function Ge(t,e,n,r,i={},o){return Object.freeze({occurrenceId:t.occurrenceId,sourceNodeId:e.sourceNodeId,sourceId:C(e,"id"),elementName:e.localName,canonicalType:n,status:r,state:Object.keys(i).length===0?wR:kR(i),...o?{authoredTextStructure:Ja(o)}:{}})}function kr(t,e,n,r){let i=t.style(e.occurrenceId);return i?.cascadedValues[r]?i.resolvedValues[r]??i.specifiedValues[r]??null:C(n,r)}function CR(t,e,n){let r=t.value(e.occurrenceId,"font-size");if(!r||r==="medium")return n.rootFontSize;let i=Re(r,{percentBasis:n.rootFontSize,viewportWidth:n.viewport.width,viewportHeight:n.viewport.height,fontSize:n.rootFontSize,rootFontSize:n.rootFontSize});return i!==void 0&&i>=0?i:n.rootFontSize}function $u(t,e,n){return{percentBasis:t==="x"?n.viewport.width:t==="y"?n.viewport.height:Math.hypot(n.viewport.width,n.viewport.height)/Math.SQRT2,viewportWidth:n.viewport.width,viewportHeight:n.viewport.height,fontSize:e,rootFontSize:n.rootFontSize}}function Nu(t){if(t===null)return null;let e=/\S+/.exec(t.trim());return e?e[0].replace(/,$/,""):null}function Cu(t,e,n,r,i,o,s){return Re(Nu(kr(t,e,n,r)),$u(i,o,s))}function Fo(t){if(t===null||t.trim()==="")return;let e=Number(t.trim());return Number.isFinite(e)?e:void 0}function $R(t){if(!t)return{points:[],odd:!1};let n=(t.match(/[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:[eE][+-]?\d+)?/g)??[]).map(Number).filter(Number.isFinite),r=n.length%2!==0,i=[];for(let o=0;o+1<n.length;o+=2)i.push({x:n[o],y:n[o+1]});return{points:i,odd:r}}function NR(t){let e=C(t,"transform");if(!e||e.trim()==="")return{rotation:0};let n=Kt(e);return Dt(n)?{rotation:0}:{transformMatrix:ot(n)}}function On(t,e,n,r){let i=t.type===t.type.toLowerCase();return[t.params[e]+(i?n:0),t.params[e+1]+(i?r:0)]}function lS(t){let e=[],n=0,r=0,i=0,o=0,s=0,a=0,c="",l=!1,d=!1;for(let u of t){let p=u.type.toUpperCase(),f=u.type===u.type.toLowerCase(),m=c.toUpperCase()==="Z",g=e.length;if(!(p==="B"||p==="R")){if(p==="Z"){n=i,r=o,l=!0,d||=e.length>1,c=u.type;continue}if(p==="M"){let[h,y]=On(u,0,n,r),b={x:h,y,pointType:"corner"};e.length>0&&(b.isSubpathStart=!0),e.push(b),n=i=h,r=o=y,c=u.type;continue}if(p==="H")n=u.params[0]+(f?n:0),e.push({x:n,y:r,pointType:"corner",segmentType:"HORIZONTAL"}),d=!0;else if(p==="V")r=u.params[0]+(f?r:0),e.push({x:n,y:r,pointType:"corner",segmentType:"VERTICAL"}),d=!0;else if(p==="L")[n,r]=On(u,0,n,r),e.push({x:n,y:r,pointType:"corner"}),d=!0;else if(p==="C"){let h=n,y=r,[b,v]=On(u,0,h,y),[I,x]=On(u,2,h,y),[k,T]=On(u,4,h,y),w=e.at(-1);w&&(w.pointType="smooth",w.handleOut={x:b,y:v}),e.push({x:k,y:T,handleIn:{x:I,y:x},pointType:"smooth"}),n=k,r=T,s=I,a=x,d=!0}else if(p==="S"){let h=n,y=r,[b,v]=On(u,0,h,y),[I,x]=On(u,2,h,y),k=e.at(-1);k&&(k.pointType="smooth",k.handleOut=/^[CcSs]$/.test(c)?{x:2*h-s,y:2*y-a}:{x:h,y}),e.push({x:I,y:x,handleIn:{x:b,y:v},pointType:"smooth",segmentType:"SMOOTH_CUBIC"}),n=I,r=x,s=b,a=v,d=!0}else if(p==="Q"||p==="T"){let h=n,y=r,b=p==="T",[v,I]=b?/^[QqTt]$/.test(c)?[2*h-s,2*y-a]:[h,y]:On(u,0,h,y),[x,k]=On(u,b?0:2,h,y),T=e.at(-1);T&&(T.pointType="smooth",T.handleOut={x:v,y:I});let w={x,y:k,pointType:"smooth",segmentType:b?"SMOOTH_QUADRATIC":"QUADRATIC"};e.push(w),n=x,r=k,s=v,a=I,d=!0}else if(p==="A"){let h=n,y=r,[b,v]=On(u,5,h,y),I=Math.abs(u.params[0]),x=Math.abs(u.params[1]),k={x:b,y:v,pointType:"corner"};I!==0&&x!==0&&(b!==n||v!==r)&&(k.segmentType="ARC",k.arcParams={rx:I,ry:x,rotation:u.params[2],largeArc:u.params[3]===1,sweep:u.params[4]===1}),(b!==n||v!==r)&&(e.push(k),d=!0),n=b,r=v}m&&e.length>g&&(e[g].isSubpathStart=!0),c=u.type}}return{points:e,closed:l,drawn:d}}function AR(t){return t.replace(/[\t\n\r ]+/g," ").trim()}function dS(t){let e=[];for(let n of t.children)if(n.kind==="text"||n.kind==="cdata"){let r=AR(n.value);r&&e.push(r)}else if(n.kind==="element"){let r=dS(n);r&&e.push(r)}return e.join(" ")}function ER(t,e){return t.usePath.length!==e.usePath.length?!1:t.usePath.every((n,r)=>n.sourceReferenceId===e.usePath[r]?.sourceReferenceId)}function MR(t,e,n){return t.occurrences.find(r=>r.correspondingSourceNodeId===n&&ER(r,e))??t.direct(n)}function OR(t,e){let n=e;for(;n;){let r=n.attributes.find(i=>i.prefix==="xml"&&i.localName==="space")?.value;if(r)return r;n=t.index.parent(n.sourceNodeId)}return null}function DR(t,e,n,r){let i=r.style(n.occurrenceId)?.cascadedValues["white-space"]?r.value(n.occurrenceId,"white-space"):null;return i==="pre"||i==="pre-wrap"||i==="pre-line"?{mode:"preserve-newlines",authored:i}:OR(t,e)==="preserve"?{mode:"preserve-spaces",authored:null}:{mode:"collapse",authored:i==="normal"?"normal":null}}function Gi(t,e){return e==="preserve-newlines"?t.replace(/\r\n?/g,`
10
+ `):e==="preserve-spaces"?t.replace(/\r?\n[ \t\r]*/g,""):t.replace(/[ \t\r\n]+/g," ")}function Vi(t,e){return t.children.map(n=>n.kind==="text"||n.kind==="cdata"?Gi(n.value,e):n.kind==="element"?Vi(n,e):"").join("")}function zR(t,e,n){let r=[],i="";for(let o of t.children){if(o.kind==="comment")continue;if(o.kind==="text"||o.kind==="cdata"){let l=Gi(o.value,n);if(n==="collapse"&&(l!==l.trim()||/ {2,}/u.test(l)))return;i+=l;continue}if(o.kind!=="element"||o.localName.toLowerCase()!=="tspan"||!C(o,"id")||o.attributes.some(l=>!(l.namespaceUri===null&&l.localName==="id"))||o.children.some(l=>l.kind==="element"))return;let a=Gi(Vi(o,n),n);if(n==="collapse"&&(a!==a.trim()||/ {2,}/u.test(a)))return;let c=i.length;i+=a,r.push({start:c,end:i.length,sourceNodeId:o.sourceNodeId})}return r.length>0&&i===e?{text:e,spans:r}:void 0}function _R(t,e,n){let r=e;for(;r&&r.sourceNodeId!==t.root.sourceNodeId;){if(r.localName.toLowerCase()==="svg"){let i=at(C(r,"viewBox")??"");if(i&&i.width>0&&i.height>0)return{width:i.width,height:i.height}}r=t.index.parent(r.sourceNodeId)}return n.viewport}function Eu(t,e,n){return t.attributes.find(r=>r.prefix===e&&r.localName===n)?.value??null}function St(t,e,n,r,i,o=r*.5){let s=Ti(t).at(0);if(s)return ur(s,{percentBasis:e==="x"?n.width:n.height,viewportWidth:n.width,viewportHeight:n.height,fontSize:r,rootFontSize:i,xHeight:o})}function FR(t,e,n,r,i,o){let s=t.children.filter(b=>b.kind==="element"&&b.localName.toLowerCase()==="tspan"),a=b=>Gi(b,e);if(s.length===0){let b=a(Vi(t,e));e==="collapse"&&(b=b.replace(/ {2,}/g," ").replace(/^ +| +$/g,""));let v=b.split(`
11
+ `).map(I=>({text:I,x:0,dy:0}));return{text:b,lines:v,linePositions:null}}let c=.001,l=St(C(t,"x"),"x",n,r,i,o)??0,d=St(C(t,"y"),"y",n,r,i,o)??null,u=[],p=!1,f=(b,v)=>{if(e!=="collapse")return b;let I=b.replace(/ {2,}/g," ");return v&&(I=I.replace(/^ +/,"")),I.replace(/ +$/,"")},m=(b,v,I,x)=>{if(!b)return;let k=I===null?0:(St(I,"x",n,r,i,o)??l)-l,T=e==="preserve-newlines"?b.split(`
12
+ `):[b];for(let w=0;w<T.length;w++){let P=T[w],N=w>0,R=w===0&&v||N;!P&&!N||(R&&p?u.push({text:P,x:w===0?k:0,dy:w===0?x:0}):p?u[u.length-1].text+=P:u.push({text:P,x:w===0?k:0,dy:0}),P&&(p=!0))}},g=b=>{let v=C(b,"x");if(Eu(b,"sodipodi","role")==="line"){let T=St(C(b,"y"),"y",n,r,i,o),w=T!==void 0&&d!==null&&Math.abs(T-d)>.5?T-d:0;return{brk:!0,x:v,dy:w}}let x=C(b,"dy");if(x!==null){let T=St(x,"y",n,r,i,o)??0;if(T>c||T<-c&&v!==null)return{brk:!0,x:v,dy:T}}let k=St(C(b,"y"),"y",n,r,i,o);if(k!==void 0&&d!==null&&Math.abs(k-d)>.5)return{brk:!0,x:v,dy:k-d};if(v!==null&&p){let T=St(v,"x",n,r,i,o);if(T!==void 0&&T<=l+.5)return{brk:!0,x:v,dy:0}}return{brk:!1,x:null,dy:0}},h=(b,v)=>{let I=!1;for(let x of b.children){if(x.kind==="text"||x.kind==="cdata"){let N=a(x.value);if(!N)continue;if(e!=="preserve-newlines"&&/^ +$/.test(N)){if(p&&u.length>0){let $=u[u.length-1].text;e==="collapse"?$.endsWith(" ")||(u[u.length-1].text+=" "):u[u.length-1].text+=N}continue}let R=v.active&&!I;m(N,R,R?v.x:null,R?v.dy:0),I=!0;continue}if(x.kind!=="element"||x.localName.toLowerCase()!=="tspan")continue;let k=g(x),T=St(C(x,"y"),"y",n,r,i,o);T!==void 0&&(d=T);let w={active:v.active&&!I||k.brk,x:k.brk?k.x:v.active&&!I?v.x:null,dy:k.brk?k.dy:v.active&&!I?v.dy:0};x.children.some(N=>N.kind==="element"&&N.localName.toLowerCase()==="tspan")?h(x,w):m(a(Vi(x,e)),w.active,w.x,w.dy),I=!0}};h(t,{active:!1,x:null,dy:0});for(let b=0;b<u.length;b++)u[b].text=f(u[b].text,b===0);let y=u.some((b,v)=>v>0&&Math.abs(b.dy)>c||Math.abs(b.x)>c)?u.map(b=>({x:b.x,dy:b.dy})):null;return{text:u.map(b=>b.text).join(`
13
+ `),lines:u,linePositions:y}}function uS(t){return t&&t.split(",").map(n=>n.trim().replace(/^['"]|['"]$/g,"").trim()).filter(Boolean).join(", ")||null}function LR(t,e,n,r,i,o){let s=Bi(t,e,n,"font-size"),a=Wt(s);return a!==void 0&&a>=0?a:r}function aS(t,e,n,r){let i=n;for(;i;){if(t.style(i.occurrenceId)?.cascadedValues[r])return!0;i=i.parentOccurrenceId?e.occurrence(i.parentOccurrenceId)??void 0:void 0}return!1}function Bi(t,e,n,r){let i=C(n,r),o=t.style(e.occurrenceId),s=o?.cascadedValues[r];return s?o?.specifiedValues[r]??s.value:i!==null?i:o?.resolvedValues[r]??null}function pS(t){if(!t)return 400;if(t==="normal"||t==="bold")return t;let e=Number(t);return Number.isFinite(e)?e:400}function BR(t){let e=pS(t);return e===400||e==="normal"?"normal":e===700||e==="bold"?"bold":e}function cS(t,e,n){let r=w=>e?t.value(e.occurrenceId,w):null,i=r("text-decoration")?.toLowerCase()??"",o=uS(r("font-family"))??"Arial",s=r("font-style"),a=s==="italic"||s==="oblique"?s:"normal",c=r("line-height"),l=c?Number(c):NaN,d=r("fill"),u=(w,P)=>Wt(r(w))??P,p=r("font-variant")??"",f=r("baseline-shift"),m=f?Wt(f):void 0,g=f==="baseline"||f==="super"||f==="sub"?f:m??"baseline",h=r("dominant-baseline"),y=new Set(["auto","alphabetic","central","middle","hanging","ideographic","mathematical","text-top","text-bottom"]),b=r("writing-mode"),v=b==="tb"||b==="tb-rl"?"vertical-rl":b==="lr"||b==="lr-tb"||b==="rl"||b==="rl-tb"?"horizontal-tb":b,I=r("direction"),x=r("unicode-bidi"),k=r("text-anchor"),T=r("text-transform");return{...yi,textDecoration:{underline:i.includes("underline"),strikethrough:i.includes("line-through"),overline:i.includes("overline")},fontVariationSettings:{},fontFamily:o,fontSize:n,fontWeight:BR(r("font-weight")),fontStyle:a,fontVariant:p,fontVariantLigatures:r("font-variant-ligatures")??"",fontVariantPosition:r("font-variant-position")??"",fontVariantCaps:r("font-variant-caps")??"",fontVariantNumeric:r("font-variant-numeric")??"",fontVariantEastAsian:r("font-variant-east-asian")??"",fill:!d||d.toLowerCase()==="black"?"#000000":d,stroke:r("stroke")??"none",lineHeight:Number.isFinite(l)?l:1.2,textTransform:T==="capitalize"||T==="uppercase"||T==="lowercase"?T:"none",baselineShift:g,dominantBaseline:y.has(h)?h:"auto",writingMode:v==="vertical-rl"||v==="vertical-lr"?v:"horizontal-tb",whiteSpace:r("white-space")==="pre"||r("white-space")==="pre-wrap"||r("white-space")==="pre-line"||r("white-space")==="nowrap"||r("white-space")==="break-spaces"?r("white-space"):"normal",direction:I==="rtl"?"rtl":"ltr",unicodeBidi:x==="embed"||x==="bidi-override"||x==="isolate"||x==="isolate-override"||x==="plaintext"?x:"normal",textAnchor:k==="middle"||k==="end"?k:"start",letterSpacing:u("letter-spacing",0),wordSpacing:u("word-spacing",0),fillOpacity:Number(r("fill-opacity")??1),strokeWidth:u("stroke-width",0),strokeOpacity:Number(r("stroke-opacity")??1)}}function GR(t,e,n,r,i,o){let s=t.style(e.occurrenceId)?.cascadedValues["font-size"];if(!s)return n;let a=s.value.trim().toLowerCase();if(a==="inherit"||a==="unset")return n;if(a==="initial"||a==="revert"||a==="revert-layer"||a==="medium")return o;let c=t.value(e.occurrenceId,"font-size"),l=Re(c,{percentBasis:n,viewportWidth:i.width,viewportHeight:i.height,fontSize:n,rootFontSize:o,xHeight:r});return l!==void 0&&l>=0?l:n}function VR(t,e,n,r,i){let o=i?.measureXHeight(t.fontFamily,e);return o!==void 0&&Number.isFinite(o)&&o>=0?o:n>0?r*(e/n):e*.5}function jR(t){return Au(t).filter(e=>e.localName.toLowerCase()==="tspan"&&!e.children.some(n=>n.kind==="element"&&n.localName.toLowerCase()==="tspan"))}function Za(t,e,n,r,i,o){return t?Ti(t).map(s=>({value:ur(s,{percentBasis:e==="x"?n.width:n.height,viewportWidth:n.width,viewportHeight:n.height,fontSize:r,rootFontSize:i,xHeight:o})??null,raw:s.unit===""||s.unit==="px"?null:`${s.value}${s.unit}`})):[]}function UR(t){if(!t)return[];let e=t.trim().split(/[\s,]+/).filter(Boolean),n=/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:[eE][+-]?\d+)?$/;return e.every(r=>n.test(r))?e.map(Number):[]}function HR(t,e,n,r,i,o,s){let a=jR(t),c=a.length>0?a:[t],l=Array.from(e,()=>({x:null,y:null,dx:0,dy:0,rotate:0})),d=0,u=!1;for(let p of c){let f=Gi(Vi(p,n),n),m=a.length>0?Math.max(d,e.indexOf(f,d)):0,g=Za(C(p,"dx"),"x",r,i,o,s),h=Za(C(p,"dy"),"y",r,i,o,s),y=Za(C(p,"x"),"x",r,i,o,s),b=Za(C(p,"y"),"y",r,i,o,s),v=UR(C(p,"rotate")),I=v.at(-1)??0,x=g.length>1||h.length>1||y.length>1||b.length>1||v.length>1,k=Eu(p,"sodipodi","role")==="line",T=h[0]?.value,w=a.length>0&&!x&&(k||T!=null&&(T>.001||T<-.001&&C(p,"x")!==null));for(let P=0;P<f.length&&m+P<l.length;P++){let N=l[m+P],R=a.length===0,$=w?null:R?P>0?y[P]?.value??null:null:x?y[P]?.value??null:P===0?y[0]?.value??null:null,A=w?null:R?P>0?b[P]?.value??null:null:x?b[P]?.value??null:P===0?b[0]?.value??null:null,O=w?0:x?g[P]?.value??0:P===0?g[0]?.value??0:0,G=w?0:x?h[P]?.value??0:P===0?h[0]?.value??0:0,M=v[P]??I;Object.assign(N,{x:$,y:A,dx:O,dy:G,rotate:M});let V={},K=R&&P===0?null:x?y[P]?.raw:P===0?y[0]?.raw:null,X=R&&P===0?null:x?b[P]?.raw:P===0?b[0]?.raw:null,U=x?g[P]?.raw:P===0?g[0]?.raw:null,te=x?h[P]?.raw:P===0?h[0]?.raw:null;!w&&K&&(V.x=K),!w&&X&&(V.y=X),!w&&U&&(V.dx=U),!w&&te&&(V.dy=te),Object.keys(V).length>0&&(N.raw=V),($!==null||A!==null||O!==0||G!==0||M!==0)&&(u=!0)}d=Math.max(d,m+f.length)}return u?l:null}function WR(t,e,n){let r=e.children.find(g=>g.kind==="element"&&g.localName.toLowerCase()==="textpath");if(!r)return{isTextPath:!1};let i={isTextPath:!1},o=C(r,"side");o==="right"&&(i.textPathSide=o);let s=C(r,"method");(s==="align"||s==="stretch")&&(i.textPathMethod=s);let a=C(r,"spacing");(a==="auto"||a==="exact")&&(i.textPathSpacing=a);let c=C(r,"startOffset");if(c){let g=Number.parseFloat(c);Number.isFinite(g)&&(i.textPathStartOffset=g,i.textPathStartOffsetUnit=c.trim().endsWith("%")?"%":"user")}let l=C(r,"lengthAdjust");(l==="spacing"||l==="spacingAndGlyphs")&&(i.textPathLengthAdjust=l);let d=C(r,"textLength");if(d){let g=Number.parseFloat(d);Number.isFinite(g)&&g>=0&&(i.textPathLength=g,i.textPathLengthUnit=d.trim().endsWith("%")?"%":"user")}let u=C(r,"path");u&&(i.textPathInlineFormat="path-attr");let p=null;if(!u){let g=Be(r)?.value;if(!g){let h=r.children.find(y=>y.kind==="element"&&y.localName.toLowerCase()==="mpath");g=h?Be(h)?.value:void 0}if(g?.startsWith("#")){i.textPathImportRefId=g.slice(1);let h=t.index.resolveAuthoredId(g.slice(1));p=h?t.index.element(h.sourceNodeId):null,u=p?C(p,"d"):null}}if(!u)return i;let f=lS(Nn(u).commands);if(f.points.length<2)return i;i.isTextPath=!0,i.textPathPoints=f.points;let m=Fo(p?C(p,"pathLength"):null);return m!==void 0&&m>=0&&(i.textPathPathLength=m),i.x=-n/2,i.y=-n/2,i}function KR(t,e,n,r,i,o,s,a,c,l,d,u){if(!t.children.some(w=>w.kind==="element"&&w.localName.toLowerCase()==="tspan"))return null;let f=cS(r,e,s),m=[{segments:[]}],g=!1,h=!1,y=St(C(t,"y"),"y",c,s,l,d)??null,b=St(C(t,"x"),"x",c,s,l,d)??0,v=w=>Gi(w,o),I=(w,P,N)=>{if(!w)return;let R=o==="preserve-newlines"?w.split(`
14
+ `):[w];for(let $=0;$<R.length;$++){let A=R[$],O=$>0;if(!A&&!O)continue;let G={text:A,style:vo(f,P)};($===0&&N||O)&&g?m.push({segments:[G]}):m[m.length-1].segments.push(G),A&&(g=!0),sr(P,f)||(h=!0)}},x=(w,P,N)=>{if(Eu(w,"sodipodi","role")==="line")return!0;let R=C(w,"x"),$=C(w,"dy");if($!==null){let O=St($,"y",c,P,l,N)??0;if(O>.001||O<-.001&&R!==null)return!0}let A=St(C(w,"y"),"y",c,P,l,N);if(A!==void 0&&y!==null&&Math.abs(A-y)>.5)return!0;if(R!==null&&g){let O=St(R,"x",c,P,l,N);if(O!==void 0&&O<=b+.5)return!0}return!1},k=(w,P,N,R,$)=>{let A=!1;for(let O of w.children){if(O.kind==="text"||O.kind==="cdata"){let ne=v(O.value);if(!ne)continue;if(o!=="preserve-newlines"&&/^ +$/.test(ne)){if(g){let F=m.at(-1)?.segments.at(-1);F&&(o==="collapse"?F.text.endsWith(" ")||(F.text+=" "):F.text+=ne)}continue}I(ne,P,N&&!A),A=!0;continue}if(O.kind!=="element"||O.localName.toLowerCase()!=="tspan")continue;let G=MR(n,e,O.sourceNodeId),M=G?GR(r,G,R,$,c,l):R,V=G?cS(r,G,M):P,K=VR(V,M,R,$,u),X=x(O,M,K),U=St(C(O,"y"),"y",c,M,l,K);U!==void 0&&(y=U);let te=N&&!A||X;O.children.some(ne=>ne.kind==="element"&&ne.localName.toLowerCase()==="tspan")?k(O,V,te,M,K):I(v(Vi(O,o)),V,te),A=!0}};if(k(t,f,!1,s,d),o==="collapse")for(let w=0;w<m.length;w++){let P=m[w],N=!1;for(let $ of P.segments)$.text=$.text.replace(/ {2,}/g," "),N&&$.text.startsWith(" ")&&($.text=$.text.slice(1)),N=$.text.endsWith(" ");if(w===0){let $=P.segments.find(A=>A.text.length>0);$&&($.text=$.text.replace(/^ +/,""))}let R=[...P.segments].reverse().find($=>$.text.length>0);R&&(R.text=R.text.replace(/ +$/,"")),P.segments=P.segments.filter($=>$.text.length>0)}return!h||m.map(w=>w.segments.map(P=>P.text).join("")).join(`
15
+ `)!==i?null:{lines:m,baseStyle:f,lineHeight:a}}function Au(t){let e=[],n=r=>{for(let i of r)i.kind==="element"&&(e.push(i),n(i.children))};return n(t.children),e}function XR(t,e){let n=t.index.parent(e.sourceNodeId);for(;n;){if(n.localName.toLowerCase()==="flowroot")return!0;n=t.index.parent(n.sourceNodeId)}return!1}var YR=[["fontVariant","font-variant"],["fontVariantLigatures","font-variant-ligatures"],["fontVariantPosition","font-variant-position"],["fontVariantCaps","font-variant-caps"],["fontVariantNumeric","font-variant-numeric"],["fontVariantEastAsian","font-variant-east-asian"]];function qR(t,e,n){let r={},i=T=>Bi(t,e,n,T);for(let[T,w]of YR){let P=i(w);P&&P.trim()&&(r[T]=P.trim())}let o=i("text-decoration")??i("text-decoration-line");if(o&&o!=="none"){let T=o.toLowerCase();r.textDecoration={underline:T.includes("underline"),strikethrough:T.includes("line-through"),overline:T.includes("overline")}}let s=i("text-anchor"),a=i("text-align");s==="middle"||s==="end"?r.textAnchor=s:a==="center"?r.textAnchor="middle":a==="end"||a==="right"?r.textAnchor="end":(a==="justify"||s==="start")&&(r.textAnchor="start");let c=T=>{let w=i(T);if(w!=="normal")return Wt(w)},l=c("letter-spacing");l!==void 0&&(r.letterSpacing=l);let d=c("word-spacing");d!==void 0&&(r.wordSpacing=d);let u=i("text-transform");u&&(r.textTransform=u.trim());let p=i("baseline-shift");p&&(r.baselineShift=p.trim());let f=i("dominant-baseline");f&&(r.dominantBaseline=f.trim());let m=i("writing-mode");m&&(r.writingMode=m==="tb"||m==="tb-rl"?"vertical-rl":m==="vertical-lr"?"vertical-lr":"horizontal-tb");let g=Number.parseFloat(i("inline-size")??"");Number.isFinite(g)&&g>0&&(r.inlineSize=g);let y=i("shape-inside")?.match(/url\(\s*#([^)]+)\s*\)/)?.[1];y&&(r.shapeInsideImportRefId=y);let b=Number.parseFloat(i("shape-padding")??"");Number.isFinite(b)&&b>0&&(r.shapePadding=b);let v=i("overflow-wrap");(v==="break-word"||v==="anywhere")&&(r.overflowWrap=v);let I=i("direction");(I==="ltr"||I==="rtl")&&(r.textDirection=I);let x=i("unicode-bidi");(x==="normal"||x==="embed"||x==="bidi-override"||x==="isolate"||x==="isolate-override"||x==="plaintext")&&(r.unicodeBidi=x);let k=i("font-variation-settings");if(k&&k!=="normal"){let T={};for(let w of k.split(",")){let P=w.trim().match(/^['"](\w{4})['"]\s+([\d.eE+-]+)$/);if(!P)continue;let N=Number(P[2]);Number.isFinite(N)&&(T[P[1]]=N)}Object.keys(T).length>0&&(r.fontVariationSettings=T)}return r}function ZR(t,e,n,r,i,o,s){let a=n.localName.toLowerCase(),c=CR(i,e,o),l=(m,g)=>Cu(i,e,n,m,g,c,o),d=m=>{s.push(RR(t,e,n,o,m))},u=NR(n),p=Fo(C(n,"pathLength")),f=m=>(p===void 0||(p<0?d("Path length must not be negative."):m.pathLength=p),m);if(a==="rect"){let m=l("x","x")??0,g=l("y","y")??0,h=l("width","x")??0,y=l("height","y")??0;if(h<0||y<0)return d("Rectangle width and height must not be negative."),Ge(e,n,null,"invalid");if(h===0||y===0)return Ge(e,n,null,"empty");let b=l("rx","x"),v=l("ry","y");(b!==void 0&&b<0||v!==void 0&&v<0)&&d("Rectangle corner radii must not be negative.");let I=b!==void 0&&b>=0,x=v!==void 0&&v>=0,k=Math.min(I?b:x?v:0,h/2),T=Math.min(x?v:I?b:0,y/2),w=f({x:m,y:g,width:h,height:y,rx:k,ry:T,cornerRadius:0});(k>0||T>0)&&Math.abs(k-T)<=1e-6&&(w.cornerRadius=k),Object.assign(w,u);let P=n.children.some(R=>R.kind==="element"&&["animate","set"].includes(R.localName.toLowerCase())&&["x","y","width","height","rx","ry"].includes(C(R,"attributeName")??"")),N=Math.abs(h-y)<=1e-6&&Math.abs(k-T)<=1e-6&&!P?"square":"rectangle";return Ge(e,n,N,"materialized",w)}if(a==="circle"){let m=l("cx","x")??0,g=l("cy","y")??0,h=l("r","radius")??0;return h<0?(d("Circle radius must not be negative."),Ge(e,n,null,"invalid")):h===0?Ge(e,n,null,"empty"):Ge(e,n,"circle","materialized",f({x:m,y:g,radius:h,...u}))}if(a==="ellipse"){let m=l("cx","x")??0,g=l("cy","y")??0,h=l("rx","x"),y=l("ry","y");(h!==void 0&&h<0||y!==void 0&&y<0)&&d("Ellipse radii must not be negative.");let b=h!==void 0&&h>=0,v=y!==void 0&&y>=0,I=b?h:v?y:0,x=v?y:b?h:0;return I===0||x===0?Ge(e,n,null,"empty"):Math.abs(I-x)<=1e-6?Ge(e,n,"circle","materialized",f({x:m,y:g,radius:I,...u})):Ge(e,n,"ellipse","materialized",f({x:m,y:g,rx:I,ry:x,...u}))}if(a==="line"){let m={x1:l("x1","x")??0,y1:l("y1","y")??0,x2:l("x2","x")??0,y2:l("y2","y")??0};return f(m),Object.assign(m,u),Ge(e,n,"line","materialized",m)}if(a==="polyline"||a==="polygon"){let m=$R(C(n,"points"));if(m.odd&&d("The final unpaired polygon coordinate was ignored."),m.points.length===0)return Ge(e,n,"polyline","materialized",f({x:0,y:0,width:0,height:0,polylinePoints:[],polylineClosed:a==="polygon",...u}));let g=m.points.map(v=>v.x),h=m.points.map(v=>v.y),y=Math.min(...g),b=Math.min(...h);return Ge(e,n,"polyline","materialized",f({x:y,y:b,width:Math.max(...g)-y,height:Math.max(...h)-b,polylinePoints:m.points,polylineClosed:a==="polygon",...u}))}if(a==="path"){let m=kr(i,e,n,"d")??"",g=/^path\(\s*(["'])([\s\S]*)\1\s*\)$/i.exec(m.trim()),h=g?g[2]:m;if(!h||h.trim().toLowerCase()==="none"){let N=n.children.find(R=>R.kind==="element"&&["animate","set"].includes(R.localName.toLowerCase())&&C(R,"attributeName")==="d");N&&(h=C(N,"from")??C(N,"to")??"")}let y=Nn(h);y.error&&d(`Invalid path data: ${y.error.message}.`);let b=lS(y.commands),v=["marker","marker-start","marker-mid","marker-end"].some(N=>{let R=kr(i,e,n,N)?.trim().toLowerCase();return R!=null&&R!==""&&R!=="none"}),I=kr(i,e,n,"stroke-linecap")?.trim(),x=kr(i,e,n,"stroke")?.trim().toLowerCase(),k=Cu(i,e,n,"stroke-width","radius",c,o),T=(I==="round"||I==="square")&&x!==void 0&&x!==null&&x!==""&&x!=="none"&&(k??1)>0;if(!b.drawn&&!(b.points.length>0&&(v||T)))return Ge(e,n,null,"empty");let w=Sn(h);if(!w)return Ge(e,n,null,"empty");let P={x:w.minX,y:w.minY,width:w.maxX-w.minX,height:w.maxY-w.minY};return f(P),P.pathPoints=b.points,P.pathClosed=b.closed,P.pathCurveType=b.points.some(N=>N.segmentType)?"mixed":b.points.some(N=>N.handleIn||N.handleOut)?"cubic":"linear",P.pathTension=.5,Object.assign(P,u),Ge(e,n,"path","materialized",P)}if(a==="text"){let m=_R(t,n,o),g=DR(t,n,e,i),h=LR(i,e,n,c,m,o.rootFontSize),y=aS(i,r,e,"font-family")?uS(Bi(i,e,n,"font-family"))??"Inter, sans-serif":"Inter, sans-serif",b=o.textMetricsHost?.measureXHeight(y,h),v=b!==void 0&&Number.isFinite(b)&&b>=0?b:h*.5,I=FR(n,g.mode,m,h,o.rootFontSize,v),x=I.text,k=aS(i,r,e,"font-weight")?pS(Bi(i,e,n,"font-weight")):400,T=Bi(i,e,n,"font-style")??"normal",w=Bi(i,e,n,"line-height"),P=w?Wt(w)??Number(w):NaN,N=Number.isFinite(P)?P:1.2,R=St(Nu(kr(i,e,n,"x")),"x",m,h,o.rootFontSize,v)??0,$=St(Nu(kr(i,e,n,"y")),"y",m,h,o.rootFontSize,v)??0,A={};for(let[U,te]of[["x",R],["y",$]]){let Z=C(n,U),ne=kr(i,e,n,U),F=Ti(Z);if(Z===null||ne?.trim()!==Z.trim()||F.length!==1)continue;St(Z,U,m,h,o.rootFontSize,v)===te&&(A[U]={raw:Z,resolved:te})}let O={x:R,y:$,textX:R,textY:$,text:x,fontSize:h,fontFamily:y,fontWeight:k,fontStyle:T,lineHeight:N,useRichText:!1,isTextPath:!1};Object.keys(A).length>0&&(O.authoredTextPosition=A),Object.assign(O,qR(i,e,n)),I.linePositions&&(O.linePositions=I.linePositions),g.authored&&g.authored!=="normal"&&(O.whiteSpace=g.authored);let G=HR(n,x,g.mode,m,h,o.rootFontSize,v);G&&(O.charOffsets=G);let M=G?null:KR(n,e,r,i,x,g.mode,h,N,m,o.rootFontSize,v,o.textMetricsHost);M&&(O.useRichText=!0,O.richTextRuns=ar(M));let V=!G&&!M&&!I.linePositions?zR(n,x,g.mode):void 0,K=Cu(i,e,n,"textLength","x",c,o);K!==void 0&&K>=0&&(O.textLength=K);let X=C(n,"lengthAdjust");return(X==="spacing"||X==="spacingAndGlyphs")&&(O.lengthAdjust=X),Object.assign(O,WR(t,n,h)),Object.assign(O,u),Ge(e,n,"text","materialized",O,V)}if(a==="flowroot"){let m=Au(n).filter(b=>b.localName.toLowerCase()==="flowpara").map(dS);if(m.every(b=>b.length===0))return Ge(e,n,null,"empty");let g=Au(n).find(b=>["rect","circle","ellipse","path"].includes(b.localName.toLowerCase())),h=0,y=0;return g?.localName.toLowerCase()==="rect"&&(h=Re(C(g,"x"),$u("x",c,o))??0,y=Re(C(g,"y"),$u("y",c,o))??0),Ge(e,n,"text","materialized",{x:h,y:y+c,text:m.join(`
16
+ `),fontSize:c,fontFamily:"Inter, sans-serif",fontWeight:400,fontStyle:"normal",lineHeight:1.2,useRichText:!1,isTextPath:!1,...u})}if(a==="image"){let m=l("x","x")??0,g=l("y","y")??0,h=l("width","x"),y=l("height","y"),b=Be(n)?.value??"";if(!b||h===void 0||y===void 0)return Ge(e,n,null,"empty");if(h<0||y<0)return d("Image width and height must not be negative."),Ge(e,n,null,"invalid");if(h===0||y===0)return Ge(e,n,null,"empty");let v={x:m,y:g,width:h,height:y,...u};v.preserveAspectRatio=C(n,"data-preserve-aspect-ratio")!=="false";let I=C(n,"preserveAspectRatio")?.trim();return I&&I!=="none"&&(v.specPreserveAspectRatio=I),v.href=b,Ge(e,n,"image","materialized",v)}if(a==="foreignobject"){let m=l("x","x")??0,g=l("y","y")??0,h=l("width","x")??0,y=l("height","y")??0;if(h<0||y<0)return d("Foreign-object width and height must not be negative."),Ge(e,n,null,"invalid");if(h===0||y===0)return Ge(e,n,null,"empty");let b=C(n,"data-shape-type")??C(n,"data-media-kind"),v=b==="audio"||b==="video"?b:null;if(v){let w=n.children.find(O=>O.kind==="element"&&O.localName.toLowerCase()===v),P={x:m,y:g,width:h,height:y,mediaKind:v,href:w?C(w,"src")??"":"",...u},N=[["begin","data-begin"],["trimStart","data-trim-start"],["trimEnd","data-trim-end"],["volume","data-volume"],["playbackRate","data-playback-rate"],["naturalDuration","data-natural-duration"],["originalWidth","data-media-original-width"],["originalHeight","data-media-original-height"],["fadeInDuration","data-fade-in"],["fadeOutDuration","data-fade-out"]];for(let[O,G]of N){let M=Fo(C(n,G));M!==void 0&&(P[O]=M)}if(P.originalWidth===void 0){let O=Fo(C(n,"data-original-width"));O!==void 0&&(P.originalWidth=O)}if(P.originalHeight===void 0){let O=Fo(C(n,"data-original-height"));O!==void 0&&(P.originalHeight=O)}let R=w?C(w,"type"):null;R&&(P.mediaMimeType=R);let $=C(n,"data-poster")??(v==="video"&&w?C(w,"poster"):null);$&&(P.posterHref=$);let A=(C(n,"data-source-rect")??"").trim().split(/[\s,]+/u).map(Number);return A.length===4&&A.every(Number.isFinite)&&(P.sourceRect={x:A[0],y:A[1],width:A[2],height:A[3]}),C(n,"data-loop")==="true"&&(P.loop=!0),C(n,"data-muted")==="true"&&(P.muted=!0),Ge(e,n,v,"materialized",P)}let I=n.rawXml??"",x=I.indexOf(">"),k=I.lastIndexOf("</"),T=x>=0&&k>x?I.slice(x+1,k):"";return Ge(e,n,"foreign-object","materialized",{x:m,y:g,width:h,height:y,rawContent:T,...u})}return Ge(e,n,null,"deferred")}function Mu(t,e,n,r){let i=[],o=[],s=new Set,a=[...e.occurrences].sort(TR);for(let d of a){if(s.has(d.occurrenceId))throw new Error(`Duplicate SVG geometry occurrence ${d.occurrenceId}.`);s.add(d.occurrenceId);let u=t.index.element(d.correspondingSourceNodeId);if(!u)throw new Error(`SVG occurrence ${d.occurrenceId} has no source element.`);if(!(u.namespaceUri===Y||t.root.namespaceUri===null&&u.namespaceUri===null))continue;let f=u.localName.toLowerCase();IR.has(f)&&(f!=="flowroot"&&XR(t,u)||o.push(ZR(t,d,u,e,n,r,i)))}let c=new Map(o.map(d=>[d.occurrenceId,d])),l=Object.freeze({candidates:Object.freeze(o),candidate(d){return c.get(d)??null}});return Object.freeze({value:l,diagnostics:Object.freeze(i)})}var fS={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function Lo(t){let e=fS[t.trim().toLowerCase()];return e===void 0?null:{r:e>>16&255,g:e>>8&255,b:e&255}}function Ou(t){return fS[t.trim().toLowerCase()]!==void 0}var zu={color:"css-rgba",angle:"linear"},Qa={color:"opaque-rgb",angle:"shortest-arc"};function Oe(t,e,n){return t+(e-t)*n}function vS(t,e,n,r){if(r==="linear")return Oe(t,e,n);let i=((e-t)%360+540)%360-180;return t+i*n}function JR(t){let e=t.trim().toLowerCase();if(e==="transparent"||e==="none")return{r:0,g:0,b:0,a:0};if(t.startsWith("#")){let i=t.slice(1);if(i.length===3)return{r:parseInt(i[0]+i[0],16),g:parseInt(i[1]+i[1],16),b:parseInt(i[2]+i[2],16),a:1};if(i.length===6)return{r:parseInt(i.slice(0,2),16),g:parseInt(i.slice(2,4),16),b:parseInt(i.slice(4,6),16),a:1};if(i.length===8)return{r:parseInt(i.slice(0,2),16),g:parseInt(i.slice(2,4),16),b:parseInt(i.slice(4,6),16),a:parseInt(i.slice(6,8),16)/255}}let n=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*([\d.]+))?/);if(n)return{r:parseInt(n[1],10),g:parseInt(n[2],10),b:parseInt(n[3],10),a:n[4]!==void 0?parseFloat(n[4]):1};let r=Lo(e);return r?{...r,a:1}:null}function xS(t){if(!t)return null;let e=t.trim();if(e.startsWith("#")){if(e.length===4)return{r:parseInt(e[1]+e[1],16),g:parseInt(e[2]+e[2],16),b:parseInt(e[3]+e[3],16),a:1};if(e.length===7)return{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16),a:1}}let n=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return n?{r:parseInt(n[1],10),g:parseInt(n[2],10),b:parseInt(n[3],10),a:1}:null}function ec(t,e=zu.color){return e==="css-rgba"?JR(t):xS(t)}function TL(t,e=zu.color){if(!t)return!1;if(e==="opaque-rgb")return xS(t)!==null;if(t.startsWith("#")||t.startsWith("rgb"))return!0;let n=t.trim().toLowerCase();return n==="transparent"||n==="none"?!0:Ou(n)}function mS(t,e,n){let r=i=>Math.round(Math.max(0,Math.min(255,i))).toString(16).padStart(2,"0");return`#${r(t)}${r(e)}${r(n)}`}function IS(t,e,n,r=zu.color){let i=ec(t,r),o=ec(e,r);if(!i||!o)return n<.5?t:e;if(r==="opaque-rgb")return mS(Oe(i.r,o.r,n),Oe(i.g,o.g,n),Oe(i.b,o.b,n));let s=i.a===0?o.r:i.r,a=i.a===0?o.g:i.g,c=i.a===0?o.b:i.b,l=o.a===0?i.r:o.r,d=o.a===0?i.g:o.g,u=o.a===0?i.b:o.b,p=Oe(s,l,n),f=Oe(a,d,n),m=Oe(c,u,n),g=Oe(i.a,o.a,n);return g>=.999?mS(p,f,m):`rgba(${Math.round(p)}, ${Math.round(f)}, ${Math.round(m)}, ${Math.round(g*1e3)/1e3})`}var wS="[+-]?(?:\\d+\\.?\\d*|\\.\\d+)(?:[eE][+-]?\\d+)?",gS=/[MLHVCSQTAZmlhvcsqtaz]/g;function ji(t){return t.match(new RegExp(wS,"g"))}function RL(t){return(ji(t)??[]).map(Number)}function kS(t,e,n){let r=ji(t),i=ji(e);if(!r||!i||r.length!==i.length)return t;let o=r.map(Number),s=i.map(Number),a=0;return t.replace(new RegExp(wS,"g"),()=>{let c=Oe(o[a],s[a],n);return a++,String(Math.round(c*1e3)/1e3)})}function QR(t,e){let n=t.match(gS)??[],r=e.match(gS)??[];return n.length!==r.length?!1:n.every((i,o)=>i===r[o])}function CL(t,e,n){return n<=0?t:n>=1?e:QR(t,e)?kS(t,e,n):n<.5?t:e}function $L(t,e,n){if(n<=0)return t;if(n>=1)return e;let r=ji(t),i=ji(e);return!r||!i||r.length!==i.length?n<.5?t:e:kS(t,e,n)}function NL(t,e,n){if(n<=0)return t;if(n>=1)return e;let r=l=>{let d=l.trim().toLowerCase();if(!d||d==="none")return null;let u=(ji(l)??[]).map(Number);return u.length===0||u.some(p=>!Number.isFinite(p)||p<0)?null:u},i=r(t),o=r(e);if(!i||!o)return n<.5?t:e;let s=(l,d)=>d===0?l:s(d,l%d),a=i.length*o.length/s(i.length,o.length),c=[];for(let l=0;l<a;l++)c.push(String(Oe(i[l%i.length],o[l%o.length],n)));return c.join(" ")}function Pr(t){return Array.isArray(t)&&t.every(e=>typeof e=="number"&&Number.isFinite(e))}function Du(t,e,n){return t.map((r,i)=>Oe(r,e[i],n))}function eC(t,e,n){return t.length!==e.length?n<.5?t:e:t.map((r,i)=>({x:Oe(r.x,e[i].x,n),y:Oe(r.y,e[i].y,n)}))}function tC(t,e,n){return t.length!==e.length?n<.5?t:e:t.map((r,i)=>{let o=e[i],s={...r,x:Oe(r.x,o.x,n),y:Oe(r.y,o.y,n)};return r.handleIn&&o.handleIn&&(s.handleIn={x:Oe(r.handleIn.x,o.handleIn.x,n),y:Oe(r.handleIn.y,o.handleIn.y,n)}),r.handleOut&&o.handleOut&&(s.handleOut={x:Oe(r.handleOut.x,o.handleOut.x,n),y:Oe(r.handleOut.y,o.handleOut.y,n)}),s})}function nC(t,e,n,r=Qa.angle){return t.length!==e.length?n<.5?t:e:t.map((i,o)=>{let s=e[o],a={...i},c=(l,d)=>l==null||d==null?l??d??null:Oe(l,d,n);return("x"in i||"x"in s)&&(a.x=c(i.x,s.x)),("y"in i||"y"in s)&&(a.y=c(i.y,s.y)),typeof i.dx=="number"&&typeof s.dx=="number"&&(a.dx=Oe(i.dx,s.dx,n)),typeof i.dy=="number"&&typeof s.dy=="number"&&(a.dy=Oe(i.dy,s.dy,n)),typeof i.rotate=="number"&&typeof s.rotate=="number"&&(a.rotate=vS(i.rotate,s.rotate,n,r)),a})}function hS(t){if(typeof t!="object"||t===null)return!1;let e=t;return(e.type==="linear-gradient"||e.type==="radial-gradient")&&Array.isArray(e.stops)}function rC(t,e,n,r=Qa.color){if(t.type!==e.type||t.stops.length!==e.stops.length)return null;let i=t.stops.map((s,a)=>({offset:Oe(s.offset,e.stops[a].offset,n),color:IS(s.color,e.stops[a].color,n,r),opacity:Oe(s.opacity,e.stops[a].opacity,n)})),o={...t,stops:i};for(let s of Object.keys(e)){if(s==="stops"||s==="type"||s==="id"||s==="sourceId")continue;let a=t[s],c=e[s];typeof a=="number"&&typeof c=="number"&&(o[s]=Oe(a,c,n))}return o}function yS(t){if(typeof t!="object"||t===null)return!1;let e=t;return typeof e.x!="number"||typeof e.y!="number"?!1:Object.keys(e).every(n=>n==="x"||n==="y")}function SS(t){if(typeof t!="object"||t===null||Array.isArray(t))return!1;let e=Object.getPrototypeOf(t);return e===Object.prototype||e===null}function iC(t,e,n){let r={...t},i=new Set([...Object.keys(t),...Object.keys(e)]);for(let o of i){let s=t[o],a=e[o];typeof s=="number"&&typeof a=="number"?r[o]=Oe(s,a,n):Pr(s)&&Pr(a)&&s.length===a.length?r[o]=Du(s,a,n):r[o]=n<.5?s:a}return r}var oC=new Set(["fillColor","borderColor"]),sC=new Set(["polylinePoints"]),aC=new Set(["pathPoints","textPathPoints"]),cC=new Set(["rotation","shiftAngle","skewX","skewY"]),lC=new Set(["customPivot"]),bS=[1,0,0,1,0,0];function dC(t,e,n,r){if(!(lC.has(t)&&(e==null||n==null))){if(t==="children"&&Array.isArray(e)&&Array.isArray(n))return pC(e,n,r);if(t==="transformMatrix"){let i=Pr(e)?e:e==null&&Pr(n)?bS:null,o=Pr(n)?n:n==null&&Pr(e)?bS:null;if(i&&o&&i.length===o.length)return Du(i,o,r)}if(!(e==null&&n==null)){if(e==null)return n;if(n==null)return e;if(oC.has(t)&&typeof e=="string"&&typeof n=="string")return IS(e,n,r,Qa.color);if(cC.has(t)&&typeof e=="number"&&typeof n=="number")return vS(e,n,r,Qa.angle);if(typeof e=="number"&&typeof n=="number")return Oe(e,n,r);if(typeof e=="string"&&typeof n=="string"){let i=parseFloat(e),o=parseFloat(n);return Number.isFinite(i)&&Number.isFinite(o)&&String(i)===e&&String(o)===n?String(Oe(i,o,r)):r<.5?e:n}if(Pr(e)&&Pr(n)&&e.length===n.length)return Du(e,n,r);if(sC.has(t)&&Array.isArray(e)&&Array.isArray(n))return eC(e,n,r);if(aC.has(t)&&Array.isArray(e)&&Array.isArray(n))return tC(e,n,r);if(t==="charOffsets"&&Array.isArray(e)&&Array.isArray(n))return nC(e,n,r);if((t==="fillGradient"||t==="strokeGradient")&&hS(e)&&hS(n)){let i=rC(e,n,r);if(i)return i}return yS(e)&&yS(n)?{x:Oe(e.x,n.x,r),y:Oe(e.y,n.y,r)}:SS(e)&&SS(n)?iC(e,n,r):r<.5?e:n}}}function uC(t,e,n){let r={...t},i=new Set([...Object.keys(t),...Object.keys(e)]);for(let o of i)r[o]=dC(o,t[o],e[o],n);return r}function pC(t,e,n){let r=Math.max(0,Math.min(1,n)),i=new Map(t.map(c=>[c.id,c])),o=new Map(e.map(c=>[c.id,c])),s=[],a=new Set;for(let c of e){let l=i.get(c.id);if(l&&l.type===c.type)a.add(c.id),s.push({...c,state:uC(l.state,c.state,r)});else{let d=c.state.opacity??1;s.push({...c,state:{...c.state,opacity:d*r}})}}for(let c of t){if(a.has(c.id))continue;let l=c.state.opacity??1,d=o.has(c.id)?PS(c,"__variant_from__"):c;s.push({...d,state:{...d.state,opacity:l*(1-r)}})}return s}function PS(t,e){let n=t.state.children;return{...t,id:`${e}${t.id}`,state:{...t.state,...Array.isArray(n)?{children:n.map(r=>PS(r,e))}:{}}}}function fC(t,e,n,r,i,o,s,a){if(t!=="mask"||e||n!=="userSpaceOnUse"||r.length!==1||!Dt(s))return!1;let c=r[0],l=i.candidate(c.occurrenceId);if(!l||l.status!=="materialized"||l.canonicalType!=="rectangle"&&l.canonicalType!=="square")return!1;let d=l.state;if(d.transformMatrix!==void 0||d.rawTransform!==void 0)return!1;let u=ec(o.value(c.occurrenceId,"fill")??"black");if(!u||u.r!==255||u.g!==255||u.b!==255||u.a!==1)return!1;let p=Number(o.value(c.occurrenceId,"fill-opacity")??1),f=Number(o.value(c.occurrenceId,"opacity")??1);if(p!==1||f!==1)return!1;let m=Number(d.x??0),g=Number(d.y??0),h=Number(d.width??d.size),y=Number(d.height??d.size),b=(v,I)=>Math.abs(v-I)<=1e-9;return b(m,0)&&b(g,0)&&b(h,a.viewport.width)&&b(y,a.viewport.height)}var Lu=new Set(["animate","animatemotion","animatetransform","set"]),nc=new Set(["clippath","defs","filter","lineargradient","marker","mask","pattern","radialgradient","symbol"]),RS=new Set(["a","g","switch","use"]),Bu=new Set(["desc","metadata","title"]),mC=new Set([...Lu,...Bu,"circle","ellipse","line","path","polygon","polyline","rect","text","use"]);function Bo(t){if(!t||typeof t!="object"&&typeof t!="function"||Object.isFrozen(t))return t;for(let e of Object.values(t))Bo(e);return Object.freeze(t)}function CS(t){if(t.namespaceUri!==Y)return null;let e=t.localName.toLowerCase();return e==="clippath"?"clip":e==="mask"?"mask":null}function Go(t,e,n,r,i){let o=CS(e)??"clip";return Object.freeze({severity:"warning",code:"invalid-svg-attribute",source:n.source,entrypoint:n.entrypoint,capability:o==="clip"?"clip-definitions":"mask-definitions",sourceId:C(e,"id")??void 0,sourceNodeId:e.sourceNodeId,elementName:e.name,documentPath:t.index.sourcePath(e.sourceNodeId),message:`${e.name} ${r} value ${i} is invalid and uses its initial value.`})}function _u(t,e,n,r,i,o){let s=C(e,i);return s===null||s===""?o:s==="userSpaceOnUse"||s==="objectBoundingBox"?s:(r.push(Go(t,e,n,i,s)),o)}function Fu(t,e,n,r,i,o,s,a,c){let l=r.value(n.occurrenceId,s)??C(e,s);if(l===null||l.trim()==="")return c;let d=l.trim();return a.includes(d)?d:(o.push(Go(t,e,i,s,l)),c)}function gC(t,e,n,r){let i={x:C(e,"x"),y:C(e,"y"),width:C(e,"width"),height:C(e,"height")},{x:o,y:s,width:a,height:c}=i;if([o,s,a,c].every(u=>u===null))return null;let l={x:"-10%",y:"-10%",width:"120%",height:"120%"},d=Object.fromEntries(Object.entries(i).map(([u,p])=>p===null?[u,l[u]]:gt(p)?[u,p]:(r.push(Go(t,e,n,u,p)),[u,l[u]])));return Object.freeze({x:d.x,y:d.y,width:d.width,height:d.height})}function TS(t){let e=gt(t);return!!(e&&e.value<=0)}function $S(t,e,n){let r=t.parentOccurrenceId,i=new Set;for(;r;){if(r===e.occurrenceId)return!0;if(i.has(r))return!1;i.add(r),r=n.get(r)?.parentOccurrenceId??null}return!1}function NS(t,e,n){let r=t.index.parent(e);for(;r&&r.sourceNodeId!==n;){if(nc.has(r.localName.toLowerCase()))return!0;r=t.index.parent(r.sourceNodeId)}return r===null}function Gu(t,e,n){let r=new Map(n.map(i=>[i.occurrenceId,i]));return n.filter(i=>$S(i,e,r)?!(i.usePath.length===0&&NS(t,i.correspondingSourceNodeId,e.correspondingSourceNodeId)):!1)}function Vu(t,e,n,r){let i=t,o=new Set;for(;i&&i.occurrenceId!==e.occurrenceId;){if(o.has(i.occurrenceId)||(o.add(i.occurrenceId),r.value(i.occurrenceId,"display")==="none"))return!1;let s=r.value(i.occurrenceId,"visibility");if(s==="hidden"||s==="collapse")return!1;i=i.parentOccurrenceId?n.get(i.parentOccurrenceId):void 0}return i?.occurrenceId===e.occurrenceId}function hC(t,e,n,r,i){let o=n.occurrences,s=new Map(r.candidates.map(l=>[l.occurrenceId,l])),a=new Set(n.resolutions.map(l=>l.useOccurrenceId)),c=new Map(o.map(l=>[l.occurrenceId,l]));for(let l of Gu(t,e,o)){if(!Vu(l,e,c,i)){if(l.occurrenceId!==e.occurrenceId)return!0;continue}let d=t.index.element(l.correspondingSourceNodeId);if(!d)return!0;let u=d.localName.toLowerCase();if(Lu.has(u)||u==="style"||u==="script"||["clip-path","mask","filter"].some(f=>(i.value(l.occurrenceId,f)??"").includes("url(")))return!0;if(Bu.has(u))continue;if(RS.has(u)){if(u!=="use")continue;return a.has(l.occurrenceId),!0}if(nc.has(u)){if(l.usePath.length>0)return!0;continue}let p=s.get(l.occurrenceId);if(!p||p.status==="deferred")return!0}return!1}function yC(t,e,n,r,i){let o=new Map(r.candidates.map(l=>[l.occurrenceId,l])),s=new Set(n.resolutions.map(l=>l.useOccurrenceId)),a=new Map(n.occurrences.map(l=>[l.occurrenceId,l])),c=!1;for(let l of Gu(t,e,n.occurrences)){if(!Vu(l,e,a,i))continue;let d=t.index.element(l.correspondingSourceNodeId);if(!d)return!1;let u=d.localName.toLowerCase();if(Bu.has(u))continue;if(Lu.has(u)||u==="style"||u==="script"||["clip-path","mask","filter"].some(f=>(i.value(l.occurrenceId,f)??"").includes("url(")))return!1;if(u==="use"){if(l.parentOccurrenceId!==e.occurrenceId||l.usePath.length>0||C(d,"id")!==null||!s.has(l.occurrenceId))return!1;c=!0;continue}if(RS.has(u)||nc.has(u))return!1;let p=o.get(l.occurrenceId);if(!p||p.status!=="materialized")return!1}return c}function SC(t,e,n,r){let i=C(e,"transform");if(!i)return _e;let o=on(i);return o||(r.push(Go(t,e,n,"transform",i)),_e)}function bC(t,e,n,r,i,o,s){let a=CS(e);if(!a)return null;let c=n.direct(e.sourceNodeId);if(!c)throw new Error(`SVG ${e.name} ${e.sourceNodeId} has no occurrence.`);let l=new Map(n.occurrences.map(A=>[A.occurrenceId,A])),d=i.candidates.flatMap(A=>{let O=l.get(A.occurrenceId);return!O||!$S(O,c,l)||O.usePath.length===0&&NS(t,A.sourceNodeId,e.sourceNodeId)||!Vu(O,c,l,r)?[]:A.status==="materialized"?[O]:[]}),u=a==="clip"&&n.resourcePolicy(e.sourceNodeId)?.status==="invalid",p=a==="clip"&&t.index.children(e.sourceNodeId).some(A=>!mC.has(A.localName.toLowerCase()));if(p&&s.push(Object.freeze({severity:"warning",code:"invalid-svg-attribute",source:o.source,entrypoint:o.entrypoint,capability:"clip-definitions",sourceId:C(e,"id")??void 0,sourceNodeId:e.sourceNodeId,elementName:e.name,documentPath:t.index.sourcePath(e.sourceNodeId),message:"A clipPath may directly contain only paths, text, basic shapes, use, animation, and descriptive elements."})),t.index.elements.some(A=>{if(A.namespaceUri!==Y||A.localName.toLowerCase()!=="use")return!1;let O=t.index.parent(A.sourceNodeId);for(;O&&O.sourceNodeId!==e.sourceNodeId;){if(nc.has(O.localName.toLowerCase()))return!1;O=t.index.parent(O.sourceNodeId)}return O?.sourceNodeId===e.sourceNodeId})&&n.resourcePolicy(e.sourceNodeId)===null)throw new Error(`SVG ${e.name} ${e.sourceNodeId} requires a matching use resource-root plan.`);let m=a==="mask"?gC(t,e,o,s):null,g=!!(m&&(TS(m.width)||TS(m.height))),h=hC(t,c,n,i,r),y=h&&!yC(t,c,n,i,r)?[]:d,b=u||p?"invalid":g||!h&&d.length===0?"empty":"materialized",v=a==="clip"?_u(t,e,o,s,"clipPathUnits","userSpaceOnUse"):null,I=a==="clip"?Fu(t,e,c,r,o,s,"clip-rule",["nonzero","evenodd"],"nonzero"):null,x=I==="evenodd"||r.style(c.occurrenceId)?.cascadedValues["clip-rule"]!==void 0?I:null,k=a==="mask"?_u(t,e,o,s,"maskUnits","objectBoundingBox"):null,T=a==="mask"?_u(t,e,o,s,"maskContentUnits","userSpaceOnUse"):null,w=a==="mask"?Fu(t,e,c,r,o,s,"mask-type",["luminance","alpha"],"luminance"):null,P=SC(t,e,o,s),N=Bo({sourceNodeId:e.sourceNodeId,sourceId:C(e,"id"),type:a,status:b,representation:h?"raw":"decomposed",identity:fC(a,h,T,d,i,r,P,o),clipPathUnits:v,clipRule:x,maskUnits:k,maskContentUnits:T,maskType:w,region:m,geometrySourceNodeIds:Object.freeze(h?[]:d.map(A=>A.correspondingSourceNodeId)),rawDefinition:h?e.rawXml??"":null}),R=new Map,$=new Map;for(let A of Gu(t,c,n.occurrences)){let O=t.index.element(A.correspondingSourceNodeId);if(O){if(!R.has(O.sourceNodeId)){let G=C(O,"transform");if(!G)R.set(O.sourceNodeId,_e);else{let M=on(G);M?R.set(O.sourceNodeId,M):(s.push(Go(t,O,o,"transform",G)),R.set(O.sourceNodeId,_e))}}a==="clip"&&$.set(A.occurrenceId,Fu(t,O,A,r,o,s,"clip-rule",["nonzero","evenodd"],N.clipRule??"nonzero"))}}return Object.freeze({definition:N,element:e,occurrence:c,rootTransform:P,transformBySourceNodeId:R,clipRuleByOccurrenceId:$,geometryOccurrences:Object.freeze(y)})}function vC(t){return t.edges.filter(e=>e.binding==="applied-css"&&e.participation==="consumer"&&(e.kind==="clip-path"&&e.propertyName==="clip-path"||e.kind==="mask-image"&&(e.propertyName==="mask"||e.propertyName==="mask-image")))}function xC(t,e,n){let r=t.occurrenceId??e.direct(t.fromSourceNodeId)?.occurrenceId;if(!r)return null;let i=t.propertyName==="clip-path"?"clip":"mask",o=t.targetSourceNodeId?n.get(t.targetSourceNodeId):void 0,s=t.validity==="valid"&&o?.definition.type===i&&o.definition.status!=="invalid";return Object.freeze({bindingId:`clip-mask-binding:${t.resourceReferenceId}:${r}`,resourceReferenceId:t.resourceReferenceId,consumerOccurrenceId:r,consumerSourceNodeId:t.fromSourceNodeId,propertyName:t.propertyName==="clip-path"?"clip-path":"mask",authoredValue:t.propertyValue,targetAuthoredId:t.targetAuthoredId,targetSourceNodeId:t.targetSourceNodeId,definitionSourceNodeId:s?t.targetSourceNodeId??null:null,status:s?"materialized":"invalid-reference"})}function IC(t){return he(qe(t.x,t.y),Ci(t.width,t.height))}function wC(t,e){let r=(t.definition.type==="clip"?t.definition.clipPathUnits:t.definition.maskContentUnits)==="objectBoundingBox"?IC(e):_e;return he(r,t.rootTransform)}function tc(t,e,n,r,i){let o=n==="x"||n==="width",s=o?r.width:r.height,a=n==="x"?r.x:n==="y"?r.y:0;if(!gt(t))return null;if(e==="objectBoundingBox"){let d=Re(t,{percentBasis:1,viewportWidth:i.viewport.width,viewportHeight:i.viewport.height,rootFontSize:i.rootFontSize,fontSize:i.rootFontSize});return d===void 0?null:a+d*s}let l=Re(t,{percentBasis:o?i.viewport.width:i.viewport.height,viewportWidth:i.viewport.width,viewportHeight:i.viewport.height,rootFontSize:i.rootFontSize,fontSize:i.rootFontSize});return l===void 0?null:l}function kC(t,e,n){if(!t.region||!t.maskUnits)return null;let r=tc(t.region.x,t.maskUnits,"x",e,n),i=tc(t.region.y,t.maskUnits,"y",e,n),o=tc(t.region.width,t.maskUnits,"width",e,n),s=tc(t.region.height,t.maskUnits,"height",e,n);return r===null||i===null||o===null||s===null?null:Object.freeze({x:r,y:i,width:o,height:s})}function PC(t,e,n,r,i){let o=new Map(r.occurrences.map(u=>[u.occurrenceId,u])),s=[],a=n.parentOccurrenceId,c=new Set;for(;a&&a!==e.occurrence.occurrenceId&&!c.has(a);){c.add(a);let u=o.get(a);if(!u)break;s.push(u),a=u.parentOccurrenceId}let l=_e,d=e.definition.type==="clip"?e.definition.clipPathUnits:e.definition.maskContentUnits;for(let u of s.reverse()){let p=t.index.element(u.correspondingSourceNodeId);if(p&&(l=he(l,e.transformBySourceNodeId.get(p.sourceNodeId)??_e),p.localName.toLowerCase()==="use")){let f=d==="objectBoundingBox"?1:i.viewport.width,m=d==="objectBoundingBox"?1:i.viewport.height,g=Re(C(p,"x"),{percentBasis:f,viewportWidth:i.viewport.width,viewportHeight:i.viewport.height,rootFontSize:i.rootFontSize})??0,h=Re(C(p,"y"),{percentBasis:m,viewportWidth:i.viewport.width,viewportHeight:i.viewport.height,rootFontSize:i.rootFontSize})??0;l=he(l,qe(g,h))}}return l}function ju(t,e,n,r,i,o){let s=[],a=t.index.elements.flatMap(g=>{let h=bC(t,g,e,n,i,o,s);return h?[h]:[]}),c=new Map(a.map(g=>[g.definition.sourceNodeId,g])),l=vC(r).flatMap(g=>{let h=xC(g,e,c);return h?[h]:[]}),d=new Map;for(let g of l){let h=`${g.consumerOccurrenceId}\0${g.propertyName}`,y=d.get(h)??[];y.push(g),d.set(h,y)}let u=new Map([...d].map(([g,h])=>[g,Object.freeze(h)])),p=Object.freeze(a.map(g=>g.definition)),f=Object.freeze(l),m=Bo({definitions:p,bindings:f,definition(g){return c.get(g)?.definition??null},bindingsFor(g,h){return u.get(`${g}\0${h}`)??[]},binding(g,h,y){let b=u.get(`${g}\0${h}`)??[];return y===void 0?b[0]??null:b.find(v=>v.resourceReferenceId===y)??null},resolve(g,h){let y=g.definitionSourceNodeId?c.get(g.definitionSourceNodeId):void 0;if(!y||g.status!=="materialized")return Bo({status:"invalid-reference",contentMatrix:null,region:null,geometrySourceNodeIds:[],geometryPlacements:[],rawDefinition:null});let b=wC(y,h.consumerObjectBounds),v=(y.definition.clipPathUnits==="objectBoundingBox"||y.definition.maskContentUnits==="objectBoundingBox"||y.definition.maskUnits==="objectBoundingBox")&&(h.consumerObjectBounds.width===0||h.consumerObjectBounds.height===0),I=y.definition.status==="empty"||v,x=(I?[]:y.geometryOccurrences).map(k=>Object.freeze({occurrenceId:k.occurrenceId,sourceNodeId:k.correspondingSourceNodeId,matrix:he(b,PC(t,y,k,e,o)),clipRule:y.definition.type==="clip"?y.clipRuleByOccurrenceId.get(k.occurrenceId)??y.definition.clipRule??"nonzero":null}));return Bo({status:I?"empty":g.status,contentMatrix:b,region:kC(y.definition,h.consumerObjectBounds,o),geometrySourceNodeIds:I?[]:y.definition.geometrySourceNodeIds,geometryPlacements:x,rawDefinition:y.definition.rawDefinition})}});return Object.freeze({value:m,diagnostics:Object.freeze(s)})}var TC=new Set(["id","viewbox","preserveaspectratio","refx","refy","markerwidth","markerheight","markerunits","orient"]),RC=new Set(["a","circle","ellipse","foreignobject","g","image","line","path","polygon","polyline","rect","svg","switch","text","use"]),CC=new Set(["animate","animatemotion","animatetransform","set"]),$C="[+-]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:[eE][+-]?\\d+)?",NC=new RegExp(`^(${$C})(deg|grad|rad|turn)?$`,"i");function AC(t,e){let n=Math.min(t.length,e.length);for(let r=0;r<n;r++){let i=t[r]-e[r];if(i!==0)return i}return t.length-e.length}function EC(t,e){return AC(t.orderKey,e.orderKey)||t.productIndex-e.productIndex||t.occurrenceId.localeCompare(e.occurrenceId)}function Ui(t,e,n,r,i,o){return Object.freeze({severity:"warning",code:"invalid-svg-attribute",source:n.source,entrypoint:n.entrypoint,capability:"markers",sourceId:C(e,"id")??void 0,sourceNodeId:e.sourceNodeId,elementName:e.name,documentPath:t.index.sourcePath(e.sourceNodeId),message:`Marker ${r} value ${i} ${o}.`})}function MC(t){let e=NC.exec(t.trim());if(!e)return null;let n=Number(e[1]);if(!Number.isFinite(n))return null;switch((e[2]??"deg").toLowerCase()){case"deg":return n;case"grad":return n*.9;case"rad":return n*180/Math.PI;case"turn":return n*360;default:return null}}function OC(t){let e=t.trim().split(/\s+/).filter(Boolean);if(e.length<1||e.length>2)return!1;let n=Do(t);return e[0]!==n.align?!1:e.length===1||e[1]==="meet"||e[1]==="slice"}function DC(t,e){let n=C(e,"data-ssk-marker-name");if(n!==null)return n;let r=t??"marker";return r.replace(/^marker[-_]?/i,"").replace(/[-_]/g," ")||r}function zC(t){let e={};for(let n of t.attributes)n.name==="xmlns"||n.prefix==="xmlns"||n.namespaceUri===null&&TC.has(n.localName.toLowerCase())||(e[n.name]=n.value);return Object.freeze(e)}function _C(t,e,n){let r=t.parentOccurrenceId,i=new Set;for(;r;){if(r===e)return!0;if(i.has(r))return!1;i.add(r),r=n.get(r)?.parentOccurrenceId??null}return!1}function FC(t,e,n){let r=new Map(e.occurrences.map(d=>[d.occurrenceId,d])),i=e.occurrences.filter(d=>_C(d,n.occurrenceId,r)).sort(EC),o=new Set,s=[],a=[],c=d=>{let u=d.parentOccurrenceId;for(;u&&u!==n.occurrenceId&&!o.has(u);)u=r.get(u)?.parentOccurrenceId??null;return u===n.occurrenceId?null:u},l=d=>{if(d.usePath.length>0)return!1;let u=d.parentOccurrenceId;for(;u&&u!==n.occurrenceId;){let p=r.get(u);if(!p)return!1;if(t.index.element(p.correspondingSourceNodeId)?.localName.toLowerCase()==="defs")return!0;u=p.parentOccurrenceId}return!1};for(let d of i){let u=t.index.element(d.correspondingSourceNodeId);if(!u||u.namespaceUri!==Y)continue;let p=u.localName.toLowerCase();if(CC.has(p)){a.push(Object.freeze({occurrenceId:d.occurrenceId,sourceNodeId:d.correspondingSourceNodeId,parentOccurrenceId:c(d),elementName:u.name,orderKey:Object.freeze([...d.orderKey])}));continue}if(!RC.has(p)||l(d))continue;let f=c(d);o.add(d.occurrenceId),s.push(Object.freeze({occurrenceId:d.occurrenceId,sourceNodeId:d.correspondingSourceNodeId,parentOccurrenceId:f,elementName:u.name,orderKey:Object.freeze([...d.orderKey])}))}return{content:Object.freeze(s),animations:Object.freeze(a)}}function Uu(t,e,n,r,i){let o=[],s=new Map,a=[],c=r.resources.filter(d=>d.kind==="marker").sort((d,u)=>{let p=t.index.element(d.sourceNodeId)?.elementOrder??0,f=t.index.element(u.sourceNodeId)?.elementOrder??0;return p-f});for(let d of c){let u=t.index.element(d.sourceNodeId);if(!u||u.namespaceUri!==Y)continue;let p=e.occurrences.find(H=>H.correspondingSourceNodeId===d.sourceNodeId&&H.usePath.length===0);if(!p)continue;let f=C(u,"id"),m=n.style(p.occurrenceId),g=Re(m?.resolvedValues["font-size"]??null,{fontSize:i.rootFontSize,rootFontSize:i.rootFontSize,viewportWidth:i.viewport.width,viewportHeight:i.viewport.height}),h=g&&g>0?g:i.rootFontSize,y=C(u,"viewBox"),b=y===null?null:at(y),v=!1,I=!1;y!==null&&(!b||b.width<0||b.height<0?(v=!0,o.push(Ui(t,u,i,"viewBox",y,"is not a valid four-number viewBox with non-negative dimensions"))):(b.width===0||b.height===0)&&(I=!0));let x=C(u,"preserveAspectRatio");x!==null&&!OC(x)&&(v=!0,o.push(Ui(t,u,i,"preserveAspectRatio",x,"does not match the SVG preserveAspectRatio grammar")));let k={},T=H=>{let oe=C(u,H);return oe!==null&&(k[H]=oe),oe},w=T("markerWidth"),P=T("markerHeight"),N=H=>({percentBasis:H==="width"?i.viewport.width:i.viewport.height,viewportWidth:i.viewport.width,viewportHeight:i.viewport.height,fontSize:h,rootFontSize:i.rootFontSize}),R=(H,oe,re)=>{if(oe===null)return 3;let xe=Re(oe,N(re));return xe===void 0||xe<0?(v=!0,o.push(Ui(t,u,i,H,oe,xe===void 0?"is not a resolvable length":"must not be negative")),3):(xe===0&&(I=!0),xe)},$=R("markerWidth",w,"width"),A=R("markerHeight",P,"height"),O={width:b?.width??$,height:b?.height??A},G=H=>{let oe=T(H);if(oe===null)return 0;let re=oe.trim(),xe=H==="refX"?O.width:O.height;if(H==="refX"){if(re==="left")return 0;if(re==="center")return xe/2;if(re==="right")return xe}else{if(re==="top")return 0;if(re==="center")return xe/2;if(re==="bottom")return xe}let Ze=Re(oe,{...N(H==="refX"?"width":"height"),percentBasis:xe});return Ze!==void 0?Ze:(v=!0,o.push(Ui(t,u,i,H,oe,"is not a valid marker reference length or keyword")),0)},M=G("refX"),V=G("refY"),K=T("markerUnits"),X="strokeWidth";K==="userSpaceOnUse"?X="userSpaceOnUse":K!==null&&K!=="strokeWidth"&&(v=!0,o.push(Ui(t,u,i,"markerUnits",K,"must be strokeWidth or userSpaceOnUse")));let U=T("orient"),te=0;if(U==="auto"||U==="auto-start-reverse")te=U;else if(U!==null){let H=MC(U);H===null?(v=!0,o.push(Ui(t,u,i,"orient",U,"is not an orientation keyword, number, or angle"))):te=H}let Z=C(u,"overflow"),ne=Z==="visible"||Z==="hidden"?Z:void 0,F=FC(t,e,p),j=Object.freeze({sourceNodeId:u.sourceNodeId,sourceId:f,name:DC(f,u),status:v?"invalid":I?"empty":"materialized",...y!==null?{viewBox:y}:{},...x!==null?{preserveAspectRatio:x}:{},refX:M,refY:V,markerWidth:$,markerHeight:A,markerUnits:X,orient:te,...ne?{overflow:ne}:{},authoredGeometry:Object.freeze(k),rootAttributes:zC(u),content:F.content,animations:F.animations});s.set(j.sourceNodeId,j),a.push(j)}let l=Object.freeze({candidates:Object.freeze(a),candidate:d=>s.get(d)??null});return Object.freeze({value:l,diagnostics:Object.freeze(o)})}var zS=["x1","y1","x2","y2"],LC=["cx","cy","r","fx","fy","fr"],AS=Object.freeze({x1:0,y1:0,x2:1,y2:0});function Uo(t){return t.namespaceUri!==Y?null:t.localName.toLowerCase()==="lineargradient"?"linear-gradient":t.localName.toLowerCase()==="radialgradient"?"radial-gradient":null}function Tr(t,e,n,r,i,o){return Object.freeze({severity:"warning",code:"invalid-svg-attribute",source:n.source,entrypoint:n.entrypoint,capability:"gradients",sourceId:C(e,"id")??void 0,sourceNodeId:e.sourceNodeId,elementName:e.name,documentPath:t.index.sourcePath(e.sourceNodeId),message:`Gradient ${r} value ${i} ${o}.`})}function BC(t,e,n){let r=[n],i=new Set([n.sourceNodeId]);for(let o of e.templateChain(n.sourceNodeId)){if(o.validity!=="valid"||!o.targetSourceNodeId||i.has(o.targetSourceNodeId))break;let s=t.index.element(o.targetSourceNodeId);if(!s||!Uo(s))break;i.add(s.sourceNodeId),r.push(s)}return r}function ES(t,e,n){for(let r of t){if(n&&Uo(r)!==n)continue;let i=C(r,e);if(i!==null)return i}return null}function MS(t,e,n){for(let r of t){if(n&&Uo(r)!==n)continue;let i=C(r,e);if(i!==null)return Object.freeze({raw:i,ownerSourceNodeId:r.sourceNodeId})}return null}function GC(t,e,n,r){let i=t.direct(n.sourceNodeId);return i?e.value(i.occurrenceId,r):null}function _S(t,e,n,r){let i=t.direct(n.sourceNodeId),o=i?e.style(i.occurrenceId):null;return o?.cascadedValues[r]?o.resolvedValues[r]??o.specifiedValues[r]??null:C(n,r)}function Hu(t){let e=/^([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?)\s*(%)?$/u.exec(t.trim());if(!e)return null;let n=Number(e[1]);return Number.isFinite(n)?e[2]?n/100:n:null}function OS(t,e,n,r){let i=GC(t,e,n,"font-size"),o=Re(i,{percentBasis:r.rootFontSize,viewportWidth:r.viewport.width,viewportHeight:r.viewport.height,fontSize:r.rootFontSize,rootFontSize:r.rootFontSize});return o!==void 0&&o>0?o:r.rootFontSize}function Vo(t,e,n,r){if(e==="objectBoundingBox")return Hu(t);let i=n==="x"?r.viewport.width:n==="y"?r.viewport.height:Math.hypot(r.viewport.width,r.viewport.height)/Math.SQRT2;return Re(t,{percentBasis:i,viewportWidth:r.viewport.width,viewportHeight:r.viewport.height,fontSize:r.fontSize,rootFontSize:r.rootFontSize})??null}function jo(t){return t==="r"||t==="fr"?"radius":t.endsWith("x")||t==="x1"||t==="x2"||t==="cx"||t==="fx"?"x":"y"}function FS(t,e){let n={};if(t.type==="linear-gradient"){for(let i of zS){let o=t.authoredGeometry[i];n[i]=o===void 0?AS[i]:Vo(o,t.gradientUnits,jo(i),e)??AS[i]}return Object.freeze(n)}let r=Object.freeze({cx:.5,cy:.5,r:.5,fr:0});for(let i of["cx","cy","r","fr"]){let o=t.authoredGeometry[i];n[i]=o===void 0?r[i]:Vo(o,t.gradientUnits,jo(i),e)??r[i]}for(let i of["fx","fy"]){let o=t.authoredGeometry[i],s=i==="fx"?n.cx:n.cy;n[i]=o===void 0?s:Vo(o,t.gradientUnits,jo(i),e)??s}return Object.freeze(n)}function DS(t){return t.children.filter(e=>e.kind==="element"&&e.namespaceUri===Y&&e.localName.toLowerCase()==="stop")}function VC(t,e,n,r,i,o){let s=e.find(f=>DS(f).length>0)??null,a=s?DS(s):[],c=[],l=0,d=e[0],u=n.direct(d.sourceNodeId),p=u?r.value(u.occurrenceId,"color"):null;for(let f of a){let m=C(f,"offset")??"0",g=Hu(m);g===null&&o.push(Tr(t,f,i,"offset",m,"is not a number or percentage"));let h=Math.min(1,Math.max(0,g??0)),y=Math.max(l,h);l=y;let b=n.direct(f.sourceNodeId),v=b?r.style(b.occurrenceId):null,I=(v?.cascadedValues["stop-color"]?v.specifiedValues["stop-color"]??v.resolvedValues["stop-color"]:C(f,"stop-color"))??"black",x=I.trim().toLowerCase(),k=/(?:^|[^-_a-z0-9])var\(/iu.test(I),T=x==="currentcolor"?p??"black":k?I:v?.resolvedValues["stop-color"]??I,w=_S(n,r,f,"stop-opacity")??"1",P=Hu(w);P===null&&o.push(Tr(t,f,i,"stop-opacity",w,"is not a number or percentage"));let N=Math.min(1,Math.max(0,P??1));T.trim().toLowerCase()==="transparent"&&(T="black",N=0),c.push(Object.freeze({occurrenceId:s?.sourceNodeId===d.sourceNodeId&&b?b.occurrenceId:`gradient-stop:${u?.occurrenceId??d.sourceNodeId}:${f.sourceNodeId}`,sourceNodeId:f.sourceNodeId,correspondingSourceNodeId:f.sourceNodeId,hostGradientSourceNodeId:d.sourceNodeId,offsetAuthored:C(f,"offset"),offset:y,color:T,opacity:N}))}return Object.freeze(c)}function jC(t,e,n,r,i,o,s){let a=Uo(e),c=BC(t,i,e),l=C(e,"id"),d=n.direct(e.sourceNodeId)?.occurrenceId??e.sourceNodeId,u=ES(c,"gradientUnits"),p=!1,f="objectBoundingBox";u==="userSpaceOnUse"?f="userSpaceOnUse":u!==null&&u!=="objectBoundingBox"&&s.push(Tr(t,e,o,"gradientUnits",u,"must be objectBoundingBox or userSpaceOnUse"));let m=ES(c,"spreadMethod"),g="pad";m==="reflect"||m==="repeat"?g=m:m!==null&&m!=="pad"&&s.push(Tr(t,e,o,"spreadMethod",m,"must be pad, reflect, or repeat"));let h=_S(n,r,e,"color-interpolation"),y="sRGB";h==="auto"||h==="linearRGB"?y=h:h!==null&&h!=="sRGB"&&s.push(Tr(t,e,o,"color-interpolation",h,"must be auto, sRGB, or linearRGB"));let b={},v={},I=a==="linear-gradient"?zS:LC;for(let R of I){let $=MS(c,R,a);if(!$)continue;b[R]=$.raw;let A=Vo($.raw,f,jo(R),{viewport:o.viewport,fontSize:OS(n,r,e,o),rootFontSize:o.rootFontSize});v[R]=Object.freeze({...$,validity:A===null?"invalid":"valid"})}let x=MS(c,"gradientTransform"),k=x?.raw??null,T=on(k??"");x&&(b.gradientTransform=x.raw,v.gradientTransform=Object.freeze({...x,validity:T===null?"invalid":"valid"}),T===null&&s.push(Tr(t,e,o,"gradientTransform",x.raw,"does not match the SVG transform-list grammar")));for(let[R,$]of Object.entries(v))R==="gradientTransform"||$.validity==="valid"||s.push(Tr(t,e,o,R,$.raw,"is not a valid gradient coordinate"));if(a==="radial-gradient")for(let R of["r","fr"]){let $=v[R];if(!$||$.validity!=="valid")continue;let A=Vo($.raw,f,jo(R),{viewport:o.viewport,fontSize:OS(n,r,e,o),rootFontSize:o.rootFontSize});A!==null&&A<0&&(p=!0,s.push(Tr(t,e,o,R,$.raw,"must not be negative")))}let w=VC(t,c,n,r,o,s),P=Object.freeze(ot(T??[1,0,0,1,0,0])),N=v.gradientTransform??null;return Object.freeze({occurrenceId:d,sourceNodeId:e.sourceNodeId,sourceId:l,type:a,status:p?"invalid":w.length===0?"empty":"materialized",gradientUnits:f,spreadMethod:g,colorInterpolation:y,authoredGeometry:Object.freeze(b),geometryValues:Object.freeze(v),transform:Object.freeze({authored:N,matrix:P}),stops:w,templateSourceNodeIds:Object.freeze(c.map(R=>R.sourceNodeId))})}function UC(t,e){let n=t.edges.flatMap(r=>{if(r.binding!=="applied-css"||!r.occurrenceId||r.propertyName!=="fill"&&r.propertyName!=="stroke")return[];let i=r.targetSourceNodeId?e.get(r.targetSourceNodeId):void 0,o=Wn(r.propertyValue)[r.tokenIndex],s=o?r.propertyValue.slice(o.tokenEnd).trim():"",a=o?!s||s.toLowerCase()==="none"?Object.freeze({kind:"none"}):Object.freeze({kind:"color",value:s}):Object.freeze({kind:"unresolved",authoredValue:r.propertyValue}),c=r.validity==="missing"||r.validity==="invalid-target"?"invalid-reference":i?i.status:"other-paint-server";return[Object.freeze({resourceReferenceId:r.resourceReferenceId,occurrenceId:r.occurrenceId,sourceNodeId:r.fromSourceNodeId,correspondingSourceNodeId:r.fromSourceNodeId,propertyName:r.propertyName,authoredValue:r.propertyValue,gradientSourceNodeId:i?.sourceNodeId??null,status:c,fallback:a})]});return Object.freeze(n)}function Wu(t,e,n,r,i){let o=[],s=r.resources.filter(u=>u.kind==="gradient").map(u=>t.index.element(u.sourceNodeId)).filter(u=>!!(u&&Uo(u))).sort((u,p)=>u.elementOrder-p.elementOrder).map(u=>jC(t,u,e,n,r,i,o)),a=new Map(s.map(u=>[u.sourceNodeId,u])),c=UC(r,a),l=new Map;for(let u of c){let p=l.get(u.occurrenceId)??[];p.push(u),l.set(u.occurrenceId,p)}for(let u of l.values())Object.freeze(u);let d=Object.freeze({candidates:Object.freeze(s),bindings:c,candidate:u=>a.get(u)??null,bindingsFor:u=>l.get(u)??Object.freeze([]),binding:(u,p,f)=>(l.get(u)??[]).find(m=>m.propertyName===p&&(f===void 0||m.resourceReferenceId===f))??null,resolveGeometry:(u,p)=>{let f=u.gradientSourceNodeId?a.get(u.gradientSourceNodeId):null;return f?FS(f,p):null}});return Object.freeze({value:d,diagnostics:Object.freeze(o)})}var HC=["x","y","width","height"],WC=new Set(["desc","metadata","title"]),KC=new Set(["defs","lineargradient","marker","mask","metadata","pattern","radialgradient","script","style","symbol","title"]),XC=/^([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?)\s*(%)?$/u,YC=/^(?:none|x(?:Min|Mid|Max)Y(?:Min|Mid|Max))(?:\s+(?:meet|slice))?$/u;function LS(t){return!!(t&&t.namespaceUri===Y&&t.localName.toLowerCase()==="pattern")}function BS(t){let e=XC.exec(t.trim());if(!e)return null;let n=Number(e[1]);return Number.isFinite(n)?e[2]?n/100:n:null}function qC(t){if(t===null)return Object.freeze({value:"xMidYMid meet",valid:!0});let e=t.trim().replace(/\s+/gu," "),n=YC.test(e),r=Do(n?e:null);return Object.freeze({value:`${r.align}${r.align==="none"&&!e.includes(" ")?"":` ${r.meetOrSlice}`}`,valid:n})}function Yr(t,e,n,r,i,o){return Object.freeze({severity:"warning",code:"invalid-svg-attribute",source:n.source,entrypoint:n.entrypoint,capability:"patterns",sourceId:C(e,"id")??void 0,sourceNodeId:e.sourceNodeId,elementName:e.name,documentPath:t.index.sourcePath(e.sourceNodeId),message:`Pattern ${r} value ${i} ${o}.`})}function ZC(t,e,n){let r=[n],i=new Set([n.sourceNodeId]);for(let o of e.templateChain(n.sourceNodeId)){if(o.validity!=="valid"||!o.targetSourceNodeId||i.has(o.targetSourceNodeId))break;let s=t.index.element(o.targetSourceNodeId);if(!LS(s))break;i.add(s.sourceNodeId),r.push(s)}return Object.freeze(r)}function Hi(t,e){for(let n of t){let r=C(n,e);if(r!==null)return Object.freeze({raw:r,ownerSourceNodeId:n.sourceNodeId})}return null}function JC(t){return t.children.filter(e=>e.kind==="element"&&!WC.has(e.localName.toLowerCase()))}function QC(t){return t.find(e=>JC(e).length>0)??null}function e$(t,e,n){let r=t;for(;r;){if(r.occurrenceId===e)return!0;r=r.parentOccurrenceId?n.get(r.parentOccurrenceId):void 0}return!1}function t$(t,e,n,r){let i=e;for(;i&&i.correspondingSourceNodeId!==n;){let o=t.index.element(i.correspondingSourceNodeId);if(o&&KC.has(o.localName.toLowerCase())&&!(o.localName.toLowerCase()==="symbol"&&i.usePath.length>0))return!1;i=i.parentOccurrenceId?r.get(i.parentOccurrenceId):void 0}return!!i}function n$(t,e,n,r){if(!r)return Object.freeze([]);let i=e.direct(r.sourceNodeId);if(!i)return Object.freeze([]);let o=new Map(e.occurrences.map(l=>[l.occurrenceId,l])),s=e.occurrences.filter(l=>l.occurrenceId!==i.occurrenceId&&e$(l,i.occurrenceId,o)&&t$(t,l,r.sourceNodeId,o)),a=new Set(s.map(l=>l.occurrenceId)),c=new Map(s.map(l=>[l.occurrenceId,`pattern-content:${n.sourceNodeId}:${l.occurrenceId}`]));return Object.freeze(s.map(l=>Object.freeze({occurrenceId:c.get(l.occurrenceId),sourceOccurrenceId:l.occurrenceId,sourceNodeId:l.correspondingSourceNodeId,correspondingSourceNodeId:l.correspondingSourceNodeId,hostPatternSourceNodeId:n.sourceNodeId,parentOccurrenceId:l.parentOccurrenceId&&a.has(l.parentOccurrenceId)?c.get(l.parentOccurrenceId)??null:null,role:l.role,shadow:l.usePath.length>0,orderKey:Object.freeze([...l.orderKey])})))}function r$(t,e,n){if(!e)return Object.freeze([]);let r=new Set(n.map(o=>o.sourceOccurrenceId)),i=new Set(n.map(o=>o.correspondingSourceNodeId));return Object.freeze(t.edges.filter(o=>o.participation==="resource-product"&&o.containingResourceSourceNodeId===e.sourceNodeId&&(o.occurrenceId!==null&&r.has(o.occurrenceId)||i.has(o.fromSourceNodeId))&&o.kind!=="pattern-template"))}function i$(t,e){if(e.length===0)return Object.freeze([]);let n=new Map(t.resources.map(r=>[r.sourceNodeId,r]));return Object.freeze(t.closureFromEdges(e).materializations.map(r=>{let i=n.get(r.sourceNodeId);return Object.freeze({sourceNodeId:r.sourceNodeId,sourceId:i?.authoredId??null,kind:i?.kind??"referenced-fragment",viaResourceReferenceId:r.viaResourceReferenceId})}))}function o$(t,e,n,r){return e==="objectBoundingBox"?BS(t)===null?"invalid":"valid":Re(t,{percentBasis:n==="x"?r.viewport.width:r.viewport.height,viewportWidth:r.viewport.width,viewportHeight:r.viewport.height,fontSize:r.rootFontSize,rootFontSize:r.rootFontSize})===void 0?"invalid":"valid"}function Wi(t,e,n,r,i){return t===void 0?i:e==="objectBoundingBox"?BS(t)??i:Re(t,{percentBasis:n==="x"?r.viewport.width:r.viewport.height,viewportWidth:r.viewport.width,viewportHeight:r.viewport.height,fontSize:r.fontSize,rootFontSize:r.rootFontSize})??i}function GS(t,e){if(t.status!=="materialized")return null;let n=Wi(t.values.x?.raw,t.patternUnits,"x",e,0),r=Wi(t.values.y?.raw,t.patternUnits,"y",e,0),i=Wi(t.values.width?.raw,t.patternUnits,"x",e,0),o=Wi(t.values.height?.raw,t.patternUnits,"y",e,0);return t.patternUnits==="userSpaceOnUse"?Object.freeze({x:n,y:r,width:i,height:o}):Object.freeze({x:e.objectBounds.x+n*e.objectBounds.width,y:e.objectBounds.y+r*e.objectBounds.height,width:i*e.objectBounds.width,height:o*e.objectBounds.height})}function s$(t,e,n,r,i,o){let s=ZC(t,r,e),a=C(e,"id"),c=n.direct(e.sourceNodeId)?.occurrenceId??e.sourceNodeId,l=Hi(s,"patternUnits"),d="objectBoundingBox";l?.raw==="userSpaceOnUse"?d="userSpaceOnUse":l&&l.raw!=="objectBoundingBox"&&o.push(Yr(t,e,i,"patternUnits",l.raw,"must be objectBoundingBox or userSpaceOnUse"));let u=Hi(s,"patternContentUnits"),p="userSpaceOnUse";u?.raw==="objectBoundingBox"?p="objectBoundingBox":u&&u.raw!=="userSpaceOnUse"&&o.push(Yr(t,e,i,"patternContentUnits",u.raw,"must be objectBoundingBox or userSpaceOnUse"));let f=!1,m={};for(let U of HC){let te=Hi(s,U);if(!te)continue;let Z=o$(te.raw,d,U==="x"||U==="width"?"x":"y",i);m[U]=Object.freeze({...te,validity:Z}),Z==="invalid"&&o.push(Yr(t,e,i,U,te.raw,"is not a valid pattern coordinate"))}let g={viewport:i.viewport,objectBounds:{x:0,y:0,width:1,height:1},fontSize:i.rootFontSize,rootFontSize:i.rootFontSize},h=Wi(m.width?.raw,d,"x",g,0),y=Wi(m.height?.raw,d,"y",g,0);for(let[U,te]of[["width",h],["height",y]])m[U]?.validity==="valid"&&te<0&&(f=!0,o.push(Yr(t,e,i,U,m[U].raw,"must not be negative")));let b=Hi(s,"patternTransform"),v=b?on(b.raw):[1,0,0,1,0,0],I=v===null?"invalid":"valid";b&&I==="invalid"&&o.push(Yr(t,e,i,"patternTransform",b.raw,"does not match the SVG transform-list grammar"));let x=Object.freeze({raw:b?.raw??null,ownerSourceNodeId:b?.ownerSourceNodeId??null,matrix:Object.freeze(ot(v??[1,0,0,1,0,0])),validity:I}),k=Hi(s,"viewBox"),T=k?at(k.raw):null,w="valid";k&&(!T||T.width<0||T.height<0)&&(w="invalid",o.push(Yr(t,e,i,"viewBox",k.raw,"must be four numbers with non-negative width and height")));let P=k?Object.freeze({...k,validity:w}):null,N=T&&w==="valid"?Object.freeze([T.x,T.y,T.width,T.height]):null,R=Hi(s,"preserveAspectRatio"),$=qC(R?.raw??null);R&&!$.valid&&o.push(Yr(t,e,i,"preserveAspectRatio",R.raw,"does not match the preserveAspectRatio grammar"));let A=R?Object.freeze({...R,validity:$.valid?"valid":"invalid"}):null,O=QC(s),G=n$(t,n,e,O),M=r$(r,O,G),V=i$(r,M),K=!!(N&&(N[2]===0||N[3]===0)),X=f?"invalid":!O||h===0||y===0||K?"empty":"materialized";return Object.freeze({occurrenceId:c,sourceNodeId:e.sourceNodeId,sourceId:a,status:X,patternUnits:d,patternContentUnits:p,values:Object.freeze(m),transform:x,viewBox:N,viewBoxAuthored:P,preserveAspectRatio:$.value,preserveAspectRatioAuthored:A,templateSourceNodeIds:Object.freeze(s.map(U=>U.sourceNodeId)),contentProviderSourceNodeId:O?.sourceNodeId??null,contentOccurrences:G,contentOccurrenceIds:Object.freeze(G.map(U=>U.occurrenceId)),resources:V})}function a$(t,e){return Object.freeze(t.edges.flatMap(n=>{if(n.binding!=="applied-css"||!n.occurrenceId||n.propertyName!=="fill"&&n.propertyName!=="stroke")return[];let r=n.targetSourceNodeId?e.get(n.targetSourceNodeId):void 0,i=Wn(n.propertyValue)[n.tokenIndex],o=i?n.propertyValue.slice(i.tokenEnd).trim():"",s=i?!o||o.toLowerCase()==="none"?Object.freeze({kind:"none"}):Object.freeze({kind:"color",value:o}):Object.freeze({kind:"unresolved",authoredValue:n.propertyValue}),a=n.validity==="missing"||n.validity==="invalid-target"?"invalid-reference":r?r.status:"other-paint-server";return[Object.freeze({resourceReferenceId:n.resourceReferenceId,consumerOccurrenceId:n.occurrenceId,occurrenceId:n.occurrenceId,sourceNodeId:n.fromSourceNodeId,correspondingSourceNodeId:n.fromSourceNodeId,propertyName:n.propertyName,authoredValue:n.propertyValue,patternSourceNodeId:r?.sourceNodeId??null,status:a,fallback:s})]}))}function Ku(t,e,n,r,i){let o=[],s=r.resources.filter(u=>u.kind==="pattern").map(u=>t.index.element(u.sourceNodeId)).filter(LS).sort((u,p)=>u.elementOrder-p.elementOrder).map(u=>s$(t,u,e,r,i,o)),a=new Map(s.map(u=>[u.sourceNodeId,u])),c=a$(r,a),l=new Map;for(let u of c){let p=l.get(u.occurrenceId)??[];p.push(u),l.set(u.occurrenceId,p)}for(let u of l.values())Object.freeze(u);let d=Object.freeze({candidates:Object.freeze(s),bindings:c,candidate:u=>a.get(u)??null,bindingsFor:u=>l.get(u)??Object.freeze([]),binding:(u,p,f)=>(l.get(u)??[]).find(m=>m.propertyName===p&&(f===void 0||m.resourceReferenceId===f))??null,resolveTile:(u,p)=>{let f=u.patternSourceNodeId?a.get(u.patternSourceNodeId):null;return f?GS(f,p):null}});return Object.freeze({value:d,diagnostics:Object.freeze(o)})}var jS=new Map([["clippath","clipPath"],["filter","filter"],["lineargradient","linearGradient"],["mask","mask"],["pattern","pattern"],["radialgradient","radialGradient"],["symbol","symbol"]]),c$=new Set(["clipPathUnits","filterUnits","gradientUnits","maskContentUnits","maskUnits","patternContentUnits","patternUnits","primitiveUnits","spreadMethod"]);function VS(t,e){let n=new Set(e.attributes.filter(o=>o.prefix==="xmlns").map(o=>o.name)),r=new Map,i=t.index.parent(e.sourceNodeId);for(;i;){for(let o of i.attributes)o.prefix==="xmlns"&&(n.has(o.name)||r.has(o.name)||r.set(o.name,o));i=t.index.parent(i.sourceNodeId)}return Object.freeze([...r.values()])}function Yu(t){return t.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;")}function rc(t){return Yu(t).replaceAll('"',"&quot;")}function l$(t){switch(t.kind){case"text":return Yu(t.value);case"comment":return`<!--${t.value}-->`;case"cdata":return`<![CDATA[${t.value.replaceAll("]]>","]]]]><![CDATA[>")}]]>`;case"processing-instruction":return`<?${t.value}?>`;case"doctype":return`<!DOCTYPE ${t.value}>`}}function Xu(t,e,n=[],r=!1){if(t.namespaceUri===Y&&t.localName.toLowerCase()==="script"||r&&t.namespaceUri===Y&&["animate","animatemotion","animatetransform","discard","set"].includes(t.localName.toLowerCase())&&!Be(t))return"";let i=e.identifierBySourceNodeId.get(t.sourceNodeId),o=e.generatedIdBySourceNodeId.get(t.sourceNodeId),s=e.attributeRewrites.get(t.sourceNodeId),a=[],c=!1,l=!1;for(let m of n)a.push(`${m.name}="${rc(m.value)}"`);for(let m of t.attributes){if(/^on/iu.test(m.name))continue;m.name==="data-source-id"&&(c=!0),m.localName==="id"&&m.namespaceUri===null&&(l=!0);let g=m.localName==="id"&&m.namespaceUri===null&&i?i.liveId:m.localName==="id"&&m.namespaceUri===null&&o?o:s?.get(m.name)??m.value;g===""&&c$.has(m.name)||a.push(`${m.name}="${rc(g)}"`)}i?.restoreSourceId&&!c&&a.push(`data-source-id="${rc(i.sourceId)}"`),o&&!l&&a.push(`id="${rc(o)}"`);let d=`<${t.name}${a.length>0?` ${a.join(" ")}`:""}`,u=e.textRewrites.get(t.sourceNodeId),p=u!==void 0?Yu(u):t.children.map(m=>m.kind==="element"?Xu(m,e,[],r):l$(m)).join(""),f=/\/\s*>\s*$/u.test(t.rawXml??"");return p.length===0&&f?`${d}/>`:`${d}>${p}</${t.name}>`}function d$(t){let e=new Map(t.resourceIds.map(i=>[i.sourceNodeId,i])),n=new Map,r=new Map;for(let i of t.rewrites){if(i.target==="text-content"){r.set(i.sourceNodeId,i.value);continue}if(!i.name)continue;let o=n.get(i.sourceNodeId)??new Map;o.set(i.name,i.value),n.set(i.sourceNodeId,o)}return{identifierBySourceNodeId:e,attributeRewrites:new Map([...n].map(([i,o])=>[i,o])),textRewrites:r,generatedIdBySourceNodeId:new Map(t.generatedIds.map(({sourceNodeId:i,liveId:o})=>[i,o]))}}function US(t,e){let n=t.index.parent(e);for(;n;){if(n.namespaceUri===Y&&n.localName.toLowerCase()==="defs")return!0;n=t.index.parent(n.sourceNodeId)}return!1}function u$(t){return t.definition.definitionChildIds&&Object.freeze(t.definition.definitionChildIds),t.definition.sourceDefinitionChildIds&&Object.freeze(t.definition.sourceDefinitionChildIds),Object.freeze(t.definition),Object.freeze(t)}function HS(t,e,n){if(e.namespaceUri!==Y||e.localName.toLowerCase()!=="g"||!US(t,e.sourceNodeId))return null;let r=e.children.filter(o=>o.kind==="element");if(r.length===0)return null;let i=[];for(let o of r){if(o.namespaceUri!==Y)return null;let s=jS.get(o.localName.toLowerCase()),a=HS(t,o,n);if(!s&&!a)return null;let c=n.identifierBySourceNodeId.get(o.sourceNodeId);if(!c)return null;i.push({sourceId:c.liveId,destinationId:c.liveId})}return i}function qu(t,e,n){let r=[],i=d$(e),o=[];for(let l of t.index.elements){if(l.namespaceUri!==Y)continue;let d=jS.get(l.localName.toLowerCase()),u=HS(t,l,i);if(!d&&!u)continue;let p=C(l,"id");if(!p)continue;let f=i.identifierBySourceNodeId.get(l.sourceNodeId);if(!f){r.push({severity:"warning",code:"invalid-svg-attribute",source:n.source,entrypoint:n.entrypoint,message:`Definition ${p} has no destination identifier assignment.`,documentPath:t.index.sourcePath(l.sourceNodeId),elementName:l.name,sourceId:p,sourceNodeId:l.sourceNodeId,capability:"paint-server-definitions"});continue}let m={id:f.liveId,type:d??l.localName,...u?{role:"referenced-fragment",definitionChildIds:u.map(g=>g.destinationId),sourceDefinitionChildIds:u.map(g=>g.sourceId)}:{},markup:Xu(l,i,VS(t,l),d==="clipPath"||d==="mask"),passthrough:!0};o.push(u$({sourceNodeId:l.sourceNodeId,sourceId:p,destinationId:f.liveId,type:d??l.localName,insideDefs:US(t,l.sourceNodeId),definition:m}))}let s=Object.freeze(o),a=new Map(s.map(l=>[l.sourceNodeId,l])),c=Object.freeze({candidates:s,candidate:l=>a.get(l)??null,definitionForSourceNode(l,d="referenced-fragment"){let u=a.get(l);if(u)return u.definition;let p=t.index.element(l);if(!p||p.namespaceUri!==Y)return null;let f=i.identifierBySourceNodeId.get(l),m=C(p,"id"),g=f?.liveId??m;return g?Object.freeze({id:g,type:p.localName,role:d,markup:Xu(p,i,VS(t,p)),passthrough:!0}):null},definitions:(l=new Set)=>Object.freeze(s.filter(d=>!l.has(d.sourceNodeId)).map(d=>d.definition))});return Object.freeze({value:c,diagnostics:Object.freeze(r)})}var ic=Object.freeze({x:"-10%",y:"-10%",width:"120%",height:"120%"}),p$=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/u,f$=/^([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?)(%)?$/u,m$=/^([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?)(deg|grad|rad|turn)?$/iu,XS=new Set(["animate","animatemotion","animatetransform","set"]),g$=new Set(["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity","plus-darker","plus-lighter"]);function Zr(t){if(!t||typeof t!="object"&&typeof t!="function"||Object.isFrozen(t))return t;for(let e of Object.values(t))Zr(e);return Object.freeze(t)}function Rr(t){return t.children.filter(e=>e.kind==="element")}function WS(t){let e="",n=[...t.children].reverse();for(;n.length>0;){let r=n.pop();r.kind==="text"||r.kind==="cdata"?e+=r.value:r.kind==="element"&&n.push(...[...r.children].reverse())}return e}function Zu(t){return(t.rawXml??"").replace(/\s+xmlns="http:\/\/www\.w3\.org\/2000\/svg"/gu,"").replace(/\s+xmlns=""/gu,"")}function Yn(t){if(t===null||!p$.test(t.trim()))return;let e=Number(t.trim());return Number.isFinite(e)?e:void 0}function qr(t,e){let n=C(t,e);return n===null?void 0:n}function sc(t,e,n=""){return`${t}:${e}${n}`}function oc(t,e,n,r){return Object.freeze({severity:"warning",code:"invalid-svg-attribute",source:t.source,entrypoint:t.entrypoint,capability:"filters",sourceNodeId:n.sourceNodeId,sourceId:C(n,"id")??void 0,occurrenceId:r,elementName:n.name,message:e})}function h$(t){let e=[...Rr(t)];for(;e.length>0;){let n=e.pop();if(n.namespaceUri===Y&&n.localName.toLowerCase()==="script")return!0;e.push(...Rr(n))}return!1}function KS(t,e,n){let r=e.direct(t.sourceNodeId);return r?n.value(r.occurrenceId,"display"):C(t,"display")}function y$(t,e,n,r){if(KS(e,n,r)?.trim().toLowerCase()==="none")return!0;let i=t.index.parent(e.sourceNodeId);for(;i;){if(i.namespaceUri===Y&&i.localName.toLowerCase()==="defs"&&KS(i,n,r)?.trim().toLowerCase()==="none")return!0;i=t.index.parent(i.sourceNodeId)}return!1}function S$(t){let e=C(t,"color-interpolation-filters"),n=C(t,"filterUnits"),r=C(t,"primitiveUnits");return{colorInterpolation:e==="auto"||e==="sRGB"||e==="linearRGB"?e:"linearRGB",filterUnits:n==="userSpaceOnUse"||n==="objectBoundingBox"?n:"objectBoundingBox",primitiveUnits:r==="userSpaceOnUse"||r==="objectBoundingBox"?r:"userSpaceOnUse",region:Object.freeze({x:C(t,"x")??ic.x,y:C(t,"y")??ic.y,width:C(t,"width")??ic.width,height:C(t,"height")??ic.height})}}function YS(t,e){let n=qr(e,"x"),r=qr(e,"y"),i=qr(e,"width"),o=qr(e,"height");n!==void 0&&(t.x=n),r!==void 0&&(t.y=r),i!==void 0&&(t.width=i),o!==void 0&&(t.height=o);let s=C(e,"filterUnits");(s==="userSpaceOnUse"||s==="objectBoundingBox")&&(t.filterUnits=s);let a=C(e,"primitiveUnits");(a==="userSpaceOnUse"||a==="objectBoundingBox")&&(t.primitiveUnits=a);let c=C(e,"color-interpolation-filters");(c==="auto"||c==="sRGB"||c==="linearRGB")&&(t.type==="raw-svg"?t.colorInterpolationFilters=c:t.filterColorInterpolation=c);let l=qr(e,"flood-color"),d=qr(e,"flood-opacity"),u=qr(e,"lighting-color");l!==void 0&&(t.floodColor=l),d!==void 0&&(t.floodOpacity=d),u!==void 0&&(t.lightingColor=u)}function b$(t){return Rr(t).filter(e=>XS.has(e.localName.toLowerCase())).map(Zu).filter(Boolean)}function Ct(t,e,n){let r={id:sc(e,t.sourceNodeId),type:e};for(let c of["in","result","x","y","width","height"]){let l=C(t,c);l!==null&&(r[c]=l)}let i=C(t,"color-interpolation-filters");(i==="auto"||i==="sRGB"||i==="linearRGB")&&(r.colorInterpolationFilters=i);let o=new Set(["in","result","x","y","width","height","color-interpolation-filters"]),s={};for(let c of t.attributes)o.has(c.name)||n.has(c.name)||(s[c.name]=c.value);Object.keys(s).length>0&&(r.unknownAttrs=s);let a=b$(t);return a.length>0&&(r.animations=a),r}function v$(t){let e=C(t,"type");if(e==="identity")return{type:e};if(e==="table"||e==="discrete"){let r=(C(t,"tableValues")??"").trim().split(/[\s,]+/u).filter(Boolean).map(i=>Yn(i));return r.some(i=>i===void 0)?void 0:{type:e,tableValues:r}}if(e==="linear"){let n={type:e},r=Yn(C(t,"slope")),i=Yn(C(t,"intercept"));return r!==void 0&&(n.slope=r),i!==void 0&&(n.intercept=i),n}if(e==="gamma"){let n={type:e},r=Yn(C(t,"amplitude")),i=Yn(C(t,"exponent")),o=Yn(C(t,"offset"));return r!==void 0&&(n.amplitude=r),i!==void 0&&(n.exponent=i),o!==void 0&&(n.offset=o),n}}function x$(t){let e={},n=t.localName.toLowerCase(),r=n==="fedistantlight"?["azimuth","elevation"]:n==="fepointlight"?["x","y","z"]:n==="fespotlight"?["x","y","z","pointsAtX","pointsAtY","pointsAtZ","specularExponent","limitingConeAngle"]:null;if(r){for(let i of r){let o=Yn(C(t,i));o!==void 0&&(e[i]=o)}return n==="fedistantlight"?{kind:"feDistantLight",...e}:n==="fepointlight"?{kind:"fePointLight",...e}:{kind:"feSpotLight",...e}}}function qt(t,e,n,r=n){let i=Yn(C(e,n));i!==void 0&&(t[r]=i)}function ut(t,e,n,r=n){let i=C(e,n);i!==null&&(t[r]=i)}function I$(t){let e=t.localName.toLowerCase();switch(e){case"feblend":{let n=Ct(t,"feBlend",new Set(["in2","mode","no-composite"]));ut(n,t,"in2");let r=C(t,"mode");return r&&g$.has(r)&&(n.mode=r),yt(t,"no-composite")&&(n.noComposite=!0),n}case"fecolormatrix":{let n=Ct(t,"feColorMatrix",new Set(["type","values"])),r=C(t,"type");return(r==="matrix"||r==="saturate"||r==="hueRotate"||r==="luminanceToAlpha")&&(n.matrixType=r),ut(n,t,"values"),n}case"fecomponenttransfer":{let n=Ct(t,"feComponentTransfer",new Set);for(let r of Rr(t)){let i=v$(r),o=r.localName.toLowerCase();o==="fefuncr"&&i?n.funcR=i:o==="fefuncg"&&i?n.funcG=i:o==="fefuncb"&&i?n.funcB=i:o==="fefunca"&&i&&(n.funcA=i)}return n}case"fecomposite":{let n=Ct(t,"feComposite",new Set(["in2","operator","k1","k2","k3","k4"]));ut(n,t,"in2");let r=C(t,"operator");(r==="over"||r==="in"||r==="out"||r==="atop"||r==="xor"||r==="lighter"||r==="arithmetic")&&(n.operator=r);for(let i of["k1","k2","k3","k4"])qt(n,t,i);return n}case"feconvolvematrix":{let r=Ct(t,"feConvolveMatrix",new Set(["order","kernelMatrix","divisor","bias","targetX","targetY","edgeMode","kernelUnitLength","preserveAlpha"]));ut(r,t,"order"),ut(r,t,"kernelMatrix");for(let s of["divisor","bias","targetX","targetY"])qt(r,t,s);let i=C(t,"edgeMode");(i==="duplicate"||i==="wrap"||i==="none")&&(r.edgeMode=i),ut(r,t,"kernelUnitLength");let o=C(t,"preserveAlpha");return o!==null&&(r.preserveAlpha=o==="true"),r}case"fediffuselighting":case"fespecularlighting":{let n=e==="fediffuselighting",i=Ct(t,n?"feDiffuseLighting":"feSpecularLighting",new Set(["surfaceScale","diffuseConstant","specularConstant","specularExponent","kernelUnitLength","lighting-color"]));qt(i,t,"surfaceScale"),n?qt(i,t,"diffuseConstant"):(qt(i,t,"specularConstant"),qt(i,t,"specularExponent")),ut(i,t,"kernelUnitLength"),ut(i,t,"lighting-color","lightingColor");for(let o of Rr(t)){let s=x$(o);if(s){i.lightSource=s;break}}return i}case"fedisplacementmap":{let n=Ct(t,"feDisplacementMap",new Set(["in2","scale","xChannelSelector","yChannelSelector"]));ut(n,t,"in2"),qt(n,t,"scale");for(let r of["xChannelSelector","yChannelSelector"]){let i=C(t,r);(i==="R"||i==="G"||i==="B"||i==="A")&&(n[r]=i)}return n}case"fedropshadow":{let n=Ct(t,"feDropShadow",new Set(["dx","dy","stdDeviation","flood-color","flood-opacity"]));return qt(n,t,"dx"),qt(n,t,"dy"),ut(n,t,"stdDeviation"),ut(n,t,"flood-color","floodColor"),ut(n,t,"flood-opacity","floodOpacity"),n}case"feflood":{let n=Ct(t,"feFlood",new Set(["flood-color","flood-opacity"]));return ut(n,t,"flood-color","floodColor"),ut(n,t,"flood-opacity","floodOpacity"),n}case"fegaussianblur":{let n=Ct(t,"feGaussianBlur",new Set(["stdDeviation","edgeMode"]));ut(n,t,"stdDeviation");let r=C(t,"edgeMode");return(r==="duplicate"||r==="wrap"||r==="none")&&(n.edgeMode=r),n}case"feimage":{let n=Ct(t,"feImage",new Set(["href","xlink:href","preserveAspectRatio","crossorigin"])),r=Be(t);r?.namespace==="svg2"?n.href=r.value:r?.namespace==="xlink"&&(n.xlinkHref=r.value),ut(n,t,"preserveAspectRatio");let i=C(t,"crossorigin");return(i==="anonymous"||i==="use-credentials")&&(n.crossorigin=i),n}case"femerge":{let n=Ct(t,"feMerge",new Set);return n.nodes=Rr(t).filter(r=>r.localName.toLowerCase()==="femergenode").map(r=>{let i=C(r,"in");return i===null?{}:{in:i}}),n}case"femorphology":{let n=Ct(t,"feMorphology",new Set(["operator","radius"])),r=C(t,"operator");return(r==="erode"||r==="dilate")&&(n.operator=r),ut(n,t,"radius"),n}case"feoffset":{let n=Ct(t,"feOffset",new Set(["dx","dy"]));return qt(n,t,"dx"),qt(n,t,"dy"),n}case"fetile":return Ct(t,"feTile",new Set);case"feturbulence":{let n=Ct(t,"feTurbulence",new Set(["baseFrequency","numOctaves","seed","stitchTiles","type"]));ut(n,t,"baseFrequency"),qt(n,t,"numOctaves"),qt(n,t,"seed");let r=C(t,"stitchTiles");(r==="stitch"||r==="noStitch")&&(n.stitchTiles=r);let i=C(t,"type");return(i==="fractalNoise"||i==="turbulence")&&(n.turbulenceType=i),n}default:return null}}function w$(t){let e=[],n="",r=0;for(let i of t)i==="("?r++:i===")"&&r--,/\s/u.test(i)&&r===0?(n&&e.push(n),n=""):n+=i;return n&&e.push(n),e}function dn(t,e){return(t===void 0?void 0:Yn(t))??e}function k$(t,e){let n=w$(t);if(n.length<2)return null;let r=n[0],i=n[1]==="1",o={id:sc(r,e,":preset"),enabled:i};switch(r){case"hue-rotate":return{...o,type:r,angle:dn(n[2],0)};case"sepia":case"grayscale":case"saturate":case"invert":case"brightness":case"contrast":return{...o,type:r,amount:dn(n[2],1)};case"duotone":return{...o,type:r,shadowColor:n[2]??"#000000",highlightColor:n[3]??"#ffffff"};case"inner-shadow":return{...o,type:r,offsetX:dn(n[2],0),offsetY:dn(n[3],0),blurRadius:dn(n[4],0),choke:dn(n[5],0),color:n[6]??"rgba(0,0,0,0.5)",opacity:1};case"drop-shadow":return{...o,type:r,offsetX:dn(n[2],0),offsetY:dn(n[3],0),blurRadius:dn(n[4],0),spread:dn(n[5],0),color:n[6]??"rgba(0,0,0,0.5)",opacity:1};case"gaussian-blur":{let s=dn(n[2],0);return{...o,type:r,blurX:s,blurY:dn(n[3],s),linked:n[3]===void 0,quality:"normal"}}default:return null}}function P$(t,e){let n={id:sc("raw-svg",t.sourceNodeId),type:"raw-svg",enabled:!0,svgContent:Rr(t).map(Zu).filter(Boolean).join(`
17
+ `)};return YS(n,t),e&&(n.display="none"),n}function T$(t){let e={id:sc("svg-primitive-chain",t.sourceNodeId),type:"svg-primitive-chain",enabled:!0,primitives:[]};YS(e,t);let n=[];for(let r of Rr(t)){let i=r.localName.toLowerCase();if(i==="title")e.filterTitle=WS(r);else if(i==="desc")e.filterDescription=WS(r);else if(XS.has(i))n.push(Zu(r));else{let o=I$(r);o&&e.primitives.push(o)}}return n.length>0&&(e.filterAnimations=n),e}function R$(t,e,n,r,i,o){let s=S$(e),a=e.attributes.find(g=>g.localName==="preset"&&g.prefix==="bx")?.value,c=y$(t,e,n,r),l=C(e,"filterUnits"),d=C(e,"primitiveUnits"),u=C(e,"color-interpolation-filters");l!==null&&l!=="userSpaceOnUse"&&l!=="objectBoundingBox"&&o.push(oc(i,`Invalid filterUnits value "${l}" uses its initial value.`,e)),d!==null&&d!=="userSpaceOnUse"&&d!=="objectBoundingBox"&&o.push(oc(i,`Invalid primitiveUnits value "${d}" uses its initial value.`,e)),u!==null&&u!=="auto"&&u!=="sRGB"&&u!=="linearRGB"&&o.push(oc(i,`Invalid color-interpolation-filters value "${u}" uses its initial value.`,e));let p=a?k$(a,e.sourceNodeId):c||h$(e)?P$(e,c):T$(e),f=Object.freeze(p?[p]:[]),m=p?.type==="svg-primitive-chain"&&p.primitives.length===0;return Zr({sourceNodeId:e.sourceNodeId,sourceId:C(e,"id"),status:p?m?"empty":"materialized":"invalid",filters:f,...s})}function C$(t,e){let n=f$.exec(t.trim());if(!n)return null;let r=Number(n[1]);return!Number.isFinite(r)||r<0?null:n[2]?r/100:r}function $$(t){let e=m$.exec(t.trim());if(!e)return null;let n=Number(e[1]);if(!Number.isFinite(n))return null;switch((e[2]??"deg").toLowerCase()){case"turn":return n*360;case"rad":return n*180/Math.PI;case"grad":return n*.9;default:return n}}function N$(t){let e=[],n="",r=null,i=!1,o=0;for(let s of t){if(r){n+=s,i?i=!1:s==="\\"?i=!0:s===r&&(r=null);continue}s==='"'||s==="'"?(r=s,n+=s):s==="("?(o++,n+=s):s===")"?(o--,n+=s):/\s/u.test(s)&&o===0?(n&&e.push(n),n=""):n+=s}return n&&e.push(n),e}function A$(t,e){if(t.toLowerCase()==="currentcolor")return e??"#000000";if(/^#[\da-f]{3,8}$/iu.test(t)||/^rgba?\(/iu.test(t))return t;let n=Lo(t);return n?`rgb(${n.r}, ${n.g}, ${n.b})`:null}function E$(t,e,n,r,i,o){if(t==="brightness"||t==="contrast"||t==="grayscale"||t==="invert"||t==="opacity"||t==="saturate"||t==="sepia"){let c=C$(e,1);return c===null?null:{id:n,type:t,enabled:!0,amount:c}}if(t==="hue-rotate"){let c=$$(e);return c===null?null:{id:n,type:t,enabled:!0,angle:c}}if(t==="blur"){let c=Re(e.trim(),{fontSize:i,rootFontSize:o.rootFontSize??16,viewportWidth:o.viewport?.width,viewportHeight:o.viewport?.height});return c===void 0||c<0||e.trim().endsWith("%")?null:{id:n,type:"gaussian-blur",enabled:!0,blurX:c,blurY:c,linked:!0,quality:"normal"}}if(t!=="drop-shadow")return null;let s=[],a=null;for(let c of N$(e.trim())){let l=Re(c,{fontSize:i,rootFontSize:o.rootFontSize??16,viewportWidth:o.viewport?.width,viewportHeight:o.viewport?.height});if(l!==void 0&&!c.endsWith("%"))s.push(l);else{let d=A$(c,r);if(!d||a!==null)return null;a=d}}return s.length<2||s.length>3||(s[2]??0)<0?null:{id:n,type:"drop-shadow",enabled:!0,offsetX:s[0],offsetY:s[1],blurRadius:s[2]??0,spread:0,color:a??r??"#000000",opacity:1}}function M$(t,e,n){let r=t.resolvePropertyValue(e.correspondingSourceNodeId,"filter",n),i=r.filter(o=>o.occurrenceId===e.occurrenceId);return i.length>0?i:r.filter(o=>o.occurrenceId===null)}function O$(t){let e=t.trim();return e.length>=2&&(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))&&(e=e.slice(1,-1).trim()),e.startsWith("#")&&e.length>1?e.slice(1):null}function D$(t,e){let n=0;for(let r of e){if(t.slice(n,r.tokenStart).replace(/\/\*[\s\S]*?\*\//gu,"").trim())return!1;n=r.tokenEnd}return t.slice(n).replace(/\/\*[\s\S]*?\*\//gu,"").trim().length===0}function z$(t,e,n,r,i,o,s,a){let c=[],l=M$(r,t,e),d=0,u=!1,p=Re(n.value(t.occurrenceId,"font-size"),{fontSize:o.rootFontSize??16,rootFontSize:o.rootFontSize??16,viewportWidth:o.viewport?.width,viewportHeight:o.viewport?.height})??o.rootFontSize??16,f=n.value(t.occurrenceId,"color"),m=Cn(e);D$(e,m)||(u=!0);for(let[y,b]of m.entries()){let v=`filter-operation:${t.occurrenceId}:${y}`,I=e.slice(b.tokenStart,b.tokenEnd);if(b.name!=="url"){let N=E$(b.name,e.slice(b.argumentsStart,b.argumentsEnd),v,f,p,o),R=N?"materialized":"invalid-reference";N||(u=!0,s.push(oc(o,`Invalid or unsupported CSS filter function "${I}".`,a,t.occurrenceId))),c.push(Object.freeze({operationId:v,kind:"function",authoredValue:I,filter:N,filterSourceNodeId:null,status:R}));continue}let k=O$(e.slice(b.argumentsStart,b.argumentsEnd))===null?void 0:l[d++],T=k?.targetSourceNodeId?i.get(k.targetSourceNodeId):null,P=k?.validity==="valid"&&T?T.status==="empty"?"empty":T.status==="materialized"?"materialized":"invalid-reference":"invalid-reference";P==="invalid-reference"&&(u=!0),c.push(Zr({operationId:v,kind:"reference",authoredValue:I,filter:P==="materialized"?T?.filters[0]??null:null,filterSourceNodeId:k?.targetSourceNodeId??null,status:P}))}let h=e.trim().toLowerCase()==="none"?"none":u||c.length===0?"invalid-reference":"materialized";return Zr({consumerOccurrenceId:t.occurrenceId,consumerSourceNodeId:t.correspondingSourceNodeId,authoredValue:e,status:h,operations:Object.freeze(c)})}function Ju(t,e,n,r,i){let o=[],s=r.resources.filter(u=>u.kind==="filter").map(u=>t.index.element(u.sourceNodeId)).filter(u=>!!u).map(u=>R$(t,u,e,n,i,o)),a=new Map(s.map(u=>[u.sourceNodeId,u])),c=[];for(let u of e.occurrences){let p=t.index.element(u.correspondingSourceNodeId);if(!p)continue;let f=n.value(u.occurrenceId,"filter");f&&c.push(z$(u,f,n,r,a,i,o,p))}let l=new Map(c.map(u=>[u.consumerOccurrenceId,u]));Zr(s),Zr(c),Zr(o);let d=Object.freeze({candidates:s,bindings:c,diagnostics:o,candidate(u){return a.get(u)??null},binding(u){return l.get(u)??null}});return Object.freeze({value:d,diagnostics:o})}var _$="application/ecmascript",F$="http://www.w3.org/1999/xlink",L$=Object.freeze([]);function B$(t){let e="",n=[...t.children].reverse();for(;n.length>0;){let r=n.pop();r.kind==="text"||r.kind==="cdata"?e+=r.value:r.kind==="element"&&n.push(...[...r.children].reverse())}return e}function G$(t,e){let n=t.attributes[e];return n.namespaceUri===F$&&n.localName==="href"?!0:n.namespaceUri!==null?!1:["id","type","href","crossorigin","async","defer"].includes(n.localName)}function V$(t){let e=t.attributes.filter((n,r)=>!G$(t,r)).map(n=>[n.name,n.value]);return e.length>0?Object.freeze(Object.fromEntries(e)):void 0}function j$(t,e){return!e||e.sourceNodeId===t.root.sourceNodeId||e.namespaceUri===Y&&["defs","metadata"].includes(e.localName.toLowerCase())?"document":"element"}function U$(t){let e=Be(t)?.value,n=e!==void 0&&e.length>0,r=C(t,"type")||_$,i=C(t,"crossorigin"),o=C(t,"id")||void 0,s=V$(t);return Object.freeze({id:`script:${t.sourceNodeId}`,...o?{svgId:o}:{},source:n?"external":"inline",content:n?"":B$(t),...n?{href:e}:{},type:r,...i==="anonymous"||i==="use-credentials"?{crossorigin:i}:{},...yt(t,"async")?{async:!0}:{},...yt(t,"defer")?{defer:!0}:{},...s?{customAttrs:s}:{}})}function Qu(t,e){let n=[],r=t.index.elements.filter(l=>l.namespaceUri===Y&&l.localName.toLowerCase()==="script").map(l=>{let d=t.index.parent(l.sourceNodeId);return Object.freeze({sourceNodeId:l.sourceNodeId,parentSourceNodeId:d?.sourceNodeId??null,scope:j$(t,d),script:U$(l)})}),i=Object.freeze(r.filter(l=>l.scope==="document")),o=Object.freeze(r.filter(l=>l.scope==="element")),s=new Map(r.map(l=>[l.sourceNodeId,l])),a=new Map;for(let l of o){if(!l.parentSourceNodeId)continue;let d=a.get(l.parentSourceNodeId)??[];a.set(l.parentSourceNodeId,Object.freeze([...d,l]))}Object.freeze(r),Object.freeze(n);let c=Object.freeze({candidates:r,documentScripts:i,elementScripts:o,candidate(l){return s.get(l)??null},forParent(l){return a.get(l)??L$}});return Object.freeze({value:c,diagnostics:n})}function qn(t){if(!t)return"";let e=t.replace(/[^A-Za-z0-9_.-]/g,"_");return e&&!/^[A-Za-z_]/.test(e)&&(e=`_${e}`),e}function H$(t){let e=t.state?.children;return Array.isArray(e)?e:[]}function qS(t,e,n="shapes"){let r=new Set,i=(o,s)=>{r.has(o)||(r.add(o),e(o,s),H$(o).forEach((a,c)=>i(a,`${s}.children[${c}]`)),r.delete(o))};t.forEach((o,s)=>i(o,`${n}[${s}]`))}function W$(t){let e=[],n=new Set,r=i=>{if(!(i===null||typeof i!="object"||n.has(i))){if(n.add(i),Array.isArray(i)){let o=i.filter(s=>!!(s&&typeof s=="object"&&typeof s.id=="string"&&typeof s.type=="string"&&"state"in s));o.length===i.length&&o.length>0?e.push(o):i.forEach(r);return}Object.values(i).forEach(r)}};return r(t),e}function K$(t){return t.definitionId??`${t.type}-${t.id}`}function X$(t,e){return{severity:"warning",code:"duplicate-svg-id",source:"native-document",entrypoint:"full-snapshot-restore",capability:"destination-identity",sourceId:t,documentPath:e[0]?.documentPath,message:`SVG destination id "${t}" has ${e.length} canonical owners.`}}function uB(t,e={}){let n=[],r=new Map,i=new Set,o=[],s=f=>{if(!f.id)return;let m=`${f.channel}\0${f.ownerKey}\0${f.id}`;if(i.has(m))return;i.add(m);let g=Object.freeze({...f});n.push(g);let h=r.get(f.id)??[];h.push(g),r.set(f.id,h)},a=(f,m)=>{let g=f.state??{},h=g.metadata;if(typeof h?.name=="string"){let y=qn(h.name);y&&s({id:y,ownerKey:`shape:${f.id}:metadata`,channel:"shape-authored",documentPath:m})}f.type==="view"&&typeof g.viewName=="string"&&g.viewName&&s({id:qn(g.viewName),ownerKey:`view:${f.id}`,channel:"view",documentPath:m}),f.type==="text"&&g.isTextPath===!0&&g.textPathPoints&&s({id:`text-path-${f.id}`,ownerKey:`shape:${f.id}:text-path`,channel:"shape-generated",documentPath:m}),g.displayMode==="motionOnly"&&s({id:f.id,ownerKey:`shape:${f.id}:motion-path`,channel:"shape-generated",documentPath:m}),Array.isArray(g.filters)&&g.filters.length>0&&s({id:`filter-${f.id}`,ownerKey:`shape:${f.id}:filter`,channel:"shape-generated",documentPath:m}),typeof h?.rawMetadata=="string"&&c(h.rawMetadata,`shape:${f.id}:metadata`,void 0,m)},c=(f,m,g,h)=>{let y=`<svg xmlns="${Y}">${f}</svg>`,b=ln(y,{source:"native-document",entrypoint:"full-snapshot-restore"},e.parserHost);if(o.push(...b.diagnostics),!b.value)return;let v=new Map;for(let I of b.value.index.elements.slice(1)){let x=C(I,"id");if(!x||b.value.index.parent(I.sourceNodeId)===b.value.root&&g===x)continue;let T=v.get(x)??0;v.set(x,T+1),s({id:x,ownerKey:`${m}#${x}${T>0?`@${T}`:""}`,channel:"verbatim-fragment"})}},l=new Map;qS(t.shapes??[],(f,m)=>{l.has(f.id)||l.set(f.id,f),a(f,m)});for(let f of l.values()){let m=f.state??{},g=[f.type==="text"?m.shapeInsideRef:void 0,f.type==="shape-reference"?m.targetShapeId:void 0];for(let h of g){if(typeof h!="string")continue;let y=l.get(h),b=y?.state?.metadata?.name;y&&(typeof b!="string"||qn(b).length===0)&&s({id:y.id,ownerKey:`shape:${y.id}:reference-target`,channel:"shape-generated",documentPath:`shape:${y.id}`})}}typeof t.documentMetadata?.rawMetadata=="string"&&c(t.documentMetadata.rawMetadata,"document:metadata",void 0,"documentMetadata");for(let f of t.documentStyles??[])f.svgId&&s({id:f.svgId,ownerKey:`style:${f.id}`,channel:"document-style",documentPath:"documentStyles"});for(let f of t.documentScripts??[])f.svgId&&s({id:f.svgId,ownerKey:`script:${f.id}`,channel:"document-script",documentPath:"documentScripts"});for(let f of t.animationTimeline?.tracks??[])f.sourceSmilId&&s({id:f.sourceSmilId,ownerKey:`animation:${f.id}`,channel:"animation",documentPath:"animationTimeline"});let d=(f,m,g)=>{let h=m?`libraryFurniture[${g}]`:`library[${g}]`;s({id:f.id,ownerKey:`library:${f.id}`,channel:"library-runtime",documentPath:h}),f.sourceId&&s({id:f.sourceId,ownerKey:`library:${f.id}:source`,channel:"library-source-alias",documentPath:h}),W$(f).forEach((y,b)=>qS(y,a,`${h}.shapeForest[${b}]`))};(t.library??[]).forEach((f,m)=>d(f,!1,m)),(e.libraryFurniture??[]).forEach((f,m)=>d(f,!0,m));for(let[f,m]of(t.paintServerDefs??[]).entries())s({id:m.id,ownerKey:`paint-server:${m.id}`,channel:"paint-server",documentPath:`paintServerDefs[${f}]`}),c(m.markup,`paint-server:${m.id}`,m.id,`paintServerDefs[${f}].markup`);for(let[f,m]of(t.clipMaskGroups??[]).entries()){let g=K$(m);s({id:g,ownerKey:`clip-mask:${m.id}`,channel:"clip-mask-definition",documentPath:`clipMaskGroups[${f}]`}),m.rawDefinition&&c(m.rawDefinition,`clip-mask:${m.id}`,g,`clipMaskGroups[${f}].rawDefinition`)}for(let f of e.platformReservations??[])s(f);for(let f of r.values())Object.freeze(f);Object.freeze(n);let u=Object.freeze({owners:n,has(f){return r.has(f)},firstOwner(f){return r.get(f)?.[0]??null},ownersOf(f){return r.get(f)??Object.freeze([])}}),p=[...r.entries()].filter(([,f])=>f.length>1).map(([f,m])=>X$(f,m));return{value:u,diagnostics:Object.freeze([...o,...p])}}function pB(t){let e=new Set(t.owners.map(s=>s.id)),n=new Map,r=[],i=new Map;return Object.freeze({allocate:s=>{let a=n.get(s.requestKey);if(a)return a;let c=s.preferredId,l=qn(c??""),d=qn(s.fallbackBase)||"svg-resource",u=l||d,p=e.has(u)?t.firstOwner(u):null,f=u;if(e.has(f)){let g=i.get(u)??1;for(;e.has(`${u}-${g}`);)g++;f=`${u}-${g}`,i.set(u,g+1)}e.add(f);let m=Object.freeze({requestKey:s.requestKey,...c!==void 0?{authoredId:c}:{},destinationId:f,...p?{collisionOwner:p}:{}});return n.set(s.requestKey,m),r.push(m),m},assignment(s){return n.get(s)??null},has(s){return e.has(s)},snapshot(){return Object.freeze([...r])}})}function ac(t,e,n,r){let i=r?.strokeWidth!=null?Math.max(.5,e*r.strokeWidth):Math.max(1,e/10);switch(t){case"stripes":return[{tag:"rect",attrs:{width:r?.strokeWidth!=null?Math.max(.01,Math.min(1,r.strokeWidth))*e:e/2,height:e,fill:n}}];case"dots":{let o=r?.dotRadius!=null?Math.max(.05,Math.min(.45,r.dotRadius)):.25;return[{tag:"circle",attrs:{cx:e/2,cy:e/2,r:e*o,fill:n}}]}case"grid":return[{tag:"path",attrs:{d:`M ${e} 0 L 0 0 0 ${e}`,fill:"none",stroke:n,"stroke-width":i}}];case"checkerboard":return[{tag:"rect",attrs:{width:e/2,height:e/2,fill:n}},{tag:"rect",attrs:{x:e/2,y:e/2,width:e/2,height:e/2,fill:n}}];case"diagonal":{let o=r?.strokeWidth!=null?Math.max(.5,e*r.strokeWidth):Math.max(1,e/5);return[{tag:"path",attrs:{d:`M 0 ${e} L ${e} 0`,stroke:n,"stroke-width":o}}]}case"crosshatch":return[{tag:"path",attrs:{d:`M 0 ${e} L ${e} 0 M 0 0 L ${e} ${e}`,stroke:n,"stroke-width":i}}];case"zigzag":{let o=r?.amplitude!=null?Math.max(.05,Math.min(.5,r.amplitude)):.25,s=e*o;return[{tag:"path",attrs:{d:`M 0 ${s} L ${e/4} 0 L ${e/2} ${s} L ${e*3/4} 0 L ${e} ${s}`,fill:"none",stroke:n,"stroke-width":i}}]}case"waves":{let o=r?.amplitude!=null?Math.max(.05,Math.min(.5,r.amplitude)):.25,s=e*o,a=e/2;return[{tag:"path",attrs:{d:`M 0 ${a} Q ${e/4} ${a-s} ${e/2} ${a} T ${e} ${a}`,fill:"none",stroke:n,"stroke-width":i}}]}case"triangles":{let o=e*.866;return[{tag:"path",attrs:{d:`M ${e/2} 0 L ${e} ${o} L 0 ${o} Z`,fill:"none",stroke:n,"stroke-width":i}}]}case"hexagons":{let o=e*.866;return[{tag:"path",attrs:{d:`M ${e*.25} 0 L ${e*.75} 0 L ${e} ${o*.5} L ${e*.75} ${o} L ${e*.25} ${o} L 0 ${o*.5} Z`,fill:"none",stroke:n,"stroke-width":i}}]}case"diamonds":return[{tag:"path",attrs:{d:`M ${e/2} 0 L ${e} ${e/2} L ${e/2} ${e} L 0 ${e/2} Z`,fill:"none",stroke:n,"stroke-width":i}}];case"circles":return[{tag:"circle",attrs:{cx:e/2,cy:e/2,r:e/3,fill:"none",stroke:n,"stroke-width":i}}];case"bricks":{let o=r?.strokeWidth!=null?Math.max(.5,e*r.strokeWidth):Math.max(1,e/15);return[{tag:"rect",attrs:{x:0,y:0,width:e,height:e/2,fill:"none",stroke:n,"stroke-width":o}},{tag:"rect",attrs:{x:-e/2,y:e/2,width:e,height:e/2,fill:"none",stroke:n,"stroke-width":o}},{tag:"rect",attrs:{x:e/2,y:e/2,width:e,height:e/2,fill:"none",stroke:n,"stroke-width":o}}]}case"herringbone":return[{tag:"path",attrs:{d:`M 0 0 L ${e/2} ${e/2} L 0 ${e} M ${e/2} ${e/2} L ${e} 0 M ${e/2} ${e/2} L ${e} ${e}`,fill:"none",stroke:n,"stroke-width":i}}];default:return[]}}function Y$(t){let e=Object.entries(t.attrs).map(([n,r])=>` ${n}="${r}"`).join("");return`<${t.tag}${e}/>`}function ep(t,e,n,r,i){let o=10*e,s="";s+=`<rect width="${o}" height="${o}" fill="${r}"/>`;let a=ac(t,o,n,i);for(let c of a)s+=Y$(c);return{svgContent:s,width:o,height:o}}function de(t,e,n){n==null||n===""||t.push([e,n])}function tp(t){return(t.stops??[]).map(e=>{let n=[["offset",`${e.offset*100}%`],["stop-color",e.color]];return e.opacity!==void 0&&e.opacity<1&&n.push(["stop-opacity",e.opacity]),{attributes:n}})}function q$(t){let e=Object.entries(t.attrs).map(([n,r])=>` ${n}="${fe(String(r))}"`).join("");return`<${t.tag}${e}/>`}function np(t,e){let n=[["id",t]];if(e.svgContent!=null){let c=e.authoredGeometry??{};return de(n,"patternUnits",e.patternUnits??"userSpaceOnUse"),de(n,"patternContentUnits",e.patternContentUnits),de(n,"x",c.x??e.x),de(n,"y",c.y??e.y),de(n,"width",c.width??e.width??10),de(n,"height",c.height??e.height??10),de(n,"viewBox",e.viewBox),de(n,"preserveAspectRatio",e.preserveAspectRatio),de(n,"patternTransform",e.patternTransform),{attributes:n,content:e.svgContent}}let r=10*(e.scale??1),i=e.color||"#000000",o=e.backgroundColor||"#ffffff";de(n,"patternUnits","userSpaceOnUse"),de(n,"width",r),de(n,"height",r),e.rotation&&de(n,"patternTransform",`rotate(${e.rotation})`);let s=`<rect width="${fe(String(r))}" height="${fe(String(r))}" fill="${fe(o)}"/>`,a=ac(e.patternType,r,i).map(q$).join("");return{attributes:n,content:`${s}${a}`}}function rp(t,e){let n=e.gradientUnits==="userSpaceOnUse",r=s=>n?String(s):`${s*100}%`,i=e.authoredGeometry??{},o=[["id",t]];return n&&de(o,"gradientUnits","userSpaceOnUse"),de(o,"x1",i.x1??r(e.x1)),de(o,"y1",i.y1??r(e.y1)),de(o,"x2",i.x2??r(e.x2)),de(o,"y2",i.y2??r(e.y2)),de(o,"spreadMethod",e.spreadMethod),e.colorInterpolation&&e.colorInterpolation!=="sRGB"&&de(o,"color-interpolation",e.colorInterpolation),de(o,"gradientTransform",i.gradientTransform??ca(e.gradientTransform)),{element:"linearGradient",attributes:o,stops:tp(e)}}function ip(t,e){let n=e.gradientUnits==="userSpaceOnUse",r=a=>n?String(a):`${a*100}%`,i=e.authoredGeometry??{},o=[["id",t]];if(n&&de(o,"gradientUnits","userSpaceOnUse"),de(o,"cx",i.cx??r(e.cx)),de(o,"cy",i.cy??r(e.cy)),de(o,"fx",i.fx??r(e.fx)),de(o,"fy",i.fy??r(e.fy)),de(o,"r",i.r??r(e.r)),(i.fr!==void 0||e.fr!==void 0&&e.fr>0)&&de(o,"fr",i.fr??r(e.fr??0)),de(o,"spreadMethod",e.spreadMethod),e.colorInterpolation&&e.colorInterpolation!=="sRGB"&&de(o,"color-interpolation",e.colorInterpolation),i.gradientTransform!==void 0||e.gradientTransform!==void 0)de(o,"gradientTransform",i.gradientTransform??ca(e.gradientTransform));else{let a=e.ry!==void 0&&e.ry!==e.r,c=!!e.rotation;if(!a&&!c)return{element:"radialGradient",attributes:o,stops:tp(e)};let l=e.cx??(n?0:.5),d=e.cy??(n?0:.5),u=[`translate(${l}, ${d})`];c&&u.push(`rotate(${e.rotation})`),a&&e.ry!==0&&u.push(`scale(1, ${e.ry/e.r})`),u.push(`translate(${-l}, ${-d})`),de(o,"gradientTransform",u.join(" "))}return{element:"radialGradient",attributes:o,stops:tp(e)}}function ZS(t){return t.some(e=>e.type==="gaussian-blur"||e.type==="motion-blur"||e.type==="drop-shadow"||e.type==="inner-shadow"||e.type==="glow"||e.type==="inner-glow"||e.type==="outline"||e.type==="morphology"||e.type==="warp"||e.type==="svg-primitive-chain"&&e.primitives.some(n=>n.type==="feGaussianBlur"||n.type==="feDropShadow"||n.type==="feOffset"||n.type==="feMorphology"||n.type==="feDisplacementMap"||n.type==="feTurbulence"))}function op(t,e,n={}){let r=e.filter(p=>p.enabled);if(r.length===0)return null;let i=r.find(p=>p.type==="raw-svg");if(i){let p=[["id",t]];return de(p,"x",n.x??i.x),de(p,"y",n.y??i.y),de(p,"width",n.width??i.width),de(p,"height",n.height??i.height),de(p,"filterUnits",n.filterUnits??i.filterUnits),de(p,"primitiveUnits",n.primitiveUnits??i.primitiveUnits),de(p,"color-interpolation-filters",n.colorInterpolation&&n.colorInterpolation!=="auto"?n.colorInterpolation:i.colorInterpolationFilters),de(p,"flood-color",i.floodColor),de(p,"flood-opacity",i.floodOpacity),de(p,"lighting-color",i.lightingColor),de(p,"display",i.display),{kind:"raw",attributes:p,content:i.svgContent}}let o=r.find(p=>p.type==="svg-primitive-chain");if(o)return{kind:"primitive-chain",attributes:[],chain:{...o,x:n.x??o.x,y:n.y??o.y,width:n.width??o.width,height:n.height??o.height,filterUnits:n.filterUnits??o.filterUnits,primitiveUnits:n.primitiveUnits??o.primitiveUnits,filterColorInterpolation:n.colorInterpolation&&n.colorInterpolation!=="auto"?n.colorInterpolation:o.filterColorInterpolation}};let s=r.some(p=>p.type==="gaussian-blur"&&p.quality==="high"||p.type==="motion-blur"&&p.quality==="high"),a=ZS(r),c=a?s?"-200%":"-100%":"-10%",l=a?s?"500%":"300%":"120%",d=n.primitiveUnits??"userSpaceOnUse",u=[["id",t]];return de(u,"x",n.x??c),de(u,"y",n.y??c),de(u,"width",n.width??l),de(u,"height",n.height??l),de(u,"filterUnits",n.filterUnits??"objectBoundingBox"),de(u,"primitiveUnits",d),n.colorInterpolation&&n.colorInterpolation!=="auto"&&de(u,"color-interpolation-filters",n.colorInterpolation),{kind:"generated",attributes:u,filters:r,primitiveUnits:d}}function S(t,e){return e==null||e===""?"":` ${t}="${fe(String(e))}"`}function lc(t){let e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e?{r:parseInt(e[1],16)/255,g:parseInt(e[2],16)/255,b:parseInt(e[3],16)/255}:{r:0,g:0,b:0}}function Z$(t,e,n){let{offsetX:r,offsetY:i,blurRadius:o,spread:s,color:a,opacity:c}=t,l="";if(s===0)l+=`<feDropShadow${S("in",e)}${S("dx",r)}${S("dy",i)}${S("stdDeviation",o/2)}${S("flood-color",a)}${S("flood-opacity",c)}${S("result",`${n}_shadow`)}/>`,l+=`<feMerge${S("result",n)}><feMergeNode${S("in",`${n}_shadow`)}/><feMergeNode${S("in",e)}/></feMerge>`;else{l+=`<feColorMatrix${S("in",e)}${S("type","matrix")}${S("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0")}${S("result",`${n}_alpha`)}/>`;let d=s>0?"dilate":"erode",u=Math.abs(s);l+=`<feMorphology${S("in",`${n}_alpha`)}${S("operator",d)}${S("radius",u)}${S("result",`${n}_spread`)}/>`,l+=`<feGaussianBlur${S("in",`${n}_spread`)}${S("stdDeviation",o/2)}${S("result",`${n}_blur`)}/>`,l+=`<feOffset${S("in",`${n}_blur`)}${S("dx",r)}${S("dy",i)}${S("result",`${n}_offset`)}/>`,l+=`<feFlood${S("flood-color",a)}${S("flood-opacity",c)}${S("result",`${n}_color`)}/>`,l+=`<feComposite${S("in",`${n}_color`)}${S("in2",`${n}_offset`)}${S("operator","in")}${S("result",`${n}_shadow`)}/>`,l+=`<feMerge${S("result",n)}><feMergeNode${S("in",`${n}_shadow`)}/><feMergeNode${S("in",e)}/></feMerge>`}return l}function J$(t,e,n){let{offsetX:r,offsetY:i,blurRadius:o,choke:s,color:a,opacity:c}=t,l=o*(1-s/100),d="";return d+=`<feColorMatrix${S("in",e)}${S("type","matrix")}${S("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0")}${S("result",`${n}_alpha`)}/>`,d+=`<feComponentTransfer${S("in",`${n}_alpha`)}${S("result",`${n}_inverted`)}><feFuncA${S("type","table")}${S("tableValues","1 0")}/></feComponentTransfer>`,d+=`<feGaussianBlur${S("in",`${n}_inverted`)}${S("stdDeviation",l/2)}${S("result",`${n}_blur`)}/>`,d+=`<feOffset${S("in",`${n}_blur`)}${S("dx",r)}${S("dy",i)}${S("result",`${n}_offset`)}/>`,d+=`<feFlood${S("flood-color",a)}${S("flood-opacity",c)}${S("result",`${n}_color`)}/>`,d+=`<feComposite${S("in",`${n}_color`)}${S("in2",`${n}_offset`)}${S("operator","in")}${S("result",`${n}_coloredShadow`)}/>`,d+=`<feComposite${S("in",`${n}_coloredShadow`)}${S("in2",`${n}_alpha`)}${S("operator","in")}${S("result",`${n}_innerShadow`)}/>`,d+=`<feComposite${S("in",`${n}_innerShadow`)}${S("in2",e)}${S("operator","over")}${S("result",n)}/>`,d}function Q$(t,e,n){let{blurX:r,blurY:i}=t;return r===0&&i===0?De(e,n):`<feGaussianBlur${S("in",e)}${S("stdDeviation",`${r/2} ${i/2}`)}${S("result",n)}/>`}function eN(t,e,n){let{distance:r,angle:i}=t;if(r===0)return De(e,n);let o=i*Math.PI/180,s=Math.abs(Math.cos(o)*r),a=Math.abs(Math.sin(o)*r);return`<feGaussianBlur${S("in",e)}${S("stdDeviation",`${s/2} ${a/2}`)}${S("result",n)}/>`}function JS(t,e,n){let{x:r,y:i,z:o,color:s,surfaceScale:a,diffuseConstant:c,specularConstant:l,specularExponent:d}=t,u="";return u+=`<feDiffuseLighting${S("in","SourceAlpha")}${S("surfaceScale",a)}${S("diffuseConstant",c)}${S("lighting-color",s)}${S("result",`${n}_diffuse`)}>`,u+=`<fePointLight${S("x",r)}${S("y",i)}${S("z",o)}/>`,u+="</feDiffuseLighting>",u+=`<feSpecularLighting${S("in","SourceAlpha")}${S("surfaceScale",a)}${S("specularConstant",l)}${S("specularExponent",d)}${S("lighting-color",s)}${S("result",`${n}_specular`)}>`,u+=`<fePointLight${S("x",r)}${S("y",i)}${S("z",o)}/>`,u+="</feSpecularLighting>",u+=`<feComposite${S("in",e)}${S("in2",`${n}_diffuse`)}${S("operator","arithmetic")}${S("k1",1)}${S("k2",0)}${S("k3",0)}${S("k4",0)}${S("result",`${n}_lit`)}/>`,u+=`<feComposite${S("in",`${n}_specular`)}${S("in2",`${n}_lit`)}${S("operator","arithmetic")}${S("k1",0)}${S("k2",1)}${S("k3",1)}${S("k4",0)}${S("result",n)}/>`,u}function QS(t,e,n){let{x:r,y:i,z:o,pointsAtX:s,pointsAtY:a,pointsAtZ:c,coneAngle:l,color:d,surfaceScale:u,specularConstant:p,specularExponent:f}=t,m="";return m+=`<feSpecularLighting${S("in","SourceAlpha")}${S("surfaceScale",u)}${S("specularConstant",p)}${S("specularExponent",f)}${S("lighting-color",d)}${S("result",`${n}_specular`)}>`,m+=`<feSpotLight${S("x",r)}${S("y",i)}${S("z",o)}${S("pointsAtX",s)}${S("pointsAtY",a)}${S("pointsAtZ",c)}${S("limitingConeAngle",l)}/>`,m+="</feSpecularLighting>",m+=`<feComposite${S("in",`${n}_specular`)}${S("in2","SourceAlpha")}${S("operator","in")}${S("result",`${n}_clipped`)}/>`,m+=`<feComposite${S("in",`${n}_clipped`)}${S("in2",e)}${S("operator","arithmetic")}${S("k1",0)}${S("k2",1)}${S("k3",1)}${S("k4",0)}${S("result",n)}/>`,m}function eb(t){switch(t.kind){case"point":return`<fePointLight${S("x",t.x)}${S("y",t.y)}${S("z",t.z)}/>`;case"spot":{let e=`<feSpotLight${S("x",t.x)}${S("y",t.y)}${S("z",t.z)}${S("pointsAtX",t.pointsAtX)}${S("pointsAtY",t.pointsAtY)}${S("pointsAtZ",t.pointsAtZ)}`;return t.limitingConeAngle!==void 0&&(e+=S("limitingConeAngle",t.limitingConeAngle)),t.specularExponent!==void 0&&(e+=S("specularExponent",t.specularExponent)),e+"/>"}case"distant":return`<feDistantLight${S("azimuth",t.azimuth)}${S("elevation",t.elevation)}/>`}}function tN(t,e,n){return`<feDiffuseLighting${S("in",e)}${S("surfaceScale",t.surfaceScale)}${S("diffuseConstant",t.diffuseConstant)}${S("lighting-color",t.color)}${S("result",n)}>`+eb(t.lightSource)+"</feDiffuseLighting>"}function nN(t,e,n){return`<feSpecularLighting${S("in",e)}${S("surfaceScale",t.surfaceScale)}${S("specularConstant",t.specularConstant)}${S("specularExponent",t.specularExponent)}${S("lighting-color",t.color)}${S("result",n)}>`+eb(t.lightSource)+"</feSpecularLighting>"}function rN(t,e,n){let{width:r,color:i,opacity:o,position:s}=t,a="";if(s==="inside")a+=`<feMorphology${S("in","SourceAlpha")}${S("operator","erode")}${S("radius",r)}${S("result",`${n}_eroded`)}/>`,a+=`<feComposite${S("in","SourceAlpha")}${S("in2",`${n}_eroded`)}${S("operator","out")}${S("result",`${n}_outlineAlpha`)}/>`,a+=`<feFlood${S("flood-color",i)}${S("flood-opacity",o)}${S("result",`${n}_color`)}/>`,a+=`<feComposite${S("in",`${n}_color`)}${S("in2",`${n}_outlineAlpha`)}${S("operator","in")}${S("result",`${n}_outline`)}/>`,a+=`<feComposite${S("in",`${n}_outline`)}${S("in2",e)}${S("operator","over")}${S("result",n)}/>`;else{let c=s==="outside"?r:r/2;a+=`<feMorphology${S("in","SourceAlpha")}${S("operator","dilate")}${S("radius",c)}${S("result",`${n}_dilated`)}/>`,a+=`<feComposite${S("in",`${n}_dilated`)}${S("in2","SourceAlpha")}${S("operator","out")}${S("result",`${n}_outlineAlpha`)}/>`,a+=`<feFlood${S("flood-color",i)}${S("flood-opacity",o)}${S("result",`${n}_color`)}/>`,a+=`<feComposite${S("in",`${n}_color`)}${S("in2",`${n}_outlineAlpha`)}${S("operator","in")}${S("result",`${n}_outline`)}/>`,a+=`<feMerge${S("result",n)}><feMergeNode${S("in",`${n}_outline`)}/><feMergeNode${S("in",e)}/></feMerge>`}return a}function iN(t,e,n){let{amount:r}=t;if(r===0)return De(e,n);let i=1+4*r,o=-r,s=[0,o,0,o,i,o,0,o,0].join(" ");return`<feConvolveMatrix${S("in",e)}${S("order","3")}${S("kernelMatrix",s)}${S("divisor","1")}${S("bias","0")}${S("preserveAlpha","true")}${S("edgeMode","duplicate")}${S("result",n)}/>`}function oN(t,e,n){let{blockSize:r}=t;if(r<=1)return De(e,n);let i=r/2,o="";return o+=`<feMorphology${S("in",e)}${S("operator","erode")}${S("radius",i)}${S("result",`${n}_eroded`)}/>`,o+=`<feMorphology${S("in",`${n}_eroded`)}${S("operator","dilate")}${S("radius",i)}${S("result",n)}/>`,o}function sN(t,e,n){let{scale:r,frequency:i,octaves:o,warpType:s}=t;if(r===0)return De(e,n);let a="";return a+=`<feTurbulence${S("type",s)}${S("baseFrequency",i)}${S("numOctaves",o)}${S("seed",0)}${S("result",`${n}_turbulence`)}/>`,a+=`<feDisplacementMap${S("in",e)}${S("in2",`${n}_turbulence`)}${S("scale",r)}${S("xChannelSelector","R")}${S("yChannelSelector","G")}${S("result",n)}/>`,a}function aN(t,e,n){let{operator:r,radiusX:i,radiusY:o}=t;return i===0&&o===0?De(e,n):`<feMorphology${S("in",e)}${S("operator",r)}${S("radius",`${i} ${o}`)}${S("result",n)}/>`}function cN(t,e,n){let{levels:r}=t;if(r<2)return De(e,n);let i=[];for(let a=0;a<r;a++)i.push(a/(r-1));let o=i.join(" "),s=`<feComponentTransfer${S("in",e)}${S("result",n)}>`;return s+=`<feFuncR${S("type","discrete")}${S("tableValues",o)}/>`,s+=`<feFuncG${S("type","discrete")}${S("tableValues",o)}/>`,s+=`<feFuncB${S("type","discrete")}${S("tableValues",o)}/>`,s+="</feComponentTransfer>",s}function lN(t,e,n){let{levels:r,contrast:i}=t;if(r<2)return De(e,n);let o=[];for(let c=0;c<r;c++){let l=c/(r-1),d=l;i!==1&&(d=.5+(l-.5)*i,d=Math.max(0,Math.min(1,d))),o.push(d)}let s=o.join(" "),a=`<feComponentTransfer${S("in",e)}${S("result",n)}>`;return a+=`<feFuncR${S("type","table")}${S("tableValues",s)}/>`,a+=`<feFuncG${S("type","table")}${S("tableValues",s)}/>`,a+=`<feFuncB${S("type","table")}${S("tableValues",s)}/>`,a+="</feComponentTransfer>",a}function dN(t,e,n){let{radius:r}=t;if(r===0)return De(e,n);let i="";return i+=`<feGaussianBlur${S("in","SourceAlpha")}${S("stdDeviation",r)}${S("result",`${n}_blurredAlpha`)}/>`,i+=`<feComponentTransfer${S("in",`${n}_blurredAlpha`)}${S("result",`${n}_thresholdAlpha`)}><feFuncA${S("type","linear")}${S("slope",20)}${S("intercept",-9)}/></feComponentTransfer>`,i+=`<feComposite${S("in",e)}${S("in2",`${n}_thresholdAlpha`)}${S("operator","in")}${S("result",n)}/>`,i}function uN(t,e,n){let{amount:r}=t;if(r===0)return De(e,n);let i=1-r;return`<feColorMatrix${S("color-interpolation-filters","sRGB")}${S("in",e)}${S("type","saturate")}${S("values",i)}${S("result",n)}/>`}function pN(t,e,n){let{red:r,green:i,blue:o}=t;if(r===1&&i===1&&o===1)return De(e,n);let s=`<feComponentTransfer${S("in",e)}${S("result",n)}>`;return s+=`<feFuncR${S("type","linear")}${S("slope",r)}${S("intercept",0)}/>`,s+=`<feFuncG${S("type","linear")}${S("slope",i)}${S("intercept",0)}/>`,s+=`<feFuncB${S("type","linear")}${S("slope",o)}${S("intercept",0)}/>`,s+="</feComponentTransfer>",s}function fN(t,e,n){let{amount:r}=t;if(r===1)return De(e,n);let i=`<feComponentTransfer${S("color-interpolation-filters","sRGB")}${S("in",e)}${S("result",n)}>`;return i+=`<feFuncR${S("type","linear")}${S("slope",r)}${S("intercept",0)}/>`,i+=`<feFuncG${S("type","linear")}${S("slope",r)}${S("intercept",0)}/>`,i+=`<feFuncB${S("type","linear")}${S("slope",r)}${S("intercept",0)}/>`,i+="</feComponentTransfer>",i}function mN(t,e,n){let{amount:r}=t;if(r===1)return De(e,n);let i=.5*(1-r),o=`<feComponentTransfer${S("color-interpolation-filters","sRGB")}${S("in",e)}${S("result",n)}>`;return o+=`<feFuncR${S("type","linear")}${S("slope",r)}${S("intercept",i)}/>`,o+=`<feFuncG${S("type","linear")}${S("slope",r)}${S("intercept",i)}/>`,o+=`<feFuncB${S("type","linear")}${S("slope",r)}${S("intercept",i)}/>`,o+="</feComponentTransfer>",o}function gN(t,e,n){let{amount:r}=t;if(r===1)return De(e,n);let i=`<feComponentTransfer${S("color-interpolation-filters","sRGB")}${S("in",e)}${S("result",n)}>`;return i+=`<feFuncA${S("type","linear")}${S("slope",r)}${S("intercept",0)}/>`,i+="</feComponentTransfer>",i}function hN(t,e,n){let{amount:r}=t;if(r===0)return De(e,n);let i=r,o=1-r,s=`${i} ${o}`,a=`<feComponentTransfer${S("color-interpolation-filters","sRGB")}${S("in",e)}${S("result",n)}>`;return a+=`<feFuncR${S("type","table")}${S("tableValues",s)}/>`,a+=`<feFuncG${S("type","table")}${S("tableValues",s)}/>`,a+=`<feFuncB${S("type","table")}${S("tableValues",s)}/>`,a+="</feComponentTransfer>",a}function yN(t,e,n){let{angle:r}=t;return r===0||r===360?De(e,n):`<feColorMatrix${S("color-interpolation-filters","sRGB")}${S("in",e)}${S("type","hueRotate")}${S("values",r)}${S("result",n)}/>`}function SN(t,e,n){let{amount:r}=t;return r===1?De(e,n):`<feColorMatrix${S("color-interpolation-filters","sRGB")}${S("in",e)}${S("type","saturate")}${S("values",r)}${S("result",n)}/>`}function bN(t,e,n){let{threshold:r}=t,i="";if(i+=`<feColorMatrix${S("in",e)}${S("type","saturate")}${S("values",0)}${S("result",`${n}_gray`)}/>`,r===.5)i+=`<feComponentTransfer${S("in",`${n}_gray`)}${S("result",n)}>`,i+=`<feFuncR${S("type","discrete")}${S("tableValues","0 1")}/>`,i+=`<feFuncG${S("type","discrete")}${S("tableValues","0 1")}/>`,i+=`<feFuncB${S("type","discrete")}${S("tableValues","0 1")}/>`,i+="</feComponentTransfer>";else{let s=[];for(let c=0;c<256;c++)s.push(c/255<r?0:1);let a=s.join(" ");i+=`<feComponentTransfer${S("in",`${n}_gray`)}${S("result",n)}>`,i+=`<feFuncR${S("type","table")}${S("tableValues",a)}/>`,i+=`<feFuncG${S("type","table")}${S("tableValues",a)}/>`,i+=`<feFuncB${S("type","table")}${S("tableValues",a)}/>`,i+="</feComponentTransfer>"}return i}function vN(t,e,n){let{amount:r}=t;if(r===0)return De(e,n);let i=[.393,.769,.189,0,0],o=[.349,.686,.168,0,0],s=[.272,.534,.131,0,0],a=[1,0,0,0,0],c=[0,1,0,0,0],l=[0,0,1,0,0],d=(g,h)=>g.map((y,b)=>y*(1-r)+h[b]*r),u=d(a,i),p=d(c,o),f=d(l,s),m=[...u,...p,...f,0,0,0,1,0].join(" ");return`<feColorMatrix${S("color-interpolation-filters","sRGB")}${S("in",e)}${S("type","matrix")}${S("values",m)}${S("result",n)}/>`}function xN(t,e,n){let{shadowColor:r,highlightColor:i}=t,o=lc(r),s=lc(i),a="";return a+=`<feColorMatrix${S("in",e)}${S("type","saturate")}${S("values",0)}${S("result",`${n}_gray`)}/>`,a+=`<feComponentTransfer${S("in",`${n}_gray`)}${S("result",n)}>`,a+=`<feFuncR${S("type","table")}${S("tableValues",`${o.r} ${s.r}`)}/>`,a+=`<feFuncG${S("type","table")}${S("tableValues",`${o.g} ${s.g}`)}/>`,a+=`<feFuncB${S("type","table")}${S("tableValues",`${o.b} ${s.b}`)}/>`,a+="</feComponentTransfer>",a}function IN(t,e,n){let{intensity:r}=t;if(r===0)return De(e,n);let i="";i+=`<feComponentTransfer${S("in",e)}${S("result",`${n}_invert`)}>`,i+=`<feFuncR${S("type","table")}${S("tableValues","1 0")}/>`,i+=`<feFuncG${S("type","table")}${S("tableValues","1 0")}/>`,i+=`<feFuncB${S("type","table")}${S("tableValues","1 0")}/>`,i+="</feComponentTransfer>",i+=`<feColorMatrix${S("in",`${n}_invert`)}${S("type","saturate")}${S("values",0)}${S("result",`${n}_gray`)}/>`;let o=[.1,.1,.1,0,0],s=[.3,.4,.3,0,0],a=[.5,.5,.8,0,0],c=[1,0,0,0,0],l=[0,1,0,0,0],d=[0,0,1,0,0],u=(h,y)=>h.map((b,v)=>b*(1-r)+y[v]*r),p=u(c,o),f=u(l,s),m=u(d,a),g=[...p,...f,...m,0,0,0,1,0].join(" ");return i+=`<feColorMatrix${S("in",`${n}_gray`)}${S("type","matrix")}${S("values",g)}${S("result",n)}/>`,i}function wN(t,e,n){let{amount:r,scale:i}=t;if(r===0)return De(e,n);let o=1/i,s="";return s+=`<feTurbulence${S("type","fractalNoise")}${S("baseFrequency",o)}${S("numOctaves",3)}${S("seed",0)}${S("result",`${n}_noise`)}/>`,s+=`<feColorMatrix${S("in",`${n}_noise`)}${S("type","saturate")}${S("values",0)}${S("result",`${n}_noiseGray`)}/>`,s+=`<feBlend${S("in",e)}${S("in2",`${n}_noiseGray`)}${S("mode","overlay")}${S("result",`${n}_blended`)}/>`,s+=`<feComposite${S("in",`${n}_blended`)}${S("in2",e)}${S("operator","arithmetic")}${S("k1",0)}${S("k2",r)}${S("k3",1-r)}${S("k4",0)}${S("result",`${n}_amt`)}/>`,s+=`<feComposite${S("in",`${n}_amt`)}${S("in2",e)}${S("operator","in")}${S("result",n)}/>`,s}function kN(t,e,n){let{strength:r,angle:i}=t;if(r===0)return De(e,n);let o=i*Math.PI/180,s=Math.cos(o),a=Math.sin(o),c=r,l=[-(c*(s+a)),-(c*a),c*(-s+a),-(c*s),1,c*s,c*(s-a),c*a,c*(s+a)].join(" ");return`<feConvolveMatrix${S("in",e)}${S("order","3 3")}${S("kernelMatrix",l)}${S("divisor",1)}${S("bias",.5)}${S("preserveAlpha","true")}${S("result",n)}/>`}function PN(t,e,n){let{amount:r,size:i}=t;if(r===0)return De(e,n);let o=.5/i,s="";return s+=`<feTurbulence${S("type","fractalNoise")}${S("baseFrequency",`${o} ${o}`)}${S("numOctaves",5)}${S("seed",0)}${S("stitchTiles","stitch")}${S("result",`${n}_grain`)}/>`,s+=`<feColorMatrix${S("in",`${n}_grain`)}${S("type","saturate")}${S("values",0)}${S("result",`${n}_grainGray`)}/>`,s+=`<feBlend${S("in",e)}${S("in2",`${n}_grainGray`)}${S("mode","soft-light")}${S("result",`${n}_blended`)}/>`,s+=`<feComposite${S("in",`${n}_blended`)}${S("in2",e)}${S("operator","arithmetic")}${S("k1",0)}${S("k2",r)}${S("k3",1-r)}${S("k4",0)}${S("result",`${n}_amt`)}/>`,s+=`<feComposite${S("in",`${n}_amt`)}${S("in2",e)}${S("operator","in")}${S("result",n)}/>`,s}function TN(t,e,n){let{wetness:r,turbulence:i}=t;if(r===0&&i===0)return De(e,n);let o="";return o+=`<feTurbulence${S("type","fractalNoise")}${S("baseFrequency",.02+i*.03)}${S("numOctaves",4)}${S("seed",42)}${S("result",`${n}_turb`)}/>`,o+=`<feDisplacementMap${S("in",e)}${S("in2",`${n}_turb`)}${S("scale",r*15)}${S("xChannelSelector","R")}${S("yChannelSelector","G")}${S("result",`${n}_disp`)}/>`,o+=`<feGaussianBlur${S("in",`${n}_disp`)}${S("stdDeviation",r*2)}${S("result",`${n}_blur`)}/>`,o+=`<feBlend${S("in",`${n}_blur`)}${S("in2",e)}${S("mode","multiply")}${S("result",n)}/>`,o}function RN(t,e,n){let{thickness:r,texture:i}=t;if(r===0&&i===0)return De(e,n);let o="";o+=`<feTurbulence${S("type","turbulence")}${S("baseFrequency",.03+i*.02)}${S("numOctaves",3)}${S("seed",1e3)}${S("result",`${n}_brush`)}/>`;let s=Math.max(3,8-Math.floor(r*5)),a=Array.from({length:s+1},(c,l)=>l/s).join(" ");o+=`<feComponentTransfer${S("in",e)}${S("result",`${n}_poster`)}>`;for(let c of["R","G","B"])o+=`<feFunc${c}${S("type","discrete")}${S("tableValues",a)}/>`;return o+="</feComponentTransfer>",o+=`<feDisplacementMap${S("in",`${n}_poster`)}${S("in2",`${n}_brush`)}${S("scale",i*4)}${S("xChannelSelector","R")}${S("yChannelSelector","G")}${S("result",`${n}_disp`)}/>`,o+=`<feMorphology${S("in",`${n}_disp`)}${S("operator","dilate")}${S("radius",r*.5)}${S("result",`${n}_thick`)}/>`,o+=`<feComposite${S("in",`${n}_thick`)}${S("in2",e)}${S("operator","in")}${S("result",n)}/>`,o}function CN(t,e,n){let{spread:r,edges:i}=t;if(r===0&&i===0)return De(e,n);let o="";return o+=`<feTurbulence${S("type","fractalNoise")}${S("baseFrequency",.01+i*.02)}${S("numOctaves",5)}${S("seed",1100)}${S("result",`${n}_ink`)}/>`,o+=`<feMorphology${S("in",e)}${S("operator","dilate")}${S("radius",r*3)}${S("result",`${n}_dilate`)}/>`,o+=`<feDisplacementMap${S("in",`${n}_dilate`)}${S("in2",`${n}_ink`)}${S("scale",i*10)}${S("xChannelSelector","R")}${S("yChannelSelector","G")}${S("result",`${n}_disp`)}/>`,o+=`<feGaussianBlur${S("in",`${n}_disp`)}${S("stdDeviation",r*.5)}${S("result",n)}/>`,o}function $N(t,e,n){let{wrinkles:r,shine:i}=t;if(r===0&&i===0)return De(e,n);let o="";return o+=`<feTurbulence${S("type","turbulence")}${S("baseFrequency",.02)}${S("numOctaves",4)}${S("seed",1200)}${S("result",`${n}_wrinkle`)}/>`,o+=`<feDisplacementMap${S("in",e)}${S("in2",`${n}_wrinkle`)}${S("scale",r*15)}${S("xChannelSelector","R")}${S("yChannelSelector","G")}${S("result",`${n}_disp`)}/>`,o+=`<feSpecularLighting${S("in",`${n}_wrinkle`)}${S("surfaceScale",r*2)}${S("specularConstant",i*1.5)}${S("specularExponent",20)}${S("result",`${n}_sheen`)}>`,o+=`<feDistantLight${S("azimuth",45)}${S("elevation",60)}/>`,o+="</feSpecularLighting>",o+=`<feBlend${S("in",`${n}_disp`)}${S("in2",`${n}_sheen`)}${S("mode","screen")}${S("result",`${n}_blend`)}/>`,o+=`<feComposite${S("in",`${n}_blend`)}${S("in2",e)}${S("operator","in")}${S("result",n)}/>`,o}function NN(t,e,n){let{density:r,size:i}=t;if(r===0)return De(e,n);let o="",s=1-r;o+=`<feTurbulence${S("type","turbulence")}${S("baseFrequency",.1/i)}${S("numOctaves",1)}${S("seed",1400)}${S("result",`${n}_hole`)}/>`,o+=`<feComponentTransfer${S("in",`${n}_hole`)}${S("result",`${n}_thresh`)}>`;for(let a of["R","G","B","A"])o+=`<feFunc${a}${S("type","linear")}${S("slope",10)}${S("intercept",-s*10+5)}/>`;o+="</feComponentTransfer>",o+=`<feComponentTransfer${S("in",`${n}_thresh`)}${S("result",`${n}_clamp`)}>`;for(let a of["R","G","B","A"])o+=`<feFunc${a}${S("type","table")}${S("tableValues","0 0 1 1")}/>`;return o+="</feComponentTransfer>",o+=`<feComposite${S("in",e)}${S("in2",`${n}_clamp`)}${S("operator","in")}${S("result",n)}/>`,o}function AN(t,e,n){let{color:r,radius:i,intensity:o}=t;if(o===0||i===0)return De(e,n);let{r:s,g:a,b:c}=lc(r),l="";return l+=`<feColorMatrix${S("in",e)}${S("type","matrix")}${S("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0")}${S("result",`${n}_alpha`)}/>`,l+=`<feGaussianBlur${S("in",`${n}_alpha`)}${S("stdDeviation",i/2)}${S("result",`${n}_blur`)}/>`,l+=`<feColorMatrix${S("in",`${n}_blur`)}${S("type","matrix")}${S("values",`0 0 0 0 ${s} 0 0 0 0 ${a} 0 0 0 0 ${c} 0 0 0 ${o} 0`)}${S("result",`${n}_color`)}/>`,l+=`<feMerge${S("result",n)}><feMergeNode${S("in",`${n}_color`)}/><feMergeNode${S("in",e)}/></feMerge>`,l}function EN(t,e,n){let{color:r,radius:i,intensity:o}=t;if(o===0||i===0)return De(e,n);let{r:s,g:a,b:c}=lc(r),l="";return l+=`<feColorMatrix${S("in",e)}${S("type","matrix")}${S("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0")}${S("result",`${n}_alpha`)}/>`,l+=`<feMorphology${S("in",`${n}_alpha`)}${S("operator","erode")}${S("radius",i/4)}${S("result",`${n}_erode`)}/>`,l+=`<feComposite${S("in",`${n}_alpha`)}${S("in2",`${n}_erode`)}${S("operator","out")}${S("result",`${n}_edge`)}/>`,l+=`<feGaussianBlur${S("in",`${n}_edge`)}${S("stdDeviation",i/3)}${S("result",`${n}_blur`)}/>`,l+=`<feColorMatrix${S("in",`${n}_blur`)}${S("type","matrix")}${S("values",`0 0 0 0 ${s} 0 0 0 0 ${a} 0 0 0 0 ${c} 0 0 0 ${o*2} 0`)}${S("result",`${n}_color`)}/>`,l+=`<feComposite${S("in",`${n}_color`)}${S("in2",`${n}_alpha`)}${S("operator","in")}${S("result",`${n}_clipped`)}/>`,l+=`<feComposite${S("in",`${n}_clipped`)}${S("in2",e)}${S("operator","over")}${S("result",n)}/>`,l}function De(t,e){return`<feMerge${S("result",e)}><feMergeNode${S("in",t)}/></feMerge>`}function sp(t){switch(t.type){case"feBlend":return MN(t);case"feColorMatrix":return ON(t);case"feComponentTransfer":return DN(t);case"feComposite":return zN(t);case"feConvolveMatrix":return _N(t);case"feDiffuseLighting":return FN(t);case"feSpecularLighting":return LN(t);case"feDisplacementMap":return BN(t);case"feDropShadow":return GN(t);case"feFlood":return VN(t);case"feGaussianBlur":return jN(t);case"feImage":return UN(t);case"feMerge":return HN(t);case"feMorphology":return WN(t);case"feOffset":return KN(t);case"feTile":return XN(t);case"feTurbulence":return YN(t)}}function bt(t){let e="";if(e+=S("in",t.in),e+=S("x",t.x),e+=S("y",t.y),e+=S("width",t.width),e+=S("height",t.height),e+=S("color-interpolation-filters",t.colorInterpolationFilters),e+=S("result",t.result),t.unknownAttrs){let n=Object.keys(t.unknownAttrs).sort();for(let r of n)e+=S(r,t.unknownAttrs[r])}return e}function vt(t){return t.animations&&t.animations.length>0?t.animations.join(""):""}function MN(t){let e=`<feBlend${bt(t)}${S("in2",t.in2)}${S("mode",t.mode)}`;t.noComposite&&(e+=' no-composite="no-composite"');let n=vt(t);return n?`${e}>${n}</feBlend>`:`${e}/>`}function ON(t){let e=`<feColorMatrix${bt(t)}${S("type",t.matrixType)}${S("values",t.values)}`,n=vt(t);return n?`${e}>${n}</feColorMatrix>`:`${e}/>`}function cc(t,e){if(!e)return"";let n=`feFunc${t}`;switch(e.type){case"identity":return`<${n} type="identity"/>`;case"table":case"discrete":return`<${n} type="${e.type}"${S("tableValues",e.tableValues.join(" "))}/>`;case"linear":return`<${n} type="linear"${S("slope",e.slope)}${S("intercept",e.intercept)}/>`;case"gamma":return`<${n} type="gamma"${S("amplitude",e.amplitude)}${S("exponent",e.exponent)}${S("offset",e.offset)}/>`}}function DN(t){let e="";return e+=cc("R",t.funcR),e+=cc("G",t.funcG),e+=cc("B",t.funcB),e+=cc("A",t.funcA),e+=vt(t),`<feComponentTransfer${bt(t)}>${e}</feComponentTransfer>`}function zN(t){let e=`<feComposite${bt(t)}${S("in2",t.in2)}${S("operator",t.operator)}`;t.operator==="arithmetic"&&(e+=S("k1",t.k1),e+=S("k2",t.k2),e+=S("k3",t.k3),e+=S("k4",t.k4));let n=vt(t);return n?`${e}>${n}</feComposite>`:`${e}/>`}function _N(t){let e=`<feConvolveMatrix${bt(t)}`;e+=S("order",t.order),e+=S("kernelMatrix",t.kernelMatrix),e+=S("divisor",t.divisor),e+=S("bias",t.bias),e+=S("targetX",t.targetX),e+=S("targetY",t.targetY),e+=S("edgeMode",t.edgeMode),e+=S("kernelUnitLength",t.kernelUnitLength),t.preserveAlpha!==void 0&&(e+=S("preserveAlpha",t.preserveAlpha?"true":"false"));let n=vt(t);return n?`${e}>${n}</feConvolveMatrix>`:`${e}/>`}function tb(t){switch(t.kind){case"feDistantLight":return`<feDistantLight${S("azimuth",t.azimuth)}${S("elevation",t.elevation)}/>`;case"fePointLight":return`<fePointLight${S("x",t.x)}${S("y",t.y)}${S("z",t.z)}/>`;case"feSpotLight":{let e=`<feSpotLight${S("x",t.x)}${S("y",t.y)}${S("z",t.z)}${S("pointsAtX",t.pointsAtX)}${S("pointsAtY",t.pointsAtY)}${S("pointsAtZ",t.pointsAtZ)}`;return e+=S("specularExponent",t.specularExponent),e+=S("limitingConeAngle",t.limitingConeAngle),e+"/>"}}}function FN(t){let e=`<feDiffuseLighting${bt(t)}`;e+=S("surfaceScale",t.surfaceScale),e+=S("diffuseConstant",t.diffuseConstant),e+=S("kernelUnitLength",t.kernelUnitLength),e+=S("lighting-color",t.lightingColor);let n="";return t.lightSource&&(n+=tb(t.lightSource)),n+=vt(t),`${e}>${n}</feDiffuseLighting>`}function LN(t){let e=`<feSpecularLighting${bt(t)}`;e+=S("surfaceScale",t.surfaceScale),e+=S("specularConstant",t.specularConstant),e+=S("specularExponent",t.specularExponent),e+=S("kernelUnitLength",t.kernelUnitLength),e+=S("lighting-color",t.lightingColor);let n="";return t.lightSource&&(n+=tb(t.lightSource)),n+=vt(t),`${e}>${n}</feSpecularLighting>`}function BN(t){let e=`<feDisplacementMap${bt(t)}`;e+=S("in2",t.in2),e+=S("scale",t.scale),e+=S("xChannelSelector",t.xChannelSelector),e+=S("yChannelSelector",t.yChannelSelector);let n=vt(t);return n?`${e}>${n}</feDisplacementMap>`:`${e}/>`}function GN(t){let e=`<feDropShadow${bt(t)}`;e+=S("dx",t.dx),e+=S("dy",t.dy),e+=S("stdDeviation",t.stdDeviation),e+=S("flood-color",t.floodColor),e+=S("flood-opacity",t.floodOpacity);let n=vt(t);return n?`${e}>${n}</feDropShadow>`:`${e}/>`}function VN(t){let e=`<feFlood${bt(t)}${S("flood-color",t.floodColor)}${S("flood-opacity",t.floodOpacity)}`,n=vt(t);return n?`${e}>${n}</feFlood>`:`${e}/>`}function jN(t){let e=`<feGaussianBlur${bt(t)}${S("stdDeviation",t.stdDeviation)}${S("edgeMode",t.edgeMode)}`,n=vt(t);return n?`${e}>${n}</feGaussianBlur>`:`${e}/>`}function UN(t){let e=`<feImage${bt(t)}`;t.href!==void 0?e+=S("href",t.href):t.xlinkHref!==void 0&&(e+=S("xlink:href",t.xlinkHref)),e+=S("preserveAspectRatio",t.preserveAspectRatio),e+=S("crossorigin",t.crossorigin);let n=vt(t);return n?`${e}>${n}</feImage>`:`${e}/>`}function HN(t){let e="";for(let n of t.nodes)e+=`<feMergeNode${S("in",n.in)}/>`;return e+=vt(t),`<feMerge${bt(t)}>${e}</feMerge>`}function WN(t){let e=`<feMorphology${bt(t)}${S("operator",t.operator)}${S("radius",t.radius)}`,n=vt(t);return n?`${e}>${n}</feMorphology>`:`${e}/>`}function KN(t){let e=`<feOffset${bt(t)}${S("dx",t.dx)}${S("dy",t.dy)}`,n=vt(t);return n?`${e}>${n}</feOffset>`:`${e}/>`}function XN(t){let e=`<feTile${bt(t)}`,n=vt(t);return n?`${e}>${n}</feTile>`:`${e}/>`}function YN(t){let e=`<feTurbulence${bt(t)}`;e+=S("baseFrequency",t.baseFrequency),e+=S("numOctaves",t.numOctaves),e+=S("seed",t.seed),e+=S("stitchTiles",t.stitchTiles),e+=S("type",t.turbulenceType);let n=vt(t);return n?`${e}>${n}</feTurbulence>`:`${e}/>`}function nb(t,e){let n=`<filter${S("id",t)}`;n+=S("x",e.x),n+=S("y",e.y),n+=S("width",e.width),n+=S("height",e.height),n+=S("filterUnits",e.filterUnits),n+=S("primitiveUnits",e.primitiveUnits),e.filterColorInterpolation&&e.filterColorInterpolation!=="auto"&&(n+=S("color-interpolation-filters",e.filterColorInterpolation)),n+=S("flood-color",e.floodColor),n+=S("flood-opacity",e.floodOpacity),n+=S("lighting-color",e.lightingColor),n+=">",e.filterTitle&&(n+=`<title>${fe(e.filterTitle)}</title>`),e.filterDescription&&(n+=`<desc>${fe(e.filterDescription)}</desc>`);for(let r of e.primitives)n+=sp(r);if(e.filterAnimations)for(let r of e.filterAnimations)n+=r;return n+="</filter>",n}function rb(t,e,n,r){switch(t.type){case"drop-shadow":return Z$(t,e,n);case"inner-shadow":return J$(t,e,n);case"gaussian-blur":return Q$(t,e,n);case"motion-blur":return eN(t,e,n);case"point-light":{let i=t;return JS(r?{...i,x:i.x+r.x,y:i.y+r.y}:i,e,n)}case"spot-light":{let i=t;return QS(r?{...i,x:i.x+r.x,y:i.y+r.y,pointsAtX:i.pointsAtX+r.x,pointsAtY:i.pointsAtY+r.y}:i,e,n)}case"diffuse-lighting":return tN(t,e,n);case"specular-lighting":return nN(t,e,n);case"outline":return rN(t,e,n);case"sharpen":return iN(t,e,n);case"pixelate":return oN(t,e,n);case"warp":return sN(t,e,n);case"morphology":return aN(t,e,n);case"contouring-discrete":return cN(t,e,n);case"contouring-table":return lN(t,e,n);case"round-edges":return dN(t,e,n);case"grayscale":return uN(t,e,n);case"channel-painter":return pN(t,e,n);case"brightness":return fN(t,e,n);case"contrast":return mN(t,e,n);case"opacity":return gN(t,e,n);case"invert":return hN(t,e,n);case"hue-rotate":return yN(t,e,n);case"saturate":return SN(t,e,n);case"black-and-white":return bN(t,e,n);case"sepia":return vN(t,e,n);case"duotone":return xN(t,e,n);case"xray":return IN(t,e,n);case"noise":return wN(t,e,n);case"emboss":return kN(t,e,n);case"film-grain":return PN(t,e,n);case"watercolor":return TN(t,e,n);case"gouache":return RN(t,e,n);case"ink-blot":return CN(t,e,n);case"crumpled-plastic":return $N(t,e,n);case"riddled":return NN(t,e,n);case"glow":return AN(t,e,n);case"inner-glow":return EN(t,e,n);case"raw-svg":return t.svgContent;case"svg-primitive-chain":return t.primitives.map(sp).join("");default:return De(e,n)}}function dc(t,e,n={}){let r=op(t,e,n);if(!r)return"";if(r.kind==="primitive-chain")return nb(t,r.chain);let i=r.attributes.map(([c,l])=>S(c,l)).join("");if(r.kind==="raw")return`<filter${i}>${r.content}</filter>`;let o="",s="SourceGraphic",a=0;for(let c of r.filters){let l=`result${a++}`;o+=rb(c,s,l),s=l}return`<filter${i}>${o}</filter>`}function qN(t){let e="",n=new Set;for(let r of t){let i=r.state.filters;if(!i||i.length===0)continue;let o=i.filter(l=>l.enabled);if(o.length===0)continue;let s=r.state.filterLibraryIds,a=Array.isArray(s)&&s.length>0?s[0]:`filter-${r.id}`;if(n.has(a))continue;n.add(a);let c=r.state;e+=dc(a,o,{colorInterpolation:c.filterColorInterpolation,filterUnits:c.filterUnits,primitiveUnits:c.primitiveUnits,x:c.filterX,y:c.filterY,width:c.filterWidth,height:c.filterHeight})}return e}function uc(t,e,n){return!e||e.length===0||e.filter(i=>i.enabled).length===0?null:Array.isArray(n)&&n.length>0?n.map(i=>`url(#${fe(i)})`).join(" "):`url(#filter-${fe(t)})`}function ZN(t,e,n){let r=uc(t,e,n);return r===null?"":` filter="${r}"`}var ve=(t,e,n={})=>({channel:"attribute",name:t,value:e,...n}),ap=/^[A-Za-z_][\w:.-]*$/,pc=(t,e)=>({channel:"style",name:t,value:e});function We(t){return typeof t=="string"?t:null}function Cr(t){return typeof t=="number"&&Number.isFinite(t)?t:null}function cp(t){return We(t("fillType"))??"solid"}function mc(t){return t("fillGradient")}function sb(t){if(!t||typeof t!="object")return;let e=t.id;return typeof e=="string"&&e.length>0?e:void 0}function JN(t){let e=We(t("fillLibraryId"))??sb(mc(t));return e?`url(#${e})`:"none"}function QN(t){let e=We(t("strokeLibraryId"))??sb(t("strokeGradient"));return e?`url(#${e})`:"none"}function ib(t,e){let n=We(t(`${e}Type`))??(e==="fill"?cp(t):"solid"),r=e==="fill"?mc(t):t("strokeGradient");if(t(e==="fill"?"inheritFill":"inheritStroke")===!0&&n==="solid"&&!r||n==="none")return null;let i=Cr(t(`${e}Opacity`))??1,o=r&&typeof r=="object"?Cr(r.opacity)??1:1,s=i*o;return s<1?s:t(e==="fill"?"preserveFillOpacity":"preserveStrokeOpacity")===!0?1:null}function eA(t){let e=We(t("strokeDasharray"));return e||Nd(We(t("lineStyle"))??"solid",Cr(t("dashLength"))??8,Cr(t("gapLength"))??4)}function ob(t){if(!We(t("strokeDasharray"))&&We(t("lineStyle"))==="dotted")return"round";let n=We(t("strokeLinecap"));return n&&n!=="butt"?n:null}function fc(t,e,n={}){if(!t||typeof t!="object"||Array.isArray(t))return[];let r=[];for(let[i,o]of Object.entries(t))typeof o=="string"&&(e==="attribute"&&!/^[a-zA-Z_:][-a-zA-Z0-9_:.]*$/.test(i)||r.push({channel:e,name:i,value:o,...n}));return r}var gc=[{id:"fill",keys:["fillColor","fillType","fillGradient","fillLibraryId","inheritFill"],project:(t,e)=>{let n=cp(t);return t("inheritFill")===!0&&n==="solid"&&!mc(t)?[ve("fill",null)]:n==="none"?[ve("fill","none")]:n==="linear-gradient"||n==="radial-gradient"||n==="pattern"?[ve("fill",JN(t))]:[ve("fill",We(t("fillColor"))??"#000000")]}},{id:"element-opacity",keys:["opacity","preserveOpacity"],project:t=>{let e=Cr(t("opacity")),n=t("preserveOpacity")===!0;return[ve("opacity",e!==null&&(e<1||n)?e:null)]}},{id:"fill-opacity",keys:["fillOpacity","preserveFillOpacity","fillType","fillGradient","inheritFill"],project:t=>[ve("fill-opacity",ib(t,"fill"))]},{id:"fill-rule",keys:["fillRule"],project:t=>{let e=We(t("fillRule"));return[ve("fill-rule",e&&e!=="nonzero"?e:null)]}},{id:"stroke",keys:["borderColor","strokeType","strokeGradient","strokeLibraryId","inheritStroke"],project:(t,e)=>{let n=We(t("strokeType"))??"solid";return t("inheritStroke")===!0&&n==="solid"&&!t("strokeGradient")?[ve("stroke",null)]:n==="none"?[ve("stroke","none")]:n==="linear-gradient"||n==="radial-gradient"||n==="pattern"?[ve("stroke",QN(t))]:[ve("stroke",We(t("borderColor"))??"none")]}},{id:"stroke-width",keys:["borderWidth"],project:t=>{let e=t("borderWidth");return[ve("stroke-width",typeof e=="number"||typeof e=="string"?e:null)]}},{id:"stroke-opacity",keys:["strokeOpacity","preserveStrokeOpacity","strokeType","strokeGradient","inheritStroke"],project:t=>[ve("stroke-opacity",ib(t,"stroke"))]},{id:"blend-mode",keys:["blendMode"],project:t=>{let e=We(t("blendMode"));return[pc("mix-blend-mode",e&&e!=="normal"?e:null)]}},{id:"paint-order",keys:["paintOrder"],project:t=>{let e=We(t("paintOrder"));return[ve("paint-order",e&&e!=="normal"?e:null)]}},{id:"inline-style",keys:["inlineStyle"],project:t=>fc(t("inlineStyle"),"style")},{id:"markers",keys:["markerStart","markerMid","markerEnd"],project:t=>[["marker-start",t("markerStart")],["marker-mid",t("markerMid")],["marker-end",t("markerEnd")]].map(([e,n])=>ve(String(e),typeof n=="string"&&n?`url(#${n})`:null))},{id:"stroke-linejoin",keys:["strokeLinejoin"],project:t=>{let e=We(t("strokeLinejoin"));return[ve("stroke-linejoin",e&&e!=="miter"?e:null)]}},{id:"stroke-linecap",keys:["strokeLinecap"],project:t=>[ve("stroke-linecap",ob(t))]},{id:"stroke-miterlimit",keys:["strokeMiterlimit"],project:t=>{let e=Cr(t("strokeMiterlimit"));return[ve("stroke-miterlimit",e!==null&&e!==4?e:null)]}},{id:"stroke-dasharray",keys:["lineStyle","dashLength","gapLength","strokeDasharray","strokeLinecap"],project:t=>[ve("stroke-dasharray",eA(t)),ve("stroke-linecap",ob(t))]},{id:"stroke-dashoffset",keys:["dashOffset"],project:t=>{let e=Cr(t("dashOffset"));return[ve("stroke-dashoffset",e!==null&&e!==0?e:null)]}},{id:"shape-rendering",keys:["shapeRendering"],project:t=>{let e=We(t("shapeRendering"));return[ve("shape-rendering",e&&e!=="auto"?e:null)]}},{id:"text-rendering",keys:["textRendering"],project:t=>{let e=We(t("textRendering"));return[ve("text-rendering",e&&e!=="auto"?e:null)]}},{id:"image-rendering",keys:["imageRendering"],project:t=>{let e=We(t("imageRendering"));return[ve("image-rendering",e&&e!=="auto"?e:null)]}},{id:"color-rendering",keys:["colorRendering"],project:t=>{let e=We(t("colorRendering"));return[ve("color-rendering",e&&e!=="auto"?e:null)]}},{id:"color-interpolation",keys:["colorInterpolation"],project:t=>{let e=We(t("colorInterpolation"));return[ve("color-interpolation",e&&e!=="sRGB"?e:null)]}},{id:"filter",keys:["filters","filterLibraryIds"],project:(t,e)=>[ve("filter",uc(e.shapeId,t("filters"),t("filterLibraryIds")))]},{id:"system-language",keys:["systemLanguage"],project:t=>{let e=t("systemLanguage");return[ve("systemLanguage",typeof e=="string"?e:null,{allowEmpty:!0})]}},{id:"required-extensions",keys:["requiredExtensions"],project:t=>{let e=t("requiredExtensions");return[ve("requiredExtensions",typeof e=="string"?e:null,{allowEmpty:!0})]}},{id:"vector-effect",keys:["vectorEffect"],project:t=>{let e=We(t("vectorEffect"));return[ve("vector-effect",e&&e!=="none"?e:null)]}},{id:"visibility",keys:["visibility"],project:t=>{let e=We(t("visibility"));return[ve("visibility",e&&e!=="visible"?e:null)]}},{id:"display",keys:["displayAttr"],project:t=>{let e=We(t("displayAttr"));return[ve("display",e&&e!=="inline"?e:null)]}},{id:"visible",keys:["visible"],project:t=>[pc("display",t("visible")===!1?"none":null)]},{id:"path-length",keys:["pathLength"],project:t=>{let e=Cr(t("pathLength"));return[ve("pathLength",e!==null&&e>=0?e:null)]}},{id:"transform-box",keys:["transformBox"],project:t=>{let e=We(t("transformBox"));return[pc("transform-box",e&&e!=="view-box"?e:null)]}},{id:"transform",keys:["rotation","transformMatrix","translateX","translateY","skewX","skewY","scaleX","scaleY","customPivot","rawTransform"],project:()=>[]},{id:"locked",keys:["locked"],project:()=>[]},{id:"metadata",keys:["metadata"],project:t=>{let e=t("metadata"),n=[],r=e?.name?qn(e.name):"";if(n.push(ve("id",r||null)),n.push(ve("class",e?.classes&&e.classes.length>0?e.classes.join(" "):null)),n.push(ve("role",e?.role??null)),n.push(ve("aria-label",e?.ariaLabel??null)),e?.aria)for(let[i,o]of Object.entries(e.aria))i!=="aria-label"&&ap.test(i)&&n.push(ve(i,o));if(n.push(ve("xml:lang",e?.lang??null)),typeof e?.tabindex=="number"&&Number.isFinite(e.tabindex)&&n.push(ve("tabindex",String(Math.trunc(e.tabindex)))),e?.autofocus&&n.push(ve("autofocus","",{allowEmpty:!0})),n.push(ve("xml:space",e?.xmlSpace??null)),e?.customData)for(let[i,o]of Object.entries(e.customData)){let s=`data-${i}`;ap.test(s)&&n.push(ve(s,o))}if(e?.foreignAttrs)for(let i of e.foreignAttrs)ap.test(i.name)&&n.push(ve(i.name,i.value));return n}},{id:"css-clip-path",keys:["cssClipPath"],project:t=>[pc("clip-path",We(t("cssClipPath")))]},{id:"css-mask-properties",keys:["cssMaskProperties"],project:t=>fc(t("cssMaskProperties"),"style")},{id:"container-presentation",keys:["containerPresentation"],project:(t,e)=>e.includeContainerPresentation?fc(t("containerPresentation"),"attribute",{ifAbsent:!0}):[]},{id:"authored-attributes",keys:["authoredAttributes"],project:(t,e)=>e.includeAuthoredAttributes?fc(t("authoredAttributes"),"attribute",{ifAbsent:!0}):[]}];function lp(t,e,n){return t.project(e,n)}function Ho(t,e){return gc.flatMap(n=>n.project(t,e))}function Ki(t){let e=t;return n=>n==="displayAttr"?t.display:e[n]}function dp(t){return cp(e=>t[e])}function ab(t){return mc(e=>t[e])}var tA=[["fontVariant","font-variant"],["fontVariantLigatures","font-variant-ligatures"],["fontVariantPosition","font-variant-position"],["fontVariantCaps","font-variant-caps"],["fontVariantNumeric","font-variant-numeric"],["fontVariantEastAsian","font-variant-east-asian"]];function fe(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function hc(t){let e=new Map,n=new Map,r=t.state,i=r;switch(t.type){case"circle":e.set("cx",String(r.x??0)),e.set("cy",String(r.y??0)),e.set("r",String(r.radius??50));break;case"ellipse":e.set("cx",String(r.cx??0)),e.set("cy",String(r.cy??0)),e.set("rx",String(r.rx??50)),e.set("ry",String(r.ry??30));break;case"rectangle":case"square":e.set("x",String(r.x??0)),e.set("y",String(r.y??0)),e.set("width",String(r.width??100)),e.set("height",String(r.height??100));{let c=r.rx??r.cornerRadius??0,l=r.ry??r.cornerRadius??0;(c>0||l>0)&&(e.set("rx",String(c)),e.set("ry",String(l)))}break;case"line":e.set("x1",String(r.x1??0)),e.set("y1",String(r.y1??0)),e.set("x2",String(r.x2??0)),e.set("y2",String(r.y2??0));break;case"text":e.set("x",String(r.x??0)),e.set("y",String(r.y??0)),r.fontSize&&e.set("font-size",String(r.fontSize)),r.fontFamily&&e.set("font-family",r.fontFamily),r.fontWeight&&e.set("font-weight",String(r.fontWeight)),r.fontStyle&&e.set("font-style",r.fontStyle),r.textAnchor&&e.set("text-anchor",r.textAnchor),r.letterSpacing&&e.set("letter-spacing",String(r.letterSpacing));for(let[c,l]of tA){let d=typeof r[c]=="string"?String(r[c]).trim():"";d&&n.set(l,d)}break;case"image":e.set("x",String(r.x??0)),e.set("y",String(r.y??0)),e.set("width",String(r.width??100)),e.set("height",String(r.height??100)),i.href&&e.set("href",String(i.href));break}for(let c of Ho(Ki(r),{shapeId:t.id,includeAuthoredAttributes:!0})){if(c.channel==="style"){n.delete(c.name),c.value!==null&&c.value!==""&&n.set(c.name,String(c.value));continue}c.ifAbsent&&e.has(c.name)||(e.delete(c.name),!(c.value===null||c.value===""&&!c.allowEmpty)&&e.set(c.name,String(c.value)))}n.size>0&&e.set("style",[...n].map(([c,l])=>`${c}: ${l}`).join("; "));let o=nA(i);o&&e.set("transform",o);let s=i.startEndpoint,a=i.endEndpoint;return s&&s!=="none"&&e.set("marker-start",`url(#line-marker-${s})`),a&&a!=="none"&&e.set("marker-end",`url(#line-marker-${a})`),e}function cb(t){switch(t.type){case"circle":return"circle";case"ellipse":return"ellipse";case"rectangle":case"square":return"rect";case"line":return"line";case"text":return"text";case"image":return"image";case"path":case"polyline":case"triangle":case"ngon":case"star":case"cross":case"ring":case"spiral":case"gear":case"arrow":return"path";default:return"g"}}function nA(t){return Rt(t)}function lb(t,e){let n=t.viewboxes?.[0];return{width:e.width??n?.width??800,height:e.height??n?.height??600}}var Jr="https://svgsketch.com/ns/metadata",Xi="http://www.w3.org/1999/02/22-rdf-syntax-ns#",Zt="http://purl.org/dc/elements/1.1/",Qr="http://creativecommons.org/ns#",rA="http://www.w3.org/2000/svg",yc={rdf:Xi,rdfs:"http://www.w3.org/2000/01/rdf-schema#",owl:"http://www.w3.org/2002/07/owl#",xsd:"http://www.w3.org/2001/XMLSchema#",dc:Zt,dcterms:"http://purl.org/dc/terms/",cc:Qr,xmp:"http://ns.adobe.com/xap/1.0/",xmpRights:"http://ns.adobe.com/xap/1.0/rights/",xmpMM:"http://ns.adobe.com/xap/1.0/mm/",photoshop:"http://ns.adobe.com/photoshop/1.0/",illustrator:"http://ns.adobe.com/AdobeIllustrator/10.0/",exif:"http://ns.adobe.com/exif/1.0/",tiff:"http://ns.adobe.com/tiff/1.0/",foaf:"http://xmlns.com/foaf/0.1/",schema:"http://schema.org/",og:"https://ogp.me/ns#",inkscape:"http://www.inkscape.org/namespaces/inkscape",sodipodi:"http://sodipodi.sourceforge.net/DTD/sodipodi-0.0.dtd",prism:"http://prismstandard.org/namespaces/basic/3.0/",svgsketch:Jr},Sc=new Set([`${Zt}|creator`,`${Zt}|subject`,`${Zt}|rights`,`${Zt}|description`,`${Qr}|license`]);function mp(t){let e=t.indexOf(":");if(e<=0||e===t.length-1)return null;let n=t.slice(0,e),r=t.slice(e+1);if(!/^[A-Za-z_][\w.-]*$/.test(r))return null;let i=yc[n];return i?{ns:i,local:r,prefix:n}:null}var iA={cc0:"https://creativecommons.org/publicdomain/zero/1.0/","cc-by":"https://creativecommons.org/licenses/by/4.0/","cc-by-sa":"https://creativecommons.org/licenses/by-sa/4.0/","cc-by-nc":"https://creativecommons.org/licenses/by-nc/4.0/","cc-by-nc-sa":"https://creativecommons.org/licenses/by-nc-sa/4.0/","cc-by-nd":"https://creativecommons.org/licenses/by-nd/4.0/","cc-by-nc-nd":"https://creativecommons.org/licenses/by-nc-nd/4.0/",mit:"https://opensource.org/licenses/MIT","apache-2.0":"https://www.apache.org/licenses/LICENSE-2.0"},oA={cc0:"CC0 1.0 Universal (Public Domain)","cc-by":"Creative Commons Attribution 4.0","cc-by-sa":"Creative Commons Attribution-ShareAlike 4.0","cc-by-nc":"Creative Commons Attribution-NonCommercial 4.0","cc-by-nc-sa":"Creative Commons Attribution-NonCommercial-ShareAlike 4.0","cc-by-nd":"Creative Commons Attribution-NoDerivatives 4.0","cc-by-nc-nd":"Creative Commons Attribution-NonCommercial-NoDerivatives 4.0",mit:"MIT License","apache-2.0":"Apache License 2.0",custom:"Custom License"};function db(t,e){return t==="custom"?e||"":iA[t]||""}function ub(t){return oA[t]||t}function pp(t){return!!(t.author||t.keywords&&t.keywords.length>0||t.license||t.customMetadata&&Object.keys(t.customMetadata).length>0)}function gp(t){let e=[];if(t.author&&e.push(`<dc:creator>${fe(t.author)}</dc:creator>`),t.keywords&&t.keywords.length>0&&e.push(`<dc:subject>${fe(t.keywords.join(", "))}</dc:subject>`),t.license){let n=db(t.license,t.licenseUrl);n&&e.push(`<cc:license rdf:resource="${fe(n)}"/>`),e.push(`<dc:rights>${fe(ub(t.license))}</dc:rights>`)}if(t.customMetadata)for(let[n,r]of Object.entries(t.customMetadata)){let i=mp(n);if(i){if(Sc.has(`${i.ns}|${i.local}`))continue;e.push(`<${i.prefix}:${i.local}>${fe(r??"")}</${i.prefix}:${i.local}>`)}else e.push(`<svgsketch:custom key="${fe(n)}" value="${fe(r??"")}"/>`)}return e.join(`
18
+ `)}function pb(t){let e=gp(t);return e.length>0?`<rdf:Description svgsketch:managed="true">
19
+ ${e}
20
+ </rdf:Description>`:`<rdf:Description svgsketch:managed="true">
21
+ </rdf:Description>`}function fp(t){let e={rdf:Xi,dc:Zt,cc:Qr,svgsketch:Jr};if(t.customMetadata)for(let r of Object.keys(t.customMetadata)){let i=mp(r);i&&!(i.prefix in e)&&(e[i.prefix]=i.ns)}return`<metadata>
22
+ <rdf:RDF ${Object.entries(e).map(([r,i])=>`xmlns:${r}="${i}"`).join(" ")}>
23
+ `+pb(t)+`
24
+ </rdf:RDF>
25
+ </metadata>`}var sA=["dc:creator","dc:subject","dc:rights","dc:description","cc:license","svgsketch:custom"];function aA(t){let e=t;for(let n of sA)e=e.replace(new RegExp(`<${n}\\b[^>]*/>\\s*`,"g"),""),e=e.replace(new RegExp(`<${n}\\b[^>]*>[\\s\\S]*?</${n}>\\s*`,"g"),"");return e}function fb(t,e){let n=t.match(/<rdf:Description\b/g);if(!n||n.length!==1||!/<rdf:RDF\b/.test(t))return null;let r=/<rdf:Description\b((?:[^>"']|"[^"]*"|'[^']*')*?)(\/?)>/.exec(t);if(!r)return null;let[i,o,s]=[r[0],r[1],r[2]],a=r.index,c=gp(e),l=`<rdf:Description svgsketch:managed="true"${o}>`,d;if(s==="/")d=t.slice(0,a)+`${l}
26
+ ${c}
27
+ </rdf:Description>`+t.slice(a+i.length);else{let p=t.lastIndexOf("</rdf:Description>");if(p<=a)return null;let f=aA(t.slice(a+i.length,p));d=t.slice(0,a)+l+f+`${c}
28
+ `+t.slice(p)}let u=[["svgsketch",Jr],["dc",Zt],["cc",Qr]];return d=d.replace(/<rdf:RDF\b((?:[^>"']|"[^"]*"|'[^']*')*?)>/,(p,f)=>{let m="";for(let[g,h]of u)d.includes(`xmlns:${g}=`)||(m+=` xmlns:${g}="${h}"`);return m?`<rdf:RDF${f}${m}>`:p}),d}function mb(t){return t.replace(/<!\[CDATA\[([\s\S]*?)\]\]>/g,"$1").replace(/<[^>]*>/g,"").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&apos;/g,"'").replace(/&amp;/g,"&").trim()}function hp(t){return t?.language?` xml:lang="${fe(t.language)}"`:""}function up(t,e,n){let r=n?` xml:lang="${fe(n)}"`:"";return`<${t}${r}>${fe(e)}</${t}>`}function gb(t){let e=t.descriptiveElements;if(!e)return null;let n={title:!1,desc:!1},r=[];for(let i of e){let o=!n[i.kind];if(n[i.kind]=!0,!o){r.push(i.rawXml);continue}let s=i.kind==="title"?t.title:t.description;s&&r.push(s.trim()===i.text.trim()?i.rawXml:up(i.kind,s,i.language))}return!n.title&&t.title&&r.unshift(up("title",t.title,null)),!n.desc&&t.description&&r.push(up("desc",t.description,null)),r.join("")}function Yi(t){if(!t)return"";let e="",n=gb(t);if(n!==null)e+=n;else if(t.title&&(e+=`<title>${fe(t.title)}</title>`),t.description||t.rawDescription){let r=mb(t.rawDescription??""),i=(t.description??"").trim();e+=t.rawDescription&&r===i?`<desc>${t.rawDescription}</desc>`:`<desc>${fe(t.description??"")}</desc>`}return t.rawMetadata&&(e+=t.rawMetadata),e}function yp(t){if(!t)return"";let e="",n=gb(t);if(n!==null)e+=n;else if(t.title&&(e+=`<title>${fe(t.title)}</title>`),t.description||t.rawDescription){let r=mb(t.rawDescription??""),i=(t.description??"").trim();t.rawDescription&&r===i?e+=`<desc>${t.rawDescription}</desc>`:e+=`<desc>${fe(t.description)}</desc>`}if(t.rawMetadata)if(!t.rawMetadataAuthoritative&&pp(t)&&!t.rawMetadata.includes("svgsketch:managed")){let r=fb(t.rawMetadata,t);e+=r??fp(t)+t.rawMetadata}else e+=t.rawMetadata;else pp(t)&&(e+=fp(t));return t.rawHtmlMetadata&&(e+=t.rawHtmlMetadata),e}var Sp="http://www.w3.org/1999/xhtml",vp="http://www.w3.org/XML/1998/namespace",cA="http://www.w3.org/1999/xlink",bp="http://www.w3.org/2000/xmlns/",lA=new Set([Y,vp,cA,Sp,bp]),dA=new Set(["data-shape-id","data-locked","data-hidden","data-cx","data-cy","data-radius","data-corner-radius","data-shift-angle","data-sides","data-arms","data-inner-radius-percent","data-arm-width-percent","data-turns","data-thickness-percent","data-direction","data-teeth","data-tooth-depth-percent","data-hole-radius-percent","data-head-width-percent","data-head-length-percent","data-shaft-width-percent","data-line-style","data-dash-length","data-gap-length","data-start-endpoint","data-end-endpoint","data-original-width","data-original-height","data-preserve-aspect-ratio"]),uA=Object.freeze(Object.fromEntries(Object.entries(yc).map(([t,e])=>[e,t])));function xp(t,e,n){return t.attributes.find(r=>r.localName===e&&r.namespaceUri===n)??null}function Ip(t){let e=xp(t,"lang",vp);return e?e.value:C(t,"lang")}function ei(t){let e="",n=[...t.children].reverse();for(;n.length>0;){let r=n.pop();r.kind==="text"||r.kind==="cdata"?e+=r.value:r.kind==="element"&&n.push(...[...r.children].reverse())}return e}function Sb(t){return t.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;")}function pA(t){return Sb(t).replaceAll('"',"&quot;")}function fA(t){switch(t.kind){case"text":return Sb(t.value);case"comment":return`<!--${t.value}-->`;case"cdata":return`<![CDATA[${t.value.replaceAll("]]>","]]]]><![CDATA[>")}]]>`;case"processing-instruction":return`<?${t.value}?>`;case"doctype":return`<!DOCTYPE ${t.value}>`}}function mA(t){let e=new Set,n=!1,r=[t];for(;r.length>0;){let i=r.pop();i.prefix&&i.prefix!=="xml"?e.add(i.prefix):!i.prefix&&i.namespaceUri&&(n=!0);for(let o of i.attributes)o.prefix&&o.prefix!=="xmlns"&&o.prefix!=="xml"&&e.add(o.prefix);for(let o of i.children)o.kind==="element"&&r.push(o)}return{prefixes:e,defaultNamespace:n}}function gA(t,e){let n=mA(e),r=new Map;for(let o of e.attributes)(o.namespaceUri===bp||o.name==="xmlns")&&r.set(o.name,o);let i=t.index.parent(e.sourceNodeId);for(;i;){for(let o of i.attributes){if(!(o.namespaceUri===bp||o.name==="xmlns")||r.has(o.name))continue;(o.name==="xmlns"&&n.defaultNamespace||o.prefix==="xmlns"&&n.prefixes.has(o.localName))&&r.set(o.name,o)}i=t.index.parent(i.sourceNodeId)}return Object.freeze([...r.values()].filter(o=>!e.attributes.some(s=>s.name===o.name)))}function bb(t,e=[]){let n=[...e,...t.attributes].map(s=>`${s.name}="${pA(s.value)}"`),r=`<${t.name}${n.length>0?` ${n.join(" ")}`:""}`,i=t.children.map(vb).join(""),o=/\/\s*>\s*$/u.test(t.rawXml??"");return i.length===0&&o?`${r}/>`:`${r}>${i}</${t.name}>`}function vb(t){return t.kind==="element"?bb(t):fA(t)}function Wo(t,e){return bb(e,gA(t,e))}function wp(t,e){return t.children.map(n=>n.kind!=="element"||!e?vb(n):Wo(e,n)).join("")}function xb(t,e,n){return e.children.filter(r=>r.kind==="element"&&(r.namespaceUri===Y||t.root.namespaceUri===null&&r.namespaceUri===null)&&r.localName.toLowerCase()===n)}function Ib(t,e){return Object.freeze(e.children.filter(n=>n.kind==="element"&&(n.namespaceUri===Y||t.root.namespaceUri===null&&n.namespaceUri===null)&&(n.localName.toLowerCase()==="title"||n.localName.toLowerCase()==="desc")).map(n=>Object.freeze({kind:n.localName.toLowerCase(),sourceNodeId:n.sourceNodeId,language:Ip(n),text:ei(n).trim(),rawInnerXml:wp(n),rawXml:Wo(t,n)})))}function wb(t){return t.map(({kind:e,language:n,text:r,rawXml:i})=>({kind:e,language:n,text:r,rawXml:i}))}function kb(t){return t.children.some(e=>e.kind==="element")}function hA(t){if(t.classes&&Object.freeze(t.classes),t.aria&&Object.freeze(t.aria),t.customData&&Object.freeze(t.customData),t.foreignAttrs){for(let e of t.foreignAttrs)Object.freeze(e);Object.freeze(t.foreignAttrs)}if(t.descriptiveElements){for(let e of t.descriptiveElements)Object.freeze(e);Object.freeze(t.descriptiveElements)}return Object.freeze(t)}function yA(t,e,n,r,i){let o={};n.length>0&&(o.descriptiveElements=wb(n));let s=C(e,"id");s&&(o.name=s);let a=(C(e,"class")??"").split(/\s+/u).filter(Boolean);a.length>0&&(o.classes=a);let c=n.find(b=>b.kind==="title"),l=n.find(b=>b.kind==="desc");if(c?.text&&(o.title=c.text),l?.text&&(o.description=l.text),l){let b=t.index.element(l.sourceNodeId);b&&kb(b)&&(o.rawDescription=wp(b,t))}let d=C(e,"role");d&&(o.role=d);let u=C(e,"aria-label");u&&(o.ariaLabel=u);let p={},f={};for(let b of e.attributes)b.namespaceUri===null&&(b.name.startsWith("aria-")&&b.name!=="aria-label"&&b.value&&(p[b.name]=b.value),b.name.startsWith("data-")&&!dA.has(b.name)&&(f[b.name.slice(5)]=b.value));Object.keys(p).length>0&&(o.aria=p),Object.keys(f).length>0&&(o.customData=f);let m=Ip(e);m!==null&&(o.lang=m);let g=C(e,"tabindex");if(g!==null){if(/^[+-]?\d+$/u.test(g.trim())){let b=Number(g);Number.isSafeInteger(b)&&(o.tabindex=b)}o.tabindex===void 0&&i.push({severity:"warning",code:"invalid-svg-attribute",source:r.source,entrypoint:r.entrypoint,capability:"metadata",documentPath:t.index.sourcePath(e.sourceNodeId),elementName:e.name,...s?{sourceId:s}:{},sourceNodeId:e.sourceNodeId,message:`Invalid tabindex value "${g}" was ignored.`})}if(yt(e,"autofocus")&&(o.autofocus=!0),!["text","tspan","flowroot"].includes(e.localName.toLowerCase())){let b=xp(e,"space",vp)?.value;(b==="default"||b==="preserve")&&(o.xmlSpace=b)}let h=e.attributes.filter(b=>b.namespaceUri!==null&&!lA.has(b.namespaceUri)).map(b=>({name:b.name,namespaceURI:b.namespaceUri,value:b.value}));h.length>0&&(o.foreignAttrs=h);let y=xb(t,e,"metadata").map(b=>Wo(t,b)).join(`
29
+ `);return y&&(o.rawMetadata=y),hA(o)}function hb(t){let e=[],n=[...t.children].reverse();for(;n.length>0;){let r=n.pop();r.kind==="element"&&(e.push(r),n.push(...[...r.children].reverse()))}return e}function yb(t,e,n){return xp(t,e,n)?.value??null}function SA(t){let e=t.toLowerCase();return e.includes("publicdomain")||e.includes("cc0")?"cc0":e.includes("by-nc-nd")?"cc-by-nc-nd":e.includes("by-nc-sa")?"cc-by-nc-sa":e.includes("by-nc")?"cc-by-nc":e.includes("by-nd")?"cc-by-nd":e.includes("by-sa")?"cc-by-sa":e.includes("/by/")||e.includes("attribution")?"cc-by":e.includes("mit")?"mit":e.includes("apache")?"apache-2.0":"custom"}function bA(t){let e=t.flatMap(p=>hb(p).filter(f=>f.namespaceUri===Xi&&f.localName==="Description")),n=e.find(p=>yb(p,"managed",Jr)==="true")??e[0];if(!n)return{};let r={},i=hb(n),o=i.find(p=>p.namespaceUri===Zt&&p.localName==="creator");o?.children.length&&(r.author=ei(o).trim());let s=i.find(p=>p.namespaceUri===Zt&&p.localName==="subject");if(s){let p=ei(s).split(",").map(f=>f.trim()).filter(Boolean);p.length>0&&(r.keywords=p)}let a=i.find(p=>p.namespaceUri===Qr&&p.localName==="license"),c=i.find(p=>p.namespaceUri===Zt&&p.localName==="rights"),l=a?yb(a,"resource",Xi)??ei(a).trim():c?ei(c).trim():"";l&&(r.license=SA(l),r.license==="custom"&&(r.licenseUrl=l));let d={},u=n.children.filter(p=>p.kind==="element");for(let p of u){if(p.namespaceUri===Jr&&p.localName==="custom"){let h=C(p,"key");h!==null&&(d[h]=C(p,"value")??"");continue}let f=p.namespaceUri??"";if(Sc.has(`${f}|${p.localName}`))continue;let m=uA[f];if(!m)continue;let g=`${m}:${p.localName}`;g in d||(d[g]=ei(p).trim())}if(Object.keys(d).length===0)for(let p of u){if(p.namespaceUri!==Zt||p.localName!=="description")continue;let f=ei(p),m=f.indexOf(":");if(m<=0)continue;let g=f.slice(0,m).trim();g&&(d[g]=f.slice(m+1).trim())}return Object.keys(d).length>0&&(r.customMetadata=d),r}function vA(t){let e=t.root,n=Ib(t,e),r=xb(t,e,"metadata"),i=bA(r);n.length>0&&(i.descriptiveElements=wb(n));let o=Ip(e);o!==null&&(i.language=o);let s=n.find(u=>u.kind==="title"),a=n.find(u=>u.kind==="desc");if(s?.text&&(i.title=s.text),a?.text&&(i.description=a.text),a){let u=t.index.element(a.sourceNodeId);u&&kb(u)&&(i.rawDescription=wp(u,t))}let c=r.map(u=>Wo(t,u)).join(`
30
+ `);c&&(i.rawMetadata=c,i.rawMetadataAuthoritative=!0);let l=Object.freeze(e.children.filter(u=>u.kind==="element"&&u.namespaceUri===Sp&&["base","link","meta"].includes(u.localName.toLowerCase())).map(u=>Object.freeze({sourceNodeId:u.sourceNodeId,localName:u.localName.toLowerCase(),namespaceUri:Sp,rawXml:Wo(t,u)})));l.length>0&&(i.rawHtmlMetadata=l.map(u=>u.rawXml).join(`
31
+ `));let d=[];for(let u=e.children.length-1;u>=0;u--){let p=e.children[u];if(p.kind==="comment"){d.unshift(p.value);continue}if(!(p.kind==="text"&&!p.value.trim()))break}if(d.length>0&&(i.trailingComments=d),i.keywords&&Object.freeze(i.keywords),i.customMetadata&&Object.freeze(i.customMetadata),i.trailingComments&&Object.freeze(i.trailingComments),i.descriptiveElements){for(let u of i.descriptiveElements)Object.freeze(u);Object.freeze(i.descriptiveElements)}return Object.freeze({sourceNodeId:e.sourceNodeId,metadata:Object.freeze(i),descriptiveElements:n,htmlMetadata:l})}function xA(t,e){let n=t.index.parent(e.sourceNodeId);if(!n)return Object.freeze([]);let r=n.children.findIndex(o=>o.kind==="element"&&o.sourceNodeId===e.sourceNodeId);if(r<0)return Object.freeze([]);let i=[];for(let o=r-1;o>=0;o--){let s=n.children[o];if(s.kind==="comment"){i.unshift(s.value);continue}if(!(s.kind==="text"&&s.value.trim().length===0))break}return Object.freeze(i)}function kp(t,e){let n=[],r=[];for(let a of t.index.elements){if(a===t.root||a.namespaceUri!==Y&&!(t.root.namespaceUri===null&&a.namespaceUri===null))continue;let c=Ib(t,a),l=yA(t,a,c,e,n),d=xA(t,a);Object.keys(l).length===0&&c.length===0&&d.length===0||r.push(Object.freeze({sourceNodeId:a.sourceNodeId,metadata:l,descriptiveElements:c,leadingComments:d}))}let i=Object.freeze(r),o=new Map(i.map(a=>[a.sourceNodeId,a]));return{value:Object.freeze({document:vA(t),candidates:i,candidate(a){return o.get(a)??null}}),diagnostics:Object.freeze(n)}}var IA="https://boxy-svg.com",Rp=new Set(["cursive","emoji","fangsong","fantasy","math","monospace","sans-serif","serif","system-ui","ui-monospace","ui-rounded","ui-sans-serif","ui-serif"]);function Pb(t){return/[\t\n\f\r ]/u.test(t??"")}function vc(t,e){if(t[e]!=="/"||t[e+1]!=="*")return e;let n=t.indexOf("*/",e+2);return n<0?t.length:n+2}function wA(t,e){let n=1,r=null,i=!1;for(let o=e+1;o<t.length;o++){let s=t[o];if(r){i?i=!1:s==="\\"?i=!0:s===r&&(r=null);continue}if(s==="/"&&t[o+1]==="*"){o=Math.max(o,vc(t,o)-1);continue}if(s==='"'||s==="'"){r=s;continue}if(s==="{")n++;else if(s==="}"&&--n===0)return o}return t.length-1}function wc(t){let e=[],n=null,r=!1;for(let i=0;i<t.length;i++){let o=t[i];if(n){r?r=!1:o==="\\"?r=!0:o===n&&(n=null);continue}if(o==="/"&&t[i+1]==="*"){i=Math.max(i,vc(t,i)-1);continue}if(o==='"'||o==="'"){n=o;continue}if(o!=="@")continue;let s=i,a=i+1;for(;/[-_a-z0-9]/iu.test(t[a]??"");)a++;let c=t.slice(i+1,a).toLowerCase(),l=a,d=null,u=!1,p=0;for(;l<t.length;l++){let m=t[l];if(d){u?u=!1:m==="\\"?u=!0:m===d&&(d=null);continue}if(m==="/"&&t[l+1]==="*"){l=Math.max(l,vc(t,l)-1);continue}if(m==='"'||m==="'"){d=m;continue}if(m==="(")p++;else if(m===")")p=Math.max(0,p-1);else if(p===0&&(m===";"||m==="{"))break}if(l>=t.length)continue;if(t[l]===";"){e.push(Object.freeze({name:c,start:s,end:l+1,preludeStart:a,preludeEnd:l,blockStart:null,blockEnd:null})),i=l;continue}let f=wA(t,l);e.push(Object.freeze({name:c,start:s,end:Math.min(t.length,f+1),preludeStart:a,preludeEnd:l,blockStart:l+1,blockEnd:f}))}return Object.freeze(e)}function kc(t){let e=t.trim();if(e.length>=2&&(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))){let n=e.slice(1,-1);return Po(n)??n}return Po(e)??e}function Pc(t){let e=Cn(t).find(r=>r.name==="url");if(e)return kc(t.slice(e.argumentsStart,e.argumentsEnd));let n=t.trim();if(n.startsWith('"')||n.startsWith("'")){let r=n[0],i=n.indexOf(r,1);return i>0?n.slice(1,i):null}return null}function Cp(t,e=0){let n=[];for(let r of Cn(t)){if(r.name==="url"){n.push(Object.freeze({rawUrl:kc(t.slice(r.argumentsStart,r.argumentsEnd)),tokenStart:e+r.tokenStart,tokenEnd:e+r.tokenEnd}));continue}n.push(...Cp(t.slice(r.argumentsStart,r.argumentsEnd),e+r.argumentsStart))}return Object.freeze(n)}function kA(t){let e=wc(t),n=e.filter(o=>o.name==="font-face"||o.name==="import"),r=[],i=0;for(let o of e){if(o.name!=="import")continue;let s=Pc(t.slice(o.preludeStart,o.preludeEnd));s!==null&&r.push(Object.freeze({url:s,channel:"css-import",tokenIndex:i})),i++}for(let o of Cp(t))n.some(s=>o.tokenStart>=s.start&&o.tokenEnd<=s.end)||(r.push(Object.freeze({url:o.rawUrl,channel:"css-url",tokenIndex:i})),i++);return Object.freeze(r)}function ti(t){let e=t.trim();if(!e)return Object.freeze({status:"empty",requestUrl:null});if(/^data:/iu.test(e))return Object.freeze({status:"data",requestUrl:null});let n=Tc(e);return Object.freeze(n?{status:"external",requestUrl:n.href}:{status:"blocked",requestUrl:null})}function Rb(t){return ti(t).status==="data"?t:""}var PA=new Set(["feimage","iframe","image","link","mpath","script","textpath","use"]),TA=new Set(["audio","embed","iframe","img","input","script","source","track","video"]);function $p(t){return t.replace(/&/gu,"&amp;").replace(/</gu,"&lt;").replace(/>/gu,"&gt;")}function Cb(t){return $p(t).replace(/"/gu,"&quot;")}function Pp(t){return t.trim().startsWith("#")?t:Rb(t)}function $b(t,e){if(t.kind!=="element"){if(t.kind==="comment")return`<!--${t.value}-->`;if(t.kind==="processing-instruction"||t.kind==="doctype")return"";let a=e==="style"?bc(t.value):t.value;return $p(a)}let n=t.localName.toLowerCase();if(n==="script"||n==="meta"&&t.attributes.some(a=>a.localName.toLowerCase()==="http-equiv"&&a.value.trim().toLowerCase()==="refresh"))return"";let i=[];for(let a of t.attributes){let c=a.name.toLowerCase(),l=a.localName.toLowerCase();if(/^on/iu.test(c))continue;let d=a.value;l==="style"?d=bc(d):(c==="href"||c==="xlink:href")&&PA.has(n)||l==="src"&&TA.has(n)||l==="poster"&&n==="video"||l==="data"&&n==="object"?d=Pp(d):l==="srcset"?d="":a.namespaceUri===null&&!c.startsWith("xmlns")&&(d=bc(d)),i.push(`${a.name}="${Cb(d)}"`)}let o=i.length>0?`<${t.name} ${i.join(" ")}>`:`<${t.name}>`,s=t.children.map(a=>$b(a,n)).join("");return`${o}${s}</${t.name}>`}function RA(t){let e=ln(t,{source:"svg",entrypoint:"svg-document-import"});if(!e.value)return"";let n=$b(e.value.root,null);return t.trimStart().startsWith("<?xml")?`<?xml version="1.0" encoding="UTF-8"?>
32
+ ${n}`:n}var CA=new Set(["animate","animatemotion","animatetransform","desc","metadata","mpath","set","title"]);function $A(t){switch(t.kind){case"text":return $p(t.value);case"comment":return`<!--${t.value}-->`;case"cdata":return`<![CDATA[${t.value.replaceAll("]]>","]]]]><![CDATA[>")}]]>`;case"processing-instruction":return`<?${t.value}?>`;case"doctype":return`<!DOCTYPE ${t.value}>`}}function Nb(t,e,n){let r=t.sourceNodeId===e,i=new Map(t.attributes.map(u=>[u.name,u.value])),o=t.attributes.map(u=>u.name),s=(u,p)=>{if(p===null){i.delete(u);return}i.has(u)||o.push(u),i.set(u,p)};r&&Object.prototype.hasOwnProperty.call(n,"clipPathUnits")&&s("clipPathUnits",n.clipPathUnits??null),n.clipRule!==void 0&&(r||!CA.has(t.localName.toLowerCase()))&&s("clip-rule",n.clipRule);let a=o.filter((u,p)=>o.indexOf(u)===p&&i.has(u)).map(u=>`${u}="${Cb(i.get(u))}"`),c=`<${t.name}${a.length>0?` ${a.join(" ")}`:""}`,l=t.children.map(u=>u.kind==="element"?Nb(u,e,n):$A(u)).join(""),d=/\/\s*>\s*$/u.test(t.rawXml??"");return l.length===0&&d?`${c}/>`:`${c}>${l}</${t.name}>`}function NA(t,e){let n=ln(`<svg xmlns="${Y}">${t}</svg>`,{source:"native-document",entrypoint:"full-snapshot-restore"});if(!n.value)return null;let r=n.value.index.children(n.value.root.sourceNodeId)[0];if(!r)return null;let i=r.localName.toLowerCase();return i!=="clippath"&&i!=="mask"?null:Nb(r,r.sourceNodeId,e)}function Tc(t){let e=/^(https?):\/\/([^/?#\s\\]+)([^\s\\]*)$/iu.exec(t);if(!e)return null;let n=e[1].toLowerCase(),r=e[2],i=r.lastIndexOf("@"),o=i>=0?r.slice(0,i+1):"",s=r.slice(i+1);if(!s)return null;let a=s.startsWith("[")?s.slice(0,Math.max(0,s.indexOf("]")+1)).toLowerCase():s.split(":")[0].toLowerCase();if(!a)return null;let c=e[3]||"/",l=c.indexOf("?"),d=c.indexOf("#",Math.max(0,l)),u=l<0?"":c.slice(l+1,d<0?void 0:d);return Object.freeze({href:`${n}://${o}${s.toLowerCase()}${c}`,hostname:a,query:u})}function Tb(t){try{return decodeURIComponent(t.replace(/\+/gu," "))}catch{return t.replace(/\+/gu," ")}}function Np(t){let e=[],n=0,r=null,i=!1,o=0;for(let s=0;s<t.length;s++){let a=t[s];if(r){i?i=!1:a==="\\"?i=!0:a===r&&(r=null);continue}if(a==="/"&&t[s+1]==="*"){s=Math.max(s,vc(t,s)-1);continue}a==='"'||a==="'"?r=a:a==="("||a==="["?o++:a===")"||a==="]"?o=Math.max(0,o-1):a===","&&o===0&&(e.push(t.slice(n,s).trim()),n=s+1)}return e.push(t.slice(n).trim()),Object.freeze(e.filter(Boolean))}function AA(t){let e=[],n=0;for(;n<t.length;){for(;n<t.length&&(Pb(t[n])||t[n]===",");)n++;if(n>=t.length)break;let r=n;for(;n<t.length&&!Pb(t[n]);)n++;let i=t.slice(r,n);if(i.endsWith(",")){i=i.replace(/,+$/u,""),i&&e.push(i);continue}i&&e.push(i);let o=0;for(;n<t.length;){let s=t[n++];if(s==="(")o++;else if(s===")")o=Math.max(0,o-1);else if(s===","&&o===0)break}}return Object.freeze(e)}function Ap(t){if(typeof t!="string")return null;let e=kc(Np(t)[0]??"").trim();return!e||Rp.has(e.toLowerCase())?null:e}function EA(t){let e=[];for(let n of Hn(t,";")){let r=t.slice(n.start,n.end),i=Hn(r,":",!0)[0]?.end??r.length;if(i>=r.length)continue;let o=r.slice(0,i).trim().toLowerCase(),s=r.slice(i+1).trim();o&&e.push(Object.freeze({property:o,value:s}))}return Object.freeze(e)}function MA(t){let e=Cn(t).find(n=>n.name==="format");return e&&kc(t.slice(e.argumentsStart,e.argumentsEnd))||null}var OA=Object.freeze({"font-style":"style","font-weight":"weight","font-stretch":"stretch","font-display":"display","unicode-range":"unicodeRange","font-feature-settings":"featureSettings","font-variation-settings":"variationSettings","ascent-override":"ascentOverride","descent-override":"descentOverride","line-gap-override":"lineGapOverride","size-adjust":"sizeAdjust"});function DA(t){let e={};for(let n of t){let r=OA[n.property];r&&n.value&&(e[r]=n.value)}return Object.keys(e).length>0?Object.freeze(e):void 0}function Ep(t){let e=[];for(let n of wc(t)){if(n.name!=="font-face"||n.blockStart===null||n.blockEnd===null)continue;let r=EA(t.slice(n.blockStart,n.blockEnd)),i=Ap(r.find(a=>a.property==="font-family")?.value),o=r.find(a=>a.property==="src")?.value;if(!i||!o)continue;let s=DA(r);for(let a of Np(o)){let c=Pc(a);if(c===null)continue;let l=ti(c);l.status!=="external"||!l.requestUrl||e.push(Object.freeze({family:i,url:l.requestUrl,format:MA(a),...s?{descriptors:s}:{}}))}}return Object.freeze(e)}function Ab(t){let e=[];for(let n of wc(t)){if(n.name!=="import")continue;let r=Pc(t.slice(n.preludeStart,n.preludeEnd));if(r===null)continue;let i=ti(r);if(i.status!=="external"||!i.requestUrl)continue;let o=Tc(i.requestUrl);if(!o||o.hostname!=="fonts.googleapis.com")continue;let s=o.query.split("&").map(a=>a.split("=",2)).filter(([a])=>Tb(a).toLowerCase()==="family").map(([,a])=>Tb(a??""));for(let a of s)for(let c of a.split("|")){let l=c.split(":")[0].trim();l&&!Rp.has(l.toLowerCase())&&e.push(l)}}return Object.freeze(e)}function zA(t){return Hn(t,";").map(e=>{let n=t.slice(e.start,e.end),r=Hn(n,":",!0)[0]?.end??n.length;if(r>=n.length||n.slice(0,r).trim().toLowerCase()!=="src")return n;let o=n.slice(0,r+1),s=Np(n.slice(r+1)).filter(a=>{let c=Pc(a);return c===null||ti(c).status==="data"});return`${o} ${s.length>0?s.join(", "):'local("__svgsketch_quarantined_font__")'}`}).join(";")}function bc(t){let e=[];for(let i of wc(t)){if(i.name==="import"){e.push({start:i.start,end:i.end,value:"/* external stylesheet import quarantined */"});continue}i.name!=="font-face"||i.blockStart===null||i.blockEnd===null||e.push({start:i.blockStart,end:i.blockEnd,value:zA(t.slice(i.blockStart,i.blockEnd))})}let n=t;for(let i of e.sort((o,s)=>s.start-o.start))n=`${n.slice(0,i.start)}${i.value}${n.slice(i.end)}`;let r=Cp(n).filter(i=>{let o=i.rawUrl.trim();return!o||o.startsWith("#")?!1:ti(o).status!=="data"}).sort((i,o)=>o.tokenStart-i.tokenStart);for(let i of r)n=`${n.slice(0,i.tokenStart)}url("data:application/octet-stream;base64,")${n.slice(i.tokenEnd)}`;return n}function _A(t,e,n){let r=[];for(let i of e.stylesheets)if(i.applicable){for(let o of Ab(i.authoredText))r.push(Object.freeze({sourceNodeId:i.sourceNodeId,occurrenceId:null,origin:"google-font-import",family:o}));for(let o of Ep(i.authoredText))r.push(Object.freeze({sourceNodeId:i.sourceNodeId,occurrenceId:null,origin:"external-font-face",family:o.family,url:o.url,format:o.format,...o.descriptors?{descriptors:o.descriptors}:{}}))}for(let i of t.index.elements)for(let o of i.attributes)if(!(o.namespaceUri!==IA||o.localName!=="fonts"))for(let s of o.value.split(",")){let a=s.replace(/\+/gu," ").trim();!a||a.includes("/")||Rp.has(a.toLowerCase())||r.push(Object.freeze({sourceNodeId:i.sourceNodeId,occurrenceId:null,origin:"boxy-fonts",family:a}))}for(let i of n.candidates){if(i.canonicalType!=="text"||i.status!=="materialized")continue;let o=a=>{let c=Ap(a);c&&r.push(Object.freeze({sourceNodeId:i.sourceNodeId,occurrenceId:i.occurrenceId,origin:"text-font-family",family:c}))};o(i.state.fontFamily);let s=bi(i.state);if(s){o(s.baseStyle.fontFamily);for(let a of s.runs)o(a.style.fontFamily)}}return Object.freeze(r)}function Jt(t,e){return t.attributes.find(n=>n.namespaceUri===null&&n.localName.toLowerCase()===e.toLowerCase())?.value??null}function xc(t){return t.children.map(e=>e.kind==="text"||e.kind==="cdata"?e.value:"").join("")}function Rc(t,e){let n=[],r=[...t.index.children(e)].reverse();for(;r.length>0;){let i=r.pop();n.push(i),r.push(...[...t.index.children(i.sourceNodeId)].reverse())}return Object.freeze(n)}function vn(t,e){let n=ti(e.href);t.push(Object.freeze({...e,...n}))}function qi(t,e,n,r=new Set(["css-import","css-url"]),i=()=>!0){for(let o of kA(e))!r.has(o.channel)||!i(o)||o.url.trim().startsWith("#")||vn(t,{...n,occurrenceId:`${n.occurrenceId}:css:${o.tokenIndex}`,channel:o.channel,href:o.url,hrefNamespace:null})}function Mp(t,e,n,r){for(let i of Rc(e,n.sourceNodeId)){let o=i.localName.toLowerCase(),s=Jt(i,"id"),a={sourceNodeId:i.sourceNodeId,occurrenceId:`${r}:foreign:${i.sourceNodeId}`,sourceId:s,elementName:i.localName},c=[{attributeName:"src",channel:"html-src",applies:["img","video","audio","source","track","iframe","embed"].includes(o)||o==="input"&&Jt(i,"type")?.toLowerCase()==="image"},{attributeName:"poster",channel:"html-poster",applies:o==="video"},{attributeName:"data",channel:"html-data",applies:o==="object"},{attributeName:"href",channel:"html-src",applies:o==="link"&&(Jt(i,"rel")??"").split(/\s+/u).some(u=>u.toLowerCase()==="stylesheet")}];for(let u of c){if(!u.applies)continue;let p=Jt(i,u.attributeName);p!==null&&vn(t,{...a,occurrenceId:`${a.occurrenceId}:${u.attributeName}`,attributeName:u.attributeName,channel:u.channel,href:p,hrefNamespace:null})}let l=Jt(i,"srcset");if(l!==null&&(o==="img"||o==="source"))for(let[u,p]of AA(l).entries())vn(t,{...a,occurrenceId:`${a.occurrenceId}:srcset:${u}`,attributeName:"srcset",channel:"html-srcset",href:p,hrefNamespace:null});let d=Jt(i,"style");d!==null&&qi(t,d,{...a,attributeName:"style"}),o==="style"&&qi(t,xc(i),{...a,attributeName:"textContent"})}}function FA(t,e,n,r){let i=Jt(n,"data-shape-type")?.toLowerCase();if(i==="video"||i==="audio"){let o=Rc(e,n.sourceNodeId).find(s=>s.localName.toLowerCase()===i);if(o){let s=Jt(o,"src")??"";if(vn(t,{sourceNodeId:o.sourceNodeId,occurrenceId:`${r}:media:src`,sourceId:Jt(o,"id"),elementName:i,attributeName:"src",channel:"html-src",href:s,hrefNamespace:null}),i==="video"){let a=Jt(n,"data-poster")??Jt(o,"poster");a!==null&&vn(t,{sourceNodeId:n.sourceNodeId,occurrenceId:`${r}:media:poster`,sourceId:Jt(n,"id"),elementName:"video",attributeName:"poster",channel:"html-poster",href:a,hrefNamespace:null})}}return}Mp(t,e,n,r)}function LA(t,e,n){let r=[];for(let i of e.occurrences){let o=t.index.element(i.correspondingSourceNodeId);if(!o||o.namespaceUri!==Y)continue;let s=o.localName.toLowerCase();if(s==="image"||s==="feimage"){let a=Be(o)??{value:"",namespace:"svg2"};vn(r,{sourceNodeId:o.sourceNodeId,occurrenceId:i.occurrenceId,sourceId:C(o,"id"),elementName:s==="feimage"?"feImage":"image",attributeName:"href",channel:"svg-href",href:a.value,hrefNamespace:a.namespace})}else s==="foreignobject"&&FA(r,t,o,i.occurrenceId)}for(let i of n.stylesheets)i.applicable&&qi(r,i.authoredText,{sourceNodeId:i.sourceNodeId,occurrenceId:`style:${i.sourceNodeId}`,sourceId:i.id,elementName:"style",attributeName:"textContent"},new Set(["css-import"]),o=>Tc(o.url)?.hostname!=="fonts.googleapis.com");for(let i of n.elements){let o=t.index.element(i.correspondingSourceNodeId);if(!(!o||o.namespaceUri!==Y))for(let s of Object.values(i.cascadedValues))qi(r,s.value,{sourceNodeId:s.sourceNodeId,occurrenceId:`style:${i.occurrenceId}:${s.propertyName}`,sourceId:null,elementName:"style-declaration",attributeName:s.propertyName})}return Object.freeze(r)}function Eb(t,e,n){let r=[...new Set(t.filter(d=>d.origin==="google-font-import"||d.origin==="boxy-fonts").map(d=>d.family))].sort(),i=[],o=new Set;for(let d of t){if(d.origin!=="external-font-face"||!d.url)continue;let u=`${d.family}\0${d.url}\0${d.format??""}\0${JSON.stringify(d.descriptors??{})}`;o.has(u)||(o.add(u),i.push(Object.freeze({family:d.family,url:d.url,format:d.format??null,...d.descriptors?{descriptors:d.descriptors}:{}})))}i.sort((d,u)=>d.family.localeCompare(u.family)||d.url.localeCompare(u.url)||(d.format??"").localeCompare(u.format??""));let s=[...new Set([...r,...i.map(d=>d.family)])].sort(),a=[...new Set(e.filter(d=>d.status==="external"&&d.requestUrl).map(d=>d.requestUrl))].sort(),c=[];s.length>0&&c.push(Object.freeze({kind:"font-consent",families:s,googleFamilies:r,...i.length>0?{externalSources:i}:{}})),a.length>0&&c.push(Object.freeze({kind:"external-asset-resolution",urls:a})),Object.freeze(s),Object.freeze(r),Object.freeze(i),Object.freeze(a),Object.freeze(c);let l=Object.freeze({fontCandidates:t,assetCandidates:e,effects:c});return Object.freeze({value:l,diagnostics:n})}function Op(t,e,n,r,i){return Eb(_A(t,n,r),LA(t,e,n),Object.freeze([]))}function BA(t){let e=t.state,n=e.extra;return typeof n=="object"&&n!==null&&!Array.isArray(n)?{...n,...e}:e}function Dp(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function zp(t,e,n){for(let r of Ab(e))t.push(Object.freeze({sourceNodeId:n,occurrenceId:null,origin:"google-font-import",family:r}));for(let r of Ep(e))t.push(Object.freeze({sourceNodeId:n,occurrenceId:null,origin:"external-font-face",family:r.family,url:r.url,format:r.format,...r.descriptors?{descriptors:r.descriptors}:{}}))}function Mb(t,e,n,r){zp(t,n,r),qi(e,n,{sourceNodeId:r,occurrenceId:r,sourceId:null,elementName:"style",attributeName:"textContent"},void 0,o=>Tc(o.url)?.hostname!=="fonts.googleapis.com");let i=new Set(Ep(n).map(o=>o.url));for(let o=e.length-1;o>=0;o--){let s=e[o];s.sourceNodeId===r&&i.has(s.requestUrl??"")&&e.splice(o,1)}}function Ob(t,e,n,r,i,o){let s=ln(`<svg xmlns="${Y}"><foreignObject>${n}</foreignObject></svg>`,i);if(!s.value){o.push(...s.diagnostics.map(c=>Object.freeze({...c,severity:"warning",message:`Canonical foreign content could not be inspected for external requests: ${c.message}`,documentPath:r})));return}let a=s.value.index.children(s.value.root.sourceNodeId).find(c=>c.localName.toLowerCase()==="foreignobject");if(a){Mp(e,s.value,a,r);for(let c of Rc(s.value,a.sourceNodeId))c.localName.toLowerCase()==="style"&&zp(t,xc(c),`${r}:${c.sourceNodeId}`)}}function _p(t,e,n,r){qi(t,e,{sourceNodeId:n,occurrenceId:`${n}:${r}`,sourceId:null,elementName:"canonical-state",attributeName:r})}function Ko(t,e,n){if(Dp(e))for(let[r,i]of Object.entries(e))typeof i=="string"&&_p(t,i,n,r)}function Fp(t,e,n,r,i,o){if(Array.isArray(n))for(let[s,a]of n.entries()){if(!Dp(a))continue;let c=`${r}:filter:${s}`;a.type==="feImage"&&vn(e,{sourceNodeId:r,occurrenceId:c,sourceId:null,elementName:"feImage",attributeName:"href",channel:"canonical-state",href:typeof a.href=="string"?a.href:typeof a.xlinkHref=="string"?a.xlinkHref:"",hrefNamespace:typeof a.href=="string"?"svg2":"xlink"}),a.type==="raw-svg"&&typeof a.svgContent=="string"&&Ic(t,e,a.svgContent,`${c}:raw`,i,o),Fp(t,e,a.primitives,`${c}:primitives`,i,o)}}function Tp(t,e,n,r,i,o){!Dp(n)||typeof n.svgContent!="string"||Ic(t,e,n.svgContent,r,i,o)}function GA(t,e,n,r,i,o){let s=BA(n),a=`snapshot:${r}:${n.id}`;if(n.type==="text"){let c=d=>{let u=Ap(d);u&&t.push(Object.freeze({sourceNodeId:a,occurrenceId:a,origin:"text-font-family",family:u}))};c(s.fontFamily);let l=bi(s);if(l){c(l.baseStyle.fontFamily);for(let d of l.runs)c(d.style.fontFamily)}}n.type==="image"?vn(e,{sourceNodeId:a,occurrenceId:a,sourceId:n.id,elementName:"image",attributeName:"href",channel:"canonical-state",href:typeof s.href=="string"?s.href:"",hrefNamespace:null}):n.type==="video"||n.type==="audio"?(vn(e,{sourceNodeId:a,occurrenceId:`${a}:src`,sourceId:n.id,elementName:n.type,attributeName:"href",channel:"canonical-state",href:typeof s.href=="string"?s.href:"",hrefNamespace:null}),n.type==="video"&&typeof s.posterHref=="string"&&vn(e,{sourceNodeId:a,occurrenceId:`${a}:poster`,sourceId:n.id,elementName:"video",attributeName:"posterHref",channel:"canonical-state",href:s.posterHref,hrefNamespace:null})):n.type==="foreign-object"&&typeof s.rawContent=="string"&&Ob(t,e,s.rawContent,a,i,o),Tp(t,e,s.fillGradient,`${a}:fillGradient`,i,o),Tp(t,e,s.strokeGradient,`${a}:strokeGradient`,i,o),Fp(t,e,s.filters,a,i,o),Ko(e,s.authoredAttributes,`${a}:authored`),Ko(e,s.containerPresentation,`${a}:container-presentation`),Ko(e,s.instancePresentation,`${a}:instance-presentation`),Ko(e,s.cssMaskProperties,`${a}:mask`),typeof s.cssClipPath=="string"&&_p(e,s.cssClipPath,a,"clip-path")}function Ic(t,e,n,r,i,o){let s=ln(`<svg xmlns="${Y}">${n}</svg>`,i);if(!s.value){o.push(...s.diagnostics.map(c=>Object.freeze({...c,severity:"warning",message:`Canonical raw definition could not be inspected for external requests: ${c.message}`,documentPath:r})));return}let a=new Set;for(let c of s.value.index.elements){if(c.localName.toLowerCase()!=="foreignobject")continue;let l=`${r}:${c.sourceNodeId}`;Mp(e,s.value,c,l);for(let d of Rc(s.value,c.sourceNodeId))a.add(d.sourceNodeId),d.localName.toLowerCase()==="style"&&zp(t,xc(d),`${r}:${d.sourceNodeId}`)}for(let c of s.value.index.elements){if(a.has(c.sourceNodeId))continue;let l=c.localName.toLowerCase();if(c.namespaceUri===Y&&(l==="image"||l==="feimage")){let d=Be(c)??{value:"",namespace:"svg2"};vn(e,{sourceNodeId:`${r}:${c.sourceNodeId}`,occurrenceId:`${r}:${c.sourceNodeId}`,sourceId:Jt(c,"id"),elementName:l==="feimage"?"feImage":"image",attributeName:"href",channel:"canonical-state",href:d.value,hrefNamespace:d.namespace})}l==="style"&&Mb(t,e,xc(c),`${r}:${c.sourceNodeId}:style`);for(let d of c.attributes)d.localName.toLowerCase()==="href"||d.localName.toLowerCase()==="src"||_p(e,d.value,`${r}:${c.sourceNodeId}`,d.name)}}function VA(t,e){let n=[],r=[],i=[];for(let[s,a]of(t.documentStyles??[]).entries())Mb(n,r,a.css,`snapshot:documentStyles[${s}]`);rt(t,{onShape:(s,a)=>GA(n,r,s,a,e,i)});for(let[s,a]of(t.library??[]).entries()){let c=`snapshot:library[${s}]`;a.kind==="pattern"?Tp(n,r,a.pattern,`${c}:pattern`,e,i):a.kind==="filter"?Fp(n,r,a.filters,`${c}:filters`,e,i):(a.kind==="symbol"||a.kind==="marker")&&Ko(r,a.rootAttributes,`${c}:root`)}let o=t.documentMetadata?.rawHtmlMetadata;typeof o=="string"&&Ob(n,r,o,"snapshot:documentMetadata.rawHtmlMetadata",e,i);for(let[s,a]of(t.paintServerDefs??[]).entries())Ic(n,r,a.markup,`snapshot:paintServerDefs[${s}]`,e,i);for(let[s,a]of(t.clipMaskGroups??[]).entries())a.rawDefinition&&Ic(n,r,a.rawDefinition,`snapshot:clipMaskGroups[${s}].rawDefinition`,e,i);return Eb(Object.freeze(n),Object.freeze(r),Object.freeze(i))}function jA(t,e,n){let r=new Set,i=o=>{let s=o;for(;s;){let a=s.localName.toLowerCase();if(a==="clippath"||a==="mask")return!0;s=t.index.parent(s.sourceNodeId)}return!1};for(let o of n.css){let s=e.occurrence(o.occurrenceId);if(!s)continue;let a=t.index.element(s.correspondingSourceNodeId);a&&i(a)&&r.add(a.sourceNodeId)}return t.index.elements.filter(o=>r.has(o.sourceNodeId)).map(o=>o.sourceNodeId)}var Db=Object.freeze({matchesMedia(t){let e=t.trim().toLowerCase();return e===""||e==="all"||e==="screen"},supportsCondition(){return!1}}),UA=new Map([["clippath","clip-path"],["marker","marker"],["mask","mask"],["pattern","pattern"]]);function HA(t){return Object.freeze(t.index.elements.flatMap(e=>{let n=UA.get(e.localName.toLowerCase());return n?[Object.freeze({sourceNodeId:e.sourceNodeId,capability:n})]:[]}))}function WA(t,e,n){let r=new Map(t.occurrences.map(i=>[i.occurrenceId,i]));return Object.freeze([...e.candidates.filter(i=>i.status==="materialized").map(i=>i.occurrenceId),...n.uses.filter(i=>["symbol-instance","linked-reference"].includes(i.status)).map(i=>i.useOccurrenceId)].filter(i=>r.get(i)?.role!=="definition"))}function Cc(t,e={}){let n={source:e.source??"svg",entrypoint:e.entrypoint??"svg-document-import"},r=ln(t,n,e.xmlHost);if(!r.value)return Object.freeze({value:null,diagnostics:r.diagnostics});let i=r.value,o=Qd(i.root,n),s=Object.freeze({width:o.value.viewBoxWidth??300,height:o.value.viewBoxHeight??150}),a=e.rootFontSize??16,c=Object.freeze({viewport:Object.freeze({x:o.value.viewBoxX??0,y:o.value.viewBoxY??0,...s}),rootFontSize:a}),l=su(i,n),d=l.value.condition(i.root.sourceNodeId),u=Object.freeze({...o.value,...d?.systemLanguage!==null&&d?.systemLanguage!==void 0?{systemLanguage:d.systemLanguage}:{},...d?.requiredExtensions!==null&&d?.requiredExtensions!==void 0?{requiredExtensions:d.requiredExtensions}:{}}),p=Qu(i,n),f=kp(i,n),m=du(i,{...n,resourceRoots:HA(i),...e.maxUseDepth!==void 0?{maxDepth:e.maxUseDepth}:{},...e.maxUseOccurrences!==void 0?{maxOccurrences:e.maxUseOccurrences}:{}}),g=Pu(i,m,{...n,environment:e.styleEnvironment??Db}),h=Mu(i,m,g.value,{...n,viewport:s,rootFontSize:a,...e.textMetricsHost?{textMetricsHost:e.textMetricsHost}:{}}),y=Ru(i,m,g.value,{...n,leafGeometry:h.value}),b=cu(i,{...e.claimedIds?{claimedIds:e.claimedIds}:{},cssAnimationTargetSourceNodeIds:jA(i,m,y.value)}),v=fu(i,m,g.value,n),I=hu(i,{...n,appliedDeclarations:g.value.appliedResourceDeclarations}),x=ju(i,m,g.value,I,h.value,{...n,viewport:s,rootFontSize:a}),k=Ju(i,m,g.value,I,{...n,viewport:s,rootFontSize:a}),T=Uu(i,m,g.value,I,{...n,viewport:s,rootFontSize:a}),w=Wu(i,m,g.value,I,{...n,viewport:s,rootFontSize:a}),P=Ku(i,m,g.value,I,{...n,viewport:s,rootFontSize:a}),N=qu(i,b,n),R=eu(i,n),$=tu(i,n),A=yu(i),O=Op(i,m,g.value,h.value,n),G=ru(i,m,{...n,materializedOccurrenceIds:WA(m,h.value,v)}),M=[...r.diagnostics,...o.diagnostics,...l.diagnostics,...p.diagnostics,...f.diagnostics,...m.diagnostics,...g.diagnostics,...y.diagnostics,...v.diagnostics,...h.diagnostics,...I.diagnostics,...x.diagnostics,...k.diagnostics,...T.diagnostics,...w.diagnostics,...P.diagnostics,...N.diagnostics,...R.diagnostics,...$.diagnostics,...O.diagnostics,...G.diagnostics],V=Object.freeze({projectionContext:c,sourceDocument:i,rootFrame:u,identifiers:b,conditionalProcessing:l.value,scripts:p.value,metadata:f.value,useOccurrences:m,styles:g.value,animations:y.value,symbolUses:v,leafGeometry:h.value,resourceDependencies:I,clipMasks:x.value,filters:k.value,markers:T.value,gradients:w.value,patterns:P.value,paintServerDefinitions:N.value,views:R.value,embeddedFrames:$.value,authoredAttributes:A,externalEffects:O.value,hierarchy:G.value});return Object.freeze({value:V,diagnostics:Object.freeze(M)})}function J(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`id-${crypto.randomUUID()}`:`id-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}function Xo(t={}){let e={schemaVersion:Lt,shapes:t.shapes?t.shapes.map(n=>({...n})):[],viewboxes:t.viewboxes?t.viewboxes.map(n=>({...n})):[]};return t.metadata&&(e.documentMetadata={title:"",description:"",author:"",keywords:[],license:"",licenseUrl:"",language:"en",customMetadata:{},...t.metadata}),e}function KA(t){let{type:e,id:n,...r}=t,i={};for(let[o,s]of Object.entries(r))s!==void 0&&(i[o]=s);return{id:n??J(),type:e,state:i}}function Zi(t,e,n,r,i){return{id:i??J(),x:t,y:e,width:n,height:r}}var XA;function YA(){return XA??=new Set([...pe.typeIds().filter(t=>t!=="document"),"spline"])}function ni(t){let e=[],n=[];if(t==null||typeof t!="object")return e.push({path:"",message:"Snapshot must be a non-null object",severity:"error"}),{valid:!1,errors:e,warnings:n};let r=t;for(let o of Object.keys(r))o in $t||n.push({path:o,message:`Unknown top-level field "${o}" (likely written by a newer version); it is preserved in the unknownFields quarantine on save`,severity:"warning"});let i={doc:r,errors:e,warnings:n};for(let o of Object.keys($t)){let s=r[o];s===void 0&&!$t[o].required||tE[o](s,i)}return{valid:e.length===0,errors:e,warnings:n}}function Ee(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function un(t,e,n){return Array.isArray(t)?!0:(n.push({path:e,message:`${e} must be an array`,severity:"error"}),!1)}var qA=new Set(["x1","y1","x2","y2","gradientTransform"]),ZA=new Set(["cx","cy","fx","fy","r","fr","gradientTransform"]),JA=new Set(["x","y","width","height"]);function Dn(t,e,n){t.push({path:e,message:n,severity:"error"})}function QA(t,e,n,r){if(!Ee(t)){Dn(r,e,"Gradient must be a plain object");return}let i=n==="linear-gradient"?["x1","y1","x2","y2","opacity"]:["cx","cy","fx","fy","r","ry","rotation","opacity"];for(let o of i)t[o]!==void 0&&(typeof t[o]!="number"||!Number.isFinite(t[o]))&&Dn(r,`${e}.${o}`,`${o} must be a finite number`);if(t.fr!==void 0&&(typeof t.fr!="number"||!Number.isFinite(t.fr))&&Dn(r,`${e}.fr`,"fr must be a finite number"),t.authoredGeometry!==void 0)if(!Ee(t.authoredGeometry))Dn(r,`${e}.authoredGeometry`,"Gradient authoredGeometry must be a plain object");else{let o=n==="linear-gradient"?qA:ZA;for(let[s,a]of Object.entries(t.authoredGeometry))o.has(s)?typeof a!="string"&&Dn(r,`${e}.authoredGeometry.${s}`,"Authored gradient geometry declarations must be strings"):Dn(r,`${e}.authoredGeometry.${s}`,"is not a supported authored gradient geometry field")}t.gradientTransform!==void 0&&(!Array.isArray(t.gradientTransform)||t.gradientTransform.length!==6||!t.gradientTransform.every(o=>typeof o=="number"&&Number.isFinite(o)))&&Dn(r,`${e}.gradientTransform`,"gradientTransform must be a 6-element finite affine matrix"),Array.isArray(t.stops)?t.stops.forEach((o,s)=>{if(!Ee(o)){Dn(r,`${e}.stops[${s}]`,"Gradient stop must be an object");return}for(let a of["offset","opacity"])o[a]!==void 0&&(typeof o[a]!="number"||!Number.isFinite(o[a]))&&Dn(r,`${e}.stops[${s}].${a}`,`${a} must be a finite number`)}):Dn(r,`${e}.stops`,"Gradient stops must be an array")}function eE(t,e,n){if(!Ee(t)){n.push({path:e,message:"Pattern must be a plain object",severity:"error"});return}for(let r of["x","y","width","height","scale","rotation","opacity"])t[r]!==void 0&&(typeof t[r]!="number"||!Number.isFinite(t[r]))&&n.push({path:`${e}.${r}`,message:`${r} must be a finite number`,severity:"error"});t.patternUnits!==void 0&&t.patternUnits!=="userSpaceOnUse"&&t.patternUnits!=="objectBoundingBox"&&n.push({path:`${e}.patternUnits`,message:"patternUnits must be userSpaceOnUse or objectBoundingBox",severity:"error"}),t.patternContentUnits!==void 0&&t.patternContentUnits!=="userSpaceOnUse"&&t.patternContentUnits!=="objectBoundingBox"&&n.push({path:`${e}.patternContentUnits`,message:"patternContentUnits must be userSpaceOnUse or objectBoundingBox",severity:"error"});for(let r of["svgContent","patternTransform","viewBox","preserveAspectRatio"])t[r]!==void 0&&typeof t[r]!="string"&&n.push({path:`${e}.${r}`,message:`${r} must be a string`,severity:"error"});if(t.authoredGeometry!==void 0)if(!Ee(t.authoredGeometry))n.push({path:`${e}.authoredGeometry`,message:"Pattern authoredGeometry must be a plain object",severity:"error"});else for(let[r,i]of Object.entries(t.authoredGeometry))JA.has(r)?typeof i!="string"&&n.push({path:`${e}.authoredGeometry.${r}`,message:"Authored pattern geometry declarations must be strings",severity:"error"}):n.push({path:`${e}.authoredGeometry.${r}`,message:"is not a supported authored pattern geometry field",severity:"error"})}var tE={schemaVersion:(t,{errors:e,warnings:n})=>{typeof t!="number"||!Number.isInteger(t)?e.push({path:"schemaVersion",message:"schemaVersion must be an integer",severity:"error"}):t>Lt&&n.push({path:"schemaVersion",message:`schemaVersion ${t} is newer than supported (${Lt})`,severity:"warning"})},shapes:(t,{errors:e,warnings:n})=>{if(!un(t,"shapes",e))return;let r=new Set;t.forEach((i,o)=>{Lp(i,`shapes[${o}]`,e,n,r)})},viewboxes:(t,{errors:e})=>{if(!un(t,"viewboxes",e))return;let n=new Set;t.forEach((r,i)=>{lE(r,`viewboxes[${i}]`,e,n)})},guides:(t,{errors:e})=>{un(t,"guides",e)&&t.forEach((n,r)=>{dE(n,`guides[${r}]`,e)})},measurements:(t,{errors:e})=>{un(t,"measurements",e)&&t.forEach((n,r)=>{let i=`measurements[${r}]`;if(!Ee(n)){e.push({path:i,message:"Measurement must be a non-null object",severity:"error"});return}(typeof n.id!="string"||n.id.length===0)&&e.push({path:`${i}.id`,message:"Measurement id must be a non-empty string",severity:"error"})})},sceneTree:(t,{doc:e,errors:n,warnings:r})=>{if(!un(t,"sceneTree",n))return;let i=nE(e.shapes),o=new Set;t.forEach((s,a)=>{rE(s,`sceneTree[${a}]`,n,r,i,o)})},clipMaskGroups:(t,{errors:e,warnings:n})=>{un(t,"clipMaskGroups",e)&&t.forEach((r,i)=>{uE(r,`clipMaskGroups[${i}]`,e,n)})},documentMetadata:(t,{errors:e})=>{Ee(t)||e.push({path:"documentMetadata",message:"documentMetadata must be a plain object",severity:"error"})},documentScripts:(t,{errors:e})=>{un(t,"documentScripts",e)&&t.forEach((n,r)=>{let i=`documentScripts[${r}]`;if(!Ee(n)){e.push({path:i,message:"Document script must be a non-null object",severity:"error"});return}(typeof n.id!="string"||n.id.length===0)&&e.push({path:`${i}.id`,message:"Document script id must be a non-empty string",severity:"error"})})},documentStyles:(t,{errors:e})=>{un(t,"documentStyles",e)&&t.forEach((n,r)=>{let i=`documentStyles[${r}]`;if(!Ee(n)){e.push({path:i,message:"Document style must be a non-null object",severity:"error"});return}(typeof n.id!="string"||n.id.length===0)&&e.push({path:`${i}.id`,message:"Document style id must be a non-empty string",severity:"error"}),typeof n.css!="string"&&e.push({path:`${i}.css`,message:"Document style css must be a string",severity:"error"})})},templateVariables:(t,{errors:e})=>{un(t,"templateVariables",e)&&t.forEach((n,r)=>{let i=`templateVariables[${r}]`;if(!Ee(n)){e.push({path:i,message:"Template variable must be a non-null object",severity:"error"});return}(typeof n.name!="string"||n.name.length===0)&&e.push({path:`${i}.name`,message:"Template variable name must be a non-empty string",severity:"error"})})},animationTimeline:(t,{doc:e,errors:n})=>{if(!Ee(t)){n.push({path:"animationTimeline",message:"animationTimeline must be a plain object",severity:"error"});return}if(t.tracks!==void 0&&!Array.isArray(t.tracks)){n.push({path:"animationTimeline.tracks",message:"animationTimeline.tracks must be an array",severity:"error"});return}Array.isArray(t.tracks)&&Number(e.schemaVersion)>=11&&t.tracks.forEach((r,i)=>{if(!Ee(r)||!Array.isArray(r.keyframes))return;let o=new Set;r.keyframes.forEach((s,a)=>{let c=`animationTimeline.tracks[${i}].keyframes[${a}].id`;if(!Ee(s)||typeof s.id!="string"||!s.id){n.push({path:c,message:"Animation keyframe id must be a non-empty string",severity:"error"});return}if(o.has(s.id)){n.push({path:c,message:`Duplicate animation keyframe id: "${s.id}"`,severity:"error"});return}o.add(s.id)})})},library:(t,{doc:e,errors:n,warnings:r})=>{if(!un(t,"library",n))return;let i=new Set;t.forEach((o,s)=>{let a=`library[${s}]`;if(!Ee(o)){n.push({path:a,message:"Library def must be a non-null object",severity:"error"});return}if(typeof o.id!="string"||o.id.length===0?n.push({path:`${a}.id`,message:"Library def id must be a non-empty string",severity:"error"}):i.has(o.id)?n.push({path:`${a}.id`,message:`Duplicate library def id: "${o.id}"`,severity:"error"}):i.add(o.id),(typeof o.kind!="string"||o.kind.length===0)&&n.push({path:`${a}.kind`,message:"Library def kind must be a non-empty string",severity:"error"}),o.kind==="symbol"||o.kind==="marker"){if(o.kind==="symbol"){let c=typeof e.schemaVersion=="number"&&e.schemaVersion>=8;if(o.defKind!==void 0&&!["symbol","group","shape"].includes(String(o.defKind))&&n.push({path:`${a}.defKind`,message:"Symbol defKind must be symbol, group, or shape",severity:"error"}),o.defKind==="shape"&&(!Array.isArray(o.shapes)||o.shapes.length!==1)&&n.push({path:`${a}.shapes`,message:"Native shape definitions must contain exactly one root shape",severity:"error"}),c)for(let l of["wrapperAttrs","groups","overflow"])o[l]!==void 0&&n.push({path:`${a}.${l}`,message:`Symbol ${l} is schema-v7 migration input only`,severity:"error"});for(let l of["viewBox","preserveAspectRatio","x","y","width","height","refX","refY"])o[l]!==void 0&&typeof o[l]!="string"&&n.push({path:`${a}.${l}`,message:`Symbol ${l} must be a string when present`,severity:"error"});if(o.rootAttributes!==void 0)if(!Ee(o.rootAttributes))n.push({path:`${a}.rootAttributes`,message:"Symbol rootAttributes must be a plain object",severity:"error"});else for(let[l,d]of Object.entries(o.rootAttributes))c&&["viewBox","preserveAspectRatio","x","y","width","height","refX","refY"].includes(l)&&n.push({path:`${a}.rootAttributes.${l}`,message:`Symbol ${l} must use its typed root field`,severity:"error"}),typeof d!="string"&&n.push({path:`${a}.rootAttributes.${l}`,message:"Symbol root attribute values must be strings",severity:"error"})}if(o.kind==="marker"){for(let c of["viewBox","preserveAspectRatio"])o[c]!==void 0&&typeof o[c]!="string"&&n.push({path:`${a}.${c}`,message:`Marker ${c} must be a string when present`,severity:"error"});if(o.authoredGeometry!==void 0)if(!Ee(o.authoredGeometry))n.push({path:`${a}.authoredGeometry`,message:"Marker authoredGeometry must be a plain object",severity:"error"});else for(let[c,l]of Object.entries(o.authoredGeometry))typeof l!="string"&&n.push({path:`${a}.authoredGeometry.${c}`,message:"Marker authored geometry declarations must be strings",severity:"error"});if(o.rootAttributes!==void 0)if(!Ee(o.rootAttributes))n.push({path:`${a}.rootAttributes`,message:"Marker rootAttributes must be a plain object",severity:"error"});else for(let[c,l]of Object.entries(o.rootAttributes))["id","viewBox","preserveAspectRatio","refX","refY","markerWidth","markerHeight","markerUnits","orient"].includes(c)&&n.push({path:`${a}.rootAttributes.${c}`,message:`Marker ${c} must use its typed root field`,severity:"error"}),typeof l!="string"&&n.push({path:`${a}.rootAttributes.${c}`,message:"Marker root attribute values must be strings",severity:"error"})}if(Array.isArray(o.shapes)){let c=new Set;o.shapes.forEach((l,d)=>{Lp(l,`${a}.shapes[${d}]`,n,r,c)})}if(o.kind==="symbol"&&Ee(o.variants))for(let[c,l]of Object.entries(o.variants)){if(!Array.isArray(l))continue;let d=new Set;l.forEach((u,p)=>{Lp(u,`${a}.variants[${c}][${p}]`,n,r,d)})}}(o.kind==="linear-gradient"||o.kind==="radial-gradient")&&QA(o.gradient,`${a}.gradient`,o.kind,n),o.kind==="pattern"&&eE(o.pattern,`${a}.pattern`,n)})},paintServerDefs:(t,{errors:e})=>{if(!un(t,"paintServerDefs",e))return;let n=new Set;t.forEach((r,i)=>{oE(r,`paintServerDefs[${i}]`,e,n)})},colorGlyphLibrary:(t,{errors:e})=>{if(!Ee(t)){e.push({path:"colorGlyphLibrary",message:"colorGlyphLibrary must be a plain object",severity:"error"});return}t.version!==void 0&&!Number.isInteger(t.version)&&e.push({path:"colorGlyphLibrary.version",message:"colorGlyphLibrary.version must be an integer",severity:"error"}),t.entries!==void 0&&!Array.isArray(t.entries)&&e.push({path:"colorGlyphLibrary.entries",message:"colorGlyphLibrary.entries must be an array",severity:"error"})},exportItems:(t,{errors:e})=>{un(t,"exportItems",e)&&t.forEach((n,r)=>{let i=`exportItems[${r}]`;if(!Ee(n)){e.push({path:i,message:"Export item must be a non-null object",severity:"error"});return}(typeof n.id!="string"||n.id.length===0)&&e.push({path:`${i}.id`,message:"Export item id must be a non-empty string",severity:"error"}),typeof n.filename!="string"&&e.push({path:`${i}.filename`,message:"Export item filename must be a string",severity:"error"}),typeof n.format!="string"&&e.push({path:`${i}.format`,message:"Export item format must be a string",severity:"error"})})},unknownFields:(t,{errors:e})=>{Ee(t)||e.push({path:"unknownFields",message:"unknownFields must be a plain object (forward-compat quarantine bag)",severity:"error"})}};function nE(t){let e=new Set;if(!Array.isArray(t))return e;for(let n of t)mn(n,{onShape:r=>{typeof r.id=="string"&&r.id.length>0&&e.add(r.id)}});return e}function zb(t){return t.startsWith("structural:")}function rE(t,e,n,r,i,o){if(t===null||typeof t!="object"){n.push({path:e,message:"Scene tree entry must be a non-null object",severity:"error"});return}let s=t;typeof s.id!="string"||s.id.length===0?n.push({path:`${e}.id`,message:"Scene tree id must be a non-empty string",severity:"error"}):(o.has(s.id)&&n.push({path:`${e}.id`,message:`Duplicate scene tree id: "${s.id}"`,severity:"error"}),o.add(s.id),!i.has(s.id)&&!zb(s.id)&&r.push({path:`${e}.id`,message:`Scene tree id "${s.id}" is not present in shapes`,severity:"warning"})),s.parentId!==null&&typeof s.parentId!="string"?n.push({path:`${e}.parentId`,message:"Scene tree parentId must be a string or null",severity:"error"}):typeof s.parentId=="string"&&!i.has(s.parentId)&&!zb(s.parentId)&&r.push({path:`${e}.parentId`,message:`Scene tree parentId "${s.parentId}" is not present in shapes`,severity:"warning"}),(typeof s.index!="number"||!Number.isInteger(s.index)||s.index<0)&&n.push({path:`${e}.index`,message:"Scene tree index must be a non-negative integer",severity:"error"}),s.updatedAt!==void 0&&(typeof s.updatedAt!="number"||!Number.isFinite(s.updatedAt)||s.updatedAt<0)&&n.push({path:`${e}.updatedAt`,message:"Scene tree updatedAt must be a non-negative finite number",severity:"error"}),s.clientId!==void 0&&typeof s.clientId!="string"&&n.push({path:`${e}.clientId`,message:"Scene tree clientId must be a string",severity:"error"})}var iE=new Set(["mask","clipPath","filter","linearGradient","radialGradient","pattern","symbol"]);function oE(t,e,n,r){if(t===null||typeof t!="object"){n.push({path:e,message:"Paint server def must be a non-null object",severity:"error"});return}let i=t;typeof i.id!="string"||i.id.length===0?n.push({path:`${e}.id`,message:"Paint server def id must be a non-empty string",severity:"error"}):r.has(i.id)?n.push({path:`${e}.id`,message:`Duplicate paint server def id: "${i.id}"`,severity:"error"}):r.add(i.id);let o=i.role===void 0?"resource":i.role;o!=="resource"&&o!=="referenced-fragment"&&n.push({path:`${e}.role`,message:"Paint server def role must be resource or referenced-fragment",severity:"error"}),typeof i.type=="string"&&(o==="resource"&&iE.has(i.type)||o==="referenced-fragment"&&/^[A-Za-z][\w.-]*$/u.test(i.type))||n.push({path:`${e}.type`,message:"Paint server def type must be a supported SVG defs element type",severity:"error"}),(typeof i.markup!="string"||i.markup.length===0)&&n.push({path:`${e}.markup`,message:"Paint server def markup must be a non-empty string",severity:"error"}),i.passthrough!==void 0&&typeof i.passthrough!="boolean"&&n.push({path:`${e}.passthrough`,message:"Paint server def passthrough must be a boolean when present",severity:"error"});for(let a of["definitionChildIds","sourceDefinitionChildIds"]){let c=i[a];c!==void 0&&(!Array.isArray(c)||c.some(l=>typeof l!="string"||l.length===0))&&n.push({path:`${e}.${a}`,message:"Definition child ids must be non-empty strings",severity:"error"})}Array.isArray(i.definitionChildIds)&&Array.isArray(i.sourceDefinitionChildIds)&&i.definitionChildIds.length!==i.sourceDefinitionChildIds.length&&n.push({path:e,message:"Definition child id arrays must have equal lengths",severity:"error"})}function Lp(t,e,n,r,i){if(t===null||typeof t!="object"||Array.isArray(t)){n.push({path:e,message:"Shape must be a non-null object",severity:"error"});return}mn(t,{onShape:(o,s)=>{sE(o,`${e}${s}`,n,r,i)}})}function sE(t,e,n,r,i){if(typeof t.id!="string"||t.id.length===0?n.push({path:`${e}.id`,message:"Shape id must be a non-empty string",severity:"error"}):i.has(t.id)?n.push({path:`${e}.id`,message:`Duplicate shape id: "${t.id}"`,severity:"error"}):i.add(t.id),typeof t.type!="string"?n.push({path:`${e}.type`,message:"Shape type must be a string",severity:"error"}):YA().has(t.type)||r.push({path:`${e}.type`,message:`Unknown shape type: "${t.type}"`,severity:"warning"}),t.state===void 0||t.state===null||typeof t.state!="object")n.push({path:`${e}.state`,message:"Shape state must be a non-null object",severity:"error"});else{let o=t.state;cE(o,`${e}.state`,n,r),o.children!==void 0&&!Array.isArray(o.children)?n.push({path:`${e}.state.children`,message:"children must be an array",severity:"error"}):Array.isArray(o.children)&&o.children.forEach((s,a)=>{(s===null||typeof s!="object"||Array.isArray(s))&&n.push({path:`${e}.state.children[${a}]`,message:"Shape must be a non-null object",severity:"error"})})}}var aE=/^\s*\{\{\s*[\w.\-]+\s*\}\}\s*$/;function _b(t){return typeof t=="number"?isFinite(t):typeof t=="string"?aE.test(t):!1}function cE(t,e,n,r){if(Ee(t.metadata))for(let s of["linkUrl","linkTarget"])Object.hasOwn(t.metadata,s)&&n.push({path:`${e}.metadata.${s}`,message:`${s} is noncanonical; use a Hyperlink container shape`,severity:"error"});if((t.fillType==="linear-gradient"||t.fillType==="radial-gradient"||t.fillType==="pattern")&&t.fillColor==="none"&&t.fillOpacity===0&&n.push({path:`${e}.fillOpacity`,message:"Painted shapes cannot carry the noncanonical no-fill opacity encoding",severity:"error"}),t.charOffsets!==void 0&&t.charOffsets!==null&&(Array.isArray(t.charOffsets)?t.charOffsets.forEach((s,a)=>{let c=`${e}.charOffsets[${a}]`;if(!Ee(s)){n.push({path:c,message:"Each charOffsets entry must be a plain object",severity:"error"});return}for(let l of["x","y"]){let d=s[l];d!==null&&(typeof d!="number"||!Number.isFinite(d))&&n.push({path:`${c}.${l}`,message:`${l} must be null or a finite number`,severity:"error"})}for(let l of["dx","dy","rotate"]){let d=s[l];(typeof d!="number"||!Number.isFinite(d))&&n.push({path:`${c}.${l}`,message:`${l} must be a finite number`,severity:"error"})}if(s.raw!==void 0)if(!Ee(s.raw))n.push({path:`${c}.raw`,message:"raw must be a plain object",severity:"error"});else for(let[l,d]of Object.entries(s.raw))(!["x","y","dx","dy"].includes(l)||typeof d!="string")&&n.push({path:`${c}.raw.${l}`,message:"raw accepts only string x/y/dx/dy members",severity:"error"})}):n.push({path:`${e}.charOffsets`,message:"charOffsets must be an array",severity:"error"})),t.authoredTextPosition!==void 0)if(!Ee(t.authoredTextPosition))n.push({path:`${e}.authoredTextPosition`,message:"authoredTextPosition must be a plain object",severity:"error"});else for(let[s,a]of Object.entries(t.authoredTextPosition)){let c=`${e}.authoredTextPosition.${s}`;if(!["x","y"].includes(s)||!Ee(a)){n.push({path:c,message:"Authored text position accepts only x/y coordinate objects",severity:"error"});continue}(typeof a.raw!="string"||a.raw.length===0||typeof a.resolved!="number"||!Number.isFinite(a.resolved))&&n.push({path:c,message:"Authored text coordinates require non-empty raw and finite resolved values",severity:"error"});for(let l of Object.keys(a))["raw","resolved"].includes(l)||n.push({path:`${c}.${l}`,message:"Authored text coordinates accept only raw/resolved members",severity:"error"})}if(t.authoredTextStructure!==void 0){let s=`${e}.authoredTextStructure`;if(!Ee(t.authoredTextStructure))n.push({path:s,message:"authoredTextStructure must be a plain object",severity:"error"});else{let a=t.authoredTextStructure,c=a.text,l=a.spans;if(typeof c!="string"||!Array.isArray(l))n.push({path:s,message:"Authored text structure requires text and spans",severity:"error"});else{let d=0;l.forEach((u,p)=>{let f=`${s}.spans[${p}]`,m=Ee(u)?u.start:void 0,g=Ee(u)?u.end:void 0;!Ee(u)||typeof m!="number"||typeof g!="number"||!Number.isInteger(m)||!Number.isInteger(g)||m<d||g<=m||g>c.length||typeof u.id!="string"||u.id.length===0||Object.keys(u).some(h=>!["start","end","id"].includes(h))?n.push({path:f,message:"Authored text spans require ordered start/end ranges and a non-empty id",severity:"error"}):d=g});for(let u of Object.keys(a))["text","spans"].includes(u)||n.push({path:`${s}.${u}`,message:"Authored text structure accepts only text/spans members",severity:"error"})}}}if(t.authoredUseGeometry!==void 0)if(!Ee(t.authoredUseGeometry))n.push({path:`${e}.authoredUseGeometry`,message:"authoredUseGeometry must be a plain object",severity:"error"});else for(let[s,a]of Object.entries(t.authoredUseGeometry))(!["x","y","width","height"].includes(s)||typeof a!="string")&&n.push({path:`${e}.authoredUseGeometry.${s}`,message:"Authored use geometry accepts only string x/y/width/height members",severity:"error"});let i=["x","y","width","height","radius","rx","ry","fontSize"];for(let s of i)t[s]!==void 0&&!_b(t[s])&&n.push({path:`${e}.${s}`,message:`${s} must be a finite number or a {{variable}} reference`,severity:"error"});for(let s of Cs){let a=t[s];if(a!=null){if(s==="transformMatrix"){(!Array.isArray(a)||a.length<6||!a.slice(0,6).every(c=>typeof c=="number"&&Number.isFinite(c)))&&n.push({path:`${e}.${s}`,message:`${s} must be a 6-element finite affine matrix`,severity:"error"});continue}_b(a)||n.push({path:`${e}.${s}`,message:`${s} must be a finite number or a {{variable}} reference`,severity:"error"})}}let o=["width","height","radius","fontSize"];for(let s of o){let a=t[s];typeof a=="number"&&a<=0&&r.push({path:`${e}.${s}`,message:`${s} should be positive (got ${a})`,severity:"warning"})}}function lE(t,e,n,r){if(t===null||typeof t!="object"){n.push({path:e,message:"Viewbox must be a non-null object",severity:"error"});return}let i=t;typeof i.id!="string"||i.id.length===0?n.push({path:`${e}.id`,message:"Viewbox id must be a non-empty string",severity:"error"}):r.has(i.id)?n.push({path:`${e}.id`,message:`Duplicate viewbox id: "${i.id}"`,severity:"error"}):r.add(i.id);for(let o of["x","y","width","height"])(typeof i[o]!="number"||!isFinite(i[o]))&&n.push({path:`${e}.${o}`,message:`${o} must be a finite number`,severity:"error"});typeof i.width=="number"&&i.width<=0&&n.push({path:`${e}.width`,message:"Viewbox width must be positive",severity:"error"}),typeof i.height=="number"&&i.height<=0&&n.push({path:`${e}.height`,message:"Viewbox height must be positive",severity:"error"})}function dE(t,e,n){if(t===null||typeof t!="object"){n.push({path:e,message:"Guide must be a non-null object",severity:"error"});return}let r=t;(typeof r.id!="string"||r.id.length===0)&&n.push({path:`${e}.id`,message:"Guide id must be a non-empty string",severity:"error"}),r.orientation!=="horizontal"&&r.orientation!=="vertical"&&n.push({path:`${e}.orientation`,message:'Guide orientation must be "horizontal" or "vertical"',severity:"error"}),(typeof r.position!="number"||!isFinite(r.position))&&n.push({path:`${e}.position`,message:"Guide position must be a finite number",severity:"error"})}function uE(t,e,n,r){if(t===null||typeof t!="object"){n.push({path:e,message:"ClipMaskGroup must be a non-null object",severity:"error"});return}let i=t;(typeof i.id!="string"||i.id.length===0)&&n.push({path:`${e}.id`,message:"ClipMaskGroup id must be a non-empty string",severity:"error"}),i.type!=="clip"&&i.type!=="mask"&&n.push({path:`${e}.type`,message:'ClipMaskGroup type must be "clip" or "mask"',severity:"error"});let o=i.clipShapeIds,s=typeof i.rawDefinition=="string"&&i.rawDefinition.length>0;o!==void 0&&!Array.isArray(o)?n.push({path:`${e}.clipShapeIds`,message:"clipShapeIds must be an array",severity:"error"}):o===void 0?n.push({path:`${e}.clipShapeIds`,message:"ClipMaskGroup must carry clipShapeIds",severity:"error"}):Array.isArray(o)&&o.length===0&&!s&&r.push({path:`${e}.clipShapeIds`,message:"ClipMaskGroup has no clip shapes and no rawDefinition; it will clip nothing",severity:"warning"}),Array.isArray(i.contentShapeIds)||n.push({path:`${e}.contentShapeIds`,message:"contentShapeIds must be an array",severity:"error"})}function Yo(t){let e=[],n=new Map,r=new Set,i=new WeakSet,o=[...t].reverse();for(;o.length>0;){let a=o.pop();if(!a||typeof a!="object"||i.has(a))continue;i.add(a),e.push(a);let c=n.get(a.id);c&&c!==a?r.add(a.id):c||n.set(a.id,a);let l=a.state.children;if(Array.isArray(l))for(let d=l.length-1;d>=0;d--){let u=l[d];u&&typeof u=="object"&&typeof u.id=="string"&&o.push(u)}}let s=new Map(n);for(let a of r)s.delete(a);return{ordered:e,uniqueById:s,duplicateIds:r}}function qo(t){let e=[...t??[]],n=new Map;for(let o of e)n.set(o.id,(n.get(o.id)??0)+1);let r=new Set([...n].filter(([,o])=>o>1).map(([o])=>o)),i=new Map;for(let o of e)r.has(o.id)||i.set(o.id,o);return{ordered:e,uniqueById:i,duplicateIds:r,definition:o=>i.get(o),symbol:o=>{let s=i.get(o);return s?.kind==="symbol"?s:void 0}}}function pE(t){let e=t.groupData;if(!e||typeof e!="object"||Array.isArray(e))return null;let n=e.transform;return typeof n=="string"&&n.trim()?n:null}function Zo(t,e){let n=Rt(t,e);if(n)return{matrix:hn(t,e),attribute:n,owner:"canonical"};let r=pE(t);return r?{matrix:Kt(r),attribute:r,owner:"group-data"}:{matrix:_e,attribute:null,owner:"none"}}function Gt(t){let e=t.transformMatrix;return pr(e)&&!Dt(e)||t.customPivot||typeof t.rawTransform=="string"&&t.rawTransform?!1:(t.rotation??0)!==0||(t.skewX??0)!==0||(t.skewY??0)!==0||(t.scaleX??1)!==1||(t.scaleY??1)!==1}function $c(t,e){let n=e?{x:(e.minX+e.maxX)/2,y:(e.minY+e.maxY)/2}:void 0;return Zo(t,n)}var fE=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/,mE=/^([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?)px$/i,gE=/^([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?)%$/;function Jo(t,e,n,r){let i=t.trim();if(fE.test(i))return Number(i);let o=mE.exec(i);if(o)return Number(o[1]);let s=gE.exec(i);if(s)return e.percentBasis===void 0?(r.push({code:"unresolved-symbol-viewport",message:`Symbol ${e.axis} percentage ${t} needs a containing viewport basis.`}),null):Number(s[1])/100*e.percentBasis;let a=n.resolveLength?.(t,e)??null;return a!==null&&Number.isFinite(a)?a:(r.push({code:"invalid-symbol-length",message:`Symbol ${e.axis} length ${t} is invalid or requires an unavailable length host.`}),null)}function hE(t){let e=t.state.authoredUseGeometry;return e&&typeof e=="object"?e:{}}function ri(t,e){let n=t[e];if(typeof n=="string")return n;if(["viewBox","preserveAspectRatio","x","y","width","height","refX","refY"].includes(e))return;let r=t.rootAttributes?.[e];return typeof r=="string"?r:void 0}function yE(t,e){if(t===void 0)return;let n=at(t);return n?n.width<0||n.height<0?(e.push({code:"invalid-symbol-viewbox",message:`Symbol viewBox ${t} has a non-finite or negative dimension and is ignored.`}),null):n:(e.push({code:"invalid-symbol-viewbox",message:`Symbol viewBox ${t} is not four finite SVG numbers and is ignored.`}),null)}function Fb(t,e,n,r,i,o){return e===void 0?0:Jo(e,{axis:n,percentBasis:n==="x"?r?.width:r?.height},i,o)??0}function Lb(t,e,n,r,i,o,s){let a=n==="width"?i?.width:i?.height,c=[r,ri(e,n)];for(let l of c){if(l===void 0||l.trim().toLowerCase()==="auto")continue;let d=Jo(l,{axis:n,percentBasis:a},o,s);if(d!==null){if(d<0){s.push({code:"invalid-symbol-length",message:`Negative symbol ${n} ${l} is invalid and falls back to auto.`});continue}return d}}return a!==void 0?a:(s.push({code:"unresolved-symbol-viewport",message:`Symbol ${n} is auto and needs a containing viewport basis.`}),null)}function Bb(t,e,n,r,i){if(t===void 0)return;let o=t.trim();if(e==="refX"){if(o==="left")return 0;if(o==="center")return(n?.width??0)/2;if(o==="right")return n?.width??0}else{if(o==="top")return 0;if(o==="center")return(n?.height??0)/2;if(o==="bottom")return n?.height??0}return Jo(t,{axis:e,percentBasis:e==="refX"?n?.width:n?.height},r,i)??void 0}function Qo(t,e,n,r={}){let i=[],o=hE(t),s=Fb(t,o.x,"x",n,r,i),a=Fb(t,o.y,"y",n,r,i),c=qe(s,a),l=ri(e,"transform"),d=l?Kt(l):_e;if((e.defKind??"symbol")!=="symbol")return{kind:"group",renders:!0,useX:s,useY:a,useAttributes:o,contentMatrix:he(c,d),childPercentBasis:n??null,viewport:null,diagnostics:i};let u=Lb(t,e,"width",o.width,n,r,i),p=Lb(t,e,"height",o.height,n,r,i),f=ri(e,"x"),m=ri(e,"y"),g=f!==void 0?Jo(f,{axis:"x",percentBasis:n?.width},r,i)??0:0,h=m!==void 0?Jo(m,{axis:"y",percentBasis:n?.height},r,i)??0:0,y=yE(e.viewBox,i),b=zo({width:u,height:p,...y?{viewBoxX:y.x,viewBoxY:y.y,viewBoxWidth:y.width,viewBoxHeight:y.height}:{},preserveAspectRatio:ri(e,"preserveAspectRatio")},n);for(let w of b.diagnostics)i.push({code:w.code==="unresolved-viewport-size"?"unresolved-symbol-viewport":"invalid-symbol-viewbox",message:w.message.replace("Nested SVG","Symbol")});if(u===null||p===null||!b.renders||!b.contentMatrix)return{kind:"symbol",renders:!1,useX:s,useY:a,useAttributes:o,contentMatrix:he(c,d),childPercentBasis:b.childPercentBasis,viewport:b,diagnostics:i};let v=Bb(ri(e,"refX"),"refX",b.childPercentBasis,r,i),I=Bb(ri(e,"refY"),"refY",b.childPercentBasis,r,i),x=Ye(b.contentMatrix,{x:v??0,y:I??0}),k=qe(g-(v===void 0?0:x.x),h-(I===void 0?0:x.y)),T=he(he(he(c,d),k),b.contentMatrix);return{kind:"symbol",renders:!0,useX:s,useY:a,useAttributes:o,contentMatrix:T,childPercentBasis:b.childPercentBasis,viewport:b,diagnostics:i}}function Hp(){return{bounds:null,status:"empty",diagnostics:[]}}function Qi(t,e,n){return n.resolveOwnTransform?.(t,e)??e}function In(t,e){return{bounds:null,status:t,diagnostics:[e]}}function Ac(t,e){return t?e?{minX:Math.min(t.minX,e.minX),minY:Math.min(t.minY,e.minY),maxX:Math.max(t.maxX,e.maxX),maxY:Math.max(t.maxY,e.maxY)}:t:e}function xn(t,e,n="empty"){return t?{bounds:t,status:"resolved",diagnostics:e}:e.some(r=>r.code==="container-cycle"||r.code==="reference-cycle"||r.code==="symbol-cycle")?{bounds:null,status:"cycle",diagnostics:e}:e.some(r=>r.code==="unsupported-shape"||r.code==="deferred-tree-kind")?{bounds:null,status:"unsupported",diagnostics:e}:e.some(r=>r.code==="unresolved-shape"||r.code==="unresolved-reference-target"||r.code==="unresolved-reference-pivot"||r.code==="duplicate-shape-id"||r.code==="unresolved-svg-viewport"||r.code==="unresolved-symbol-definition"||r.code==="duplicate-library-id"||r.code==="unresolved-symbol-viewport"||r.code==="unresolved-symbol-pivot")?{bounds:null,status:"unresolved",diagnostics:e}:{bounds:null,status:n,diagnostics:e}}function Vp(t){if(t.length===0)return null;let e=t[0].x,n=t[0].y,r=t[0].x,i=t[0].y;for(let o=1;o<t.length;o++){let s=t[o];e=Math.min(e,s.x),n=Math.min(n,s.y),r=Math.max(r,s.x),i=Math.max(i,s.y)}return{minX:e,minY:n,maxX:r,maxY:i}}function Wp(t,e){return Vp([Ye(e,{x:t.minX,y:t.minY}),Ye(e,{x:t.maxX,y:t.minY}),Ye(e,{x:t.maxX,y:t.maxY}),Ye(e,{x:t.minX,y:t.maxY})])}function Gb(t,e,n,r,i){return n<0||r<0?null:Wp({minX:t,minY:e,maxX:t+n,maxY:e+r},i)}function Vb(t,e,n,r,i){if(n<0||r<0)return null;let o=Ye(i,{x:t,y:e}),s=Math.hypot(i[0]*n,i[2]*r),a=Math.hypot(i[1]*n,i[3]*r);return{minX:o.x-s,minY:o.y-a,maxX:o.x+s,maxY:o.y+a}}function SE(t,e){let n=Array.isArray(t)?t:[t],r=null;for(let i of n)r=Ac(r,Wp(i,e));return r}function Bp(t,e,n){return In("unsupported",{code:e,shapeId:t.id,message:`Object bounds for ${n} require a document resolver policy.`,path:[t.id]})}function jp(t,e,n={}){let r=cn(t);if(!r)return In("unsupported",{code:"unsupported-shape",shapeId:t.id,message:`No geometry kernel is registered for shape type ${t.type}.`,path:[t.id]});let i;switch(r.kind){case"circle":i=Vb(r.cx,r.cy,r.r,r.r,e);break;case"ellipse":i=Vb(r.cx,r.cy,r.rx,r.ry,e);break;case"rectangle":if(r.width<0||r.height<0)i=null;else if(r.pathData)i=Sn(r.pathData,e);else if(r.rx>0&&r.ry>0){let o=Tu(r.x,r.y,r.width,r.height,r.rx,r.ry);i=o?Sn(o,e):null}else i=Gb(r.x,r.y,r.width,r.height,e);break;case"line":if(r.boundsPolicy==="linked-line")return Bp(t,"deferred-tree-kind","linked line");i=Vp([Ye(e,{x:r.x1,y:r.y1}),Ye(e,{x:r.x2,y:r.y2})]);break;case"text":{let o=n.measureText?.(t,r)??null;if(!o)return Bp(t,"deferred-tree-kind","text");i=SE(o,e);break}case"path":{let o=r.placement?he(e,qe(r.placement.x,r.placement.y)):e;i=Sn(r.d,o);break}case"polyline":{let o=r.points.length>0?r.points:[{x:0,y:0}];i=Vp(o.map(s=>Ye(e,s)));break}case"positioning-rect":i=Gb(r.x,r.y,r.width,r.height,e);break;case"view":return Hp();case"container":case"embedded-svg":case"shape-reference":case"symbol-instance":return Bp(t,"deferred-tree-kind",r.kind)}return i?{bounds:i,status:"resolved",diagnostics:[]}:{bounds:null,status:"empty",diagnostics:[]}}function Up(t){let e=t.state.children;return Array.isArray(e)?e.filter(n=>!!n&&typeof n=="object"&&typeof n.id=="string"):[]}function Zn(t){let e=Yo(t.shapes),n=qo(t.library),r=t.sceneTree??[];if(r.length===0)return{roots:()=>t.shapes,shape:l=>e.uniqueById.get(l),duplicateShapeIds:()=>e.duplicateIds,libraryDefinition:l=>n.definition(l),duplicateLibraryIds:()=>n.duplicateIds,children:Up};let i=new Map,o=new Set;for(let l of r){let d=i.get(l.parentId)??[];i.set(l.parentId,[...d,l]),e.uniqueById.has(l.id)&&o.add(l.id)}let s=l=>{let d=[],u=new Set,p=f=>{for(let m of mt([...i.get(f)??[]])){let g=e.uniqueById.get(m.id);if(g){d.push(g);continue}u.has(m.id)||(u.add(m.id),p(m.id),u.delete(m.id))}};return p(l),d};return{roots:()=>[...s(null),...t.shapes.filter(l=>!o.has(l.id))],shape:l=>e.uniqueById.get(l),duplicateShapeIds:()=>e.duplicateIds,libraryDefinition:l=>n.definition(l),duplicateLibraryIds:()=>n.duplicateIds,children:l=>[...s(l.id),...Up(l).filter(d=>!o.has(d.id))]}}function jb(t,e){return`${e.identityPrefixes.at(-1)??"document"}\0${t.id}`}var bE=new Set(["block","contents","flex","flow","flow-root","grid","inherit","initial","inline","inline-block","inline-flex","inline-grid","inline-table","list-item","none","revert","revert-layer","ruby","ruby-base","ruby-base-container","ruby-text","ruby-text-container","run-in","table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row","table-row-group","unset"]),Gp=new Set(["block","inline","run-in"]),vE=new Set(["flow","flow-root","table","flex","grid","ruby"]);function xE(t){let e=t.trim().toLowerCase();if(bE.has(e)||/^(?:var|env)\(/.test(e)&&e.endsWith(")"))return!0;let n=e.split(/\s+/);if(n.length<2||n.length>3||new Set(n).size!==n.length)return!1;if(n.includes("list-item")){let r=n.filter(i=>i!=="list-item");return r.filter(i=>Gp.has(i)).length<=1&&r.filter(i=>i==="flow"||i==="flow-root").length<=1&&r.every(i=>Gp.has(i)||i==="flow"||i==="flow-root")}return n.length===2&&n.some(r=>Gp.has(r))&&n.some(r=>vE.has(r))}function IE(t){if(!t)return null;let e=null;for(let n of Pi(t,";")){let r=Pi(n,":");if(r.length<2||r[0].trim().toLowerCase()!=="display")continue;let i=r.slice(1).join(":").trim(),o=/\s*!important\s*$/i.test(i),s=i.replace(/\s*!important\s*$/i,"").trim().toLowerCase();xE(s)&&(!e||o||!e.important)&&(e={value:s,important:o})}return e}function Ub(t,e){let n=IE(typeof e=="string"?e:void 0);return n?n.value!=="none":typeof t!="string"||t.trim().toLowerCase()!=="none"}function ts(t,e){if(t.state.visible===!1)return!1;let n=t.type==="symbol-instance"?t.state.instancePresentation:void 0,r=n?.display??t.state.display;return Ub(r,n?.style)?e.participatesInRendering?.(t)??!0:!1}function wE(t,e,n){let r=t.rootAttributes;return Ub(r?.display,r?.style)?n.participatesSymbolDefinition?.(t,e)??!0:!1}function kE(t,e={}){return{x:t.x,y:t.y,width:e.width!==void 0?e.width:t.width,height:e.height!==void 0?e.height:t.height,viewBoxX:t.viewBoxX,viewBoxY:t.viewBoxY,viewBoxWidth:t.viewBoxWidth,viewBoxHeight:t.viewBoxHeight,preserveAspectRatio:t.preserveAspectRatio}}function ii(t,e,n={}){let r=cn(t);if(!r||r.kind!=="embedded-svg")return{matrix:_e,attribute:null,pivotRequired:!1,pivotResolved:!1,viewport:zo({})};let i=zo(kE(r,n),e),o=Gt(t.state),s=i.frame?{x:i.frame.x+i.frame.width/2,y:i.frame.y+i.frame.height/2}:void 0;return{matrix:hn(t.state,s),attribute:Rt(t.state,s),pivotRequired:o,pivotResolved:!o||s!==void 0,viewport:i}}function Hb(t,e,n){return e.diagnostics.map(r=>({code:r.code==="unresolved-viewport-size"?"unresolved-svg-viewport":"invalid-svg-viewport",shapeId:t.id,message:r.message,path:[...n,t.id]}))}function Nc(t,e,n,r){let i=null,o=[],s=n.forceInlineChildren>0?Up(t):n.view.children(t);for(let a of s){if(!ts(a,n.host))continue;let c=ns(a,e,n,r);i=Ac(i,c.bounds),o.push(...c.diagnostics)}return xn(i,o)}function Wb(t,e){return{...t,diagnostics:t.diagnostics.map(n=>n.path.includes(e)?n:{...n,path:[e,...n.path]})}}function PE(t,e,n,r,i={}){let o=ii(t,r,i),s=Hb(t,o.viewport,n.path);if(o.pivotRequired&&!o.pivotResolved)return s.push({code:"unresolved-svg-viewport",shapeId:t.id,message:`Embedded SVG ${t.id} has decomposed rotation/scale/skew channels, but its auto viewport frame cannot be resolved without a parent viewport.`,path:[...n.path,t.id]}),xn(null,s,"unresolved");if(!o.viewport.renders)return xn(null,s,o.viewport.status==="zero-disabled"?"empty":"unresolved");let a=jb(t,n);n.active.add(a),n.path.push(t.id);let l=t.state.isRootSvg===!0?e:he(he(e,Qi(t,o.matrix,n.host)),o.viewport.contentMatrix??_e),d=Nc(t,l,n,o.viewport.childPercentBasis??r);return n.path.pop(),n.active.delete(a),xn(d.bounds,[...s,...d.diagnostics],d.status)}function TE(t,e,n={},r={}){let i=typeof e=="string"?t.shape(e):e;if(!i){let d=typeof e=="string"?e:e.id;return In("unresolved",{code:"unresolved-shape",shapeId:d,message:`Shape ${d} is not present in the document bounds view.`,path:[d]})}let o=cn(i);if(!o||o.kind!=="embedded-svg")return In("unsupported",{code:"unsupported-shape",shapeId:i.id,message:`Shape ${i.id} is not an embedded SVG viewport.`,path:[i.id]});let s=ii(i,n.parentViewport),a=Hb(i,s.viewport,[]);if(!s.viewport.frame||s.pivotRequired&&!s.pivotResolved)return xn(null,a,"unresolved");let c=he(n.toTarget??_e,Qi(i,s.matrix,r)),l=s.viewport.frame;return{bounds:Wp({minX:l.x,minY:l.y,maxX:l.x+l.width,maxY:l.y+l.height},c),status:"resolved",diagnostics:a}}function Kb(t,e,n){let r=n.view.duplicateShapeIds?.().has(e)??!1;return In("unresolved",{code:r?"duplicate-shape-id":"unresolved-reference-target",shapeId:t.id,message:r?`Shape reference ${t.id} targets ambiguous duplicate id ${e}.`:e?`Shape reference ${t.id} targets ${e}, which is not present in the document.`:`Shape reference ${t.id} has no targetShapeId.`,path:e?[...n.path,e]:[...n.path]})}function RE(t,e){let n=[...e.path,t.id];return In("cycle",{code:"reference-cycle",shapeId:t.id,message:`Shape reference cycle detected: ${n.join(" -> ")}.`,path:n})}function Xb(t,e,n,r,i){if(!Gt(t.state))return{matrix:hn(t.state),attribute:Rt(t.state),pivotRequired:!1,pivotResolved:!0,diagnostics:[],contentBounds:null};let s=qe(e.offsetX,e.offsetY),a={width:e.width,height:e.height},c=Wb(ns(n,s,r,i,a),t.id),l=c.diagnostics.some(u=>u.code==="unsupported-shape"||u.code==="deferred-tree-kind"||u.code==="unresolved-reference-pivot"),d=c.bounds&&!l?{x:(c.bounds.minX+c.bounds.maxX)/2,y:(c.bounds.minY+c.bounds.maxY)/2}:null;if(!d){let u=c.bounds===null&&(c.status==="empty"||c.status==="cycle"||c.status==="unresolved"),p={code:"unresolved-reference-pivot",shapeId:t.id,message:`Shape reference ${t.id} has decomposed rotation/scale/skew channels, but its translated target bounds require unavailable contextual geometry or measurement.`,path:[...r.path]};return{matrix:hn(t.state),attribute:Rt(t.state),pivotRequired:!0,pivotResolved:u,diagnostics:u?c.diagnostics:[...c.diagnostics,p],contentBounds:c}}return{matrix:hn(t.state,d),attribute:Rt(t.state,d),pivotRequired:!0,pivotResolved:!0,diagnostics:[],contentBounds:c}}function CE(t,e,n,r,i){if(r.activeReferences.has(t.id))return RE(t,r);r.activeReferences.add(t.id),r.path.push(t.id);let o=u=>(r.path.pop(),r.activeReferences.delete(t.id),u),s=e.targetShapeId?.trim()??"",a=s?r.view.shape(s):void 0;if(!a)return o(Kb(t,s,r));if(!ts(a,r.host))return o(Hp());let c=Xb(t,e,a,r,i);if(c.pivotRequired&&!c.pivotResolved)return o(xn(null,[...c.diagnostics],"unresolved"));if(c.contentBounds?.bounds===null&&c.pivotResolved)return o(c.contentBounds);let l=he(he(n,Qi(t,c.matrix,r.host)),qe(e.offsetX,e.offsetY)),d=Wb(ns(a,l,r,i,{width:e.width,height:e.height}),t.id);return o({...d,diagnostics:[...c.diagnostics,...d.diagnostics]})}function Ji(t,e){let n=t.state.instancePresentation?.transform,r=typeof n=="string"&&n.trim()?n.trim():null,i=hn(t.state,e),o=Rt(t.state,e);return r?{matrix:he(Kt(r),i),attribute:o?`${r} ${o}`:r}:{matrix:i,attribute:o}}function es(t,e,n,r){return{code:n,shapeId:t.id,message:r,path:[...e.path,t.id]}}function Yb(t,e,n,r,i,o=!1){let s=Ai(e,t),a=Qo(t,e,i,{resolveLength:r.host.resolveSymbolLength}),c=[...s.diagnostics.map(g=>es(t,r,g.code,g.message)),...a.diagnostics.map(g=>es(t,r,g.code==="invalid-symbol-length"||g.code==="invalid-symbol-viewbox"?"invalid-symbol-viewport":"unresolved-symbol-viewport",g.message))];if(!a.renders){let g=a.viewport?.status==="zero-disabled";return{...xn(null,c,g?"empty":"unresolved"),transform:{...Ji(t),pivotRequired:Gt(t.state),pivotResolved:!0,diagnostics:c}}}if(!wE(e,t,r.host))return{...Hp(),transform:{...Ji(t),pivotRequired:Gt(t.state),pivotResolved:!0,diagnostics:c}};if(r.activeSymbols.has(s.materializationKey)){let g=es(t,r,"symbol-cycle",`Symbol instance cycle detected through ${e.id}.`);return{...In("cycle",g),transform:{...Ji(t),pivotRequired:Gt(t.state),pivotResolved:!0,diagnostics:[g]}}}r.activeSymbols.add(s.materializationKey),r.identityPrefixes.push(s.materializationKey),r.forceInlineChildren++,r.path.push(t.id);let l=g=>{let h=null,y=[];for(let b of s.shapes){if(!ts(b,r.host))continue;let v=ns(b,g,r,a.childPercentBasis??i);h=Ac(h,v.bounds),y.push(...v.diagnostics)}return xn(h,y)},d=Gt(t.state),u=Ji(t),p=!d,f=[];if(d){let g=l(a.contentMatrix),h=g.diagnostics.some(b=>b.code==="unsupported-shape"||b.code==="deferred-tree-kind"||b.code==="unresolved-symbol-viewport"),y=g.bounds&&!h?{x:(g.bounds.minX+g.bounds.maxX)/2,y:(g.bounds.minY+g.bounds.maxY)/2}:void 0;if(y)u=Ji(t,y),p=!0;else{let b=g.bounds===null&&(g.status==="empty"||g.status==="cycle"||g.status==="unresolved");p=b,b||(f=[es(t,r,"unresolved-symbol-pivot",`Symbol instance ${t.id} needs unavailable contextual geometry or measurement for its decomposed transform pivot.`)]),b&&!o&&(f=[...g.diagnostics])}}let m;if(d&&!p)m=xn(null,[...c,...f],"unresolved");else{let g=he(he(n,Qi(t,u.matrix,r.host)),a.contentMatrix),h=l(g);m=xn(h.bounds,[...c,...f,...h.diagnostics],h.status)}return r.path.pop(),r.forceInlineChildren--,r.identityPrefixes.pop(),r.activeSymbols.delete(s.materializationKey),{...m,transform:{...u,pivotRequired:d,pivotResolved:p,diagnostics:[...c,...f]}}}function $E(t,e,n,r){let i=String(t.state.symbolId??"").trim(),o=i?n.view.duplicateLibraryIds?.().has(i)??!1:!1,s=i?n.view.libraryDefinition?.(i):void 0;if(o||!s||s.kind!=="symbol")return In("unresolved",es(t,n,o?"duplicate-library-id":"unresolved-symbol-definition",o?`Symbol instance ${t.id} targets duplicate library id ${i}.`:`Symbol instance ${t.id} targets missing symbol definition ${i||"(blank)"}.`));let a=Yb(t,s,e,n,r),{transform:c,...l}=a;return l}function ns(t,e,n,r,i={}){let o=jb(t,n);if(n.active.has(o)){if(!n.collectDiagnostics)return{bounds:null,status:"cycle",diagnostics:[]};let l=[...n.path,t.id];return In("cycle",{code:"container-cycle",shapeId:t.id,message:`Container cycle detected: ${l.join(" -> ")}.`,path:l})}let s=cn(t);if(!s)return jp(t,e,n.host);if(s.kind==="shape-reference")return CE(t,s,e,n,r);if(s.kind==="embedded-svg")return PE(t,e,n,r,i);if(s.kind==="symbol-instance")return $E(t,e,n,r);if(s.kind!=="container"){let l=hn(t.state,s.defaultPivot??void 0);return jp(t,he(e,Qi(t,l,n.host)),n.host)}n.active.add(o),n.path.push(t.id);let a=Zo(t.state).matrix;if(Gt(t.state)){let l=n.collectDiagnostics;n.collectDiagnostics=!1;let d=Nc(t,_e,n,r);n.collectDiagnostics=l;let u=d.diagnostics.some(p=>p.code==="unsupported-shape"||p.code==="deferred-tree-kind");a=$c(t.state,u?null:d.bounds).matrix}let c=Nc(t,he(e,Qi(t,a,n.host)),n,r);return n.path.pop(),n.active.delete(o),c}function rs(t,e,n={},r={}){let i=typeof e=="string"?t.shape(e):e;if(!i){let o=typeof e=="string"?e:e.id;return In("unresolved",{code:"unresolved-shape",shapeId:o,message:`Shape ${o} is not present in the document bounds view.`,path:[o]})}return ns(i,n.toTarget??_e,{view:t,host:r,active:new Set,activeReferences:new Set,activeSymbols:new Set,identityPrefixes:[],forceInlineChildren:0,path:[],collectDiagnostics:!0},n.parentViewport)}function is(t,e,n={},r={}){let i=typeof e=="string"?t.shape(e):e;if(!i){let s=typeof e=="string"?e:e.id;return In("unresolved",{code:"unresolved-shape",shapeId:s,message:`Shape ${s} is not present in the document bounds view.`,path:[s]})}let o={...r,resolveOwnTransform:(s,a)=>s===i?_e:r.resolveOwnTransform?.(s,a)??a};return rs(t,i,{parentViewport:n.parentViewport},o)}function Kp(t,e,n={},r){let i=cn(e);if(!i||i.kind!=="shape-reference")return{matrix:_e,attribute:null,pivotRequired:!1,pivotResolved:!1,diagnostics:[]};let o={view:t,host:n,active:new Set,activeReferences:new Set([e.id]),activeSymbols:new Set,identityPrefixes:[],forceInlineChildren:0,path:[e.id],collectDiagnostics:!0},s=i.targetShapeId?.trim()??"",a=s?t.shape(s):void 0;if(!a||!ts(a,n)){let l=Gt(e.state);return{matrix:hn(e.state),attribute:Rt(e.state),pivotRequired:l,pivotResolved:!0,diagnostics:a?[]:Kb(e,s,o).diagnostics}}let c=Xb(e,i,a,o,r);return{matrix:c.matrix,attribute:c.attribute,pivotRequired:c.pivotRequired,pivotResolved:c.pivotResolved,diagnostics:c.diagnostics}}function Xp(t,e,n={},r){let i=Gt(e.state),o=String(e.state.symbolId??"").trim(),s=o?t.duplicateLibraryIds?.().has(o)??!1:!1,a=o?t.libraryDefinition?.(o):void 0;return s||!a||a.kind!=="symbol"?{...Ji(e),pivotRequired:i,pivotResolved:!0,diagnostics:[]}:Yb(e,a,_e,{view:t,host:n,active:new Set,activeReferences:new Set,activeSymbols:new Set,identityPrefixes:[],forceInlineChildren:0,path:[],collectDiagnostics:!0},r,!0).transform}function NE(t,e={},n={}){let r=null,i=[];for(let o of t.roots()){if(!ts(o,n))continue;let s=rs(t,o,e,n);r=Ac(r,s.bounds),i.push(...s.diagnostics)}return xn(r,i)}function Yp(t,e={}){if(!Gt(t.state))return{transform:Zo(t.state),contentBounds:null,pivotRequired:!1,pivotResolved:!0};let i={view:Zn({shapes:[t],viewboxes:[]}),host:e,active:new Set([`document\0${t.id}`]),activeReferences:new Set,activeSymbols:new Set,identityPrefixes:[],forceInlineChildren:0,path:[t.id],collectDiagnostics:!0},o=Nc(t,_e,i),a=o.diagnostics.some(c=>c.code==="unsupported-shape"||c.code==="deferred-tree-kind")?null:o.bounds;return{transform:$c(t.state,a),contentBounds:o,pivotRequired:!0,pivotResolved:a!==null||o.status==="empty"}}function os(t,e=t.id){return{kind:"pattern",id:e,name:t.name??e,pattern:{type:"pattern",svgContent:t.svgContent,width:t.width,height:t.height,patternType:"custom",color:"#000000",backgroundColor:"transparent",scale:1,rotation:0,opacity:1,patternUnits:"userSpaceOnUse"}}}function qb(t){if(t.builtIn)return!1;let e=t.pattern;return!e||typeof e!="object"?!1:e.patternType==="custom"&&typeof e.svgContent=="string"}function Zb(t){let e=(t.viewBox??"").trim().split(/[\s,]+/).filter(o=>o.length>0).map(Number),n=e.length===4&&e.every(o=>Number.isFinite(o)),r=n&&e[2]>0?e[2]:t.width??10,i=n&&e[3]>0?e[3]:t.height??10;return{width:r,height:i}}function qp(t){if(!qb(t))return null;let{width:e,height:n}=Zb(t.pattern);return{id:t.id,name:t.name,svgContent:t.pattern.svgContent??"",width:e,height:n}}function Zp(t){return typeof t=="string"&&t.length>0?t:null}function AE(t){let e=Zp(t.groupId);if(e)return e;let n=t.extra;return!n||typeof n!="object"||Array.isArray(n)?null:Zp(n.groupId)}function Jb(t){delete t.groupId;let e=t.extra;if(!e||typeof e!="object"||Array.isArray(e))return;let n=e;delete n.groupId,Object.keys(n).length===0&&delete t.extra}function EE(t){let e={};return t.transformOrigin&&(e.transformOrigin=t.transformOrigin),t.pluginId&&(e.pluginId=t.pluginId),t.pluginData&&(e.pluginData=t.pluginData),t.attributes&&Object.keys(t.attributes).length>0&&(e.attributes=t.attributes),t.fill&&(e.fill=t.fill),t.fillOpacity&&(e.fillOpacity=t.fillOpacity),t.strokeOpacity&&(e.strokeOpacity=t.strokeOpacity),t.opacity&&(e.opacity=t.opacity),t.filter&&(e.filter=t.filter),t.cssFilter&&(e.cssFilter=t.cssFilter),t.mixBlendMode&&(e.mixBlendMode=t.mixBlendMode),t.isolation&&(e.isolation=t.isolation),t.clipPath&&(e.clipPath=t.clipPath),t.mask&&(e.mask=t.mask),t.rawMetadata&&(e.rawMetadata=t.rawMetadata),t.transform&&(e.transform=t.transform),e}function ME(t){let e=EE(t),n={fillColor:null,borderColor:null,rotation:0,skewX:0,skewY:0,customPivot:null};return Object.keys(e).length>0&&(n.groupData=e),{id:t.id,type:"group",state:n}}function Qb(t,e){let n=t.state.children;if(Array.isArray(n))for(let r of n)e.add(r.id),Qb(r,e)}function ev(t,e=!1){let n=t.state,r=n.children;return e&&Jb(n),Array.isArray(r)&&(n.children=r.map(i=>ev(i,!0))),t}function OE(t){if(t.length<2)return t.map(s=>s.shape);let e=t.filter(s=>s.shape.type==="group"&&s.siblingIndex!==void 0&&Number.isFinite(s.siblingIndex)).sort((s,a)=>(s.siblingIndex??0)-(a.siblingIndex??0));if(e.length===0)return[...t].sort((s,a)=>s.flatOrder-a.flatOrder).map(s=>s.shape);let n=Array(t.length).fill(null),r=new Set(e);for(let s of e){let a=Math.max(0,Math.min(t.length-1,s.siblingIndex??0));for(;a<n.length&&n[a]!==null;)a++;if(a>=n.length)for(a=n.length-1;a>=0&&n[a]!==null;)a--;a>=0&&(n[a]=s)}let i=t.filter(s=>!r.has(s)).sort((s,a)=>s.flatOrder-a.flatOrder),o=0;for(let s of i){for(;o<n.length&&n[o]!==null;)o++;o<n.length&&(n[o]=s)}return n.filter(s=>s!==null).map(s=>s.shape)}function ss(t,e=[]){let n=structuredClone(t),r=structuredClone(e),i=new Map;for(let h of r)i.set(h.id,h);let o=n.map(h=>ev(h)),s=new Set;for(let h of o)Qb(h,s);let a=new Map,c=new Map;o.forEach((h,y)=>{s.has(h.id)||c.has(h.id)||(a.set(h.id,y),c.set(h.id,h))});for(let h of r){if(s.has(h.id)||c.has(h.id))continue;let y=ME(h);a.set(y.id,Number.POSITIVE_INFINITY),c.set(y.id,y)}let l=new Map,d=new Map;for(let h of c.values()){let y=h.state,b=i.get(h.id),v=AE(y)??(h.type==="group"?Zp(b?.parentId):null),I=l.get(v)??[];d.set(h.id,v),I.push({shape:h,flatOrder:a.get(h.id)??Number.POSITIVE_INFINITY,siblingIndex:h.type==="group"?b?.siblingIndex:void 0}),l.set(v,I)}let u=new Set,p=h=>{if(u.has(h.id))return null;u.add(h.id);let y=h.state,b=Array.isArray(y.children)?y.children:[],v=f(h.id),I=new Set(b.map(k=>k.id)),x=[...b,...v.filter(k=>!I.has(k.id))];return x.length>0?y.children=x:delete y.children,Jb(y),h},f=h=>{let y=[];for(let b of OE(l.get(h)??[])){let v=p(b);v&&y.push(v)}return y},m=f(null),g=h=>{if(!h)return;let y=p(h);y&&m.push(y)};for(let h of c.values()){let y=d.get(h.id);y&&!c.has(y)&&g(h)}for(let h of r)g(c.get(h.id));for(let h of c.values())g(h);return m}var DE=[["splinePoints","pathPoints"],["splineClosed","pathClosed"],["splineCurveType","pathCurveType"],["splineTension","pathTension"],["splineArcParams","pathArcParams"],["splineControlBounds","pathControlBounds"]];function zE(t){let e=!1;if(t.type==="spline"&&(t.type="path",e=!0),t.state&&typeof t.state=="object"){let n=t.state,r=n.extra&&typeof n.extra=="object"&&!Array.isArray(n.extra)?n.extra:null;for(let[i,o]of DE)Object.prototype.hasOwnProperty.call(n,i)&&(Object.prototype.hasOwnProperty.call(n,o)||(n[o]=n[i]),Reflect.deleteProperty(n,i),e=!0),r&&Object.prototype.hasOwnProperty.call(r,i)&&(Object.prototype.hasOwnProperty.call(n,o)||(n[o]=r[i]),delete r[i],e=!0);r&&Object.keys(r).length===0&&delete n.extra}return e}function tv(t){return rt(t,{onShape:e=>{zE(e)}}),t}function _E(t){if(t.type!=="connector")return;let e=t.state,n=as(e.sourcePoint),r=as(e.targetPoint);t.type="line",t.state={...t.state,x1:typeof e.x1=="number"?e.x1:n?.x??0,y1:typeof e.y1=="number"?e.y1:n?.y??0,x2:typeof e.x2=="number"?e.x2:r?.x??0,y2:typeof e.y2=="number"?e.y2:r?.y??0,routingMode:e.routingMode??"orthogonal"}}function iv(t){let e=t.customPivot;if(e)return e;let n=t.x,r=t.y,i=t.width,o=t.height;if(typeof n=="number"&&typeof r=="number"&&typeof i=="number"&&typeof o=="number")return{x:n+i/2,y:r+o/2};let s=t.radius;if(typeof n=="number"&&typeof r=="number"&&typeof s=="number")return{x:n,y:r};let a=t.cx,c=t.cy;if(typeof a=="number"&&typeof c=="number")return{x:a,y:c};let l=t.x1,d=t.y1,u=t.x2,p=t.y2;if(typeof l=="number"&&typeof d=="number"&&typeof u=="number"&&typeof p=="number")return{x:(l+u)/2,y:(d+p)/2};let f=t.pathPoints;if(f?.[0])return{x:f[0].x,y:f[0].y};let m=t.polylinePoints;if(m?.[0])return{x:m[0].x,y:m[0].y}}function FE(t){return rt(t,{onShape:e=>{let n=e.state;!n||typeof n!="object"||wh(n,iv(n))}}),t.schemaVersion=3,t}function as(t){let e=t;return e&&typeof e.x=="number"&&Number.isFinite(e.x)&&typeof e.y=="number"&&Number.isFinite(e.y)?{x:e.x,y:e.y}:null}function LE(t,e){let n=t.translateX??0,r=t.translateY??0,i=typeof t.rawTransform=="string"?t.rawTransform:"",o=qe(n,r);if(i)return ot(he(o,Kt(i)));let s=t.rotation??0,a=t.skewX??0,c=t.skewY??0;if(s!==0||a!==0||c!==0){let u=as(t.customPivot)??e??as(t.scaleAnchor);u&&(o=he(o,qe(u.x,u.y)),s!==0&&(o=he(o,Ro(s))),a!==0&&(o=he(o,oa(a))),c!==0&&(o=he(o,sa(c))),o=he(o,qe(-u.x,-u.y)))}let l=t.scaleX??1,d=t.scaleY??1;if(l!==1||d!==1){let u=as(t.scaleAnchor)??e;u&&(o=he(o,qe(u.x,u.y)),o=he(o,Ci(l,d)),o=he(o,qe(-u.x,-u.y)))}return ot(o)}function BE(t){return rt(t,{onShape:e=>{let n=e.state;!n||typeof n!="object"||!("scaleAnchor"in n)||(e.type==="text"&&!pr(n.transformMatrix)&&(n.transformMatrix=LE(n,iv(n))),delete n.scaleAnchor)}}),t.schemaVersion=4,t}function GE(t){let e=t,n=Array.isArray(t.library)?[...t.library]:[],r=new Set(n.map(l=>l.id));if(Array.isArray(e.symbols))for(let l of e.symbols)!l||r.has(l.id)||(n.push({...l,kind:"symbol"}),r.add(l.id));if(Array.isArray(e.markers))for(let l of e.markers)!l||r.has(l.id)||(n.push({...l,kind:"marker"}),r.add(l.id));let i=new Map,o=(l,d)=>{let{id:u,sourceId:p,...f}=l,m=JSON.stringify({kind:d,...f}),g=i.get(m);if(g)return g;let h=r.has(l.id)?`grd-${Ec()}`:l.id;r.add(h),i.set(m,h);let y=d==="linear-gradient"?{kind:"linear-gradient",id:h,name:l.sourceId??h,sourceId:l.sourceId,gradient:nv(l)}:{kind:"radial-gradient",id:h,name:l.sourceId??h,sourceId:l.sourceId,gradient:nv(l)};return n.push(y),h},s=new Map;if(Array.isArray(e.customPatterns))for(let l of e.customPatterns){if(!l)continue;let d=r.has(l.id)?`pat-${Ec()}`:l.id;r.add(d),s.set(l.id,d),n.push(os(l,d))}let a=l=>{if(l.customPatternId){let b=s.get(l.customPatternId);if(b)return b}let{id:d,sourceId:u,customPatternId:p,...f}=l,m=JSON.stringify({kind:"pattern",...f}),g=i.get(m);if(g)return g;let h=r.has(l.id)?`pat-${Ec()}`:l.id;r.add(h),i.set(m,h);let y={kind:"pattern",id:h,name:l.sourceId??h,sourceId:l.sourceId,pattern:f};return n.push(y),h};for(let l of t.shapes??[]){let d=l.state;if(!d)continue;let u=d.fillGradient;u&&(typeof d.fillType!="string"&&(d.fillType=u.type),u.type==="linear-gradient"||u.type==="radial-gradient"?d.fillLibraryId=o(u,u.type):u.type==="pattern"&&(d.fillLibraryId=a(u)));let p=d.strokeGradient;p&&(typeof d.strokeType!="string"&&(d.strokeType=p.type),p.type==="linear-gradient"||p.type==="radial-gradient"?d.strokeLibraryId=o(p,p.type):p.type==="pattern"&&(d.strokeLibraryId=a(p)));let f=d.filters;if(Array.isArray(f)&&f.length>0){let m=c(f,d,l.id);d.filterLibraryIds=[m]}}return t.library=n,rt(t,{onShape:_E}),delete e.customPatterns,delete e.symbols,delete e.markers,t;function c(l,d,u){let p={filters:l,colorInterpolation:d.filterColorInterpolation,filterUnits:d.filterUnits,primitiveUnits:d.primitiveUnits,x:d.filterX,y:d.filterY,width:d.filterWidth,height:d.filterHeight},f=JSON.stringify({kind:"filter",...p}),m=i.get(f);if(m)return m;let g=`filter-${u}`,h=r.has(g)?`flt-${Ec()}`:g;r.add(h),i.set(f,h);let y={kind:"filter",id:h,name:h,filters:p.filters,...p.colorInterpolation?{colorInterpolation:p.colorInterpolation}:{},...p.filterUnits?{filterUnits:p.filterUnits}:{},...p.primitiveUnits?{primitiveUnits:p.primitiveUnits}:{},...p.x!==void 0?{x:p.x}:{},...p.y!==void 0?{y:p.y}:{},...p.width!==void 0?{width:p.width}:{},...p.height!==void 0?{height:p.height}:{}};return n.push(y),h}}function nv(t){let{id:e,sourceId:n,...r}=t;return r}var Jp=0;function Ec(){return Jp=Jp+1&65535,`${Date.now().toString(36)}-${Jp.toString(36)}`}function VE(t){return rt(t,{onState:e=>{let n=e,r=Object.prototype.hasOwnProperty.call(n,"richTextData"),i=n.richTextData;if(Ds(e),!r)return;n.richTextData=i;let o=e.extra;o&&(delete o.richTextData,Object.keys(o).length===0&&delete e.extra)}}),t.schemaVersion=5,t}function jE(t){if(!t||typeof t!="object"||Array.isArray(t))return;let e=t;if(e.richTextRuns!==void 0&&e.richTextRuns!==null)return;let n=e.richTextData;!n||typeof n!="object"||Array.isArray(n)||Array.isArray(n.lines)&&(e.richTextRuns=ar(n))}function UE(t){return rt(t,{onState:e=>jE(e)}),t.schemaVersion=6,t}function Qp(t,e){if(!e.has(t))return t;let n=2;for(;e.has(`${t}-${n}`);)n++;return`${t}-${n}`}function cs(t){let e=new Set,n=new Set,r=new Map;rt(t,{onShape:o=>{if(n.add(o.id),o.type!=="view")return;r.has(o.id)||r.set(o.id,o);let s=o.state.viewName;typeof s=="string"&&s&&e.add(s)}});let i=[];return(t.viewboxes??[]).filter(o=>{let s=r.get(o.id);return!(s&&s.state.viewBoxX===o.x&&s.state.viewBoxY===o.y&&s.state.viewBoxWidth===Math.max(1,o.width)&&s.state.viewBoxHeight===Math.max(1,o.height))}).forEach((o,s)=>{let a=Qp(`view-${s+1}`,e);e.add(a);let c=Qp(o.id||`legacy-view-${s+1}`,n);n.add(c),i.push({id:c,type:"view",state:{viewBoxX:o.x,viewBoxY:o.y,viewBoxWidth:Math.max(1,o.width),viewBoxHeight:Math.max(1,o.height),viewName:a}})}),i.length>0&&t.shapes.unshift(...i),t.viewboxes=[],t}var HE=["svgX","svgY","svgWidth","svgHeight","svgViewBoxX","svgViewBoxY","svgViewBoxWidth","svgViewBoxHeight","svgPreserveAspectRatio"];function WE(t){if(t.type!=="svg"||t.state.isRootSvg===!0)return;let e=t.state;if(![e.svgViewBoxX,e.svgViewBoxY,e.svgViewBoxWidth,e.svgViewBoxHeight].every(i=>i===0))return;if(e.svgX===0&&e.svgY===0&&e.svgWidth===0&&e.svgHeight===0&&e.svgPreserveAspectRatio===""){for(let i of HE)delete e[i];return}delete e.svgViewBoxX,delete e.svgViewBoxY,delete e.svgViewBoxWidth,delete e.svgViewBoxHeight}function ov(t){return rt(t,{onShape:WE}),cs(t),t.schemaVersion=7,t}var KE=["viewBox","preserveAspectRatio","x","y","width","height","refX","refY"];function XE(t,e){if(t.type!=="symbol-instance"||t.state.authoredUseGeometry!==void 0)return;let n={};for(let r of["x","y","width","height"]){if((r==="width"||r==="height")&&e.has(String(t.state.symbolId??"")))continue;let i=t.state[r];typeof i=="number"&&Number.isFinite(i)&&(n[r]=String(i))}Object.keys(n).length>0&&(t.state.authoredUseGeometry=n)}function YE(t){let e=new Set((t.library??[]).filter(n=>n.kind==="symbol"&&n.defKind==="group").map(n=>n.id));for(let n of t.library??[]){if(n.kind!=="symbol")continue;let r=n,i={...r.wrapperAttrs??{},...r.rootAttributes??{}};for(let s of KE){let a=i[s];r[s]===void 0&&a!==void 0&&(r[s]=a),delete i[s]}if(r.overflow!==void 0&&i.overflow===void 0&&(i.overflow=r.overflow),Object.keys(i).length>0?r.rootAttributes=i:delete r.rootAttributes,r.shapes=ss(r.shapes,r.groups),r.variants)for(let[s,a]of Object.entries(r.variants))r.variants[s]=ss(a,r.groups);let o=r;delete o.wrapperAttrs,delete o.groups,delete o.overflow}return rt(t,{onShape:n=>XE(n,e)}),t.schemaVersion=8,t}function qE(t){let e=t;Array.isArray(t.shapes)&&(t.shapes=ss(t.shapes,e.groups)),delete e.groups,Array.isArray(e.rawPaintServerDefs)&&!Array.isArray(t.paintServerDefs)&&(t.paintServerDefs=Xg(e.rawPaintServerDefs)),delete e.rawPaintServerDefs;for(let n of t.library??[]){if(n.kind!=="marker")continue;let r=n;r.shapes=ss(r.shapes,r.groups),delete r.groups}return Array.isArray(e.clipMaskGroups)&&(t.clipMaskGroups=e.clipMaskGroups.map(n=>{let r=n,i=Array.isArray(r.clipShapeIds)?r.clipShapeIds:typeof r.clipShapeId=="string"&&r.clipShapeId.length>0?[r.clipShapeId]:[],o={...r,clipShapeIds:i};return delete o.clipShapeId,o})),t.schemaVersion=9,t}function ZE(t){return rt(t,{onState:e=>{let n=e;n.richTextRuns===void 0&&n.richTextData!==null&&typeof n.richTextData=="object"&&Array.isArray(n.richTextData.lines)&&(n.richTextRuns=ar(n.richTextData)),delete n.richTextData}}),t.schemaVersion=10,t}function JE(t){let n=(Array.isArray(t)?t.slice(0,6).join(" "):String(t)).trim().toLowerCase();return n==="none"||n==="hidden"||n==="collapse"?"none":"inline"}function rv(t){let e=new Set(t.keyframes.flatMap(n=>n.id?[n.id]:[]));if(t.keyframes.forEach((n,r)=>{if(n.id)return;let i=`kf${r}`;for(;e.has(i);)i=`${i}x`;n.id=i,e.add(i)}),t.property==="visibility"&&t.sourceSmilAttribute==="display"){t.property="display";for(let n of t.keyframes)n.value=JE(n.value)}delete t.sourceSmilAttribute}function QE(t){if(!Array.isArray(t.shapes))return;let e=new Map,n=new Map,r=new Map,i=(s,a)=>{let c=a?n:e,l=c.get(s.id)??[];l.push(s),c.set(s.id,l),r.set(s.id,(r.get(s.id)??0)+1);let d=s.state.children;Array.isArray(d)&&d.forEach(u=>i(u,!0))};t.shapes.forEach(s=>i(s,!1));let o=new Set;for(let[s,a]of e)a.length!==1||r.get(s)!==2||(n.get(s)??[]).length===1&&o.add(s);t.shapes=t.shapes.filter(s=>!o.has(s.id))}function eM(t){if(!Array.isArray(t.shapes))return;rt(t,{onShape:a=>{if(a.type!=="view")return;let c=a.state;Reflect.deleteProperty(c,"viewLinkedSvgId"),typeof c.extra=="object"&&c.extra!==null&&!Array.isArray(c.extra)&&Reflect.deleteProperty(c.extra,"viewLinkedSvgId")}});let e=t.shapes.filter(a=>{if(a.type!=="view")return!1;let c=a.state;return c.isHomeView===!0||typeof c.extra=="object"&&c.extra!==null&&!Array.isArray(c.extra)&&c.extra.isHomeView===!0});if(e.length===0)return;let n=e[0].state,r=Number(n.viewBoxWidth??0),i=Number(n.viewBoxHeight??0),o=t.shapes.find(a=>a.type==="svg"&&a.state.isRootSvg===!0);if(o&&r>0&&i>0){let a=Number(o.state.svgViewBoxWidth??0),c=Number(o.state.svgViewBoxHeight??0);a>0&&c>0||(o.state.svgViewBoxX=Number(n.viewBoxX??0),o.state.svgViewBoxY=Number(n.viewBoxY??0),o.state.svgViewBoxWidth=r,o.state.svgViewBoxHeight=i,Number(o.state.svgWidth??0)>0||(o.state.svgWidth=r),Number(o.state.svgHeight??0)>0||(o.state.svgHeight=i))}let s=new Set(e.map(a=>a.id));t.shapes=t.shapes.filter(a=>!s.has(a.id)),t.sceneTree=t.sceneTree?.filter(a=>!s.has(a.id))}function tM(t){if(!Array.isArray(t.shapes))return;let e=new Set;rt(t,{onShape:i=>{typeof i.id=="string"&&e.add(i.id)}});let n=new Map,r=i=>i.map(o=>{let s=o.state.children;Array.isArray(s)&&(o.state.children=r(s));let a=o.state.metadata;if(!a||typeof a!="object"||Array.isArray(a))return o;let c=typeof a.linkUrl=="string"?a.linkUrl:"",l=typeof a.linkTarget=="string"?a.linkTarget:"";if(!Object.hasOwn(a,"linkUrl")&&!Object.hasOwn(a,"linkTarget"))return o;let{linkUrl:d,linkTarget:u,...p}=a;if(o.state.metadata=p,!c||o.type==="hyperlink")return o;let f=Qp(`${o.id}-link`,e);return e.add(f),n.set(o.id,f),{id:f,type:"hyperlink",state:{href:c,...l?{linkTarget:l}:{},children:[o]}}});t.shapes=r(t.shapes);for(let i of t.library??[])if(!(i.kind!=="symbol"&&i.kind!=="marker")&&(i.shapes=r(i.shapes),i.kind==="symbol"&&i.variants))for(let[o,s]of Object.entries(i.variants))i.variants[o]=r(s);if(t.sceneTree&&n.size>0){let i=[];for(let o of t.sceneTree){let s=n.get(o.id);if(!s){i.push(o);continue}i.push({...o,id:s}),i.push({id:o.id,parentId:s,index:0})}t.sceneTree=i}}function nM(t){rt(t,{onState:e=>{(e.fillType==="linear-gradient"||e.fillType==="radial-gradient"||e.fillType==="pattern")&&e.fillColor==="none"&&e.fillOpacity===0&&(e.fillOpacity=1)}})}function rM(t){rt(t,{onState:e=>{Array.isArray(e.charOffsets)&&(e.charOffsets=e.charOffsets.map(n=>{if(!n||typeof n!="object"||"dx"in n||typeof n.x!="number")return n;let r=n;return{x:null,y:null,dx:r.x,dy:typeof r.y=="number"&&Number.isFinite(r.y)?r.y:0,rotate:typeof r.rotate=="number"&&Number.isFinite(r.rotate)?r.rotate:0}}))}})}function iM(t){rt(t,{onShape:e=>{if(e.type!=="group")return;let n=e.state,r=n.groupData;if(!r||typeof r!="object"||Array.isArray(r))return;let i=r,o=i.attributes;if(o&&typeof o=="object"&&!Array.isArray(o)){let s={...o};n.locked===void 0&&s["data-locked"]==="true"&&(n.locked=!0),n.visible===void 0&&s["data-hidden"]==="true"&&(n.visible=!1),delete s["data-locked"],delete s["data-hidden"],Object.keys(s).length>0?i.attributes=s:delete i.attributes}Array.isArray(i.classes)&&(i.classes=i.classes.map(s=>{let a=String(s);return a.startsWith("usr-")?a.slice(4):a}))}})}function oM(t){let e=tv(t);cs(e),eM(e),QE(e),tM(e),nM(e),rM(e),iM(e);for(let n of e.animationTimeline?.tracks??[])rv(n);for(let n of e.library??[])if(n.kind==="marker")for(let r of n.animations??[])rv(r);return e.schemaVersion=11,e}function sv(t){return t.schemaVersion=12,t}function sM(t){return t.schemaVersion=13,t}var av=Object.freeze({1:GE,2:FE,3:BE,4:VE,5:UE,6:ov,7:YE,8:qE,9:ZE,10:oM,11:sv,12:sM});function aM(t){let e=t.schemaVersion;return typeof e!="number"||!Number.isFinite(e)||e<1?1:Math.floor(e)}function ls(t,e=av){let n=JSON.parse(JSON.stringify(t)),r=aM(n);if(r>Lt)return n;if(r===Lt)return n.schemaVersion=Lt,n;for(;r<Lt;){let i=e[r];if(!i)throw new Error(`[svgsketch/core] No migration registered for schema version ${r} \u2192 ${r+1}. Cannot safely upgrade this document to version ${Lt}.`);n=i(n),r+=1}return n.schemaVersion=Lt,n}var cM=["unknown-shape-diagnostic","symbol-variants-overrides","smil-timeline","motion-only-partition","paint-server-references","filter-references","document-definition-context","inline-child-containers","isolated-flowchart-nodes","text-path","common-presentation","gradient-definition-envelope","filter-definition-envelope","export-precision-rounding","defs-deduplication","source-id-restoration","orphan-def-exclusion","font-embedding","initial-value-elision","namespace-declaration-completion"],ee=t=>({mode:"supported",by:t}),$r=t=>({mode:"diagnostic",signal:"warning",by:t}),ye=t=>({mode:"outside-contract",reason:t}),ct=t=>t,cv=ye("DXF is a static CAD geometry contract and has no representation for this SVG behavior."),lv=ye("Mermaid is a static graph-structure contract and has no representation for this SVG behavior."),dv=ye("PDF export produces a static page from the current editor SVG projection and does not promise animation playback."),lM={"unknown-shape-diagnostic":ct({renderToSvg:$r("renderShape reports UNSUPPORTED_SHAPE_TYPE through renderToSvgWithDiagnostics"),codegen:$r("buildRenderPlan carries UNSUPPORTED_SHAPE_TYPE into generateCodeWithDiagnostics"),dxf:$r("DxfExportStats records unsupported types and the DXF export UI reports them"),mermaid:$r("exportMermaidWithDiagnostics records unsupported nodes and both Mermaid UIs report them"),pdf:ye("PDF conversion consumes an already-projected editor SVG; unknown model nodes never enter its input."),"editor-dom":ye("Unknown nodes are preserved for round-trip but require a registered shape implementation for projection.")}),"symbol-variants-overrides":ct({renderToSvg:ee("buildRenderPlan materializes symbol variants and per-instance overrides before emission"),codegen:ee("every component backend consumes buildRenderPlan symbol materialization"),dxf:$r("DXF unsupported-shape accounting reports symbol instances without a lowering"),mermaid:$r("Mermaid node-skip diagnostics report symbol instances without a lowering"),pdf:ee("the editor projects SymbolInstance content into the SVG consumed by svg2pdf"),"editor-dom":ee("SymbolInstance projects resolved library variants and overrides")}),"smil-timeline":ct({renderToSvg:ee("buildRenderPlan injects renderAnimationElements output into shape markup"),codegen:ee("component backends preserve SMIL children in planned shape markup"),dxf:cv,mermaid:lv,pdf:dv,"editor-dom":ee("AnimationManager and the shared SMIL kernel project live playback")}),"motion-only-partition":ct({renderToSvg:ee("buildRenderPlan diverts motionOnly templates into defs outside visible paint"),codegen:ee("component backends consume the render plan visible and motion-def partitions"),dxf:cv,mermaid:lv,pdf:dv,"editor-dom":ye("The authoring DOM retains motion templates for editing instead of applying export partitioning.")}),"paint-server-references":ct({renderToSvg:ee("plan defs and shapes use one library-first paint-server reference resolver"),codegen:ee("buildShapeAttrs and plan defs use the library-first reference resolver"),dxf:ye("DXF promises geometry and basic entity colors, not SVG paint-server definition graphs."),mermaid:ye("Mermaid graph syntax has no SVG gradient or pattern paint-server model."),pdf:ee("the cloned SVG carries paint-server definitions and references into svg2pdf"),"editor-dom":ee("GradientManager maintains live defs matching shape paint references")}),"filter-references":ct({renderToSvg:ee("renderFilterDefs and filterReferenceValue emit matching identifiers"),codegen:ee("planned filter defs and buildShapeAttrs share filter reference resolution"),dxf:ye("DXF entity geometry has no SVG filter graph or filter-reference representation."),mermaid:ye("Mermaid graph syntax has no SVG filter graph or filter-reference representation."),pdf:ee("the cloned SVG carries filter definitions and references into svg2pdf"),"editor-dom":ee("FilterManager maintains live filter definitions and shape references")}),"document-definition-context":ct({renderToSvg:ee("buildRenderPlan consumes the full snapshot definition and style context"),codegen:ee("component codegen accepts snapshot context and clipboard supplies its definitions"),dxf:ye("DXF consumes resolved shapes and does not serialize SVG document definition sections."),mermaid:ye("Mermaid consumes graph nodes and does not serialize SVG definition sections."),pdf:ee("PDF receives a cloned SVG document with its referenced definition context"),"editor-dom":ee("the document aggregate and managers project referenced resources into defs")}),"inline-child-containers":ct({renderToSvg:ee("renderShape recursively renders INLINE_CHILD_CONTAINER_TYPES children"),codegen:ee("component backends preserve recursively rendered plan container markup"),dxf:ee("DXF walks INLINE_CHILD_CONTAINER_TYPES with transforms and cycle guards"),mermaid:$r("unsupported container nodes are counted by exportMermaidWithDiagnostics"),pdf:ee("the cloned editor SVG preserves nested containers for svg2pdf"),"editor-dom":ee("registered containers project managed children into nested SVG elements")}),"isolated-flowchart-nodes":ct({renderToSvg:ye("Isolated-node declarations are a Mermaid graph concern, not an SVG branch."),codegen:ye("Isolated-node declarations are a Mermaid graph concern, not component SVG output."),dxf:ye("DXF emits geometry independently and has no connector-enrolment requirement."),mermaid:ee("exportMermaid declares mapped nodes before emitting connector edges"),pdf:ye("PDF paints SVG geometry independently and has no graph-node declaration requirement."),"editor-dom":ye("The live SVG projects shapes independently and has no graph-node declaration requirement.")}),"text-path":ct({renderToSvg:ee("renderText emits textPath markup and its referenced path definition"),codegen:ee("component backends preserve planned textPath markup and definitions"),dxf:ye("DXF text entities do not reproduce SVG textPath layout along arbitrary paths."),mermaid:ye("Mermaid labels do not reproduce SVG textPath layout along arbitrary paths."),pdf:$r("ExportPanel.generatePdfBlob detects textPath content and shows its localized warning"),"editor-dom":ee("Text projects textPath attributes and maintains its referenced path")}),"common-presentation":ct({renderToSvg:ee("commonAttrs projects the ordered PRESENTATION_SEMANTICS vocabulary"),codegen:ee("buildShapeAttrs projects the ordered PRESENTATION_SEMANTICS vocabulary"),dxf:ye("DXF is not an SVG presentation-attribute serialization contract."),mermaid:ye("Mermaid is not an SVG presentation-attribute serialization contract."),pdf:ee("svg2pdf consumes common presentation attributes from the cloned SVG"),"editor-dom":ee("COMMON_PROP_RENDERERS derives its dispatch from PRESENTATION_SEMANTICS")}),"gradient-definition-envelope":ct({renderToSvg:ee("gradient renderers serialize the shared typed definition envelopes"),codegen:ee("render plan defs contain gradients serialized from shared typed envelopes"),dxf:ye("DXF has no SVG linearGradient or radialGradient definition envelope."),mermaid:ye("Mermaid has no SVG linearGradient or radialGradient definition envelope."),pdf:ee("the cloned SVG supplies shared-envelope gradient definitions to svg2pdf"),"editor-dom":ee("GradientManager projects shared gradient envelopes into live defs")}),"filter-definition-envelope":ct({renderToSvg:ee("renderFilterElement serializes filterDefinitionEnvelope for each wrapper kind"),codegen:ee("render plan defs contain filters serialized from shared typed envelopes"),dxf:ye("DXF has no SVG filter element or primitive graph envelope representation."),mermaid:ye("Mermaid has no SVG filter element or primitive graph envelope representation."),pdf:ee("the cloned SVG supplies shared-envelope filter definitions to svg2pdf"),"editor-dom":ee("FilterManager projects filterDefinitionEnvelope before primitive emission")}),"export-precision-rounding":ct({renderToSvg:ee("finalizeRenderPlan rounds markup coordinates at the effective documentMetadata.coordinatePrecision"),codegen:ye("Codegen backends consume the un-finalized render plan; component output precision is a code-style concern, not an export boundary."),dxf:ye("DXF numeric precision is owned by the DXF writer, not the SVG export boundary."),mermaid:ye("Mermaid emits graph syntax rather than SVG coordinate attribute streams."),pdf:ee("PDF viewbox pages consume the plan-assembled string (core rounding); selection pages pass through SvgExportFinalizer.roundSvgAttributes"),"editor-dom":ee("static string exports round through core finalizeRenderPlan (plan-assembled); the selection/subtree markup clone sinks round through SvgExportFinalizer.roundSvgAttributes; the raster clone sink skips rounding by design (spelling-only, pixel-irrelevant)")}),"defs-deduplication":ct({renderToSvg:ee("finalizeRenderPlan collapses content-identical gradient/pattern/marker defs and rewrites references"),codegen:ye("Codegen backends consume the un-finalized render plan; def duplication in generated components is a code-size concern outside the export contract."),dxf:ye("DXF output has no shared-definition graph in which duplicates could exist."),mermaid:ye("Mermaid output has no shared-definition graph in which duplicates could exist."),pdf:ee("PDF viewbox pages consume the plan-assembled string (core dedup); selection pages pass through SvgExportFinalizer.deduplicateDefsForExport"),"editor-dom":ee("static string exports dedup through core finalizeRenderPlan (plan-assembled); the selection/subtree markup clone sinks run SvgExportFinalizer.deduplicateDefsForExport; the raster clone sink skips dedup by design (spelling-only, pixel-irrelevant)")}),"source-id-restoration":ct({renderToSvg:ee("finalizeRenderPlan restores uncontested library sourceIds and rewrites references"),codegen:ye("Generated components keep collision-safe runtime ids; source ids are a document round-trip concern."),dxf:ye("DXF entities carry no SVG id namespace for source ids to be restored into."),mermaid:ye("Mermaid nodes carry no SVG id namespace for source ids to be restored into."),pdf:ye("PDF output has no id namespace to restore; the intermediate SVG string restores ids for fidelity but the PDF consumer never observes them."),"editor-dom":ee("static string exports restore source ids through core finalizeRenderPlan (plan-assembled); the selection/subtree markup clone sinks run SvgExportFinalizer.restoreSourceIds; the raster clone sink skips restoration by design (ids are spelling, not pixels)")}),"orphan-def-exclusion":ct({renderToSvg:ee("def emission is demand-driven (collectReferencedLibraryDefs, the referenced-marker gate, the paint-server reachability fixed point) \u2014 unreferenced defs are never emitted, so no pruning pass exists or is needed"),codegen:ee("component backends consume the same demand-driven plan def channels"),dxf:ye("DXF output has no defs graph from which orphans could need excluding."),mermaid:ye("Mermaid output has no defs graph from which orphans could need excluding."),pdf:ee("the editor SVG consumed by svg2pdf passes through pruneOrphanedDefs"),"editor-dom":ee("static string exports are demand-driven via the core plan (no orphans emitted); the raster/selection clone sinks sweep accumulated live defs with SvgExportFinalizer.pruneOrphanedDefs")}),"font-embedding":ct({renderToSvg:ee("finalizeRenderPlan ships @font-face CSS from the injected resolveFontEmbedCss hook (core is platform-free; binary resolution is the caller environment responsibility)"),codegen:ye("Generated components inherit the host page font pipeline; embedding binaries in component source is out of contract."),dxf:ye("DXF text styling is font-name based; the format has no font binary embedding."),mermaid:ye("Mermaid delegates font resolution entirely to the rendering host page."),pdf:ee("svg2pdf consumes the editor SVG after embedFontsInClone inlined @font-face CSS"),"editor-dom":ee("static string exports resolve plan-collected families through fontManager into the core resolveFontEmbedCss hook; the embedded-SVG subtree async export runs SvgExportFinalizer.embedFontsInClone; raster sinks rasterize with the session live font faces and need no embedding")}),"initial-value-elision":ct({renderToSvg:ee("finalizeRenderPlan drops redundant spec initials and product defaults under an initial-valued cascade (elideInitialValuesInPlan)"),codegen:ye("Codegen backends consume the un-finalized plan; explicit values in component source are a readability choice, not an export-boundary concern."),dxf:ye("DXF entities carry explicit CAD attributes with no SVG initial-value cascade."),mermaid:ye("Mermaid emits graph syntax; SVG presentation initial values never appear in its output."),pdf:ee("PDF viewbox pages consume the plan-assembled string (core elision); selection pages pass through SvgExportFinalizer.stripDefaultPaintAttributes"),"editor-dom":ee("static string exports elide through core finalizeRenderPlan (plan-assembled); the selection/subtree markup clone sinks run SvgExportFinalizer.stripDefaultPaintAttributes and the output-artifact rules; the raster clone sink keeps default attributes by design (elision is spelling-only)")}),"namespace-declaration-completion":ct({renderToSvg:ee("finalizeRenderPlan declares used prefixes on the root via a well-known URI table (declareUsedNamespacePrefixes); unresolvable prefixes warn undeclarable-namespace-prefix"),codegen:ye("Generated components render into a host document whose framework owns namespace handling; JSX/Vue templates have no xmlns declaration surface to complete."),dxf:ye("DXF is not XML and has no namespace prefixes to declare or complete."),mermaid:ye("Mermaid graph syntax is not XML; no namespace declarations exist."),pdf:ee("svg2pdf consumes the editor SVG string whose serializer declared every namespace it uses"),"editor-dom":ee("static string exports complete declarations through core declareUsedNamespacePrefixes; the raster/selection clone sinks rely on XMLSerializer plus hoistForeignNamespaceDecls")})};function oi(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}async function tf(t,e,n,r){let i=t[e];typeof i=="string"&&(t[e]=await r(i,n))}async function ef(t,e){oi(t)&&await tf(t,"svgContent","svgMarkup",e)}async function nf(t,e){if(!oi(t))return;await tf(t,"href","href",e),await ef(t.fillGradient,e),await ef(t.strokeGradient,e);let n=t.children;if(Array.isArray(n))for(let r of n)oi(r)&&await nf(r.state,e)}async function dM(t,e){if(!oi(t))return;let n=t.shapes;if(Array.isArray(n))for(let o of n)oi(o)&&await nf(o.state,e);let r=t.library;if(Array.isArray(r))for(let o of r)oi(o)&&o.kind==="pattern"&&await ef(o.pattern,e);let i=t.customPatterns;if(Array.isArray(i))for(let o of i)oi(o)&&await tf(o,"svgContent","svgMarkup",e)}function ds(t,e,n={}){let r=ni(t),i=r.errors.filter(o=>!n.ignoreError?.(o));if(i.length>0){let o=i.map(s=>` ${s.path}: ${s.message}`).join(`
10
33
  `);throw new Error(`Invalid .svgs document:
11
- ${a}`)}}return s}function hc(n){return[...n].sort((e,t)=>e.id.localeCompare(t.id))}function nt(n){if(n==null)return n;if(Array.isArray(n))return n.map(nt);if(typeof n!="object")return n;let e={},t=Object.keys(n).sort();for(let r of t)e[r]=nt(n[r]);return e}function gc(n){let e={};return e.id=n.id,e.type=n.type,e.state=nt(n.state),e}var Pe=/\{\{\s*([\w.\-]+)\s*\}\}/g;function Wr(n,e){return n.replace(Pe,(t,r)=>{let i=e[r];return i!==void 0?String(i):t})}function Hr(n,e={}){let t={};if(n.templateVariables)for(let i of n.templateVariables)i.defaultValue!==void 0&&i.defaultValue!==""&&(t[i.name]=i.defaultValue);if(Object.assign(t,e),Object.keys(t).length===0)return JSON.parse(JSON.stringify(n));let r=JSON.parse(JSON.stringify(n));for(let i of r.shapes)kn(i.state,t);if(r.documentMetadata){let i=r.documentMetadata;kn(i,t)}return r}function kn(n,e){for(let t of Object.keys(n)){let r=n[t];if(typeof r=="string"){if(Pe.lastIndex=0,Pe.test(r)){Pe.lastIndex=0;let i=Wr(r,e);if(yc(r)){let s=Number(i);if(!isNaN(s)&&Sc(t)){n[t]=s;continue}}n[t]=i}}else if(Array.isArray(r))for(let i=0;i<r.length;i++)typeof r[i]=="string"?(Pe.lastIndex=0,Pe.test(r[i])&&(Pe.lastIndex=0,r[i]=Wr(r[i],e))):r[i]!==null&&typeof r[i]=="object"&&kn(r[i],e);else r!==null&&typeof r=="object"&&kn(r,e)}}function yc(n){return/^\s*\{\{\s*[\w.\-]+\s*\}\}\s*$/.test(n)}var bc=new Set(["x","y","width","height","radius","rx","ry","cx","cy","x1","y1","x2","y2","fontSize","borderWidth","cornerRadius","opacity","fillOpacity","strokeOpacity",...qt,"letterSpacing","wordSpacing","lineHeight","sides","arms","innerRadiusPercent","armWidthPercent","teeth","toothDepthPercent","holeRadiusPercent","turns","thicknessPercent","direction","headWidthPercent","headLengthPercent","shaftWidthPercent","shiftAngle","dashLength","gapLength","textPathStartOffset","imageOpacity"]);function Sc(n){return bc.has(n)}function jr(n){let e=n.templateVariables??[],t=new Set(e.map(s=>s.name)),r=new Set;for(let s of n.shapes)Tn(s.state,r);n.documentMetadata&&Tn(n.documentMetadata,r);let i=[...r].filter(s=>!t.has(s)).sort();return{defined:[...e],undeclared:i}}function Tn(n,e){for(let t of Object.values(n))if(typeof t=="string"){let r;for(Pe.lastIndex=0;(r=Pe.exec(t))!==null;)e.add(r[1])}else if(Array.isArray(t))for(let r of t)if(typeof r=="string"){let i;for(Pe.lastIndex=0;(i=Pe.exec(r))!==null;)e.add(i[1])}else r!==null&&typeof r=="object"&&Tn(r,e);else t!==null&&typeof t=="object"&&Tn(t,e)}function xc(n){let e={};for(let t of n){let r=t.indexOf("=");if(r===-1)throw new Error(`Invalid variable format: "${t}". Expected "name=value".`);let i=t.slice(0,r).trim(),s=t.slice(r+1);if(!i)throw new Error(`Invalid variable format: "${t}". Variable name cannot be empty.`);e[i]=s}return e}var $c=3,vc=12;function kc(n){return n==null||!Number.isFinite(n)?3:n<0?0:n>12?12:Math.floor(n)}function Xr(n,e){if(!Number.isFinite(n))return n;let t=Math.pow(10,e);return Math.round(n*t)/t}var Tc=/-?\d+(?:\.\d+)?(?:[eE][-+]?\d+)?/g;function Ka(n,e){return n.replace(Tc,t=>{let r=parseFloat(t);return Number.isFinite(r)?String(Xr(r,e)):t})}var wc=new Set(["rawTransform","strokeDasharray","filterX","filterY","filterWidth","filterHeight","cssClipPath"]),Pc=new Set(["metadata","customMetadata","customAttrs","customData","bindings","richTextRuns","richTextData","cssMaskProperties","rawMetadata"]);function Me(n,e,t){if(e==null)return e;if(typeof e=="number")return Xr(e,t);if(typeof e=="string")return wc.has(n)?Ka(e,t):e;if(typeof e=="boolean")return e;if(Array.isArray(e))return e.map(r=>Me(n,r,t));if(typeof e=="object"){if(Pc.has(n))return e;if(n==="symbolOverrides"){let i={};for(let[s,o]of Object.entries(e))i[s]=Me("state",o,t);return i}let r={};for(let[i,s]of Object.entries(e))r[i]=Me(i,s,t);return r}return e}function Kr(n,e){return{id:n.id,type:n.type,state:Me("state",n.state,e)}}function _c(n,e){let t={...n,shapes:n.shapes.map(r=>Kr(r,e)),viewboxes:n.viewboxes.map(r=>Me("viewbox",r,e))};return n.guides&&(t.guides=n.guides.map(r=>Me("guide",r,e))),n.measurements&&(t.measurements=n.measurements.map(r=>Me("measurement",r,e))),n.animationTimeline&&(t.animationTimeline=Me("animationTimeline",n.animationTimeline,e)),n.symbols&&(t.symbols=n.symbols.map(r=>({...r,shapes:r.shapes.map(i=>Kr(i,e))}))),n.markers&&(t.markers=n.markers.map(r=>Me("marker",r,e))),n.customPatterns&&(t.customPatterns=n.customPatterns.map(r=>Me("customPattern",r,e))),t}function Pn(n,e,t=-90){let r=[],i=t*Math.PI/180;for(let s=0;s<n;s++){let o=i+s*2*Math.PI/n;r.push({x:e*Math.cos(o),y:e*Math.sin(o)})}return r}function Zr(n,e,t,r=-90){let i=[],s=e*(t/100),o=r*Math.PI/180;for(let a=0;a<n*2;a++){let l=o+a*Math.PI/n,c=a%2===0?e:s;i.push({x:c*Math.cos(l),y:c*Math.sin(l)})}return i}function Jr(n,e,t=0){let r=n*(e/100)/2,i=[{x:-r,y:-n},{x:r,y:-n},{x:r,y:-r},{x:n,y:-r},{x:n,y:r},{x:r,y:r},{x:r,y:n},{x:-r,y:n},{x:-r,y:r},{x:-n,y:r},{x:-n,y:-r},{x:-r,y:-r}];if(t===0)return i;let s=Math.cos(t*Math.PI/180),o=Math.sin(t*Math.PI/180);return i.map(a=>({x:a.x*s-a.y*o,y:a.x*o+a.y*s}))}function Qr(n,e,t,r,i=-90){let o=n*2*(t/100),a=n*(e/100),l=a*(r/100),c=[{x:n,y:0},{x:n-o,y:-a/2},{x:n-o,y:-l/2},{x:-n,y:-l/2},{x:-n,y:l/2},{x:n-o,y:l/2},{x:n-o,y:a/2}];if(i===0)return c;let f=Math.cos(i*Math.PI/180),d=Math.sin(i*Math.PI/180);return c.map(p=>({x:p.x*f-p.y*d,y:p.x*d+p.y*f}))}function ei(n,e,t,r,i=0){let s=n,o=s*(t/100),a=s*(r/100),l=a/2,c=e*Math.PI/180,f=Math.cos(c),d=Math.sin(c),p=Math.abs(f),m=Math.abs(d),h=Math.max(p,m)||1,g={x:f*(s/h),y:d*(s/h)},b={x:g.x+f*o,y:g.y+d*o},$=Math.min(a,s-l),k=-s+l+$,S=s-l-$,x={x:-s,y:-s},v={x:s,y:-s},w={x:s,y:s},T={x:-s,y:s},P;if(p>=m&&f>0){let N=Math.max(k,Math.min(S,g.y)),B={x:s,y:N-l},D={x:s,y:N+l};P=[x,v,B,b,D,w,T]}else if(p>=m&&f<=0){let N=Math.max(k,Math.min(S,g.y)),B={x:-s,y:N+l},D={x:-s,y:N-l};P=[x,v,w,T,B,b,D]}else if(d<0){let N=Math.max(k,Math.min(S,g.x)),B={x:N-l,y:-s},D={x:N+l,y:-s};P=[x,B,b,D,v,w,T]}else{let N=Math.max(k,Math.min(S,g.x)),B={x:N+l,y:s},D={x:N-l,y:s};P=[x,v,w,B,b,D,T]}if(i===0)return P;let R=Math.cos(i*Math.PI/180),M=Math.sin(i*Math.PI/180);return P.map(N=>({x:N.x*R-N.y*M,y:N.x*M+N.y*R}))}function ti(n,e,t,r,i=0){let s=Math.max(2,Math.round(e)),o=n*(t/100),a=n*(r/100)/2,l=s+1,c=[];for(let g=0;g<l;g++){let b=g/(l-1),$=-n+b*2*n,k=0;g>0&&g<l-1&&(k=g%2===1?o:-o),c.push({x:k,y:$})}let f=[],d=[];for(let g=0;g<l;g++){if(g===0||g===l-1){f.push({...c[g]}),d.push({...c[g]});continue}let b=c[g-1],$=c[g],k=c[g+1],S=$.x-b.x,x=$.y-b.y,v=Math.hypot(S,x)||1,w=S/v,T=x/v,P=k.x-$.x,R=k.y-$.y,M=Math.hypot(P,R)||1,N=P/M,B=R/M,D=(w+N)/2,L=(T+B)/2,K=Math.hypot(D,L),C,ne;K<1e-6?(C=-T,ne=w):(C=-L/K,ne=D/K),f.push({x:$.x-C*a,y:$.y-ne*a}),d.push({x:$.x+C*a,y:$.y+ne*a})}let p=[];p.push(f[0]);for(let g=1;g<l-1;g++)p.push(d[g]);p.push(f[l-1]);for(let g=l-2;g>=1;g--)p.push(f[g]);if(i===0)return p;let m=Math.cos(i*Math.PI/180),h=Math.sin(i*Math.PI/180);return p.map(g=>({x:g.x*m-g.y*h,y:g.x*h+g.y*m}))}function ni(n,e,t,r=0){let i=n,s=Math.max(.3,Math.min(.9,e/100)),o=-i*(t/100),a={x:0,y:i},l={x:0,y:o},c={x:-i*s,y:i*.4},f={x:-i*s,y:-i},d={x:i*s,y:-i},p={x:i*s,y:i*.4},m=[a,c,f,l,d,p,a],h=r===0?m:(()=>{let v=Math.cos(r*Math.PI/180),w=Math.sin(r*Math.PI/180);return m.map(T=>({x:T.x*v-T.y*w,y:T.x*w+T.y*v}))})(),[g,b,$,k,S,x]=h;return`M ${g.x} ${g.y} C ${b.x} ${b.y} ${$.x} ${$.y} ${k.x} ${k.y} C ${S.x} ${S.y} ${x.x} ${x.y} ${g.x} ${g.y} Z`}function ri(n,e,t,r=0){let i=Math.max(3,Math.round(e)),s=Math.max(.3,Math.min(1,t/100)),o=n,a=o*1.7,l=o*1.15,c=[];for(let T=0;T<i;T++){let R=(90+T/i*360)*Math.PI/180;c.push({x:a/2*Math.cos(R),y:-(l/2)*Math.sin(R)})}let f=.15,d=0;for(let T=0;T<i;T++){let P=c[T],R=c[(T+1)%i];d=Math.max(d,Math.hypot(R.x-P.x,R.y-P.y))}let p=d/(2*(1-f))+.001,m=Math.max(p,d*(.68+s*.35)),h=c.map(T=>{let P=T.y/(l/2);return m*(1-f*P)});function g(T){let P=c[T],R=c[(T+1)%i],M=h[T],N=h[(T+1)%i],B=R.x-P.x,D=R.y-P.y,L=Math.hypot(B,D)||1,K=(M*M-N*N+L*L)/(2*L),C=Math.sqrt(Math.max(0,M*M-K*K)),ne=P.x+K/L*B,Q=P.y+K/L*D,Z=-D/L,me=B/L,Y={x:ne+Z*C,y:Q+me*C},W={x:ne-Z*C,y:Q-me*C};return Y.x*Y.x+Y.y*Y.y>W.x*W.x+W.y*W.y?Y:W}let b=[];for(let T=0;T<i;T++)b.push(g(T));let $=14,k=[];for(let T=0;T<i;T++){let P=c[T],R=h[T],M=b[(T-1+i)%i],N=b[T],B=Math.atan2(M.y-P.y,M.x-P.x),L=Math.atan2(N.y-P.y,N.x-P.x)-B;L<=0&&(L+=2*Math.PI);let K=2*Math.PI-L,C=B+L/2,ne=B-K/2,Q={x:P.x+R*Math.cos(C),y:P.y+R*Math.sin(C)},Z={x:P.x+R*Math.cos(ne),y:P.y+R*Math.sin(ne)},Y=Q.x*Q.x+Q.y*Q.y>Z.x*Z.x+Z.y*Z.y?L:-K;for(let W=0;W<$;W++){let de=W/$,he=B+de*Y;k.push({x:P.x+R*Math.cos(he),y:P.y+R*Math.sin(he)})}}let S=0;for(let T of k){let P=Math.max(Math.abs(T.x),Math.abs(T.y));P>S&&(S=P)}if(S>0&&S!==o){let T=o/S;for(let P of k)P.x*=T,P.y*=T}let x=T=>{if(r===0)return T;let P=Math.cos(r*Math.PI/180),R=Math.sin(r*Math.PI/180);return{x:T.x*P-T.y*R,y:T.x*R+T.y*P}},v=k.map(x),w=`M ${v[0].x} ${v[0].y}`;for(let T=1;T<v.length;T++)w+=` L ${v[T].x} ${v[T].y}`;return w+=" Z",w}function Ce(n,e=0,t=0){if(n.length<3)return"";if(e<=0)return n.map((s,o)=>(o===0?"M":"L")+`${s.x},${s.y}`).join(" ")+" Z";let r=Math.min(e,t*.4),i="";for(let s=0;s<n.length;s++){let o=n[(s-1+n.length)%n.length],a=n[s],l=n[(s+1)%n.length],c={x:o.x-a.x,y:o.y-a.y},f=Math.hypot(c.x,c.y);c.x/=f,c.y/=f;let d={x:l.x-a.x,y:l.y-a.y},p=Math.hypot(d.x,d.y);d.x/=p,d.y/=p;let m=Math.min(r,f/2),h=Math.min(r,p/2),g={x:a.x+c.x*m,y:a.y+c.y*m},b={x:a.x+d.x*h,y:a.y+d.y*h};i+=s===0?`M${g.x},${g.y}`:` L${g.x},${g.y}`,i+=` Q${a.x},${a.y} ${b.x},${b.y}`}return i+" Z"}function ii(n,e,t="evenodd"){let r=n*(e/100),i=t==="nonzero"?1:0;return`M ${n} 0 A ${n} ${n} 0 1 1 ${-n} 0 A ${n} ${n} 0 1 1 ${n} 0 Z M ${r} 0 A ${r} ${r} 0 1 ${i} ${-r} 0 A ${r} ${r} 0 1 ${i} ${r} 0 Z`}function si(n,e,t,r=1,i=0){let s=n*(t/100),a=Math.round(e*36),l=e*2*Math.PI,c=(n-s/2)/l,f=i*Math.PI/180,d=[],p=[];for(let g=0;g<=a;g++){let b=g/a,$=b*l*r+f,k=c*(b*l)+s/2,S=s/2;d.push({x:(k+S*.3)*Math.cos($),y:(k+S*.3)*Math.sin($)}),p.push({x:Math.max(0,k-S*.3)*Math.cos($),y:Math.max(0,k-S*.3)*Math.sin($)})}let m=`M ${d[0].x} ${d[0].y}`;for(let g=1;g<d.length;g++)m+=` L ${d[g].x} ${d[g].y}`;let h=p[p.length-1];m+=` L ${h.x} ${h.y}`;for(let g=p.length-2;g>=0;g--)m+=` L ${p[g].x} ${p[g].y}`;return m+=" Z",m}var Rc=.2;function Xa(n,e,t,r=0){let i=e*(t/100),s=e,o=e-i,a=2*Math.PI/n,l=a*Rc/2,c=a/4,f=r*Math.PI/180,d=[];for(let p=0;p<n;p++){let m=f+p*a;d.push({x:o*Math.cos(m),y:o*Math.sin(m)}),d.push({x:s*Math.cos(m+c-l),y:s*Math.sin(m+c-l)}),d.push({x:s*Math.cos(m+c+l),y:s*Math.sin(m+c+l)}),d.push({x:o*Math.cos(m+a/2),y:o*Math.sin(m+a/2)})}return d}function ai(n,e,t,r=0,i=0,s="evenodd",o=0){let a=Xa(n,e,t,o),l=Math.min(r,e*.1),c=Ce(a,l,e);if(i>0){let f=e*(i/100),d=s==="nonzero"?1:0;c+=` M ${f} 0 A ${f} ${f} 0 1 ${d} ${-f} 0 A ${f} ${f} 0 1 ${d} ${f} 0 Z`}return c}function oi(n,e,t,r,i,s="round",o="uniform",a){let l=Math.min(t,r)/2,c,f,d,p,m,h,g,b;if(o==="non-uniform"&&a?(c=Math.min(a.radiusTL??i,l),f=Math.min(a.radiusTR??i,l),d=Math.min(a.radiusBR??i,l),p=Math.min(a.radiusBL??i,l),m=a.shapeTL??s,h=a.shapeTR??s,g=a.shapeBR??s,b=a.shapeBL??s):(c=f=d=p=Math.min(i,l),m=h=g=b=s),!(s!=="round"||o==="non-uniform"||c>0&&m!=="round"||f>0&&h!=="round"||d>0&&g!=="round"||p>0&&b!=="round")&&c===f&&f===d&&d===p)return null;let k=`M${n+c},${e}`;return k+=` L${n+t-f},${e}`,k+=wn(h,f,n+t,e,"tr"),k+=` L${n+t},${e+r-d}`,k+=wn(g,d,n+t,e+r,"br"),k+=` L${n+p},${e+r}`,k+=wn(b,p,n,e+r,"bl"),k+=` L${n},${e+c}`,k+=wn(m,c,n,e,"tl"),k+=" Z",k}function wn(n,e,t,r,i){if(e<=0)return"";switch(n){case"round":switch(i){case"tr":return` A${e},${e} 0 0 1 ${t},${r+e}`;case"br":return` A${e},${e} 0 0 1 ${t-e},${r}`;case"bl":return` A${e},${e} 0 0 1 ${t},${r-e}`;case"tl":return` A${e},${e} 0 0 1 ${t+e},${r}`}break;case"scoop":switch(i){case"tr":return` A${e},${e} 0 0 0 ${t},${r+e}`;case"br":return` A${e},${e} 0 0 0 ${t-e},${r}`;case"bl":return` A${e},${e} 0 0 0 ${t},${r-e}`;case"tl":return` A${e},${e} 0 0 0 ${t+e},${r}`}break;case"bevel":switch(i){case"tr":return` L${t},${r+e}`;case"br":return` L${t-e},${r}`;case"bl":return` L${t},${r-e}`;case"tl":return` L${t+e},${r}`}break;case"notch":switch(i){case"tr":return` L${t-e},${r+e} L${t},${r+e}`;case"br":return` L${t-e},${r-e} L${t-e},${r}`;case"bl":return` L${t+e},${r-e} L${t},${r-e}`;case"tl":return` L${t+e},${r+e} L${t+e},${r}`}break}return""}function li(n,e,t,r,i,s={}){let o=e+r/2,a=t+i/2;switch(n){case"diamond":return`M${o},${t} L${e+r},${a} L${o},${t+i} L${e},${a} Z`;case"parallelogram":{let l=(s.slantPercent??20)/100*r;return`M${e+l},${t} L${e+r},${t} L${e+r-l},${t+i} L${e},${t+i} Z`}case"trapezoid":{let l=(s.topWidthPercent??70)/100*r,c=(r-l)/2;return`M${e+c},${t} L${e+c+l},${t} L${e+r},${t+i} L${e},${t+i} Z`}case"terminator":{let l=i/2;return`M${e+l},${t} L${e+r-l},${t} A${l},${l} 0 0 1 ${e+r-l},${t+i} L${e+l},${t+i} A${l},${l} 0 0 1 ${e+l},${t} Z`}case"cylinder":{let l=r/2,c=Math.min((s.capHeightPercent??15)/100*i,i/2);return`M${e},${t+c} A${l},${c} 0 0 1 ${e+r},${t+c} A${l},${c} 0 0 1 ${e},${t+c} L${e},${t+i-c} A${l},${c} 0 0 0 ${e+r},${t+i-c} L${e+r},${t+c} M${o-l},${t+c} A${l},${c} 0 0 0 ${o+l},${t+c}`}case"document-shape":{let l=(s.waveAmplitudePercent??15)/100*i;return`M${e},${t} L${e+r},${t} L${e+r},${t+i} C${e+r*.75},${t+i-l*2} ${o+r*.25},${t+i+l} ${o},${t+i} C${o-r*.25},${t+i-l} ${e+r*.25},${t+i+l*.5} ${e},${t+i} Z`}}}function rt(n,e,t=!1,r=.5,i){if(n.length<2)return n.length===1?`M ${n[0].x} ${n[0].y}`:"";switch(e){case"CATMULL_ROM":case"catmull-rom":return Cc(n,t,r);case"BASIS":case"basis":return Dc(n,t);case"ARC":case"arc":return i&&i.length>0?Ac(n,t,i):Wt(n,t,"CUBIC");case"LINEAR":case"linear":return Wt(n,t,"LINEAR");case"QUADRATIC":case"quadratic":return Wt(n,t,"QUADRATIC");case"CUBIC":case"cubic":return Wt(n,t,"CUBIC");default:return Wt(n,t)}}function Ac(n,e,t){let r=`M ${n[0].x} ${n[0].y}`,i=0,s={rx:50,ry:50,rotation:0,largeArc:!1,sweep:!0};for(let o=0;o<n.length-1;o++){let a=n[o+1];if(a.isSubpathStart){if(e&&o-i>=1){let c=n[i],f=t?.[o]??s;r+=` A ${f.rx} ${f.ry} ${f.rotation} ${f.largeArc?1:0} ${f.sweep?1:0} ${c.x} ${c.y} Z`}r+=` M ${a.x} ${a.y}`,i=o+1;continue}let l=t?.[o]??s;r+=` A ${l.rx} ${l.ry} ${l.rotation} ${l.largeArc?1:0} ${l.sweep?1:0} ${a.x} ${a.y}`}if(e&&n.length-i>1){let o=n[i],a=t?.[n.length-1]??s;r+=` A ${a.rx} ${a.ry} ${a.rotation} ${a.largeArc?1:0} ${a.sweep?1:0} ${o.x} ${o.y} Z`}return r}function Wt(n,e,t){let r=`M ${n[0].x} ${n[0].y}`,i=0,s=null,o=null;for(let a=0;a<n.length-1;a++){let l=n[a],c=n[a+1];if(c.isSubpathStart){if(e&&a-i>=1){let d=n[i];r+=Yr(l,d,d.segmentType,s,o,t),r+=" Z"}r+=` M ${c.x} ${c.y}`,i=a+1,s=null,o=null;continue}r+=Yr(l,c,c.segmentType,s,o,t);let f=Mc(c.segmentType??t,l,c);s=f,f==="quad"?o=l.handleOut??null:o=null}if(e&&n.length-i>1){let a=n[n.length-1],l=n[i],c=(l.segmentType??t??(a.handleOut||l.handleIn?"CUBIC":"LINEAR")).toUpperCase();c==="LINEAR"||c==="HORIZONTAL"||c==="VERTICAL"||(r+=Yr(a,l,l.segmentType,s,o,t)),r+=" Z"}return r}var Ic=.001;function xt(n,e){return Math.abs(n-e)<Ic}function Mc(n,e,t){let r=(n??(e.handleOut||t.handleIn?"CUBIC":"LINEAR")).toUpperCase();return r==="CUBIC"||r==="SMOOTH_CUBIC"?"cubic":r==="QUADRATIC"||r==="SMOOTH_QUADRATIC"?"quad":null}function Yr(n,e,t,r,i,s){let o=(t??s??(n.handleOut||e.handleIn?"CUBIC":"LINEAR")).toUpperCase();if(o==="LINEAR"||o==="HORIZONTAL"||o==="VERTICAL")return(o==="HORIZONTAL"||o==="LINEAR")&&xt(n.y,e.y)?` H ${e.x}`:(o==="VERTICAL"||o==="LINEAR")&&xt(n.x,e.x)?` V ${e.y}`:` L ${e.x} ${e.y}`;if(o==="ARC"){let c=e.arcParams;return c?` A ${c.rx} ${c.ry} ${c.rotation} ${c.largeArc?1:0} ${c.sweep?1:0} ${e.x} ${e.y}`:` L ${e.x} ${e.y}`}if(o==="QUADRATIC"||o==="SMOOTH_QUADRATIC"){let c=n.handleOut??{x:(n.x+e.x)/2,y:(n.y+e.y)/2};return r==="quad"&&i&&xt(c.x,2*n.x-i.x)&&xt(c.y,2*n.y-i.y)?` T ${e.x} ${e.y}`:` Q ${c.x} ${c.y} ${e.x} ${e.y}`}let a=n.handleOut??{x:n.x,y:n.y},l=e.handleIn??{x:e.x,y:e.y};return r==="cubic"&&n.handleIn&&n.handleOut&&xt(n.handleOut.x,2*n.x-n.handleIn.x)&&xt(n.handleOut.y,2*n.y-n.handleIn.y)?` S ${l.x} ${l.y} ${e.x} ${e.y}`:` C ${a.x} ${a.y} ${l.x} ${l.y} ${e.x} ${e.y}`}function Cc(n,e,t){if(n.length<2)return n.length===1?`M ${n[0].x} ${n[0].y}`:"";let r=t,i=e?[n[n.length-1],...n,n[0],n[1]]:[n[0],...n,n[n.length-1]],s=`M ${n[0].x} ${n[0].y}`,o=e?n.length:n.length-1;for(let a=0;a<o;a++){let l=i[a],c=i[a+1],f=i[a+2],d=i[a+3],p=Math.hypot(f.x-c.x,f.y-c.y),m=Math.hypot(c.x-l.x,c.y-l.y),h=Math.hypot(d.x-f.x,d.y-f.y),g=Math.pow(m,r),b=Math.pow(p,r),$=Math.pow(h,r),k=Math.pow(m,2*r),S=Math.pow(p,2*r),x=Math.pow(h,2*r),v,w,T,P;m<1e-8?(v=c.x,w=c.y):(v=(k*f.x-S*l.x+(2*k+3*g*b+S)*c.x)/(3*g*(g+b)),w=(k*f.y-S*l.y+(2*k+3*g*b+S)*c.y)/(3*g*(g+b))),h<1e-8?(T=f.x,P=f.y):(T=(x*c.x-S*d.x+(2*x+3*$*b+S)*f.x)/(3*$*($+b)),P=(x*c.y-S*d.y+(2*x+3*$*b+S)*f.y)/(3*$*($+b))),s+=` C ${v} ${w} ${T} ${P} ${f.x} ${f.y}`}return e&&(s+=" Z"),s}function Dc(n,e){let t=n.length;if(t<2)return t===1?`M ${n[0].x} ${n[0].y}`:"";if(t===2)return`M ${n[0].x} ${n[0].y} L ${n[1].x} ${n[1].y}`;if(e){let s=(n[0].x+4*n[1].x+n[2].x)/6,o=(n[0].y+4*n[1].y+n[2].y)/6,a=`M ${s} ${o}`;for(let l=0;l<t;l++){let c=n[(l+1)%t],f=n[(l+2)%t],d=n[(l+3)%t];a+=qr(c,f,d)}return a+=" Z",a}let r=n,i=`M ${r[0].x} ${r[0].y}`;i+=` L ${(5*r[0].x+r[1].x)/6} ${(5*r[0].y+r[1].y)/6}`;for(let s=0;s<=t-3;s++)i+=qr(r[s],r[s+1],r[s+2]);return i+=qr(r[t-2],r[t-1],r[t-1]),i+=` L ${r[t-1].x} ${r[t-1].y}`,i}function qr(n,e,t){return` C ${(2*n.x+e.x)/3} ${(2*n.y+e.y)/3} ${(n.x+2*e.x)/3} ${(n.y+2*e.y)/3} ${(n.x+4*e.x+t.x)/6} ${(n.y+4*e.y+t.y)/6}`}function Ht(n,e,t){let r=Number.isFinite(e)?Math.max(1,e):8,i=Number.isFinite(t)?Math.max(1,t):4;switch(n){case"dashed":case"dotted":case"custom":return`${r} ${i}`;default:return null}}var Fc=[["fontVariant","font-variant"],["fontVariantLigatures","font-variant-ligatures"],["fontVariantPosition","font-variant-position"],["fontVariantCaps","font-variant-caps"],["fontVariantNumeric","font-variant-numeric"],["fontVariantEastAsian","font-variant-east-asian"]];function q(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function Ec(n){let e=n.fillType;return e||(n.fillGradient?n.fillGradient.r!==void 0?"radial-gradient":"linear-gradient":n.linearGradient?"linear-gradient":n.radialGradient?"radial-gradient":"solid")}function _n(n){let e=new Map,t=n.state,r=t;switch(n.type){case"circle":e.set("cx",String(t.x??0)),e.set("cy",String(t.y??0)),e.set("r",String(t.radius??50));break;case"ellipse":e.set("cx",String(t.cx??0)),e.set("cy",String(t.cy??0)),e.set("rx",String(t.rx??50)),e.set("ry",String(t.ry??30));break;case"rectangle":case"square":e.set("x",String(t.x??0)),e.set("y",String(t.y??0)),e.set("width",String(t.width??100)),e.set("height",String(t.height??100));{let x=t.rx??t.cornerRadius??0,v=t.ry??t.cornerRadius??0;(x>0||v>0)&&(e.set("rx",String(x)),e.set("ry",String(v)))}break;case"line":e.set("x1",String(t.x1??0)),e.set("y1",String(t.y1??0)),e.set("x2",String(t.x2??0)),e.set("y2",String(t.y2??0));break;case"text":e.set("x",String(t.x??0)),e.set("y",String(t.y??0)),t.fontSize&&e.set("font-size",String(t.fontSize)),t.fontFamily&&e.set("font-family",t.fontFamily),t.fontWeight&&e.set("font-weight",String(t.fontWeight)),t.fontStyle&&e.set("font-style",t.fontStyle),t.textAnchor&&e.set("text-anchor",t.textAnchor),t.letterSpacing&&e.set("letter-spacing",String(t.letterSpacing));{let x=Fc.map(([v,w])=>{let T=typeof t[v]=="string"?String(t[v]).trim():"";return T?`${w}: ${T}`:""}).filter(Boolean).join("; ");x&&e.set("style",x)}break;case"image":e.set("x",String(t.x??0)),e.set("y",String(t.y??0)),e.set("width",String(t.width??100)),e.set("height",String(t.height??100)),r.href&&e.set("href",String(r.href));break}let i=Ec(r);i==="none"?e.set("fill","none"):i==="linear-gradient"||i==="radial-gradient"?e.set("fill",`url(#gradient-fill-${n.id})`):i==="pattern"?e.set("fill",`url(#pattern-fill-${n.id})`):e.set("fill",t.fillColor??"#000000");let s=t.opacity;s!==void 0&&s<1&&e.set("opacity",String(s));let o=t.fillOpacity;o!==void 0&&o<1&&e.set("fill-opacity",String(o)),t.fillRule&&t.fillRule!=="nonzero"&&e.set("fill-rule",t.fillRule);let a=r.strokeType??"solid";if(a==="none")e.set("stroke","none");else if(a==="linear-gradient"||a==="radial-gradient")e.set("stroke",`url(#gradient-stroke-${n.id})`);else{let x=t.borderColor??"none";x!=="none"&&e.set("stroke",x)}let l=t.borderWidth;l!=null&&l!==0&&e.set("stroke-width",String(l));let c=t.strokeOpacity;c!==void 0&&c<1&&e.set("stroke-opacity",String(c));let f=t.lineStyle??"solid",d=t.dashLength??8,p=t.gapLength??4,m=Ht(f,d,p);m&&(e.set("stroke-dasharray",m),f==="dotted"&&e.set("stroke-linecap","round"));let h=Oc(r);h&&e.set("transform",h);let g=r.filters;g&&g.length>0&&e.set("filter",`url(#filter-${n.id})`);let b=t.shapeRendering;b&&b!=="auto"&&e.set("shape-rendering",b),t.pathLength!==void 0&&e.set("pathLength",String(t.pathLength));let $=r.startEndpoint,k=r.endEndpoint;$&&$!=="none"&&e.set("marker-start",`url(#line-marker-${$})`),k&&k!=="none"&&e.set("marker-end",`url(#line-marker-${k})`);let S=r.metadata;return S&&(S.role&&e.set("role",S.role),S.ariaLabel&&e.set("aria-label",S.ariaLabel)),e}function Ya(n){switch(n.type){case"circle":return"circle";case"ellipse":return"ellipse";case"rectangle":case"square":return"rect";case"line":return"line";case"text":return"text";case"image":return"image";case"path":case"polyline":case"triangle":case"ngon":case"star":case"cross":case"ring":case"spiral":case"gear":case"arrow":return"path";default:return"g"}}function Oc(n){return Gt(n)}function De(n,e){let t=n.viewboxes?.[0];return{width:e.width??t?.width??800,height:e.height??t?.height??600}}function u(n,e){return e==null||e===""?"":` ${n}="${q(String(e))}"`}function An(n){let e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);return e?{r:parseInt(e[1],16)/255,g:parseInt(e[2],16)/255,b:parseInt(e[3],16)/255}:{r:0,g:0,b:0}}function Lc(n,e,t){let{offsetX:r,offsetY:i,blurRadius:s,spread:o,color:a,opacity:l}=n,c="";if(o===0)c+=`<feDropShadow${u("in",e)}${u("dx",r)}${u("dy",i)}${u("stdDeviation",s/2)}${u("flood-color",a)}${u("flood-opacity",l)}${u("result",`${t}_shadow`)}/>`,c+=`<feMerge${u("result",t)}><feMergeNode${u("in",`${t}_shadow`)}/><feMergeNode${u("in",e)}/></feMerge>`;else{c+=`<feColorMatrix${u("in",e)}${u("type","matrix")}${u("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0")}${u("result",`${t}_alpha`)}/>`;let f=o>0?"dilate":"erode",d=Math.abs(o);c+=`<feMorphology${u("in",`${t}_alpha`)}${u("operator",f)}${u("radius",d)}${u("result",`${t}_spread`)}/>`,c+=`<feGaussianBlur${u("in",`${t}_spread`)}${u("stdDeviation",s/2)}${u("result",`${t}_blur`)}/>`,c+=`<feOffset${u("in",`${t}_blur`)}${u("dx",r)}${u("dy",i)}${u("result",`${t}_offset`)}/>`,c+=`<feFlood${u("flood-color",a)}${u("flood-opacity",l)}${u("result",`${t}_color`)}/>`,c+=`<feComposite${u("in",`${t}_color`)}${u("in2",`${t}_offset`)}${u("operator","in")}${u("result",`${t}_shadow`)}/>`,c+=`<feMerge${u("result",t)}><feMergeNode${u("in",`${t}_shadow`)}/><feMergeNode${u("in",e)}/></feMerge>`}return c}function Nc(n,e,t){let{offsetX:r,offsetY:i,blurRadius:s,choke:o,color:a,opacity:l}=n,c=s*(1-o/100),f="";return f+=`<feColorMatrix${u("in",e)}${u("type","matrix")}${u("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0")}${u("result",`${t}_alpha`)}/>`,f+=`<feComponentTransfer${u("in",`${t}_alpha`)}${u("result",`${t}_inverted`)}><feFuncA${u("type","table")}${u("tableValues","1 0")}/></feComponentTransfer>`,f+=`<feGaussianBlur${u("in",`${t}_inverted`)}${u("stdDeviation",c/2)}${u("result",`${t}_blur`)}/>`,f+=`<feOffset${u("in",`${t}_blur`)}${u("dx",r)}${u("dy",i)}${u("result",`${t}_offset`)}/>`,f+=`<feFlood${u("flood-color",a)}${u("flood-opacity",l)}${u("result",`${t}_color`)}/>`,f+=`<feComposite${u("in",`${t}_color`)}${u("in2",`${t}_offset`)}${u("operator","in")}${u("result",`${t}_coloredShadow`)}/>`,f+=`<feComposite${u("in",`${t}_coloredShadow`)}${u("in2",`${t}_alpha`)}${u("operator","in")}${u("result",`${t}_innerShadow`)}/>`,f+=`<feComposite${u("in",`${t}_innerShadow`)}${u("in2",e)}${u("operator","over")}${u("result",t)}/>`,f}function Bc(n,e,t){let{blurX:r,blurY:i}=n;return r===0&&i===0?H(e,t):`<feGaussianBlur${u("in",e)}${u("stdDeviation",`${r/2} ${i/2}`)}${u("result",t)}/>`}function zc(n,e,t){let{distance:r,angle:i}=n;if(r===0)return H(e,t);let s=i*Math.PI/180,o=Math.abs(Math.cos(s)*r),a=Math.abs(Math.sin(s)*r);return`<feGaussianBlur${u("in",e)}${u("stdDeviation",`${o/2} ${a/2}`)}${u("result",t)}/>`}function qa(n,e,t){let{x:r,y:i,z:s,color:o,surfaceScale:a,diffuseConstant:l,specularConstant:c,specularExponent:f}=n,d="";return d+=`<feDiffuseLighting${u("in","SourceAlpha")}${u("surfaceScale",a)}${u("diffuseConstant",l)}${u("lighting-color",o)}${u("result",`${t}_diffuse`)}>`,d+=`<fePointLight${u("x",r)}${u("y",i)}${u("z",s)}/>`,d+="</feDiffuseLighting>",d+=`<feSpecularLighting${u("in","SourceAlpha")}${u("surfaceScale",a)}${u("specularConstant",c)}${u("specularExponent",f)}${u("lighting-color",o)}${u("result",`${t}_specular`)}>`,d+=`<fePointLight${u("x",r)}${u("y",i)}${u("z",s)}/>`,d+="</feSpecularLighting>",d+=`<feComposite${u("in",e)}${u("in2",`${t}_diffuse`)}${u("operator","arithmetic")}${u("k1",1)}${u("k2",0)}${u("k3",0)}${u("k4",0)}${u("result",`${t}_lit`)}/>`,d+=`<feComposite${u("in",`${t}_specular`)}${u("in2",`${t}_lit`)}${u("operator","arithmetic")}${u("k1",0)}${u("k2",1)}${u("k3",1)}${u("k4",0)}${u("result",t)}/>`,d}function Za(n,e,t){let{x:r,y:i,z:s,pointsAtX:o,pointsAtY:a,pointsAtZ:l,coneAngle:c,color:f,surfaceScale:d,specularConstant:p,specularExponent:m}=n,h="";return h+=`<feSpecularLighting${u("in","SourceAlpha")}${u("surfaceScale",d)}${u("specularConstant",p)}${u("specularExponent",m)}${u("lighting-color",f)}${u("result",`${t}_specular`)}>`,h+=`<feSpotLight${u("x",r)}${u("y",i)}${u("z",s)}${u("pointsAtX",o)}${u("pointsAtY",a)}${u("pointsAtZ",l)}${u("limitingConeAngle",c)}/>`,h+="</feSpecularLighting>",h+=`<feComposite${u("in",`${t}_specular`)}${u("in2","SourceAlpha")}${u("operator","in")}${u("result",`${t}_clipped`)}/>`,h+=`<feComposite${u("in",`${t}_clipped`)}${u("in2",e)}${u("operator","arithmetic")}${u("k1",0)}${u("k2",1)}${u("k3",1)}${u("k4",0)}${u("result",t)}/>`,h}function Ja(n){switch(n.kind){case"point":return`<fePointLight${u("x",n.x)}${u("y",n.y)}${u("z",n.z)}/>`;case"spot":{let e=`<feSpotLight${u("x",n.x)}${u("y",n.y)}${u("z",n.z)}${u("pointsAtX",n.pointsAtX)}${u("pointsAtY",n.pointsAtY)}${u("pointsAtZ",n.pointsAtZ)}`;return n.limitingConeAngle!==void 0&&(e+=u("limitingConeAngle",n.limitingConeAngle)),n.specularExponent!==void 0&&(e+=u("specularExponent",n.specularExponent)),e+"/>"}case"distant":return`<feDistantLight${u("azimuth",n.azimuth)}${u("elevation",n.elevation)}/>`}}function Gc(n,e,t){return`<feDiffuseLighting${u("in",e)}${u("surfaceScale",n.surfaceScale)}${u("diffuseConstant",n.diffuseConstant)}${u("lighting-color",n.color)}${u("result",t)}>`+Ja(n.lightSource)+"</feDiffuseLighting>"}function Vc(n,e,t){return`<feSpecularLighting${u("in",e)}${u("surfaceScale",n.surfaceScale)}${u("specularConstant",n.specularConstant)}${u("specularExponent",n.specularExponent)}${u("lighting-color",n.color)}${u("result",t)}>`+Ja(n.lightSource)+"</feSpecularLighting>"}function Uc(n,e,t){let{width:r,color:i,opacity:s,position:o}=n,a="";if(o==="inside")a+=`<feMorphology${u("in","SourceAlpha")}${u("operator","erode")}${u("radius",r)}${u("result",`${t}_eroded`)}/>`,a+=`<feComposite${u("in","SourceAlpha")}${u("in2",`${t}_eroded`)}${u("operator","out")}${u("result",`${t}_outlineAlpha`)}/>`,a+=`<feFlood${u("flood-color",i)}${u("flood-opacity",s)}${u("result",`${t}_color`)}/>`,a+=`<feComposite${u("in",`${t}_color`)}${u("in2",`${t}_outlineAlpha`)}${u("operator","in")}${u("result",`${t}_outline`)}/>`,a+=`<feComposite${u("in",`${t}_outline`)}${u("in2",e)}${u("operator","over")}${u("result",t)}/>`;else{let l=o==="outside"?r:r/2;a+=`<feMorphology${u("in","SourceAlpha")}${u("operator","dilate")}${u("radius",l)}${u("result",`${t}_dilated`)}/>`,a+=`<feComposite${u("in",`${t}_dilated`)}${u("in2","SourceAlpha")}${u("operator","out")}${u("result",`${t}_outlineAlpha`)}/>`,a+=`<feFlood${u("flood-color",i)}${u("flood-opacity",s)}${u("result",`${t}_color`)}/>`,a+=`<feComposite${u("in",`${t}_color`)}${u("in2",`${t}_outlineAlpha`)}${u("operator","in")}${u("result",`${t}_outline`)}/>`,a+=`<feMerge${u("result",t)}><feMergeNode${u("in",`${t}_outline`)}/><feMergeNode${u("in",e)}/></feMerge>`}return a}function Wc(n,e,t){let{amount:r}=n;if(r===0)return H(e,t);let i=1+4*r,s=-r,o=[0,s,0,s,i,s,0,s,0].join(" ");return`<feConvolveMatrix${u("in",e)}${u("order","3")}${u("kernelMatrix",o)}${u("divisor","1")}${u("bias","0")}${u("preserveAlpha","true")}${u("edgeMode","duplicate")}${u("result",t)}/>`}function Hc(n,e,t){let{blockSize:r}=n;if(r<=1)return H(e,t);let i=r/2,s="";return s+=`<feMorphology${u("in",e)}${u("operator","erode")}${u("radius",i)}${u("result",`${t}_eroded`)}/>`,s+=`<feMorphology${u("in",`${t}_eroded`)}${u("operator","dilate")}${u("radius",i)}${u("result",t)}/>`,s}function jc(n,e,t){let{scale:r,frequency:i,octaves:s,warpType:o}=n;if(r===0)return H(e,t);let a="";return a+=`<feTurbulence${u("type",o)}${u("baseFrequency",i)}${u("numOctaves",s)}${u("seed",0)}${u("result",`${t}_turbulence`)}/>`,a+=`<feDisplacementMap${u("in",e)}${u("in2",`${t}_turbulence`)}${u("scale",r)}${u("xChannelSelector","R")}${u("yChannelSelector","G")}${u("result",t)}/>`,a}function Kc(n,e,t){let{operator:r,radiusX:i,radiusY:s}=n;return i===0&&s===0?H(e,t):`<feMorphology${u("in",e)}${u("operator",r)}${u("radius",`${i} ${s}`)}${u("result",t)}/>`}function Xc(n,e,t){let{levels:r}=n;if(r<2)return H(e,t);let i=[];for(let a=0;a<r;a++)i.push(a/(r-1));let s=i.join(" "),o=`<feComponentTransfer${u("in",e)}${u("result",t)}>`;return o+=`<feFuncR${u("type","discrete")}${u("tableValues",s)}/>`,o+=`<feFuncG${u("type","discrete")}${u("tableValues",s)}/>`,o+=`<feFuncB${u("type","discrete")}${u("tableValues",s)}/>`,o+="</feComponentTransfer>",o}function Yc(n,e,t){let{levels:r,contrast:i}=n;if(r<2)return H(e,t);let s=[];for(let l=0;l<r;l++){let c=l/(r-1),f=c;i!==1&&(f=.5+(c-.5)*i,f=Math.max(0,Math.min(1,f))),s.push(f)}let o=s.join(" "),a=`<feComponentTransfer${u("in",e)}${u("result",t)}>`;return a+=`<feFuncR${u("type","table")}${u("tableValues",o)}/>`,a+=`<feFuncG${u("type","table")}${u("tableValues",o)}/>`,a+=`<feFuncB${u("type","table")}${u("tableValues",o)}/>`,a+="</feComponentTransfer>",a}function qc(n,e,t){let{radius:r}=n;if(r===0)return H(e,t);let i="";return i+=`<feGaussianBlur${u("in","SourceAlpha")}${u("stdDeviation",r)}${u("result",`${t}_blurredAlpha`)}/>`,i+=`<feComponentTransfer${u("in",`${t}_blurredAlpha`)}${u("result",`${t}_thresholdAlpha`)}><feFuncA${u("type","linear")}${u("slope",20)}${u("intercept",-9)}/></feComponentTransfer>`,i+=`<feComposite${u("in",e)}${u("in2",`${t}_thresholdAlpha`)}${u("operator","in")}${u("result",t)}/>`,i}function Zc(n,e,t){let{amount:r}=n;if(r===0)return H(e,t);let i=1-r;return`<feColorMatrix${u("color-interpolation-filters","sRGB")}${u("in",e)}${u("type","saturate")}${u("values",i)}${u("result",t)}/>`}function Jc(n,e,t){let{red:r,green:i,blue:s}=n;if(r===1&&i===1&&s===1)return H(e,t);let o=`<feComponentTransfer${u("in",e)}${u("result",t)}>`;return o+=`<feFuncR${u("type","linear")}${u("slope",r)}${u("intercept",0)}/>`,o+=`<feFuncG${u("type","linear")}${u("slope",i)}${u("intercept",0)}/>`,o+=`<feFuncB${u("type","linear")}${u("slope",s)}${u("intercept",0)}/>`,o+="</feComponentTransfer>",o}function Qc(n,e,t){let{amount:r}=n;if(r===1)return H(e,t);let i=`<feComponentTransfer${u("color-interpolation-filters","sRGB")}${u("in",e)}${u("result",t)}>`;return i+=`<feFuncR${u("type","linear")}${u("slope",r)}${u("intercept",0)}/>`,i+=`<feFuncG${u("type","linear")}${u("slope",r)}${u("intercept",0)}/>`,i+=`<feFuncB${u("type","linear")}${u("slope",r)}${u("intercept",0)}/>`,i+="</feComponentTransfer>",i}function ed(n,e,t){let{amount:r}=n;if(r===1)return H(e,t);let i=.5*(1-r),s=`<feComponentTransfer${u("color-interpolation-filters","sRGB")}${u("in",e)}${u("result",t)}>`;return s+=`<feFuncR${u("type","linear")}${u("slope",r)}${u("intercept",i)}/>`,s+=`<feFuncG${u("type","linear")}${u("slope",r)}${u("intercept",i)}/>`,s+=`<feFuncB${u("type","linear")}${u("slope",r)}${u("intercept",i)}/>`,s+="</feComponentTransfer>",s}function td(n,e,t){let{amount:r}=n;if(r===1)return H(e,t);let i=`<feComponentTransfer${u("color-interpolation-filters","sRGB")}${u("in",e)}${u("result",t)}>`;return i+=`<feFuncA${u("type","linear")}${u("slope",r)}${u("intercept",0)}/>`,i+="</feComponentTransfer>",i}function nd(n,e,t){let{amount:r}=n;if(r===0)return H(e,t);let i=r,s=1-r,o=`${i} ${s}`,a=`<feComponentTransfer${u("color-interpolation-filters","sRGB")}${u("in",e)}${u("result",t)}>`;return a+=`<feFuncR${u("type","table")}${u("tableValues",o)}/>`,a+=`<feFuncG${u("type","table")}${u("tableValues",o)}/>`,a+=`<feFuncB${u("type","table")}${u("tableValues",o)}/>`,a+="</feComponentTransfer>",a}function rd(n,e,t){let{angle:r}=n;return r===0||r===360?H(e,t):`<feColorMatrix${u("color-interpolation-filters","sRGB")}${u("in",e)}${u("type","hueRotate")}${u("values",r)}${u("result",t)}/>`}function id(n,e,t){let{amount:r}=n;return r===1?H(e,t):`<feColorMatrix${u("color-interpolation-filters","sRGB")}${u("in",e)}${u("type","saturate")}${u("values",r)}${u("result",t)}/>`}function sd(n,e,t){let{threshold:r}=n,i="";if(i+=`<feColorMatrix${u("in",e)}${u("type","saturate")}${u("values",0)}${u("result",`${t}_gray`)}/>`,r===.5)i+=`<feComponentTransfer${u("in",`${t}_gray`)}${u("result",t)}>`,i+=`<feFuncR${u("type","discrete")}${u("tableValues","0 1")}/>`,i+=`<feFuncG${u("type","discrete")}${u("tableValues","0 1")}/>`,i+=`<feFuncB${u("type","discrete")}${u("tableValues","0 1")}/>`,i+="</feComponentTransfer>";else{let o=[];for(let l=0;l<256;l++)o.push(l/255<r?0:1);let a=o.join(" ");i+=`<feComponentTransfer${u("in",`${t}_gray`)}${u("result",t)}>`,i+=`<feFuncR${u("type","table")}${u("tableValues",a)}/>`,i+=`<feFuncG${u("type","table")}${u("tableValues",a)}/>`,i+=`<feFuncB${u("type","table")}${u("tableValues",a)}/>`,i+="</feComponentTransfer>"}return i}function ad(n,e,t){let{amount:r}=n;if(r===0)return H(e,t);let i=[.393,.769,.189,0,0],s=[.349,.686,.168,0,0],o=[.272,.534,.131,0,0],a=[1,0,0,0,0],l=[0,1,0,0,0],c=[0,0,1,0,0],f=(g,b)=>g.map(($,k)=>$*(1-r)+b[k]*r),d=f(a,i),p=f(l,s),m=f(c,o),h=[...d,...p,...m,0,0,0,1,0].join(" ");return`<feColorMatrix${u("color-interpolation-filters","sRGB")}${u("in",e)}${u("type","matrix")}${u("values",h)}${u("result",t)}/>`}function od(n,e,t){let{shadowColor:r,highlightColor:i}=n,s=An(r),o=An(i),a="";return a+=`<feColorMatrix${u("in",e)}${u("type","saturate")}${u("values",0)}${u("result",`${t}_gray`)}/>`,a+=`<feComponentTransfer${u("in",`${t}_gray`)}${u("result",t)}>`,a+=`<feFuncR${u("type","table")}${u("tableValues",`${s.r} ${o.r}`)}/>`,a+=`<feFuncG${u("type","table")}${u("tableValues",`${s.g} ${o.g}`)}/>`,a+=`<feFuncB${u("type","table")}${u("tableValues",`${s.b} ${o.b}`)}/>`,a+="</feComponentTransfer>",a}function ld(n,e,t){let{intensity:r}=n;if(r===0)return H(e,t);let i="";i+=`<feComponentTransfer${u("in",e)}${u("result",`${t}_invert`)}>`,i+=`<feFuncR${u("type","table")}${u("tableValues","1 0")}/>`,i+=`<feFuncG${u("type","table")}${u("tableValues","1 0")}/>`,i+=`<feFuncB${u("type","table")}${u("tableValues","1 0")}/>`,i+="</feComponentTransfer>",i+=`<feColorMatrix${u("in",`${t}_invert`)}${u("type","saturate")}${u("values",0)}${u("result",`${t}_gray`)}/>`;let s=[.1,.1,.1,0,0],o=[.3,.4,.3,0,0],a=[.5,.5,.8,0,0],l=[1,0,0,0,0],c=[0,1,0,0,0],f=[0,0,1,0,0],d=(b,$)=>b.map((k,S)=>k*(1-r)+$[S]*r),p=d(l,s),m=d(c,o),h=d(f,a),g=[...p,...m,...h,0,0,0,1,0].join(" ");return i+=`<feColorMatrix${u("in",`${t}_gray`)}${u("type","matrix")}${u("values",g)}${u("result",t)}/>`,i}function ud(n,e,t){let{amount:r,scale:i}=n;if(r===0)return H(e,t);let s=1/i,o="";return o+=`<feTurbulence${u("type","fractalNoise")}${u("baseFrequency",s)}${u("numOctaves",3)}${u("seed",0)}${u("result",`${t}_noise`)}/>`,o+=`<feColorMatrix${u("in",`${t}_noise`)}${u("type","saturate")}${u("values",0)}${u("result",`${t}_noiseGray`)}/>`,o+=`<feBlend${u("in",e)}${u("in2",`${t}_noiseGray`)}${u("mode","overlay")}${u("result",`${t}_blended`)}/>`,o+=`<feComposite${u("in",`${t}_blended`)}${u("in2",e)}${u("operator","arithmetic")}${u("k1",0)}${u("k2",r)}${u("k3",1-r)}${u("k4",0)}${u("result",`${t}_amt`)}/>`,o+=`<feComposite${u("in",`${t}_amt`)}${u("in2",e)}${u("operator","in")}${u("result",t)}/>`,o}function cd(n,e,t){let{strength:r,angle:i}=n;if(r===0)return H(e,t);let s=i*Math.PI/180,o=Math.cos(s),a=Math.sin(s),l=r,c=[-(l*(o+a)),-(l*a),l*(-o+a),-(l*o),1,l*o,l*(o-a),l*a,l*(o+a)].join(" ");return`<feConvolveMatrix${u("in",e)}${u("order","3 3")}${u("kernelMatrix",c)}${u("divisor",1)}${u("bias",.5)}${u("preserveAlpha","true")}${u("result",t)}/>`}function dd(n,e,t){let{amount:r,size:i}=n;if(r===0)return H(e,t);let s=.5/i,o="";return o+=`<feTurbulence${u("type","fractalNoise")}${u("baseFrequency",`${s} ${s}`)}${u("numOctaves",5)}${u("seed",0)}${u("stitchTiles","stitch")}${u("result",`${t}_grain`)}/>`,o+=`<feColorMatrix${u("in",`${t}_grain`)}${u("type","saturate")}${u("values",0)}${u("result",`${t}_grainGray`)}/>`,o+=`<feBlend${u("in",e)}${u("in2",`${t}_grainGray`)}${u("mode","soft-light")}${u("result",`${t}_blended`)}/>`,o+=`<feComposite${u("in",`${t}_blended`)}${u("in2",e)}${u("operator","arithmetic")}${u("k1",0)}${u("k2",r)}${u("k3",1-r)}${u("k4",0)}${u("result",`${t}_amt`)}/>`,o+=`<feComposite${u("in",`${t}_amt`)}${u("in2",e)}${u("operator","in")}${u("result",t)}/>`,o}function fd(n,e,t){let{wetness:r,turbulence:i}=n;if(r===0&&i===0)return H(e,t);let s="";return s+=`<feTurbulence${u("type","fractalNoise")}${u("baseFrequency",.02+i*.03)}${u("numOctaves",4)}${u("seed",42)}${u("result",`${t}_turb`)}/>`,s+=`<feDisplacementMap${u("in",e)}${u("in2",`${t}_turb`)}${u("scale",r*15)}${u("xChannelSelector","R")}${u("yChannelSelector","G")}${u("result",`${t}_disp`)}/>`,s+=`<feGaussianBlur${u("in",`${t}_disp`)}${u("stdDeviation",r*2)}${u("result",`${t}_blur`)}/>`,s+=`<feBlend${u("in",`${t}_blur`)}${u("in2",e)}${u("mode","multiply")}${u("result",t)}/>`,s}function pd(n,e,t){let{thickness:r,texture:i}=n;if(r===0&&i===0)return H(e,t);let s="";s+=`<feTurbulence${u("type","turbulence")}${u("baseFrequency",.03+i*.02)}${u("numOctaves",3)}${u("seed",1e3)}${u("result",`${t}_brush`)}/>`;let o=Math.max(3,8-Math.floor(r*5)),a=Array.from({length:o+1},(l,c)=>c/o).join(" ");s+=`<feComponentTransfer${u("in",e)}${u("result",`${t}_poster`)}>`;for(let l of["R","G","B"])s+=`<feFunc${l}${u("type","discrete")}${u("tableValues",a)}/>`;return s+="</feComponentTransfer>",s+=`<feDisplacementMap${u("in",`${t}_poster`)}${u("in2",`${t}_brush`)}${u("scale",i*4)}${u("xChannelSelector","R")}${u("yChannelSelector","G")}${u("result",`${t}_disp`)}/>`,s+=`<feMorphology${u("in",`${t}_disp`)}${u("operator","dilate")}${u("radius",r*.5)}${u("result",`${t}_thick`)}/>`,s+=`<feComposite${u("in",`${t}_thick`)}${u("in2",e)}${u("operator","in")}${u("result",t)}/>`,s}function md(n,e,t){let{spread:r,edges:i}=n;if(r===0&&i===0)return H(e,t);let s="";return s+=`<feTurbulence${u("type","fractalNoise")}${u("baseFrequency",.01+i*.02)}${u("numOctaves",5)}${u("seed",1100)}${u("result",`${t}_ink`)}/>`,s+=`<feMorphology${u("in",e)}${u("operator","dilate")}${u("radius",r*3)}${u("result",`${t}_dilate`)}/>`,s+=`<feDisplacementMap${u("in",`${t}_dilate`)}${u("in2",`${t}_ink`)}${u("scale",i*10)}${u("xChannelSelector","R")}${u("yChannelSelector","G")}${u("result",`${t}_disp`)}/>`,s+=`<feGaussianBlur${u("in",`${t}_disp`)}${u("stdDeviation",r*.5)}${u("result",t)}/>`,s}function hd(n,e,t){let{wrinkles:r,shine:i}=n;if(r===0&&i===0)return H(e,t);let s="";return s+=`<feTurbulence${u("type","turbulence")}${u("baseFrequency",.02)}${u("numOctaves",4)}${u("seed",1200)}${u("result",`${t}_wrinkle`)}/>`,s+=`<feDisplacementMap${u("in",e)}${u("in2",`${t}_wrinkle`)}${u("scale",r*15)}${u("xChannelSelector","R")}${u("yChannelSelector","G")}${u("result",`${t}_disp`)}/>`,s+=`<feSpecularLighting${u("in",`${t}_wrinkle`)}${u("surfaceScale",r*2)}${u("specularConstant",i*1.5)}${u("specularExponent",20)}${u("result",`${t}_sheen`)}>`,s+=`<feDistantLight${u("azimuth",45)}${u("elevation",60)}/>`,s+="</feSpecularLighting>",s+=`<feBlend${u("in",`${t}_disp`)}${u("in2",`${t}_sheen`)}${u("mode","screen")}${u("result",`${t}_blend`)}/>`,s+=`<feComposite${u("in",`${t}_blend`)}${u("in2",e)}${u("operator","in")}${u("result",t)}/>`,s}function gd(n,e,t){let{density:r,size:i}=n;if(r===0)return H(e,t);let s="",o=1-r;s+=`<feTurbulence${u("type","turbulence")}${u("baseFrequency",.1/i)}${u("numOctaves",1)}${u("seed",1400)}${u("result",`${t}_hole`)}/>`,s+=`<feComponentTransfer${u("in",`${t}_hole`)}${u("result",`${t}_thresh`)}>`;for(let a of["R","G","B","A"])s+=`<feFunc${a}${u("type","linear")}${u("slope",10)}${u("intercept",-o*10+5)}/>`;s+="</feComponentTransfer>",s+=`<feComponentTransfer${u("in",`${t}_thresh`)}${u("result",`${t}_clamp`)}>`;for(let a of["R","G","B","A"])s+=`<feFunc${a}${u("type","table")}${u("tableValues","0 0 1 1")}/>`;return s+="</feComponentTransfer>",s+=`<feComposite${u("in",e)}${u("in2",`${t}_clamp`)}${u("operator","in")}${u("result",t)}/>`,s}function yd(n,e,t){let{color:r,radius:i,intensity:s}=n;if(s===0||i===0)return H(e,t);let{r:o,g:a,b:l}=An(r),c="";return c+=`<feColorMatrix${u("in",e)}${u("type","matrix")}${u("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0")}${u("result",`${t}_alpha`)}/>`,c+=`<feGaussianBlur${u("in",`${t}_alpha`)}${u("stdDeviation",i/2)}${u("result",`${t}_blur`)}/>`,c+=`<feColorMatrix${u("in",`${t}_blur`)}${u("type","matrix")}${u("values",`0 0 0 0 ${o} 0 0 0 0 ${a} 0 0 0 0 ${l} 0 0 0 ${s} 0`)}${u("result",`${t}_color`)}/>`,c+=`<feMerge${u("result",t)}><feMergeNode${u("in",`${t}_color`)}/><feMergeNode${u("in",e)}/></feMerge>`,c}function bd(n,e,t){let{color:r,radius:i,intensity:s}=n;if(s===0||i===0)return H(e,t);let{r:o,g:a,b:l}=An(r),c="";return c+=`<feColorMatrix${u("in",e)}${u("type","matrix")}${u("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0")}${u("result",`${t}_alpha`)}/>`,c+=`<feMorphology${u("in",`${t}_alpha`)}${u("operator","erode")}${u("radius",i/4)}${u("result",`${t}_erode`)}/>`,c+=`<feComposite${u("in",`${t}_alpha`)}${u("in2",`${t}_erode`)}${u("operator","out")}${u("result",`${t}_edge`)}/>`,c+=`<feGaussianBlur${u("in",`${t}_edge`)}${u("stdDeviation",i/3)}${u("result",`${t}_blur`)}/>`,c+=`<feColorMatrix${u("in",`${t}_blur`)}${u("type","matrix")}${u("values",`0 0 0 0 ${o} 0 0 0 0 ${a} 0 0 0 0 ${l} 0 0 0 ${s*2} 0`)}${u("result",`${t}_color`)}/>`,c+=`<feComposite${u("in",`${t}_color`)}${u("in2",`${t}_alpha`)}${u("operator","in")}${u("result",`${t}_clipped`)}/>`,c+=`<feComposite${u("in",`${t}_clipped`)}${u("in2",e)}${u("operator","over")}${u("result",t)}/>`,c}function H(n,e){return`<feMerge${u("result",e)}><feMergeNode${u("in",n)}/></feMerge>`}function ui(n){switch(n.type){case"feBlend":return Sd(n);case"feColorMatrix":return xd(n);case"feComponentTransfer":return $d(n);case"feComposite":return vd(n);case"feConvolveMatrix":return kd(n);case"feDiffuseLighting":return Td(n);case"feSpecularLighting":return wd(n);case"feDisplacementMap":return Pd(n);case"feDropShadow":return _d(n);case"feFlood":return Rd(n);case"feGaussianBlur":return Ad(n);case"feImage":return Id(n);case"feMerge":return Md(n);case"feMorphology":return Cd(n);case"feOffset":return Dd(n);case"feTile":return Fd(n);case"feTurbulence":return Ed(n)}}function le(n){let e="";if(e+=u("in",n.in),e+=u("x",n.x),e+=u("y",n.y),e+=u("width",n.width),e+=u("height",n.height),e+=u("color-interpolation-filters",n.colorInterpolationFilters),e+=u("result",n.result),n.unknownAttrs){let t=Object.keys(n.unknownAttrs).sort();for(let r of t)e+=u(r,n.unknownAttrs[r])}return e}function ue(n){return n.animations&&n.animations.length>0?n.animations.join(""):""}function Sd(n){let e=`<feBlend${le(n)}${u("in2",n.in2)}${u("mode",n.mode)}`;n.noComposite&&(e+=' no-composite="no-composite"');let t=ue(n);return t?`${e}>${t}</feBlend>`:`${e}/>`}function xd(n){let e=`<feColorMatrix${le(n)}${u("type",n.matrixType)}${u("values",n.values)}`,t=ue(n);return t?`${e}>${t}</feColorMatrix>`:`${e}/>`}function Rn(n,e){if(!e)return"";let t=`feFunc${n}`;switch(e.type){case"identity":return`<${t} type="identity"/>`;case"table":case"discrete":return`<${t} type="${e.type}"${u("tableValues",e.tableValues.join(" "))}/>`;case"linear":return`<${t} type="linear"${u("slope",e.slope)}${u("intercept",e.intercept)}/>`;case"gamma":return`<${t} type="gamma"${u("amplitude",e.amplitude)}${u("exponent",e.exponent)}${u("offset",e.offset)}/>`}}function $d(n){let e="";return e+=Rn("R",n.funcR),e+=Rn("G",n.funcG),e+=Rn("B",n.funcB),e+=Rn("A",n.funcA),e+=ue(n),`<feComponentTransfer${le(n)}>${e}</feComponentTransfer>`}function vd(n){let e=`<feComposite${le(n)}${u("in2",n.in2)}${u("operator",n.operator)}`;n.operator==="arithmetic"&&(e+=u("k1",n.k1),e+=u("k2",n.k2),e+=u("k3",n.k3),e+=u("k4",n.k4));let t=ue(n);return t?`${e}>${t}</feComposite>`:`${e}/>`}function kd(n){let e=`<feConvolveMatrix${le(n)}`;e+=u("order",n.order),e+=u("kernelMatrix",n.kernelMatrix),e+=u("divisor",n.divisor),e+=u("bias",n.bias),e+=u("targetX",n.targetX),e+=u("targetY",n.targetY),e+=u("edgeMode",n.edgeMode),e+=u("kernelUnitLength",n.kernelUnitLength),n.preserveAlpha!==void 0&&(e+=u("preserveAlpha",n.preserveAlpha?"true":"false"));let t=ue(n);return t?`${e}>${t}</feConvolveMatrix>`:`${e}/>`}function Qa(n){switch(n.kind){case"feDistantLight":return`<feDistantLight${u("azimuth",n.azimuth)}${u("elevation",n.elevation)}/>`;case"fePointLight":return`<fePointLight${u("x",n.x)}${u("y",n.y)}${u("z",n.z)}/>`;case"feSpotLight":{let e=`<feSpotLight${u("x",n.x)}${u("y",n.y)}${u("z",n.z)}${u("pointsAtX",n.pointsAtX)}${u("pointsAtY",n.pointsAtY)}${u("pointsAtZ",n.pointsAtZ)}`;return e+=u("specularExponent",n.specularExponent),e+=u("limitingConeAngle",n.limitingConeAngle),e+"/>"}}}function Td(n){let e=`<feDiffuseLighting${le(n)}`;e+=u("surfaceScale",n.surfaceScale),e+=u("diffuseConstant",n.diffuseConstant),e+=u("kernelUnitLength",n.kernelUnitLength),e+=u("lighting-color",n.lightingColor);let t="";return n.lightSource&&(t+=Qa(n.lightSource)),t+=ue(n),`${e}>${t}</feDiffuseLighting>`}function wd(n){let e=`<feSpecularLighting${le(n)}`;e+=u("surfaceScale",n.surfaceScale),e+=u("specularConstant",n.specularConstant),e+=u("specularExponent",n.specularExponent),e+=u("kernelUnitLength",n.kernelUnitLength),e+=u("lighting-color",n.lightingColor);let t="";return n.lightSource&&(t+=Qa(n.lightSource)),t+=ue(n),`${e}>${t}</feSpecularLighting>`}function Pd(n){let e=`<feDisplacementMap${le(n)}`;e+=u("in2",n.in2),e+=u("scale",n.scale),e+=u("xChannelSelector",n.xChannelSelector),e+=u("yChannelSelector",n.yChannelSelector);let t=ue(n);return t?`${e}>${t}</feDisplacementMap>`:`${e}/>`}function _d(n){let e=`<feDropShadow${le(n)}`;e+=u("dx",n.dx),e+=u("dy",n.dy),e+=u("stdDeviation",n.stdDeviation),e+=u("flood-color",n.floodColor),e+=u("flood-opacity",n.floodOpacity);let t=ue(n);return t?`${e}>${t}</feDropShadow>`:`${e}/>`}function Rd(n){let e=`<feFlood${le(n)}${u("flood-color",n.floodColor)}${u("flood-opacity",n.floodOpacity)}`,t=ue(n);return t?`${e}>${t}</feFlood>`:`${e}/>`}function Ad(n){let e=`<feGaussianBlur${le(n)}${u("stdDeviation",n.stdDeviation)}${u("edgeMode",n.edgeMode)}`,t=ue(n);return t?`${e}>${t}</feGaussianBlur>`:`${e}/>`}function Id(n){let e=`<feImage${le(n)}`;n.href!==void 0?e+=u("href",n.href):n.xlinkHref!==void 0&&(e+=u("xlink:href",n.xlinkHref)),e+=u("preserveAspectRatio",n.preserveAspectRatio),e+=u("crossorigin",n.crossorigin);let t=ue(n);return t?`${e}>${t}</feImage>`:`${e}/>`}function Md(n){let e="";for(let t of n.nodes)e+=`<feMergeNode${u("in",t.in)}/>`;return e+=ue(n),`<feMerge${le(n)}>${e}</feMerge>`}function Cd(n){let e=`<feMorphology${le(n)}${u("operator",n.operator)}${u("radius",n.radius)}`,t=ue(n);return t?`${e}>${t}</feMorphology>`:`${e}/>`}function Dd(n){let e=`<feOffset${le(n)}${u("dx",n.dx)}${u("dy",n.dy)}`,t=ue(n);return t?`${e}>${t}</feOffset>`:`${e}/>`}function Fd(n){let e=`<feTile${le(n)}`,t=ue(n);return t?`${e}>${t}</feTile>`:`${e}/>`}function Ed(n){let e=`<feTurbulence${le(n)}`;e+=u("baseFrequency",n.baseFrequency),e+=u("numOctaves",n.numOctaves),e+=u("seed",n.seed),e+=u("stitchTiles",n.stitchTiles),e+=u("type",n.turbulenceType);let t=ue(n);return t?`${e}>${t}</feTurbulence>`:`${e}/>`}function eo(n,e){let t=`<filter${u("id",n)}`;t+=u("x",e.x),t+=u("y",e.y),t+=u("width",e.width),t+=u("height",e.height),t+=u("filterUnits",e.filterUnits),t+=u("primitiveUnits",e.primitiveUnits),e.filterColorInterpolation&&e.filterColorInterpolation!=="auto"&&(t+=u("color-interpolation-filters",e.filterColorInterpolation)),t+=u("flood-color",e.floodColor),t+=u("flood-opacity",e.floodOpacity),t+=u("lighting-color",e.lightingColor),t+=">",e.filterTitle&&(t+=`<title>${q(e.filterTitle)}</title>`),e.filterDescription&&(t+=`<desc>${q(e.filterDescription)}</desc>`);for(let r of e.primitives)t+=ui(r);if(e.filterAnimations)for(let r of e.filterAnimations)t+=r;return t+="</filter>",t}function to(n,e,t,r){switch(n.type){case"drop-shadow":return Lc(n,e,t);case"inner-shadow":return Nc(n,e,t);case"gaussian-blur":return Bc(n,e,t);case"motion-blur":return zc(n,e,t);case"point-light":{let i=n;return qa(r?{...i,x:i.x+r.x,y:i.y+r.y}:i,e,t)}case"spot-light":{let i=n;return Za(r?{...i,x:i.x+r.x,y:i.y+r.y,pointsAtX:i.pointsAtX+r.x,pointsAtY:i.pointsAtY+r.y}:i,e,t)}case"diffuse-lighting":return Gc(n,e,t);case"specular-lighting":return Vc(n,e,t);case"outline":return Uc(n,e,t);case"sharpen":return Wc(n,e,t);case"pixelate":return Hc(n,e,t);case"warp":return jc(n,e,t);case"morphology":return Kc(n,e,t);case"contouring-discrete":return Xc(n,e,t);case"contouring-table":return Yc(n,e,t);case"round-edges":return qc(n,e,t);case"grayscale":return Zc(n,e,t);case"channel-painter":return Jc(n,e,t);case"brightness":return Qc(n,e,t);case"contrast":return ed(n,e,t);case"opacity":return td(n,e,t);case"invert":return nd(n,e,t);case"hue-rotate":return rd(n,e,t);case"saturate":return id(n,e,t);case"black-and-white":return sd(n,e,t);case"sepia":return ad(n,e,t);case"duotone":return od(n,e,t);case"xray":return ld(n,e,t);case"noise":return ud(n,e,t);case"emboss":return cd(n,e,t);case"film-grain":return dd(n,e,t);case"watercolor":return fd(n,e,t);case"gouache":return pd(n,e,t);case"ink-blot":return md(n,e,t);case"crumpled-plastic":return hd(n,e,t);case"riddled":return gd(n,e,t);case"glow":return yd(n,e,t);case"inner-glow":return bd(n,e,t);case"raw-svg":return n.svgContent;case"svg-primitive-chain":return n.primitives.map(ui).join("");default:return H(e,t)}}function Od(n){return n.some(e=>e.type==="gaussian-blur"||e.type==="motion-blur"||e.type==="drop-shadow"||e.type==="inner-shadow"||e.type==="glow"||e.type==="inner-glow"||e.type==="outline"||e.type==="morphology"||e.type==="warp"||e.type==="svg-primitive-chain"&&e.primitives.some(t=>t.type==="feGaussianBlur"||t.type==="feDropShadow"||t.type==="feOffset"||t.type==="feMorphology"||t.type==="feDisplacementMap"||t.type==="feTurbulence"))}function ci(n,e,t={}){let r=e.filter(x=>x.enabled);if(r.length===0)return"";let i=t.colorInterpolation&&t.colorInterpolation!=="auto"?u("color-interpolation-filters",t.colorInterpolation):"",s=r.find(x=>x.type==="raw-svg");if(s){let x=t.colorInterpolation&&t.colorInterpolation!=="auto"?t.colorInterpolation:s.colorInterpolationFilters,v=t.filterUnits??s.filterUnits,w=t.primitiveUnits??s.primitiveUnits,T=t.x??s.x,P=t.y??s.y,R=t.width??s.width,M=t.height??s.height;return`<filter${u("id",n)}${u("x",T)}${u("y",P)}${u("width",R)}${u("height",M)}${u("filterUnits",v)}${u("primitiveUnits",w)}${u("color-interpolation-filters",x)}${u("flood-color",s.floodColor)}${u("flood-opacity",s.floodOpacity)}${u("lighting-color",s.lightingColor)}${u("display",s.display)}>${s.svgContent}</filter>`}let o=r.find(x=>x.type==="svg-primitive-chain");if(o){let x={...o,x:t.x??o.x,y:t.y??o.y,width:t.width??o.width,height:t.height??o.height,filterUnits:t.filterUnits??o.filterUnits,primitiveUnits:t.primitiveUnits??o.primitiveUnits,filterColorInterpolation:t.colorInterpolation&&t.colorInterpolation!=="auto"?t.colorInterpolation:o.filterColorInterpolation};return eo(n,x)}let a=r.some(x=>x.type==="gaussian-blur"&&x.quality==="high"||x.type==="motion-blur"&&x.quality==="high"),l=Od(r),c=l?a?"-200%":"-100%":"-10%",f=l?a?"500%":"300%":"120%",d="",p="SourceGraphic",m=0;for(let x of r){let v=`result${m++}`;d+=to(x,p,v),p=v}let h=t.filterUnits??"objectBoundingBox",g=t.primitiveUnits??"userSpaceOnUse",b=t.x??c,$=t.y??c,k=t.width??f,S=t.height??f;return`<filter${u("id",n)}${u("x",b)}${u("y",$)}${u("width",k)}${u("height",S)}${u("filterUnits",h)}${u("primitiveUnits",g)}${i}>${d}</filter>`}function Ld(n){let e="",t=new Set;for(let r of n){let i=r.state.filters;if(!i||i.length===0)continue;let s=i.filter(c=>c.enabled);if(s.length===0)continue;let o=r.state.filterLibraryIds,a=Array.isArray(o)&&o.length>0?o[0]:`filter-${r.id}`;if(t.has(a))continue;t.add(a);let l=r.state;e+=ci(a,s,{colorInterpolation:l.filterColorInterpolation,filterUnits:l.filterUnits,primitiveUnits:l.primitiveUnits,x:l.filterX,y:l.filterY,width:l.filterWidth,height:l.filterHeight})}return e}function di(n,e,t){return!e||e.length===0||e.filter(i=>i.enabled).length===0?"":Array.isArray(t)&&t.length>0?` filter="${t.map(s=>`url(#${q(s)})`).join(" ")}"`:` filter="url(#filter-${q(n)})"`}function Nd(n){if(n instanceof Map)return n;let e=new Map;for(let t of n)e.set(t.id,t);return e}function Bd(n){if(n.kind==="marker")return n.shapes;if(n.kind!=="symbol")return[];if(!n.variants)return n.shapes;let e=[...n.shapes];for(let t of Object.values(n.variants))e.push(...t);return e}function no(n,e,t,r){let i=Nd(t),s=new Set,o=[],a=[],l=d=>{if(typeof d!="string"||!d||s.has(d))return;let p=i.get(d);p&&(p.kind!=="symbol"&&p.kind!=="marker"||(s.add(d),o.push(p)))},c=d=>{a.push(d)},f=d=>{let p=d.state;if(!p)return;l(p.symbolId),l(p.markerStart),l(p.markerMid),l(p.markerEnd);let m=p.children;if(Array.isArray(m))for(let g of m)c(g);let h=p.symbolOverrides;if(h&&typeof h=="object"&&!Array.isArray(h))for(let[g,b]of Object.entries(h))!b||typeof b!="object"||Array.isArray(b)||c({id:g,type:"symbol-override",state:b})};for(let d of n)c(d);for(let d of e)l(d);for(;;){let d=a.shift();if(d){r(d),f(d);continue}let p=o.shift();if(!p)break;for(let m of Bd(p))c(m)}}var zd=[],Gd=[];function Mn(n,e,t){no(n,Gd,e,t)}function Vd(n,e,t){no(zd,n,e,t)}function Ud(n,e){if(!n)return;let t=n,r=t.markerStart;typeof r=="string"&&r&&e(r);let i=t.markerMid;typeof i=="string"&&i&&e(i);let s=t.markerEnd;typeof s=="string"&&s&&e(s);let o=t.startEndpoint;typeof o=="string"&&o&&o!=="none"&&e(In(o));let a=t.endEndpoint;typeof a=="string"&&a&&a!=="none"&&e(In(a))}function In(n){return`line-marker-${n}`}function Wd(n,e,t){if(!n)return;let r=n,i=o=>{typeof o=="string"&&o&&t(o)};i(r.fillLibraryId),i(r.strokeLibraryId),i(r.markerStart),i(r.markerMid),i(r.markerEnd),i(r.symbolId);let s=r.filterLibraryIds;if(Array.isArray(s)&&s.length>0)for(let o of s)i(o);else Array.isArray(r.filters)&&r.filters.length>0&&t(`filter-${e}`);r.fillLibraryId||i(r.fillGradient?.id),r.strokeLibraryId||i(r.strokeGradient?.id)}function Cn(n,e=[]){let t=new Set,r=new Set;return Mn(n,e,i=>{let s=i.state;if(!s)return;typeof s.markerStart=="string"&&s.markerStart&&t.add(s.markerStart),typeof s.markerMid=="string"&&s.markerMid&&t.add(s.markerMid),typeof s.markerEnd=="string"&&s.markerEnd&&t.add(s.markerEnd);let o=s.startEndpoint,a=s.endEndpoint;typeof o=="string"&&o&&o!=="none"&&r.add(o),typeof a=="string"&&a&&a!=="none"&&r.add(a)}),{ids:t,legacyEndpoints:r}}function Hd(n,e){let{ids:t,legacyEndpoints:r}=Cn(n,e);for(let i of r)t.add(In(i));return t}function Dn(n,e,t,r){let i=r?.strokeWidth!=null?Math.max(.5,e*r.strokeWidth):Math.max(1,e/10);switch(n){case"stripes":return[{tag:"rect",attrs:{width:r?.strokeWidth!=null?Math.max(.01,Math.min(1,r.strokeWidth))*e:e/2,height:e,fill:t}}];case"dots":{let s=r?.dotRadius!=null?Math.max(.05,Math.min(.45,r.dotRadius)):.25;return[{tag:"circle",attrs:{cx:e/2,cy:e/2,r:e*s,fill:t}}]}case"grid":return[{tag:"path",attrs:{d:`M ${e} 0 L 0 0 0 ${e}`,fill:"none",stroke:t,"stroke-width":i}}];case"checkerboard":return[{tag:"rect",attrs:{width:e/2,height:e/2,fill:t}},{tag:"rect",attrs:{x:e/2,y:e/2,width:e/2,height:e/2,fill:t}}];case"diagonal":{let s=r?.strokeWidth!=null?Math.max(.5,e*r.strokeWidth):Math.max(1,e/5);return[{tag:"path",attrs:{d:`M 0 ${e} L ${e} 0`,stroke:t,"stroke-width":s}}]}case"crosshatch":return[{tag:"path",attrs:{d:`M 0 ${e} L ${e} 0 M 0 0 L ${e} ${e}`,stroke:t,"stroke-width":i}}];case"zigzag":{let s=r?.amplitude!=null?Math.max(.05,Math.min(.5,r.amplitude)):.25,o=e*s;return[{tag:"path",attrs:{d:`M 0 ${o} L ${e/4} 0 L ${e/2} ${o} L ${e*3/4} 0 L ${e} ${o}`,fill:"none",stroke:t,"stroke-width":i}}]}case"waves":{let s=r?.amplitude!=null?Math.max(.05,Math.min(.5,r.amplitude)):.25,o=e*s,a=e/2;return[{tag:"path",attrs:{d:`M 0 ${a} Q ${e/4} ${a-o} ${e/2} ${a} T ${e} ${a}`,fill:"none",stroke:t,"stroke-width":i}}]}case"triangles":{let s=e*.866;return[{tag:"path",attrs:{d:`M ${e/2} 0 L ${e} ${s} L 0 ${s} Z`,fill:"none",stroke:t,"stroke-width":i}}]}case"hexagons":{let s=e*.866;return[{tag:"path",attrs:{d:`M ${e*.25} 0 L ${e*.75} 0 L ${e} ${s*.5} L ${e*.75} ${s} L ${e*.25} ${s} L 0 ${s*.5} Z`,fill:"none",stroke:t,"stroke-width":i}}]}case"diamonds":return[{tag:"path",attrs:{d:`M ${e/2} 0 L ${e} ${e/2} L ${e/2} ${e} L 0 ${e/2} Z`,fill:"none",stroke:t,"stroke-width":i}}];case"circles":return[{tag:"circle",attrs:{cx:e/2,cy:e/2,r:e/3,fill:"none",stroke:t,"stroke-width":i}}];case"bricks":{let s=r?.strokeWidth!=null?Math.max(.5,e*r.strokeWidth):Math.max(1,e/15);return[{tag:"rect",attrs:{x:0,y:0,width:e,height:e/2,fill:"none",stroke:t,"stroke-width":s}},{tag:"rect",attrs:{x:-e/2,y:e/2,width:e,height:e/2,fill:"none",stroke:t,"stroke-width":s}},{tag:"rect",attrs:{x:e/2,y:e/2,width:e,height:e/2,fill:"none",stroke:t,"stroke-width":s}}]}case"herringbone":return[{tag:"path",attrs:{d:`M 0 0 L ${e/2} ${e/2} L 0 ${e} M ${e/2} ${e/2} L ${e} 0 M ${e/2} ${e/2} L ${e} ${e}`,fill:"none",stroke:t,"stroke-width":i}}];default:return[]}}function jd(n){let e=Object.entries(n.attrs).map(([t,r])=>` ${t}="${r}"`).join("");return`<${n.tag}${e}/>`}function fi(n,e,t,r,i){let s=10*e,o="";o+=`<rect width="${s}" height="${s}" fill="${r}"/>`;let a=Dn(n,s,t,i);for(let l of a)o+=jd(l);return{svgContent:o,width:s,height:s}}var Fn="0 0 10 10",pi=6,mi=6;function $t(){return[{id:"line-marker-arrow",refX:10,refY:5,element:{tag:"path",attrs:{d:"M 0 0 L 10 5 L 0 10 Z",fill:"context-stroke",stroke:"context-stroke"}}},{id:"line-marker-open-arrow",refX:10,refY:5,element:{tag:"path",attrs:{d:"M 0 0 L 10 5 L 0 10",fill:"none",stroke:"context-stroke","stroke-width":1.5,"stroke-linejoin":"round","stroke-linecap":"round"}}},{id:"line-marker-circle",refX:5,refY:5,element:{tag:"circle",attrs:{cx:5,cy:5,r:3.2,fill:"context-stroke",stroke:"context-stroke"}}},{id:"line-marker-diamond",refX:5,refY:5,element:{tag:"path",attrs:{d:"M 5 0 L 10 5 L 5 10 L 0 5 Z",fill:"context-stroke",stroke:"context-stroke"}}},{id:"line-marker-square",refX:5,refY:5,element:{tag:"rect",attrs:{x:1.5,y:1.5,width:7,height:7,fill:"context-stroke",stroke:"context-stroke"}}}]}var ro={"line-marker-arrow":"mkr-builtin-arrow","line-marker-open-arrow":"mkr-builtin-open-arrow","line-marker-circle":"mkr-builtin-circle","line-marker-diamond":"mkr-builtin-diamond","line-marker-square":"mkr-builtin-square"},Kd={"mkr-builtin-arrow":"Arrow","mkr-builtin-open-arrow":"Open Arrow","mkr-builtin-circle":"Circle","mkr-builtin-diamond":"Diamond","mkr-builtin-square":"Square"};function Xd(){return $t().map(n=>{let e=ro[n.id]??n.id;return{kind:"marker",id:e,name:Kd[e]??e,viewBox:Fn,refX:n.refX,refY:n.refY,markerWidth:6,markerHeight:6,markerUnits:"strokeWidth",orient:"auto-start-reverse",shapes:[],builtIn:!0}})}function Yd(n){return n.replace(/[^a-zA-Z0-9_-]/g,"_")}function qd(n){let e=n.state.symbolOverrides;return!!e&&Object.keys(e).length>0}function jt(n){let e=n.state.symbolId??"",t=n.state.variantKey??"";return qd(n)?`${e}--ovr-${n.id}`:t?`${e}--${Yd(t)}`:e}function hi(n,e){let t=e.state.variantKey??"",r=t?n.variants?.[t]??n.shapes:n.shapes,i=e.state.symbolOverrides;return!i||Object.keys(i).length===0?r:r.map(s=>{let o=i[s.id];return!o||Object.keys(o).length===0?s:{...s,state:{...s.state,...o}}})}function En(n,e){switch(e){case"uppercase":return n.toLocaleUpperCase();case"lowercase":return n.toLocaleLowerCase();case"capitalize":return n.replace(/\b\p{L}/gu,t=>t.toLocaleUpperCase());default:return n}}var Zd=[["fontVariant","font-variant"],["fontVariantLigatures","font-variant-ligatures"],["fontVariantPosition","font-variant-position"],["fontVariantCaps","font-variant-caps"],["fontVariantNumeric","font-variant-numeric"],["fontVariantEastAsian","font-variant-east-asian"]];function Kt(n){return Zd.map(([e,t])=>{let r=n[e],i=typeof r=="string"?r.trim():"";return i?`${t}: ${i}`:""}).filter(Boolean).join("; ")}function gi(n,e){let t=[],r=(a,l)=>{l!==""&&t.push({name:a,value:l})};n.fontFamily!==e.fontFamily&&r("font-family",String(n.fontFamily)),n.fontSize!==e.fontSize&&r("font-size",String(n.fontSize)),n.fontWeight!==e.fontWeight&&r("font-weight",String(n.fontWeight)),n.fontStyle!==e.fontStyle&&r("font-style",String(n.fontStyle));let i=Kt(n);i&&i!==Kt(e)&&r("style",i);let s=n.textDecoration,o=e.textDecoration;if(s.underline!==o.underline||s.strikethrough!==o.strikethrough||s.overline!==o.overline){let a=[];s.underline&&a.push("underline"),s.strikethrough&&a.push("line-through"),s.overline&&a.push("overline"),r("text-decoration",a.join(" "))}if(n.baselineShift!==e.baselineShift){let a=n.baselineShift;a==="super"||a==="sub"?r("baseline-shift",a):typeof a=="number"&&r("baseline-shift",`${a}px`)}return n.letterSpacing!==e.letterSpacing&&r("letter-spacing",String(n.letterSpacing)),n.fill!==e.fill&&r("fill",String(n.fill)),n.fillOpacity!==e.fillOpacity&&r("fill-opacity",String(n.fillOpacity)),n.direction!==e.direction&&r("direction",String(n.direction)),n.unicodeBidi!==e.unicodeBidi&&r("unicode-bidi",String(n.unicodeBidi)),t}function y(n,e){return e==null||e===""?"":` ${n}="${q(String(e))}"`}function vt(n,e){return e==null?"":` ${n}="${q(e)}"`}function Jd(n){let e=n.map(t=>(t??"").trim().replace(/;$/,"")).filter(Boolean).join("; ");return e?y("style",e):""}function Qd(n,e){return typeof e=="number"&&e>0?`${n}: ${e}px`:""}function ef(n){if(n&&typeof n=="object"){let e=n;return"dx"in e?{x:typeof e.x=="number"?e.x:null,y:typeof e.y=="number"?e.y:null,dx:typeof e.dx=="number"?e.dx:0,dy:typeof e.dy=="number"?e.dy:0,rotate:typeof e.rotate=="number"?e.rotate:0}:{x:null,y:null,dx:typeof e.x=="number"?e.x:0,dy:typeof e.y=="number"?e.y:0,rotate:typeof e.rotate=="number"?e.rotate:0}}return{x:null,y:null,dx:0,dy:0,rotate:0}}function io(n,e){let t=-1;for(let i=n.length-1;i>=0;i--)if(n[i][e]!==null){t=i;break}if(t<0)return[];let r=new Array(t+1);for(let i=0;i<=t;i++)r[i]=n[i][e]??0;return r}function so(n,e){let t=-1;for(let i=n.length-1;i>=0;i--)if(n[i][e]!==0){t=i;break}if(t<0)return[];let r=new Array(t+1);for(let i=0;i<=t;i++)r[i]=n[i][e];return r}function tf(n){if(n.length===0)return[];let e=n.length-1,t=n[e].rotate;for(;e>0&&n[e-1].rotate===t;)e--;if(e===0&&t===0)return[];let r=new Array(e+1);for(let i=0;i<=e;i++)r[i]=n[i].rotate;return r}function Re(n,e){return Gt(n,e)}function nf(n,e,t){return Ba(n,e,t)}function rf(n){if(typeof n=="string"){let r=n.trim();return r.length>0?r:void 0}if(!n||typeof n!="object")return;let e=n,t=[];return e.underline&&t.push("underline"),e.strikethrough&&t.push("line-through"),e.overline&&t.push("overline"),t.length>0?t.join(" "):void 0}function sf(n){if(typeof n.strokeDasharray=="string")return n.strokeDasharray;let e=n.lineStyle??"solid",t=n.dashLength??8,r=n.gapLength??4;return Ht(e,t,r)}function On(n,e){let t=n[e];return t!==void 0?t:n.extra?.[e]}function af(n){let e=n.fillType;return e||(n.fillGradient?n.fillGradient.r!==void 0?"radial-gradient":"linear-gradient":On(n,"linearGradient")?"linear-gradient":On(n,"radialGradient")?"radial-gradient":"solid")}function of(n){return n.fillGradient??On(n,"linearGradient")??On(n,"radialGradient")??void 0}function _e(n,e){let t=y("data-shape-id",e),r=af(n),i=of(n);if(r==="none")t+=y("fill","none");else if(r==="linear-gradient"||r==="radial-gradient"){let w=n.fillLibraryId??i?.id;t+=y("fill",`url(#${w??`gradient-fill-${e}`})`)}else if(r==="pattern"){let w=n.fillLibraryId??i?.id;t+=y("fill",`url(#${w??`pattern-fill-${e}`})`)}else t+=y("fill",n.fillColor??"#000000");let s=n.opacity;s!==void 0&&s<1&&(t+=y("opacity",s));let o=n.fillOpacity;o!==void 0&&o<1&&(t+=y("fill-opacity",o));let a=n.fillRule;a&&a!=="nonzero"&&(t+=y("fill-rule",a));let l=n.strokeType??"solid",c=n.strokeGradient;if(l==="none")t+=y("stroke","none");else if(l==="linear-gradient"||l==="radial-gradient"){let w=n.strokeLibraryId??c?.id;t+=y("stroke",`url(#${w??`gradient-stroke-${e}`})`)}else if(l==="pattern"){let w=n.strokeLibraryId??c?.id;t+=y("stroke",`url(#${w??`pattern-stroke-${e}`})`)}else t+=y("stroke",n.borderColor??"none");let f=n.borderWidth;f!=null&&(t+=y("stroke-width",f));let d=n.strokeOpacity;d!==void 0&&d<1&&(t+=y("stroke-opacity",d));let p=n.paintOrder;p&&p!=="normal"&&(t+=y("paint-order",p));let m=n.markerStart,h=n.markerMid,g=n.markerEnd;m&&(t+=y("marker-start",`url(#${m})`)),h&&(t+=y("marker-mid",`url(#${h})`)),g&&(t+=y("marker-end",`url(#${g})`));let b=sf(n);b&&(t+=y("stroke-dasharray",b),!n.strokeDasharray&&n.lineStyle==="dotted"&&(t+=y("stroke-linecap","round")));let $=n.dashOffset;$!==void 0&&$!==0&&(t+=y("stroke-dashoffset",$));let k=n.shapeRendering;k&&k!=="auto"&&(t+=y("shape-rendering",k)),t+=di(e,n.filters,n.filterLibraryIds),t+=vt("systemLanguage",n.systemLanguage),t+=vt("requiredExtensions",n.requiredExtensions);let S=n.vectorEffect;S&&S!=="none"&&(t+=y("vector-effect",S));let x=n.visibility;x&&x!=="visible"&&(t+=y("visibility",x));let v=n.metadata;return v&&(v.role&&(t+=y("role",v.role)),v.ariaLabel&&(t+=y("aria-label",v.ariaLabel))),t}function yi(n){let e=n.metadata;if(!e)return"";let t="";return e.title&&(t+=`<title>${q(e.title)}</title>`),e.description&&(t+=`<desc>${q(e.description)}</desc>`),t}function lf(n,e){let t=yi(e);if(!t)return n;let r=n.lastIndexOf("/>");if(r===-1){let o=n.indexOf(">");return o===-1?n:n.slice(0,o+1)+t+n.slice(o+1)}let i=n.match(/^<(\w+)/),s=i?i[1]:"g";return n.slice(0,r)+">"+t+`</${s}>`}function bi(n){let e="",t=n.startEndpoint,r=n.endEndpoint;return t&&t!=="none"&&(e+=y("marker-start",`url(#line-marker-${t})`)),r&&r!=="none"&&(e+=y("marker-end",`url(#line-marker-${r})`)),e}function ao(n){let e=n.state,t=e.x??0,r=e.y??0,i=e.radius??50,s=Re(e,{x:t,y:r});return`<circle${y("cx",t)}${y("cy",r)}${y("r",i)}${_e(e,n.id)}${s?y("transform",s):""}/>`}function oo(n){let e=n.state,t=e.cx??0,r=e.cy??0,i=e.rx??50,s=e.ry??30,o=e.pathLength,a=Re(e,{x:t,y:r});return`<ellipse${y("cx",t)}${y("cy",r)}${y("rx",i)}${y("ry",s)}${o!==void 0?y("pathLength",o):""}${_e(e,n.id)}${a?y("transform",a):""}/>`}function lo(n){let e=n.state,t=e,r=e.x??0,i=e.y??0,s=e.width??100,o=e.height??100,a=e.cornerRadius??0,l=e.rx??a,c=e.ry??a,f=t.cornerShape??"round",d=t.cornerMode??"uniform",p={x:r+s/2,y:i+o/2},m=Re(e,p);if(f!=="round"||d==="non-uniform"){let h=oi(r,i,s,o,a,f,d,d==="non-uniform"?{radiusTL:t.cornerRadiusTL,radiusTR:t.cornerRadiusTR,radiusBR:t.cornerRadiusBR,radiusBL:t.cornerRadiusBL,shapeTL:t.cornerShapeTL,shapeTR:t.cornerShapeTR,shapeBR:t.cornerShapeBR,shapeBL:t.cornerShapeBL}:void 0);if(h)return`<path${y("d",h)}${_e(e,n.id)}${m?y("transform",m):""}/>`}return`<rect${y("x",r)}${y("y",i)}${y("width",s)}${y("height",o)}${l>0||c>0?`${y("rx",l)}${y("ry",c)}`:""}${_e(e,n.id)}${m?y("transform",m):""}/>`}function uo(n){let e=n.state,t=e.x1??0,r=e.y1??0,i=e.x2??0,s=e.y2??0,o={x:(t+i)/2,y:(r+s)/2},a=Re(e,o),l={...e,fillType:"none"};return`<line${y("x1",t)}${y("y1",r)}${y("x2",i)}${y("y2",s)}${_e(l,n.id)}${bi(e)}${a?y("transform",a):""}/>`}function co(n){let e=n.state,t=e.x??0,r=e.y??0,i=En(e.text??"",e.textTransform),s=e.fontSize??16,o=e.fontFamily??"sans-serif",a=e.fontWeight??"normal",l=e.fontStyle??"normal",c=e.textAnchor??"start",f=rf(e.textDecoration),d=e.letterSpacing,p=e.wordSpacing,m=e.lineHeight??1.25,g=Re(e,{x:t,y:r}),b=y("x",t)+y("y",r);b+=y("font-size",s),b+=y("font-family",o),a!=="normal"&&(b+=y("font-weight",a)),l!=="normal"&&(b+=y("font-style",l)),c!=="start"&&(b+=y("text-anchor",c)),f&&(b+=y("text-decoration",f)),d&&(b+=y("letter-spacing",d)),p&&(b+=y("word-spacing",p));let $=e.baselineShift;$&&$!=="baseline"&&(b+=y("baseline-shift",$));let k=e.dominantBaseline;k&&k!=="auto"&&(b+=y("dominant-baseline",k));let S=e.writingMode;S&&S!=="horizontal-tb"&&(b+=y("writing-mode",S));let x=e.textLength;x!==void 0&&x>0&&(b+=y("textLength",x),e.lengthAdjust==="spacingAndGlyphs"&&(b+=y("lengthAdjust","spacingAndGlyphs")));let v=e.textDirection;v&&v!=="ltr"&&(b+=y("direction",v));let w=e.unicodeBidi;w&&w!=="normal"&&(b+=y("unicode-bidi",w));let T=e.shapeInsideRef;if(T){b+=y("shape-inside",`url(#${T})`);let D=e.shapePadding;D!==void 0&&(b+=y("shape-padding",D))}let P=Kt(e),R=e.fontVariationSettings,M="";if(R&&Object.keys(R).length>0&&(M=`font-variation-settings: ${Object.entries(R).map(([L,K])=>`'${L}' ${K}`).join(", ")}`),b+=Jd([P,M,Qd("inline-size",e.inlineSize),typeof e.overflowWrap=="string"?`overflow-wrap: ${e.overflowWrap}`:"",typeof e.whiteSpace=="string"?`white-space: ${e.whiteSpace}`:"",typeof e.lineHeight=="number"?`line-height: ${e.lineHeight}`:""]),b+=_e(e,n.id),g&&(b+=y("transform",g)),e.isTextPath&&e.textPathPoints){let D=e.textPathPoints,L=e.textPathStartOffset??0,K=e.textPathSide,C=`text-path-${n.id}`,ne=e.textPathMethod,Q=e.textPathSpacing,Z=e.textPathLengthAdjust,me=e.textPathLength,Y="";if(D.length>=2)if(K==="right"){let W=D[D.length-1];Y=`M ${W.x} ${W.y}`;for(let de=D.length-1;de>0;de--){let he=D[de],Te=D[de-1],$e=he.handleIn??he,lt=Te.handleOut??Te;Y+=` C ${$e.x} ${$e.y}, ${lt.x} ${lt.y}, ${Te.x} ${Te.y}`}}else{Y=`M ${D[0].x} ${D[0].y}`;for(let W=0;W<D.length-1;W++){let de=D[W],he=D[W+1],Te=de.handleOut??de,$e=he.handleIn??he;Y+=` C ${Te.x} ${Te.y}, ${$e.x} ${$e.y}, ${he.x} ${he.y}`}}return`<defs><path id="${q(C)}"${y("d",Y)} fill="none"/></defs><text${b}><textPath href="#${q(C)}"${y("startOffset",`${L}%`)}${y("method",ne)}${y("spacing",Q)}${y("lengthAdjust",Z)}${y("textLength",me)}>${q(i)}</textPath></text>`}if(e.charOffsets&&Array.isArray(e.charOffsets)&&e.charOffsets.length>0){let D=e.charOffsets.map(ef),L=i.split(`
12
- `),K=e.linePositions??[],C=s*m,ne="",Q=0;return L.forEach((Z,me)=>{let Y=Array.from(Z).length,W=D.slice(Q,Q+Y),de=K[me],he=de?t+de.x:me>0?t:NaN,Te=de?de.dy:me>0?C:NaN,$e="",lt=io(W,"x");if(Number.isFinite(he)||lt.length>0){let Qn=lt.length>0?lt.slice():[];Number.isFinite(he)&&(Qn[0]=Qn[0]??he),$e+=y("x",Qn.join(" "))}let Ts=io(W,"y");Ts.length>0&&($e+=y("y",Ts.join(" ")));let ws=so(W,"dx");ws.length>0&&($e+=y("dx",ws.join(" ")));let Ps=so(W,"dy"),Ge=Ps.length>0||Number.isFinite(Te)?Ps.slice():[];for(Number.isFinite(Te)&&(Ge[0]=(Ge[0]??0)+Te);Ge.length>0&&Ge[Ge.length-1]===0;)Ge.pop();Ge.length>0&&($e+=y("dy",Ge.join(" ")));let _s=tf(W);_s.length>0&&($e+=y("rotate",_s.join(" "))),ne+=`<tspan${$e}>${q(Z)}</tspan>`,Q+=Y+1}),`<text${b}>${ne}</text>`}let B=kr(e);if(B){let D=je(B),L=e.linePositions,K=s*D.lineHeight,C="";return D.lines.forEach((ne,Q)=>{ne.segments.forEach((Z,me)=>{let Y="";if(me===0){let W=L?.[Q];W?((Math.abs(W.x)>.001||Q>0)&&(Y+=y("x",t+W.x)),(Math.abs(W.dy)>.001||Q>0)&&(Y+=y("dy",W.dy))):Q>0&&(Y+=y("x",t),Y+=y("dy",`${K}px`))}for(let{name:W,value:de}of gi(Z.style,D.baseStyle))Y+=y(W,de);Y+=' xml:space="preserve"',C+=`<tspan${Y}>${q(En(Z.text,Z.style.textTransform))}</tspan>`})}),`<text${b}>${C}</text>`}return`<text${b}>${q(i)}</text>`}function fo(n){let e=n.state,t=e.pathPoints??[],r=e.pathCurveType??"CUBIC",i=e.pathClosed??!1,s=e.pathTension??.5,o=e.pathArcParams,a=rt(t,r,i,s,o),l=t.length>0?e.customPivot??{x:t[0].x,y:t[0].y}:void 0,c=l?Re(e,l):null;return`<path${y("d",a)}${_e(e,n.id)}${bi(e)}${c?y("transform",c):""}/>`}function po(n){let e=n.state,t=e.polylinePoints??[],r=e.polylineClosed??!1,i=t.map(l=>`${l.x},${l.y}`).join(" "),s=t.length>0?e.customPivot??{x:t[0].x,y:t[0].y}:void 0,o=s?Re(e,s):null;return`<${r?"polygon":"polyline"}${y("points",i)}${_e(e,n.id)}${bi(e)}${o?y("transform",o):""}/>`}function mo(n){let e=n.state,t=e.x??0,r=e.y??0,i=e.width??100,s=e.height??100,o=e.href??"",a=e.imageOpacity,l=e.preserveAspectRatio?"xMidYMid meet":"none",c={x:t+i/2,y:r+s/2},f=Re(e,c);return`<image${y("x",t)}${y("y",r)}${y("width",i)}${y("height",s)}${y("href",o)}${y("preserveAspectRatio",l)}${a!==void 0&&a<1?y("opacity",a):""}${_e(e,n.id)}${f?y("transform",f):""}/>`}function Ln(n){return!n||n.length===0?"":n.map(e=>fe(e)).join("")}function ho(n){let e=n.state,t="",r=Re(e);r&&(t+=y("transform",r));let i=e.opacity;i!==void 0&&i<1&&(t+=y("opacity",i));let s=e.metadata;s&&(s.role&&(t+=y("role",s.role)),s.ariaLabel&&(t+=y("aria-label",s.ariaLabel)));let o=e.containerPresentation;if(o)for(let[l,c]of Object.entries(o))/^[a-zA-Z_:][-a-zA-Z0-9_:.]*$/.test(l)&&(t+=` ${l}="${q(c)}"`);let a=e.authoredAttributes;if(a)for(let[l,c]of Object.entries(a))c===null||!/^[a-zA-Z_:][-a-zA-Z0-9_:.]*$/.test(l)||(t+=` ${l}="${q(c)}"`);return t}function uf(n){let e=n.state,t=e.href,r=e.hrefXlink,i="<a";return t!==void 0&&(i+=y("href",t)),r!==void 0&&(i+=y("xlink:href",r)),i+=y("target",e.linkTarget),i+=y("rel",e.linkRel),e.linkDownload===""?i+=' download=""':i+=y("download",e.linkDownload),i+=y("ping",e.linkPing),i+=y("hreflang",e.linkHreflang),i+=y("type",e.linkType),i+=y("referrerpolicy",e.linkReferrerPolicy),i+=ho(n),i+=y("data-shape-id",n.id),i+=">",i+=yi(e),i+=Ln(e.children),i+="</a>",i}function cf(n){let e=n.state,t="<switch";return t+=vt("systemLanguage",e.switchSystemLanguage),t+=vt("requiredExtensions",e.switchRequiredExtensions),t+=ho(n),t+=y("data-shape-id",n.id),t+=">",t+=yi(e),t+=Ln(e.children),t+="</switch>",t}function df(n){let e=n.state,t=Re(e),r="<g";return r+=y("data-shape-id",n.id),t&&(r+=y("transform",t)),e.opacity!==void 0&&e.opacity<1&&(r+=y("opacity",e.opacity)),e.visibility&&(r+=y("visibility",e.visibility)),e.blendMode&&(r+=y("style",`mix-blend-mode:${e.blendMode}`)),r+=">",r+=Ln(e.children),r+="</g>",r}function ff(n){let e=n.state,t=e.viewBoxX,r=e.viewBoxY,i=e.viewBoxWidth,s=e.viewBoxHeight,o=t!==void 0&&r!==void 0&&i!==void 0&&s!==void 0?`${t} ${r} ${i} ${s}`:void 0,a="<view";return a+=y("id",n.id),a+=y("viewBox",o),a+=y("preserveAspectRatio",e.viewPreserveAspectRatio),a+=y("zoomAndPan",e.viewZoomAndPan),a+=y("viewTarget",e.viewTarget),e.viewName&&(a+=y("data-view-name",e.viewName)),a+="/>",a}function pf(n){let e=n.state,t=e.svgX,r=e.svgY,i=e.svgWidth,s=e.svgHeight,o=e.svgViewBoxX,a=e.svgViewBoxY,l=e.svgViewBoxWidth,c=e.svgViewBoxHeight,f=o!==void 0&&a!==void 0&&l!==void 0&&c!==void 0?`${o} ${a} ${l} ${c}`:void 0,d="<svg";return d+=y("xmlns","http://www.w3.org/2000/svg"),d+=y("x",t),d+=y("y",r),d+=y("width",i),d+=y("height",s),d+=y("viewBox",f),d+=y("preserveAspectRatio",e.svgPreserveAspectRatio),d+=y("data-shape-id",n.id),d+=">",d+=Ln(e.children),d+="</svg>",d}function mf(n){let e=n.state,t=e.targetShapeId;if(!t)return`<!-- shape-reference ${q(n.id)} has no targetShapeId -->`;let r=e.offsetX??0,i=e.offsetY??0,s="<use";return s+=y("href",`#${t}`),s+=y("x",r),s+=y("y",i),e.width!==void 0&&(s+=y("width",e.width)),e.height!==void 0&&(s+=y("height",e.height)),s+=y("data-shape-id",n.id),e.opacity!==void 0&&e.opacity<1&&(s+=y("opacity",e.opacity)),s+="/>",s}function go(n){let e=n.state,t=jt(n),r=e.x??0,i=e.y??0,s=e.width??100,o=e.height??100;return`<use href="#${q(t)}" x="${r}" y="${i}" width="${s}" height="${o}"/>`}function hf(n){let e=n.state,t=e.mediaKind??n.type,r=e.x??0,i=e.y??0,s=e.width??320,o=e.height??180,a=e.href??"",l=e.mediaMimeType,c=e.posterHref,f=e.mediaOpacity,d=`<${t} xmlns="http://www.w3.org/1999/xhtml"`;d+=y("src",a),l&&(d+=y("type",l)),c&&t==="video"&&(d+=y("poster",c)),e.muted&&(d+=' muted=""'),e.loop&&(d+=' loop=""'),e.playbackRate!==void 0&&(d+=y("data-playback-rate",e.playbackRate)),e.volume!==void 0&&(d+=y("data-volume",e.volume)),d+=' preload="auto" playsinline=""',d+=t==="video"?' style="width:100%;height:100%;display:block;"></video>':"></audio>";let p="<foreignObject";return p+=y("x",r),p+=y("y",i),p+=y("width",s),p+=y("height",o),p+=y("data-shape-id",n.id),p+=y("data-media-kind",t),e.naturalDuration!==void 0&&(p+=y("data-natural-duration",e.naturalDuration)),e.begin!==void 0&&(p+=y("data-begin",e.begin)),e.trimStart!==void 0&&(p+=y("data-trim-start",e.trimStart)),e.trimEnd!==void 0&&(p+=y("data-trim-end",e.trimEnd)),e.fadeInDuration!==void 0&&(p+=y("data-fade-in",e.fadeInDuration)),e.fadeOutDuration!==void 0&&(p+=y("data-fade-out",e.fadeOutDuration)),p+=vt("systemLanguage",e.systemLanguage),p+=vt("requiredExtensions",e.requiredExtensions),f!==void 0&&f<1&&(p+=y("opacity",f)),p+=">",p+=d,p+="</foreignObject>",p}function yo(n){let e=n.state,t=e.x??0,r=e.y??0,i=e.width??100,s=e.height??60,o={x:t+i/2,y:r+s/2},a=Re(e,o),l=li(n.type,t,r,i,s,{slantPercent:e.slantPercent,topWidthPercent:e.topWidthPercent,capHeightPercent:e.capHeightPercent,waveAmplitudePercent:e.waveAmplitudePercent});return`<path${y("d",l)}${_e(e,n.id)}${a?y("transform",a):""}/>`}function bo(n){let e=n.state,t=e.cx??0,r=e.cy??0,i=e.radius??50,s=e.cornerRadius??0,o=e.shiftAngle??-90,a=e.fillRule??"nonzero",l=nf(e,t,r),c="";switch(n.type){case"triangle":c=Ce(Pn(3,i,o),s,i);break;case"ngon":{let d=e.sides??6;c=Ce(Pn(d,i,o),s,i);break}case"star":{let d=e.arms??5,p=e.innerRadiusPercent??50;c=Ce(Zr(d,i,p,o),s,i);break}case"cross":{let d=e.armWidthPercent??40;c=Ce(Jr(i,d,o),s,i);break}case"ring":{let d=e.innerRadiusPercent??50;c=ii(i,d,a);break}case"spiral":{let d=e.turns??3,p=e.thicknessPercent??20,m=e.spiralDirection??1;c=si(i,d,p,m,o);break}case"gear":{let d=e.teeth??8,p=e.toothDepthPercent??30,m=e.holeRadiusPercent??0;c=ai(d,i,p,s,m,a,o);break}case"arrow":{let d=e.headWidthPercent??100,p=e.headLengthPercent??30,m=e.shaftWidthPercent??40;c=Ce(Qr(i,d,p,m,o),s,i);break}case"speechBubble":{let d=e.tailAngleDeg??45,p=e.tailLengthPercent??40,m=e.tailWidthPercent??25;c=Ce(ei(i,d,p,m,o),s,i);break}case"lightning":{let d=e.boltSegments??3,p=e.boltJaggednessPercent??40,m=e.boltWidthPercent??30;c=Ce(ti(i,d,p,m,o),s,i);break}case"heart":{let d=e.lobeRadiusPercent??50,p=e.cleftDepthPercent??25;c=ni(i,d,p,o);break}case"cloud":{let d=e.cloudBumps??5,p=e.cloudPuffinessPercent??60;c=ri(i,d,p,o);break}default:return`<!-- unsupported polygon shape: ${q(n.type)} -->`}let f="";return(n.type==="ring"||n.type==="gear")&&(f=y("fill-rule",a)),`<path${y("d",c)}${f}${_e(e,n.id)}${y("transform",l)}/>`}function fe(n){let e;switch(n.type){case"circle":e=ao(n);break;case"ellipse":e=oo(n);break;case"rectangle":case"square":e=lo(n);break;case"line":e=uo(n);break;case"text":e=co(n);break;case"path":e=fo(n);break;case"polyline":e=po(n);break;case"image":e=mo(n);break;case"triangle":case"ngon":case"star":case"cross":case"ring":case"spiral":case"gear":case"arrow":case"speechBubble":case"lightning":case"heart":case"cloud":e=bo(n);break;case"diamond":case"parallelogram":case"trapezoid":case"terminator":case"cylinder":case"document-shape":e=yo(n);break;case"hyperlink":e=uf(n);break;case"switch":e=cf(n);break;case"container":case"group":e=df(n);break;case"view":e=ff(n);break;case"svg":e=pf(n);break;case"shape-reference":e=mf(n);break;case"symbol-instance":e=go(n);break;case"audio":case"video":e=hf(n);break;default:return`<!-- unsupported shape type: ${q(n.type)} -->`}return lf(e,n.state)}function So(n,e){let t=(e.stops??[]).map(o=>{let a=`<stop${y("offset",`${o.offset*100}%`)}${y("stop-color",o.color)}`;return o.opacity!==void 0&&o.opacity<1&&(a+=y("stop-opacity",o.opacity)),a+="/>",a}).join(""),r=e.gradientUnits==="userSpaceOnUse",i=o=>r?String(o):`${o*100}%`,s=r?y("gradientUnits","userSpaceOnUse"):"";return`<linearGradient${y("id",n)}${s}${y("x1",i(e.x1))}${y("y1",i(e.y1))}${y("x2",i(e.x2))}${y("y2",i(e.y2))}${e.spreadMethod?y("spreadMethod",e.spreadMethod):""}>${t}</linearGradient>`}function xo(n,e){let t=(e.stops??[]).map(f=>{let d=`<stop${y("offset",`${f.offset*100}%`)}${y("stop-color",f.color)}`;return f.opacity!==void 0&&f.opacity<1&&(d+=y("stop-opacity",f.opacity)),d+="/>",d}).join(""),r=e.gradientUnits==="userSpaceOnUse",i=f=>r?String(f):`${f*100}%`,s=r?y("gradientUnits","userSpaceOnUse"):"",o="",a=e.ry!==void 0&&e.ry!==e.r,l=!!e.rotation;if(a||l){let f=e.cx??(r?0:.5),d=e.cy??(r?0:.5),p=[];p.push(`translate(${f}, ${d})`),l&&p.push(`rotate(${e.rotation})`),a&&e.ry!==0&&p.push(`scale(1, ${e.ry/e.r})`),p.push(`translate(-${f}, -${d})`),o=y("gradientTransform",p.join(" "))}let c=e.fr!==void 0&&e.fr>0?y("fr",i(e.fr)):"";return`<radialGradient${y("id",n)}${s}${y("cx",i(e.cx))}${y("cy",i(e.cy))}${y("fx",i(e.fx))}${y("fy",i(e.fy))}${y("r",i(e.r))}${c}${e.spreadMethod?y("spreadMethod",e.spreadMethod):""}${o}>${t}</radialGradient>`}function $o(n,e){if(e.svgContent!=null){let a=e.width??10,l=e.height??10,c=e.patternUnits??"userSpaceOnUse",f=e.patternContentUnits,d=e.patternTransform,p=e.viewBox,m=e.preserveAspectRatio,h=e.x??0,g=e.y??0,b=`<pattern${y("id",n)}`;return b+=y("patternUnits",c),f&&(b+=y("patternContentUnits",f)),h&&(b+=y("x",h)),g&&(b+=y("y",g)),b+=y("width",a),b+=y("height",l),p&&(b+=y("viewBox",p)),m&&(b+=y("preserveAspectRatio",m)),d&&(b+=y("patternTransform",d)),b+=`>${e.svgContent}</pattern>`,b}let t=10*(e.scale??1),r=e.rotation??0,i=e.color||"#000000",s=e.backgroundColor||"#ffffff",o="";return o+=`<rect${y("width",t)}${y("height",t)}${y("fill",s)}/>`,o+=gf(e.patternType,t,i),`<pattern${y("id",n)}${y("patternUnits","userSpaceOnUse")}${y("width",t)}${y("height",t)}${r?y("patternTransform",`rotate(${r})`):""}>${o}</pattern>`}function gf(n,e,t){return Dn(n,e,t).map(i=>{let s=Object.entries(i.attrs).map(([o,a])=>y(o,a)).join("");return`<${i.tag}${s}/>`}).join("")}function Be(n,e=[]){let t=Array.isArray(n)?Cn(n,e):n;if(t.ids.size===0&&t.legacyEndpoints.size===0)return"";let r="",i=$t();for(let s of i){let o=s.id,a=o.replace("line-marker-",""),l=`mkr-builtin-${a}`,c=t.legacyEndpoints.has(a)||t.ids.has(o),f=t.ids.has(l);if(!c&&!f)continue;let d=s.element,p=Object.entries(d.attrs).map(([g,b])=>y(g,b)).join(""),m=`<${d.tag}${p}/>`,h=g=>{r+=`<marker${y("id",g)}${y("viewBox",Fn)}${y("refX",s.refX)}${y("refY",s.refY)}${y("markerWidth",6)}${y("markerHeight",6)}${y("orient","auto-start-reverse")}>${m}</marker>`};c&&h(o),f&&h(l)}return r}var ze=n=>n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),vo=["linear-gradient","radial-gradient","pattern","filter","marker","symbol"];function ko(n){switch(n.kind){case"symbol":return To(n);case"marker":return wo(n);case"linear-gradient":return Po(n);case"radial-gradient":return _o(n);case"pattern":return Ro(n);case"filter":return Ao(n)}}function To(n){let e=n.shapes.map(i=>fe(i)).join(""),t=n.viewBox?` viewBox="${ze(n.viewBox)}"`:"",r=n.overflow?` overflow="${ze(n.overflow)}"`:"";return`<symbol id="${ze(n.id)}"${t}${r}>${e}</symbol>`}function wo(n){let e;if(n.builtIn){let s=$t().find(o=>n.id.includes(o.id)||n.id===o.id);if(s){let o=Object.entries(s.element.attrs).map(([a,l])=>` ${a}="${ze(String(l))}"`).join("");e=`<${s.element.tag}${o}/>`}else e=""}else e=n.shapes.map(s=>fe(s)).join("");let t=typeof n.orient=="number"?String(n.orient):n.orient,r=n.viewBox?` viewBox="${ze(n.viewBox)}"`:"",i=n.overflow?` overflow="${ze(n.overflow)}"`:"";return`<marker id="${ze(n.id)}"${r} refX="${n.refX}" refY="${n.refY}" markerWidth="${n.markerWidth}" markerHeight="${n.markerHeight}" markerUnits="${ze(n.markerUnits)}" orient="${ze(t)}"${i}>${e}</marker>`}function Po(n){let e={...n.gradient,type:"linear-gradient",id:n.id};return So(n.id,e)}function _o(n){let e={...n.gradient,type:"radial-gradient",id:n.id};return xo(n.id,e)}function Ro(n){let e={...n.pattern,type:"pattern",id:n.id};return $o(n.id,e)}function Ao(n){return ci(n.id,n.filters,{colorInterpolation:n.colorInterpolation,filterUnits:n.filterUnits,primitiveUnits:n.primitiveUnits,x:n.x,y:n.y,width:n.width,height:n.height})}function Nn(n){let e=new Map;for(let r of n){let i=e.get(r.kind);i?i.push(r):e.set(r.kind,[r])}let t="";for(let r of vo){let i=e.get(r);if(i)for(let s of i)t+=ko(s)}return t}function it(n,e){let t=Bn(n,e);return t.length===0?"":Nn(t)}function Bn(n,e){let t=new Map;for(let l of e)t.set(l.id,l);let r=new Map,i=l=>{if(!l)return;let c=t.get(l);c&&r.set(l,c)},s=(l,c)=>{if(!l||typeof l!="object")return;let f=l;if(!f.id||r.has(f.id))return;let d=c==="linear-gradient"?"linear-gradient":c==="radial-gradient"?"radial-gradient":c==="pattern"?"pattern":null;if(!d)return;let{id:p,sourceId:m,...h}=l,g;if(d==="linear-gradient")g={kind:"linear-gradient",id:f.id,name:m??f.id,sourceId:m,gradient:h};else if(d==="radial-gradient")g={kind:"radial-gradient",id:f.id,name:m??f.id,sourceId:m,gradient:h};else{let{customPatternId:b,...$}=h;g={kind:"pattern",id:f.id,name:m??f.id,sourceId:m,pattern:$}}r.set(f.id,g)},o=(l,c)=>{let f=l.filters;if(!Array.isArray(f)||f.length===0)return;let d=`filter-${c}`;r.has(d)||r.set(d,{kind:"filter",id:d,name:d,filters:f,...l.filterColorInterpolation&&l.filterColorInterpolation!=="auto"?{colorInterpolation:l.filterColorInterpolation}:{},...l.filterUnits?{filterUnits:l.filterUnits}:{},...l.primitiveUnits?{primitiveUnits:l.primitiveUnits}:{},...typeof l.filterX=="string"?{x:l.filterX}:{},...typeof l.filterY=="string"?{y:l.filterY}:{},...typeof l.filterWidth=="string"?{width:l.filterWidth}:{},...typeof l.filterHeight=="string"?{height:l.filterHeight}:{}})},a=l=>{let c=l.state;if(!c)return;i(c.fillLibraryId),i(c.strokeLibraryId),i(c.markerStart),i(c.markerMid),i(c.markerEnd),i(c.symbolId);let f=c.filterLibraryIds;if(Array.isArray(f))for(let d of f)typeof d=="string"&&i(d);c.fillLibraryId||s(c.fillGradient,c.fillType),c.strokeLibraryId||s(c.strokeGradient,c.strokeType),(!Array.isArray(f)||f.length===0)&&o(c,l.id)};for(let l of n)a(l);return Mn(n,e,a),Array.from(r.values())}function Io(n){return n.easing==="custom-bezier"&&n.customBezier?n.customBezier:tr[n.easing]??null}function Mo(n,e,t,r,i){if(n===e&&t===r)return i;let s=1e-6,o=8,a=m=>(((1-3*t+3*n)*m+(3*t-6*n))*m+3*n)*m,l=m=>(((1-3*r+3*e)*m+(3*r-6*e))*m+3*e)*m,c=m=>(3*(1-3*t+3*n)*m+2*(3*t-6*n))*m+3*n,f=i;for(let m=0;m<o;m++){let h=a(f)-i;if(Math.abs(h)<s)return l(f);let g=c(f);if(Math.abs(g)<s)break;f-=h/g}let d=0,p=1;for(f=i;d<p;){let m=a(f);if(Math.abs(m-i)<s)return l(f);i>m?d=f:p=f;let h=(p-d)*.5+d;if(h===f)break;f=h}return l(f)}function Co(n){let e=n.split(/\s+/).map(parseFloat);if(e.length!==4||e.some(o=>!Number.isFinite(o)))return n;let[t,r,i,s]=e;return`${1-i} ${1-s} ${1-t} ${1-r}`}function xe(n){return!Number.isFinite(n)||Math.abs(n)<1e-9?"0":Math.abs(n-1)<1e-9?"1":parseFloat(n.toFixed(6)).toString()}function Si([n,e,t,r]){let i=s=>Number.isFinite(s)?parseFloat(s.toFixed(6)).toString():"0";return`${i(n)} ${i(e)} ${i(t)} ${i(r)}`}function Do(n){return n.length>0&&n.every(e=>e==="0 0 1 1")}function Gn(n){if(n.length<2)return!1;let e=n.length-1,t=1e-4;for(let r=0;r<n.length;r++){let i=r/e,s=parseFloat(n[r]);if(!Number.isFinite(s)||Math.abs(s-i)>t)return!1}return!0}function xi(n){if(n.length<2)return!1;let e=n.length-1,t=1e-4;for(let r=0;r<n.length;r++)if(Math.abs(n[r]-r/e)>t)return!1;return!0}function st(n){let e=n.cycleDuration??(n.keyframes.length>0?n.keyframes[n.keyframes.length-1].time:0);return n.cycleBehavior==="alternate"?e*2:e}function kt(n){let e=n.beginTrigger;if(e)switch(e.type){case"time":{let r=parseFloat(e.value);return Number.isNaN(r)?"":Number.isFinite(r)?r!==0?`${r}s`:"":"indefinite"}case"event":return e.value;case"expression":return"";default:break}let t=n.keyframes[0]?.time??0;return t!==0?`${t}s`:""}function $i(n){return n.keyframes.length===1&&n.cycleDuration===void 0}function vi(n){return n.calcMode!=="discrete"?!1:n.sourceSmilElement==="set"?!0:!n.sourceSmilElement&&!n.cycleInfinite&&n.keyframes.every(e=>e.easing!=="steps")}function ki(n,e){if(e<=0)return kt(n);if(kt(n)==="indefinite")return"indefinite";let t=n.keyframes[e]?.time??0;return t!==0?`${t}s`:""}function Ti(n){return n.cycleInfinite?"indefinite":n.cycleRepeats&&n.cycleRepeats>1?String(n.cycleRepeats):null}function Tt(n){return n.cycleInfinite||n.fill==="remove"?null:"freeze"}function wi(n){return n.additive==="sum"?"sum":null}function Pi(n){return n.keyframes.map(e=>{let t=typeof e.value=="number"?e.value:parseFloat(String(e.value));return Number.isFinite(t)?Math.max(0,Math.min(1,t)):0})}function yf(n){let e=t=>Math.max(0,Math.min(1,t));return[n[0],e(n[1]),n[2],e(n[3])]}function bf(n){let[e,t,r,i]=n,s=new Set,o=8;for(let d=1;d<=o;d++)s.add(d/o);let a=t-2*i+1,l=2*(i-2*t),c=t,f=d=>{if(!Number.isFinite(d)||d<=0||d>=1)return;let p=3*(1-d)**2*d*e+3*(1-d)*d**2*r+d**3;p>0&&p<1&&s.add(Number(p.toFixed(6)))};if(Math.abs(a)<1e-9)Math.abs(l)>=1e-9&&f(-c/l);else{let d=l*l-4*a*c;if(d>=0){let p=Math.sqrt(d);f((-l+p)/(2*a)),f((-l-p)/(2*a))}}return[...s].sort((d,p)=>d-p)}function Sf(n,e,t,r,i,s){let o=typeof n.value=="number"&&typeof e.value=="number",a=Ye(e.value);if(e.easing==="linear-function"&&e.linearPoints&&e.linearPoints.length>=2){if(o){let b=e.linearPoints;for(let $=1;$<b.length;$++){let k=b[$],S=n.time+(e.time-n.time)*k.position,x=n.value+(e.value-n.value)*k.value;r.push(x),i.push(xe(t(S))),s.push("0 0 1 1")}return}r.push(a),i.push(xe(t(e.time))),s.push("0 0 1 1");return}if(e.easing==="steps"){r.push(a),i.push(xe(t(e.time))),s.push("0 0 1 1");return}let l=Io(e);if(!l){r.push(a),i.push(xe(t(e.time))),s.push("0 0 1 1");return}let[,c,,f]=l;if(!(c<0||c>1||f<0||f>1)){r.push(a),i.push(xe(t(e.time))),s.push(Si(l));return}if(!o){r.push(a),i.push(xe(t(e.time))),s.push(Si(yf(l)));return}let p=bf(l),m=n.value,h=e.value,g=e.time-n.time;for(let b of p){let $=Mo(l[0],l[1],l[2],l[3],b),k=n.time+g*b,S=m+(h-m)*$;r.push(S),i.push(xe(t(k))),s.push("0 0 1 1")}}function Ye(n){return Array.isArray(n)?n.join(" "):n}function xf(n,e,t){let r=[],{count:i,position:s}=t,o=e.time-n.time,a=Ye(n.value),l=Ye(e.value),c=typeof a=="number"&&typeof l=="number",f=typeof a=="string"&&typeof l=="string",d=h=>f?h<.5?a:l:c?a+(l-a)*h:h>=1?l:a,p=h=>{let g=Math.floor(h*i);(s==="jump-start"||s==="jump-both")&&(g+=1);let b;switch(s){case"jump-start":case"jump-end":b=i;break;case"jump-none":b=i-1;break;case"jump-both":b=i+1;break}return g>b&&(g=b),g<0&&(g=0),g/b},m=p(0);for(let h=1;h<=i;h++){let g=h/i,b=p(g);if(b===m)continue;let $=n.time+g*o;r.push({value:d(b),time:$}),m=b}return r.length===0||r[r.length-1].time<e.time?r.push({value:l,time:e.time}):r[r.length-1]={value:l,time:e.time},r}function $f(n,e){let t=[],r=[],i=(s,o)=>{t.push(s),r.push(xe(e(o)))};i(Ye(n[0].value),n[0].time);for(let s=1;s<n.length;s++){let o=n[s-1],a=n[s];if(a.easing==="steps"&&a.stepsParams){let l=xf(o,a,a.stepsParams);for(let c of l)i(c.value,c.time)}else i(Ye(a.value),a.time)}return{values:t,keyTimes:r}}function zn(n,e,t,r,i){if(i.cycleBehavior!=="alternate"||n.length<2)return{values:n,keyTimes:e,keySplines:t,calcMode:r};let s=n.slice(0,-1).reverse(),o=e.slice(0,-1).reverse().map(l=>xe(1-parseFloat(l))),a=t.slice().reverse().map(Co);return{values:[...n,...s],keyTimes:[...e,...o],keySplines:[...t,...a],calcMode:r}}function at(n){let e=n.keyframes;if(e.length===0)return{values:[],keyTimes:[],keySplines:[],calcMode:"spline"};let t=st(n),r=e[0]?.time??0,i=c=>t>0?(c-r)/t:0;if(e.some(c=>c.easing==="steps")){let{values:c,keyTimes:f}=$f(e,i);return zn(c,f,[],"discrete",n)}if(n.calcMode==="discrete"){let c=e.map(d=>Ye(d.value)),f=e.map(d=>xe(i(d.time)));return zn(c,f,[],"discrete",n)}if(n.calcMode==="paced"){let c=e.map(d=>Ye(d.value)),f=e.map(d=>xe(i(d.time)));return zn(c,f,[],"paced",n)}let o=[Ye(e[0].value)],a=[xe(i(e[0].time))],l=[];for(let c=1;c<e.length;c++)Sf(e[c-1],e[c],i,o,a,l);return zn(o,a,l,"spline",n)}function Vn(n,e={}){let t=e.defaultCalcMode??"linear",r={};if(n.calcMode==="paced")return t!=="paced"&&(r.calcMode="paced"),r;if(n.calcMode==="discrete")return r.keyTimes=n.keyTimes.join(";"),r.calcMode="discrete",r;let i=n.keySplines.length>0&&!Do(n.keySplines);return Gn(n.keyTimes)||(r.keyTimes=n.keyTimes.join(";")),i&&(r.calcMode="spline",r.keySplines=n.keySplines.join(";")),r}function Fo(n,e){if(n.shapeId!==e.shapeId||n.keyframes.length!==e.keyframes.length||(n.cycleDuration??-1)!==(e.cycleDuration??-1)||(n.cycleRepeats??1)!==(e.cycleRepeats??1)||!!n.cycleInfinite!=!!e.cycleInfinite||(n.cycleBehavior??"restart")!==(e.cycleBehavior??"restart")||(n.additive??"replace")!==(e.additive??"replace")||(n.calcMode??"linear")!==(e.calcMode??"linear")||!!n.locked!=!!e.locked)return!1;let t=(r,i)=>!r&&!i||!!r&&!!i&&r.type===i.type&&r.value===i.value;if(!t(n.beginTrigger,e.beginTrigger)||!t(n.endTrigger,e.endTrigger))return!1;for(let r=0;r<n.keyframes.length;r++){let i=n.keyframes[r],s=e.keyframes[r];if(i.time!==s.time||i.easing!==s.easing)return!1;let o=i.customBezier,a=s.customBezier;if(!!o!=!!a)return!1;if(o&&a){for(let l=0;l<4;l++)if(o[l]!==a[l])return!1}if(JSON.stringify(i.linearPoints??null)!==JSON.stringify(s.linearPoints??null)||JSON.stringify(i.stepsParams??null)!==JSON.stringify(s.stepsParams??null))return!1}return!0}function _i(n){let e=new Map,t=new Set,r=new Map;for(let i of n){if(!i.enabled||i.keyframes.length<2||i.property!=="translateX"&&i.property!=="translateY"&&i.property!=="scaleX"&&i.property!=="scaleY")continue;let s=r.get(i.shapeId)??[];s.push(i),r.set(i.shapeId,s)}for(let i of r.values()){let s=new Set;for(let o=0;o<i.length;o++){let a=i[o];if(s.has(a.id))continue;let l=a.property==="translateX"||a.property==="translateY",c=l?"translateX":"scaleX",f=l?"translateY":"scaleY";if(!(a.property!==c&&a.property!==f))for(let d=o+1;d<i.length;d++){let p=i[d];if(s.has(p.id)||!(a.property===c&&p.property===f||a.property===f&&p.property===c)||!Fo(a,p))continue;let m=a.property===c?a:p,h=a.property===f?a:p;e.set(m.id,h),t.add(h.id),s.add(m.id),s.add(h.id);break}}}return{partner:e,skip:t}}function Ri(n,e,t,r){if(r){let s=e?r.values:n.values,o=e?n.values:r.values,a=Math.min(s.length,o.length),l=[];for(let c=0;c<a;c++)l.push(`${s[c]} ${o[c]}`);return l}let i=t?"1":"0";return n.values.map(s=>e?`${i} ${s}`:`${s} ${i}`)}var Oo={x:"x",y:"y",cx:"cx",cy:"cy",x1:"x1",y1:"y1",x2:"x2",y2:"y2",posX:"x",posY:"y",radius:"r",r:"r",rx:"rx",ry:"ry",width:"width",height:"height",pathLength:"pathLength",svgX:"x",svgY:"y",svgWidth:"width",svgHeight:"height",opacity:"opacity",fillOpacity:"fill-opacity",strokeOpacity:"stroke-opacity",fillColor:"fill",strokeColor:"stroke",strokeWidth:"stroke-width",strokeDasharray:"stroke-dasharray",strokeDashoffset:"stroke-dashoffset",display:"display",visibility:"visibility",borderWidth:"stroke-width",cornerRadius:"rx",fontSize:"font-size",letterSpacing:"letter-spacing",wordSpacing:"word-spacing",textLength:"textLength",d:"d",pathMorph:"d",polylinePoints:"points"},Lo=new Set(["transformMatrix","rotation","skewX","skewY"]),No=new Set(["translateX","translateY","scaleX","scaleY"]);function Un(n){return n.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function j(n,e){return e==null?"":` ${n}="${Un(e)}"`}function Ai(n,e){let t=Vn(n,e);return j("keyTimes",t.keyTimes)+j("calcMode",t.calcMode)+j("keySplines",t.keySplines)}function Wn(n,e){return j("dur",`${e}s`)+j("begin",kt(n)||null)+j("repeatCount",Ti(n))}function vf(n){let e=Oo[n.property];if(!e)return"";let t=st(n);if(t<=0)return"";let r=at(n);return r.values.length<2?"":"<animate"+j("attributeName",e)+j("values",r.values.join(";"))+Ai(r)+Wn(n,t)+j("fill",Tt(n))+"/>"}function kf(n){let e;switch(n.property){case"transformMatrix":e="matrix";break;case"rotation":e="rotate";break;case"skewX":e="skewX";break;case"skewY":e="skewY";break;default:return""}let t=st(n);if(t<=0)return"";let r=at(n),i=e==="matrix"?r.values.map(o=>wf(o)):r.values.map(o=>String(o));if(i.length<2||i.some(o=>o.length===0))return"";let s=e==="rotate"&&n.transformOrigin?i.map(o=>`${o} ${n.transformOrigin.x} ${n.transformOrigin.y}`):i;return'<animateTransform attributeName="transform"'+j("type",e)+j("values",s.join(";"))+Ai(r)+Wn(n,t)+j("additive",wi(n))+j("fill",Tt(n))+"/>"}function Tf(n,e,t){let r=n.property==="scaleX"||n.property==="scaleY",i=n.property==="translateY"||n.property==="scaleY",s=r?"scale":"translate",o=st(n);if(o<=0)return"";let a=at(n);if(a.values.length<2)return"";let l=e?at(e):void 0,c=Ri(a,i,r,l);if(c.length<2)return"";let f=!n.replacesCarrierBase||t?"sum":null;return'<animateTransform attributeName="transform"'+j("type",s)+j("values",c.join(";"))+Ai(a)+Wn(n,o)+j("additive",f)+j("fill",Tt(n))+"/>"}function wf(n){if(Array.isArray(n)&&n.length>=6){let e=n.slice(0,6);if(e.every(t=>typeof t=="number"&&Number.isFinite(t)))return e.join(" ")}if(typeof n=="string"){let e=n.trim(),t=/^matrix\(([^)]+)\)$/i.exec(e),i=(t?t[1]:e).split(/[\s,]+/).filter(Boolean).map(Number);if(i.length>=6&&i.slice(0,6).every(Number.isFinite))return i.slice(0,6).join(" ")}return""}function Pf(n){if(!n.motionPath)return"";let e=st(n);if(e<=0)return"";let t=at(n),r=Pi(n),i=!!n.motionPathRef&&(n.motionPathRef.mode??"trackShape")==="curveTemplate",s=Vn(t,{defaultCalcMode:"paced"}),o=xi(r)&&Gn(t.keyTimes)&&t.calcMode!=="discrete"&&s.calcMode===void 0,a="<animateMotion";return i||(a+=j("path",n.motionPath)),a+=j("keyTimes",s.keyTimes),o||(a+=j("keyPoints",r.join(";"))),a+=j("calcMode",s.calcMode)+j("keySplines",s.keySplines),a+=Wn(n,e),a+=j("fill",Tt(n)),n.motionRotate!==void 0&&(a+=j("rotate",typeof n.motionRotate=="number"?String(n.motionRotate):n.motionRotate)),i?a+=`><mpath href="#${Un(n.motionPathRef.shapeId)}"/></animateMotion>`:a+="/>",a}function Eo(n,e){if(Lo.has(n.property)||No.has(n.property)||n.property==="pathMotion")return"";let t=Oo[n.property];if(!t)return"";let r=n.keyframes[e];return r?"<set"+j("attributeName",t)+j("to",Array.isArray(r.value)?r.value.join(" "):String(r.value))+j("begin",ki(n,e)||null)+"/>":""}function _f(n){let e=kt(n);return e?`<discard begin="${Un(e)}"/>`:"<discard/>"}function Ii(n){let e=new Map,t=n.tracks.map(a=>({...a,locked:a.locked??!1,keyframes:[...a.keyframes].sort((l,c)=>l.time-c.time).map(l=>({...l,time:l.time,value:l.value,easing:l.easing}))})),r=_i(t),i=new Set,s=new Set,o=(a,l,c)=>{if(!l)return;let f=l;c.sourceSmilId&&!i.has(c.sourceSmilId)&&(i.add(c.sourceSmilId),f=l.replace(/^(<[a-zA-Z]+)/,`$1 id="${Un(c.sourceSmilId)}"`));let d=e.get(a)??[];d.push(f),e.set(a,d)};for(let a of t){if(!a.enabled||r.skip.has(a.id)||a.keyframes.length<1)continue;if(a.property==="discard"){o(a.shapeId,_f(a),a);continue}if($i(a)){o(a.shapeId,Eo(a,0),a);continue}if(vi(a)){for(let c=0;c<a.keyframes.length;c++)o(a.shapeId,Eo(a,c),a);continue}if(a.keyframes.length<2)continue;let l="";a.property==="pathMotion"&&a.motionPath?l=Pf(a):Lo.has(a.property)?(l=kf(a),l&&s.add(a.shapeId)):No.has(a.property)?(l=Tf(a,r.partner.get(a.id),s.has(a.shapeId)),l&&s.add(a.shapeId)):l=vf(a),o(a.shapeId,l,a)}return e}function Xt(n,e={}){let{xmlDeclaration:t=!0,backgroundColor:r,indent:i=!0,className:s}=e,o=n.viewboxes?.[0],a=e.width??o?.width??800,l=e.height??o?.height??600,c=e.viewBox??`0 0 ${a} ${l}`,f=i?`
13
- `:"",d=i?" ":"",p=n.shapes??[],m=p.filter(D=>D.state?.displayMode==="motionOnly"),h=p.filter(D=>D.state?.displayMode!=="motionOnly"),g=Mf(n),b=Cf(n),$=[...Array.isArray(n.library)?n.library:[],...(b??[]).filter(D=>!D.builtIn&&!(Array.isArray(n.library)&&n.library.some(L=>L.id===D.id)))],k=Bn(h,$),S=k.length>0?Nn(k):"",x=Be(h,$),v=Df(g,h,new Set(k.map(D=>D.id))),w=Rf(m),T=S.length>0||x.length>0||v.length>0||w.length>0,P="";T&&(P=`${f}${d}<defs>${f}`,S.length>0&&(P+=`${d}${d}${S}${f}`),x.length>0&&(P+=`${d}${d}${x}${f}`),v.length>0&&(P+=`${d}${d}${v}${f}`),w.length>0&&(P+=`${d}${d}${w}${f}`),P+=`${d}</defs>`);let R="";r&&(R=`${f}${d}<rect width="${a}" height="${l}" fill="${r}"/>`);let M=n.animationTimeline?Ii(n.animationTimeline):null,N=h.map(D=>{let L=fe(D),K=M?.get(D.id);return K&&K.length>0&&(L=Ff(L,K,d)),`${d}${L}`}).join(f),B="";return t&&(B+=`<?xml version="1.0" encoding="UTF-8"?>${f}`),B+='<svg xmlns="http://www.w3.org/2000/svg"',B+=` width="${a}" height="${l}"`,B+=` viewBox="${c}"`,s&&(B+=` class="${s}"`),B+=">",B+=P,B+=R,h.length>0&&(B+=`${f}${N}`),B+=`${f}</svg>${f}`,B}function Rf(n){if(n.length===0)return"";let e=[];for(let t of n){let r=Af(t);if(!r)continue;let i=If(r);e.push(`<path id="${Bo(t.id)}" d="${Bo(i)}"/>`)}return e.join("")}function Af(n){let e=n.state;if(typeof e?.d=="string")return e.d;switch(n.type){case"rectangle":{let t=e?.x??0,r=e?.y??0,i=e?.width??0,s=e?.height??0;return i<=0||s<=0?null:`M${t},${r}h${i}v${s}h${-i}Z`}case"circle":{let t=e?.cx??0,r=e?.cy??0,i=e?.radius??0;return i<=0?null:`M${t-i},${r}A${i},${i} 0 1 0 ${t+i},${r}A${i},${i} 0 1 0 ${t-i},${r}Z`}case"ellipse":{let t=e?.cx??0,r=e?.cy??0,i=e?.rx??0,s=e?.ry??0;return i<=0||s<=0?null:`M${t-i},${r}A${i},${s} 0 1 0 ${t+i},${r}A${i},${s} 0 1 0 ${t-i},${r}Z`}case"line":{let t=e?.x1??0,r=e?.y1??0,i=e?.x2??0,s=e?.y2??0;return`M${t},${r}L${i},${s}`}default:return null}}function If(n){let e=/[Mm]\s*(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)[\s,]+(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)/.exec(n);if(!e)return n;let t=parseFloat(e[1]),r=parseFloat(e[2]);if(!isFinite(t)||!isFinite(r)||t===0&&r===0)return n;let i=!0;return n.replace(/([MLCQSTHVAZ])\s*([\d\s.,e+-]*)/gi,(s,o,a)=>{let l=o.toUpperCase(),c=o!==l,f=i;if(i=!1,l==="Z")return s;let d=a.trim().split(/[\s,]+/).filter(m=>m.length>0).map(Number);if(d.length===0||c&&!f)return s;let p=[];if(l==="H")for(let m of d)p.push(m-t);else if(l==="V")for(let m of d)p.push(m-r);else if(l==="A")for(let m=0;m<d.length;m+=7)p.push(d[m],d[m+1],d[m+2],d[m+3],d[m+4]),m+5<d.length&&p.push(d[m+5]-t),m+6<d.length&&p.push(d[m+6]-r);else for(let m=0;m<d.length;m+=2)p.push(d[m]-t),m+1<d.length&&p.push(d[m+1]-r);return`${o} ${p.join(" ")}`})}function Bo(n){return n.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;")}function Mf(n){let t=(Array.isArray(n.library)?n.library:[]).filter(r=>r.kind==="symbol");return t.length>0?t:n.symbols??[]}function Cf(n){let t=(Array.isArray(n.library)?n.library:[]).filter(r=>r.kind==="marker");return t.length>0?t:n.markers}var Mi=n=>n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");function Df(n,e,t=new Set){if(n.length===0)return"";let r=new Map;for(let l of n)r.set(l.id,l);let i=new Map,s=new Set,o=[...e];for(let l=0;l<o.length;l++){let c=o[l],f=c.state?.children;if(Array.isArray(f)&&o.push(...f),c.type!=="symbol-instance")continue;let d=r.get(c.state.symbolId??"");if(!d)continue;let p=jt(c);if(s.has(p))continue;s.add(p);let m=hi(d,c);o.push(...m),!t.has(p)&&i.set(p,{def:d,resolved:m})}if(i.size===0)return"";let a=[];for(let[l,{def:c,resolved:f}]of i){let d=f.map(h=>fe(h)).join(""),p=c.viewBox?` viewBox="${Mi(c.viewBox)}"`:"",m=c.overflow?` overflow="${Mi(c.overflow)}"`:"";a.push(`<symbol id="${Mi(l)}"${p}${m}>${d}</symbol>`)}return a.join("")}function Ff(n,e,t){let r=e.join(""),i=0;for(;i<n.length;){let c=n.slice(i);if(!/^<defs[\s>]/.test(c))break;let f=n.indexOf("</defs>",i);if(f===-1)break;i=f+7}let s=n.slice(0,i),o=n.slice(i),a=o.lastIndexOf("/>");if(a!==-1){let c=o.match(/^<(\w+)/),f=c?c[1]:"g";return s+o.slice(0,a)+">"+r+`</${f}>`}let l=o.match(/<\/(\w+)>$/);if(l){let c=o.lastIndexOf(`</${l[1]}>`);return s+o.slice(0,c)+r+o.slice(c)}return s+o+r}var wt=Math.PI*2;function Ef(n,e,t,r){let i=e*e-4*n*t;if(!(i>=0))return;let s=Math.sqrt(i),o=-.5*(e+(e>=0?s:-s));if(n!==0){let a=o/n;a>0&&a<1&&r.push(a)}if(o!==0){let a=t/o;a>0&&a<1&&r.push(a)}}function Of(n,e,t,r,i){let s=1-i;return s*s*s*n+3*s*s*i*e+3*s*i*i*t+i*i*i*r}function Lf(n,e,t,r){let i=1-r;return i*i*n+2*i*r*e+r*r*t}function Ci(n,e,t,r){let i=n<r?n:r,s=n>r?n:r,o=-n+3*e-3*t+r,a=2*(n-2*e+t),l=e-n,c=[];Ef(o,a,l,c);for(let f of c){let d=Of(n,e,t,r,f);d<i&&(i=d),d>s&&(s=d)}return{min:i,max:s}}function Di(n,e,t){let r=n<t?n:t,i=n>t?n:t,s=n-2*e+t;if(s!==0){let o=(n-e)/s;if(o>0&&o<1){let a=Lf(n,e,t,o);a<r&&(r=a),a>i&&(i=a)}}return{min:r,max:i}}function zo(n,e,t,r){let i=n*r-e*t>=0?1:-1,s=Math.sqrt((n*n+e*e)*(t*t+r*r));if(s===0)return 0;let o=(n*t+e*r)/s;return o<-1?o=-1:o>1&&(o=1),i*Math.acos(o)}function Uo(n,e,t,r,i,s,o,a,l){if(n===a&&e===l||t===0||r===0)return null;let c=Math.abs(t),f=Math.abs(r),d=i%360*Math.PI/180,p=Math.cos(d),m=Math.sin(d),h=(n-a)/2,g=(e-l)/2,b=p*h+m*g,$=-m*h+p*g,k=b*b,S=$*$,x=c*c,v=f*f,w=k/x+S/v;if(w>1){let me=Math.sqrt(w);c*=me,f*=me,x=c*c,v=f*f}let T=x*S+v*k;if(T===0)return null;let P=(x*v-T)/T;P<0&&(P=0);let R=Math.sqrt(P);s===o&&(R=-R);let M=R*(c*$/f),N=R*(-(f*b)/c),B=p*M-m*N+(n+a)/2,D=m*M+p*N+(e+l)/2,L=(b-M)/c,K=($-N)/f,C=(-b-M)/c,ne=(-$-N)/f,Q=zo(1,0,L,K),Z=zo(L,K,C,ne);return!o&&Z>0?Z-=wt:o&&Z<0&&(Z+=wt),{cx:B,cy:D,rx:c,ry:f,phi:d,theta1:Q,deltaTheta:Z}}function Nf(n,e){let t=Math.cos(n.phi),r=Math.sin(n.phi),i=Math.cos(e),s=Math.sin(e);return{x:n.cx+n.rx*t*i-n.ry*r*s,y:n.cy+n.rx*r*i+n.ry*t*s}}function Bf(n,e,t){if(t>=0){let i=(n-e)%wt;return i<0&&(i+=wt),i<=t}let r=(e-n)%wt;return r<0&&(r+=wt),r<=-t}function Wo(n,e,t,r,i,s,o,a,l){let c={minX:Math.min(n,a),minY:Math.min(e,l),maxX:Math.max(n,a),maxY:Math.max(e,l)},f=Uo(n,e,t,r,i,s,o,a,l);if(!f)return c;let d=Math.cos(f.phi),p=Math.sin(f.phi),m=Math.atan2(-f.ry*p,f.rx*d),h=Math.atan2(f.ry*d,f.rx*p),g=[m,m+Math.PI,h,h+Math.PI];for(let b of g){if(!Bf(b,f.theta1,f.deltaTheta))continue;let $=Nf(f,b);$.x<c.minX&&(c.minX=$.x),$.x>c.maxX&&(c.maxX=$.x),$.y<c.minY&&(c.minY=$.y),$.y>c.maxY&&(c.maxY=$.y)}return c}var zf="MmLlHhVvCcSsQqTtAaZz";function Hn(n){return n>=48&&n<=57}function Gf(n){return n===32||n===9||n===10||n===12||n===13}var Fi=class{constructor(e){this.d=e}d;i=0;skipWsp(){for(;this.i<this.d.length&&Gf(this.d.charCodeAt(this.i));)this.i++}skipCommaWsp(){this.skipWsp(),this.d.charCodeAt(this.i)===44&&(this.i++,this.skipWsp())}atEnd(){return this.skipWsp(),this.i>=this.d.length}readCommand(){this.skipWsp();let e=this.d[this.i];return e!==void 0&&zf.indexOf(e)>=0?(this.i++,e):null}nextIsNumber(){this.skipCommaWsp();let e=this.d.charCodeAt(this.i);return Hn(e)||e===43||e===45||e===46}readNumber(){this.skipCommaWsp();let e=this.d,t=this.i,r=this.i,i=e.charCodeAt(r);(i===43||i===45)&&r++;let s=0;for(;r<e.length&&Hn(e.charCodeAt(r));)r++,s++;if(e.charCodeAt(r)===46)for(r++;r<e.length&&Hn(e.charCodeAt(r));)r++,s++;if(s===0)return null;let o=e.charCodeAt(r);if(o===101||o===69){let l=r+1,c=e.charCodeAt(l);(c===43||c===45)&&l++;let f=0;for(;l<e.length&&Hn(e.charCodeAt(l));)l++,f++;f>0&&(r=l)}let a=Number.parseFloat(e.slice(t,r));return Number.isFinite(a)?(this.i=r,a):null}readFlag(){this.skipCommaWsp();let e=this.d[this.i];return e==="0"?(this.i++,!1):e==="1"?(this.i++,!0):null}};function jn(n,e,t){e<n.minX&&(n.minX=e),e>n.maxX&&(n.maxX=e),t<n.minY&&(n.minY=t),t>n.maxY&&(n.maxY=t),n.any=!0}function Ei(n,e){e.minX<n.minX&&(n.minX=e.minX),e.maxX>n.maxX&&(n.maxX=e.maxX),e.minY<n.minY&&(n.minY=e.minY),e.maxY>n.maxY&&(n.maxY=e.maxY),n.any=!0}function Go(n,e,t,r,i,s,o,a,l){let c=Ci(e,r,s,a),f=Ci(t,i,o,l);Ei(n,{minX:c.min,maxX:c.max,minY:f.min,maxY:f.max})}function Vo(n,e,t,r,i,s,o){let a=Di(e,r,s),l=Di(t,i,o);Ei(n,{minX:a.min,maxX:a.max,minY:l.min,maxY:l.max})}function Ho(n){if(!n)return null;let e=new Fi(n),t={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,any:!1},r=0,i=0,s=0,o=0,a=0,l=0,c=null,f="",d=!1,p=()=>t.any?{minX:t.minX,minY:t.minY,maxX:t.maxX,maxY:t.maxY}:null;for(;!e.atEnd();){let m=e.readCommand();if(m!==null)f=m;else if(f===""||f==="Z"||f==="z"||!e.nextIsNumber())break;if(!d){if(f!=="M"&&f!=="m")return null;d=!0}let h=f>="a"&&f<="z";switch(f){case"M":case"m":{let g=e.readNumber(),b=e.readNumber();if(g===null||b===null)return p();r=h?r+g:g,i=h?i+b:b,s=r,o=i,jn(t,r,i),c=null,f=h?"l":"L";break}case"L":case"l":{let g=e.readNumber(),b=e.readNumber();if(g===null||b===null)return p();r=h?r+g:g,i=h?i+b:b,jn(t,r,i),c=null;break}case"H":case"h":{let g=e.readNumber();if(g===null)return p();r=h?r+g:g,jn(t,r,i),c=null;break}case"V":case"v":{let g=e.readNumber();if(g===null)return p();i=h?i+g:g,jn(t,r,i),c=null;break}case"C":case"c":{let g=e.readNumber(),b=e.readNumber(),$=e.readNumber(),k=e.readNumber(),S=e.readNumber(),x=e.readNumber();if(g===null||b===null||$===null||k===null||S===null||x===null)return p();let v=h?r+g:g,w=h?i+b:b,T=h?r+$:$,P=h?i+k:k,R=h?r+S:S,M=h?i+x:x;Go(t,r,i,v,w,T,P,R,M),a=T,l=P,c="cubic",r=R,i=M;break}case"S":case"s":{let g=e.readNumber(),b=e.readNumber(),$=e.readNumber(),k=e.readNumber();if(g===null||b===null||$===null||k===null)return p();let S=c==="cubic"?2*r-a:r,x=c==="cubic"?2*i-l:i,v=h?r+g:g,w=h?i+b:b,T=h?r+$:$,P=h?i+k:k;Go(t,r,i,S,x,v,w,T,P),a=v,l=w,c="cubic",r=T,i=P;break}case"Q":case"q":{let g=e.readNumber(),b=e.readNumber(),$=e.readNumber(),k=e.readNumber();if(g===null||b===null||$===null||k===null)return p();let S=h?r+g:g,x=h?i+b:b,v=h?r+$:$,w=h?i+k:k;Vo(t,r,i,S,x,v,w),a=S,l=x,c="quad",r=v,i=w;break}case"T":case"t":{let g=e.readNumber(),b=e.readNumber();if(g===null||b===null)return p();let $=c==="quad"?2*r-a:r,k=c==="quad"?2*i-l:i,S=h?r+g:g,x=h?i+b:b;Vo(t,r,i,$,k,S,x),a=$,l=k,c="quad",r=S,i=x;break}case"A":case"a":{let g=e.readNumber(),b=e.readNumber(),$=e.readNumber(),k=e.readFlag(),S=e.readFlag(),x=e.readNumber(),v=e.readNumber();if(g===null||b===null||$===null||k===null||S===null||x===null||v===null)return p();let w=h?r+x:x,T=h?i+v:v;Ei(t,Wo(r,i,g,b,$,k,S,w,T)),r=w,i=T,c=null;break}case"Z":case"z":{r=s,i=o,c=null;break}default:return p()}}return p()}function Vf(n,e,t=!1,r=.5,i){return n.length===0?null:Ho(rt(n,e,t,r,i))}function Oi(n,e){let t=De(n,e);return Xt(n,{width:t.width,height:t.height,xmlDeclaration:e.xmlDeclaration??!1,indent:!0})}function Uf(n){return n==="class"?"className":n==="for"?"htmlFor":n.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}function jo(n){return n.replace(/\s([a-z][a-z-]*?)=/g,(e,t)=>t.startsWith("data-")||t.startsWith("aria-")?e:` ${Uf(t)}=`)}function Li(n,e){let t=e.componentName??"SvgComponent",r=De(n,e),i=e.indent??" ",s=n.shapes??[],o=e.typescript??!1,a=Array.isArray(n.library)?n.library:[],l=it(s,a),c=Be(s,a),f=l+c,d=f.length>0,p=s.map(h=>{let g=fe(h);return`${i}${i}${i}${jo(g)}`}),m=[];m.push("import React from 'react';"),m.push(""),o?(m.push(`interface ${t}Props {`),m.push(`${i}className?: string;`),m.push(`${i}style?: React.CSSProperties;`),m.push("}"),m.push(""),m.push(`const ${t}: React.FC<${t}Props> = ({ className, style }) => {`)):m.push(`const ${t} = ({ className, style }) => {`),m.push(`${i}return (`),m.push(`${i}${i}<svg xmlns="http://www.w3.org/2000/svg" width="${r.width}" height="${r.height}" viewBox="0 0 ${r.width} ${r.height}" className={className} style={style}>`),d&&(m.push(`${i}${i}${i}<defs>`),m.push(`${i}${i}${i}${i}${jo(f)}`),m.push(`${i}${i}${i}</defs>`));for(let h of p)m.push(h);return m.push(`${i}${i}</svg>`),m.push(`${i});`),m.push("};"),m.push(""),m.push(`export default ${t};`),m.push(""),m.join(`
14
- `)}function Ni(n,e){let t=e.componentName??"SvgComponent",r=De(n,e),i=e.indent??" ",s=n.shapes??[],o=e.typescript??!1,a=Array.isArray(n.library)?n.library:[],l=it(s,a),c=Be(s,a),f=l+c,d=f.length>0,p=s.map(h=>`${i}${i}${fe(h)}`),m=[];m.push("<template>"),m.push(`${i}<svg xmlns="http://www.w3.org/2000/svg" width="${r.width}" height="${r.height}" viewBox="0 0 ${r.width} ${r.height}" :class="className" :style="style">`),d&&(m.push(`${i}${i}<defs>`),m.push(`${i}${i}${i}${f}`),m.push(`${i}${i}</defs>`));for(let h of p)m.push(h);return m.push(`${i}</svg>`),m.push("</template>"),m.push(""),o?m.push('<script setup lang="ts">'):m.push("<script setup>"),m.push(`// ${t}`),o?(m.push("defineProps<{"),m.push(`${i}className?: string;`),m.push(`${i}style?: Record<string, string>;`),m.push("}>();")):(m.push("defineProps({"),m.push(`${i}className: { type: String, default: '' },`),m.push(`${i}style: { type: Object, default: () => ({}) },`),m.push("});")),m.push("</script>"),m.push(""),m.join(`
15
- `)}var Wf=new Set(["circle","ellipse","rectangle","square","line","text","image"]);function Ko(n){return n.replace(/\\/g,"\\\\").replace(/'/g,"\\'")}function Xo(n){return n.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${")}function Hf(n){if(!Wf.has(n.type))return!0;let e=n.state.metadata;return!!(e?.title||e?.description||n.type==="text"&&n.state.isTextPath)}function Bi(n,e){let t=e.componentName??"createSvg",r=De(n,e),i=e.indent??" ",s=n.shapes??[],o=e.typescript??!1,a=[];a.push("import * as d3 from 'd3';"),a.push(""),o?a.push(`export function ${t}(container: string | HTMLElement): d3.Selection<SVGSVGElement, unknown, HTMLElement, unknown> {`):a.push(`export function ${t}(container) {`),a.push(`${i}const svg = d3.select(container)`),a.push(`${i}${i}.append('svg')`),a.push(`${i}${i}.attr('xmlns', 'http://www.w3.org/2000/svg')`),a.push(`${i}${i}.attr('width', ${r.width})`),a.push(`${i}${i}.attr('height', ${r.height})`),a.push(`${i}${i}.attr('viewBox', '0 0 ${r.width} ${r.height}');`),a.push("");let l=Array.isArray(n.library)?n.library:[],c=it(s,l),f=Be(s,l),d=`${c}${f}`;d.length>0&&(a.push(`${i}svg.append('defs').html(\`${Xo(d)}\`);`),a.push(""));for(let p=0;p<s.length;p++){let m=s[p];if(a.push(`${i}// ${m.type}${m.state.metadata?.name?` \u2014 ${m.state.metadata.name}`:""}`),Hf(m)){a.push(`${i}svg.append('g').html(\`${Xo(fe(m))}\`);`),a.push("");continue}let h=Ya(m),g=_n(m),b=`shape${p+1}`;a.push(`${i}const ${b} = svg.append('${h}')`);for(let[$,k]of g)a.push(`${i}${i}.attr('${$}', '${Ko(k)}')`);m.type==="text"&&m.state.text&&a.push(`${i}${i}.text('${Ko(m.state.text)}')`),a[a.length-1]=a[a.length-1]+";",a.push("")}return a.push(`${i}return svg;`),a.push("}"),a.push(""),a.join(`
16
- `)}function Yo(n,e){let t=n.state.metadata?.name;return t?t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""):`${n.type}-${e+1}`}var jf=new Set(["fill","fill-opacity","fill-rule","stroke","stroke-width","stroke-opacity","stroke-dasharray","stroke-linecap","opacity","transform","filter"]);function zi(n,e){let t=De(n,e),r=e.indent??" ",i=n.shapes??[],s=[];for(let l=0;l<i.length;l++){let c=i[l],f=Yo(c,l),d=_n(c),p=[];for(let[m,h]of d)jf.has(m)&&p.push(`${r}${m}: ${h};`);p.length>0&&s.push(`.${f} {
17
- ${p.join(`
34
+ ${o}`)}return n.includeWarnings===!1?[]:r.warnings.map(o=>({severity:"warning",code:/\.type$/.test(o.path)&&/Unknown shape type/.test(o.message)?"unavailable-shape-descriptor":"native-validation-warning",source:"native-document",entrypoint:e,message:o.message,documentPath:o.path}))}function rf(t,e={}){let{indent:n=2,trailingNewline:r=!0,validate:i=!1}=e;if(i){let a=ni(t);if(!a.valid){let c=a.errors.map(l=>` ${l.path}: ${l.message}`).join(`
35
+ `);throw new Error(`Invalid document:
36
+ ${c}`)}}let o={};for(let a of sf){let c=a==="unknownFields"?af(t):t[a];c!==void 0&&(o[a]=uM($t[a].serialization,c))}let s=JSON.stringify(o,null,n);return r?s+`
37
+ `:s}function uM(t,e){switch(t.kind){case"verbatim":return e;case"shape-array":return e.map(n=>mM(Ml(structuredClone(n))));case"id-sorted-array":return fM(e).map(eo);case"ordered-array":return e.map(eo);case"deep-sorted-object":case"unknown-bag":return eo(e);default:return pM(t)}}function pM(t){throw new Error(`Unhandled serialization kind: ${JSON.stringify(t)}`)}function of(t,e={}){return uv(t,e).value}function uv(t,e={}){let{validate:n=!0,migrate:r=!0}=e,i;try{i=JSON.parse(t)}catch(a){throw new Error(`Failed to parse .svgs document: ${a.message}`)}if(i===null||typeof i!="object"||Array.isArray(i))throw new Error("Invalid .svgs document: root must be a JSON object");let o=i;o=us(o),r&&(o=ls(o)),o=ps(o);let s=[];return n&&s.push(...ds(o,"native-document-open")),{value:o,diagnostics:s}}function fM(t){return[...t].sort((e,n)=>e.id.localeCompare(n.id))}function eo(t){if(t==null)return t;if(Array.isArray(t))return t.map(eo);if(typeof t!="object")return t;let e={},n=Object.keys(t).sort();for(let r of n)e[r]=eo(t[r]);return e}function mM(t){let e={id:t.id,type:t.type},n=Object.keys(t).filter(r=>r!=="id"&&r!=="type").sort();for(let r of n)e[r]=eo(t[r]);return e}var wn=/\{\{\s*([\w.\-]+)\s*\}\}/g;function cf(t,e){return t.replace(wn,(n,r)=>{let i=e[r];return i!==void 0?String(i):n})}function Mc(t,e={}){let n={};if(t.templateVariables)for(let i of t.templateVariables)i.defaultValue!==void 0&&i.defaultValue!==""&&(n[i.name]=i.defaultValue);if(Object.assign(n,e),Object.keys(n).length===0)return JSON.parse(JSON.stringify(t));let r=JSON.parse(JSON.stringify(t));if(r.templateVariables)for(let i of r.templateVariables)Object.prototype.hasOwnProperty.call(e,i.name)&&(i.defaultValue=String(e[i.name]));return lf(r,n),r}function lf(t,e){for(let n of Object.keys(t)){let r=t[n];if(typeof r=="string"){if(wn.lastIndex=0,wn.test(r)){wn.lastIndex=0;let i=cf(r,e);if(gM(r)){let o=Number(i);if(!isNaN(o)&&yM(n)){t[n]=o;continue}}t[n]=i}}else if(Array.isArray(r))for(let i=0;i<r.length;i++)typeof r[i]=="string"?(wn.lastIndex=0,wn.test(r[i])&&(wn.lastIndex=0,r[i]=cf(r[i],e))):r[i]!==null&&typeof r[i]=="object"&&lf(r[i],e);else r!==null&&typeof r=="object"&&lf(r,e)}}function gM(t){return/^\s*\{\{\s*[\w.\-]+\s*\}\}\s*$/.test(t)}var hM=new Set(["x","y","width","height","radius","rx","ry","cx","cy","x1","y1","x2","y2","fontSize","borderWidth","cornerRadius","opacity","fillOpacity","strokeOpacity",...Cs,"letterSpacing","wordSpacing","lineHeight","sides","arms","innerRadiusPercent","armWidthPercent","teeth","toothDepthPercent","holeRadiusPercent","turns","thicknessPercent","direction","headWidthPercent","headLengthPercent","shaftWidthPercent","shiftAngle","dashLength","gapLength","textPathStartOffset","imageOpacity"]);function yM(t){return hM.has(t)}function uf(t){let e=t.templateVariables??[],n=new Set(e.map(o=>o.name)),r=new Set;df(t,r);let i=[...r].filter(o=>!n.has(o)).sort();return{defined:[...e],undeclared:i}}function df(t,e){for(let n of Object.values(t))if(typeof n=="string"){let r;for(wn.lastIndex=0;(r=wn.exec(n))!==null;)e.add(r[1])}else if(Array.isArray(n))for(let r of n)if(typeof r=="string"){let i;for(wn.lastIndex=0;(i=wn.exec(r))!==null;)e.add(i[1])}else r!==null&&typeof r=="object"&&df(r,e);else n!==null&&typeof n=="object"&&df(n,e)}function SM(t){let e={};for(let n of t){let r=n.indexOf("=");if(r===-1)throw new Error(`Invalid variable format: "${n}". Expected "name=value".`);let i=n.slice(0,r).trim(),o=n.slice(r+1);if(!i)throw new Error(`Invalid variable format: "${n}". Variable name cannot be empty.`);e[i]=o}return e}var Oc=3,pf=12;function ff(t){return t==null||!Number.isFinite(t)?Oc:t<0?0:t>pf?pf:Math.floor(t)}function zn(t,e){if(!Number.isFinite(t))return t;let n=Math.pow(10,e);return Math.round(t*n)/n}var bM=/-?\d+(?:\.\d+)?(?:[eE][-+]?\d+)?/g;function Dc(t,e){return t.replace(bM,n=>{let r=parseFloat(n);return Number.isFinite(r)?String(zn(r,e)):n})}var vM=new Set(["rawTransform","strokeDasharray","filterX","filterY","filterWidth","filterHeight","cssClipPath"]),xM=new Set(["metadata","customMetadata","customAttrs","customData","bindings","richTextRuns","cssMaskProperties","rawMetadata"]);function si(t,e,n){if(e==null)return e;if(typeof e=="number")return zn(e,n);if(typeof e=="string")return vM.has(t)?Dc(e,n):e;if(typeof e=="boolean")return e;if(Array.isArray(e))return e.map(r=>si(t,r,n));if(typeof e=="object"){if(xM.has(t))return e;if(t==="symbolOverrides"){let i={};for(let[o,s]of Object.entries(e))i[o]=si("state",s,n);return i}let r={};for(let[i,o]of Object.entries(e))r[i]=si(i,o,n);return r}return e}function pv(t,e){return{id:t.id,type:t.type,state:si("state",t.state,e)}}function IM(t,e){let n=t,r={...n};for(let i of Object.keys($t)){let o=n[i];if(o!==void 0)switch($t[i].precision){case"opaque":break;case"numeric-leaves":r[i]=si(i,o,e);break;case"animation-timeline":r[i]=wM(o,e);break;case"shape-trees":r[i]=kM(i,o,e);break}}return r}function wM(t,e){return{...t,tracks:t.tracks.map(n=>({...n,...n.motionPathMatrix?{motionPathMatrix:n.motionPathMatrix.map(r=>zn(r,e))}:{},...n.ancestorMatrix?{ancestorMatrix:n.ancestorMatrix.map(r=>zn(r,e))}:{},...n.transformOrigin?{transformOrigin:{x:zn(n.transformOrigin.x,e),y:zn(n.transformOrigin.y,e)}}:{},...n.pasteOffset?{pasteOffset:{x:zn(n.pasteOffset.x,e),y:zn(n.pasteOffset.y,e)}}:{},...typeof n.motionRotate=="number"?{motionRotate:zn(n.motionRotate,e)}:{},keyframes:n.keyframes.map(r=>({...r,value:si("value",r.value,e)}))}))}}function kM(t,e,n){return Array.isArray(e)?t==="shapes"?e.map(r=>pv(r,n)):e.map(r=>si("libraryDef",r,n)):e}var gf=["unsupported-shape-type","unsupported-polygon-type","unresolved-reference","undeclarable-namespace-prefix","unresolved-container-pivot","unresolved-reference-pivot","duplicate-shape-id","reference-cycle","unresolved-svg-viewport","symbol-cycle","unresolved-symbol-definition","duplicate-library-id","invalid-symbol-viewport","unresolved-symbol-viewport","unresolved-symbol-pivot","unknown-symbol-variant","ambiguous-symbol-override-target","unresolved-symbol-override-target"],to=class{collected=[];seen=new Set;report(e){let n=`${e.severity}|${e.code}|${e.shapeId??""}|${e.message}`;this.seen.has(n)||(this.seen.add(n),this.collected.push(e))}get diagnostics(){return[...this.collected]}},mf=[];function _c(t,e){mf.push(t);try{return e()}finally{mf.pop()}}function zt(t){for(let e of mf)e.report(t)}var Fc="0 0 10 10",hf=6,yf=6;function no(){return[{id:"line-marker-arrow",refX:10,refY:5,element:{tag:"path",attrs:{d:"M 0 0 L 10 5 L 0 10 Z",fill:"context-stroke",stroke:"context-stroke"}}},{id:"line-marker-open-arrow",refX:10,refY:5,element:{tag:"path",attrs:{d:"M 0 0 L 10 5 L 0 10",fill:"none",stroke:"context-stroke","stroke-width":1.5,"stroke-linejoin":"round","stroke-linecap":"round"}}},{id:"line-marker-circle",refX:5,refY:5,element:{tag:"circle",attrs:{cx:5,cy:5,r:3.2,fill:"context-stroke",stroke:"context-stroke"}}},{id:"line-marker-diamond",refX:5,refY:5,element:{tag:"path",attrs:{d:"M 5 0 L 10 5 L 5 10 L 0 5 Z",fill:"context-stroke",stroke:"context-stroke"}}},{id:"line-marker-square",refX:5,refY:5,element:{tag:"rect",attrs:{x:1.5,y:1.5,width:7,height:7,fill:"context-stroke",stroke:"context-stroke"}}}]}var Lc={"line-marker-arrow":"mkr-builtin-arrow","line-marker-open-arrow":"mkr-builtin-open-arrow","line-marker-circle":"mkr-builtin-circle","line-marker-diamond":"mkr-builtin-diamond","line-marker-square":"mkr-builtin-square"},RM={"mkr-builtin-arrow":"Arrow","mkr-builtin-open-arrow":"Open Arrow","mkr-builtin-circle":"Circle","mkr-builtin-diamond":"Diamond","mkr-builtin-square":"Square"};function CM(){return no().map(t=>{let e=Lc[t.id]??t.id;return{kind:"marker",id:e,name:RM[e]??e,viewBox:Fc,refX:t.refX,refY:t.refY,markerWidth:6,markerHeight:6,markerUnits:"strokeWidth",orient:"auto-start-reverse",shapes:[],builtIn:!0}})}function ai(t,e){switch(e){case"uppercase":return t.toLocaleUpperCase();case"lowercase":return t.toLocaleLowerCase();case"capitalize":return t.replace(/\b\p{L}/gu,n=>n.toLocaleUpperCase());default:return t}}var $M=[["fontVariant","font-variant"],["fontVariantLigatures","font-variant-ligatures"],["fontVariantPosition","font-variant-position"],["fontVariantCaps","font-variant-caps"],["fontVariantNumeric","font-variant-numeric"],["fontVariantEastAsian","font-variant-east-asian"]];function fs(t){return $M.map(([e,n])=>{let r=t[e],i=typeof r=="string"?r.trim():"";return i?`${n}: ${i}`:""}).filter(Boolean).join("; ")}function Sf(t,e){let n=[],r=(a,c)=>{c!==""&&n.push({name:a,value:c})};t.fontFamily!==e.fontFamily&&r("font-family",String(t.fontFamily)),t.fontSize!==e.fontSize&&r("font-size",String(t.fontSize)),t.fontWeight!==e.fontWeight&&r("font-weight",String(t.fontWeight)),t.fontStyle!==e.fontStyle&&r("font-style",String(t.fontStyle));let i=fs(t);i&&i!==fs(e)&&r("style",i);let o=t.textDecoration,s=e.textDecoration;if(o.underline!==s.underline||o.strikethrough!==s.strikethrough||o.overline!==s.overline){let a=[];o.underline&&a.push("underline"),o.strikethrough&&a.push("line-through"),o.overline&&a.push("overline"),r("text-decoration",a.join(" "))}if(t.baselineShift!==e.baselineShift){let a=t.baselineShift;a==="super"||a==="sub"?r("baseline-shift",a):typeof a=="number"&&r("baseline-shift",`${a}px`)}return t.letterSpacing!==e.letterSpacing&&r("letter-spacing",String(t.letterSpacing)),t.fill!==e.fill&&r("fill",String(t.fill)),t.fillOpacity!==e.fillOpacity&&r("fill-opacity",String(t.fillOpacity)),t.direction!==e.direction&&r("direction",String(t.direction)),t.unicodeBidi!==e.unicodeBidi&&r("unicode-bidi",String(t.unicodeBidi)),n}function xf(t,e){if(t===null||typeof t=="string"||typeof t=="boolean")return t;if(typeof t=="number"){if(!Number.isFinite(t))throw new TypeError("Text layout keys require finite numbers.");return Object.is(t,-0)?0:t}if(t!==void 0){if(Array.isArray(t)){if(e.has(t))throw new TypeError("Text layout keys cannot contain cycles.");e.add(t);let n=t.map(r=>xf(r,e)??null);return e.delete(t),n}if(typeof t=="object"){let n=t;if(e.has(n))throw new TypeError("Text layout keys cannot contain cycles.");e.add(n);let r={};for(let i of Object.keys(n).sort()){let o=xf(n[i],e);o!==void 0&&(r[i]=o)}return e.delete(n),r}throw new TypeError(`Text layout keys cannot contain ${typeof t} values.`)}}function PV(t){return`text-layout-v1:${JSON.stringify(xf(t,new Set))}`}function Jn(t,e){if(!Number.isFinite(t))throw new TypeError(`${e} must be finite.`);return Object.is(t,-0)?0:t}function ro(t,e){let n=Jn(t,e);if(n<0)throw new TypeError(`${e} must be non-negative.`);return n}function kn(t,e,n=!1){if(!Number.isInteger(t)||t<(n?-1:0))throw new TypeError(`${e} must be an integer${n?" greater than or equal to -1":""}.`);return t}function bf(t,e){return Object.freeze({x:Jn(t.x,`${e}.x`),y:Jn(t.y,`${e}.y`)})}function vf(t,e){return Object.freeze({x:Jn(t.x,`${e}.x`),y:Jn(t.y,`${e}.y`),width:ro(t.width,`${e}.width`),height:ro(t.height,`${e}.height`)})}function TV(t){if(!t.key)throw new TypeError("Text layout product key must not be empty.");let e=t.glyphs.map((s,a)=>Object.freeze({index:kn(s.index,`glyphs[${a}].index`),modelIndex:kn(s.modelIndex,`glyphs[${a}].modelIndex`,!0),text:s.text,lineIndex:kn(s.lineIndex,`glyphs[${a}].lineIndex`),cell:vf(s.cell,`glyphs[${a}].cell`),start:bf(s.start,`glyphs[${a}].start`),end:bf(s.end,`glyphs[${a}].end`),rotation:Jn(s.rotation,`glyphs[${a}].rotation`),advance:ro(s.advance,`glyphs[${a}].advance`)})),n=t.carets.map((s,a)=>Object.freeze({index:kn(s.index,`carets[${a}].index`),modelIndex:kn(s.modelIndex,`carets[${a}].modelIndex`,!0),lineIndex:kn(s.lineIndex,`carets[${a}].lineIndex`),x:Jn(s.x,`carets[${a}].x`),y:Jn(s.y,`carets[${a}].y`),height:ro(s.height,`carets[${a}].height`),rotation:Jn(s.rotation,`carets[${a}].rotation`)})),r=t.lines.map((s,a)=>Object.freeze({index:kn(s.index,`lines[${a}].index`),startGlyph:kn(s.startGlyph,`lines[${a}].startGlyph`),endGlyph:kn(s.endGlyph,`lines[${a}].endGlyph`),baseline:bf(s.baseline,`lines[${a}].baseline`),bounds:vf(s.bounds,`lines[${a}].bounds`),advance:ro(s.advance,`lines[${a}].advance`)})),i=t.modelToGlyphMap.map((s,a)=>kn(s,`modelToGlyphMap[${a}]`,!0)),o=t.glyphToModelMap.map((s,a)=>kn(s,`glyphToModelMap[${a}]`,!0));return Object.freeze({key:t.key,bounds:t.bounds?vf(t.bounds,"bounds"):null,advance:ro(t.advance,"advance"),glyphs:Object.freeze(e),carets:Object.freeze(n),lines:Object.freeze(r),modelToGlyphMap:Object.freeze(i),glyphToModelMap:Object.freeze(o)})}function NM(t){return{text:t.text,style:{...t.style}}}function Bc(t){return{segments:[{text:"",style:t}]}}function AM(t){let e=[];for(let n of t.segments){let r=n.text.match(/\S+|\s+/g);if(r)for(let i of r)e.push({text:i,style:n.style})}return e}function EM(t,e){if(e<=0)return t;let n=t.width-e*2;return n>0?{x:t.x+e,width:n}:null}function mv(t,e,n){let r=t.measureText(e,n);if(!Number.isFinite(r)||r<0)throw new TypeError(`TextMeasurementHost returned invalid width ${String(r)}`);return r}function gv(t,e,n,r){if(t.length===0)return;let i=t[t.length-1],o=i.text.replace(/\s+$/,""),s=i.text.length-o.length;if(s!==0){n.length=r-s;for(let a=0;a<s;a++)e[e.length-s+a]=-1;t[t.length-1]={...i,text:o}}}function MM(t,e){let n=t.whiteSpace==="normal"||t.whiteSpace==="nowrap"||t.whiteSpace==="pre-line",r=t.whiteSpace==="normal"||t.whiteSpace==="nowrap",i=t.whiteSpace!=="pre"&&t.whiteSpace!=="nowrap",o=t.whiteSpace!=="break-spaces",s=t.shapeInsideGeometry??null,a=Math.max(0,t.shapePadding??0),c=[],l=[],d=new Map,u=x=>{if(!s)return t.inlineSize;let k=t.baseStyle.fontSize*t.lineHeight,T=s.bounds.minY+t.baseStyle.fontSize+x*k;if(T>s.bounds.maxY)return l.push(s.bounds.minX),0;let w=Math.round(T*256),P=d.get(w);if(P===void 0){let N=s.getSpanAtY(T);P=N?EM(N,a):null,d.set(w,P)}return P?(l.push(P.x),P.width):(l.push(s.bounds.minX),0)},p=[];for(let x=0;x<t.lines.length;x++){x>0&&p.push(r?{text:" ",style:t.baseStyle,modelLen:1,isHardBreak:!1,isWhitespace:!0}:{text:"",style:t.baseStyle,modelLen:1,isHardBreak:!0,isWhitespace:!1});for(let k of AM(t.lines[x])){let T=/^\s+$/.test(k.text);p.push({text:n&&T?" ":k.text,style:k.style,modelLen:k.text.length,isHardBreak:!1,isWhitespace:T})}}if(n)for(let x=p.length-1;x>0;x--){let k=p[x],T=p[x-1];k.isWhitespace&&!k.isHardBreak&&T.isWhitespace&&!T.isHardBreak&&(T.modelLen+=k.modelLen,p.splice(x,1))}let f=[],m=[],g=0,h=0,y=[],b=0,v=u(0),I=!0;for(let x of p){if(x.isHardBreak){y.length===0&&(m.push(g),h++,s&&l.length<=c.length&&u(c.length)),f.push(h),g++,c.push(y.length>0?{segments:y}:Bc(t.baseStyle)),y=[],b=0,v=u(c.length),I=!0;continue}if(n&&x.isWhitespace&&I){for(let w=0;w<x.modelLen;w++)f.push(-1),g++;continue}let k=mv(e,x.text,x.style);if(i&&v>0&&b+k>v&&b>0&&(o&&(gv(y,f,m,h),h=m.length),c.push(y.length>0?{segments:y}:Bc(t.baseStyle)),y=[],b=0,v=u(c.length),I=!0,x.isWhitespace)){for(let w=0;w<x.modelLen;w++)f.push(-1),g++;continue}if(i&&v>0&&k>v&&t.overflowWrap!=="normal"){for(let P of x.text){let N=mv(e,P,x.style);b+N>v&&b>0&&(c.push(y.length>0?{segments:y}:Bc(t.baseStyle)),y=[],b=0,v=u(c.length)),f.push(h),m.push(g),g++,h++;let R=y[y.length-1];R&&sr(R.style,x.style)?y[y.length-1]={...R,text:R.text+P}:y.push({text:P,style:{...x.style}}),b+=N}let w=x.modelLen-x.text.length;for(let P=0;P<w;P++)f.push(-1),g++;I=!1;continue}for(let w of x.text)f.push(h),m.push(g),g++,h++;for(let w=x.text.length;w<x.modelLen;w++)f.push(-1),g++;let T=y[y.length-1];T&&sr(T.style,x.style)?y[y.length-1]={...T,text:T.text+x.text}:x.text&&y.push(NM(x)),b+=k,I=!1}return n&&y.length>0&&gv(y,f,m,h),y.length===0&&p.length===0&&m.push(g),c.push(y.length>0?{segments:y}:Bc(t.baseStyle)),{lines:c,modelToSvgMap:f,svgToModelMap:m,shapeInsideLineXOffsets:l}}var Gc=class{constructor(e){this.measurementHost=e}measurementHost;layout(e){return MM(e,this.measurementHost)}};function ms(t){let e=0;for(;e<t.length;){let r=t.slice(e);if(!/^<defs[\s>]/.test(r))break;let i=t.indexOf("</defs>",e);if(i===-1)break;e=i+7}let n=/^<([A-Za-z_][\w:.-]*)((?:"[^"]*"|'[^']*'|[^>"'])*?)(\/?)>/.exec(t.slice(e));return n?{prefixEnd:e,openStart:e,openEnd:e+n[0].length,tagName:n[1],attributes:n[2],selfClosing:n[3]==="/"}:null}function D(t,e){return e==null||e===""?"":` ${t}="${fe(String(e))}"`}function Sv(t){let e=Yp(t);return e.pivotRequired&&!e.pivotResolved&&zt({severity:"warning",code:"unresolved-container-pivot",shapeId:t.id,message:`Container ${t.id} has decomposed rotation/scale/skew channels, but its local content bounds include contextual geometry unavailable without its document resolver or measurement host; the transform was emitted without a derived pivot.`}),e.transform.attribute}function Nt(t,e){let n=cn(t);if(!n||n.kind!==e)throw new Error(`Shape geometry registry mismatch for ${t.type}: expected ${e}`);return n}function io(t,e){return e==null?"":` ${t}="${fe(e)}"`}function OM(t){let e=t.map(n=>(n??"").trim().replace(/;$/,"")).filter(Boolean).join("; ");return e?D("style",e):""}function DM(t,e){return typeof e=="number"&&e>0?`${t}: ${e}px`:""}function zM(t){if(t&&typeof t=="object"){let e=t;return"dx"in e?{x:typeof e.x=="number"?e.x:null,y:typeof e.y=="number"?e.y:null,dx:typeof e.dx=="number"?e.dx:0,dy:typeof e.dy=="number"?e.dy:0,rotate:typeof e.rotate=="number"?e.rotate:0}:{x:null,y:null,dx:typeof e.x=="number"?e.x:0,dy:typeof e.y=="number"?e.y:0,rotate:typeof e.rotate=="number"?e.rotate:0}}return{x:null,y:null,dx:0,dy:0,rotate:0}}function hv(t,e){let n=-1;for(let i=t.length-1;i>=0;i--)if(t[i][e]!==null){n=i;break}if(n<0)return[];let r=new Array(n+1);for(let i=0;i<=n;i++)r[i]=t[i][e]??0;return r}function yv(t,e){let n=-1;for(let i=t.length-1;i>=0;i--)if(t[i][e]!==0){n=i;break}if(n<0)return[];let r=new Array(n+1);for(let i=0;i<=n;i++)r[i]=t[i][e];return r}function _M(t){if(t.length===0)return[];let e=t.length-1,n=t[e].rotate;for(;e>0&&t[e-1].rotate===n;)e--;if(e===0&&n===0)return[];let r=new Array(e+1);for(let i=0;i<=e;i++)r[i]=t[i].rotate;return r}function _n(t,e){return Rt(t,e)}function FM(t,e,n){return kh(t,e,n)}function LM(t){if(typeof t=="string"){let r=t.trim();return r.length>0?r:void 0}if(!t||typeof t!="object")return;let e=t,n=[];return e.underline&&n.push("underline"),e.strikethrough&&n.push("line-through"),e.overline&&n.push("overline"),n.length>0?n.join(" "):void 0}function pn(t,e,n=[]){return D("data-shape-id",e)+bv(Ho(Ki(t),{shapeId:e}),n)}function bv(t,e=[]){let n="",r=new Map,i=new Map;for(let o of t){if(o.channel==="style"){i.delete(o.name),o.value!==null&&o.value!==""&&i.set(o.name,o.value);continue}o.ifAbsent&&r.has(o.name)||(r.delete(o.name),!(o.value===null||o.value===""&&!o.allowEmpty)&&r.set(o.name,o))}for(let o of r.values())n+=o.allowEmpty?io(o.name,String(o.value)):D(o.name,o.value);return(e.length>0||i.size>0)&&(n+=OM([...e,...[...i].map(([o,s])=>`${o}: ${s}`)])),n}var BM=new Set(["element-opacity","system-language","required-extensions","visibility","display","metadata","container-presentation","authored-attributes"]);function jc(t){let e=t.metadata;return Yi(e)}function GM(t,e){let n=jc(e);if(!n)return t;let r=ms(t);if(!r)return t;let i=t.slice(0,r.openStart),o=t.slice(r.openStart),s=r.openEnd-r.openStart;return r.selfClosing?i+`<${r.tagName}${r.attributes}>`+n+`</${r.tagName}>`+o.slice(s):i+o.slice(0,s)+n+o.slice(s)}function VM(t,e){if(e.length===0)return t;let n=e.join(""),r=ms(t);if(!r)return t;let i=t.slice(0,r.openStart),o=t.slice(r.openStart),s=r.openEnd-r.openStart;if(r.selfClosing)return i+`<${r.tagName}${r.attributes}>`+n+`</${r.tagName}>`+o.slice(s);let a=o.match(/<\/([\w:-]+)>$/);if(!a)return i+o+n;let c=o.lastIndexOf(`</${a[1]}>`);return i+o.slice(0,c)+n+o.slice(c)}function If(t){let e="",n=t.startEndpoint,r=t.endEndpoint;return n&&n!=="none"&&!t.markerStart&&(e+=D("marker-start",`url(#line-marker-${n})`)),r&&r!=="none"&&!t.markerEnd&&(e+=D("marker-end",`url(#line-marker-${r})`)),e}function vv(t){let e=t.state,{cx:n,cy:r,r:i,defaultPivot:o}=Nt(t,"circle"),s=_n(e,o??void 0);return`<circle${D("cx",n)}${D("cy",r)}${D("r",i)}${pn(e,t.id)}${s?D("transform",s):""}/>`}function xv(t){let e=t.state,{cx:n,cy:r,rx:i,ry:o,pathLength:s,defaultPivot:a}=Nt(t,"ellipse"),c=_n(e,a??void 0);return`<ellipse${D("cx",n)}${D("cy",r)}${D("rx",i)}${D("ry",o)}${s!==void 0?D("pathLength",s):""}${pn(e,t.id)}${c?D("transform",c):""}/>`}function Iv(t){let e=t.state,{x:n,y:r,width:i,height:o,rx:s,ry:a,pathData:c,defaultPivot:l}=Nt(t,"rectangle"),d=_n(e,l??void 0);return c?`<path${D("d",c)}${pn(e,t.id)}${d?D("transform",d):""}/>`:`<rect${D("x",n)}${D("y",r)}${D("width",i)}${D("height",o)}${s>0||a>0?`${D("rx",s)}${D("ry",a)}`:""}${pn(e,t.id)}${d?D("transform",d):""}/>`}function wv(t){let e=t.state,{x1:n,y1:r,x2:i,y2:o,defaultPivot:s}=Nt(t,"line"),a=_n(e,s??void 0),c={...e,fillType:"none"};return`<line${D("x1",n)}${D("y1",r)}${D("x2",i)}${D("y2",o)}${pn(c,t.id)}${If(e)}${a?D("transform",a):""}/>`.replace(' fill="none"',"")}function kv(t,e){let n=t.state,{x:r,y:i,defaultPivot:o}=Nt(t,"text"),s=n.text??"",a=ai(s,n.textTransform),c=n.fontSize??16,l=n.fontFamily??"sans-serif",d=n.fontWeight??"normal",u=n.fontStyle??"normal",p=n.textAnchor??"start",f=LM(n.textDecoration),m=n.letterSpacing,g=n.wordSpacing,h=n.lineHeight??1.25,y=_n(n,o??void 0),b=n.isTextPath&&n.textPathPoints,v=n.authoredTextPosition,I=v?.x?.resolved===r?v.x.raw:r,x=v?.y?.resolved===i?v.y.raw:i,k=b?"":D("x",I)+D("y",x);k+=D("font-size",c),k+=D("font-family",l),d!=="normal"&&d!=="400"&&(k+=D("font-weight",d)),u!=="normal"&&(k+=D("font-style",u)),p!=="start"&&(k+=D("text-anchor",p)),f&&(k+=D("text-decoration",f)),m&&(k+=D("letter-spacing",m)),g&&(k+=D("word-spacing",g));let T=n.baselineShift;T&&T!=="baseline"&&(k+=D("baseline-shift",T));let w=n.dominantBaseline;w&&w!=="auto"&&(k+=D("dominant-baseline",w));let P=n.writingMode;P&&P!=="horizontal-tb"&&(k+=D("writing-mode",P));let N=n.textLength;N!==void 0&&N>0&&(k+=D("textLength",N),n.lengthAdjust==="spacingAndGlyphs"&&(k+=D("lengthAdjust","spacingAndGlyphs")));let R=n.textDirection;R&&R!=="ltr"&&(k+=D("direction",R));let $=n.unicodeBidi;$&&$!=="normal"&&(k+=D("unicode-bidi",$));let A=n.shapeInsideRef,O="",G="";if(A){O=`shape-inside: url(#${e?.shapeInsideTargetElementId?.(A)??A})`;let H=n.shapePadding;H!==void 0&&H>0&&(G=`shape-padding: ${H}`)}let M=fs(n),V=n.fontVariationSettings,K="";V&&Object.keys(V).length>0&&(K=`font-variation-settings: ${Object.entries(V).map(([H,oe])=>`'${H}' ${oe}`).join(", ")}`);let X=n.inlineSize!==void 0||A!==void 0||typeof n.overflowWrap=="string",U=typeof n.lineHeight=="number"&&n.lineHeight!==1.2,te=[M,K,DM("inline-size",n.inlineSize),O,G,typeof n.overflowWrap=="string"?`overflow-wrap: ${n.overflowWrap}`:"",typeof n.whiteSpace=="string"?`white-space: ${n.whiteSpace}`:"",X&&U?`line-height: ${n.lineHeight}`:""];if(k+=pn(n,t.id,te),y&&(k+=D("transform",y)),n.isTextPath&&n.textPathPoints){let j=n.textPathPoints,H=n.textPathStartOffset??0,oe=n.textPathSide,re=`text-path-${t.id}`,xe=n.textPathMethod,Ze=n.textPathSpacing,et=n.textPathLengthAdjust,kt=n.textPathLength,lt="";if(j.length>=2)if(oe==="right"){let Ve=j[j.length-1];lt=`M ${Ve.x} ${Ve.y}`;for(let E=j.length-1;E>0;E--){let z=j[E],B=j[E-1],se=z.handleIn??z,me=B.handleOut??B;lt+=` C ${se.x} ${se.y} ${me.x} ${me.y} ${B.x} ${B.y}`}}else{lt=`M ${j[0].x} ${j[0].y}`;for(let Ve=0;Ve<j.length-1;Ve++){let E=j[Ve],z=j[Ve+1],B=E.handleOut??E,se=z.handleIn??z;lt+=` C ${B.x} ${B.y} ${se.x} ${se.y} ${z.x} ${z.y}`}}return`<defs><path id="${fe(re)}"${D("d",lt)} fill="none"/></defs><text${k}><textPath href="#${fe(re)}"${D("startOffset",`${H}%`)}${D("method",xe)}${D("spacing",Ze)}${D("lengthAdjust",et)}${D("textLength",kt)}>${fe(a)}</textPath></text>`}if(n.charOffsets&&Array.isArray(n.charOffsets)&&n.charOffsets.length>0){let j=n.charOffsets.map(zM),H=a.split(`
38
+ `),oe=n.linePositions??[],re=c*h,xe="",Ze=0;return H.forEach((et,kt)=>{let lt=Array.from(et).length,Ve=j.slice(Ze,Ze+lt),E=oe[kt],z=E?r+E.x:kt>0?r:NaN,B=E?E.dy:kt>0?re:NaN,se="",me=hv(Ve,"x");if(Number.isFinite(z)||me.length>0){let je=me.length>0?me.slice():[];Number.isFinite(z)&&(je[0]=je[0]??z),se+=D("x",je.join(" "))}let L=hv(Ve,"y");L.length>0&&(se+=D("y",L.join(" ")));let be=yv(Ve,"dx");be.length>0&&(se+=D("dx",be.join(" ")));let ce=yv(Ve,"dy"),Te=ce.length>0||Number.isFinite(B)?ce.slice():[];for(Number.isFinite(B)&&(Te[0]=(Te[0]??0)+B);Te.length>0&&Te[Te.length-1]===0;)Te.pop();Te.length>0&&(se+=D("dy",Te.join(" ")));let Xe=_M(Ve);Xe.length>0&&(se+=D("rotate",Xe.join(" "))),xe+=`<tspan${se}>${fe(et)}</tspan>`,Ze+=lt+1}),`<text${k}>${xe}</text>`}let ne=bi(n);if(ne){let j=Kl(ne),H=e?.textShapeInsideGeometry?.(t)??null,re=!!e?.textMeasurementHost&&(typeof n.inlineSize=="number"||H!==null||n.whiteSpace==="normal"||n.whiteSpace==="nowrap"||n.whiteSpace==="pre-line")?new Gc(e.textMeasurementHost).layout({lines:j.lines,baseStyle:j.baseStyle,lineHeight:j.lineHeight,inlineSize:typeof n.inlineSize=="number"?n.inlineSize:0,overflowWrap:n.overflowWrap==="break-word"||n.overflowWrap==="anywhere"?n.overflowWrap:"normal",whiteSpace:n.whiteSpace==="normal"||n.whiteSpace==="nowrap"||n.whiteSpace==="pre"||n.whiteSpace==="pre-line"||n.whiteSpace==="break-spaces"?n.whiteSpace:"pre-wrap",shapeInsideGeometry:H,shapePadding:typeof n.shapePadding=="number"?n.shapePadding:0}):null,xe=re?.lines??j.lines,Ze=n.linePositions,et=c*j.lineHeight,kt="";return xe.forEach((lt,Ve)=>{lt.segments.forEach((E,z)=>{let B="";if(z===0){let se=re?.shapeInsideLineXOffsets[Ve];if(H&&se!==void 0)B+=D("x",se),B+=D("y",H.bounds.minY+c+Ve*et);else if(Ze?.[Ve]){let me=Ze[Ve];(Math.abs(me.x)>.001||Ve>0)&&(B+=D("x",r+me.x)),(Math.abs(me.dy)>.001||Ve>0)&&(B+=D("dy",me.dy))}else Ve>0&&(B+=D("x",r),B+=D("dy",`${et}px`))}for(let{name:se,value:me}of Sf(E.style,j.baseStyle))B+=D(se,me);B+=' xml:space="preserve"',kt+=`<tspan${B}>${fe(ai(E.text||(re?"\u200B":""),E.style.textTransform))}</tspan>`})}),`<text${k}>${kt}</text>`}let F=n.authoredTextStructure;if(F?.text===s&&F.spans.length>0){let j=0,H="",oe=!0;for(let re of F.spans){if(!Number.isInteger(re.start)||!Number.isInteger(re.end)||re.start<j||re.end<=re.start||re.end>s.length||!re.id){oe=!1;break}H+=fe(ai(s.slice(j,re.start),n.textTransform)),H+=`<tspan${D("id",re.id)}>${fe(ai(s.slice(re.start,re.end),n.textTransform))}</tspan>`,j=re.end}if(oe)return H+=fe(ai(s.slice(j),n.textTransform)),`<text${k}>${H}</text>`}return`<text${k}>${fe(a)}</text>`}function Pv(t){let e=t.state,n=Nt(t,"path"),r=n.defaultPivot?_n(e,n.defaultPivot):null;return`<path${D("d",n.d)}${pn(e,t.id)}${If(e)}${r?D("transform",r):""}/>`}function Tv(t){let e=t.state,{points:n,closed:r,defaultPivot:i}=Nt(t,"polyline"),o=n.map(c=>`${c.x},${c.y}`).join(" "),s=i?_n(e,i):null;return`<${r?"polygon":"polyline"}${D("points",o)}${pn(e,t.id)}${If(e)}${s?D("transform",s):""}/>`}function Rv(t){let e=t.state,{x:n,y:r,width:i,height:o,defaultPivot:s}=Nt(t,"positioning-rect"),a=e.href??"",c=e.imageOpacity,l=e.specPreserveAspectRatio||(e.preserveAspectRatio?"xMidYMid meet":"none"),d=_n(e,s??void 0);return`<image${D("x",n)}${D("y",r)}${D("width",i)}${D("height",o)}${D("href",a)}${D("preserveAspectRatio",l)}${c!==void 0&&c<1?D("opacity",c):""}${pn(e,t.id)}${d?D("transform",d):""}/>`}function Cv(t){let e=t.state,{x:n,y:r,width:i,height:o,defaultPivot:s}=Nt(t,"positioning-rect"),a=e.rawContent??"",c=_n(e,s??void 0);return`<foreignObject${D("x",n)}${D("y",r)}${D("width",i)}${D("height",o)}${pn(e,t.id)}${c?D("transform",c):""}>${a}</foreignObject>`}function Uc(t,e){return!t||t.length===0?"":t.map(n=>fn(n,e)).join("")}function $v(t){let e=t.state,n="",r=Ki(e),i=gc.filter(o=>BM.has(o.id)).flatMap(o=>lp(o,r,{shapeId:t.id,includeAuthoredAttributes:!0,includeContainerPresentation:!0}));return n+=bv(i),n}function Nv(t){let e=Sv(t);return(e?D("transform",e):"")+$v(t)}function jM(t,e){let n=t.state,r=n.href,i=n.hrefXlink,o="<a";return r!==void 0&&(o+=D("href",r)),i!==void 0&&(o+=D("xlink:href",i)),o+=D("target",n.linkTarget),o+=D("rel",n.linkRel),n.linkDownload===""?o+=' download=""':o+=D("download",n.linkDownload),o+=D("ping",n.linkPing),o+=D("hreflang",n.linkHreflang),o+=D("type",n.linkType),o+=D("referrerpolicy",n.linkReferrerPolicy),o+=Nv(t),o+=D("data-shape-id",t.id),o+=">",o+=jc(n),o+=Uc(n.children,e),o+="</a>",o}function UM(t,e){let n=t.state,r="<switch";return r+=io("systemLanguage",n.switchSystemLanguage),r+=io("requiredExtensions",n.switchRequiredExtensions),r+=Nv(t),r+=D("data-shape-id",t.id),r+=">",r+=jc(n),r+=Uc(n.children,e),r+="</switch>",r}function HM(t,e){let n=t.state,r=Sv(t),i="<g";i+=D("data-shape-id",t.id),r&&(i+=D("transform",r)),n.opacity!==void 0&&n.opacity<1&&(i+=D("opacity",n.opacity)),n.visibility&&(i+=D("visibility",n.visibility));let o=n.groupData,s=[];if(n.blendMode&&s.push(`mix-blend-mode:${n.blendMode}`),o){let a=o;if(a.clipPath&&(i+=D("clip-path",a.clipPath)),a.mask&&(i+=D("mask",a.mask)),a.filter&&(i+=D("filter",a.filter)),a.fill&&(i+=D("fill",a.fill)),a.fillOpacity&&(i+=D("fill-opacity",a.fillOpacity)),a.strokeOpacity&&(i+=D("stroke-opacity",a.strokeOpacity)),a.opacity&&n.opacity===void 0&&(i+=D("opacity",a.opacity)),Array.isArray(a.classes)&&a.classes.length>0&&(i+=D("class",a.classes.join(" "))),a.attributes)for(let[c,l]of Object.entries(a.attributes))/^[A-Za-z_][\w:.-]*$/.test(c)&&(new RegExp(`\\s${c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*=`).test(i)||(i+=D(c,l)));a.cssFilter&&s.push(`filter:${a.cssFilter}`),a.mixBlendMode&&!n.blendMode&&s.push(`mix-blend-mode:${a.mixBlendMode}`),a.isolation&&s.push(`isolation:${a.isolation}`),a.transformOrigin&&s.push(`transform-origin:${a.transformOrigin}`)}return s.length>0&&(i+=D("style",s.join(";"))),i+=">",i+=Uc(n.children,e),i+="</g>",i}function WM(t){let e=t.state,n=Nt(t,"view"),r=n.viewBoxX,i=n.viewBoxY,o=n.viewBoxWidth,s=n.viewBoxHeight,a=r!==void 0&&i!==void 0&&o!==void 0&&s!==void 0?`${r} ${i} ${o} ${s}`:void 0,c="<view";return c+=D("id",t.id),c+=D("viewBox",a),c+=D("preserveAspectRatio",n.preserveAspectRatio),c+=D("zoomAndPan",e.viewZoomAndPan),c+=D("viewTarget",e.viewTarget),e.viewName&&(c+=D("data-view-name",e.viewName)),c+="/>",c}function KM(t,e){let n=t.state,r=Nt(t,"embedded-svg"),i=ii(t);i.pivotRequired&&!i.pivotResolved&&zt({severity:"warning",code:"unresolved-svg-viewport",shapeId:t.id,message:`Embedded SVG ${t.id} has decomposed rotation/scale/skew channels, but its auto viewport frame cannot be resolved without a parent viewport.`});let o=r.x,s=r.y,a=r.width,c=r.height,l=r.viewBoxX,d=r.viewBoxY,u=r.viewBoxWidth,p=r.viewBoxHeight,f=l!==void 0&&d!==void 0&&u!==void 0&&p!==void 0?`${l} ${d} ${u} ${p}`:void 0,m="<svg";return m+=D("xmlns","http://www.w3.org/2000/svg"),m+=D("x",o),m+=D("y",s),m+=D("width",a),m+=D("height",c),m+=D("viewBox",f),r.preserveAspectRatio!==void 0&&(m+=io("preserveAspectRatio",r.preserveAspectRatio)),i.attribute&&(m+=D("transform",i.attribute)),m+=$v(t),m+=D("data-shape-id",t.id),m+=">",m+=jc(n),m+=Uc(n.children,e),m+="</svg>",m}function XM(t,e){let n=t.state,r=Nt(t,"shape-reference"),i=r.targetShapeId;if(!i?.trim())return zt({severity:"warning",code:"unresolved-reference",shapeId:t.id,message:`Shape reference ${t.id} has no targetShapeId and was not rendered.`}),`<!-- shape-reference ${fe(t.id)} has no targetShapeId -->`;let o=r.offsetX,s=r.offsetY,a=e?.shapeReferenceTargetElementId?.(i);if(a===null)return zt({severity:"error",code:"duplicate-shape-id",shapeId:t.id,message:`Shape reference ${t.id} targets ambiguous duplicate id ${i}.`}),`<!-- shape-reference ${fe(t.id)} has ambiguous target ${fe(i)} -->`;let c=a??i,l=e?.shapeReferenceBounds?.(t),d=l?.diagnostics.find(h=>h.code==="reference-cycle");if(d&&zt({severity:"warning",code:"reference-cycle",shapeId:t.id,message:d.message}),l?.status==="cycle"&&l.bounds===null)return`<!-- cyclic shape-reference ${fe(t.id)} was not rendered -->`;let u=e?.shapeReferenceTransform?.(t),p=u?.pivotRequired??Gt(t.state),f=u?.pivotResolved??!p;p&&!f&&zt({severity:"warning",code:"unresolved-reference-pivot",shapeId:t.id,message:`Shape reference ${t.id} has decomposed rotation/scale/skew channels, but its translated target bounds require unavailable contextual geometry or measurement.`});let m=u?.attribute??Rt(t.state),g="<use";return g+=D("href",`#${c}`),g+=D("x",o),g+=D("y",s),r.width!==void 0&&(g+=D("width",r.width)),r.height!==void 0&&(g+=D("height",r.height)),g+=D("data-shape-id",t.id),m&&(g+=D("transform",m)),n.opacity!==void 0&&n.opacity<1&&(g+=D("opacity",n.opacity)),g+="/>",g}function Av(t,e){let n=t.state,r=Nt(t,"symbol-instance"),i=e?.symbolInstanceTargetElementId?.(t),o=i===void 0?r.targetId:i;if(o===null)return`<!-- Invalid symbol instance: ${fe(t.id)} -->`;let s=e?.symbolDefKind?.(r.symbolId),a=`<use href="#${fe(o)}"`,c=n.authoredUseGeometry;c&&typeof c=="object"&&(c.x!==void 0&&(a+=D("x",c.x)),c.y!==void 0&&(a+=D("y",c.y)),(s===void 0||s==="symbol")&&(c.width!==void 0&&(a+=D("width",c.width)),c.height!==void 0&&(a+=D("height",c.height)))),a+=D("data-shape-id",t.id);let l=n.instancePresentation;if(l)for(let[g,h]of Object.entries(l))g!=="transform"&&(h==null||h===""||/^[A-Za-z_][\w:.-]*$/.test(g)&&(a+=D(g,h)));let d=e?.symbolInstanceTransform?.(t),u=Rt(n),p=l?.transform?.trim(),f=p?u?`${p} ${u}`:p:u,m=d?.attribute??f;return m&&(a+=D("transform",m)),`${a}/>`}function YM(t){let e=t.state,n=Nt(t,"positioning-rect"),r=e.mediaKind??t.type,i=e.href??"",o=e.mediaMimeType,s=e.posterHref,a=e.mediaOpacity,c=`<${r} xmlns="http://www.w3.org/1999/xhtml"`;c+=D("src",i),o&&(c+=D("type",o)),s&&r==="video"&&(c+=D("poster",s)),e.muted&&(c+=' muted=""'),e.loop&&(c+=' loop=""'),e.playbackRate!==void 0&&(c+=D("data-playback-rate",e.playbackRate)),e.volume!==void 0&&(c+=D("data-volume",e.volume)),c+=' preload="auto" playsinline=""',c+=r==="video"?' style="width:100%;height:100%;display:block;"></video>':"></audio>";let l="<foreignObject";return l+=D("x",n.x),l+=D("y",n.y),l+=D("width",n.width),l+=D("height",n.height),l+=D("data-shape-id",t.id),l+=D("data-media-kind",r),e.naturalDuration!==void 0&&(l+=D("data-natural-duration",e.naturalDuration)),e.begin!==void 0&&(l+=D("data-begin",e.begin)),e.trimStart!==void 0&&(l+=D("data-trim-start",e.trimStart)),e.trimEnd!==void 0&&(l+=D("data-trim-end",e.trimEnd)),e.fadeInDuration!==void 0&&(l+=D("data-fade-in",e.fadeInDuration)),e.fadeOutDuration!==void 0&&(l+=D("data-fade-out",e.fadeOutDuration)),l+=io("systemLanguage",e.systemLanguage),l+=io("requiredExtensions",e.requiredExtensions),a!==void 0&&a<1&&(l+=D("opacity",a)),l+=">",l+=c,l+="</foreignObject>",l}function Ev(t){let e=t.state,n=Nt(t,"path"),r=n.defaultPivot?_n(e,n.defaultPivot):null;return`<path${D("d",n.d)}${pn(e,t.id)}${r?D("transform",r):""}/>`}function Mv(t){let e=t.state;if(Ao(t.type)?.renderer!=="polygon")return zt({severity:"warning",code:"unsupported-polygon-type",message:`Unsupported polygon shape type "${t.type}" on shape "${t.id}"; the shape was dropped from the rendered output`,shapeId:t.id}),`<!-- unsupported polygon shape: ${fe(t.type)} -->`;let r=Nt(t,"path"),i=r.placement??{x:0,y:0},o=FM(e,i.x,i.y),s=r.fillRule?D("fill-rule",r.fillRule):"";return`<path${D("d",r.d)}${s}${pn(e,t.id)}${D("transform",o)}/>`}var qM={circle:vv,ellipse:xv,rectangle:Iv,line:wv,text:kv,path:Pv,polyline:Tv,image:Rv,polygon:Mv,flowchart:Ev,hyperlink:jM,switch:UM,container:HM,view:WM,svg:KM,"shape-reference":XM,"symbol-instance":Av,media:YM,"foreign-object":Cv};function fn(t,e){let n=Ao(t.type);if(!n)return zt({severity:"warning",code:"unsupported-shape-type",message:`Unsupported shape type "${t.type}" on shape "${t.id}"; the shape was dropped from the rendered output`,shapeId:t.id}),`<!-- unsupported shape type: ${fe(t.type)} -->`;let r=qM[n.renderer](t,e);r=JM(r,t),r=GM(r,t.state),e?.forcedElementIds?.has(t.id)&&(r=Ov(r,t.id));let i=e?.elementIdForShape?.(t);i&&(r=ZM(r,i));let o=e?.animationElementsForShape?.(t);o&&o.length>0&&(r=VM(r,o));let s=t.state?.leadingComments;return Array.isArray(s)&&s.length>0&&(r=s.map(c=>`<!--${c.replace(/--/g,"- -").replace(/-$/,"- ")}-->`).join("")+r),r}function Ov(t,e){let n=ms(t);if(!n)return t;let r=t.slice(n.openStart,n.openEnd);if(/\sid=/.test(r))return t;let i=n.openStart+1+n.tagName.length;return`${t.slice(0,i)}${D("id",e)}${t.slice(i)}`}function ZM(t,e){let n=ms(t);if(!n)return t;let r=t.slice(n.openStart,n.openEnd),i=/\sid=("[^"]*"|'[^']*')/.exec(r);if(!i)return Ov(t,e);let o=n.openStart+i.index;return`${t.slice(0,o)}${D("id",e)}${t.slice(o+i[0].length)}`}function JM(t,e){let n=e.state?.authoredAttributes;if(!n)return t;let r=/^<([A-Za-z][\w:-]*)((?:[^>"']|"[^"]*"|'[^']*')*?)(\/?)>/.exec(t);if(!r)return t;let[i,o,s,a]=r,c="";for(let[l,d]of Object.entries(n))d===null||!/^[a-zA-Z_:][-a-zA-Z0-9_:.]*$/.test(l)||new RegExp(`\\s${l}\\s*=`).test(s)||(c+=` ${l}="${fe(d)}"`);return c?`<${o}${s}${c}${a}>`+t.slice(i.length):t}function QM(t){let e="",n=new Set,r=i=>{if(i&&typeof i=="object"&&"id"in i){let o=i.id;return typeof o=="string"?o:void 0}};for(let i of t){let o=i.state,s=dp(o),a=ab(o),c=o.strokeType??"solid",l=o.strokeGradient;if(s==="linear-gradient"&&a){let d=r(a);d&&!n.has(d)&&(e+=gs(d,a),n.add(d))}if(s==="radial-gradient"&&a){let d=r(a);d&&!n.has(d)&&(e+=hs(d,a),n.add(d))}if(s==="pattern"&&a){let d=r(a);d&&!n.has(d)&&(e+=Vc(d,a),n.add(d))}if(c==="linear-gradient"&&l){let d=r(l);d&&!n.has(d)&&(e+=gs(d,l),n.add(d))}if(c==="radial-gradient"&&l){let d=r(l);d&&!n.has(d)&&(e+=hs(d,l),n.add(d))}if(c==="pattern"&&l){let d=r(l);d&&!n.has(d)&&(e+=Vc(d,l),n.add(d))}}return e}function gs(t,e,n){return Dv(rp(t,e),n)}function hs(t,e,n){return Dv(ip(t,e),n)}function Dv(t,e){let n=t.attributes.map(([o,s])=>D(o,s)).join(""),r=String(t.attributes.find(([o])=>o==="id")?.[1]??""),i=t.stops.map((o,s)=>{let a=o.attributes.map(([l,d])=>D(l,d)).join(""),c=e?.gradientStopAnimationElements?.(r,s)??[];return c.length>0?`<stop${a}>${c.join("")}</stop>`:`<stop${a}/>`}).join("");return`<${t.element}${n}>${i}</${t.element}>`}function Vc(t,e){let n=np(t,e);return`<pattern${n.attributes.map(([i,o])=>D(i,o)).join("")}>${n.content}</pattern>`}function wf(t,e=[]){let n=Array.isArray(t)?Di(t,e):t;if(n.ids.size===0&&n.legacyEndpoints.size===0)return"";let r="",i=no();for(let o of i){let s=o.id,a=s.replace("line-marker-",""),c=`mkr-builtin-${a}`,l=n.legacyEndpoints.has(a)||n.ids.has(s),d=n.ids.has(c);if(!l&&!d)continue;let u=o.element,p=Object.entries(u.attrs).map(([g,h])=>D(g,h)).join(""),f=`<${u.tag}${p}/>`,m=g=>{r+=`<marker${D("id",g)}${D("viewBox",Fc)}${D("refX",o.refX)}${D("refY",o.refY)}${D("markerWidth",6)}${D("markerHeight",6)}${D("orient","auto-start-reverse")}>${f}</marker>`};l&&m(s),d&&m(c)}return r}var xt=t=>t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");function Fv(t){let e=ln(`<svg xmlns="${Y}" xmlns:xlink="http://www.w3.org/1999/xlink">${t}</svg>`,{source:"native-document",entrypoint:"full-snapshot-restore"}).value;return e?new Set(e.index.localReferences.map(n=>n.targetAuthoredId)):new Set}function kf(t){let e=new Set,n=r=>{for(let i of Wn(r))e.add(i.targetAuthoredId)};for(let r of t.documentStyles??[])n(r.css);for(let r of t.animationTimeline?.tracks??[])for(let i of r.keyframes)typeof i.value=="string"&&n(i.value);for(let r of t.clipMaskGroups??[])if(r.rawDefinition)for(let i of Fv(r.rawDefinition))e.add(i);return e}var Lv=["linear-gradient","radial-gradient","pattern","filter","marker","symbol"];function Qn(t){let e=new Map;for(let n of t)n.kind==="symbol"&&e.set(n.id,n.defKind??"symbol");return{symbolDefKind:n=>e.get(n)}}function Hc(t,e){switch(t.kind){case"symbol":return Wc(t,e);case"marker":return Bv(t,e);case"linear-gradient":return Gv(t,e);case"radial-gradient":return Vv(t,e);case"pattern":return jv(t);case"filter":return Uv(t)}}function Wc(t,e){return ys(t,t.id,t.shapes,e)}var zv=["viewBox","preserveAspectRatio","x","y","width","height","refX","refY"];function _v(t,e){let n=t.rootAttributes??{},r="";if(e)for(let i of zv){let o=t[i];o!==void 0&&(r+=` ${i}="${xt(o)}"`)}for(let[i,o]of Object.entries(n))i==="id"||zv.includes(i)||/^[A-Za-z_][\w:.-]*$/.test(i)&&(r+=` ${i}="${xt(o)}"`);return r}function ys(t,e,n,r){if((t.defKind??"symbol")==="shape"){let[o]=n;if(!o||n.length!==1)return`<!-- invalid native-shape definition: ${xt(e)} -->`;let s={...o,state:{...o.state,authoredAttributes:{...o.state.authoredAttributes??{},...t.rootAttributes??{}},...t.metadata?{metadata:{...o.state.metadata??{},...t.metadata}}:{}}};return fn(s,{...r,elementIdForShape:a=>a.id===s.id?e:r?.elementIdForShape?.(a)})}let i=Yi(t.metadata)+n.map(o=>fn(o,r)).join("");return(t.defKind??"symbol")==="group"?`<g id="${xt(e)}"${_v(t,!1)}>${i}</g>`:`<symbol id="${xt(e)}"${_v(t,!0)}>${i}</symbol>`}function Bv(t,e){let n;if(t.builtIn){let a=no().find(c=>t.id.includes(c.id)||t.id===c.id);if(a){let c=Object.entries(a.element.attrs).map(([l,d])=>` ${l}="${xt(String(d))}"`).join("");n=`<${a.element.tag}${c}/>`}else n=""}else n=t.shapes.map(a=>fn(a,e)).join("");let r=t.authoredGeometry??{},i={refX:r.refX??String(t.refX),refY:r.refY??String(t.refY),markerWidth:r.markerWidth??String(t.markerWidth),markerHeight:r.markerHeight??String(t.markerHeight),markerUnits:r.markerUnits??t.markerUnits,orient:r.orient??(typeof t.orient=="number"?String(t.orient):t.orient)},o="";t.viewBox!==void 0&&(o+=` viewBox="${xt(t.viewBox)}"`),t.preserveAspectRatio!==void 0&&(o+=` preserveAspectRatio="${xt(t.preserveAspectRatio)}"`);let s=new Set(["id","viewBox","preserveAspectRatio","refX","refY","markerWidth","markerHeight","markerUnits","orient"]);for(let[a,c]of Object.entries(t.rootAttributes??{}))s.has(a)||!/^[A-Za-z_][\w:.-]*$/.test(a)||(o+=` ${a}="${xt(c)}"`);return t.overflow!==void 0&&t.rootAttributes?.overflow===void 0&&(o+=` overflow="${xt(t.overflow)}"`),n=Yi(t.metadata)+n,`<marker id="${xt(t.id)}"${o} refX="${xt(i.refX)}" refY="${xt(i.refY)}" markerWidth="${xt(i.markerWidth)}" markerHeight="${xt(i.markerHeight)}" markerUnits="${xt(i.markerUnits)}" orient="${xt(i.orient)}">${n}</marker>`}function Gv(t,e){let n={...t.gradient,type:"linear-gradient",id:t.id};return Kc(gs(t.id,n,e),t.metadata)}function Vv(t,e){let n={...t.gradient,type:"radial-gradient",id:t.id};return Kc(hs(t.id,n,e),t.metadata)}function jv(t){let e={...t.pattern,type:"pattern",id:t.id};return Kc(Vc(t.id,e),t.metadata)}function Uv(t){return Kc(dc(t.id,t.filters,{colorInterpolation:t.colorInterpolation,filterUnits:t.filterUnits,primitiveUnits:t.primitiveUnits,x:t.x,y:t.y,width:t.width,height:t.height}),t.metadata)}function Kc(t,e){let n=Yi(e);if(!n)return t;let r=t.match(/^<([\w:-]+)([^>]*)\/>$/u);if(r)return`<${r[1]}${r[2]}>${n}</${r[1]}>`;let i=t.indexOf(">");return i<0?t:t.slice(0,i+1)+n+t.slice(i+1)}function Xc(t,e){let n=new Map;for(let o of t){let s=n.get(o.kind);s?s.push(o):n.set(o.kind,[o])}let r=e??Qn(t),i="";for(let o of Lv){let s=n.get(o);if(s)for(let a of s)i+=Hc(a,r)}return i}function eO(t,e){let n=Yc(t,e);return n.length===0?"":Xc(n,Qn(e))}function Yc(t,e,n=[]){let r=new Map;for(let d of e)r.set(d.id,d);let i=new Map,o=d=>{if(!d)return;let u=r.get(d);u&&i.set(d,u)},s=(d,u)=>{if(!d||typeof d!="object")return;let p=d;if(!p.id||i.has(p.id))return;let f=u==="linear-gradient"?"linear-gradient":u==="radial-gradient"?"radial-gradient":u==="pattern"?"pattern":null;if(!f)return;let{id:m,sourceId:g,...h}=d,y;if(f==="linear-gradient")y={kind:"linear-gradient",id:p.id,name:g??p.id,sourceId:g,gradient:h};else if(f==="radial-gradient")y={kind:"radial-gradient",id:p.id,name:g??p.id,sourceId:g,gradient:h};else{let{customPatternId:b,...v}=h;y={kind:"pattern",id:p.id,name:g??p.id,sourceId:g,pattern:v}}i.set(p.id,y)},a=(d,u)=>{let p=d.filters;if(!Array.isArray(p)||p.length===0)return;let f=`filter-${u}`;i.has(f)||i.set(f,{kind:"filter",id:f,name:f,filters:p,...d.filterColorInterpolation&&d.filterColorInterpolation!=="auto"?{colorInterpolation:d.filterColorInterpolation}:{},...d.filterUnits?{filterUnits:d.filterUnits}:{},...d.primitiveUnits?{primitiveUnits:d.primitiveUnits}:{},...typeof d.filterX=="string"?{x:d.filterX}:{},...typeof d.filterY=="string"?{y:d.filterY}:{},...typeof d.filterWidth=="string"?{width:d.filterWidth}:{},...typeof d.filterHeight=="string"?{height:d.filterHeight}:{}})},c=d=>{let u=d.state;if(!u)return;if(o(u.fillLibraryId),o(u.strokeLibraryId),o(u.markerStart),o(u.markerMid),o(u.markerEnd),d.type==="symbol-instance"){let f=u.symbolId;f&&No(d)===f&&o(f)}else o(u.symbolId);let p=u.filterLibraryIds;if(Array.isArray(p))for(let f of p)typeof f=="string"&&o(f);u.fillLibraryId||s(u.fillGradient,u.fillType),u.strokeLibraryId||s(u.strokeGradient,u.strokeType),(!Array.isArray(p)||p.length===0)&&a(u,d.id)};for(let d of t)c(d);let l=Array.from(n);for(let d of l)o(d);return _a(t,e,c),Xd(l,e,c),Array.from(i.values())}function Hv(t){let e=new Map,n=(s,a)=>{let c=s.type??a;return c==="linear-gradient"||c==="radial-gradient"||c==="pattern"?c:null},r=(s,a,c)=>{if(typeof s!="string"||s.length===0||!a||typeof a!="object"||e.has(s))return;let l=a,d=n(l,c);if(!d)return;let{id:u,sourceId:p,type:f,...m}=l,g=typeof p=="string"?p:s;if(d==="linear-gradient")e.set(s,{kind:d,id:s,name:g,...typeof p=="string"?{sourceId:p}:{},gradient:m});else if(d==="radial-gradient")e.set(s,{kind:d,id:s,name:g,...typeof p=="string"?{sourceId:p}:{},gradient:m});else{let{customPatternId:h,...y}=m;e.set(s,{kind:"pattern",id:s,name:g,...typeof p=="string"?{sourceId:p}:{},pattern:y})}},i=s=>{let a=s.filterLibraryIds;if(!Array.isArray(a)||a.length!==1||typeof a[0]!="string")return;let c=a[0],l=s.filters;!Array.isArray(l)||l.length===0||e.has(c)||e.set(c,{kind:"filter",id:c,name:c,filters:l,...s.filterColorInterpolation&&s.filterColorInterpolation!=="auto"?{colorInterpolation:s.filterColorInterpolation}:{},...s.filterUnits?{filterUnits:s.filterUnits}:{},...s.primitiveUnits?{primitiveUnits:s.primitiveUnits}:{},...typeof s.filterX=="string"?{x:s.filterX}:{},...typeof s.filterY=="string"?{y:s.filterY}:{},...typeof s.filterWidth=="string"?{width:s.filterWidth}:{},...typeof s.filterHeight=="string"?{height:s.filterHeight}:{}})},o=s=>{let a=s.state;if(!a)return;r(a.fillLibraryId,a.fillGradient,a.fillType),r(a.strokeLibraryId,a.strokeGradient,a.strokeType),i(a);let c=a.children;if(Array.isArray(c))for(let l of c)o(l)};for(let s of t)o(s);return Array.from(e.values())}var tO=new Set(["id","href","xlink:href","fill","stroke","stop-color","flood-color","lighting-color","color","solid-color","text-decoration-color","caret-color","class","font-family","lang","xml:lang","style","keyTimes","keyPoints","keySplines","gradientTransform"]),Zv=/([A-Za-z_][\w:.-]*)\s*=\s*"([^"]*)"/g;function Jv(t,e){return t.length===0?t:t.replace(Zv,(n,r,i)=>{if(tO.has(r)||r==="xmlns"||r.startsWith("xmlns:")||r.startsWith("data-")||!/\d/.test(i)||i.includes("url(")||i.charCodeAt(0)===35)return n;let o=Dc(i,e);return o===i?n:`${r}="${o}"`})}var oo=/<\/?([A-Za-z][\w:-]*)((?:"[^"]*"|'[^']*'|[^>"'])*?)(\/?)>/g;function Ss(t){let e=[],n=0,r=0,i="";oo.lastIndex=0;let o;for(;(o=oo.exec(t))!==null;){let s=o[0].startsWith("</"),a=o[3]==="/";if(s){if(n=Math.max(0,n-1),n===0){let c=t.slice(r,oo.lastIndex);e.push({markup:c,tag:i,id:Wv(c)}),r=oo.lastIndex,i=""}continue}if(n===0&&(i=o[1].toLowerCase()),!a)n++;else if(n===0){let c=t.slice(r,oo.lastIndex);e.push({markup:c,tag:i,id:Wv(c)}),r=oo.lastIndex,i=""}}if(r<t.length){let s=t.slice(r);s.trim().length>0&&e.push({markup:s,tag:"",id:null})}return e}function nO(t,e){let n=(e.paintServerDefs??[]).filter(u=>Array.isArray(u.definitionChildIds)&&u.definitionChildIds.length>0);if(n.length===0)return t;let r=new Map,i=new Map;for(let u of er){let p=Ss(t.defs[u]);r.set(u,p),p.forEach((f,m)=>{!f.id||i.has(f.id)||i.set(f.id,{channel:u,index:m,segment:f,key:`${u}:${m}`})})}let o=new Map(n.map(u=>[u.id,u])),s=new Set,a=new Map,c=new Map,l=(u,p)=>{let f=c.get(u);if(f)return f;if(p.has(u))return null;let m=o.get(u),g=i.get(u);if(!m||!g)return null;let h=g.segment.markup,y=h.indexOf(">"),b=h.lastIndexOf("</");if(y<0||b<=y)return h;let v=h.slice(y+1,b),I=m.sourceDefinitionChildIds??m.definitionChildIds,x=m.definitionChildIds,k=new Map(I.map((N,R)=>[N,R])),T=new Set(p);T.add(u);let w=Ss(v).map(N=>{if(!N.id)return N.markup;let R=k.get(N.id);if(R===void 0)return N.markup;let $=x[R],A=i.get($);if(!A||A.key===g.key)return N.markup;let O=o.has($)?l($,T):A.segment.markup;return O?(s.add(A.key),N.markup.slice(0,N.markup.indexOf("<"))+O.trimStart()):N.markup}).join(""),P=h.slice(0,y+1)+w+h.slice(b);return c.set(u,P),P};for(let u of n){let p=i.get(u.id);if(!p)continue;let f=l(u.id,new Set);f&&a.set(p.key,f)}let d={...t.defs};for(let u of er)d[u]=(r.get(u)??[]).map((p,f)=>{let m=`${u}:${f}`;return s.has(m)?"":a.get(m)??p.markup}).join("");return{...t,defs:d}}function Wv(t){let e=/^[^>]*>/.exec(t.trimStart()),n=e?e[0]:t,r=/\sid\s*=\s*"([^"]*)"/.exec(n);return r?r[1]:null}function Zc(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Jc(t,e){if(e.size===0||t.length===0)return t;let n=t;for(let[r,i]of e){let o=Zc(r);n=n.replace(new RegExp(`url\\(\\s*(['"]?)#${o}\\1\\s*\\)`,"g"),(s,a)=>`url(${a}#${i}${a})`),n=n.replace(new RegExp(`((?:xlink:)?href\\s*=\\s*)(["'])#${o}\\2`,"g"),(s,a,c)=>`${a}${c}#${i}${c}`)}return n}function rO(t,e,n){return t.replace(new RegExp(`(\\sid\\s*=\\s*")${Zc(e)}(")`),`$1${n}$2`)}var er=["library","builtinMarkers","symbols","motionPaths","paintServers","clipMask","inlineHoisted"];function qc(t,e){let n={...t.defs};for(let r of er)n[r]=e(n[r]);return{...t,defs:n,backgroundRect:e(t.backgroundRect),body:t.body.map(r=>r.kind==="shape"?{...r,markup:e(r.markup)}:{...r,open:e(r.open),close:e(r.close),members:r.members.map(i=>({...i,markup:e(i.markup)}))}),envelope:{...t.envelope}}}function Qv(t,e){let n=qc(t,e);return{...n,envelope:{...n.envelope,styles:e(n.envelope.styles)}}}function iO(t){let e=new Set,n=/\sid\s*=\s*"([^"]*)"/g,r=i=>{n.lastIndex=0;let o;for(;(o=n.exec(i))!==null;)e.add(o[1])};for(let i of er)r(t.defs[i]);for(let i of t.body)if(i.kind==="shape")r(i.markup);else{r(i.open);for(let o of i.members)r(o.markup)}return r(t.envelope.descriptive),e}function oO(t,e){let n=e.library??[];if(n.length===0)return t;let r=iO(t),i=new Map,o=new Set;for(let c of n){let l=c.sourceId,d=c.id;!l||!d||l===d||o.has(l)||r.has(l)||r.has(d)&&(i.set(d,l),o.add(l))}if(i.size===0)return t;let s=Qv(t,c=>Jc(c,i)),a={...s.defs};for(let c of er){let l=a[c];for(let[d,u]of i)l=rO(l,d,u);a[c]=l}return{...s,defs:a}}var ex=new Set(["circle","ellipse","g","image","line","lineargradient","path","polygon","polyline","radialgradient","rect","pattern","marker","symbol","text"]),sO=new Set(["circle","ellipse","image","line","path","polygon","polyline","rect","text"]),aO=new Set(["defs","g"]);function tx(t,e,n){let r=e;n&&(r=r.replace(new RegExp(`\\sid\\s*=\\s*"${Zc(n)}"`),""));let i=[];if(ex.has(t)&&!["lineargradient","radialgradient","pattern","marker"].includes(t)){r=r.replace(/\sxmlns:svg="http:\/\/www\.w3\.org\/2000\/svg"/g,"").replace(/\sxmlns:xlink="http:\/\/www\.w3\.org\/1999\/xlink"/g,"");let o=/\sid\s*=\s*"([^"]*)"/g,s;for(;(s=o.exec(r))!==null;)s[1]!==""&&i.push(s[1]);let a=new Map;i.forEach((l,d)=>a.set(l,`__local_${d}`)),r=Jc(r,a);for(let[l,d]of a)r=r.replace(new RegExp(`(\\sid\\s*=\\s*")${Zc(l)}(")`,"g"),`$1${d}$2`);let c=0;r=r.replace(/\s(data-shape-id|data-svgsketch-inner-id)\s*=\s*"[^"]*"/g,(l,d)=>` ${d}="__shape_${c++}"`),r=ao(r,[{}])}return{hash:r.replace(/\s+/g," ").trim(),localIds:i}}function Pf(t,e=[t]){let n=Wc(t,Qn(e.includes(t)?e:[...e,t])),r=Ss(n).find(o=>o.id===t.id);if(!r)return`invalid|${n}`;let i=tx(r.tag,r.markup,r.id);return`${r.tag}|${i.hash}`}function nx(t){let e=new Map,n=new Map,r={...t.defs},i=!1,o=(l,d)=>{l.forEach((u,p)=>{let f=d[p];f!==void 0&&u!==f&&n.set(u,f)})},s=(l,d)=>{let u=[],p=Ss(l);for(let f of p){let m=f;if(aO.has(m.tag)){let b=m.markup.indexOf(">"),v=m.markup.toLowerCase().lastIndexOf(`</${m.tag}>`);if(b>=0&&v>b){let I=m.markup.slice(b+1,v),x=s(I,m.tag==="defs");if(x!==I&&(i=!0),m={...m,markup:m.markup.slice(0,b+1)+x+m.markup.slice(v)},m.tag==="defs"||!m.id){u.push(m.markup);continue}}}if(!ex.has(m.tag)||!m.id||!d&&sO.has(m.tag)){u.push(m.markup);continue}let g=tx(m.tag,m.markup,m.id),h=`${m.tag}|${g.hash}`,y=e.get(h);if(y===void 0){e.set(h,{id:m.id,localIds:g.localIds}),u.push(m.markup);continue}if(o(g.localIds,y.localIds),y.id===m.id){i=!0;continue}n.set(m.id,y.id),i=!0}return u.join("")};for(let l of er)r[l]=s(r[l],!0);if(!i&&n.size===0)return t;let a={...t,defs:r},c=n.size===0?a:Qv(a,l=>Jc(l,n));return nx(c)}var cO=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","inherit","initial","unset","revert"]);function Kv(t){return t.replace(/&apos;/g,"'").replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").split(",")[0].trim().replace(/^['"]|['"]$/g,"").trim()}function rx(t){let e=new Set,n=r=>{if(!r.includes("font-family"))return;let i=/font-family\s*=\s*"([^"]*)"/g,o;for(;(o=i.exec(r))!==null;)e.add(Kv(o[1]));let s=/font-family\s*:\s*([^;"}<]+)/g;for(;(o=s.exec(r))!==null;)e.add(Kv(o[1]))};for(let r of er)n(t.defs[r]);for(let r of t.body)if(r.kind==="shape")n(r.markup);else for(let i of r.members)n(i.markup);return n(t.envelope.styles),[...e].filter(r=>r&&!cO.has(r.toLowerCase()))}function lO(t,e){let n=rx(t);if(n.length===0)return t;let r=e(n);if(!r||r.trim().length===0)return t;let i=`<style type="text/css">
39
+ ${r.trim()}
40
+ </style>`;return{...t,envelope:{...t.envelope,styles:t.envelope.styles.length>0?`${i}
41
+ ${t.envelope.styles}`:i}}}var dO=new Set(["rect","image","svg","use","text"]),Xv="Inter, sans-serif",uO=new Map([["stroke","stroke"],["stroke-width","strokeWidth"],["stroke-opacity","strokeOpacity"],["fill-opacity","fillOpacity"],["font-weight","fontWeight"],["font-style","fontStyle"],["text-anchor","textAnchor"],["font-family","fontFamily"]]);function so(t){let e=parseFloat(t);return Number.isFinite(e)&&Math.abs(e-1)<1e-6}function Yv(t){let e=parseFloat(t);return Number.isFinite(e)&&e===0}function qv(t){return t===void 0||t==="normal"||t==="400"}var pO=/\s+([A-Za-z_][\w:.-]*)\s*=\s*"([^"]*)"/g;function fO(t,e,n){let r=t.toLowerCase();if(r==="g")return e;let i=r==="image"||r==="foreignobject";return e.replace(pO,(o,s,a)=>{switch(s){case"stroke":return i||a==="none"&&(n.stroke===void 0||n.stroke==="none")?"":o;case"fill":return i?"":o;case"stroke-width":return i||so(a)&&(n.strokeWidth===void 0||so(n.strokeWidth))?"":o;case"stroke-opacity":return so(a)&&(n.strokeOpacity===void 0||so(n.strokeOpacity))?"":o;case"fill-opacity":return so(a)&&(n.fillOpacity===void 0||so(n.fillOpacity))?"":o;case"x":case"y":return dO.has(r)&&Yv(a)?"":o;case"font-weight":return qv(a)&&qv(n.fontWeight)?"":o;case"font-style":return a==="normal"&&(n.fontStyle===void 0||n.fontStyle==="normal")?"":o;case"text-anchor":return a==="start"&&(n.textAnchor===void 0||n.textAnchor==="start")?"":o;case"font-family":return a===Xv&&(n.fontFamily===void 0||n.fontFamily===Xv)?"":o;case"orient":return r==="marker"&&Yv(a)?"":o;case"markerUnits":return r==="marker"&&a==="strokeWidth"?"":o;default:return o}})}function ao(t,e){if(t.length===0)return t;let n=/<(\/?)([A-Za-z_][\w:.-]*)((?:"[^"]*"|'[^']*'|[^>"'])*?)(\/?)>/g,r="",i=0,o;for(;(o=n.exec(t))!==null;){let[s,a,c,l,d]=o;if(r+=t.slice(i,o.index),i=o.index+s.length,a==="/"){e.length>1&&e.pop(),r+=s;continue}let u=e[e.length-1],p=fO(c,l,u);if(r+=`<${c}${p}${d}>`,d!=="/"){let f={...u};l.replace(Zv,(m,g,h)=>{let y=uO.get(g);return y&&(f[y]=h),m}),e.push(f)}}return r+=t.slice(i),r}function mO(t){let e={...t.defs};for(let i of er)e[i]=ao(e[i],[{}]);let n=[{}],r=t.body.map(i=>{if(i.kind==="shape")return{...i,markup:ao(i.markup,n)};let o=ao(i.open,n),s=i.members.map(c=>({...c,markup:ao(c.markup,n)})),a=ao(i.close,n);return{...i,open:o,members:s,close:a}});return{...t,defs:e,body:r}}function gO(t){let e="",n=i=>i.replace(/<defs>[\s\S]*?<\/defs>/g,o=>(e+=o.slice(6,-7),"")),r=t.body.map(i=>i.kind==="shape"?{...i,markup:n(i.markup)}:{...i,members:i.members.map(o=>({...o,markup:n(o.markup)}))});return e.length===0?t:{...t,body:r,defs:{...t.defs,inlineHoisted:t.defs.inlineHoisted+e}}}var hO=new Map([["xlink","http://www.w3.org/1999/xlink"],["dc","http://purl.org/dc/elements/1.1/"],["cc","http://creativecommons.org/ns#"],["rdf","http://www.w3.org/1999/02/22-rdf-syntax-ns#"],["inkscape","http://www.inkscape.org/namespaces/inkscape"],["sodipodi","http://sodipodi.sourceforge.net/DTD/sodipodi-0.0.dtd"]]),yO=new Set(["xml","xmlns"]);function SO(t){let e=new Set,n=new Map,r=/<(\/)?([A-Za-z_][\w:.-]*)((?:"[^"]*"|'[^']*'|[^>"'])*?)(\/?)>/g,i=/(?:^|\s)([A-Za-z_][\w.-]*):([A-Za-z_][\w.-]*)\s*=/g,o=/(?:^|\s)xmlns:([A-Za-z_][\w.-]*)\s*=\s*(?:"([^"]*)"|'([^']*)')/g,s=(u,p)=>{o.lastIndex=0;let f;for(;(f=o.exec(u))!==null;){let m=f[1],g=f[2]??f[3]??"";p.add(m);let h=n.get(m);h||(h=new Set,n.set(m,h)),h.add(g)}},a=(u,p)=>{i.lastIndex=0;let f;for(;(f=i.exec(u))!==null;)f[1]!=="xmlns"&&!p.has(f[1])&&e.add(f[1])},c=new Set(yO);s(t.envelope.rootAttributes,c),a(t.envelope.rootAttributes,c);let l=u=>{if(u.length===0)return;let p=[new Set(c)];r.lastIndex=0;let f;for(;(f=r.exec(u))!==null;){if(f[1]){p.length>1&&p.pop();continue}let m=new Set(p[p.length-1]);s(f[3],m);let g=f[2].indexOf(":");if(g>0){let h=f[2].slice(0,g);m.has(h)||e.add(h)}a(f[3],m),f[4]||p.push(m)}};for(let u of er)l(t.defs[u]);for(let u of t.body)u.kind==="shape"?l(u.markup):l(`${u.open}${u.members.map(p=>p.markup).join("")}</g>`);l(t.backgroundRect),l(t.envelope.descriptive),l(t.envelope.scripts),l(t.envelope.styles);let d=[];for(let u of e){let p=n.get(u),f=p?.size===1?[...p][0]:void 0,m=hO.get(u)??f;if(!m){zt({severity:"warning",code:"undeclarable-namespace-prefix",message:`namespace prefix "${u}:" is used by emitted markup but is neither bound to one unambiguous preserved URI nor a well-known prefix; the output is not namespace-well-formed for this prefix`});continue}d.push(` xmlns:${u}="${m}"`)}return d.length===0?t:(d.sort(),{...t,envelope:{...t.envelope,rootAttributes:t.envelope.rootAttributes+d.join("")}})}function Tf(t,e,n={}){let r=gO(t);if(r=nO(r,e),(n.restoreSourceIds??!0)&&(r=oO(r,e)),(n.deduplicateDefs??!0)&&(r=nx(r)),n.shapeIdAttributes===!1&&(r=qc(r,i=>i.replace(/\sdata-shape-id="[^"]*"/g,""))),r=qc(r,i=>i.replace(/\sdata-source-id="[^"]*"/g,"")),n.resolveFontEmbedCss&&(r=lO(r,n.resolveFontEmbedCss)),n.precision!==null){let i=ff(n.precision??e.documentMetadata?.coordinatePrecision??Oc);r=qc(r,o=>Jv(o,i))}return(n.elideInitialValues??!0)&&(r=mO(r)),r=SO(r),r}var ix=new WeakMap;function bO(t){let e=ix.get(t);if(e)return e;let n=new Set(t.hierarchy.containers.map(r=>r.occurrenceId));return ix.set(t,n),n}function Qc(t,e){for(let n of t){let r=n.state;typeof r.symbolId=="string"&&(r.symbolId=e.get(r.symbolId)??r.symbolId);let i=r.children;Array.isArray(i)&&Qc(i,e)}}function vO(t,e){let n=[...t];for(;;){let r=new Map,i=new Map;for(let o of n){if(o.kind!=="symbol")continue;let s=Pf(o,n),a=r.get(s);a?i.set(o.id,a):r.set(s,o.id)}if(i.size===0)return n;Qc(e,i);for(let o of n)if(o.kind==="symbol"){Qc(o.shapes,i);for(let s of Object.values(o.variants??{}))Qc(s,i)}n=n.filter(o=>o.kind!=="symbol"||!i.has(o.id))}}var xO=new Set(["height","href","id","download","hreflang","ping","preserveaspectratio","referrerpolicy","rel","requiredextensions","systemlanguage","target","transform","type","viewbox","width","x","xlink:href","y"]),ax=new Set(["color","color-interpolation","color-rendering","display","fill","fill-opacity","fill-rule","filter","marker","marker-end","marker-mid","marker-start","mask","mix-blend-mode","opacity","paint-order","shape-rendering","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-rendering","image-rendering","transform-origin","isolation","vector-effect","visibility"]),IO=new Set([...ax,"mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","mix-blend-mode"]);function el(t){if(t===null)return;let e=t.trim();if(!/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?(?:px)?$/u.test(e))return;let n=Number(e.replace(/px$/iu,""));return Number.isFinite(n)?n:void 0}function Rf(t){if(t===null)return;let e=t.trim(),n=/^([+-]?(?:\d+(?:\.\d*)?|\.\d+))%$/u.exec(e),r=n?Number(n[1])/100:el(e);return r===void 0?void 0:Math.min(1,Math.max(0,r))}function bs(t,e,n="auto"){if(t===null)return;let r=e.find(i=>i.toLowerCase()===t.trim().toLowerCase());return!r||r===n?void 0:r}function wO(t){if(t===null)return;let e=t.trim();if(!e||e.toLowerCase()==="none")return;if(/(?:^|[^-_a-z0-9])var\(/iu.test(e))return e;let n=Ti(e),r=e.replace(/[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?(?:px|pt|pc|in|cm|mm|q|em|rem|%|ex|ch|vw|vh|vmin|vmax)?/giu,"").replace(/[\s,]+/gu,"");if(!(n.length===0||r||n.some(i=>i.value<0))&&!n.every(i=>i.value===0))return e}function kO(t,e){let n=Math.max(t.length,e.length);for(let r=0;r<n;r++){let i=(t[r]??-1)-(e[r]??-1);if(i!==0)return i}return 0}function cx(t){let e=new Map(t.useOccurrences.occurrences.map(n=>[n.occurrenceId,n]));return[...new Set([...t.hierarchy.containers.map(n=>n.occurrenceId),...t.hierarchy.placements.map(n=>n.occurrenceId)])].map(n=>e.get(n)).filter(n=>n!==void 0).sort((n,r)=>kO(n.orderKey,r.orderKey)||n.productIndex-r.productIndex||n.occurrenceId.localeCompare(r.occurrenceId))}function PO(t){let e=new Set;for(let n of t.symbolUses.definitions){e.add(n.productRootOccurrenceId);for(let r of n.contentOccurrenceIds)e.add(r)}return e}function lx(t){let e=PO(t),n=new Set(["clippath","filter","lineargradient","marker","mask","pattern","radialgradient"]),r=new Map,i=new Map(t.useOccurrences.occurrences.map(a=>[a.occurrenceId,a]));for(let a of t.useOccurrences.occurrences){if(!a.parentOccurrenceId)continue;let c=r.get(a.parentOccurrenceId)??[];c.push(a),r.set(a.parentOccurrenceId,c)}let o=new Set;for(let a of t.symbolUses.uses){if(a.status!=="linked-reference")continue;let c=[...r.get(a.useOccurrenceId)??[]];for(;c.length>0;){let l=c.pop();o.has(l.occurrenceId)||(o.add(l.occurrenceId),c.push(...r.get(l.occurrenceId)??[]))}}let s=new Set;for(let a of t.useOccurrences.occurrences){let c=a,l=new Set;for(;c&&!l.has(c.occurrenceId);){l.add(c.occurrenceId);let d=t.sourceDocument.index.element(c.correspondingSourceNodeId);if(d&&n.has(d.localName.toLowerCase())){s.add(a.occurrenceId);break}c=c.parentOccurrenceId?i.get(c.parentOccurrenceId):void 0}}return cx(t).filter(a=>!e.has(a.occurrenceId)&&!o.has(a.occurrenceId)&&!s.has(a.occurrenceId))}function Fn(t,e){return e.replace(/url\(\s*(['"]?)#([^'")\s]+)\1\s*\)/gu,(n,r,i)=>{let o=t.identifiers.liveIdForSourceId(i);return o?`url(${r}#${o}${r})`:n})}function TO(t,e,n){let r=t.metadata.candidate(e.correspondingSourceNodeId)?.metadata;if(!r||Object.keys(r).length===0)return;let i=structuredClone(r),o=t.identifiers.liveIdForSourceNodeId(e.correspondingSourceNodeId);if(o&&typeof i.name=="string"&&(i.name=o),typeof i.name=="string"&&e.usePath.length>0){let s=(n.get(i.name)??0)+1;n.set(i.name,s),i.name=`${i.name}-use-${s}`}return i}function RO(t,e){let n=t.scripts.forParent(e).map(r=>({...r.script,customAttrs:r.script.customAttrs?{...r.script.customAttrs}:void 0}));return n.length>0?n:void 0}function CO(t,e,n=!1){let r={};for(let i of t.authoredAttributes.forElement(e)){let o=i.name.toLowerCase();if(i.classification==="style"){n&&(r[i.name]=Fn(t,i.value));continue}["namespace","metadata","aria","data","conditional","geometry","element-specific","foreign"].includes(i.classification)||i.classification==="presentation"&&IO.has(o)&&o!=="color"||xO.has(o)||(r[i.name]=Fn(t,i.value))}return r}function $O(t,e,n){let r=t.styles.style(e),i=v=>{let I=v.toLowerCase(),k=r?.specifiedValues[I]??r?.resolvedValues[I]??null;return k===null?null:n.rewriteValue(e,k)},o={},s=i("fill"),a=i("stroke"),c=t.useOccurrences.occurrence(e),l=c?.parentOccurrenceId?t.styles.style(c.parentOccurrenceId):null,d=r?.cascadedValues.fill!==void 0,u=r?.cascadedValues.stroke!==void 0;s!==null&&(o.fillColor=s==="black"&&r?.cascadedValues.fill===void 0?"#000000":Fn(t,s),s.trim().toLowerCase()==="none"&&(o.fillType="none")),a!==null&&a.trim().toLowerCase()!=="none"?o.borderColor=Fn(t,a):(o.borderColor="none",o.strokeType="none"),!d&&l&&l.resolvedValues.fill!==void 0&&l.resolvedValues.fill===r?.resolvedValues.fill&&(delete o.fillColor,delete o.fillType,o.inheritFill=!0),!u&&l&&l.resolvedValues.stroke!==void 0&&l.resolvedValues.stroke===r?.resolvedValues.stroke&&(o.borderColor="none",delete o.strokeType,o.inheritStroke=!0);let p=[["fillOpacity","fill-opacity",Rf],["strokeOpacity","stroke-opacity",Rf],["opacity","opacity",Rf],["borderWidth","stroke-width",el],["strokeMiterlimit","stroke-miterlimit",el],["dashOffset","stroke-dashoffset",el],["fillRule","fill-rule",v=>v??void 0],["strokeLinecap","stroke-linecap",v=>v??void 0],["strokeLinejoin","stroke-linejoin",v=>v??void 0],["strokeDasharray","stroke-dasharray",wO],["paintOrder","paint-order",v=>v??void 0],["vectorEffect","vector-effect",v=>v??void 0],["blendMode","mix-blend-mode",v=>v??void 0],["shapeRendering","shape-rendering",v=>bs(v,["auto","optimizeSpeed","crispEdges","geometricPrecision"])],["textRendering","text-rendering",v=>bs(v,["auto","optimizeSpeed","optimizeLegibility","geometricPrecision"])],["imageRendering","image-rendering",v=>bs(v,["auto","optimizeSpeed","optimizeQuality","crisp-edges","pixelated","smooth","high-quality"])],["colorRendering","color-rendering",v=>bs(v,["auto","optimizeSpeed","optimizeQuality"])],["colorInterpolation","color-interpolation",v=>bs(v,["auto","sRGB","linearRGB"],"sRGB")]];for(let[v,I,x]of p){let k=r?.cascadedValues[I];if(!k&&["fill-opacity","stroke-opacity","opacity","stroke-miterlimit","stroke-dashoffset","fill-rule","stroke-linecap","stroke-linejoin","stroke-dasharray","paint-order","vector-effect","mix-blend-mode"].includes(I)||!k&&I==="stroke-width"&&(!a||a==="none"))continue;let T=x(i(I));T!==void 0&&(v==="paintOrder"&&T==="normal"||(o[v]=T))}if(o.opacity===1&&r?.cascadedValues.opacity!==void 0&&(o.preserveOpacity=!0),o.inheritFill===!0&&r?.cascadedValues["fill-opacity"]===void 0&&delete o.fillOpacity,o.inheritStroke===!0)for(let[v,I]of[["stroke-opacity","strokeOpacity"],["stroke-width","borderWidth"],["stroke-miterlimit","strokeMiterlimit"],["stroke-dashoffset","dashOffset"],["stroke-linecap","strokeLinecap"],["stroke-linejoin","strokeLinejoin"],["stroke-dasharray","strokeDasharray"]])r?.cascadedValues[v]===void 0&&delete o[I];i("display")?.trim().toLowerCase()==="none"&&(o.display="none");let f=i("visibility")?.trim(),m=r?.cascadedValues.visibility?.value?.trim().toLowerCase();!(l!==null&&c?.parentOccurrenceId!==null&&c?.parentOccurrenceId!==void 0&&bO(t).has(c.parentOccurrenceId)&&l.resolvedValues.visibility===r?.resolvedValues.visibility&&(m===void 0||m==="inherit"||m==="unset"))&&(f==="hidden"||f==="collapse")&&(o.visibility=f);let h=r?.cascadedValues["clip-path"]?.value??null;h&&!/^url\(/iu.test(h.trim())&&(o.cssClipPath=h);let y={};for(let v of["mask","mask-image","mask-mode","mask-repeat","mask-position","mask-clip","mask-origin","mask-size","mask-composite","mask-type"]){let I=r?.cascadedValues[v]?.value??null;I!==null&&(y[v]=Fn(t,I))}Object.keys(y).length>0&&(o.cssMaskProperties=y);let b=Object.fromEntries(Object.entries(r?.inlineDeclarations??{}).filter(([v])=>v.startsWith("--")||v.startsWith("-")).map(([v,I])=>[v,n.rewriteValue(e,I)]));Object.keys(b).length>0&&(o.inlineStyle=b);for(let[v,I]of[["marker-start","markerStart"],["marker-mid","markerMid"],["marker-end","markerEnd"]]){let x=i(v);if(!x)continue;let k=t.resourceDependencies.edges.filter(w=>w.kind==="marker"&&w.propertyName===v&&w.propertyValue===x&&(w.occurrenceId!==null&&w.occurrenceId===e||w.occurrenceId===null&&w.fromSourceNodeId===r?.correspondingSourceNodeId));if(k.length>0){let w=k[0];if(w.validity!=="valid"||!w.targetSourceNodeId)continue;let P=t.markers.candidate(w.targetSourceNodeId);if(!P||P.status!=="materialized")continue;o[I]=tr(t,P.sourceNodeId,P.sourceId)??void 0;continue}let T=/url\(\s*(['"]?)#([^'"\s)]+)\1\s*\)/u.exec(x)?.[2];T&&(o[I]=t.identifiers.liveIdForSourceId(T)??T)}return o}function dx(t,e,n){let r={},i=t.styles.style(e);if(!i)return r;for(let[o,s]of Object.entries(i.cascadedValues))ax.has(o)&&(r[o]=n.rewriteValue(e,Fn(t,s.value)));return r}function NO(t,e){let n=t.symbolUses.use(e.occurrenceId);if(e.role==="use-carrier"&&n){let c=n.transform.matrix??[1,0,0,1,0,0],l=he(c,qe(n.geometry.x,n.geometry.y));return Dt(l)?void 0:ot(l)}let r=t.sourceDocument.index.element(e.correspondingSourceNodeId);if(!r)return;let o=t.styles.style(e.occurrenceId)?.cascadedValues.transform,s=o?.value??C(r,"transform");if(!s||s.trim().toLowerCase()==="none"||o&&o.origin!=="presentation")return;let a=on(s);return a&&!Dt(a)?ot(a):void 0}function ux(t,e,n,r){let i=n.get(e)?.parentOccurrenceId??null;for(;i;){let s=r.get(i);if(s?.type==="svg"){let a=s.state;if(typeof a.svgViewBoxWidth=="number"&&typeof a.svgViewBoxHeight=="number"&&a.svgViewBoxWidth>0&&a.svgViewBoxHeight>0)return{x:typeof a.svgViewBoxX=="number"?a.svgViewBoxX:0,y:typeof a.svgViewBoxY=="number"?a.svgViewBoxY:0,width:a.svgViewBoxWidth,height:a.svgViewBoxHeight};if(typeof a.svgWidth=="number"&&typeof a.svgHeight=="number"&&a.svgWidth>=0&&a.svgHeight>=0)return{x:0,y:0,width:a.svgWidth,height:a.svgHeight}}i=n.get(i)?.parentOccurrenceId??null}let o=t.rootFrame;return{x:o.viewBoxX??0,y:o.viewBoxY??0,width:o.viewBoxWidth??o.width??300,height:o.viewBoxHeight??o.height??150}}function px(t,e,n,r){if(e==="view-box")return{boxX:n.x,boxY:n.y,boxWidth:n.width,boxHeight:n.height};if(e!=="fill-box"&&e!=="content-box"&&e!=="stroke-box"&&e!=="border-box")return null;let i=is(r,t).bounds;if(!i)return null;let o=e==="stroke-box"||e==="border-box",s=Number(t.state.borderWidth??0),a=o&&Number.isFinite(s)&&s>0?s/2:0;return{boxX:i.minX-a,boxY:i.minY-a,boxWidth:i.maxX-i.minX+a*2,boxHeight:i.maxY-i.minY+a*2}}function AO(t,e,n,r,i){for(let o of[...e].reverse()){let s=r.get(o.occurrenceId);if(!s)continue;let a=t.styles.style(o.occurrenceId),c=a?.cascadedValues.transform;if(!c||c.origin==="presentation")continue;let l=c.value.trim();if(!l||l.toLowerCase()==="none"){delete s.state.transformMatrix;continue}let d=ux(t,o.occurrenceId,n,r),u=t.styles.value(o.occurrenceId,"transform-box")??"view-box",p=px(s,u,d,i);if(!p)continue;let f=t.projectionContext.rootFontSize,m=Re(t.styles.value(o.occurrenceId,"font-size"),{percentBasis:f,viewportWidth:d.width,viewportHeight:d.height,fontSize:f,rootFontSize:f})??f,h=a.cascadedValues["transform-origin"]?fa(t.styles.value(o.occurrenceId,"transform-origin")??"0 0",{...p,viewportWidth:d.width,viewportHeight:d.height,fontSize:m,rootFontSize:f}):{x:0,y:0};if(!h)continue;let y=ha([{offset:0,transform:l}],{...p,viewportWidth:d.width,viewportHeight:d.height,fontSize:m,rootFontSize:f,transformOrigin:h,retainPureRotationOrigin:!1});if(y.status!=="projected"||y.stops.length!==1)continue;let b=y.stops[0].matrix;Dt(b)?delete s.state.transformMatrix:s.state.transformMatrix=ot(b)}}function Nr(t,e,n,r,i=!1){let o=$O(t,e.occurrenceId,r),s=TO(t,e,n),a=e.usePath.length===0?t.metadata.candidate(e.correspondingSourceNodeId)?.leadingComments:void 0,c=RO(t,e.correspondingSourceNodeId),l=CO(t,e.correspondingSourceNodeId,i),d=t.conditionalProcessing.condition(e.correspondingSourceNodeId),u=NO(t,e);return s&&(o.metadata=s),a&&a.length>0&&(o.leadingComments=[...a]),c&&(o.scripts=c),Object.keys(l).length>0&&(o.authoredAttributes=l),d&&d.systemLanguage!==null&&(o.systemLanguage=d.systemLanguage),d&&d.requiredExtensions!==null&&(o.requiredExtensions=d.requiredExtensions),u&&(o.transformMatrix=u),o}function Cf(t,e,n,r,i){let o=Nr(t,e,r,i,!0),s=dx(t,e.occurrenceId,i);if(Object.keys(s).length>0)if(n==="group"){let c={},l={};for(let[d,u]of Object.entries(s))d==="fill"?c.fill=u:d==="fill-opacity"?c.fillOpacity=u:d==="stroke-opacity"?c.strokeOpacity=u:d==="opacity"?c.opacity=u:d==="mix-blend-mode"?c.mixBlendMode=u:d==="transform-origin"?c.transformOrigin=u:d==="isolation"?c.isolation=u:d==="filter"?c.filter=u:d==="clip-path"?c.clipPath=u:d==="mask"?c.mask=u:l[d]=u;Object.keys(l).length>0&&(c.attributes=l),o.groupData=c}else o.containerPresentation=s;let a=t.sourceDocument.index.element(e.correspondingSourceNodeId);if(!a)return o;if(n==="hyperlink"){let c=C(a,"href"),l=a.attributes.find(u=>u.name==="xlink:href")?.value,d=u=>{if(!u.startsWith("#"))return u;let p=t.identifiers.liveIdForSourceId(u.slice(1));return p?`#${p}`:u};c!==null?o.href=d(c):l!==void 0&&(o.href=d(l)),l!==void 0&&(o.hrefXlink=d(l));for(let[u,p]of[["target","linkTarget"],["download","linkDownload"],["ping","linkPing"],["rel","linkRel"],["hreflang","linkHreflang"],["type","linkType"],["referrerpolicy","linkReferrerPolicy"]]){let f=C(a,u);f!==null&&(o[p]=f)}}else if(n==="switch"){let c=t.conditionalProcessing.condition(a.sourceNodeId);c&&(o.switchSystemLanguage=c.systemLanguage,o.switchRequiredExtensions=c.requiredExtensions)}else if(n==="embedded-svg"){let c=t.embeddedFrames.find(l=>l.sourceNodeId===a.sourceNodeId);c&&Object.assign(o,c.state)}return o}function $f(t){return t==="embedded-svg"?"svg":t}function EO(t){let e=t.styles.stylesheets.map((n,r)=>({id:`svg-style-${r+1}`,...n.id?{svgId:n.id}:{},css:n.authoredText,...n.type?{type:n.type}:{},...n.media?{media:n.media}:{},preserved:!0}));return e.length>0?e:void 0}function MO(t){return{severity:"error",code:"application-rolled-back",source:"svg",entrypoint:"svg-document-import",capability:"geometry",message:t}}function tr(t,e,n){return t.identifiers.resourceIds.find(r=>r.sourceNodeId===e)?.liveId??n}function fx(t,e){return t.identifiers.liveIdForSourceNodeId(e)??t.identifiers.generatedIds.find(n=>n.sourceNodeId===e)?.liveId??null}function tl(t,e){let n=structuredClone(e.state),r=e.authoredTextStructure;if(!r)return n;let i=r.spans.flatMap(o=>{let s=fx(t,o.sourceNodeId);return s?[{start:o.start,end:o.end,id:s}]:[]});return i.length===r.spans.length&&(n.authoredTextStructure={text:r.text,spans:i}),n}function OO(t,e){let n=e;for(;n;){let r=t.clipMasks.definition(n.sourceNodeId);if(r)return r.representation==="raw";n=t.sourceDocument.index.parent(n.sourceNodeId)}return!1}function DO(t){return t.replaceAll("\\","\\\\").replaceAll('"','\\"').replaceAll(`
42
+ `,"\\a ")}function zO(t){let e=t?.rawXml??"",n=e.indexOf(">"),r=e.lastIndexOf("</");return n>=0&&r>n?e.slice(n+1,r):""}function mx(t){return t.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;")}function ox(t){return mx(t).replaceAll('"',"&quot;")}function _O(t,e){let n=new Map(e.map(a=>[a.occurrenceId,a])),r=new Map;for(let a of e){if(!a.parentOccurrenceId||!n.has(a.parentOccurrenceId))continue;let c=r.get(a.parentOccurrenceId)??[];c.push(a),r.set(a.parentOccurrenceId,c)}let i=(a,c,l=new Set)=>{let d=[];for(let u of a.attributes){let p=u.name.toLowerCase();if(p.startsWith("xmlns")||/^on[a-z]/u.test(p)||l.has(p)||p==="id"&&c.shadow)continue;let f=p==="id"?tr(t,a.sourceNodeId,u.value)??u.value:Fn(t,u.value);d.push(`${u.name}="${ox(f)}"`)}return d.length>0?` ${d.join(" ")}`:""},o=a=>a.children.filter(c=>c.kind!=="element").map(c=>c.kind==="comment"?`<!--${c.value}-->`:c.kind==="cdata"?`<![CDATA[${c.value.replaceAll("]]>","]]]]><![CDATA[>")}]]>`:c.kind==="processing-instruction"?`<?${c.value}?>`:c.kind==="doctype"?`<!DOCTYPE ${c.value}>`:mx(c.value)).join(""),s=a=>{let c=t.sourceDocument.index.element(a.correspondingSourceNodeId);if(!c)return"";let d=(r.get(a.occurrenceId)??[]).map(s).join("");if(c.localName.toLowerCase()==="use"){let p=new Set(["href","xlink:href","x","y","width","height","transform","id"]),f=t.symbolUses.use(a.sourceOccurrenceId),m=[];f?.transform.authored&&m.push(f.transform.authored);let g=f?.geometry.x??0,h=f?.geometry.y??0;(g!==0||h!==0)&&m.push(`translate(${g} ${h})`);let y=m.length>0?` transform="${ox(m.join(" "))}"`:"";return`<g${i(c,a,p)}${y}>${d}</g>`}let u=d||o(c);return`<${c.name}${i(c,a)}>${u}</${c.name}>`};return e.filter(a=>a.parentOccurrenceId===null||!n.has(a.parentOccurrenceId)).map(s).join("")}function co(t,e){let n=o=>{let s=t.useOccurrences.direct(o.sourceNodeId);return s?t.styles.value(s.occurrenceId,"display"):C(o,"display")},r=t.sourceDocument.index.element(e);if(!r)return!1;if(n(r)?.trim().toLowerCase()==="none")return!0;let i=t.sourceDocument.index.parent(e);for(;i;){if(i.localName.toLowerCase()==="defs"&&n(i)?.trim().toLowerCase()==="none")return!0;i=t.sourceDocument.index.parent(i.sourceNodeId)}return!1}function FO(t){let e=t.indexOf(">");if(e<0)return t;let n=t.slice(0,e);return/\bdisplay\s*=/iu.test(n)?t:t.replace(/^(\s*<[\w:.-]+)/u,'$1 display="none"')}function vs(t,e,n){let r=n.kind==="color"?n.value??"none":"none";e==="fill"?(t.fillType=n.kind==="color"?"solid":"none",t.fillColor=r):(t.strokeType=n.kind==="color"?"solid":"none",t.borderColor=r)}function Nf(t,e){e==="fill"?(t.fillType="none",t.fillColor="none",delete t.fillGradient,delete t.fillLibraryId):(t.strokeType="none",t.borderColor="none",delete t.strokeGradient,delete t.strokeLibraryId)}function LO(t,e,n){let r=[...e.library??[]],i=new Set,o=new Map,s=new Map,a={width:t.rootFrame.viewBoxWidth??t.rootFrame.width??300,height:t.rootFrame.viewBoxHeight??t.rootFrame.height??150},c=Zn(e);for(let d of t.gradients.bindings){let u=n.get(d.occurrenceId);if(!u)continue;let p=u.state,f=d.propertyName==="fill"?"fill":"stroke";if(f==="fill"&&p.inheritFill===!0||f==="stroke"&&p.inheritStroke===!0)continue;if(d.status!=="materialized"||!d.gradientSourceNodeId||co(t,d.gradientSourceNodeId)){d.status==="empty"?Nf(p,d.propertyName):(d.status==="invalid"||d.status==="invalid-reference"||d.gradientSourceNodeId&&co(t,d.gradientSourceNodeId))&&vs(p,d.propertyName,d.fallback);continue}let m=t.gradients.candidate(d.gradientSourceNodeId),g=m?tr(t,m.sourceNodeId,m.sourceId):null;if(!m||m.status!=="materialized"||!g)continue;let h=t.gradients.resolveGeometry(d,{viewport:a,fontSize:16,rootFontSize:16});if(!h)continue;let y=Object.fromEntries(Object.entries(m.geometryValues).filter(([,x])=>x.validity==="valid").map(([x,k])=>[x,k.raw])),b={id:g,stops:m.stops.map(x=>({offset:x.offset,color:x.color,opacity:x.opacity})),spreadMethod:m.spreadMethod,opacity:1,...m.gradientUnits==="userSpaceOnUse"?{gradientUnits:"userSpaceOnUse"}:{},...m.colorInterpolation!=="sRGB"?{colorInterpolation:m.colorInterpolation}:{},...Object.keys(y).length>0?{authoredGeometry:y}:{},...m.transform.authored?.validity==="valid"?{gradientTransform:[...m.transform.matrix]}:{},...m.sourceId?{sourceId:m.sourceId}:{}},v=m.type==="linear-gradient"?{type:"linear-gradient",x1:h.x1,y1:h.y1,x2:h.x2,y2:h.y2,...b}:{type:"radial-gradient",cx:h.cx,cy:h.cy,fx:h.fx,fy:h.fy,r:h.r,ry:h.r,rotation:0,...h.fr!==0||m.authoredGeometry.fr!==void 0?{fr:h.fr}:{},...b};if(!o.has(g)){let{id:x,sourceId:k,...T}=v,w={kind:m.type,id:g,name:m.sourceId??g,...k?{sourceId:k}:{},gradient:T};o.set(g,w),i.add(g)}let I=v.stops[0]?.color??"#000000";f==="fill"?(p.fillType=v.type,p.fillGradient=v,p.fillLibraryId=g,p.fillColor=I):(p.strokeType=v.type,p.strokeGradient=v,p.strokeLibraryId=g,p.borderColor=I)}for(let d of t.patterns.bindings){let u=n.get(d.occurrenceId);if(!u)continue;let p=u.state,f=d.propertyName==="fill"?"fill":"stroke";if(f==="fill"&&p.inheritFill===!0||f==="stroke"&&p.inheritStroke===!0)continue;if(d.status!=="materialized"||!d.patternSourceNodeId||co(t,d.patternSourceNodeId)){d.status==="empty"?Nf(p,d.propertyName):(d.status==="invalid"||d.status==="invalid-reference"||d.patternSourceNodeId&&co(t,d.patternSourceNodeId))&&vs(p,d.propertyName,d.fallback);continue}let m=t.patterns.candidate(d.patternSourceNodeId),g=m?tr(t,m.sourceNodeId,m.sourceId):null;if(!m||m.status!=="materialized"||!g){vs(p,d.propertyName,d.fallback);continue}let h=is(c,u).bounds,y=t.patterns.resolveTile(d,{viewport:a,objectBounds:h?{x:h.minX,y:h.minY,width:h.maxX-h.minX,height:h.maxY-h.minY}:{x:0,y:0,width:0,height:0},fontSize:16,rootFontSize:16});if(!y){Nf(p,d.propertyName);continue}let b=m.contentProviderSourceNodeId?t.sourceDocument.index.element(m.contentProviderSourceNodeId):null,v=m.contentOccurrences.length>0?_O(t,m.contentOccurrences):zO(b);if(!v)continue;let I=Object.fromEntries(Object.entries(m.values).filter(([,k])=>k.validity==="valid").map(([k,T])=>[k,T.raw])),x={type:"pattern",id:g,patternType:"custom",color:"#000000",backgroundColor:"#ffffff",scale:1,rotation:0,opacity:1,svgContent:Fn(t,v),width:y.width,height:y.height,patternUnits:m.patternUnits,patternContentUnits:m.patternContentUnits,...m.values.x?{x:y.x}:{},...m.values.y?{y:y.y}:{},...Object.keys(I).length>0?{authoredGeometry:I}:{},...m.transform.raw&&m.transform.validity==="valid"?{patternTransform:m.transform.raw}:{},...m.viewBoxAuthored?.validity==="valid"?{viewBox:m.viewBoxAuthored.raw}:{},...m.preserveAspectRatioAuthored?.validity==="valid"?{preserveAspectRatio:m.preserveAspectRatioAuthored.raw}:{},...m.sourceId?{sourceId:m.sourceId}:{}};if(!s.has(g)){let{id:k,sourceId:T,customPatternId:w,...P}=x;s.set(g,{kind:"pattern",id:g,name:m.sourceId??g,...T?{sourceId:T}:{},pattern:P}),i.add(g)}f==="fill"?(p.fillType="pattern",p.fillGradient=x,p.fillLibraryId=g,p.fillColor=x.color):(p.strokeType="pattern",p.strokeGradient=x,p.strokeLibraryId=g,p.borderColor=x.color)}let l=[...o.values(),...s.values()];return l.length>0&&(e.library=[...r,...l]),i}function BO(t,e,n){let r=[...e.library??[]],i=new Map,o=new Set;for(let s of t.filters.bindings){let a=n.get(s.consumerOccurrenceId);if(!a)continue;let c=a.state;if(s.status!=="materialized"){delete c.filterLibraryIds,delete c.filters;continue}let l=[],d=[],u=[],p=!1;for(let f of s.operations){if(f.status!=="materialized")continue;if(f.kind==="function"){p=!0,f.filter&&d.push(structuredClone(f.filter));continue}if(!f.filterSourceNodeId)continue;let m=t.filters.candidate(f.filterSourceNodeId),g=m?tr(t,m.sourceNodeId,m.sourceId):null;!m||m.status!=="materialized"||!g||(l.push(g),o.add(g),u.push({id:g,candidate:m}),d.push(...structuredClone(m.filters)))}if(p&&l.length>0){let f=`filter-${a.id}`,m=1,g=new Set([...r.map(y=>y.id),...i.keys()]);for(;g.has(f);)f=`filter-${a.id}-${m++}`;let h=u[0]?.candidate;i.set(f,{kind:"filter",id:f,name:f,filters:structuredClone(d),...h?{colorInterpolation:h.colorInterpolation,filterUnits:h.filterUnits,primitiveUnits:h.primitiveUnits,x:h.region.x,y:h.region.y,width:h.region.width,height:h.region.height}:{}}),c.filterLibraryIds=[f]}else if(l.length>0){c.filterLibraryIds=l;for(let{id:f,candidate:m}of u)i.has(f)||i.set(f,{kind:"filter",id:f,name:m.sourceId??f,...m.sourceId?{sourceId:m.sourceId}:{},filters:[...structuredClone(m.filters)],colorInterpolation:m.colorInterpolation,filterUnits:m.filterUnits,primitiveUnits:m.primitiveUnits,x:m.region.x,y:m.region.y,width:m.region.width,height:m.region.height})}d.length>0&&(c.filters=d)}return i.size>0&&(e.library=[...r,...i.values()]),o}function GO(t,e,n,r,i,o,s){let a=[],c=new Set,l=new Map(e.sceneTree?.map(u=>[u.id,{parentId:u.parentId,index:u.index}])??[]),d=0;for(let u of t.clipMasks.bindings){let p=n.get(u.consumerOccurrenceId);if(!p||!r.has(p.id))continue;let f=p.state,m=u.definitionSourceNodeId?t.clipMasks.definition(u.definitionSourceNodeId):null,g=Fn(t,u.authoredValue);if(u.status!=="materialized"||!m||m.status!=="materialized"||co(t,m.sourceNodeId)){u.propertyName==="clip-path"?f.cssClipPath=g:f.cssMaskProperties={...f.cssMaskProperties??{},[u.propertyName]:g};continue}let h=tr(t,m.sourceNodeId,m.sourceId)??`${m.type}-definition-${d+1}`,y=t.sourceDocument.index.element(m.sourceNodeId),b=!c.has(h);c.add(h);let v=b&&m.representation==="raw"?t.paintServerDefinitions.candidate(m.sourceNodeId)?.definition.markup??Fn(t,y?.rawXml??m.rawDefinition??""):"",I=e.sceneTree?.find(P=>P.id===p.id),x=l.get(p.id);if(delete f.cssClipPath,f.cssMaskProperties&&typeof f.cssMaskProperties=="object"){let P={...f.cssMaskProperties};delete P[u.propertyName],f.cssMaskProperties=Object.keys(P).length>0?P:void 0}let k=f.authoredAttributes;if(k&&typeof k=="object"){let P={...k};delete P[u.propertyName],f.authoredAttributes=Object.keys(P).length>0?P:void 0}let T=[],w=is(Zn(e),p).bounds;if(w){let P=t.clipMasks.resolve(u,{consumerObjectBounds:{x:w.minX,y:w.minY,width:w.maxX-w.minX,height:w.maxY-w.minY}});for(let N of P.geometryPlacements){let R=i.get(N.occurrenceId),$=t.leafGeometry.candidate(N.occurrenceId);if(!R||!$?.canonicalType||$.status!=="materialized")continue;let A=`clip-mask-${d+1}-shape-${T.length+1}`,O={...tl(t,$),...Nr(t,R,o,s)},G=O.transformMatrix,M=G?he(N.matrix,G):N.matrix;Dt(M)?delete O.transformMatrix:O.transformMatrix=ot(M),m.type==="clip"&&(O.fillColor="#000000",O.fillType="solid",delete O.inheritFill,delete O.inheritStroke,delete O.borderColor,delete O.borderWidth,O.strokeType="none",N.clipRule==="evenodd"?O.fillRule="evenodd":$.canonicalType==="path"?O.fillRule="nonzero":delete O.fillRule);let V={id:A,type:$.canonicalType,state:O};e.shapes.push(V),T.push(A),n.has(N.occurrenceId)||n.set(N.occurrenceId,V)}}a.push({id:`clip-mask-${++d}`,type:m.type,definitionId:h,clipShapeIds:T,contentShapeIds:[p.id],parentId:x?.parentId??I?.parentId??null,...x?{siblingIndex:x.index}:{},...m.type==="clip"?{...m.clipPathUnits?{clipPathUnits:m.clipPathUnits}:{},...m.clipRule?{clipRule:m.clipRule}:{}}:{...m.maskUnits?{maskUnits:m.maskUnits}:{},...m.maskContentUnits?{maskContentUnits:m.maskContentUnits}:{},...m.maskType?{maskType:m.maskType}:{},...m.region?{maskBounds:{...m.region}}:{}},...v?{rawDefinition:v}:{}})}return a.length>0&&(e.clipMaskGroups=a,lr(e)),c}function Af(t,e={}){let n=wu(t.styles),r=new Map(t.useOccurrences.occurrences.map(E=>[E.occurrenceId,E])),i=new Map(t.hierarchy.containers.map(E=>[E.occurrenceId,E])),o=new Map(t.leafGeometry.candidates.filter(E=>E.status==="materialized").map(E=>[E.occurrenceId,E])),s=cx(t),a=lx(t),c=new Map,l=new Map;for(let E of t.symbolUses.definitions){let z=tr(t,E.sourceNodeId,E.sourceId)??`symbol-${c.size+1}`,B=(l.get(z)??0)+1;l.set(z,B),c.set(E.productKey,B===1?z:`${z}-use-${B}`)}let d=new Map;a.forEach((E,z)=>{d.set(E.occurrenceId,`svg-node-${z+1}`)});let u=new Map,p=[];for(let E of a){let z=d.get(E.occurrenceId),B=t.symbolUses.use(E.occurrenceId);if(B?.status==="symbol-instance"&&B.definitionProductKey){let L=t.symbolUses.definition(B.definitionProductKey),be=c.get(B.definitionProductKey);if(!L||!be)continue;let ce=Nr(t,E,u,n);delete ce.transformMatrix,ce.symbolId=be,ce.x=B.geometry.x,ce.y=B.geometry.y,ce.width=B.geometry.width??L.parsedViewBox?.width??100,ce.height=B.geometry.height??L.parsedViewBox?.height??100,B.geometry.authored&&(ce.authoredUseGeometry={...B.geometry.authored});let Te={...B.presentation};B.transform.authored&&B.transform.authored.trim()&&(Te.transform=B.transform.authored),Object.keys(Te).length>0&&(ce.instancePresentation=Te),L.parsedViewBox?(ce.viewBoxWidth=L.parsedViewBox.width,ce.viewBoxHeight=L.parsedViewBox.height,ce.scaleContentToViewport=!0):ce.scaleContentToViewport=!1,p.push({id:z,type:"symbol-instance",state:ce});continue}if(B?.status==="linked-reference"&&B.targetSourceNodeId){let L=t.useOccurrences.direct(B.targetSourceNodeId),be=L?d.get(L.occurrenceId):void 0;if(!be)continue;let ce=Nr(t,E,u,n),Te=B.transform.matrix;ce.targetShapeId=be,ce.offsetX=B.geometry.x,ce.offsetY=B.geometry.y,Te&&!Dt(Te)?ce.transformMatrix=ot(Te):delete ce.transformMatrix,p.push({id:z,type:"shape-reference",state:ce});continue}let se=i.get(E.occurrenceId);if(se){p.push({id:z,type:$f(se.kind),state:Cf(t,E,se.kind,u,n)});continue}let me=o.get(E.occurrenceId);me?.canonicalType&&p.push({id:z,type:me.canonicalType,state:{...tl(t,me),...Nr(t,E,u,n)}})}let f=new Map,m=[];for(let[E,z]of t.symbolUses.definitions.entries()){let B=c.get(z.productKey);if(!B)continue;let se=new Set;for(let ie of z.contentOccurrenceIds){let we=t.symbolUses.use(ie);if(we?.status!=="symbol-instance"||!we.definitionProductKey)continue;let $e=t.symbolUses.definition(we.definitionProductKey);if($e){se.add($e.productRootOccurrenceId);for(let Ue of $e.contentOccurrenceIds)se.add(Ue)}}let me=t.sourceDocument.index.element(z.sourceNodeId),L=new Set(z.contentOccurrenceIds);me&&!["g","symbol"].includes(me.localName.toLowerCase())&&L.add(z.productRootOccurrenceId);let be=s.filter(ie=>L.has(ie.occurrenceId)&&!se.has(ie.occurrenceId)),ce=new Map;be.forEach((ie,we)=>{ce.set(ie.occurrenceId,`symbol-node-${E+1}-${we+1}`)});let Te=new Map;for(let ie of be){let we=ce.get(ie.occurrenceId),$e=t.symbolUses.use(ie.occurrenceId),Ue=null;if($e?.status==="symbol-instance"&&$e.definitionProductKey){let Ie=t.symbolUses.definition($e.definitionProductKey),He=c.get($e.definitionProductKey);if(Ie&&He){let Se=Nr(t,ie,u,n);delete Se.transformMatrix,Se.symbolId=He,Se.x=$e.geometry.x,Se.y=$e.geometry.y,Se.width=$e.geometry.width??Ie.parsedViewBox?.width??100,Se.height=$e.geometry.height??Ie.parsedViewBox?.height??100,$e.geometry.authored&&(Se.authoredUseGeometry={...$e.geometry.authored});let dt={...$e.presentation};$e.transform.authored&&$e.transform.authored.trim()&&(dt.transform=$e.transform.authored),Object.keys(dt).length>0&&(Se.instancePresentation=dt),Ie.parsedViewBox?(Se.viewBoxWidth=Ie.parsedViewBox.width,Se.viewBoxHeight=Ie.parsedViewBox.height,Se.scaleContentToViewport=!0):Se.scaleContentToViewport=!1,Ue={id:we,type:"symbol-instance",state:Se}}}else{let Ie=i.get(ie.occurrenceId);if(Ie)Ue={id:we,type:$f(Ie.kind),state:Cf(t,ie,Ie.kind,u,n)};else{let He=o.get(ie.occurrenceId);He?.canonicalType&&(Ue={id:we,type:He.canonicalType,state:{...tl(t,He),...Nr(t,ie,u,n)}})}}if(!Ue)continue;ie.occurrenceId===z.productRootOccurrenceId&&me&&!["g","symbol"].includes(me.localName.toLowerCase())&&delete Ue.state.transformMatrix;let tt=t.useOccurrences.direct(ie.correspondingSourceNodeId),tn=tt?t.styles.style(tt.occurrenceId):null,W=Ue.state;tn?.cascadedValues.fill||(delete W.fillColor,delete W.fillType,delete W.fillGradient,delete W.fillLibraryId,W.inheritFill=!0),tn?.cascadedValues.stroke||(delete W.borderColor,delete W.strokeType,delete W.strokeGradient,delete W.strokeLibraryId,W.inheritStroke=!0),Te.set(ie.occurrenceId,Ue),f.set(ie.occurrenceId,Ue)}let Xe=[];for(let ie of be){let we=Te.get(ie.occurrenceId);if(!we)continue;let $e=i.get(ie.occurrenceId),Ue=t.hierarchy.placements.find(W=>W.occurrenceId===ie.occurrenceId),tt=$e?.parentContainerOccurrenceId??Ue?.parentContainerOccurrenceId??null,tn=tt?Te.get(tt):void 0;if(tn){let W=tn.state,Ie=W.children??[];W.children=[...Ie,we]}else Xe.push(we)}let je=t.metadata.candidate(z.sourceNodeId)?.metadata,Ft=me!==null&&["g","symbol"].includes(me.localName.toLowerCase()),Ut={...z.rootAttributes,...Ft?dx(t,z.productRootOccurrenceId,n):{}};m.push({kind:"symbol",id:B,name:z.sourceId??B,...z.sourceId?{sourceId:z.sourceId}:{},defKind:z.defKind,...z.viewBox!==null?{viewBox:z.viewBox}:{},...z.preserveAspectRatio!==null?{preserveAspectRatio:z.preserveAspectRatio}:{},...z.x!==null?{x:z.x}:{},...z.y!==null?{y:z.y}:{},...z.width!==null?{width:z.width}:{},...z.height!==null?{height:z.height}:{},...z.refX!==null?{refX:z.refX}:{},...z.refY!==null?{refY:z.refY}:{},...Object.keys(Ut).length>0?{rootAttributes:Ut}:{},...je&&Object.keys(je).length>0?{metadata:structuredClone(je)}:{},shapes:Xe})}for(let[E,z]of t.markers.candidates.entries()){if(z.status!=="materialized")continue;let B=tr(t,z.sourceNodeId,z.sourceId);if(!B)continue;let se=new Map;for(let ie of z.content){let we=r.get(ie.occurrenceId);if(!we)continue;let $e=`marker-node-${E+1}-${se.size+1}`,Ue=i.get(we.occurrenceId),tt=ie.elementName==="g"?"group":ie.elementName==="a"?"hyperlink":ie.elementName==="switch"?"switch":ie.elementName==="svg"?"embedded-svg":null,tn=Ue?.kind??tt,W=null;if(tn)W={id:$e,type:$f(tn),state:Cf(t,we,tn,u,n)};else{let Ie=o.get(we.occurrenceId);Ie?.canonicalType&&(W={id:$e,type:Ie.canonicalType,state:{...tl(t,Ie),...Nr(t,we,u,n)}})}W&&se.set(we.occurrenceId,W)}let me=[];for(let ie of z.content){let we=se.get(ie.occurrenceId);if(!we)continue;let $e=ie.parentOccurrenceId?se.get(ie.parentOccurrenceId):void 0;if($e){let Ue=$e.state;Ue.children=[...Ue.children??[],we]}else me.push(we)}let L=new Map(z.content.map(ie=>[ie.occurrenceId,ie])),be=new Map;for(let ie of z.content){let we=se.get(ie.occurrenceId);we&&!be.has(ie.sourceNodeId)&&be.set(ie.sourceNodeId,we)}let ce=ie=>({shapeId:ie.id,shapeType:ie.type,state:ie.state}),Te=ie=>{let we=[];for(let[$e,Ue]of se){let tt=L.get($e)?.parentOccurrenceId??null;for(;tt;){if(tt===ie){we.push(Ue);break}tt=L.get(tt)?.parentOccurrenceId??null}}return we},Xe=z.viewBox?.trim().split(/[\s,]+/u).map(Number),je=Xe?.length===4&&Xe.every(Number.isFinite)?{x:Xe[0],y:Xe[1],width:Xe[2],height:Xe[3]}:{x:0,y:0,width:z.markerWidth,height:z.markerHeight},Ft=Na(t,{shapeIdForOccurrence:ie=>se.get(ie)?.id??null,shapeStateForOccurrence:ie=>se.get(ie)?.state??null,shapeIdForSourceNode:ie=>be.get(ie)?.id??null,shapeBindingsForOccurrence:ie=>{let we=se.get(ie);return we?[ce(we)]:[]},descendantShapeBindingsForOccurrence:ie=>Te(ie).map(ce),cssTransformContextForOccurrence:()=>({viewportWidth:je.width,viewportHeight:je.height,boxX:je.x,boxY:je.y,boxWidth:je.width,boxHeight:je.height})}),Ut=t.metadata.candidate(z.sourceNodeId)?.metadata;m.push({kind:"marker",id:B,name:z.name,...z.sourceId?{sourceId:z.sourceId}:{},...Ut&&Object.keys(Ut).length>0?{metadata:structuredClone(Ut)}:{},...z.viewBox?{viewBox:z.viewBox}:{},...z.preserveAspectRatio?{preserveAspectRatio:z.preserveAspectRatio}:{},...Object.keys(z.authoredGeometry).length>0?{authoredGeometry:{...z.authoredGeometry}}:{},...Object.keys(z.rootAttributes).length>0?{rootAttributes:{...z.rootAttributes}}:{},refX:z.refX,refY:z.refY,markerWidth:z.markerWidth,markerHeight:z.markerHeight,markerUnits:z.markerUnits,orient:z.orient,...z.overflow?{overflow:z.overflow}:{},shapes:me,...Ft?{animations:Ft.tracks}:{}})}for(let[E,z]of t.views.entries()){let B=t.sourceDocument.index.element(z.sourceNodeId),se=B?C(B,"id"):null,me=tr(t,z.sourceNodeId,se);p.push({id:`svg-view-${E+1}`,type:"view",state:{...z.state,...me?{viewName:me}:{}}})}let g=new Map,h=[];for(let E of a){let z=d.get(E.occurrenceId);if(!z||!p.some(ce=>ce.id===z))continue;let B=i.get(E.occurrenceId),se=t.hierarchy.placements.find(ce=>ce.occurrenceId===E.occurrenceId),me=B?.parentContainerOccurrenceId??se?.parentContainerOccurrenceId??null,L=me?d.get(me)??null:null,be=g.get(L)??0;g.set(L,be+1),h.push({id:z,parentId:L,index:be})}for(let E of p.filter(z=>z.type==="view")){let z=g.get(null)??0;g.set(null,z+1),h.push({id:E.id,parentId:null,index:z})}let y=t.rootFrame,b=e.entrypoint==="external-svg-paste",v=y.systemLanguage!==void 0||y.requiredExtensions!==void 0,I=b&&(y.targetedPasteWrapper||v)?"svg-import-root-wrapper":null;if(I){let E={...y.systemLanguage!==void 0?{systemLanguage:y.systemLanguage}:{},...y.requiredExtensions!==void 0?{requiredExtensions:y.requiredExtensions}:{}},z=y.targetedPasteWrapper?"svg":"group";z==="svg"&&(y.width!==void 0&&(E.svgWidth=y.width),y.height!==void 0&&(E.svgHeight=y.height),y.sizingMode==="explicit"&&(E.svgViewBoxX=y.viewBoxX,E.svgViewBoxY=y.viewBoxY,E.svgViewBoxWidth=y.viewBoxWidth,E.svgViewBoxHeight=y.viewBoxHeight),y.preserveAspectRatio!==void 0&&(E.svgPreserveAspectRatio=y.preserveAspectRatio)),p.unshift({id:I,type:z,state:E});for(let B of h)B.parentId===null&&(B.parentId=I);h.unshift({id:I,parentId:null,index:0})}let x=y.viewBoxWidth??y.width??300,k=y.viewBoxHeight??y.height??150;p.unshift({id:"svg-document-root",type:"svg",state:{isRootSvg:!0,svgWidth:y.width??x,svgHeight:y.height??k,svgViewBoxX:y.viewBoxX??0,svgViewBoxY:y.viewBoxY??0,svgViewBoxWidth:x,svgViewBoxHeight:k,...y.preserveAspectRatio!==void 0?{svgPreserveAspectRatio:y.preserveAspectRatio}:{},...y.systemLanguage!==void 0?{systemLanguage:y.systemLanguage}:{},...y.requiredExtensions!==void 0?{requiredExtensions:y.requiredExtensions}:{}}});let T=vO(m,p),w=Xo({shapes:p,viewboxes:[Zi(y.viewBoxX??0,y.viewBoxY??0,Math.max(x,1),Math.max(k,1),"svg-viewbox-1")],metadata:t.metadata.document.metadata});w.sceneTree=[{id:"svg-document-root",parentId:null,index:0},...h.map(E=>E.parentId===null?{...E,index:E.index+1}:E)],T.length>0&&(w.library=T);let P=Zn(w),N=new Map,R=new Map;for(let E of a){let z=d.get(E.occurrenceId),B=z?p.find(se=>se.id===z):void 0;B&&(N.set(E.occurrenceId,B),R.has(E.correspondingSourceNodeId)||R.set(E.correspondingSourceNodeId,B.id))}AO(t,a,r,N,P);let $=new Map(N),A=new Map;for(let E of t.symbolUses.uses){if(E.status!=="symbol-instance"||!E.definitionProductKey)continue;let z=$.get(E.useOccurrenceId),B=t.symbolUses.definition(E.definitionProductKey);if(!z||!B)continue;let se=A.get(B.productRootOccurrenceId)??[];se.push(z),A.set(B.productRootOccurrenceId,se),R.has(B.sourceNodeId)||R.set(B.sourceNodeId,z.id)}for(let[E,z]of f){N.set(E,z);let B=r.get(E);B&&!R.has(B.correspondingSourceNodeId)&&R.set(B.correspondingSourceNodeId,z.id)}if(I){let E=p.find(B=>B.id===I),z=t.useOccurrences.direct(t.sourceDocument.root.sourceNodeId);E&&(R.set(t.sourceDocument.root.sourceNodeId,E.id),z&&(N.set(z.occurrenceId,E),$.set(z.occurrenceId,E)))}let O=new Set(w.shapes.map(E=>E.id));GO(t,w,N,O,r,u,n),LO(t,w,N),BO(t,w,N);let G=E=>{let z=[];for(let[B,se]of N){let me=r.get(B)?.parentOccurrenceId??null;for(;me;){if(me===E){z.push(se);break}me=r.get(me)?.parentOccurrenceId??null}}return z},M=E=>ux(t,E,r,N),V=E=>({shapeId:E.id,shapeType:E.type,state:E.state}),K=E=>{let z=$.get(E);return z?[z]:A.get(E)??[]},X=Na(t,{shapeIdForOccurrence:E=>K(E)[0]?.id??null,shapeStateForOccurrence:E=>K(E)[0]?.state??null,shapeIdForSourceNode:E=>R.get(E)??null,shapeBindingsForOccurrence:E=>K(E).map(V),descendantShapeBindingsForOccurrence:E=>G(E).filter(z=>O.has(z.id)).map(V),domTargetForOccurrence:E=>{let z=r.get(E);if(!z)return null;let B=t.sourceDocument.index.element(z.correspondingSourceNodeId);if(!B||!OO(t,B))return null;let se=fx(t,B.sourceNodeId);if(!se)return null;let me=Object.fromEntries(B.attributes.map(L=>[L.name,L.value]));return me.id=se,{shapeId:`__dom__${se}`,selector:`[id="${DO(se)}"]`,baseTransform:t.styles.value(E,"transform")??me.transform??"",baseAttributes:Object.freeze(me)}},cssTransformContextForOccurrence:(E,z)=>{let B=K(E)[0],se=M(E),me=B?px(B,z,se,P):null;return{viewportWidth:se.width,viewportHeight:se.height,...me??{}}}});X&&(w.animationTimeline=X);let U=Object.entries(n.variables).map(([E,z])=>({name:E,type:/^(?:[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?)$/u.test(z.trim())?"number":/^(?:#[0-9a-f]{3,8}|(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color)\s*\()/iu.test(z.trim())?"color":"string",defaultValue:z}));U.length>0&&(w.templateVariables=U);let te=EO(t);te&&(w.documentStyles=te);let Z=new Set([...N.keys()].map(E=>t.useOccurrences.occurrence(E)?.correspondingSourceNodeId).filter(E=>E!==void 0)),ne=[...t.scripts.documentScripts,...t.scripts.elementScripts.filter(E=>E.parentSourceNodeId!==null&&!Z.has(E.parentSourceNodeId))].map(E=>({...E.script,customAttrs:E.script.customAttrs?{...E.script.customAttrs}:void 0}));ne.length>0&&(w.documentScripts=ne);let F=new Set((w.library??[]).map(E=>E.id)),j=new Set((w.clipMaskGroups??[]).map(E=>E.definitionId)),H=new Set;for(let E of t.paintServerDefinitions.candidates)(F.has(E.destinationId)||j.has(E.destinationId))&&H.add(E.sourceNodeId);for(let E of t.gradients.candidates)if(H.has(E.sourceNodeId))for(let z of E.templateSourceNodeIds)H.add(z);for(let E of t.patterns.candidates)if(H.has(E.sourceNodeId))for(let z of E.templateSourceNodeIds)H.add(z);let oe=new Set(t.symbolUses.definitions.map(E=>E.sourceNodeId));for(let E of oe)H.add(E);for(let E of t.markers.candidates)E.status==="materialized"&&H.add(E.sourceNodeId);let re=[...t.paintServerDefinitions.definitions(H)],xe=new Set(t.paintServerDefinitions.candidates.filter(E=>!H.has(E.sourceNodeId)).map(E=>E.sourceNodeId)),Ze=new Map,et=E=>{if(H.has(E)||oe.has(E))return;let z=t.paintServerDefinitions.definitionForSourceNode(E);z&&!re.some(B=>B.id===z.id)&&Ze.set(z.id,z)};for(let E of t.filters.bindings){if(E.status!=="materialized")continue;let z=t.resourceDependencies.edges.filter(B=>B.kind==="filter"&&B.propertyName==="filter"&&B.propertyValue===E.authoredValue&&(B.occurrenceId!==null&&B.occurrenceId===E.consumerOccurrenceId||B.occurrenceId===null&&B.fromSourceNodeId===E.consumerSourceNodeId));for(let B of t.resourceDependencies.closureFromEdges(z).materializations)B.role==="referenced-fragment"&&et(B.sourceNodeId)}let kt=(E,z)=>{let B=t.sourceDocument.index.parent(E);for(;B;){if(B.sourceNodeId===z)return!0;B=t.sourceDocument.index.parent(B.sourceNodeId)}return!1};for(let E of t.useOccurrences.sourceResolutions)E.status!=="resolved"||!E.targetSourceNodeId||[...xe].some(z=>kt(E.useSourceNodeId,z))&&et(E.targetSourceNodeId);let lt=[...re,...Ze.values()];lt.length>0&&(w.paintServerDefs=lt.map(E=>{let z=t.paintServerDefinitions.candidates.find(se=>se.definition.id===E.id)?.sourceNodeId,B=structuredClone(E);return z&&co(t,z)&&(B.markup=FO(B.markup)),B}));let Ve=ni(w);return Ve.errors.length>0?{value:null,diagnostics:Ve.errors.map(E=>MO(`${E.path}: ${E.message}`))}:{value:w,diagnostics:[]}}function VO(t,e){let n=t.sourceDocument.index.element(e.correspondingSourceNodeId),r=n?C(n,"id"):null;return{elementName:n?.name??"unknown",sourceNodeId:e.correspondingSourceNodeId,occurrenceId:e.occurrenceId,orderKey:[...e.orderKey],productIndex:e.productIndex,...r!==null?{authoredId:r}:{},...n?{elementOrder:n.elementOrder}:{},sourceOrder:n?.elementOrder??e.orderKey[0]??0}}function jO(t,e){let n={},r=(i,o)=>{o!==void 0&&(n[i]=structuredClone(o))};return t.documentMetadata&&Object.keys(t.documentMetadata).length>0&&r("documentMetadata",t.documentMetadata),((t.documentScripts?.length??0)>0||e==="svg-document-import")&&r("documentScripts",t.documentScripts??[]),((t.documentStyles?.length??0)>0||e==="svg-document-import")&&r("documentStyles",t.documentStyles??[]),(t.templateVariables?.length??0)>0&&r("templateVariables",t.templateVariables),(t.library?.length??0)>0&&r("library",t.library),(t.paintServerDefs?.length??0)>0&&r("paintServerDefs",t.paintServerDefs),t.animationTimeline&&r("animationTimeline",t.animationTimeline),t.colorGlyphLibrary&&Object.keys(t.colorGlyphLibrary).length>0&&r("colorGlyphLibrary",t.colorGlyphLibrary),n}function UO(t,e){let n=lx(t),r=new Map(n.map((d,u)=>[`svg-node-${u+1}`,d])),i=new Map(t.views.map((d,u)=>[`svg-view-${u+1}`,d])),o=new Map(e.sceneTree?.map(d=>[d.id,d])),s=e.shapes.filter(d=>d.state.isRootSvg!==!0),a=new Map(s.map(d=>[d.id,d])),c=d=>{let u=new Set,p=o.get(d)?.parentId??null;for(;p&&!a.has(p)&&!u.has(p);)u.add(p),p=o.get(p)?.parentId??null;return p&&a.has(p)?p:null},l=d=>{let u=[],p=new Set,f=c(d);for(;f&&a.has(f)&&!p.has(f);)p.add(f),u.unshift(f),f=c(f);return u};return s.map((d,u)=>{let p=r.get(d.id),f=i.get(d.id),m=f?t.sourceDocument.index.element(f.sourceNodeId):null,g=m?C(m,"id"):null,h=m?{elementName:m.name,sourceNodeId:m.sourceNodeId,...g!==null?{authoredId:g}:{},elementOrder:m.elementOrder,sourceOrder:m.elementOrder}:void 0;return{planNodeId:d.id,serialized:structuredClone(d),parentPlanNodeId:c(d.id),sourceOrder:u,groupPath:l(d.id),...p?{sourceElement:VO(t,p)}:h?{sourceElement:h}:{}}})}function HO(t,e){let n=new Map;for(let r of e){let i=r.sourceElement?.sourceNodeId;i&&!n.has(i)&&n.set(i,r.planNodeId)}return e.flatMap(r=>{let i=r.sourceElement?.sourceNodeId;return i?t.sourceDocument.index.referencesFrom(i).map(o=>({kind:o.attributeName?`${o.channel}:${o.attributeName}`:o.channel,fromPlanNodeId:r.planNodeId,...o.targetSourceNodeId?{targetSourceNodeId:o.targetSourceNodeId,toPlanNodeId:n.get(o.targetSourceNodeId)}:{},fromSourceNodeId:i,sourceId:r.sourceElement?.authoredId,targetSourceId:o.targetAuthoredId})):[]}).sort((r,i)=>r.fromPlanNodeId.localeCompare(i.fromPlanNodeId)||r.kind.localeCompare(i.kind)||(r.targetSourceId??"").localeCompare(i.targetSourceId??""))}function sx(t,e,n){return Da({planVersion:1,identityMode:"allocate",source:{kind:e.source??"svg",fingerprint:Oa(t)},intent:e.entrypoint??"svg-document-import",nodes:[],documentFields:{},referenceEdges:[],clipMaskGroups:[],diagnostics:[...n],externalEffects:[]})}function WO(t,e){let n=e.entrypoint??"svg-document-import";if(n!=="plugin-svg-fragment"&&n!=="pattern-fragment")return[];let r=e.source??"svg",i=[],o=new Set,s=(a,c,l)=>{o.has(a)||(o.add(a),i.push({severity:"warning",code:"unsupported-ingest-capability",source:r,entrypoint:n,capability:a,message:c,...l?{elementName:l}:{}}))};n==="plugin-svg-fragment"?((t.metadata.document.metadata.rawMetadata||t.metadata.candidates.some(c=>c.metadata.rawMetadata))&&s("metadata","Plugin SVG fragments preserve host document metadata.","metadata"),t.views.length>0&&s("views","Plugin SVG fragments do not alter document navigation views.","view")):(t.scripts.candidates.length>0&&s("scripts","Pattern fragments keep scripts inert and do not adopt them.","script"),t.animations.smil.length>0&&s("smil-animation","Pattern editing materializes static tile geometry and omits SMIL animation tracks.","animate"),t.animations.css.length>0&&s("css-animation","Pattern editing materializes static tile geometry and omits CSS animation tracks."),t.clipMasks.bindings.length>0&&s("clip-mask-membership","Pattern editing does not adopt document clip or mask membership.","clipPath"),t.embeddedFrames.length>0&&s("embedded-svg","Pattern editing flattens nested SVG content into the tile coordinate frame.","svg"));for(let a of t.externalEffects.effects)a.kind==="font-consent"?s("fonts",`${n} does not start an implicit external font consent flow.`):s("external-assets",`${n} does not fetch or convert external image assets.`,"image");return i}function gx(t,e={},n=[]){let r=Af(t,{entrypoint:e.entrypoint??"svg-document-import"});if(!r.value)return{value:null,diagnostics:Object.freeze([...n,...r.diagnostics])};let i=UO(t,r.value),o=WO(t,e),s={planVersion:1,identityMode:"allocate",source:{kind:e.source??"svg",fingerprint:Oa(t.sourceDocument.rawSource)},intent:e.entrypoint??"svg-document-import",nodes:i,documentFields:jO(r.value,e.entrypoint??"svg-document-import"),referenceEdges:HO(t,i),clipMaskGroups:structuredClone(r.value.clipMaskGroups??[]),rootFrame:structuredClone(t.rootFrame),diagnostics:[...n,...r.diagnostics,...o],externalEffects:[...structuredClone(t.externalEffects.effects)]};return{value:Da(s),diagnostics:s.diagnostics}}function KO(t,e={}){let n=Cc(t,e);if(!n.value)return sx(t,e,n.diagnostics);let r=gx(n.value,e,n.diagnostics);return r.value??sx(t,e,r.diagnostics)}var nl=class extends Error{diagnostics;constructor(e){let n=e.filter(r=>r.severity==="error").map(r=>r.message).join("; ");super(`SVG import failed${n?`: ${n}`:"."}`),this.name="SvgImportError",this.diagnostics=e}};function hx(t,e={}){let n=Cc(t,e);if(!n.value)return{value:null,diagnostics:n.diagnostics};let r=Af(n.value,e);return{value:r.value,diagnostics:Object.freeze([...n.diagnostics,...r.diagnostics])}}function Ef(t,e={}){let n=hx(t,e);if(!n.value||n.diagnostics.some(r=>r.severity==="error"))throw new nl(n.diagnostics);return n.value}var _=(t,e)=>({action:t,by:e});var It=t=>t,Ke="DocumentSerializer canonical snapshot restore",ze="policy-driven SVG plan materializer",_t="policy-driven clipboard plan materializer",Ce="policy-driven fragment plan materializer",At="SceneGraph hierarchy and source-order projection",zc={schemaVersion:It({"native-document-open":_("derived","parseDocument migration and schema stamping"),"full-snapshot-restore":_("derived","snapshot migration and schema stamping"),"svg-document-import":_("preserve-host",ze),"external-svg-paste":_("preserve-host",ze),"internal-clipboard-paste":_("preserve-host",_t),"plugin-svg-fragment":_("preserve-host",Ce),"pattern-fragment":_("preserve-host",Ce),"vectorized-svg-fragment":_("preserve-host",Ce)}),shapes:It({"native-document-open":_("replace",Ke),"full-snapshot-restore":_("replace",Ke),"svg-document-import":_("append",ze),"external-svg-paste":_("append",ze),"internal-clipboard-paste":_("append",_t),"plugin-svg-fragment":_("append",Ce),"pattern-fragment":_("append","fragment-scoped pattern materializer"),"vectorized-svg-fragment":_("append","path-only vectorized materializer")}),viewboxes:It({"native-document-open":_("derived",At),"full-snapshot-restore":_("derived",At),"svg-document-import":_("derived",At),"external-svg-paste":_("derived",At),"internal-clipboard-paste":_("derived",At),"plugin-svg-fragment":_("derived",At),"pattern-fragment":_("derived",At),"vectorized-svg-fragment":_("derived",At)}),guides:It({"native-document-open":_("replace",Ke),"full-snapshot-restore":_("replace",Ke),"svg-document-import":_("preserve-host",ze),"external-svg-paste":_("preserve-host",ze),"internal-clipboard-paste":_("preserve-host",_t),"plugin-svg-fragment":_("preserve-host",Ce),"pattern-fragment":_("preserve-host",Ce),"vectorized-svg-fragment":_("preserve-host",Ce)}),measurements:It({"native-document-open":_("replace",Ke),"full-snapshot-restore":_("replace",Ke),"svg-document-import":_("preserve-host",ze),"external-svg-paste":_("preserve-host",ze),"internal-clipboard-paste":_("preserve-host",_t),"plugin-svg-fragment":_("preserve-host",Ce),"pattern-fragment":_("preserve-host",Ce),"vectorized-svg-fragment":_("preserve-host",Ce)}),sceneTree:It({"native-document-open":_("derived",At),"full-snapshot-restore":_("derived",At),"svg-document-import":_("derived",At),"external-svg-paste":_("derived",At),"internal-clipboard-paste":_("derived",At),"plugin-svg-fragment":_("derived",At),"pattern-fragment":_("derived",At),"vectorized-svg-fragment":_("derived",At)}),clipMaskGroups:It({"native-document-open":_("replace",Ke),"full-snapshot-restore":_("replace",Ke),"svg-document-import":_("append",ze),"external-svg-paste":_("append",ze),"internal-clipboard-paste":_("append",_t),"plugin-svg-fragment":_("append",Ce),"pattern-fragment":_("preserve-host","fragment-scoped pattern materializer"),"vectorized-svg-fragment":_("preserve-host","path-only vectorized materializer")}),documentMetadata:It({"native-document-open":_("replace",Ke),"full-snapshot-restore":_("replace",Ke),"svg-document-import":_("replace",ze),"external-svg-paste":_("merge",ze),"internal-clipboard-paste":_("preserve-host",_t),"plugin-svg-fragment":_("preserve-host",Ce),"pattern-fragment":_("preserve-host",Ce),"vectorized-svg-fragment":_("preserve-host",Ce)}),documentScripts:It({"native-document-open":_("replace",Ke),"full-snapshot-restore":_("replace",Ke),"svg-document-import":_("replace",ze),"external-svg-paste":_("append",ze),"internal-clipboard-paste":_("append",_t),"plugin-svg-fragment":_("append",Ce),"pattern-fragment":_("preserve-host",Ce),"vectorized-svg-fragment":_("preserve-host",Ce)}),documentStyles:It({"native-document-open":_("replace",Ke),"full-snapshot-restore":_("replace",Ke),"svg-document-import":_("replace",ze),"external-svg-paste":_("merge",ze),"internal-clipboard-paste":_("append",_t),"plugin-svg-fragment":_("append",Ce),"pattern-fragment":_("preserve-host",Ce),"vectorized-svg-fragment":_("preserve-host",Ce)}),templateVariables:It({"native-document-open":_("replace",Ke),"full-snapshot-restore":_("replace",Ke),"svg-document-import":_("replace",ze),"external-svg-paste":_("merge",ze),"internal-clipboard-paste":_("append",_t),"plugin-svg-fragment":_("append",Ce),"pattern-fragment":_("preserve-host",Ce),"vectorized-svg-fragment":_("preserve-host",Ce)}),animationTimeline:It({"native-document-open":_("replace",Ke),"full-snapshot-restore":_("replace",Ke),"svg-document-import":_("append",ze),"external-svg-paste":_("append",ze),"internal-clipboard-paste":_("append",_t),"plugin-svg-fragment":_("append",Ce),"pattern-fragment":_("preserve-host",Ce),"vectorized-svg-fragment":_("preserve-host",Ce)}),library:It({"native-document-open":_("replace",Ke),"full-snapshot-restore":_("replace",Ke),"svg-document-import":_("append",ze),"external-svg-paste":_("append",ze),"internal-clipboard-paste":_("append",_t),"plugin-svg-fragment":_("append",Ce),"pattern-fragment":_("preserve-host","fragment-scoped pattern materializer"),"vectorized-svg-fragment":_("preserve-host","path-only vectorized materializer")}),paintServerDefs:It({"native-document-open":_("replace",Ke),"full-snapshot-restore":_("replace",Ke),"svg-document-import":_("append",ze),"external-svg-paste":_("append",ze),"internal-clipboard-paste":_("append",_t),"plugin-svg-fragment":_("append",Ce),"pattern-fragment":_("preserve-host","fragment-scoped pattern materializer"),"vectorized-svg-fragment":_("preserve-host","path-only vectorized materializer")}),colorGlyphLibrary:It({"native-document-open":_("replace",Ke),"full-snapshot-restore":_("replace",Ke),"svg-document-import":_("preserve-host",ze),"external-svg-paste":_("preserve-host",ze),"internal-clipboard-paste":_("preserve-host",_t),"plugin-svg-fragment":_("preserve-host",Ce),"pattern-fragment":_("preserve-host",Ce),"vectorized-svg-fragment":_("preserve-host",Ce)}),exportItems:It({"native-document-open":_("replace",Ke),"full-snapshot-restore":_("replace",Ke),"svg-document-import":_("preserve-host",ze),"external-svg-paste":_("preserve-host",ze),"internal-clipboard-paste":_("preserve-host",_t),"plugin-svg-fragment":_("preserve-host",Ce),"pattern-fragment":_("preserve-host",Ce),"vectorized-svg-fragment":_("preserve-host",Ce)}),unknownFields:It({"native-document-open":_("replace","forward-compatible quarantine restore"),"full-snapshot-restore":_("replace","forward-compatible quarantine restore"),"svg-document-import":_("preserve-host",ze),"external-svg-paste":_("preserve-host",ze),"internal-clipboard-paste":_("preserve-host",_t),"plugin-svg-fragment":_("preserve-host",Ce),"pattern-fragment":_("preserve-host",Ce),"vectorized-svg-fragment":_("preserve-host",Ce)})};function La(t,e){return zc[t][e]}function fv(t=Eo,e=zc){let n=Object.keys($t);if(n.length===0)throw new Error("Document field roster must not be empty.");if(t.length===0)throw new Error("Ingress intent roster must not be empty.");if(new Set(t).size!==t.length)throw new Error("Ingress intent roster contains duplicate entries.");let r=Object.keys(e);for(let i of n)if(!e[i])throw new Error(`Document field ${i} lacks an ingress matrix.`);for(let i of r)if(!Object.hasOwn($t,i))throw new Error(`Unknown document field ${i} has an ingress matrix.`);for(let i of n){let o=e[i];for(let s of t){let a=o[s];if(!a)throw new Error(`Document field ${i} lacks intent ${s}.`);if((a.action==="exempt"?a.reason:a.by).trim().length<12)throw new Error(`Ingress policy ${s} lacks a substantive owner or reason.`)}for(let s of Object.keys(o))if(!t.includes(s))throw new Error(`Document field ${i} has unknown intent ${s}.`)}}var PM=["renderToSvg","codegen","dxf","mermaid","pdf","editor-dom"],$t={schemaVersion:{serialization:{kind:"verbatim"},precision:"opaque",required:!1,collab:{exempt:"Format version of the document envelope, not content. The reducer never rewrites it; it is stamped by the serializer and consumed by migrateSnapshot."},rendered:{renderToSvg:{exempt:"Format-envelope version consumed by migrateSnapshot before renderToSvg sees the snapshot; it has no output representation."},codegen:{exempt:"Format-envelope version consumed while normalizing codegen input; it is not content in an embeddable component."},dxf:{exempt:"Format-envelope version is consumed before the editor constructs DXF shape inputs and has no DXF entity representation."},mermaid:{exempt:"Format-envelope version is consumed before Mermaid receives shapes and has no graph-syntax representation."},pdf:{exempt:"Format-envelope version is consumed during document migration before the PDF export surface receives its SVG page input."},"editor-dom":{exempt:"Format-envelope version is consumed during document migration before the live editor DOM is projected."}}},shapes:{serialization:{kind:"shape-array"},precision:"shape-trees",required:!0,collab:{ops:["shape:add","shape:update","shape:remove","text:format"]},rendered:{renderToSvg:{by:"svg-renderer main loop via renderShape; motionOnly shapes become origin-normalized <path> defs for <mpath>"},codegen:{by:"buildRenderPlan supplies the normalized visible-shape entries and defs consumed by every component backend"},dxf:{by:"apps/editor/src/export/dxf-exporter.ts converts supported geometry and accounts for unsupported shape inputs"},mermaid:{by:"apps/editor/src/export/mermaid-exporter.ts maps flowchart nodes and connectors into graph syntax with skip accounting"},pdf:{by:"ExportPanel.generatePdfBlob converts rendered SVG shape markup through svg2pdf and warns before unsupported textPath expansion"},"editor-dom":{by:"SceneGraph and scene-graph-dom-projector drive registered Shape renderers for the live canvas projection"}}},viewboxes:{serialization:{kind:"id-sorted-array"},precision:"numeric-leaves",required:!0,collab:{exempt:"DERIVED, not stored. `DocumentRootManager.getViewboxes()` projects it from the `<view>` shapes on every read, and the editor host installs no-op setters after View unification. Editing a view is a `shape:update`, which is on the wire; the array regenerates from the shapes on the next serialize."},rendered:{renderToSvg:{by:"viewboxes[0] drives the root width, height, and viewBox in svg-renderer sizing"},codegen:{by:"buildRenderPlan.frame supplies the shared width, height, and viewBox used by every component backend"},dxf:{exempt:"DXF writes model-space geometry and unit metadata, not an SVG viewport or page framing rectangle."},mermaid:{exempt:"Mermaid computes graph layout from topology and has no authored viewport or viewBox capability."},pdf:{by:"ExportPanel PDF page generation uses the selected source bounds and page settings to establish the PDF frame and placement"},"editor-dom":{by:"DocumentRootManager projects view shapes and the active view onto the live root SVG viewport"}}},guides:{serialization:{kind:"id-sorted-array"},precision:"numeric-leaves",required:!1,collab:{ops:["guides:set","guide:upsert","guide:remove","guide:move"]},rendered:{renderToSvg:{exempt:"Editor authoring chrome (alignment guides); SVG document output has no representation for them by design."},codegen:{exempt:"Alignment guides are editor authoring chrome and do not belong in an embeddable generated component."},dxf:{exempt:"Alignment guides are editor authoring chrome rather than drawing geometry and do not become DXF entities."},mermaid:{exempt:"Alignment guides are editor authoring chrome rather than graph nodes or edges and do not enter Mermaid syntax."},pdf:{exempt:"Alignment guides are editor authoring chrome and are excluded from the rendered SVG page supplied to PDF conversion."},"editor-dom":{by:"GuideManager projects persisted guides into the editor authoring overlay"}}},measurements:{serialization:{kind:"id-sorted-array"},precision:"numeric-leaves",required:!1,collab:{ops:["measurements:set","measurement:upsert","measurement:remove","measurement:move"]},rendered:{renderToSvg:{exempt:"Editor measurement chrome has no SVG document representation; the editor SVG export omits it by design."},codegen:{exempt:"Measurements are editor authoring chrome and do not belong in an embeddable generated component."},dxf:{exempt:"Editor measurement annotations are not drawing geometry and do not become DXF entities in this exporter."},mermaid:{exempt:"Editor measurement annotations are not graph nodes or edges and do not enter Mermaid syntax."},pdf:{exempt:"Editor measurement annotations are authoring chrome and are excluded from the rendered SVG page supplied to PDF conversion."},"editor-dom":{by:"MeasureManager projects persisted measurements into the editor authoring overlay"}}},sceneTree:{serialization:{kind:"id-sorted-array"},precision:"opaque",required:!1,collab:{ops:["scene:move","scene:place"]},rendered:{renderToSvg:{exempt:"Structure authority whose render projection is inline state.children; renderToSvg consumes that projection instead of the tree."},codegen:{exempt:"Component backends consume buildRenderPlan over inline state.children, the canonical render projection of sceneTree."},dxf:{exempt:"DXF receives shape trees whose inline children are the render projection; it does not replay sceneTree independently."},mermaid:{exempt:"Mermaid receives serialized shapes and connector references rather than replaying the editor sceneTree."},pdf:{exempt:"PDF receives the rendered SVG hierarchy produced from inline children and does not independently replay sceneTree placements."},"editor-dom":{by:"SceneGraph structure and scene-graph-dom-projector reconcile sceneTree placements into the live DOM hierarchy"}}},clipMaskGroups:{serialization:{kind:"id-sorted-array"},precision:"opaque",required:!1,collab:{ops:["clipMask:upsert","clipMask:remove"]},rendered:{renderToSvg:{by:"renderer/clip-mask-defs.ts emits clipPath and mask defs plus content wrapping while suppressing clip shapes from the visible tree"},codegen:{by:"buildRenderPlan clip-mask runs and defs are consumed by every component backend without re-deriving membership"},dxf:{exempt:"DXF is a geometry exchange target with no SVG clipPath or mask model; shape conversion operates on authored geometry."},mermaid:{exempt:"Mermaid graph syntax has no clipping or masking vocabulary; export is defined over flowchart topology and labels."},pdf:{by:"The rendered SVG page carries reachable clipPath and mask definitions into the svg2pdf conversion boundary"},"editor-dom":{by:"ClipMaskManager and ClipMaskHandler project definitions and content wrappers into the live canvas DOM"}}},documentMetadata:{serialization:{kind:"deep-sorted-object"},precision:"opaque",required:!1,collab:{ops:["metadata:set","metadata:patch"]},rendered:{renderToSvg:{by:"renderer/document-metadata.ts emits xml:lang on the root plus title, description, metadata, and raw HTML metadata as first children"},codegen:{exempt:"Embeddable component backends omit document-artifact identity because the host application owns title, description, and RDF metadata."},dxf:{exempt:"The DXF exporter writes drawing entities and units only; SVG document identity metadata is outside its interchange contract."},mermaid:{exempt:"Mermaid export represents graph topology and labels; SVG document identity metadata has no graph-syntax equivalent."},pdf:{exempt:"SVG title, description, and RDF blocks are not mapped to PDF document information by the current export workflow."},"editor-dom":{by:"DocumentMetadataManager owns metadata and projects language and descriptive elements onto the live document DOM"}}},documentScripts:{serialization:{kind:"ordered-array"},precision:"opaque",required:!1,collab:{ops:["documentScripts:set","documentScript:upsert","documentScript:remove"]},rendered:{renderToSvg:{by:"renderer/document-scripts.ts emits script elements at the end of the SVG when RenderOptions.includeScripts is enabled"},codegen:{exempt:"Embeddable component backends never inject authored executable scripts; behavior in the host application belongs to consumer code."},dxf:{exempt:"DXF drawing output cannot carry executable SVG document scripts and the exporter never evaluates them."},mermaid:{exempt:"Mermaid graph output cannot carry executable SVG document scripts and the exporter never evaluates them."},pdf:{exempt:"PDF conversion never executes or embeds authored SVG scripts; executable document behavior is outside the static export contract."},"editor-dom":{exempt:"DocumentScriptManager keeps scripts inert and never inserts them into the live SVG because dynamically appended script elements execute."}}},documentStyles:{serialization:{kind:"ordered-array"},precision:"opaque",required:!1,collab:{ops:["documentStyles:set","documentStyle:upsert","documentStyle:remove"]},rendered:{renderToSvg:{by:"renderer/document-styles.ts emits style elements as last children with animation declarations stripped because SMIL owns playback"},codegen:{by:"buildRenderPlan.documentStyles supplies normalized style markup to every component backend"},dxf:{exempt:"CSS rules style SVG presentation rather than DXF geometry entities and are outside the DXF export contract."},mermaid:{exempt:"Authored SVG CSS cannot be represented in Mermaid graph syntax; Mermaid styling is generated from its own vocabulary."},pdf:{by:"The rendered SVG page carries authored style elements and computed presentation into the svg2pdf conversion boundary"},"editor-dom":{by:"DocumentStylesManager projects ordered authored styles into the live SVG and keeps the cascade synchronized"}}},templateVariables:{serialization:{kind:"ordered-array"},precision:"opaque",required:!1,collab:{ops:["templateVariables:set","templateVariable:upsert","templateVariable:remove"]},rendered:{renderToSvg:{exempt:"Template variables are substituted upstream by CLI, Action, and SDK entry points; in-renderer substitution would double-apply them."},codegen:{exempt:"Template variables are substituted while normalizing the codegen document input, before any component backend receives a plan."},dxf:{exempt:"Template variables are document-input preprocessing; the DXF exporter receives already-materialized live shape values."},mermaid:{exempt:"Template variables are document-input preprocessing; the Mermaid exporter receives already-materialized labels and references."},pdf:{exempt:"Template variables are resolved before the editor renders the SVG page that is supplied to PDF conversion."},"editor-dom":{by:"VariableManager resolves template variables and maintains their safe live style projection for shape renderers"}}},animationTimeline:{serialization:{kind:"deep-sorted-object"},precision:"animation-timeline",required:!1,collab:{ops:["animation:set","animation:config","animation:clear","animationTrack:upsert","animationTrack:remove","animationKeyframe:upsert","animationKeyframe:remove"]},rendered:{renderToSvg:{by:"renderAnimationElements injects SMIL children per target shape through smil-kernel"},codegen:{by:"buildRenderPlan attaches the same SMIL children to shape markup consumed by every component backend"},dxf:{exempt:"DXF output is a static geometry snapshot and has no SVG SMIL timeline representation in the supported file version."},mermaid:{exempt:"Mermaid export is a static graph description and has no SVG SMIL timeline representation."},pdf:{exempt:"PDF output is a static page snapshot and has no time-based SMIL timeline representation in the export contract."},"editor-dom":{by:"AnimationManager composes ephemeral overlays and the SMIL export kernel projects authored timelines for document output"}}},library:{serialization:{kind:"id-sorted-array"},precision:"shape-trees",required:!1,collab:{ops:["library:set","library:upsert","library:remove"]},rendered:{renderToSvg:{by:"renderLibraryDefs emits reference-filtered gradients, patterns, filters, markers, and symbols into defs"},codegen:{by:"buildRenderPlan library-def channels are emitted by every component backend with shared reference reachability"},dxf:{exempt:"The DXF exporter converts flattened shape geometry and text; SVG visual library definitions have no entity equivalent."},mermaid:{exempt:"Mermaid represents graph nodes and connectors, not reusable SVG paint, filter, marker, or symbol definitions."},pdf:{by:"The rendered SVG page carries reachable library definitions and their references into the svg2pdf conversion boundary"},"editor-dom":{by:"LibraryRegistry plus gradient, filter, marker, pattern, and symbol managers project reachable definitions into live defs"}}},paintServerDefs:{serialization:{kind:"id-sorted-array"},precision:"opaque",required:!1,collab:{ops:["paintServerDefs:set","paintServerDef:upsert","paintServerDef:remove"]},rendered:{renderToSvg:{by:"renderer/paint-server-defs.ts emits verbatim markup in defs when transitively referenced or marked passthrough"},codegen:{by:"buildRenderPlan paint-server channels carry reachable typed definitions to every component backend"},dxf:{exempt:"Typed SVG paint-server definitions have no DXF entity representation; the exporter operates on shape geometry."},mermaid:{exempt:"Typed SVG paint-server definitions have no Mermaid syntax representation; export operates on graph topology and labels."},pdf:{by:"The rendered SVG page carries reachable typed paint-server definitions into the svg2pdf conversion boundary"},"editor-dom":{by:"PaintServerDef state and definition managers project reachable typed definition markup into live defs"}}},colorGlyphLibrary:{serialization:{kind:"deep-sorted-object"},precision:"opaque",required:!1,collab:{ops:["colorGlyphLibrary:set"]},rendered:{renderToSvg:{exempt:"Font-foundry assets are consumed when emitting an OpenType font binary and have no SVG document representation."},codegen:{exempt:"Font-foundry assets do not belong in embeddable SVG components; generated code references ordinary text and font resources."},dxf:{exempt:"Font-foundry color-glyph assets have no DXF entity representation in the geometry and MTEXT exporter."},mermaid:{exempt:"Font-foundry color-glyph assets have no Mermaid graph-syntax representation and are not graph content."},pdf:{exempt:"Color-glyph source assets back font generation rather than PDF page conversion; rendered text uses the resolved font face."},"editor-dom":{exempt:"Color glyph assets back font-binary generation rather than the editor DOM; text rendering uses the resolved font face."}}},exportItems:{serialization:{kind:"ordered-array"},precision:"opaque",required:!1,collab:{ops:["exportItems:set","exportItem:upsert","exportItem:remove"]},rendered:{renderToSvg:{exempt:"Export profiles are instructions about filenames, formats, and settings, not renderable SVG document content."},codegen:{exempt:"Export profiles configure how code generation is invoked and are not content emitted into a generated component."},dxf:{exempt:"Export profiles configure the editor export workflow; the selected DXF profile is input to invocation, not a DXF entity."},mermaid:{exempt:"Export profiles configure the editor export workflow and are not nodes, connectors, or directives in Mermaid output."},pdf:{exempt:"The selected export profile configures PDF invocation and page settings; it is not content embedded in the PDF page."},"editor-dom":{exempt:"Export profiles configure the export workflow and are intentionally not projected into the live canvas SVG."}}},unknownFields:{serialization:{kind:"unknown-bag"},precision:"opaque",required:!1,collab:{exempt:"Forward-compat quarantine from newer writers; has no ops by definition \u2014 a current client cannot edit a field it does not understand, the DocumentRoom stores raw JSON so the bag rides the seed snapshot, and future clients (the only writers of these fields) carry real ops for them."},rendered:{renderToSvg:{exempt:"Contents are by definition not understood by this build; preservation is pass-through only and rendering them would be a guess."},codegen:{exempt:"Contents are by definition not understood by this build; component generation preserves rather than interprets unknown fields."},dxf:{exempt:"Contents are by definition not understood by this build; DXF conversion cannot safely infer geometry from unknown fields."},mermaid:{exempt:"Contents are by definition not understood by this build; Mermaid export cannot safely infer graph semantics from them."},pdf:{exempt:"Contents are by definition not understood by this build; PDF conversion cannot safely invent a page representation for them."},"editor-dom":{exempt:"Contents are by definition not understood by this build; the editor preserves them without inventing a DOM projection."}}}},sf=["schemaVersion","documentMetadata","documentScripts","documentStyles","templateVariables","exportItems","viewboxes","guides","measurements","sceneTree","clipMaskGroups","library","colorGlyphLibrary","paintServerDefs","animationTimeline","unknownFields","shapes"],TM=["id","type","state"];function Mf(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function us(t){let e=t,n=e.unknownFields;if(!Mf(n))return delete e.unknownFields,t;for(let[r,i]of Object.entries(n))r!=="unknownFields"&&(r in e||(e[r]=i));return delete e.unknownFields,t}function ps(t){let e=t,n=Mf(e.unknownFields)?e.unknownFields:void 0;for(let r of Object.keys(e)){if(r==="unknownFields"||r in $t)continue;let i=e[r];delete e[r],i!==void 0&&((n??={})[r]=i)}return n&&Object.keys(n).length>0?e.unknownFields=n:delete e.unknownFields,t}function af(t){let e=t,n,r=e.unknownFields;if(Mf(r))for(let[i,o]of Object.entries(r))i==="unknownFields"||i in $t||o===void 0||((n??={})[i]=o);for(let i of Object.keys(e)){if(i==="unknownFields"||i in $t)continue;let o=e[i];o!==void 0&&((n??={})[i]=o)}return n}var XO=["migration","validation","normalization","canonical-node-construction","document-section-staging"];function yx(t,e,n,r,i){e.set(t.id,t),n.push({id:t.id,parentId:r,index:i});let o=t.state.children;Array.isArray(o)&&o.forEach((s,a)=>yx(s,e,n,t.id,a))}function YO(t,e){let n=new Map,r=[];t.shapes.forEach((l,d)=>yx(l,n,r,null,d));let i=new Map(r.map(l=>[l.id,l])),o=new Set,s=[];for(let l of t.sceneTree??[])o.has(l.id)||(o.add(l.id),s.push(structuredClone(l)));for(let l of r)o.has(l.id)||(o.add(l.id),s.push(structuredClone(l)));let a=new Set(s.map(l=>l.id)),c=new Map;for(let l of s){let d=i.get(l.id),u=e||l.parentId===null||a.has(l.parentId)?l.parentId:d?.parentId??null,p=c.get(u)??[];p.push({...l,parentId:u}),c.set(u,p)}t.sceneTree=[...c.values()].flatMap(l=>mt(l).map((d,u)=>{let p={...d,index:u};return p.orderKey===void 0&&delete p.orderKey,p.updatedAt===void 0&&delete p.updatedAt,p.clientId===void 0&&delete p.clientId,p}))}function qO(t,e){if(!e.has(t))return t;let n=2;for(;e.has(`${t}-${n}`);)n++;return`${t}-${n}`}function ZO(t,e){if(e===!1||t.shapes.find(u=>u.type==="svg"&&u.state.isRootSvg===!0))return;let r=new Set((t.sceneTree??[]).filter(u=>u.parentId===null).map(u=>u.id)),i=(t.sceneTree?.length??0)>0;if(t.shapes.some(u=>u.type==="svg"&&u.state.isRootSvg!==!0&&(!i||r.has(u.id))))return;let s=e?.width??800,a=e?.height??600,c=new Set,l=u=>{for(let p of u){c.add(p.id);let f=p.state.children;Array.isArray(f)&&l(f)}};l(t.shapes);let d=qO(e?.idBase??"document-root",c);t.shapes.unshift({id:d,type:"svg",state:{isRootSvg:!0,svgWidth:s,svgHeight:a,svgViewBoxX:0,svgViewBoxY:0,svgViewBoxWidth:s,svgViewBoxHeight:a,svgPreserveAspectRatio:"xMidYMid meet"}}),t.sceneTree&&t.sceneTree.length>0&&(t.sceneTree=[{id:d,parentId:null,index:0},...t.sceneTree.map(u=>u.parentId===null?{...u,index:u.index+1}:u)])}function JO(t){let e=new Set,n=r=>{let i=r.state.children;if(Array.isArray(i))for(let o of i)e.add(o.id),n(o)};t.shapes.forEach(n),t.shapes=t.shapes.filter(r=>!e.has(r.id))}function Sx(t,e){YO(t,e.preserveUnresolvedParents),e.materializeClipMaskStructure&&lr(t),Ii(t),JO(t)}function QO(t){let e=structuredClone(t);return Sx(e,{materializeClipMaskStructure:!1,preserveUnresolvedParents:!0}),e}function eD(t){let e=new Map,n=r=>{if(e.has(r.id))return;e.set(r.id,r);let i=r.state.children;Array.isArray(i)&&i.forEach(n)};return t.forEach(n),e}var tD=/^structural:(clip|mask):(.+):(group|path|content)$/;function nD(t,e,n,r){let i=new zr,o=eD(t.shapes);for(let s of o.values()){let a=e===null||e.has(s.type),c=structuredClone(s);a&&c.state.children&&delete c.state.children;let l=rn.fromSerialized(c);a||(l.preserveSerializedState(s.state),r.push(s.id),n.push({severity:"warning",code:"unavailable-shape-descriptor",source:"native-document",entrypoint:"full-snapshot-restore",message:`No shape descriptor is available for ${s.type}.`,documentPath:`shapes.${s.id}`,shapeId:s.id})),i.addNode(l)}for(let s of t.sceneTree??[]){if(i.getNode(s.id))continue;let a=tD.exec(s.id);if(!a)continue;let[,c,l,d]=a,u=t.clipMaskGroups?.find(f=>f.type===c&&f.id===l),p={structural:!0};d==="group"&&u&&(p.clipMaskDefId=Ot(u)),i.addNode(rn.fromSerialized({id:s.id,type:`${c}-${d}-structure`,state:p}))}for(let s of t.sceneTree??[])i.getNode(s.id)&&i.moveNodeToParentId(s.id,s.parentId,s.index);return i.clearAllDirty(),i}function rD(t,e={}){let n=null,r=null;try{let i=structuredClone(t);i=us(i),i=ls(i),e.injectFault?.("migration"),i=ps(i),ds(i,"full-snapshot-restore",{includeWarnings:!1}),cs(i),ZO(i,e.rootFrame),Sx(i,{materializeClipMaskStructure:!0,preserveUnresolvedParents:!1});let o=ds(i,"full-snapshot-restore").filter(l=>l.code!=="unavailable-shape-descriptor");e.injectFault?.("validation"),e.injectFault?.("normalization");let s=[],a=e.availableShapeTypes?new Set(e.availableShapeTypes):null;n=nD(i,a,o,s),e.injectFault?.("canonical-node-construction"),r=new Br(n),r.loadSections(i),e.injectFault?.("document-section-staging");let c=wi.own(r,e.identity);return c.assertCoherent(),{document:c,snapshot:structuredClone(i),diagnostics:Object.freeze(structuredClone(o)),unavailableNodeIds:Object.freeze([...s])}}catch(i){throw r?r.dispose():n?.dispose(),i}}function bx(t){return t.easing==="custom-bezier"&&t.customBezier?t.customBezier:ui[t.easing]??null}function vx(t,e,n,r,i){if(t===e&&n===r)return i;let o=1e-6,s=8,a=f=>(((1-3*n+3*t)*f+(3*n-6*t))*f+3*t)*f,c=f=>(((1-3*r+3*e)*f+(3*r-6*e))*f+3*e)*f,l=f=>(3*(1-3*n+3*t)*f+2*(3*n-6*t))*f+3*t,d=i;for(let f=0;f<s;f++){let m=a(d)-i;if(Math.abs(m)<o)return c(d);let g=l(d);if(Math.abs(g)<o)break;d-=m/g}let u=0,p=1;for(d=i;u<p;){let f=a(d);if(Math.abs(f-i)<o)return c(d);i>f?u=d:p=d;let m=(p-u)*.5+u;if(m===d)break;d=m}return c(d)}function il(t){let e=t.split(/\s+/).map(parseFloat);if(e.length!==4||e.some(s=>!Number.isFinite(s)))return t;let[n,r,i,o]=e;return`${1-i} ${1-o} ${1-n} ${1-r}`}function Et(t){return!Number.isFinite(t)||Math.abs(t)<1e-9?"0":Math.abs(t-1)<1e-9?"1":parseFloat(t.toFixed(6)).toString()}function Of([t,e,n,r]){let i=o=>Number.isFinite(o)?parseFloat(o.toFixed(6)).toString():"0";return`${i(t)} ${i(e)} ${i(n)} ${i(r)}`}function xx(t){return t.length>0&&t.every(e=>e==="0 0 1 1")}function ol(t){if(t.length<2)return!1;let e=t.length-1,n=1e-4;for(let r=0;r<t.length;r++){let i=r/e,o=parseFloat(t[r]);if(!Number.isFinite(o)||Math.abs(o-i)>n)return!1}return!0}function Df(t){if(t.length<2)return!1;let e=t.length-1,n=1e-4;for(let r=0;r<t.length;r++)if(Math.abs(t[r]-r/e)>n)return!1;return!0}function Er(t){let e=t.cycleDuration??(t.keyframes.length>0?t.keyframes[t.keyframes.length-1].time:0);return t.cycleBehavior==="alternate"||t.cycleBehavior==="alternate-reverse"?e*2:e}function lo(t){let e=t.beginTrigger;if(e)switch(e.type){case"time":{let r=parseFloat(e.value);return Number.isNaN(r)?"":Number.isFinite(r)?r!==0?`${r}s`:"":"indefinite"}case"event":return e.value;case"expression":return"";default:break}let n=t.keyframes[0]?.time??0;return n!==0?`${n}s`:""}function sl(t){return t.keyframes.length===1&&t.cycleDuration===void 0}function al(t){return t.calcMode!=="discrete"?!1:t.sourceSmilElement==="set"?!0:!t.sourceSmilElement&&!t.cycleInfinite&&t.keyframes.every(e=>e.easing!=="steps")}function zf(t,e){if(e<=0)return lo(t);if(lo(t)==="indefinite")return"indefinite";let n=t.keyframes[e]?.time??0;return n!==0?`${n}s`:""}function _f(t){if(t.cycleInfinite)return"indefinite";let e=t.cycleRepeats??1,n=t.cycleBehavior==="alternate"||t.cycleBehavior==="alternate-reverse"?e/2:e;return n===1?null:String(n)}function ci(t){return t.cycleInfinite||t.fill==="remove"?null:"freeze"}function cl(t){return t.additive==="sum"?"sum":null}function Ff(t){return t.keyframes.map(e=>{let n=typeof e.value=="number"?e.value:parseFloat(String(e.value));return Number.isFinite(n)?Math.max(0,Math.min(1,n)):0})}function iD(t){let e=n=>Math.max(0,Math.min(1,n));return[t[0],e(t[1]),t[2],e(t[3])]}function oD(t){let[e,n,r,i]=t,o=new Set,s=8;for(let u=1;u<=s;u++)o.add(u/s);let a=n-2*i+1,c=2*(i-2*n),l=n,d=u=>{if(!Number.isFinite(u)||u<=0||u>=1)return;let p=3*(1-u)**2*u*e+3*(1-u)*u**2*r+u**3;p>0&&p<1&&o.add(Number(p.toFixed(6)))};if(Math.abs(a)<1e-9)Math.abs(c)>=1e-9&&d(-l/c);else{let u=c*c-4*a*l;if(u>=0){let p=Math.sqrt(u);d((-c+p)/(2*a)),d((-c-p)/(2*a))}}return[...o].sort((u,p)=>u-p)}function sD(t,e,n,r,i,o){let s=typeof t.value=="number"&&typeof e.value=="number",a=Ar(e.value);if(e.easing==="linear-function"&&e.linearPoints&&e.linearPoints.length>=2){if(s){let h=e.linearPoints;for(let y=1;y<h.length;y++){let b=h[y],v=t.time+(e.time-t.time)*b.position,I=t.value+(e.value-t.value)*b.value;r.push(I),i.push(Et(n(v))),o.push("0 0 1 1")}return}r.push(a),i.push(Et(n(e.time))),o.push("0 0 1 1");return}if(e.easing==="steps"){r.push(a),i.push(Et(n(e.time))),o.push("0 0 1 1");return}let c=bx(e);if(!c){r.push(a),i.push(Et(n(e.time))),o.push("0 0 1 1");return}let[,l,,d]=c;if(!(l<0||l>1||d<0||d>1)){r.push(a),i.push(Et(n(e.time))),o.push(Of(c));return}if(!s){r.push(a),i.push(Et(n(e.time))),o.push(Of(iD(c)));return}let p=oD(c),f=t.value,m=e.value,g=e.time-t.time;for(let h of p){let y=vx(c[0],c[1],c[2],c[3],h),b=t.time+g*h,v=f+(m-f)*y;r.push(v),i.push(Et(n(b))),o.push("0 0 1 1")}}function Ar(t){return Array.isArray(t)?t.join(" "):t}function aD(t,e,n){let r=[],{count:i,position:o}=n,s=e.time-t.time,a=Ar(t.value),c=Ar(e.value),l=typeof a=="number"&&typeof c=="number",d=typeof a=="string"&&typeof c=="string",u=m=>d?m<.5?a:c:l?a+(c-a)*m:m>=1?c:a,p=m=>{let g=Math.floor(m*i);(o==="jump-start"||o==="jump-both")&&(g+=1);let h;switch(o){case"jump-start":case"jump-end":h=i;break;case"jump-none":h=i-1;break;case"jump-both":h=i+1;break}return g>h&&(g=h),g<0&&(g=0),g/h},f=p(0);for(let m=1;m<=i;m++){let g=m/i,h=p(g);if(h===f)continue;let y=t.time+g*s;r.push({value:u(h),time:y}),f=h}return r.length===0||r[r.length-1].time<e.time?r.push({value:c,time:e.time}):r[r.length-1]={value:c,time:e.time},r}function cD(t,e){let n=[],r=[],i=(o,s)=>{n.push(o),r.push(Et(e(s)))};i(Ar(t[0].value),t[0].time);for(let o=1;o<t.length;o++){let s=t[o-1],a=t[o];if(a.easing==="steps"&&a.stepsParams){let c=aD(s,a,a.stepsParams);for(let l of c)i(l.value,l.time)}else i(Ar(a.value),a.time)}return{values:n,keyTimes:r}}function lD(t,e,n){return{values:t.slice().reverse(),keyTimes:e.slice().reverse().map(r=>Et(1-parseFloat(r))),keySplines:n.slice().reverse().map(il)}}function rl(t,e,n,r,i){let o=i.cycleBehavior??"restart";if(o==="restart"||t.length<2)return{values:t,keyTimes:e,keySplines:n,calcMode:r};if(o==="reverse")return{...lD(t,e,n),calcMode:r};if(o==="alternate-reverse"){let l=t.slice().reverse(),d=e.slice().reverse().map(p=>Et(.5-parseFloat(p))),u=n.slice().reverse().map(il);return{values:[...l,...t.slice(1)],keyTimes:[...d,...e.slice(1).map(p=>Et(.5+parseFloat(p)))],keySplines:[...u,...n],calcMode:r}}let s=t.slice(0,-1).reverse(),a=e.slice(0,-1).reverse().map(l=>Et(1-parseFloat(l))),c=n.slice().reverse().map(il);return{values:[...t,...s],keyTimes:[...e,...a],keySplines:[...n,...c],calcMode:r}}function Mr(t){let e=t.keyframes;if(e.length===0)return{values:[],keyTimes:[],keySplines:[],calcMode:"spline"};let n=Er(t),r=e[0]?.time??0,i=l=>n>0?(l-r)/n:0;if(e.some(l=>l.easing==="steps")){let{values:l,keyTimes:d}=cD(e,i);return rl(l,d,[],"discrete",t)}if(t.calcMode==="discrete"){let l=e.map(u=>Ar(u.value)),d=e.map(u=>Et(i(u.time)));return rl(l,d,[],"discrete",t)}if(t.calcMode==="paced"){let l=e.map(u=>Ar(u.value)),d=e.map(u=>Et(i(u.time)));return rl(l,d,[],"paced",t)}let s=[Ar(e[0].value)],a=[Et(i(e[0].time))],c=[];for(let l=1;l<e.length;l++)sD(e[l-1],e[l],i,s,a,c);return rl(s,a,c,"spline",t)}function ll(t,e={}){let n=e.defaultCalcMode??"linear",r={};if(t.calcMode==="paced")return n!=="paced"&&(r.calcMode="paced"),r;if(t.calcMode==="discrete")return r.keyTimes=t.keyTimes.join(";"),r.calcMode="discrete",r;let i=t.keySplines.length>0&&!xx(t.keySplines);return ol(t.keyTimes)||(r.keyTimes=t.keyTimes.join(";")),i&&(r.calcMode="spline",r.keySplines=t.keySplines.join(";")),r}function Ix(t,e){if(t.shapeId!==e.shapeId||t.keyframes.length!==e.keyframes.length||(t.cycleDuration??-1)!==(e.cycleDuration??-1)||(t.cycleRepeats??1)!==(e.cycleRepeats??1)||!!t.cycleInfinite!=!!e.cycleInfinite||(t.cycleBehavior??"restart")!==(e.cycleBehavior??"restart")||(t.additive??"replace")!==(e.additive??"replace")||(t.calcMode??"linear")!==(e.calcMode??"linear")||!!t.locked!=!!e.locked)return!1;let n=(r,i)=>!r&&!i||!!r&&!!i&&r.type===i.type&&r.value===i.value;if(!n(t.beginTrigger,e.beginTrigger)||!n(t.endTrigger,e.endTrigger))return!1;for(let r=0;r<t.keyframes.length;r++){let i=t.keyframes[r],o=e.keyframes[r];if(i.time!==o.time||i.easing!==o.easing)return!1;let s=i.customBezier,a=o.customBezier;if(!!s!=!!a)return!1;if(s&&a){for(let c=0;c<4;c++)if(s[c]!==a[c])return!1}if(JSON.stringify(i.linearPoints??null)!==JSON.stringify(o.linearPoints??null)||JSON.stringify(i.stepsParams??null)!==JSON.stringify(o.stepsParams??null))return!1}return!0}function Lf(t){let e=new Map,n=new Set,r=new Map;for(let i of t){if(!i.enabled||i.keyframes.length<2||i.property!=="translateX"&&i.property!=="translateY"&&i.property!=="scaleX"&&i.property!=="scaleY")continue;let o=r.get(i.shapeId)??[];o.push(i),r.set(i.shapeId,o)}for(let i of r.values()){let o=new Set;for(let s=0;s<i.length;s++){let a=i[s];if(o.has(a.id))continue;let c=a.property==="translateX"||a.property==="translateY",l=c?"translateX":"scaleX",d=c?"translateY":"scaleY";if(!(a.property!==l&&a.property!==d))for(let u=s+1;u<i.length;u++){let p=i[u];if(o.has(p.id)||!(a.property===l&&p.property===d||a.property===d&&p.property===l)||!Ix(a,p))continue;let f=a.property===l?a:p,m=a.property===d?a:p;e.set(f.id,m),n.add(m.id),o.add(f.id),o.add(m.id);break}}}return{partner:e,skip:n}}function Bf(t,e,n,r){if(r){let o=e?r.values:t.values,s=e?t.values:r.values,a=Math.min(o.length,s.length),c=[];for(let l=0;l<a;l++)c.push(`${o[l]} ${s[l]}`);return c}let i=n?"1":"0";return t.values.map(o=>e?`${i} ${o}`:`${o} ${i}`)}var wx={x:"x",y:"y",cx:"cx",cy:"cy",x1:"x1",y1:"y1",x2:"x2",y2:"y2",posX:"x",posY:"y",radius:"r",r:"r",rx:"rx",ry:"ry",width:"width",height:"height",pathLength:"pathLength",svgX:"x",svgY:"y",svgWidth:"width",svgHeight:"height",opacity:"opacity",fillOpacity:"fill-opacity",strokeOpacity:"stroke-opacity",fillColor:"fill",strokeColor:"stroke",strokeWidth:"stroke-width",strokeDasharray:"stroke-dasharray",strokeDashoffset:"stroke-dashoffset",display:"display",visibility:"visibility",borderWidth:"stroke-width",cornerRadius:"rx",fontSize:"font-size",letterSpacing:"letter-spacing",wordSpacing:"word-spacing",textLength:"textLength",d:"d",pathMorph:"d",polylinePoints:"points"},kx=new Set(["transformMatrix","rotation","skewX","skewY"]),Px=new Set(["translateX","translateY","scaleX","scaleY"]);function ul(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Me(t,e){return e==null?"":` ${t}="${ul(e)}"`}function pl(t,e){let n=ll(t,e);return Me("keyTimes",n.keyTimes)+Me("calcMode",n.calcMode)+Me("keySplines",n.keySplines)}function Is(t,e){return Me("dur",`${e}s`)+Me("begin",lo(t)||null)+Me("repeatCount",_f(t))}function xs(t,e){let n=e??wx[t.property];if(!n)return"";let r=Er(t);if(r<=0)return"";let i=Mr(t);return i.values.length<2?"":"<animate"+Me("attributeName",n)+Me("values",i.values.join(";"))+pl(i)+Is(t,r)+Me("fill",ci(t))+"/>"}function dD(t,e){let n;switch(t.property){case"transformMatrix":n="matrix";break;case"rotation":n="rotate";break;case"skewX":n="skewX";break;case"skewY":n="skewY";break;default:return""}let r=Er(t);if(r<=0)return"";let i=Mr(t),o=n==="matrix"?i.values.map(c=>pD(c)):i.values.map(c=>String(c));if(o.length<2||o.some(c=>c.length===0))return"";let s=n==="rotate"&&t.transformOrigin?o.map(c=>`${c} ${t.transformOrigin.x} ${t.transformOrigin.y}`):o,a=t.replacesCarrierBase&&e?"sum":cl(t);return'<animateTransform attributeName="transform"'+Me("type",n)+Me("values",s.join(";"))+pl(i)+Is(t,r)+Me("additive",a)+Me("fill",ci(t))+"/>"}function uD(t,e,n){let r=t.property==="scaleX"||t.property==="scaleY",i=t.property==="translateY"||t.property==="scaleY",o=r?"scale":"translate",s=Er(t);if(s<=0)return"";let a=Mr(t);if(a.values.length<2)return"";let c=e?Mr(e):void 0,l=Bf(a,i,r,c);if(l.length<2)return"";let d=!t.replacesCarrierBase||n?"sum":null;return'<animateTransform attributeName="transform"'+Me("type",o)+Me("values",l.join(";"))+pl(a)+Is(t,s)+Me("additive",d)+Me("fill",ci(t))+"/>"}function pD(t){if(Array.isArray(t)&&t.length>=6){let e=t.slice(0,6);if(e.every(n=>typeof n=="number"&&Number.isFinite(n)))return e.join(" ")}if(typeof t=="string"){let e=t.trim(),n=/^matrix\(([^)]+)\)$/i.exec(e),i=(n?n[1]:e).split(/[\s,]+/).filter(Boolean).map(Number);if(i.length>=6&&i.slice(0,6).every(Number.isFinite))return i.slice(0,6).join(" ")}return""}function fD(t){if(!t.motionPath)return"";let e=Er(t);if(e<=0)return"";let n=Mr(t),r=Ff(t),i=!!t.motionPathRef&&(t.motionPathRef.mode??"trackShape")==="curveTemplate",o=ll(n,{defaultCalcMode:"paced"}),s=Df(r)&&ol(n.keyTimes)&&n.calcMode!=="discrete"&&o.calcMode===void 0,a="<animateMotion";return i||(a+=Me("path",t.motionPath)),a+=Me("keyTimes",o.keyTimes),s||(a+=Me("keyPoints",r.join(";"))),a+=Me("calcMode",o.calcMode)+Me("keySplines",o.keySplines),a+=Is(t,e),a+=Me("fill",ci(t)),t.motionRotate!==void 0&&(a+=Me("rotate",typeof t.motionRotate=="number"?String(t.motionRotate):t.motionRotate)),i?a+=`><mpath href="#${ul(t.motionPathRef.shapeId)}"/></animateMotion>`:a+="/>",a}function dl(t,e,n){if(kx.has(t.property)||Px.has(t.property)||t.property==="pathMotion")return"";let r=n??(t.property==="domAttribute"?t.domAttribute:wx[t.property]);if(!r)return"";let i=t.keyframes[e];return i?"<set"+Me("attributeName",r)+Me("to",Array.isArray(i.value)?i.value.join(" "):String(i.value))+Me("begin",zf(t,e)||null)+"/>":""}function Tx(t,e){let n={...t,locked:t.locked??!1,keyframes:[...t.keyframes].sort((r,i)=>r.time-i.time).map(r=>({...r,easing:r.easing}))};return!n.enabled||n.keyframes.length===0?"":sl(n)?dl(n,0,e):al(n)?n.keyframes.map((r,i)=>dl(n,i,e)).join(""):n.keyframes.length<2?"":xs(n,e)}function mD(t){let e=lo(t);return e?`<discard begin="${ul(e)}"/>`:"<discard/>"}function gD(t){if(!t.transformFunction)return"";let e=Er(t);if(e<=0)return"";let n=Mr(t);return n.values.length<2?"":'<animateTransform attributeName="transform"'+Me("type",t.transformFunction)+Me("values",n.values.join(";"))+pl(n)+Is(t,e)+Me("additive",cl(t))+Me("fill",ci(t))+"/>"}function fl(t){let e=new Map,n=t.tracks.map(l=>({...l,locked:l.locked??!1,keyframes:[...l.keyframes].sort((d,u)=>d.time-u.time).map(d=>({...d,time:d.time,value:d.value,easing:d.easing}))})),r=[...n.flatMap(l=>{let d=ah(l);return d?[d]:[]}),...n],i=Lf(r),o=new Set,s=new Set,a=new Set,c=(l,d,u)=>{if(!d)return;let p=d;u.sourceSmilId&&!o.has(u.sourceSmilId)&&(o.add(u.sourceSmilId),p=d.replace(/^(<[a-zA-Z]+)/,`$1 id="${ul(u.sourceSmilId)}"`));let f=e.get(l)??[];f.push(p),e.set(l,f)};for(let l of r){if(!l.enabled||i.skip.has(l.id)||l.keyframes.length<1)continue;if(l.property==="discard"){c(l.shapeId,mD(l),l);continue}if(sl(l)){c(l.shapeId,dl(l,0),l);continue}if(al(l)){for(let p=0;p<l.keyframes.length;p++)c(l.shapeId,dl(l,p),l);continue}if(l.keyframes.length<2)continue;let d=l.id.endsWith(":backwards-fill")?s:a,u="";l.property==="domTransformStack"?u=gD(l):l.property==="domAttribute"&&l.domAttribute?u=xs(l,l.domAttribute):l.property==="domDisplay"?u=xs(l,"display"):l.property==="domVisibility"?u=xs(l,"visibility"):l.property==="pathMotion"&&l.motionPath?u=fD(l):kx.has(l.property)?(u=dD(l,d.has(l.shapeId)),u&&d.add(l.shapeId)):Px.has(l.property)?(u=uD(l,i.partner.get(l.id),d.has(l.shapeId)),u&&d.add(l.shapeId)):u=xs(l),c(l.shapeId,u,l)}return e}function hD(t){return t.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&")}function yD(t){return!t.domTargetSelector||!t.shapeId.startsWith("__dom__")?null:t.shapeId.slice(7)||null}function Gf(t,e,n){if(!t||!e)return t;let r=n??fl(e),i=new Map;for(let s of e.tracks){if(!s.enabled||!s.template||!s.domTargetSelector)continue;let a=yD(s);a&&!i.has(s.shapeId)&&i.set(s.shapeId,a)}let o=t;for(let[s,a]of i){let c=r.get(s)?.join("")??"";if(!c)continue;let l=hD(a),d=new RegExp(`<([A-Za-z_][\\w:.-]*)([^>]*\\bid=(['"])${l}\\3[^>]*?)(\\s*/?)>`,"u");o=o.replace(d,(u,p,f,m,g)=>g.includes("/")?`<${p}${f}>${c}</${p}>`:`<${p}${f}>${c}`)}return o}function gl(t){return t===null||typeof t!="object"?JSON.stringify(t)??"null":Array.isArray(t)?`[${t.map(gl).join(",")}]`:`{${Object.entries(t).sort(([e],[n])=>e.localeCompare(n)).map(([e,n])=>`${JSON.stringify(e)}:${gl(n)}`).join(",")}}`}function ml(t,e,n){for(let r of t){r.type==="symbol-instance"&&n(r,e);let i=r.state.children;if(!Array.isArray(i))continue;let o=e;r.type==="svg"&&(o=ii(r,e).viewport.childPercentBasis??e),ml(i,o,n)}}function Vf(t,e,n={}){let r=n.reservedIds??new Set,i=qo(t),o=new Map,s=[],a=new WeakMap,c=new Map,l=[],d=(R,$)=>{a.set(R,$);let A=c.get(R.id);A?A.push($):c.set(R.id,[$]),l.push(...$.diagnostics)},u=(R,$,A)=>{if(a.has(R))return;let O=String(R.state.symbolId??"").trim(),G=O!==""&&i.duplicateIds.has(O),M=O?i.symbol(O):void 0;if(G||!M){d(R,{targetId:null,definition:null,materializationKey:null,materialization:null,parentViewport:A,viewport:null,diagnostics:[{code:G?"duplicate-library-id":"unresolved-symbol-definition",shapeId:R.id,message:G?`Symbol instance ${R.id} targets duplicate library id ${O}.`:`Symbol instance ${R.id} targets missing symbol definition ${O||"(blank)"}.`}]});return}let V=n.instancePolicy?.(R),K=V?.initialVariantKey===void 0?R:{...R,state:{...R.state,variantKey:V.initialVariantKey}},X=Ai(M,K),U=V?.dedicated===!0,te=Qo(R,M,A,n.viewportHost);if($.includes(X.materializationKey)){d(R,{targetId:null,definition:M,materializationKey:X.materializationKey,materialization:null,parentViewport:A,viewport:te,diagnostics:[...X.diagnostics,{code:"symbol-cycle",shapeId:R.id,message:`Symbol instance cycle detected through ${M.id}.`}]});return}let Z=A?`${A.width},${A.height}`:"none",ne=`${X.materializationKey}\0path=${$.join("")}\0viewport=${Z}`+(U?`\0dedicated=${R.id}`:""),F=o.get(ne);if(!F){let oe=structuredClone(X.shapes);F={occurrenceKey:ne,materializationKey:X.materializationKey,candidateTargetId:U?`${M.id}--ovr-${R.id}`:X.candidateTargetId,targetId:U?`${M.id}--ovr-${R.id}`:X.candidateTargetId,definition:M,shapes:oe,materialized:X.materialized||U,forcedDedicated:U,activeDepth:$.length,parentViewport:A,viewport:te},o.set(ne,F),s.push(F)}let j={targetId:F.targetId,definition:M,materializationKey:X.materializationKey,materialization:null,diagnostics:X.diagnostics,parentViewport:A,viewport:te,pending:F};d(R,j);let H=[...$,X.materializationKey];ml(F.shapes,F.viewport.childPercentBasis??A,(oe,re)=>u(oe,H,re))};ml(e,n.parentViewport,(R,$)=>{u(R,[],$)});let p=new Map,f=new Map,m=new Set,g=R=>{let $=p.get(R);if($)return $;if(m.has(R))throw new Error(`Materialization occurrence graph retained a cycle at ${R.occurrenceKey}.`);m.add(R);let A=[];ml(R.shapes,R.viewport.childPercentBasis??R.parentViewport,M=>{let V=a.get(M);if(V?.pending){A.push(`resolved:${g(V.pending)}`);return}A.push(gl({materializationKey:V?.materializationKey??null,diagnostics:V?.diagnostics.map(K=>K.code)??["missing-resolution"]}))}),m.delete(R);let O=gl({materializationKey:R.materializationKey,nested:A,forcedOccurrence:R.forcedDedicated?R.occurrenceKey:null}),G=f.get(O);return G||(G=`materialization-signature:${f.size+1}`,f.set(O,G)),p.set(R,G),G},h=(R,$)=>R.activeDepth-$.activeDepth||R.candidateTargetId.localeCompare($.candidateTargetId)||R.occurrenceKey.localeCompare($.occurrenceKey),y=new Map;for(let R of s){let $=g(R),A=y.get($);(!A||h(R,A)<0)&&y.set($,R)}let b=new Map;for(let R of s)b.set(R,y.get(g(R)));let v=s.filter(R=>b.get(R)===R),I=new Map;for(let R of v){let $=I.get(R.materializationKey);(!$||$.forcedDedicated&&!R.forcedDedicated||$.forcedDedicated===R.forcedDedicated&&h(R,$)<0)&&I.set(R.materializationKey,R)}let x=R=>R.forcedDedicated||R.materialized||I.get(R.materializationKey)!==R,k=new Set(v.filter(R=>!x(R)).map(R=>R.definition.id)),T=new Set([...r,...k,...v.filter(x).map(R=>R.candidateTargetId)]),w=new Set([...r,...k]);for(let R of v){if(!x(R)){R.targetId=R.definition.id;continue}let $=R.candidateTargetId,A=$;if(w.has(A)){let O=2;do A=`${$}-${O++}`;while(T.has(A)||w.has(A))}R.targetId=A,w.add(A)}let P=new Map,N=v.map(R=>{let $={materializationKey:R.materializationKey,targetId:R.targetId,candidateTargetId:R.candidateTargetId,definition:R.definition,shapes:R.shapes,parentViewport:R.parentViewport,viewport:R.viewport};return P.set(R,$),$});for(let R of s){let $=b.get(R),A=P.get($);R.targetId=A.targetId,R!==$&&P.set(R,{materializationKey:R.materializationKey,targetId:A.targetId,candidateTargetId:R.candidateTargetId,definition:R.definition,shapes:R.shapes,parentViewport:R.parentViewport,viewport:R.viewport})}for(let R of c.values())for(let $ of R)$.pending&&($.targetId=$.pending.targetId,$.materialization=P.get($.pending)??null,delete $.pending);return{materializations:N,diagnostics:l,resolve(R){let $=a.get(R);if($)return $;let A=c.get(R.id);return A?.length===1?A[0]:void 0}}}var SD="text/css";function hl(t){return t.includes("{")?t.replace(/([^{}]*)\{([^{}]*)\}/g,(e,n,r)=>{let i=Rx(r);if(i===r)return e;let o=String(n).trim();return!/^(?:from|to|[\d.]+%)(?:\s*,\s*(?:from|to|[\d.]+%))*$/i.test(o)&&!/[^\s;]/.test(i)?"":`${n}{${i}}`}):Rx(t)}var bD=/(?:^|[\s;])(?:-(?:webkit|moz|o|ms)-)?animation(?:-[a-z-]+)?\s*:[^;]*(?:;|$)/gi,vD=/(?:^|[\s;])(?:-(?:webkit|moz|o|ms)-)?transition(?:-[a-z-]+)?\s*:[^;]*(?:;|$)/gi,xD=/(?:^|[\s;])(?:-(?:webkit|moz|o|ms)-)?(?:transform-origin|transform-box)\s*:[^;]*(?:;|$)/gi;function Rx(t){let e=!1,n=t.replace(bD,r=>(e=!0,jf(r)));return n=n.replace(vD,r=>jf(r)),e&&(n=n.replace(xD,r=>jf(r))),n}function jf(t){return t.startsWith(";")?";":""}function ID(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/"/g,"&quot;")}function Cx(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;")}function yl(t){let e=t.map(({name:n,defaultValue:r})=>` --${n}: ${r};`);return e.length?`:root, svg {
43
+ ${e.join(`
44
+ `)}
45
+ }
46
+ `:""}function Uf(t){if(!t||t.length===0)return"";let e=yl(t);return e?`<style id="svgsketch-variables">${Cx(e)}</style>`:""}function Hf(t){if(!t||t.length===0)return"";let e=[];for(let n of t){let r=new Map;if(n.svgId&&r.set("id",n.svgId),n.type&&n.type!==SD&&r.set("type",n.type),n.media&&r.set("media",n.media),n.customAttrs)for(let[o,s]of Object.entries(n.customAttrs))r.has(o)||r.set(o,s);let i="<style";for(let[o,s]of r)i+=` ${o}="${ID(s)}"`;i+=`>${Cx(hl(n.css))}</style>`,e.push(i)}return e.join("")}function wD(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/"/g,"&quot;")}function kD(t){return t?t.includes("]]>")?t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"):/[<&>]/.test(t)?`<![CDATA[${t}]]>`:t:""}function Wf(t){if(!t||t.length===0)return"";let e=[];for(let n of t){let r=new Map;if(n.svgId&&r.set("id",n.svgId),n.type&&r.set("type",n.type),n.source==="external"&&n.href&&r.set("href",n.href),n.crossorigin&&r.set("crossorigin",n.crossorigin),n.async&&r.set("async",""),n.defer&&r.set("defer",""),n.customAttrs)for(let[o,s]of Object.entries(n.customAttrs))r.has(o)||r.set(o,s);let i="<script";for(let[o,s]of r)i+=` ${o}="${wD(s)}"`;n.source==="inline"&&n.content?i+=`>${kD(n.content)}</script>`:i+="/>",e.push(i)}return e.join("")}function PD(t){return t.replace(new RegExp(`\\s+${Xs}\\s*=\\s*(?:"[^"]*"|'[^']*')`,"g"),"")}function Kf(t,e){let n=/url\(\s*['"]?#([^'")\s]+)['"]?\s*\)/g,r;for(;(r=n.exec(t))!==null;)e.add(r[1]);let i=/\b(?:xlink:)?href\s*=\s*(?:"#([^"]+)"|'#([^']+)')/g;for(;(r=i.exec(t))!==null;)e.add(r[1]??r[2])}function Xf(t,e,n=[],r=new Set){let i=new Map;for(let l of t.paintServerDefs??[]){if(!l||typeof l.markup!="string")continue;let d=l.id??Ys(l.markup);!d||r.has(d)||i.set(d,{id:d,markup:PD(l.markup),passthrough:l.passthrough===!0})}if(i.size===0)return"";let o=new Set;Kf(e,o);for(let l of n)Kf(l,o);let s=new Map;for(let l of i.values())l.passthrough&&s.set(l.id,l);let a=!0;for(;a;){a=!1;for(let l of i.values())s.has(l.id)||!o.has(l.id)||(s.set(l.id,l),a=!0);for(let l of s.values()){let d=o.size;Kf(l.markup,o),o.size>d&&(a=!0)}}if(s.size===0)return"";let c=[];for(let l of i.values())s.has(l.id)&&c.push(l.markup);return c.join("")}function Yf(t){let e=new Set;for(let n of t??[])e.add(n.definitionId??`${n.type}-${n.id}`);return e}var TD={defsMarkup:"",suppressedShapeIds:new Set,memberToDirective:new Map};function Qt(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/"/g,"&quot;")}function Sl(t){return t.definitionId??`${t.type}-${t.id}`}function qf(t,e){let n=0;for(;n<t.length;){let l=/^\s+/.exec(t.slice(n));if(l){n+=l[0].length;continue}if(!t.startsWith("<!--",n))break;let d=t.indexOf("-->",n+4);if(d<0)return t;n=d+3}let r=t.slice(n),i=/^<([A-Za-z][\w:-]*)((?:[^>"']|"[^"]*"|'[^']*')*?)(\/?)>/.exec(r);if(!i)return t;let[o,s,a,c]=i;return t.slice(0,n)+`<${s}${e(a)}${c}>`+r.slice(o.length)}function RD(t,e){return qf(t,n=>{let r=n.replace(/\s+id\s*=\s*(?:"[^"]*"|'[^']*')/,"");return` id="${Qt(e)}"${r}`})}function ws(t,e){return t.replace(new RegExp(`\\s+${e}\\s*=\\s*(?:"[^"]*"|'[^']*')`,"g"),"")}function CD(t,e,n){return qf(t,r=>{let i=ws(r,"data-shape-id");if(e==="clip"){let o=/\bfill-rule\s*=\s*(?:"([^"]*)"|'([^']*)')/.exec(i);i=ws(i,"fill-rule"),i=ws(i,"clip-rule"),i=ws(i,"fill"),i=i.replace(/\s+stroke(?:-[a-z-]+)?\s*=\s*(?:"[^"]*"|'[^']*')/g,""),i+=' fill="black"';let s=n??o?.[1]??o?.[2];s&&(i+=` clip-rule="${Qt(s)}"`)}return i})}function Zf(t){let e=t.clipMaskGroups;if(!Array.isArray(e)||e.length===0)return TD;let n=new Map;for(let c of t.shapes??[])mn(c,{onShape:l=>n.set(l.id,l)});let r=Qn(Array.isArray(t.library)?t.library:[]),i=new Set,o=new Map,s=new Set,a=[];for(let c of e){if(!c||c.type!=="clip"&&c.type!=="mask")continue;let l=Sl(c),d=Array.isArray(c.clipShapeIds)?c.clipShapeIds:[];for(let p of d)i.add(p);if(!s.has(l)){if(typeof c.rawDefinition=="string"&&c.rawDefinition.length>0)s.add(l),a.push(RD(c.rawDefinition,l));else if(d.length>0){s.add(l);let p=c.type==="clip"?"clipPath":"mask",f=`<${p} id="${Qt(l)}"`;c.type==="clip"?(c.clipPathUnits&&(f+=` clipPathUnits="${Qt(c.clipPathUnits)}"`),c.clipRule&&(f+=` clip-rule="${Qt(c.clipRule)}"`)):(c.maskUnits&&(f+=` maskUnits="${Qt(c.maskUnits)}"`),c.maskContentUnits&&(f+=` maskContentUnits="${Qt(c.maskContentUnits)}"`),c.maskBounds&&(f+=` x="${Qt(c.maskBounds.x)}" y="${Qt(c.maskBounds.y)}"`,f+=` width="${Qt(c.maskBounds.width)}"`,f+=` height="${Qt(c.maskBounds.height)}"`),c.maskType&&(f+=` mask-type="${Qt(c.maskType)}"`)),f+=">";for(let m of d){let g=n.get(m);g&&(f+=CD(fn(g,r),c.type,c.clipRule))}f+=`</${p}>`,a.push(f)}}let u=Array.isArray(c.contentShapeIds)?c.contentShapeIds:[];if(u.length>0){let p={attr:c.type==="clip"?"clip-path":"mask",defId:l,memberIds:u};for(let f of u)o.has(f)||o.set(f,p)}}return{defsMarkup:a.join(""),suppressedShapeIds:i,memberToDirective:o}}function Jf(t,e){return qf(t,n=>`${ws(n,e.attr)} ${e.attr}="url(#${Qt(e.defId)})"`)}function bl(t,e){let n=t.state?.children;return!Array.isArray(n)||n.length===0?t:{...t,state:{...t.state,children:$x(n,e)}}}function $x(t,e){let n=t.filter(i=>!e.suppressedShapeIds.has(i?.id)).map(i=>bl(i,e)),r=[];for(let i=0;i<n.length;){let o=n[i],s=e.memberToDirective.get(o.id);if(!s){r.push(o),i++;continue}let a=[o],c=i+1;for(;c<n.length&&e.memberToDirective.get(n[c].id)===s;)a.push(n[c]),c++;a.length===1?r.push($D(o,s)):r.push(ND(a,s)),i=c}return r}function $D(t,e){let n=t.state,r={...n.authoredAttributes??{},[e.attr]:`url(#${e.defId})`};return{...t,state:{...n,authoredAttributes:r}}}function ND(t,e){return{id:`clipmask-wrapper:${e.defId}:${t[0].id}`,type:"group",state:{children:t,groupData:{[e.attr==="clip-path"?"clipPath":"mask"]:`url(#${e.defId})`}}}}function Vt(t){return t.library+t.builtinMarkers+t.symbols+t.motionPaths+t.paintServers+t.clipMask+t.inlineHoisted}function AD(t){return gf.some(e=>e===t)}function ED(t,e){let n=at(t);return n&&n.width>0&&n.height>0?{width:n.width,height:n.height}:e}function Pn(t,e={}){let{backgroundColor:n,includeScripts:r=!0}=e;if(t.sceneTree&&t.sceneTree.length>0){let L={...t,shapes:structuredClone(t.shapes??[])};Ii(L),t=L}let i=t.shapes??[],o=i.find(L=>L.type==="svg"&&L.state?.isRootSvg===!0),s=o?.state,a=Number(s?.svgViewBoxWidth??0),c=Number(s?.svgViewBoxHeight??0),l=a>0&&c>0?{x:Number(s?.svgViewBoxX??0),y:Number(s?.svgViewBoxY??0),width:a,height:c,intrinsicWidth:Number(s?.svgWidth??0)>0?Number(s?.svgWidth):a,intrinsicHeight:Number(s?.svgHeight??0)>0?Number(s?.svgHeight):c,preserveAspectRatio:typeof s?.svgPreserveAspectRatio=="string"?s.svgPreserveAspectRatio.trim():""}:null,d=t.viewboxes?.[0],u=e.width??l?.intrinsicWidth??d?.width??800,p=e.height??l?.intrinsicHeight??d?.height??600,f=e.viewBox??(l?`${l.x} ${l.y} ${l.width} ${l.height}`:`0 0 ${u} ${p}`),m=e.preserveAspectRatio??l?.preserveAspectRatio??"",g=ED(f,l?{width:l.width,height:l.height}:{width:u,height:p}),h=new Set,y=L=>{for(let be of L??[])h.add(be.id),y(be.state?.children)};for(let L of i)y(L.state?.children);let b=i.filter(L=>L.state?.displayMode==="motionOnly"),v=i.filter(L=>L.state?.displayMode!=="motionOnly"&&L!==o&&!h.has(L.id)),I=new Set(b.filter(L=>vl(L)!==null).map(L=>L.id)),x=t.animationTimeline?{...t.animationTimeline,tracks:t.animationTimeline.tracks.map(L=>{let be=L.motionPathRef;if(L.property!=="pathMotion"||!L.motionPath||!be||(be.mode??"trackShape")!=="curveTemplate"||I.has(be.shapeId))return L;let{motionPathRef:ce,...Te}=L;return Te})}:null,k=x?fl(x):null,T=Zf(t),w=Gf(T.defsMarkup,x,k??void 0),P=DD(t),N=zD(t),R=Array.isArray(t.library)?t.library:[],$=kf({documentStyles:t.documentStyles,animationTimeline:x,clipMaskGroups:t.clipMaskGroups}),A=Yc(v,R,$),O=A.filter(L=>L.kind!=="symbol"),G=Di(v,R);for(let L of $)G.ids.add(L);let M=Qn(R);M.textMeasurementHost=e.textMeasurementHost;let V;{let L=Yo(i),be=new Map,ce=new Set,Te=new Set,Xe=(W,Ie)=>{W&&Ie.add(W)};for(let W of L.ordered)W.type==="text"&&Xe(W.state?.shapeInsideRef,ce),W.type==="shape-reference"&&Xe(W.state?.targetShapeId,Te);let je=new Map;for(let W of L.ordered){let Ie=W.state?.metadata?.name,He=Ie?qn(Ie):"",Se=ce.has(W.id)||Te.has(W.id);He?je.set(W,He):Se&&!L.duplicateIds.has(W.id)&&je.set(W,W.id)}let Ft=new Set([...O.map(W=>W.id),...b.filter(W=>vl(W)).map(W=>W.id),...(t.clipMaskGroups??[]).map(Sl)]);for(let[W,Ie]of Object.entries(Lc)){let He=W.replace("line-marker-","");(G.legacyEndpoints.has(He)||G.ids.has(W))&&Ft.add(W),G.ids.has(Ie)&&Ft.add(Ie)}for(let W of L.ordered)W.type==="text"&&W.state.isTextPath&&W.state.textPathPoints&&Ft.add(`text-path-${W.id}`);V=Vf(R,v,{reservedIds:new Set([...Ft,...je.values()]),parentViewport:g,instancePolicy:(()=>{let W=e.symbolInstanceInitialVariants;if(!W||W.size===0)return;let Ie=new WeakMap;for(let[He,Se]of W){let dt=L.uniqueById.get(He);dt?.type==="symbol-instance"&&Ie.set(dt,Se)}return He=>{let Se=Ie.get(He);return Se===void 0?void 0:{initialVariantKey:Se,dedicated:!0}}})()});for(let W of V.materializations)Ft.add(W.targetId);for(let W of V.diagnostics)zt({severity:"warning",code:W.code,shapeId:W.shapeId,message:W.message});M.symbolInstanceTargetElementId=W=>V.resolve(W)?.targetId;let Ut=Zn(t),ie=new WeakMap;M.symbolInstanceTransform=W=>{let Ie=ie.get(W);if(!Ie){let He=V.resolve(W);Ie=Xp(Ut,W,{},He?.parentViewport??g),ie.set(W,Ie);for(let Se of Ie.diagnostics)!["invalid-symbol-viewport","unresolved-symbol-viewport","unresolved-symbol-pivot"].includes(Se.code)||!AD(Se.code)||zt({severity:"warning",code:Se.code,shapeId:Se.shapeId,message:Se.message})}return Ie};let we=new Set([...je.values(),...Ft]),$e=new Set(Ft),Ue=new Map,tt=new Map,tn=new Map;for(let[W,Ie]of je){let He=(Ue.get(Ie)??0)+1;Ue.set(Ie,He);let Se=Ie;if(He>1||$e.has(Se)){let dt=2;do Se=`${Ie}-${dt++}`;while(we.has(Se)||$e.has(Se))}tt.set(W,Se),L.duplicateIds.has(W.id)||tn.set(W.id,Se),$e.add(Se)}for(let[W,Ie]of L.uniqueById){let He=tt.get(Ie);He&&be.set(W,He)}if(tt.size>0&&(M.elementIdForShape=W=>tn.get(W.id)??tt.get(W)),ce.size>0&&(M.shapeInsideTargetElementId=W=>be.get(W)),Te.size>0){M.shapeReferenceTargetElementId=Se=>L.duplicateIds.has(Se)?null:be.get(Se);let W=Zn(t),Ie=new WeakMap,He=new WeakMap;M.shapeReferenceBounds=Se=>{let dt=Ie.get(Se);return dt||(dt=rs(W,Se),Ie.set(Se,dt)),dt},M.shapeReferenceTransform=Se=>{let dt=He.get(Se);return dt||(dt=Kp(W,Se),He.set(Se,dt)),dt}}}let K=new Map,X=new Set,U=new Map(Yo(i).ordered.map(L=>[L.id,L]));for(let L of x?.tracks??[]){let be=/^(fill|stroke)GradientStop(\d+)(Color|Opacity|Offset)$/.exec(L.property);if(!be)continue;let ce=U.get(L.shapeId);if(!ce)continue;let Te=be[1],Xe=Number(be[2]),je=be[3],Ft=ce.state?.[Te==="fill"?"fillGradient":"strokeGradient"],Ut=ce.state?.[Te==="fill"?"fillLibraryId":"strokeLibraryId"]??Ft?.id;if(!Ut)continue;let ie=je==="Color"?"stop-color":je==="Opacity"?"stop-opacity":"offset",we=Tx(L,ie);if(!we)continue;let $e=`${Ut}|${Xe}|${ie}|${we}`;if(X.has($e))continue;X.add($e);let Ue=K.get(Ut)??new Map,tt=Ue.get(Xe)??[];tt.push(we),Ue.set(Xe,tt),K.set(Ut,Ue)}M.gradientStopAnimationElements=(L,be)=>K.get(L)?.get(be);let te=O.length>0?Xc(O,M):"",Z=V.materializations.filter(L=>L.targetId===L.definition.id).map(L=>ys(L.definition,L.targetId,L.shapes,M)).join(""),ne=new Set(V.materializations.filter(L=>L.targetId===L.definition.id).map(L=>L.definition.id)),F=A.filter(L=>L.kind==="symbol"&&!ne.has(L.id)).map(L=>Hc(L,M)).join(""),j=te+Z+F,H=wf(G,R),oe=V.materializations.filter(L=>L.targetId!==L.definition.id).map(L=>ys(L.definition,L.targetId,L.shapes,M)).join(""),re=_D(b),xe=n?`<rect width="${u}" height="${p}" fill="${n}"/>`:"",Ze={...M,animationElementsForShape:L=>k?.get(L.id)},et=L=>{let be=fn(L,Ze),ce=k?.get(L.id),Te=ce&&ce.length>0?ce:[];return{shape:L,markup:be,smil:Te}},kt=v.filter(L=>!T.suppressedShapeIds.has(L.id)).map(L=>bl(L,T)),lt=[];for(let L=0;L<kt.length;){let be=kt[L],ce=T.memberToDirective.get(be.id);if(!ce){lt.push({kind:"shape",...et(be)}),L++;continue}let Te=[be],Xe=L+1;for(;Xe<kt.length&&T.memberToDirective.get(kt[Xe].id)===ce;)Te.push(kt[Xe]),Xe++;if(Te.length===1){let je=et(be);lt.push({kind:"shape",...je,markup:Jf(je.markup,ce)})}else lt.push({kind:"clip-mask-run",directive:ce,open:`<g ${ce.attr}="url(#${Qf(ce.defId)})">`,close:"</g>",members:Te.map(et)});L=Xe}let Ve=Ex(lt),E=(t.documentStyles??[]).map(L=>hl(L.css)),z=yl(t.templateVariables??[]),B=Xf(t,Ve,[...E,z,w,j,oe,H,re],Yf(t.clipMaskGroups)),se={rootAttributes:hp(t.documentMetadata),descriptive:yp(t.documentMetadata),scripts:r?Wf(t.documentScripts):"",styles:Uf(t.templateVariables)+Hf(t.documentStyles),trailingComments:(t.documentMetadata?.trailingComments??[]).map(L=>`<!--${L.replace(/--/g,"- -").replace(/-$/,"- ")}-->`).join("")},me={frame:{width:u,height:p,viewBox:f,preserveAspectRatio:m,...e.omitFrameAttributes?{omit:e.omitFrameAttributes}:{}},defs:{library:j,builtinMarkers:H,symbols:oe,motionPaths:re,paintServers:B,clipMask:w,inlineHoisted:""},body:lt,motionOnlyShapes:b,backgroundRect:xe,envelope:se,strippedCssTexts:E,strippedDocumentCss:E.join(`
47
+ `).trim(),symbols:V};return OD(me),me}function Ex(t){let e="";for(let n of t)if(n.kind==="shape")e+=n.markup;else{e+=n.open;for(let r of n.members)e+=r.markup;e+=n.close}return e}var Nx=/url\(\s*['"]?#([^'")\s]+)['"]?\s*\)/g,Ax=/<(?:use|mpath|textPath)\b[^>]*?\s(?:xlink:)?href\s*=\s*"#([^"]+)"/g,MD=/\sid\s*=\s*"([^"]+)"/g;function ks(t,e,n){for(let r of e.matchAll(t))n.add(r[1])}function OD(t){let e=new Set,n=[Vt(t.defs),Ex(t.body),t.envelope.descriptive,t.envelope.styles];for(let s of n)ks(MD,s,e);let r=(s,a)=>{for(let c of s)e.has(c)||zt({severity:"warning",code:"unresolved-reference",message:a?`Unresolved reference "#${c}" on shape "${a}"; no definition with that id is emitted`:`Unresolved reference "#${c}"; no definition with that id is emitted`,...a?{shapeId:a}:{}})},i=s=>{let a=new Set;ks(Nx,s.markup,a),ks(Ax,s.markup,a),r(a,s.shape.id)};for(let s of t.body)if(s.kind==="shape")i(s);else for(let a of s.members)i(a);let o=new Set;ks(Nx,Vt(t.defs),o),ks(Ax,Vt(t.defs),o),r(o)}function DD(t){return(Array.isArray(t.library)?t.library:[]).filter(n=>n.kind==="symbol")}function zD(t){let n=(Array.isArray(t.library)?t.library:[]).filter(r=>r.kind==="marker");return n.length>0?n:void 0}function _D(t){if(t.length===0)return"";let e=[];for(let n of t){let r=vl(n);r&&e.push(`<path id="${Qf(n.id)}" d="${Qf(r)}"/>`)}return e.join("")}function Qf(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;")}function vl(t){return qa(t)}function Ps(t,e={}){return xl(t,e).svg}function xl(t,e={}){let n=new to;return{svg:_c(n,()=>Mx(Tf(Pn(t,e),t,e),e)),diagnostics:n.diagnostics}}function Mx(t,e={}){let{xmlDeclaration:n=!0,indent:r=!0,className:i}=e,o=r?`
48
+ `:"",s=r?" ":"",a=[];for(let m of t.body){if(m.kind==="shape"){a.push(`${s}${m.markup}`);continue}a.push(`${s}${m.open}`);for(let g of m.members)a.push(`${s}${s}${g.markup}`);a.push(`${s}${m.close}`)}let c=a.join(o),l=t.defs,d="";Vt(l).length>0&&(d=`${o}${s}<defs>${o}`,l.library.length>0&&(d+=`${s}${s}${l.library}${o}`),l.builtinMarkers.length>0&&(d+=`${s}${s}${l.builtinMarkers}${o}`),l.symbols.length>0&&(d+=`${s}${s}${l.symbols}${o}`),l.motionPaths.length>0&&(d+=`${s}${s}${l.motionPaths}${o}`),l.paintServers.length>0&&(d+=`${s}${s}${l.paintServers}${o}`),l.clipMask.length>0&&(d+=`${s}${s}${l.clipMask}${o}`),l.inlineHoisted.length>0&&(d+=`${s}${s}${l.inlineHoisted}${o}`),d+=`${s}</defs>`);let u=t.backgroundRect.length>0?`${o}${s}${t.backgroundRect}`:"",p="";n&&(p+=`<?xml version="1.0" encoding="UTF-8"?>${o}`);let f=t.frame.omit;return p+='<svg xmlns="http://www.w3.org/2000/svg"',f?.width||(p+=` width="${t.frame.width}"`),f?.height||(p+=` height="${t.frame.height}"`),f?.viewBox||(p+=` viewBox="${t.frame.viewBox}"`),t.frame.preserveAspectRatio&&(p+=` preserveAspectRatio="${t.frame.preserveAspectRatio}"`),i&&(p+=` class="${i}"`),p+=t.envelope.rootAttributes,p+=">",t.envelope.descriptive.length>0&&(p+=`${o}${s}${t.envelope.descriptive}`),p+=d,p+=u,c.length>0&&(p+=`${o}${c}`),t.envelope.scripts.length>0&&(p+=`${o}${s}${t.envelope.scripts}`),t.envelope.styles.length>0&&(p+=`${o}${s}${t.envelope.styles}`),t.envelope.trailingComments.length>0&&(p+=`${o}${s}${t.envelope.trailingComments}`),p+=`${o}</svg>${o}`,p}var FD=.25,LD=20;function em(t,e){return Math.hypot(e.x-t.x,e.y-t.y)}function Ox(t,e,n){let r=n.x-e.x,i=n.y-e.y,o=r*r+i*i;if(o===0)return em(t,e);let s=Math.max(0,Math.min(1,((t.x-e.x)*r+(t.y-e.y)*i)/o));return Math.hypot(t.x-(e.x+s*r),t.y-(e.y+s*i))}function uo(t,e){return{x:(t.x+e.x)/2,y:(t.y+e.y)/2}}function Ts(t,e,n,r,i,o,s=0){if(s>=LD||Ox(e,t,r)<=i&&Ox(n,t,r)<=i){o.push(r);return}let a=uo(t,e),c=uo(e,n),l=uo(n,r),d=uo(a,c),u=uo(c,l),p=uo(d,u);Ts(t,a,d,p,i,o,s+1),Ts(p,u,l,r,i,o,s+1)}function Dx(t,e){return t?{x:e.x*2-t.x,y:e.y*2-t.y}:{...e}}function BD(t){return Object.freeze({x:t.x,y:t.y})}function GD(t,e={}){let n=Nn(t);if(n.error||n.commands.length===0)return null;let r=e.transform??_e,i=Number.isFinite(e.tolerance)&&(e.tolerance??0)>0?e.tolerance:FD,o=I=>Ye(r,I),s=[],a=null,c={x:0,y:0},l={x:0,y:0},d=null,u=null,p="",f=(I,x,k)=>({x:I.params[x]+(I.type===I.type.toLowerCase()?k.x:0),y:I.params[x+1]+(I.type===I.type.toLowerCase()?k.y:0)}),m=I=>{a||(a=[o(c)],s.push(a)),a.push(o(I)),c=I};for(let I of n.commands){let x=I.type.toUpperCase(),k=I.type===I.type.toLowerCase(),T={...c},w=p==="C"||p==="S",P=p==="Q"||p==="T";switch(x){case"M":{c=f(I,0,T),l={...c},a=[o(c)],s.push(a);break}case"L":m(f(I,0,T));break;case"H":m({x:I.params[0]+(k?T.x:0),y:c.y});break;case"V":m({x:c.x,y:I.params[0]+(k?T.y:0)});break;case"C":{let N=f(I,0,T),R=f(I,2,T),$=f(I,4,T);a||(a=[o(c)],s.push(a)),Ts(o(c),o(N),o(R),o($),i,a),c=$,d=R;break}case"S":{let N=Dx(w?d:null,c),R=f(I,0,T),$=f(I,2,T);a||(a=[o(c)],s.push(a)),Ts(o(c),o(N),o(R),o($),i,a),c=$,d=R;break}case"Q":case"T":{let N=x==="Q"?f(I,0,T):Dx(P?u:null,c),R=f(I,x==="Q"?2:0,T),$={x:c.x+2/3*(N.x-c.x),y:c.y+2/3*(N.y-c.y)},A={x:R.x+2/3*(N.x-R.x),y:R.y+2/3*(N.y-R.y)};a||(a=[o(c)],s.push(a)),Ts(o(c),o($),o(A),o(R),i,a),c=R,u=N;break}case"A":{let N=f(I,5,T),R=Ia(c.x,c.y,I.params[0],I.params[1],I.params[2],I.params[3]===1,I.params[4]===1,N.x,N.y);if(!R){m(N);break}a||(a=[o(c)],s.push(a));let $=Math.cos(R.phi),A=Math.sin(R.phi),O=Math.max(R.rx,R.ry),G=O<=i?Math.PI/4:Math.max(.01,2*Math.acos(Math.max(-1,1-i/O))),M=Math.max(1,Math.ceil(Math.abs(R.deltaTheta)/G));for(let V=1;V<=M;V++){let K=R.theta1+R.deltaTheta*V/M,X=Math.cos(K),U=Math.sin(K);a.push(o({x:R.cx+R.rx*$*X-R.ry*A*U,y:R.cy+R.rx*A*X+R.ry*$*U}))}c=N;break}case"Z":a&&em(a[a.length-1],o(l))>0&&a.push(o(l)),c={...l};break;default:return null}x!=="C"&&x!=="S"&&(d=null),x!=="Q"&&x!=="T"&&(u=null),p=x}let g=[],h=0;for(let I of s)for(let x=1;x<I.length;x++){let k=em(I[x-1],I[x]);k!==0&&(g.push({start:I[x-1],end:I[x],offset:h,length:k}),h+=k)}let y=Object.freeze(s.map(I=>Object.freeze(I.map(BD)))),b=y[0]?.[0]??Object.freeze({x:0,y:0}),v=y[y.length-1]?.at(-1)??b;return Object.freeze({length:h,subpaths:y,pointAtLength(I){if(g.length===0||!Number.isFinite(I)||I<=0)return b;if(I>=h)return v;let x=g.find(T=>I<=T.offset+T.length);if(!x)return v;let k=(I-x.offset)/x.length;return Object.freeze({x:x.start.x+(x.end.x-x.start.x)*k,y:x.start.y+(x.end.y-x.start.y)*k})}})}function zx(t,e){return e?t.variants?.[e]??t.shapes:t.shapes}function _x(t,e){return!e||Object.keys(e).length===0?t:t.map(n=>{let r=e[n.id];return!r||Object.keys(r).length===0?n:{...n,state:{...n.state,...r}}})}function nm(t){let e=[];for(let n of t.timeline.tracks){if(n.property!=="instanceVariant"||n.enabled===!1)continue;let r=t.instances.get(n.shapeId);if(!r)continue;let i=t.getSymbol(r.symbolId);if(!i)continue;let o=t.instanceSymbolIds.get(r.id);if(!o||!t.existingInnerIds.has(o))continue;let s=[...n.keyframes].sort((a,c)=>a.time-c.time);s.length<2||e.push({symbolId:o,def:i,overrides:r.symbolOverrides,keyframes:s})}return e}function rm(t){let e=new Map;for(let[n,r]of t.existingInnerIds)e.set(n,new Set(r));return e}function VD(t){return t.replace(/&apos;/g,"'").replace(/&quot;/g,'"').replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&amp;/g,"&")}function po(t,e){let n=fn(t),r=0;for(;n.startsWith("<!--",r);){let c=n.indexOf("-->",r);if(c===-1)return null;r=c+3}let i=n.indexOf("<",r);if(i===-1)return null;let o=n.indexOf(">",i);if(o===-1)return null;let s=n.slice(i,o+1),a=new RegExp(`\\s${e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&")}="([^"]*)"`).exec(s);return a?VD(a[1]):null}var li=(t,e=0)=>typeof t=="number"&&Number.isFinite(t)?t:e;function jD(t,e,n){let r=t.transformMatrix;if(r&&r.length>=6)return{x:r[0]*e.x+r[2]*e.y+r[4],y:r[1]*e.x+r[3]*e.y+r[5]};let i=li(t.translateX),o=li(t.translateY),s=t.rawTransform;if(s){let g=ot(Kt(s)),h=g[0]*e.x+g[2]*e.y+g[4],y=g[1]*e.x+g[3]*e.y+g[5];return{x:h+i,y:y+o}}let a=li(t.rotation),c=li(t.skewX),l=li(t.skewY),d=li(t.scaleX,1),u=li(t.scaleY,1),p=d!==1||u!==1;if(a===0&&c===0&&l===0&&!p)return{x:e.x+i,y:e.y+o};let f=e.x-n.x,m=e.y-n.y;if(l!==0&&(m=m+f*Math.tan(l*Math.PI/180)),c!==0&&(f=f+m*Math.tan(c*Math.PI/180)),p&&(f*=d,m*=u),a!==0){let g=a*Math.PI/180,h=Math.cos(g),y=Math.sin(g),b=f*h-m*y,v=f*y+m*h;f=b,m=v}return{x:f+n.x+i,y:m+n.y+o}}function Fx(t,e){let n=Ld(e);if(!n)return t.resolveShapeCenterFallback?.(e)??null;let r=e.state,i=r.customPivot??n;return jD(r,n,i)}var UD=[{key:"fillColor",attr:"fill"},{key:"borderColor",attr:"stroke"},{key:"borderWidth",attr:"stroke-width"},{key:"opacity",attr:"opacity"},{key:"fillOpacity",attr:"fill-opacity"},{key:"strokeOpacity",attr:"stroke-opacity"},{key:"fontSize",attr:"font-size"}],HD={circle:{x:"cx",y:"cy",radius:"r"},ellipse:{x:"cx",y:"cy",rx:"rx",ry:"ry"},rectangle:{x:"x",y:"y",width:"width",height:"height"},square:{x:"x",y:"y",width:"width",height:"height"},line:{x1:"x1",y1:"y1",x2:"x2",y2:"y2"},image:{x:"x",y:"y",width:"width",height:"height"},text:{x:"x",y:"y"}},Lx=new Set(["triangle","polygon","star","diamond","ngon","cross","heart","gear","arrow","cloud","ring","lightning","speech-bubble","spiral"]),WD=[{key:"fillColor",prop:"fill"},{key:"borderColor",prop:"stroke"},{key:"borderWidth",prop:"stroke-width"},{key:"opacity",prop:"opacity"},{key:"fillOpacity",prop:"fill-opacity"},{key:"strokeOpacity",prop:"stroke-opacity"}],KD=[{key:"fillColor",prop:"fill"},{key:"borderColor",prop:"stroke"},{key:"borderWidth",prop:"strokeWidth"},{key:"opacity",prop:"opacity"},{key:"fillOpacity",prop:"fillOpacity"},{key:"strokeOpacity",prop:"strokeOpacity"}];function Bx(t,e){return t+(((e-t)%360+540)%360-180)}function en(t,e,n,r,i){return{element:"animate",attributes:[["attributeName",t],["from",e],["to",n],["begin",r],["dur",i],["fill","freeze"]]}}function tm(t,e,n,r,i,o){return{element:"animateTransform",attributes:[["attributeName","transform"],["type",t],["from",e],["to",n],["begin",r],["dur",i],["fill","freeze"],["additive",o]]}}function XD(t){let e=t.state.opacity;return e!==void 0?String(e):"1"}function Gx(t){let e=t.state.opacity;return e!==void 0?String(Number(e)):"1"}function*im(t,e){let{keyframes:n,def:r,overrides:i}=t;for(let o=0;o<n.length-1;o++){let s=n[o],a=n[o+1],c=String(s.value??""),l=String(a.value??"");if(c===l)continue;let d=_x(zx(r,c),i),u=_x(zx(r,l),i);yield{treeA:d,treeB:u,aById:new Map(d.map(p=>[p.id,p])),bById:new Map(u.map(p=>[p.id,p])),index:o,beginSec:s.time/e,durSec:(a.time-s.time)/e}}}function YD(t){let e=nm(t);if(e.length===0)return[];let n=t.timeline.duration>0?t.timeline.duration:1,r=rm(t),i=[];for(let o of e){let s=r.get(o.symbolId),a=[];for(let c of im(o,n)){let l=`${c.beginSec}s`,d=`${c.durSec}s`;for(let u of c.treeB){let p=c.aById.get(u.id);if(!p||!s.has(u.id))continue;let f=p.state,m=u.state,g=[];for(let{key:y,attr:b}of UD){let v=f[y],I=m[y];v===void 0&&I===void 0||v!==I&&(v==null||I==null||g.push({action:"animate",spec:en(b,String(v),String(I),l,d)}))}let h=HD[u.type];if(h)for(let[y,b]of Object.entries(h)){let v=f[y],I=m[y];v===void 0&&I===void 0||v!==I&&(v==null||I==null||g.push({action:"animate",spec:en(b,String(v),String(I),l,d)}))}if(Lx.has(u.type)){let y=Number(f.cx),b=Number(f.cy),v=Number(m.cx),I=Number(m.cy),x=Number(f.rotation??0),k=Number(m.rotation??0);if(Number.isFinite(y)&&Number.isFinite(b)&&Number.isFinite(v)&&Number.isFinite(I)&&Number.isFinite(x)&&Number.isFinite(k)&&(y!==v||b!==I||x!==k)){c.index===0&&g.push({action:"setBaseTransform",transform:`translate(${y}, ${b}) rotate(${x})`}),g.push({action:"animate",spec:tm("translate",`${y} ${b}`,`${v} ${I}`,l,d,"replace")});let R=Bx(x,k);g.push({action:"animate",spec:tm("rotate",String(x),String(R),l,d,"sum")})}let w=f.sides,P=m.sides;if((f.radius!==m.radius||f.shiftAngle!==m.shiftAngle||f.cornerRadius!==m.cornerRadius)&&w===P){let R=po(p,"d"),$=po(u,"d");R&&$&&R!==$&&g.push({action:"animate",spec:en("d",R,$,l,d)})}else if(w!==P){let R=`${u.id}--xf`,$=1;for(;s.has(R);)R=`${u.id}--xf${$++}`;s.add(R),g.push({action:"crossfade",innerId:R,shape:u,fadeOut:en("opacity","1","0",l,d),fadeIn:en("opacity","0",XD(u),l,d)})}}if(u.type==="polyline"){let y=f.polylinePoints??null,b=m.polylinePoints??null;if(y&&b&&y.length===b.length){let v=po(p,"points"),I=po(u,"points");v&&I&&v!==I&&g.push({action:"animate",spec:en("points",v,I,l,d)})}}if(f.lineStyle!==m.lineStyle||f.dashLength!==m.dashLength||f.gapLength!==m.gapLength){let y=po(p,"stroke-dasharray"),b=po(u,"stroke-dasharray");y&&b&&y!==b&&g.push({action:"animate",spec:en("stroke-dasharray",y,b,l,d)})}if(!Lx.has(u.type)){let y=Number(f.rotation??0),b=Number(m.rotation??0);if(Number.isFinite(y)&&Number.isFinite(b)&&y!==b){let v=Fx(t,p),I=Fx(t,u);if(v&&I){let x=Bx(y,b);g.push({action:"animate",spec:tm("rotate",`${y} ${v.x} ${v.y}`,`${x} ${I.x} ${I.y}`,l,d,"sum")})}}}for(let[y,b]of[["fillGradient","fill"],["strokeGradient","stroke"]]){let v=qD(f,m,y,b,l,d);v&&g.push(v)}a.push({op:"withInner",innerId:u.id,actions:g})}for(let u of c.treeA)c.bById.has(u.id)||s.has(u.id)&&a.push({op:"withInner",innerId:u.id,actions:[{action:"animate",spec:en("opacity","1","0",l,d)}]});for(let u of c.treeB)c.aById.has(u.id)||(s.add(u.id),a.push({op:"ensureInner",innerId:u.id,shape:u,animations:[en("opacity","0",Gx(u),l,d)]}))}i.push({symbolId:o.symbolId,ops:a})}return i}function qD(t,e,n,r,i,o){let s=t[n],a=e[n];if(!s||!a||s.type!==a.type||!Array.isArray(s.stops)||!Array.isArray(a.stops)||s.stops.length!==a.stops.length)return null;let c=[];for(let u=0;u<s.stops.length;u++){let p=s.stops[u],f=a.stops[u],m=[];p.offset!==f.offset&&m.push(en("offset",String(p.offset),String(f.offset),i,o)),p.color!==f.color&&m.push(en("stop-color",p.color,f.color,i,o)),p.opacity!==f.opacity&&m.push(en("stop-opacity",String(p.opacity),String(f.opacity),i,o)),m.length>0&&c.push({index:u,animations:m})}let l=s.type==="linear-gradient"?["x1","y1","x2","y2"]:["cx","cy","fx","fy","r"],d=[];for(let u of l){let p=s[u],f=a[u];typeof p!="number"||typeof f!="number"||p===f||d.push(en(u,String(p),String(f),i,o))}return{action:"gradient",paintAttr:r,expectedStopCount:s.stops.length,stops:c,gradient:d}}var ZD=t=>t.replace(/[^a-zA-Z0-9_-]/g,"_");function JD(t){let e=nm(t);if(e.length===0)return{stylesheet:null,symbols:[]};let n=t.timeline.duration>0?t.timeline.duration:1,r=rm(t),i=[],o=0,s=[],a=new Map;for(let c of e){let l=r.get(c.symbolId),d=s.find(f=>f.symbolId===c.symbolId);d||(d={symbolId:c.symbolId,scopeClass:`svgsketch-variant-${ZD(c.symbolId)}`,ensure:[],assignments:[]},s.push(d),a.set(d,new Map));let u=a.get(d),p=(f,m,g,h,y,b)=>{let v=`svgsketch-vt-${++o}`;i.push(`@keyframes ${v} { 0% { ${h}: ${m}; } 100% { ${h}: ${g}; } }`);let I=`${v} ${b}s linear ${y}s forwards`,x=u.get(f);x?x.push(I):u.set(f,[I])};for(let f of im(c,n))if(!(f.durSec<=0)){for(let m of f.treeB){let g=f.aById.get(m.id);if(!g||!l.has(m.id))continue;let h=g.state,y=m.state;for(let{key:b,prop:v}of WD){let I=h[b],x=y[b];I===void 0&&x===void 0||I!==x&&(I==null||x==null||p(m.id,String(I),String(x),v,f.beginSec,f.durSec))}}for(let m of f.treeA)f.bById.has(m.id)||l.has(m.id)&&p(m.id,"1","0","opacity",f.beginSec,f.durSec);for(let m of f.treeB)f.aById.has(m.id)||(l.has(m.id)||(d.ensure.push({innerId:m.id,shape:m}),l.add(m.id)),p(m.id,"0",Gx(m),"opacity",f.beginSec,f.durSec))}}for(let[c,l]of a)for(let[d,u]of l)c.assignments.push({innerId:d,animation:u.join(", ")});return{stylesheet:i.length>0?i.join(`
49
+ `):null,symbols:s}}function QD(t){let e=nm(t);if(e.length===0)return{scriptBody:null,symbols:[]};let n=t.timeline.duration>0?t.timeline.duration:1,r=rm(t),i=[],o=[];for(let c of e){let l=r.get(c.symbolId),d=o.find(u=>u.symbolId===c.symbolId);d||(d={symbolId:c.symbolId,ensure:[]},o.push(d));for(let u of im(c,n)){let p=u.beginSec*1e3,f=u.durSec*1e3;if(f<=0)continue;let m=(g,h)=>{let y={},b={};for(let[v,[I,x]]of Object.entries(h))y[v]=I,b[v]=x;i.push({symbolId:c.symbolId,innerId:g,keyframes:[y,b],durationMs:f,delayMs:p})};for(let g of u.treeB){let h=u.aById.get(g.id);if(!h)continue;let y=h.state,b=g.state,v={};for(let{key:I,prop:x}of KD){let k=y[I],T=b[I];k===void 0&&T===void 0||k!==T&&(k==null||T==null||(v[x]=[k,T]))}Object.keys(v).length>0&&m(g.id,v)}for(let g of u.treeA)u.bById.has(g.id)||m(g.id,{opacity:[1,0]});for(let g of u.treeB){if(u.aById.has(g.id))continue;l.has(g.id)||(d.ensure.push({innerId:g.id,shape:g}),l.add(g.id));let h=g.state.opacity,y=h!==void 0?Number(h):1;m(g.id,{opacity:[0,y]})}}}return i.length===0?{scriptBody:null,symbols:o}:{scriptBody:`
50
+ (function () {
51
+ function start() {
52
+ var specs = ${JSON.stringify(i)};
53
+ for (var i = 0; i < specs.length; i++) {
54
+ var spec = specs[i];
55
+ var symbolEl = document.getElementById(spec.symbolId);
56
+ if (!symbolEl) continue;
57
+ var innerEl = symbolEl.querySelector('[data-svgsketch-inner-id="' + spec.innerId + '"]');
58
+ if (!innerEl || !innerEl.animate) continue;
59
+ try {
60
+ innerEl.animate(spec.keyframes, {
61
+ duration: spec.durationMs,
62
+ delay: spec.delayMs,
63
+ fill: 'forwards',
64
+ easing: 'linear'
65
+ });
66
+ } catch (err) {
67
+ // Element.animate may throw on unsupported property names; skip silently.
68
+ }
69
+ }
70
+ }
71
+ if (document.readyState === 'loading') {
72
+ document.addEventListener('DOMContentLoaded', start);
73
+ } else {
74
+ start();
75
+ }
76
+ })();
77
+ `,symbols:o}}function om(t,e){let n=lb(t,e);return Ps(t,{width:n.width,height:n.height,xmlDeclaration:e.xmlDeclaration??!1,indent:!0})}function ez(t){return t==="class"?"className":t==="for"?"htmlFor":t.replace(/-([a-z])/g,(e,n)=>n.toUpperCase())}function Il(t){return t.replace(/\s([a-z][a-z-]*?)=/g,(e,n)=>n.startsWith("data-")||n.startsWith("aria-")?e:` ${ez(n)}=`)}function sm(t,e){let n=e.componentName??"SvgComponent",r=e.indent??" ",i=e.typescript??!1,o=Pn(t,{width:e.width,height:e.height}),s=[];for(let u of o.body){if(u.kind==="shape"){s.push(`${r}${r}${r}${Il(u.markup)}`);continue}s.push(`${r}${r}${r}${Il(u.open)}`);for(let p of u.members)s.push(`${r}${r}${r}${r}${Il(p.markup)}`);s.push(`${r}${r}${r}${u.close}`)}let a=Vt(o.defs),c=a.length>0,l=o.strippedDocumentCss,d=[];d.push("import React from 'react';"),d.push(""),i?(d.push(`interface ${n}Props {`),d.push(`${r}className?: string;`),d.push(`${r}style?: React.CSSProperties;`),d.push("}"),d.push(""),d.push(`const ${n}: React.FC<${n}Props> = ({ className, style }) => {`)):d.push(`const ${n} = ({ className, style }) => {`),d.push(`${r}return (`),d.push(`${r}${r}<svg xmlns="http://www.w3.org/2000/svg" width="${o.frame.width}" height="${o.frame.height}" viewBox="${o.frame.viewBox}" className={className} style={style}>`),c&&(d.push(`${r}${r}${r}<defs>`),d.push(`${r}${r}${r}${r}${Il(a)}`),d.push(`${r}${r}${r}</defs>`));for(let u of s)d.push(u);return l.length>0&&d.push(`${r}${r}${r}<style>{${JSON.stringify(l)}}</style>`),d.push(`${r}${r}</svg>`),d.push(`${r});`),d.push("};"),d.push(""),d.push(`export default ${n};`),d.push(""),d.join(`
78
+ `)}function am(t,e){let n=e.componentName??"SvgComponent",r=e.indent??" ",i=e.typescript??!1,o=Pn(t,{width:e.width,height:e.height}),s=[];for(let u of o.body){if(u.kind==="shape"){s.push(`${r}${r}${u.markup}`);continue}s.push(`${r}${r}${u.open}`);for(let p of u.members)s.push(`${r}${r}${r}${p.markup}`);s.push(`${r}${r}${u.close}`)}let a=Vt(o.defs),c=a.length>0,l=o.strippedDocumentCss,d=[];d.push("<template>"),d.push(`${r}<svg xmlns="http://www.w3.org/2000/svg" width="${o.frame.width}" height="${o.frame.height}" viewBox="${o.frame.viewBox}" :class="className" :style="style">`),c&&(d.push(`${r}${r}<defs>`),d.push(`${r}${r}${r}${a}`),d.push(`${r}${r}</defs>`));for(let u of s)d.push(u);return l.length>0&&d.push(`${r}${r}<component :is="'style'">${l}</component>`),d.push(`${r}</svg>`),d.push("</template>"),d.push(""),i?d.push('<script setup lang="ts">'):d.push("<script setup>"),d.push(`// ${n}`),i?(d.push("defineProps<{"),d.push(`${r}className?: string;`),d.push(`${r}style?: Record<string, string>;`),d.push("}>();")):(d.push("defineProps({"),d.push(`${r}className: { type: String, default: '' },`),d.push(`${r}style: { type: Object, default: () => ({}) },`),d.push("});")),d.push("</script>"),d.push(""),d.join(`
79
+ `)}var tz=new Set(["circle","ellipse","rectangle","square","line","text","image"]);function Vx(t){return t.replace(/\\/g,"\\\\").replace(/'/g,"\\'")}function wl(t){return t.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${")}function nz(t){let e=t.shape;if(!tz.has(e.type)||t.smil.length>0)return!0;let n=e.state.metadata;return!!(n?.title||n?.description||e.type==="text"&&e.state.isTextPath||/\s(?:clip-path|mask)="url\(#/u.test(t.markup))}function cm(t,e){let n=e.componentName??"createSvg",r=e.indent??" ",i=e.typescript??!1,o=Pn(t,{width:e.width,height:e.height}),s=[];s.push("import * as d3 from 'd3';"),s.push(""),i?s.push(`export function ${n}(container: string | HTMLElement): d3.Selection<SVGSVGElement, unknown, HTMLElement, unknown> {`):s.push(`export function ${n}(container) {`),s.push(`${r}const svg = d3.select(container)`),s.push(`${r}${r}.append('svg')`),s.push(`${r}${r}.attr('xmlns', 'http://www.w3.org/2000/svg')`),s.push(`${r}${r}.attr('width', ${o.frame.width})`),s.push(`${r}${r}.attr('height', ${o.frame.height})`),s.push(`${r}${r}.attr('viewBox', '${o.frame.viewBox}');`),s.push("");let a=Vt(o.defs);a.length>0&&(s.push(`${r}svg.append('defs').html(\`${wl(a)}\`);`),s.push(""));let c=o.strippedDocumentCss;c.length>0&&(s.push(`${r}svg.append('style').text(\`${wl(c)}\`);`),s.push(""));let l=0;for(let d of o.body){if(l++,d.kind==="clip-mask-run"){s.push(`${r}// group`);let g=d.open+d.members.map(h=>h.markup).join("")+d.close;s.push(`${r}svg.append('g').html(\`${wl(g)}\`);`),s.push("");continue}let u=d.shape;if(s.push(`${r}// ${u.type}${u.state.metadata?.name?` \u2014 ${u.state.metadata.name}`:""}`),nz(d)){s.push(`${r}svg.append('g').html(\`${wl(d.markup)}\`);`),s.push("");continue}let p=cb(u),f=hc(u),m=`shape${l}`;s.push(`${r}const ${m} = svg.append('${p}')`);for(let[g,h]of f)s.push(`${r}${r}.attr('${g}', '${Vx(h)}')`);u.type==="text"&&u.state.text&&s.push(`${r}${r}.text('${Vx(u.state.text)}')`),s[s.length-1]=s[s.length-1]+";",s.push("")}return s.push(`${r}return svg;`),s.push("}"),s.push(""),s.join(`
80
+ `)}function rz(t,e){let n=t.state.metadata?.name;return n?n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""):`${t.type}-${e+1}`}var iz=new Set(["fill","fill-opacity","fill-rule","stroke","stroke-width","stroke-opacity","stroke-dasharray","stroke-linecap","opacity","transform","filter"]);function jx(t,e){let n=t.indexOf(" ");return n===-1?t:t.slice(0,n)+` class="${e}"`+t.slice(n)}function lm(t,e){let n=e.indent??" ",r=Pn(t,{width:e.width,height:e.height}),i=0,o=new Map,s=[],a=f=>{o.set(f,rz(f.shape,i)),s.push(f),i++};for(let f of r.body)f.kind==="shape"?a(f):f.members.forEach(a);let c=[];for(let f of s){let m=hc(f.shape),g=[];for(let[h,y]of m)iz.has(h)&&g.push(`${n}${h}: ${y};`);g.length>0&&c.push(`.${o.get(f)} {
81
+ ${g.join(`
18
82
  `)}
19
- }`)}let o=[];for(let l=0;l<i.length;l++){let c=i[l],f=Yo(c,l),d=fe(c),p=d.indexOf(" ");p!==-1&&(d=d.slice(0,p)+` class="${f}"`+d.slice(p)),o.push(`${r}${d}`)}let a=[];a.push("<style>");for(let l of s)a.push(l);a.push("</style>"),a.push(""),a.push(`<svg xmlns="http://www.w3.org/2000/svg" width="${t.width}" height="${t.height}" viewBox="0 0 ${t.width} ${t.height}">`);for(let l of o)a.push(l);return a.push("</svg>"),a.push(""),a.join(`
20
- `)}function Gi(n,e){let t=Kf(n,e),r={...e};switch(r.format){case"svg":return Oi(t,r);case"react":return Li(t,r);case"vue":return Ni(t,r);case"d3":return Bi(t,r);case"css":return zi(t,r);default:throw new Error(`Unsupported code format: ${r.format}`)}}function Kf(n,e){return Array.isArray(n)?{shapes:n,viewboxes:[{id:"default",x:0,y:0,width:e.width??800,height:e.height??600}]}:n}var Kn=class n{_snapshot;constructor(e={}){let{width:t=800,height:r=600,viewboxId:i}=e,s=vn(0,0,t,r,i);this._snapshot=Gr({viewboxes:[s]})}static fromSnapshot(e){let t=new n;return t._snapshot=JSON.parse(JSON.stringify(e)),t}static fromJSON(e,t){let r=Ur(e,t),i=new n;return i._snapshot=r,i}add(e){let t="build"in e&&typeof e.build=="function"?e.build():e;return this._snapshot.shapes.push(t),this}addAll(...e){for(let t of e)this.add(t);return this}remove(e){let t=this._snapshot.shapes.length;return this._snapshot.shapes=this._snapshot.shapes.filter(r=>r.id!==e),this._snapshot.shapes.length<t}get shapes(){return this._snapshot.shapes}findShape(e){return this._snapshot.shapes.find(t=>t.id===e)}size(e,t){return this._snapshot.viewboxes.length>0?(this._snapshot.viewboxes[0].width=e,this._snapshot.viewboxes[0].height=t):this._snapshot.viewboxes=[vn(0,0,e,t)],this}get width(){return this._snapshot.viewboxes[0]?.width??800}get height(){return this._snapshot.viewboxes[0]?.height??600}title(e){return this._ensureMetadata(),this._snapshot.documentMetadata.title=e,this}description(e){return this._ensureMetadata(),this._snapshot.documentMetadata.description=e,this}author(e){return this._ensureMetadata(),this._snapshot.documentMetadata.author=e,this}keywords(...e){return this._ensureMetadata(),this._snapshot.documentMetadata.keywords=e,this}license(e,t){return this._ensureMetadata(),this._snapshot.documentMetadata.license=e,t!==void 0&&(this._snapshot.documentMetadata.licenseUrl=t),this}language(e){return this._ensureMetadata(),this._snapshot.documentMetadata.language=e,this}customMetadata(e){return this._ensureMetadata(),this._snapshot.documentMetadata.customMetadata={...this._snapshot.documentMetadata.customMetadata,...e},this}get meta(){return this._snapshot.documentMetadata}defineSymbol(e,t,r){let i=_(),s=t.map(a=>"build"in a&&typeof a.build=="function"?a.build():a),o={kind:"symbol",id:i,name:e,viewBox:r?.viewBox??"0 0 100 100",shapes:s};return r?.groups&&(o.groups=r.groups),r?.thumbnail&&(o.thumbnail=r.thumbnail),r?.defKind&&(o.defKind=r.defKind),r?.wrapperAttrs&&(o.wrapperAttrs=r.wrapperAttrs),r?.variantAxes&&(o.variantAxes=r.variantAxes),r?.variants&&(o.variants=r.variants),r?.variantThumbnails&&(o.variantThumbnails=r.variantThumbnails),this._pushLibraryDef(o),i}placeSymbolInstance(e,t,r,i,s){let o,a={};typeof i=="number"||i===void 0?o=i:(a=i,o=a.width,s=a.height??s);let l={symbolId:e,x:t,y:r,width:o??100,height:s??100};a.variantKey&&(l.variantKey=a.variantKey),a.symbolOverrides&&(l.symbolOverrides=a.symbolOverrides),a.instancePresentation&&(l.instancePresentation=a.instancePresentation);let c={id:_(),type:"symbol-instance",state:l};return this._snapshot.shapes.push(c),this}removeSymbol(e){if(!this._snapshot.library)return!1;let t=this._snapshot.library.length;return this._snapshot.library=this._snapshot.library.filter(r=>!(r.kind==="symbol"&&r.id===e)),this._snapshot.library.length<t}get symbols(){return(this._snapshot.library??[]).filter(e=>e.kind==="symbol")}defineMarker(e,t,r){let i=_(),s=t.map(a=>"build"in a&&typeof a.build=="function"?a.build():a),o={kind:"marker",id:i,name:e,viewBox:r?.viewBox??"0 0 10 10",refX:r?.refX??5,refY:r?.refY??5,markerWidth:r?.markerWidth??10,markerHeight:r?.markerHeight??10,markerUnits:r?.markerUnits??"strokeWidth",orient:r?.orient??"auto",shapes:s};return r?.groups&&(o.groups=r.groups),r?.thumbnail&&(o.thumbnail=r.thumbnail),this._pushLibraryDef(o),i}defineFilter(e,t,r){let i=_(),s={kind:"filter",id:i,name:e,filters:t};return r?.colorInterpolation&&(s.colorInterpolation=r.colorInterpolation),r?.filterUnits&&(s.filterUnits=r.filterUnits),r?.primitiveUnits&&(s.primitiveUnits=r.primitiveUnits),r?.x!==void 0&&(s.x=r.x),r?.y!==void 0&&(s.y=r.y),r?.width!==void 0&&(s.width=r.width),r?.height!==void 0&&(s.height=r.height),r?.thumbnail&&(s.thumbnail=r.thumbnail),this._pushLibraryDef(s),i}defineLinearGradientLibrary(e,t,r){let i=_(),s="build"in t?t.build():t,{id:o,sourceId:a,...l}=s,c={kind:"linear-gradient",id:i,name:e,gradient:l};return r?.thumbnail&&(c.thumbnail=r.thumbnail),this._pushLibraryDef(c),i}defineRadialGradientLibrary(e,t,r){let i=_(),s="build"in t?t.build():t,{id:o,sourceId:a,...l}=s,c={kind:"radial-gradient",id:i,name:e,gradient:l};return r?.thumbnail&&(c.thumbnail=r.thumbnail),this._pushLibraryDef(c),i}definePatternLibrary(e,t,r){let i=_(),s="build"in t?t.build():t,{id:o,sourceId:a,customPatternId:l,...c}=s,f={kind:"pattern",id:i,name:e,pattern:c};return r?.thumbnail&&(f.thumbnail=r.thumbnail),this._pushLibraryDef(f),i}removeLibraryDef(e){if(!this._snapshot.library)return!1;let t=this._snapshot.library.length;return this._snapshot.library=this._snapshot.library.filter(r=>r.id!==e),this._snapshot.library.length<t}get library(){return this._snapshot.library??[]}_pushLibraryDef(e){this._snapshot.library||(this._snapshot.library=[]);let t=this._snapshot.library.findIndex(r=>r.id===e.id);t>=0?this._snapshot.library[t]=e:this._snapshot.library.push(e)}addClipGroup(e,t,r){this._snapshot.clipMaskGroups||(this._snapshot.clipMaskGroups=[]);let i=_(),s={id:i,type:"clip",clipShapeIds:e,contentShapeIds:t,parentId:null};return r?.clipPathUnits&&(s.clipPathUnits=r.clipPathUnits),r?.clipRule&&(s.clipRule=r.clipRule),r?.rawDefinition&&(s.rawDefinition=r.rawDefinition),this._snapshot.clipMaskGroups.push(s),i}addMaskGroup(e,t,r){this._snapshot.clipMaskGroups||(this._snapshot.clipMaskGroups=[]);let i=_(),s={id:i,type:"mask",clipShapeIds:e,contentShapeIds:t,parentId:null};return r?.maskUnits&&(s.maskUnits=r.maskUnits),r?.maskContentUnits&&(s.maskContentUnits=r.maskContentUnits),r?.maskBounds&&(s.maskBounds=r.maskBounds),r?.maskType&&(s.maskType=r.maskType),r?.rawDefinition&&(s.rawDefinition=r.rawDefinition),this._snapshot.clipMaskGroups.push(s),i}removeClipMaskGroup(e){if(!this._snapshot.clipMaskGroups)return!1;let t=this._snapshot.clipMaskGroups.length;return this._snapshot.clipMaskGroups=this._snapshot.clipMaskGroups.filter(r=>r.id!==e),this._snapshot.clipMaskGroups.length<t}addGuide(e,t,r){this._snapshot.guides||(this._snapshot.guides=[]);let i=_(),s={id:i,orientation:e,position:t,controlPointOffset:0};return r?.color&&(s.color=r.color),r?.opacity!==void 0&&(s.opacity=r.opacity),this._snapshot.guides.push(s),i}removeGuide(e){if(!this._snapshot.guides)return!1;let t=this._snapshot.guides.length;return this._snapshot.guides=this._snapshot.guides.filter(r=>r.id!==e),this._snapshot.guides.length<t}clearGuides(){return this._snapshot.guides=[],this}get guides(){return this._snapshot.guides??[]}addMeasurement(e,t,r){this._snapshot.measurements||(this._snapshot.measurements=[]);let i=_(),s={id:i,type:e,points:t,visible:r?.visible??!0,snapDivisions:r?.snapDivisions??1};return r?.color&&(s.color=r.color),r?.opacity!==void 0&&(s.opacity=r.opacity),this._snapshot.measurements.push(s),i}removeMeasurement(e){if(!this._snapshot.measurements)return!1;let t=this._snapshot.measurements.length;return this._snapshot.measurements=this._snapshot.measurements.filter(r=>r.id!==e),this._snapshot.measurements.length<t}get measurements(){return this._snapshot.measurements??[]}addCustomPattern(e,t,r,i){let s=_();return this._pushLibraryDef(Ke({id:s,name:e,svgContent:t,width:r,height:i})),s}removeCustomPattern(e){let t=this._snapshot.library;if(!t)return!1;let r=t.length;return this._snapshot.library=t.filter(i=>!(i.kind==="pattern"&&i.id===e)),this._snapshot.library.length<r}get customPatterns(){let e=[];for(let t of this._snapshot.library??[]){if(t.kind!=="pattern")continue;let r=Dt(t);r&&e.push(r)}return e}addGroup(e,t){this._snapshot.groups||(this._snapshot.groups=[]);let r=e??_();return this._snapshot.groups.push({id:r,parentId:t??null}),r}removeGroup(e){if(!this._snapshot.groups)return!1;let t=this._snapshot.groups.length;this._snapshot.groups=this._snapshot.groups.filter(r=>r.id!==e);for(let r of this._snapshot.shapes)r.state.groupId===e&&delete r.state.groupId;return this._snapshot.groups.length<t}moveToGroup(e,t){let r=this._snapshot.shapes.find(i=>i.id===e);return r&&(r.state.groupId=t),this}removeFromGroup(e){let t=this._snapshot.shapes.find(r=>r.id===e);return t&&delete t.state.groupId,this}bringToFront(e){let t=this._snapshot.shapes.findIndex(r=>r.id===e);if(t>=0){let[r]=this._snapshot.shapes.splice(t,1);this._snapshot.shapes.push(r)}return this}sendToBack(e){let t=this._snapshot.shapes.findIndex(r=>r.id===e);if(t>=0){let[r]=this._snapshot.shapes.splice(t,1);this._snapshot.shapes.unshift(r)}return this}reorder(e,t){let r=this._snapshot.shapes.findIndex(i=>i.id===e);if(r>=0){let[i]=this._snapshot.shapes.splice(r,1),s=Math.max(0,Math.min(t,this._snapshot.shapes.length));this._snapshot.shapes.splice(s,0,i)}return this}defineVariable(e,t,r,i){this._snapshot.templateVariables||(this._snapshot.templateVariables=[]);let s=this._snapshot.templateVariables.find(o=>o.name===e);if(s)s.type=t,s.defaultValue=r,i?.label!==void 0&&(s.label=i.label),i?.description!==void 0&&(s.description=i.description);else{let o={name:e,type:t,defaultValue:r};i?.label!==void 0&&(o.label=i.label),i?.description!==void 0&&(o.description=i.description),this._snapshot.templateVariables.push(o)}return this}removeVariable(e){return this._snapshot.templateVariables&&(this._snapshot.templateVariables=this._snapshot.templateVariables.filter(t=>t.name!==e)),this}get variables(){return this._snapshot.templateVariables??[]}inspectVariables(){return jr(this._snapshot)}setTimeline(e){return"build"in e&&typeof e.build=="function"?this._snapshot.animationTimeline=e.build():this._snapshot.animationTimeline=e,this}clearTimeline(){return delete this._snapshot.animationTimeline,this}get timeline(){return this._snapshot.animationTimeline}toSVG(e){let{variables:t,...r}=e??{},i=Hr(this._snapshot,t);return Xt(i,r)}toJSON(e){return Vr(this._snapshot,e)}toSnapshot(){return JSON.parse(JSON.stringify(this._snapshot))}toCode(e,t){return Gi(this._snapshot,{...t,format:e})}_ensureMetadata(){this._snapshot.documentMetadata||(this._snapshot.documentMetadata={title:"",description:"",author:"",keywords:[],license:"",licenseUrl:"",language:"en",customMetadata:{}})}};var Vi=class{_track;constructor(e,t){this._track={id:_(),shapeId:e,property:t,keyframes:[],enabled:!0,locked:!1}}id(e){return this._track.id=e,this}keyframe(e,t,r="linear"){return this._track.keyframes.push({id:_(),time:e,value:t,easing:r}),this}keyframeBezier(e,t,r){return this._track.keyframes.push({id:_(),time:e,value:t,easing:"custom-bezier",customBezier:r}),this}keyframeLinear(e,t,r){return this._track.keyframes.push({id:_(),time:e,value:t,easing:"linear-function",linearPoints:r}),this}keyframes(...e){return this._track.keyframes.push(...e.map(t=>t.id?t:{...t,id:_()})),this}disabled(){return this._track.enabled=!1,this}locked(){return this._track.locked=!0,this}motionPath(e){return this._track.motionPath=e,this}motionPathRef(e,t="trackShape"){return this._track.motionPathRef={shapeId:e,mode:t},this}beginTrigger(e,t){return this._track.beginTrigger={type:e,value:t},this}endTrigger(e,t){return this._track.endTrigger={type:e,value:t},this}cycleDuration(e){return this._track.cycleDuration=e,this}cycleRepeats(e){return this._track.cycleRepeats=e,this}infinite(){return this._track.cycleInfinite=!0,this}cycle(e){return this._track.cycleBehavior=e,this}transformOrigin(e,t){return this._track.transformOrigin={x:e,y:t},this}motionRotate(e){return this._track.motionRotate=e,this}additive(e){return this._track.additive=e,this}build(){let e=[...this._track.keyframes].sort((t,r)=>t.time-r.time);return{...this._track,keyframes:e}}},Ui=class{_duration;_loop=!1;_playbackSpeed=1;_tracks=[];constructor(e){this._duration=e}loop(e=!0){return this._loop=e,this}speed(e){return this._playbackSpeed=e,this}duration(e){return this._duration=e,this}addTrack(e){return this._tracks.push(e),this}addTracks(...e){return this._tracks.push(...e),this}buildTimeline(){return{duration:this._duration,loop:this._loop,playbackSpeed:this._playbackSpeed,tracks:this._tracks.map(e=>e.build())}}build(){let e=this.buildTimeline();return{duration:e.duration,loop:e.loop,playbackSpeed:e.playbackSpeed,tracks:e.tracks.map(t=>({id:t.id,shapeId:t.shapeId,property:t.property,enabled:t.enabled,locked:t.locked||void 0,motionPath:t.motionPath,motionPathRef:t.motionPathRef,beginTrigger:t.beginTrigger,endTrigger:t.endTrigger,cycleDuration:t.cycleDuration,cycleRepeats:t.cycleRepeats,cycleInfinite:t.cycleInfinite,cycleBehavior:t.cycleBehavior,transformOrigin:t.transformOrigin,motionRotate:t.motionRotate,additive:t.additive,keyframes:t.keyframes.map(r=>({...r.id?{id:r.id}:{},time:r.time,value:r.value,easing:r.easing,...r.customBezier?{customBezier:r.customBezier}:{},...r.linearPoints?{linearPoints:r.linearPoints}:{}}))}))}}};var ce=class{_id;_type;_state={};constructor(e,t){this._type=e,this._id=t??_()}id(e){return this._id=e,this}locked(e=!0){return this._state.locked=e,this}visible(e=!0){return this._state.visible=e,this}displayMode(e){return this._state.displayMode=e,this}motionOnly(){return this._state.displayMode="motionOnly",this}fill(e,t){return this._state.fillColor=e,this._state.fillType="solid",t!==void 0&&(this._state.fillOpacity=t),this}noFill(){return this._state.fillType="none",this}fillGradient(e){let t="build"in e?e.build():e;return this._state.fillType=t.type,this._state.fillGradient=t,this}fillPattern(e){let t="build"in e?e.build():e;return this._state.fillType="pattern",this._state.fillGradient=t,this}fillOpacity(e){return this._state.fillOpacity=e,this}fillRule(e){return this._state.fillRule=e,this}stroke(e,t){return this._state.borderColor=e,t!==void 0&&(this._state.borderWidth=t),this}noStroke(){return this._state.borderColor="none",this._state.borderWidth=0,this}strokeWidth(e){return this._state.borderWidth=e,this}strokeOpacity(e){return this._state.strokeOpacity=e,this}strokeGradient(e){let t="build"in e?e.build():e;return this._state.strokeType=t.type,this._state.strokeGradient=t,this}strokePattern(e){let t="build"in e?e.build():e;return this._state.strokeType="pattern",this._state.strokeGradient=t,this}strokeLinejoin(e){return this._state.strokeLinejoin=e,this}strokeLinecap(e){return this._state.strokeLinecap=e,this}strokeMiterlimit(e){return this._state.strokeMiterlimit=e,this}dashOffset(e){return this._state.dashOffset=e,this}strokeDasharray(e){return this._state.strokeDasharray=e,this}dash(e,t,r){return this._state.lineStyle=e,e==="custom"&&(t!==void 0&&(this._state.dashLength=t),r!==void 0&&(this._state.gapLength=r)),this}opacity(e){return this._state.opacity=e,this}rotate(e){return this._state.rotation=e,this.refreshTransformMatrix(),this}skew(e,t){return this._state.skewX=e,this._state.skewY=t,this.refreshTransformMatrix(),this}scale(e,t){return this._state.scaleX=e,this._state.scaleY=t??e,this.refreshTransformMatrix(),this}pivot(e,t){return this._state.customPivot={x:e,y:t},this.refreshTransformMatrix(),this}transformMatrix(e){if(e.length<6||!e.slice(0,6).every(Number.isFinite))throw new RangeError("transformMatrix must contain six finite numbers");return this._state.transformMatrix=e.slice(0,6),this}refreshTransformMatrix(){this._state.transformMatrix=et(Sn(this._state,this.defaultTransformPivot()))}defaultTransformPivot(){let e=this._state.customPivot;if(e)return e;let t=this._state.x,r=this._state.y,i=this._state.width,s=this._state.height;if(t!==void 0&&r!==void 0&&i!==void 0&&s!==void 0)return{x:t+i/2,y:r+s/2};let o=this._state.radius;if(t!==void 0&&r!==void 0&&o!==void 0)return{x:t,y:r};let a=this._state.cx,l=this._state.cy;if(a!==void 0&&l!==void 0)return{x:a,y:l};let c=this._state.x1,f=this._state.y1,d=this._state.x2,p=this._state.y2;if(c!==void 0&&f!==void 0&&d!==void 0&&p!==void 0)return{x:(c+d)/2,y:(f+p)/2};let m=this._state.pathPoints;if(m?.[0])return{x:m[0].x,y:m[0].y};let h=this._state.polylinePoints;if(h?.[0])return h[0]}filter(...e){let t=this._state.filters??[];return this._state.filters=[...t,...e],this}dropShadow(e={}){let t={id:`drop-shadow-${_()}`,type:"drop-shadow",enabled:!0,offsetX:e.offsetX??4,offsetY:e.offsetY??4,blurRadius:e.blurRadius??8,spread:e.spread??0,color:e.color??"#000000",opacity:e.opacity??.3};return this.filter(t)}innerShadow(e={}){let t={id:`inner-shadow-${_()}`,type:"inner-shadow",enabled:!0,offsetX:e.offsetX??2,offsetY:e.offsetY??2,blurRadius:e.blurRadius??4,choke:e.choke??0,color:e.color??"#000000",opacity:e.opacity??.5};return this.filter(t)}blur(e,t,r){let i=e??4,s=t??i,o={id:`gaussian-blur-${_()}`,type:"gaussian-blur",enabled:!0,blurX:i,blurY:s,linked:i===s,quality:r?.quality??"normal"};return this.filter(o)}glow(e={}){let t={id:`glow-${_()}`,type:"glow",enabled:!0,color:e.color??"#ffffff",radius:e.radius??10,intensity:e.intensity??.8};return this.filter(t)}innerGlow(e={}){let t={id:`inner-glow-${_()}`,type:"inner-glow",enabled:!0,color:e.color??"#ffffff",radius:e.radius??10,intensity:e.intensity??.8};return this.filter(t)}grayscale(e=1){let t={id:`grayscale-${_()}`,type:"grayscale",enabled:!0,amount:e};return this.filter(t)}sepia(e=1){let t={id:`sepia-${_()}`,type:"sepia",enabled:!0,amount:e};return this.filter(t)}outline(e={}){return this.filter({id:`outline-${_()}`,type:"outline",enabled:!0,width:e.width??3,color:e.color??"#000000",opacity:e.opacity??1,position:e.position??"outside"})}motionBlur(e={}){let t={id:`motion-blur-${_()}`,type:"motion-blur",enabled:!0,distance:e.distance??10,angle:e.angle??0,quality:e.quality??"normal"};return this.filter(t)}pointLight(e={}){let t={id:`point-light-${_()}`,type:"point-light",enabled:!0,x:e.x??100,y:e.y??100,z:e.z??200,color:e.color??"#ffffff",surfaceScale:e.surfaceScale??5,diffuseConstant:e.diffuseConstant??1,specularConstant:e.specularConstant??1,specularExponent:e.specularExponent??20};return this.filter(t)}spotLight(e={}){let t={id:`spot-light-${_()}`,type:"spot-light",enabled:!0,x:e.x??100,y:e.y??0,z:e.z??200,pointsAtX:e.pointsAtX??100,pointsAtY:e.pointsAtY??100,pointsAtZ:e.pointsAtZ??0,coneAngle:e.coneAngle??30,color:e.color??"#ffffff",surfaceScale:e.surfaceScale??5,specularConstant:e.specularConstant??1,specularExponent:e.specularExponent??20};return this.filter(t)}sharpen(e=1){let t={id:`sharpen-${_()}`,type:"sharpen",enabled:!0,amount:e};return this.filter(t)}pixelate(e=8){let t={id:`pixelate-${_()}`,type:"pixelate",enabled:!0,blockSize:e};return this.filter(t)}warp(e={}){let t={id:`warp-${_()}`,type:"warp",enabled:!0,scale:e.scale??10,frequency:e.frequency??.02,octaves:e.octaves??1,warpType:e.warpType??"turbulence"};return this.filter(t)}morphology(e={}){let t=e.radiusX??2,r=e.radiusY??t,i={id:`morphology-${_()}`,type:"morphology",enabled:!0,operator:e.operator??"dilate",radiusX:t,radiusY:r,linked:e.linked??t===r};return this.filter(i)}contouring(e={}){if((e.mode??"discrete")==="table"){let i={id:`contouring-table-${_()}`,type:"contouring-table",enabled:!0,levels:e.levels??4,contrast:e.contrast??1};return this.filter(i)}let r={id:`contouring-discrete-${_()}`,type:"contouring-discrete",enabled:!0,levels:e.levels??4};return this.filter(r)}roundEdges(e=4){let t={id:`round-edges-${_()}`,type:"round-edges",enabled:!0,radius:e};return this.filter(t)}channelPainter(e={}){let t={id:`channel-painter-${_()}`,type:"channel-painter",enabled:!0,red:e.red??1,green:e.green??1,blue:e.blue??1};return this.filter(t)}brightness(e=1){let t={id:`brightness-${_()}`,type:"brightness",enabled:!0,amount:e};return this.filter(t)}contrast(e=1){let t={id:`contrast-${_()}`,type:"contrast",enabled:!0,amount:e};return this.filter(t)}filterOpacity(e=1){let t={id:`opacity-${_()}`,type:"opacity",enabled:!0,amount:e};return this.filter(t)}invert(e=1){let t={id:`invert-${_()}`,type:"invert",enabled:!0,amount:e};return this.filter(t)}hueRotate(e=0){let t={id:`hue-rotate-${_()}`,type:"hue-rotate",enabled:!0,angle:e};return this.filter(t)}saturate(e=1){let t={id:`saturate-${_()}`,type:"saturate",enabled:!0,amount:e};return this.filter(t)}blackAndWhite(e=.5){let t={id:`black-and-white-${_()}`,type:"black-and-white",enabled:!0,threshold:e};return this.filter(t)}duotone(e={}){let t={id:`duotone-${_()}`,type:"duotone",enabled:!0,shadowColor:e.shadowColor??"#000000",highlightColor:e.highlightColor??"#ffffff"};return this.filter(t)}xray(e=1){let t={id:`xray-${_()}`,type:"xray",enabled:!0,intensity:e};return this.filter(t)}noise(e={}){let t={id:`noise-${_()}`,type:"noise",enabled:!0,amount:e.amount??.3,scale:e.scale??1};return this.filter(t)}emboss(e={}){let t={id:`emboss-${_()}`,type:"emboss",enabled:!0,strength:e.strength??1,angle:e.angle??135};return this.filter(t)}filmGrain(e={}){let t={id:`film-grain-${_()}`,type:"film-grain",enabled:!0,amount:e.amount??.3,size:e.size??1};return this.filter(t)}watercolor(e={}){let t={id:`watercolor-${_()}`,type:"watercolor",enabled:!0,wetness:e.wetness??.5,turbulence:e.turbulence??.5};return this.filter(t)}gouache(e={}){let t={id:`gouache-${_()}`,type:"gouache",enabled:!0,thickness:e.thickness??.5,texture:e.texture??.5};return this.filter(t)}inkBlot(e={}){let t={id:`ink-blot-${_()}`,type:"ink-blot",enabled:!0,spread:e.spread??.5,edges:e.edges??.5};return this.filter(t)}crumpledPlastic(e={}){let t={id:`crumpled-plastic-${_()}`,type:"crumpled-plastic",enabled:!0,wrinkles:e.wrinkles??.5,shine:e.shine??.5};return this.filter(t)}riddled(e={}){let t={id:`riddled-${_()}`,type:"riddled",enabled:!0,density:e.density??.5,size:e.size??1};return this.filter(t)}cssClipPath(e){return this._state.cssClipPath=e,this}cssMaskProperties(e){return this._state.cssMaskProperties=e,this}vectorEffect(e){return this._state.vectorEffect=e,this}transformBox(e){return this._state.transformBox=e,this}paintOrder(e){return this._state.paintOrder=e,this}blendMode(e){return this._state.blendMode=e,this}visibility(e){return this._state.visibility=e,this}shapeRendering(e){return this._state.shapeRendering=e,this}filterColorInterpolation(e){return this._state.filterColorInterpolation=e,this}inheritFill(e=!0){return this._state.inheritFill=e,this}inheritStroke(e=!0){return this._state.inheritStroke=e,this}systemLanguage(e){return this._state.systemLanguage=e,this}requiredExtensions(e){return this._state.requiredExtensions=e,this}fillLibrary(e,t="linear-gradient"){return this._state.fillLibraryId=e,this._state.fillType=t,this}strokeLibrary(e,t="linear-gradient"){return this._state.strokeLibraryId=e,this._state.strokeType=t,this}filterLibrary(...e){let t=this._state.filterLibraryIds??[];return this._state.filterLibraryIds=[...t,...e],this}markerStartRef(e){return this._state.markerStart=e,this}markerMidRef(e){return this._state.markerMid=e,this}markerEndRef(e){return this._state.markerEnd=e,this}bind(e,t){let r=this._state.bindings??{};return this._state.bindings={...r,[e]:t},this}metadata(e){return this._state.metadata={...this._state.metadata,...e},this}group(e){return this._state.groupId=e,this}build(){return{id:this._id,type:this._type,state:{...this._state}}}},Wi=class extends ce{constructor(e,t,r){if(r<0)throw new RangeError("Circle radius must be non-negative");super("circle"),this._state.x=e,this._state.y=t,this._state.radius=r}position(e,t){return this._state.x=e,this._state.y=t,this}radius(e){return this._state.radius=e,this}},Hi=class extends ce{constructor(e,t,r,i){if(r<0||i<0)throw new RangeError("Ellipse radii must be non-negative");super("ellipse"),this._state.cx=e,this._state.cy=t,this._state.rx=r,this._state.ry=i}position(e,t){return this._state.cx=e,this._state.cy=t,this}radii(e,t){return this._state.rx=e,this._state.ry=t,this}},ji=class extends ce{constructor(e,t,r,i){if(r<0||i<0)throw new RangeError("Rectangle dimensions must be non-negative");super("rectangle"),this._state.x=e,this._state.y=t,this._state.width=r,this._state.height=i}position(e,t){return this._state.x=e,this._state.y=t,this}size(e,t){return this._state.width=e,this._state.height=t,this}cornerRadius(e){return this._state.cornerRadius=e,this._state.rx=e,this._state.ry=e,this}radii(e,t){return this._state.rx=e,this._state.ry=t,e===t&&(this._state.cornerRadius=e),this}},Ki=class extends ce{constructor(e,t,r){if(r<0)throw new RangeError("Square size must be non-negative");super("square"),this._state.x=e,this._state.y=t,this._state.width=r,this._state.height=r}position(e,t){return this._state.x=e,this._state.y=t,this}size(e){return this._state.width=e,this._state.height=e,this}cornerRadius(e){return this._state.cornerRadius=e,this._state.rx=e,this._state.ry=e,this}radii(e,t){return this._state.rx=e,this._state.ry=t,e===t&&(this._state.cornerRadius=e),this}},Xi=class extends ce{constructor(e,t,r,i){super("line"),this._state.x1=e,this._state.y1=t,this._state.x2=r,this._state.y2=i}from(e,t){return this._state.x1=e,this._state.y1=t,this}to(e,t){return this._state.x2=e,this._state.y2=t,this}markerStart(e){return this._state.startEndpoint=e,this}markerEnd(e){return this._state.endEndpoint=e,this}markers(e,t){return this._state.startEndpoint=e,this._state.endEndpoint=t,this}},Yi=class extends ce{constructor(e,t,r){super("text"),this._state.x=e,this._state.y=t,this._state.text=r}position(e,t){return this._state.x=e,this._state.y=t,this}content(e){return this._state.text=e,this}fontSize(e){return this._state.fontSize=e,this}fontFamily(e){return this._state.fontFamily=e,this}fontWeight(e){return this._state.fontWeight=e,this}fontStyle(e){return this._state.fontStyle=e,this}fontVariant(e){return this._state.fontVariant=e,this}fontVariantLigatures(e){return this._state.fontVariantLigatures=e,this}fontVariantPosition(e){return this._state.fontVariantPosition=e,this}fontVariantCaps(e){return this._state.fontVariantCaps=e,this}fontVariantNumeric(e){return this._state.fontVariantNumeric=e,this}fontVariantEastAsian(e){return this._state.fontVariantEastAsian=e,this}anchor(e){return this._state.textAnchor=e,this}letterSpacing(e){return this._state.letterSpacing=e,this}lineHeight(e){return this._state.lineHeight=e,this}decoration(e){return this._state.textDecoration=e,this}transform(e){return this._state.textTransform=e,this}textPath(e,t=0){return this._state.isTextPath=!0,this._state.textPathPoints=e,this._state.textPathStartOffset=t,this}textPathOffset(e){return this._state.textPathStartOffset=e,this}textPathSide(e){return this._state.textPathSide=e,this}direction(e){return this._state.textDirection=e,this}unicodeBidi(e){return this._state.unicodeBidi=e,this}dominantBaseline(e){return this._state.dominantBaseline=e,this}writingMode(e){return this._state.writingMode=e,this}wordSpacing(e){return this._state.wordSpacing=e,this}baselineShift(e){return this._state.baselineShift=e,this}inlineSize(e){return this._state.inlineSize=e,this}overflowWrap(e){return this._state.overflowWrap=e,this}whiteSpace(e){return this._state.whiteSpace=e,this}fontVariationSettings(e){return this._state.fontVariationSettings=e,this}charOffsets(e){return this._state.charOffsets=e,this}shapeInsideRef(e){return this._state.shapeInsideRef=e,this}shapePadding(e){return this._state.shapePadding=e,this}richTextData(e){let t=gt(e);return this._state.richTextRuns=t,this._state.richTextData=je(t),this}richTextRuns(e){let t=ht(e);return this._state.richTextRuns=t,this._state.richTextData=je(t),this}useRichText(e=!0){return this._state.useRichText=e,this}linePositions(e){return this._state.linePositions=e,this}textLength(e){return this._state.textLength=e,this}lengthAdjust(e){return this._state.lengthAdjust=e,this}},ge=class extends ce{constructor(e,t,r,i){super(e),this._state.cx=t,this._state.cy=r,this._state.radius=i}position(e,t){return this._state.cx=e,this._state.cy=t,this}radius(e){return this._state.radius=e,this}shiftAngle(e){return this._state.shiftAngle=e,this}cornerRadius(e){return this._state.cornerRadius=e,this}},qi=class extends ge{constructor(e,t,r){super("triangle",e,t,r)}},Zi=class extends ge{constructor(e,t,r,i=5){super("ngon",e,t,r),this._state.sides=i}sides(e){return this._state.sides=e,this}},Ji=class extends ge{constructor(e,t,r){super("star",e,t,r),this._state.arms=5,this._state.innerRadiusPercent=40}arms(e){return this._state.arms=e,this}innerRadius(e){return this._state.innerRadiusPercent=e,this}},Qi=class extends ge{constructor(e,t,r){super("cross",e,t,r),this._state.armWidthPercent=35}armWidth(e){return this._state.armWidthPercent=e,this}},es=class extends ge{constructor(e,t,r){super("ring",e,t,r),this._state.innerRadiusPercent=60}innerRadius(e){return this._state.innerRadiusPercent=e,this}},ts=class extends ge{constructor(e,t,r){super("spiral",e,t,r),this._state.turns=3,this._state.thicknessPercent=15,this._state.spiralDirection=1}turns(e){return this._state.turns=e,this}thickness(e){return this._state.thicknessPercent=e,this}direction(e){return this._state.spiralDirection=e,this}},ns=class extends ge{constructor(e,t,r){super("gear",e,t,r),this._state.teeth=8,this._state.toothDepthPercent=25}teeth(e){return this._state.teeth=e,this}toothDepth(e){return this._state.toothDepthPercent=e,this}holeRadius(e){return this._state.holeRadiusPercent=e,this}},rs=class extends ge{constructor(e,t,r){super("arrow",e,t,r),this._state.headWidthPercent=100,this._state.headLengthPercent=35,this._state.shaftWidthPercent=35}headWidth(e){return this._state.headWidthPercent=e,this}headLength(e){return this._state.headLengthPercent=e,this}shaftWidth(e){return this._state.shaftWidthPercent=e,this}},is=class extends ge{constructor(e,t,r){super("heart",e,t,r),this._state.lobeRadiusPercent=50,this._state.cleftDepthPercent=25}lobeRadius(e){return this._state.lobeRadiusPercent=e,this}cleftDepth(e){return this._state.cleftDepthPercent=e,this}},ss=class extends ge{constructor(e,t,r){super("lightning",e,t,r),this._state.boltSegments=3,this._state.boltJaggednessPercent=40,this._state.boltWidthPercent=30}segments(e){return this._state.boltSegments=e,this}jaggedness(e){return this._state.boltJaggednessPercent=e,this}thickness(e){return this._state.boltWidthPercent=e,this}},as=class extends ge{constructor(e,t,r){super("cloud",e,t,r),this._state.cloudBumps=5,this._state.cloudPuffinessPercent=60}bumps(e){return this._state.cloudBumps=e,this}puffiness(e){return this._state.cloudPuffinessPercent=e,this}},os=class extends ge{constructor(e,t,r){super("speechBubble",e,t,r),this._state.tailAngleDeg=45,this._state.tailLengthPercent=40,this._state.tailWidthPercent=25}tailAngle(e){return this._state.tailAngleDeg=e,this}tailLength(e){return this._state.tailLengthPercent=e,this}tailWidth(e){return this._state.tailWidthPercent=e,this}},ot=class extends ce{add(e){let t="build"in e&&typeof e.build=="function"?e.build():e,r=this._state.children??[];return this._state.children=[...r,t],this}addAll(...e){for(let t of e)this.add(t);return this}children(e){return this._state.children=e.map(t=>"build"in t&&typeof t.build=="function"?t.build():t),this}},ls=class extends ot{constructor(e){super("hyperlink"),e!==void 0&&(this._state.href=e)}href(e){return this._state.href=e,this}hrefXlink(e){return this._state.hrefXlink=e,this}target(e){return this._state.linkTarget=e,this}download(e){return this._state.linkDownload=e,this}rel(e){return this._state.linkRel=e,this}ping(e){return this._state.linkPing=e,this}hreflang(e){return this._state.linkHreflang=e,this}type(e){return this._state.linkType=e,this}referrerPolicy(e){return this._state.linkReferrerPolicy=e,this}},us=class extends ot{constructor(){super("switch")}},cs=class extends ot{constructor(){super("container")}},ds=class extends ce{constructor(e){super("view"),e&&(this._state.viewBoxX=e.x,this._state.viewBoxY=e.y,this._state.viewBoxWidth=e.width,this._state.viewBoxHeight=e.height)}viewBox(e,t,r,i){return this._state.viewBoxX=e,this._state.viewBoxY=t,this._state.viewBoxWidth=r,this._state.viewBoxHeight=i,this}name(e){return this._state.viewName=e,this}preserveAspectRatio(e){return this._state.viewPreserveAspectRatio=e,this}zoomAndPan(e){return this._state.viewZoomAndPan=e,this}viewTarget(e){return this._state.viewTarget=e,this}asHome(e=!0){return this}},fs=class extends ot{constructor(e=0,t=0,r=100,i=100){super("svg"),this._state.svgX=e,this._state.svgY=t,this._state.svgWidth=r,this._state.svgHeight=i}position(e,t){return this._state.svgX=e,this._state.svgY=t,this}size(e,t){return this._state.svgWidth=e,this._state.svgHeight=t,this}viewBox(e,t,r,i){return this._state.svgViewBoxX=e,this._state.svgViewBoxY=t,this._state.svgViewBoxWidth=r,this._state.svgViewBoxHeight=i,this}preserveAspectRatio(e){return this._state.svgPreserveAspectRatio=e,this}asRoot(e=!0){return this._state.isRootSvg=e,this}},ps=class extends ce{constructor(e){super("shape-reference"),e!==void 0&&(this._state.targetShapeId=e)}target(e){return this._state.targetShapeId=e,this}offset(e,t){return this._state.offsetX=e,this._state.offsetY=t,this}size(e,t){return this._state.width=e,this._state.height=t,this}},Xn=class extends ce{position(e,t){return this._state.x=e,this._state.y=t,this}size(e,t){return this._state.width=e,this._state.height=t,this}src(e){return this._state.href=e,this}mimeType(e){return this._state.mediaMimeType=e,this}naturalDuration(e){return this._state.naturalDuration=e,this}begin(e){return this._state.begin=e,this}trim(e,t){return this._state.trimStart=e,this._state.trimEnd=t,this}volume(e){return this._state.volume=e,this}muted(e=!0){return this._state.muted=e,this}loop(e=!0){return this._state.loop=e,this}playbackRate(e){return this._state.playbackRate=e,this}fade(e,t){return this._state.fadeInDuration=e,this._state.fadeOutDuration=t,this}language(e){return this._state.systemLanguage=e,this}},ms=class extends Xn{constructor(e){super("video"),this._state.mediaKind="video",e!==void 0&&(this._state.href=e)}poster(e){return this._state.posterHref=e,this}sourceRect(e){return this._state.sourceRect=e,this}},hs=class extends Xn{constructor(e){super("audio"),this._state.mediaKind="audio",e!==void 0&&(this._state.href=e)}},gs=class extends ce{constructor(e=[]){super("path"),this._state.pathPoints=[...e],this._state.pathCurveType="cubic",this._state.pathClosed=!1}points(e){return this._state.pathPoints=[...e],this}addPoint(e,t){let r=this._state.pathPoints??[];return r.push({x:e,y:t}),this._state.pathPoints=r,this}curveType(e){return this._state.pathCurveType=e,this}closed(e=!0){return this._state.pathClosed=e,this}tension(e){return this._state.pathTension=e,this}arcParams(e){return this._state.pathArcParams=e,this}markerStart(e){return this._state.startEndpoint=e,this}markerEnd(e){return this._state.endEndpoint=e,this}markers(e,t){return this._state.startEndpoint=e,this._state.endEndpoint=t,this}toD(){let e=this._state.pathPoints??[],t=this._state.pathCurveType??"CUBIC",r=this._state.pathClosed??!1,i=this._state.pathTension??.5,s=this._state.pathArcParams;return rt(e,t,r,i,s)}},ys=class extends ce{constructor(e=[]){super("polyline"),this._state.polylinePoints=[...e],this._state.polylineClosed=!1}points(e){return this._state.polylinePoints=[...e],this}addPoint(e,t){let r=this._state.polylinePoints??[];return r.push({x:e,y:t}),this._state.polylinePoints=r,this}closed(e=!0){return this._state.polylineClosed=e,this}markerStart(e){return this._state.startEndpoint=e,this}markerEnd(e){return this._state.endEndpoint=e,this}markers(e,t){return this._state.startEndpoint=e,this._state.endEndpoint=t,this}},bs=class extends ce{constructor(e,t,r,i,s){super("image"),this._state.x=e,this._state.y=t,this._state.width=r,this._state.height=i,this._state.href=s}position(e,t){return this._state.x=e,this._state.y=t,this}size(e,t){return this._state.width=e,this._state.height=t,this}src(e){return this._state.href=e,this}preserveAspectRatio(e){return this._state.preserveAspectRatio=e,this}};var Yn=class{_x1;_y1;_x2;_y2;_stops=[];_spreadMethod="pad";_opacity=1;_id;constructor(e=0,t=0,r=1,i=0){this._x1=e,this._y1=t,this._x2=r,this._y2=i,this._id=_()}stop(e,t,r=1){return this._stops.push({offset:e,color:t,opacity:r}),this}direction(e,t,r,i){return this._x1=e,this._y1=t,this._x2=r,this._y2=i,this}spread(e){return this._spreadMethod=e,this}opacity(e){return this._opacity=e,this}build(){return{type:"linear-gradient",id:this._id,x1:this._x1,y1:this._y1,x2:this._x2,y2:this._y2,stops:[...this._stops],spreadMethod:this._spreadMethod,opacity:this._opacity}}},qn=class{_cx=.5;_cy=.5;_fx=.5;_fy=.5;_r=.5;_ry=.5;_rotation=0;_stops=[];_spreadMethod="pad";_opacity=1;_id;constructor(){this._id=_()}center(e,t){return this._cx=e,this._cy=t,this}focus(e,t){return this._fx=e,this._fy=t,this}radius(e,t){return this._r=e,this._ry=t??e,this}rotation(e){return this._rotation=e,this}stop(e,t,r=1){return this._stops.push({offset:e,color:t,opacity:r}),this}spread(e){return this._spreadMethod=e,this}opacity(e){return this._opacity=e,this}build(){return{type:"radial-gradient",id:this._id,cx:this._cx,cy:this._cy,fx:this._fx,fy:this._fy,r:this._r,ry:this._ry,rotation:this._rotation,stops:[...this._stops],spreadMethod:this._spreadMethod,opacity:this._opacity}}},Zn=class{_patternType;_color;_backgroundColor;_scale=1;_rotation=0;_opacity=1;_patternParams;_id;_svgContent;_width;_height;_patternUnits;_patternContentUnits;_patternTransform;_viewBox;_preserveAspectRatio;_x;_y;_customPatternId;constructor(e="stripes",t="#000000",r="#ffffff"){this._patternType=e,this._color=t,this._backgroundColor=r,this._id=_()}scale(e){return this._scale=e,this}rotation(e){return this._rotation=e,this}opacity(e){return this._opacity=e,this}params(e){return this._patternParams=e,this}svgContent(e){return this._svgContent=e,this}size(e,t){return this._width=e,this._height=t,this}patternUnits(e){return this._patternUnits=e,this}patternContentUnits(e){return this._patternContentUnits=e,this}patternTransform(e){return this._patternTransform=e,this}viewBox(e){return this._viewBox=e,this}preserveAspectRatio(e){return this._preserveAspectRatio=e,this}position(e,t){return this._x=e,this._y=t,this}customPatternId(e){return this._customPatternId=e,this}build(){let e,t,r;if(this._svgContent!==void 0)e=this._svgContent,t=this._width??10,r=this._height??10;else{let s=fi(this._patternType,this._scale,this._color,this._backgroundColor,this._patternParams);e=s.svgContent,t=this._width??s.width,r=this._height??s.height}let i={type:"pattern",id:this._id,patternType:this._svgContent!==void 0?"custom":this._patternType,color:this._color,backgroundColor:this._backgroundColor,scale:this._scale,rotation:this._rotation,opacity:this._opacity,svgContent:e,width:t,height:r,patternUnits:this._patternUnits??"userSpaceOnUse",patternParams:this._patternParams,patternTransform:this._patternTransform??(this._rotation?`rotate(${this._rotation})`:void 0)};return this._patternContentUnits&&(i.patternContentUnits=this._patternContentUnits),this._viewBox&&(i.viewBox=this._viewBox),this._preserveAspectRatio&&(i.preserveAspectRatio=this._preserveAspectRatio),this._x!==void 0&&(i.x=this._x),this._y!==void 0&&(i.y=this._y),this._customPatternId&&(i.customPatternId=this._customPatternId),i}};function Xf(n=0,e=0,t=1,r=0){return new Yn(n,e,t,r)}function Yf(){return new qn}function qf(n="stripes",e="#000000",t="#ffffff"){return new Zn(n,e,t)}var el={rows:4,cols:4,style:"classic",tabDepthPercent:20,tabPattern:"random",seed:1},Zf=.04,Jf=0;function Qf(n){let e=n>>>0;return()=>{e=e+1831565813>>>0;let t=e;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}}function F(n){return Number(n.toFixed(3)).toString()}function ep(n,e,t,r,i,s,o,a,l,c,f,d){return[[0,0],[.2,a],[.5+l+f,-s+c],[.5-s+l,s+c],[.5-2*s+l-f,3*s+c],[.5+2*s+l-f,3*s+c],[.5+s+l,s+c],[.5+l+f,-s+c],[.8,d],[1,0]].map(([m,h])=>{let g=e+m*r,b=t+h*i*o;return n?{x:g,y:b}:{x:b,y:g}})}function qo(n,e,t,r,i,s,o,a,l,c,f){let d=[],p=(v,w)=>l==="alternating"?0:v+c()*(w-v),m=()=>c()<.5,h=p(-a,a),g=l==="alternating"?f%2===0:m(),b=null,$=h,k=p(-a,a),S=p(-a,a),x=p(-a,a);h=p(-a,a);for(let v=0;v<n;v++){v>0&&(b=g,g=l==="alternating"?(f+v)%2===0:m(),$=g===b?-h:h,k=p(-a,a),S=p(-a,a),x=p(-a,a),h=p(-a,a));let w=g?-1:1,T=t+v*i;d.push(ep(e,T,r,i,s,o,w,$,k,S,x,h))}return d}function Zo(n,e,t,r,i,s,o){let a=2*s;return[[0,0],[.2,0],[.4,0],[.4,a],[.4,a],[.6,a],[.6,a],[.6,0],[.8,0],[1,0]].map(([c,f])=>{let d=e+c*r,p=t+f*i*o;return n?{x:d,y:p}:{x:p,y:d}})}function Jo(n,e){return n+` C ${F(e[1].x)} ${F(e[1].y)} ${F(e[2].x)} ${F(e[2].y)} ${F(e[3].x)} ${F(e[3].y)} C ${F(e[4].x)} ${F(e[4].y)} ${F(e[5].x)} ${F(e[5].y)} ${F(e[6].x)} ${F(e[6].y)} C ${F(e[7].x)} ${F(e[7].y)} ${F(e[8].x)} ${F(e[8].y)} ${F(e[9].x)} ${F(e[9].y)}`}function Qo(n,e){return n+` C ${F(e[8].x)} ${F(e[8].y)} ${F(e[7].x)} ${F(e[7].y)} ${F(e[6].x)} ${F(e[6].y)} C ${F(e[5].x)} ${F(e[5].y)} ${F(e[4].x)} ${F(e[4].y)} ${F(e[3].x)} ${F(e[3].y)} C ${F(e[2].x)} ${F(e[2].y)} ${F(e[1].x)} ${F(e[1].y)} ${F(e[0].x)} ${F(e[0].y)}`}function tp(n,e={}){let t={...el,...e};if(t.rows<1||t.cols<1)throw new Error("generatePuzzlePieces: rows and cols must be >= 1");if(!Number.isFinite(n.width)||!Number.isFinite(n.height))throw new Error("generatePuzzlePieces: bounds must have finite width/height");if(n.width<=0||n.height<=0)throw new Error("generatePuzzlePieces: bounds must have positive width/height");let{rows:r,cols:i,style:s,tabDepthPercent:o,tabPattern:a,seed:l}=t,c=Qf(l),f=n.width/i,d=n.height/r,p=Math.max(0,Math.min(.4,o/200)),m=(s==="classic"||s==="curved")&&p>0,h=s==="square-tabs"&&p>0,g=s==="classic"&&a==="random"?Zf:Jf,b=[];for(let S=0;S<r-1;S++){let x=n.y+(S+1)*d;if(m)b.push(qo(i,!0,n.x,x,f,d,p,g,a,c,S));else if(h){let v=[];for(let w=0;w<i;w++){let T=a==="alternating"?(S+w)%2===0?1:-1:c()<.5?1:-1;v.push(Zo(!0,n.x+w*f,x,f,d,p,T))}b.push(v)}else b.push(new Array(i).fill(null))}let $=[];for(let S=0;S<i-1;S++){let x=n.x+(S+1)*f;if(m)$.push(qo(r,!1,n.y,x,d,f,p,g,a,c,S));else if(h){let v=[];for(let w=0;w<r;w++){let T=a==="alternating"?(w+S)%2===0?1:-1:c()<.5?1:-1;v.push(Zo(!1,n.y+w*d,x,d,f,p,T))}$.push(v)}else $.push(new Array(r).fill(null))}let k=[];for(let S=0;S<r;S++)for(let x=0;x<i;x++){let v=n.x+x*f,w=n.y+S*d,T=v+f,P=w+d,R=`M ${F(v)} ${F(w)}`;if(S===0)R+=` L ${F(T)} ${F(w)}`;else{let M=b[S-1][x];M?R=Jo(R,M):R+=` L ${F(T)} ${F(w)}`}if(x===i-1)R+=` L ${F(T)} ${F(P)}`;else{let M=$[x][S];M?R=Jo(R,M):R+=` L ${F(T)} ${F(P)}`}if(S===r-1)R+=` L ${F(v)} ${F(P)}`;else{let M=b[S][x];M?R=Qo(R,M):R+=` L ${F(v)} ${F(P)}`}if(x===0)R+=` L ${F(v)} ${F(w)}`;else{let M=$[x-1][S];M?R=Qo(R,M):R+=` L ${F(v)} ${F(w)}`}R+=" Z",k.push({id:`puzzle-${l}-r${S}-c${x}`,row:S,col:x,d:R})}return k}var rl=[1,2,3,4,5,6,7,8,9],np={easy:{minGivens:40,maxGivens:45,maxRating:"singles"},medium:{minGivens:34,maxGivens:39,maxRating:"hidden-singles"},hard:{minGivens:28,maxGivens:33,maxRating:"search"},expert:{minGivens:24,maxGivens:27,maxRating:"search"}};function Yt(n){return n.map(e=>[...e])}function rp(){return Array.from({length:9},()=>Array.from({length:9},()=>0))}function il(n){let e=n>>>0;return()=>{e=e+1831565813>>>0;let t=e;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}}function sl(n,e){let t=[...n];for(let r=t.length-1;r>0;r--){let i=Math.floor(e()*(r+1));[t[r],t[i]]=[t[i],t[r]]}return t}function Pt(n){return 1<<n-1}function al(n){let e=0,t=n;for(;t;)t&=t-1,e++;return e}function ip(n){for(let e=1;e<=9;e++)if(n===Pt(e))return e;return 0}function xs(n,e){return Math.floor(n/3)*3+Math.floor(e/3)}function Ss(n){let e=0;for(let t of n)for(let r of t)r!==0&&e++;return e}function sp(n){if(!Number.isFinite(n))return 1;let e=Math.floor(n);return e===0?1:e}function ol(n,e){if(!Array.isArray(n)||n.length!==9)return e.push("Grid must contain 9 rows."),!1;let t=!0;for(let r=0;r<9;r++){if(!Array.isArray(n[r])||n[r].length!==9){e.push(`Row ${r+1} must contain 9 cells.`),t=!1;continue}for(let i=0;i<9;i++){let s=n[r][i];(!Number.isInteger(s)||s<0||s>9)&&(e.push(`Cell R${r+1}C${i+1} must be a digit from 0 to 9.`),t=!1)}}return t}function ll(n,e){let t=!0,r=(i,s)=>{let o=0;for(let a of s){if(a===0)continue;let l=Pt(a);if(o&l){e.push(`${i} contains duplicate ${a}.`),t=!1;return}o|=l}};for(let i=0;i<9;i++)r(`Row ${i+1}`,n[i]);for(let i=0;i<9;i++)r(`Column ${i+1}`,n.map(s=>s[i]));for(let i=0;i<9;i+=3)for(let s=0;s<9;s+=3){let o=[];for(let a=i;a<i+3;a++)for(let l=s;l<s+3;l++)o.push(n[a][l]);r(`Box ${Math.floor(i/3)*3+Math.floor(s/3)+1}`,o)}return t}function $s(n){let e=Array.from({length:9},()=>0),t=Array.from({length:9},()=>0),r=Array.from({length:9},()=>0);for(let i=0;i<9;i++)for(let s=0;s<9;s++){let o=n[i][s];if(o===0)continue;let a=Pt(o),l=xs(i,s);if(e[i]&a||t[s]&a||r[l]&a)return null;e[i]|=a,t[s]|=a,r[l]|=a}return{rows:e,cols:t,boxes:r}}function vs(n,e,t,r,i){return 511&~(t[n]|r[e]|i[xs(n,e)])}function ul(n,e,t){let r=$s(n);if(!r)return[];let i=Yt(n),s=[],{rows:o,cols:a,boxes:l}=r,c=()=>{if(s.length>=e)return;let f=-1,d=-1,p=0,m=10;for(let g=0;g<9;g++){for(let b=0;b<9;b++){if(i[g][b]!==0)continue;let $=vs(g,b,o,a,l),k=al($);if(k===0)return;if(k<m&&(f=g,d=b,p=$,m=k,k===1))break}if(m===1)break}if(f===-1){s.push(Yt(i));return}let h=rl.filter(g=>p&Pt(g));t&&(h=sl(h,t));for(let g of h){let b=Pt(g),$=xs(f,d);if(i[f][d]=g,o[f]|=b,a[d]|=b,l[$]|=b,c(),l[$]&=~b,a[d]&=~b,o[f]&=~b,i[f][d]=0,s.length>=e)return}};return c(),s}function ap(n){let e=rp(),t=il(n),[r]=ul(e,1,t);if(!r)throw new Error("generateSudokuPuzzle: failed to generate solved grid");return r}function op(n){let e=$s(n);if(!e)return null;for(let t=0;t<9;t++)for(let r=0;r<9;r++){if(n[t][r]!==0)continue;let i=vs(t,r,e.rows,e.cols,e.boxes);if(al(i)===1)return{row:t,col:r,value:ip(i)}}return null}function lp(n){let e=$s(n);if(!e)return null;let t=r=>{for(let i of rl){let s=Pt(i),o=null;for(let a of r)if(!(n[a.row][a.col]!==0||!(vs(a.row,a.col,e.rows,e.cols,e.boxes)&s))){if(o){o=null;break}o=a}if(o)return{...o,value:i}}return null};for(let r=0;r<9;r++){let i=t(Array.from({length:9},(s,o)=>({row:r,col:o})));if(i)return i}for(let r=0;r<9;r++){let i=t(Array.from({length:9},(s,o)=>({row:o,col:r})));if(i)return i}for(let r=0;r<9;r+=3)for(let i=0;i<9;i+=3){let s=[];for(let a=r;a<r+3;a++)for(let l=i;l<i+3;l++)s.push({row:a,col:l});let o=t(s);if(o)return o}return null}function tl(n){let e=Yt(n),t=!1;for(;Ss(e)<81;){let r=op(e);if(r){e[r.row][r.col]=r.value;continue}let i=lp(e);if(i){t=!0,e[i.row][i.col]=i.value;continue}return"search"}return t?"hidden-singles":"singles"}function nl(n,e){let t={singles:0,"hidden-singles":1,search:2};return t[n]<=t[e]}function Jn(n,e={}){let t=[];return ol(n,t)?ll(n,t)?ul(n,Math.max(1,Math.floor(e.maxSolutions??2))):[]:[]}function up(n){let e=[];if(!ol(n,e))return{valid:!1,unique:!1,solution:null,errors:e};if(ll(n,e),e.length>0)return{valid:!1,unique:!1,solution:null,errors:e};let r=Jn(n,{maxSolutions:2});return r.length===0?e.push("Puzzle has no solution."):r.length>1&&e.push("Puzzle has more than one solution."),{valid:e.length===0,unique:r.length===1,solution:r[0]?Yt(r[0]):null,errors:e}}function cp(n){let e=n.difficulty,t=np[e];if(!t)throw new Error(`generateSudokuPuzzle: unsupported difficulty "${e}"`);let r=sp(n.seed);for(let i=0;i<30;i++){let s=r+i*104729>>>0,o=il(s),a=ap(s),l=Yt(a),c=t.minGivens+Math.floor(o()*(t.maxGivens-t.minGivens+1)),f=sl(Array.from({length:81},(h,g)=>({row:Math.floor(g/9),col:g%9})),o);for(let h of f){if(Ss(l)<=c)break;let g=l[h.row][h.col];if(l[h.row][h.col]=0,Jn(l,{maxSolutions:2}).length!==1){l[h.row][h.col]=g;continue}let $=tl(l);nl($,t.maxRating)||(l[h.row][h.col]=g)}let d=Ss(l),p=tl(l);if(Jn(l,{maxSolutions:2}).length===1&&d>=t.minGivens&&d<=t.maxGivens&&nl(p,t.maxRating))return{puzzle:l,solution:a,difficulty:e,seed:r,givens:d,rating:p}}throw new Error(`generateSudokuPuzzle: unable to generate a ${e} puzzle`)}var cl="ABCDEFGHIJKLMNOPQRSTUVWXYZ";var dp={E:{direction:"E",dr:0,dc:1},S:{direction:"S",dr:1,dc:0},SE:{direction:"SE",dr:1,dc:1},NE:{direction:"NE",dr:-1,dc:1},W:{direction:"W",dr:0,dc:-1},N:{direction:"N",dr:-1,dc:0},NW:{direction:"NW",dr:-1,dc:-1},SW:{direction:"SW",dr:1,dc:-1}};function fl(n){if(!Number.isFinite(n))return 1;let e=Math.floor(n);return e===0?1:e}function pl(n){let e=n>>>0;return()=>{e=e+1831565813>>>0;let t=e;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}}function _t(n){let e=globalThis.Intl.Segmenter;return e?Array.from(new e(void 0,{granularity:"grapheme"}).segment(n),t=>t.segment.normalize("NFC")):Array.from(n.normalize("NFC"))}function fp(n,e,t,r){return n>=0&&e>=0&&n<r&&e<t}function ks(n,e){return Array.from({length:e},()=>Array.from({length:n},()=>!0))}function ml(n,e,t,r){if(!t)return ks(n,e);if(!Array.isArray(t)||t.length!==e)return r.push(`Mask must contain exactly ${e} rows.`),ks(n,e);let i=[];for(let s=0;s<e;s++){if(!Array.isArray(t[s])||t[s].length!==n)return r.push(`Mask row ${s+1} must contain exactly ${n} cells.`),ks(n,e);i.push(t[s].map(Boolean))}return i}function pp(n){let e=0;for(let t of n)for(let r of t)r&&e++;return e}function mp(n){return n.trim().normalize("NFC")}function hp(n){return n.replace(/\r/g,"").split(/[,\n]+/).map(e=>e.trim()).filter(e=>e.length>0)}function hl(n,e){let t=[];return n.across&&(t.push("E"),e&&t.push("W")),n.down&&(t.push("S"),e&&t.push("N")),n.diagonal&&(t.push("SE","NE"),e&&t.push("NW","SW")),t}function gp(n,e,t,r,i,s,o,a){let l=_t(n),c=[];for(let f=0;f<l.length;f++){let d=e+r.dr*f,p=t+r.dc*f;if(!fp(d,p,s,o)||!i[d][p])return null;c.push({row:d,col:p,grapheme:l[f]})}return{word:n,graphemes:l,row:e,col:t,direction:r.direction,dr:r.dr,dc:r.dc,cells:c,jitter:a}}function gl(n,e,t,r,i,s){let o=[];for(let a of e){let l=dp[a];for(let c=0;c<i;c++)for(let f=0;f<r;f++){let d=gp(n,c,f,l,t,r,i,s());d&&o.push(d)}}return o}function yl(n){let e=[],t=[],r=[],i=Math.floor(n.width),s=Math.floor(n.height);(!Number.isInteger(i)||i<2||i>64)&&e.push("Width must be an integer from 2 to 64."),(!Number.isInteger(s)||s<2||s>64)&&e.push("Height must be an integer from 2 to 64.");let o=hl(n.axes,n.allowBackwards);o.length===0&&e.push("At least one word direction must be enabled.");let a=ml(Math.max(1,i),Math.max(1,s),n.mask,e),l=pp(a);l===0&&e.push("Mask must contain at least one active cell.");let c=new Set,f=[];for(let m of n.words){let h=mp(m);if(h){if(/\s/u.test(h)){r.push({input:m,reason:"Words cannot contain whitespace."});continue}if(c.has(h)){r.push({input:m,reason:"Duplicate word."});continue}c.add(h),f.push(h)}}f.length===0&&e.push("Enter at least one word.");let d=pl(fl(n.seed));if(e.length===0)for(let m=f.length-1;m>=0;m--){let h=f[m];gl(h,o,a,i,s,d).length===0&&(r.push({input:h,reason:"No legal placement exists for the current size, mask, and directions."}),f.splice(m,1))}r.length>0&&e.push(`${r.length} word${r.length===1?"":"s"} rejected.`);let p=Math.max(0,l);return f.length>p&&t.push("The word count exceeds the active cell count; overlaps may be required for this puzzle."),{valid:e.length===0,acceptedWords:f,rejectedWords:r,errors:e,warnings:t,minWords:1,maxWords:p,activeCells:l,directions:o}}function yp(n,e){for(let t of e.cells){let r=n[t.row][t.col];if(r!==null&&r!==t.grapheme)return!0}return!1}function bp(n,e){let t=[];for(let r of e.cells)n[r.row][r.col]===null&&(t.push({row:r.row,col:r.col}),n[r.row][r.col]=r.grapheme);return t}function Sp(n,e){for(let t of e)n[t.row][t.col]=null}function dl(n,e){let t=0;for(let r of e.cells)n[r.row][r.col]===r.grapheme&&t++;return t}function xp(n){return{word:n.word,row:n.row,col:n.col,direction:n.direction,path:n.cells.map(e=>({...e}))}}function $p(n){let e=n.fillerAlphabet??cl,t=typeof e=="string"?_t(e):e.flatMap(i=>_t(i)),r=t.filter((i,s)=>i.trim()&&t.indexOf(i)===s);return r.length>0?r:_t(cl)}function vp(n){let e=Math.floor(n.width),t=Math.floor(n.height),r=fl(n.seed),i=yl({...n,width:e,height:t,seed:r});if(!i.valid)throw new Error(`generateWordSearch: ${i.errors[0]??"invalid options"}`);let s=ml(e,t,n.mask,[]),o=Math.max(1,Math.floor(n.maxBacktrackNodes??15e4));for(let a=0;a<24;a++){let l=pl(r+a*104729>>>0),c=i.directions,f=new Map;for(let k of i.acceptedWords)f.set(k,gl(k,c,s,e,t,l));let d=[...i.acceptedWords].sort((k,S)=>{let x=f.get(k)?.length??0,v=f.get(S)?.length??0;return x!==v?x-v:_t(S).length-_t(k).length}),p=Array.from({length:t},(k,S)=>Array.from({length:e},(x,v)=>s[S][v]?null:"")),m=[],h=new Map,g=0,b=k=>{if(++g>o)return!1;if(k>=d.length)return!0;let S=d[k],x=[...f.get(S)??[]].filter(v=>!yp(p,v)).sort((v,w)=>{let T=dl(p,w)-dl(p,v);if(T!==0)return T;let P=(h.get(v.direction)??0)-(h.get(w.direction)??0);return P!==0?P:v.jitter-w.jitter});for(let v of x){let w=bp(p,v);if(m.push(xp(v)),h.set(v.direction,(h.get(v.direction)??0)+1),b(k+1))return!0;h.set(v.direction,(h.get(v.direction)??1)-1),m.pop(),Sp(p,w)}return!1};if(!b(0))continue;let $=$p(n);for(let k=0;k<t;k++)for(let S=0;S<e;S++)s[k][S]?p[k][S]===null&&(p[k][S]=$[Math.floor(l()*$.length)]):p[k][S]="";return{width:e,height:t,grid:p,mask:s.map(k=>[...k]),normalizedWords:[...i.acceptedWords],placements:[...m],seed:r,title:n.title,creator:n.creator,lint:i}}throw new Error("generateWordSearch: unable to place all words with the current settings")}function kp(n,e,t){let r=!1;for(let i=0,s=t.length-1;i<t.length;s=i++){let o=t[i],a=t[s];o.y>e!=a.y>e&&n<(a.x-o.x)*(e-o.y)/(a.y-o.y)+o.x&&(r=!r)}return r}function Tp(){let n=[];for(let e=0;e<10;e++){let t=e%2===0?.5:.23,r=-Math.PI/2+e*Math.PI/5;n.push({x:.5+Math.cos(r)*t,y:.5+Math.sin(r)*t})}return n}function wp(n,e,t){let r=Math.max(1,Math.floor(n)),i=Math.max(1,Math.floor(e)),s=Tp();return Array.from({length:i},(o,a)=>Array.from({length:r},(l,c)=>{let f=(c+.5)/r,d=(a+.5)/i,p=f*2-1,m=d*2-1;switch(t){case"rectangle":return!0;case"circle":return p*p+m*m<=1;case"triangle":return d>=.08&&d<=.95&&Math.abs(p)<=d;case"diamond":return Math.abs(p)+Math.abs(m)<=1;case"star":return kp(f,d,s);case"heart":{let h=p*1.25,g=-m*1.25;return Math.pow(h*h+g*g-1,3)-h*h*g*g*g<=0}case"cross":return Math.abs(p)<=.32||Math.abs(m)<=.32;default:return!0}}))}export{rs as Arrow,hs as Audio,ro as BUILTIN_MARKER_ID_MAP,vu as COLLAB_PROTOCOL_VERSION,te as COMMON_PROP_DEFAULTS,Ms as COMMON_TRANSFORM_NODE_DEFAULTS,ve as CURRENT_SCHEMA_VERSION,Wi as Circle,as as Cloud,cs as Container,ot as ContainerShapeBuilder,Qi as Cross,$c as DEFAULT_COORDINATE_PRECISION,on as DEFAULT_RICH_TEXT_STYLE,Kn as Document,Kn as DocumentBuilder,tr as EASING_CURVES,er as EasingType,Hi as Ellipse,ns as Gear,is as Heart,ls as Hyperlink,hn as IDENTITY_AFFINE,bs as ImageShape,Os as KNOWN_STATE_KEYS,vo as LIBRARY_EMIT_ORDER,ss as Lightning,Xi as Line,Yn as LinearGradientBuilder,mi as MARKER_HEIGHT,Fn as MARKER_VIEWBOX,pi as MARKER_WIDTH,vc as MAX_COORDINATE_PRECISION,Wa as MIGRATIONS,Zi as NGon,Dl as NON_WIRE_PROP_KEYS,qt as NUMERIC_SHAPE_TRANSFORM_STATE_KEYS,fs as NestedSvg,tn as NodeSchemaRegistry,el as PUZZLE_DEFAULTS,gs as Path,Rs as PathCurveType,bl as PathPointType,Zn as PatternBuilder,ys as Polyline,Ct as RICH_TEXT_STYLE_KEYS,qn as RadialGradientBuilder,ji as Rectangle,es as Ring,As as SERIALIZED_SHAPE_STATE_KEYS,Is as SHAPE_TRANSFORM_STATE_KEYS,or as SceneGraph,We as SceneNode,ce as ShapeBuilder,ps as ShapeReference,os as SpeechBubble,ts as Spiral,Ki as Square,Ji as Star,us as Switch,Yi as Text,Ui as Timeline,Vi as Track,qi as Triangle,ms as Video,ds as View,Xe as affine,Dr as affineFromArray,et as affineToArray,Nm as almostEqualAffine,zm as applyAffineToPoint,Gm as applyAffineToVector,hu as applyOpToSnapshot,Ra as applyOpsInPlace,gu as applyOpsToSnapshot,Aa as applyOpsToSnapshotWithAccepted,un as applyRichTextFormat,Xl as applyTextSplice,En as applyTextTransform,Uo as arcEndpointToCenter,Fo as areTracksTimingEquivalent,Ea as around,Ri as buildCompoundTransformValues,at as buildSmilKeyframeData,Ba as canonicalPolygonTransformString,Gt as canonicalTransformString,fa as collaborationResourceKey,Cn as collectMarkerReferences,Bn as collectReferencedLibraryDefs,Hd as collectReferencedMarkerIds,en as compareOrderKeys,Sn as composeLegacyTransformMatrix,Qr as computeArrowVertices,ri as computeCloudPath,Jr as computeCrossVertices,Ht as computeDashArray,li as computeFlowchartBoxPath,ai as computeGearPath,Xa as computeGearVertices,ni as computeHeartPath,ti as computeLightningVertices,Pn as computePolygonVertices,oi as computeRectanglePath,ii as computeRingPath,ei as computeSpeechBubbleVertices,si as computeSpiralPath,rt as computeSplinePath,Zr as computeStarVertices,Gr as createDocument,pt as createSceneNode,pc as createShape,vn as createViewbox,wp as createWordSearchPrimitiveMask,Ci as cubicBezierExtent1D,Ke as customPatternDefToLibraryDef,br as declaredRichTextDeltaKeys,Vm as decomposeAffine2D,Ap as defaultVariableMode,tu as deriveRichTextFormatRanges,je as deriveSegments,Kl as deriveTextSplice,Su as downTranslateAnimationKeyframeOps,$u as downTranslateCollectionMoveOps,ku as downTranslateDocumentFieldOps,bu as downTranslateScenePlaceOps,xu as downTranslateTextFormatOps,Wo as ellipticalArcBounds,q as escXml,jr as extractVariables,di as filterAttr,bt as findShapeById,nn as flattenShapeStateTree,Ue as flattenStateExtra,Na as foldLegacyAncestorTransformIntoMatrix,Wd as forEachLibraryRefInState,Ud as forEachMarkerRefInState,Mn as forEachReachableShape,Vd as forEachShapeInLibraryDefs,jl as formatOperationValidationIssues,Si as formatSmilKeySpline,xe as formatSmilKeyTime,pn as freezeSiblingOrderKeys,Gi as generateCode,zi as generateCssCode,Bi as generateD3Code,_ as generateId,fi as generatePatternSvgContent,tp as generatePuzzlePieces,Li as generateReactCode,cp as generateSudokuPuzzle,Oi as generateSvgCode,Ni as generateVueCode,vp as generateWordSearch,Xd as getBuiltInMarkerDefs,Pp as getEasingCubicBezier,kc as getEffectivePrecision,Io as getKeyframeCubicBezier,$t as getMarkerDescriptors,Dn as getPatternElements,wi as getSmilAdditive,kt as getSmilBeginValue,Tt as getSmilFillMode,Pi as getSmilMotionKeyPoints,Ti as getSmilRepeatCount,ki as getSmilSetBeginValue,st as getSmilTrackDuration,hl as getWordSearchDirections,sr as initialOrderKeys,Bm as invertAffine,xi as isDefaultKeyPoints,Gn as isDefaultKeyTimes,Bt as isFiniteAffineArray,Fa as isIdentityAffine,Do as isIdentityLinearSplines,$i as isIndefiniteSetTrack,cn as isReusablePatternTile,vi as isSetSequenceTrack,Qt as isValidOrderKey,It as keyBetween,ir as keysBetween,In as legacyEndpointMarkerId,Xf as linearGradient,yl as lintWordSearchOptions,yu as materializeSceneTreeOrderKeys,Da as matrixTransformPart,au as maxCollaborationTimestamp,hr as mergeRichTextStyle,Lr as migrateSnapshot,Ar as moveResourceById,ie as multiplyAffine,O as nodeSchemas,ht as normalizeRichTextRuns,Le as normalizeRichTextStyle,ln as normalizeRichTextStyleDelta,Ae as orderSiblings,Ur as parseDocument,Fr as parseSvgTransformList,xc as parseVariableArgs,hp as parseWordSearchWords,ft as partitionShapeStateTree,ar as partitionStateExtra,Ho as pathDataBounds,qf as pattern,Dt as patternLibraryDefToCustomPatternDef,sa as patternTileSize,_i as planTransformFusion,Lt as projectSceneTreeOntoClipMaskGroups,Ta as projectSceneTreeOntoShapes,ou as promoteRebasedShapeUpdateClock,Di as quadraticBezierExtent1D,Yf as radialGradient,eu as rebaseRichTextFormatRanges,ru as rebaseRichTextRuns,Co as reflectCubicBezier,be as removeResourceById,fr as removeResourceByKey,mr as removeResourceByName,va as removeTrackKeyframe,Ii as renderAnimationElements,Be as renderBuiltinMarkerDefs,ao as renderCircle,oo as renderEllipse,Ld as renderFilterDefs,Ao as renderFilterLibraryDef,ui as renderFilterPrimitive,to as renderFilterPrimitivesForType,yo as renderFlowchartBox,mo as renderImage,ko as renderLibraryDef,Nn as renderLibraryDefs,uo as renderLine,Po as renderLinearGradientLibraryDef,wo as renderMarkerLibraryDef,Ro as renderPatternLibraryDef,bo as renderPolygonShape,po as renderPolyline,_o as renderRadialGradientLibraryDef,lo as renderRectangle,it as renderReferencedLibraryDefs,fe as renderShape,fo as renderSpline,eo as renderSvgPrimitiveChainFilter,go as renderSymbolInstance,To as renderSymbolLibraryDef,co as renderText,Xt as renderToSvg,Jl as resolveRichTextStyleAt,hi as resolveSymbolInstanceShapes,ec as rewriteDocumentEmbeddedPayloads,zr as rewriteShapeStateEmbeddedPayloads,Kt as richTextFontVariantCss,ia as richTextLineSpans,kr as richTextRunsFromState,gr as richTextStyleDelta,$r as richTextStyleDeltasEqual,xr as richTextStylesEqual,gi as richTextTspanAttributes,zt as rotateAffine,Xr as roundCoord,Ka as roundNumberString,Kr as roundSerializedShape,_c as roundSnapshot,gt as runsFromSegments,Tr as sanitizeRichTextFormatRanges,gn as scaleAffine,pu as senderCorrectionsForOp,yn as skewXAffine,bn as skewYAffine,Vn as smilKeyframeAttributes,Mo as solveCubicBezier,Jn as solveSudoku,Vf as splinePathBounds,Vr as stringifyDocument,Wr as substituteString,Hr as substituteVariables,jt as symbolInstanceTargetId,an as transformSplice,Ie as translateAffine,ju as tryParseSvgTransformList,ye as upsertResourceById,dr as upsertResourceByKey,pr as upsertResourceByName,$a as upsertTrackKeyframe,Wl as validateDocumentOperations,cr as validateOperation,Hl as validatePresenceOperation,$n as validateSnapshot,up as validateSudokuPuzzle,Ce as verticesToPath};
83
+ }`)}let l=[];for(let f of r.body){if(f.kind==="shape"){l.push(`${n}${jx(f.markup,o.get(f))}`);continue}l.push(`${n}${f.open}`);for(let m of f.members)l.push(`${n}${n}${jx(m.markup,o.get(m))}`);l.push(`${n}${f.close}`)}let d=Vt(r.defs),u=r.strippedDocumentCss,p=[];p.push("<style>");for(let f of c)p.push(f);u.length>0&&p.push(u),p.push("</style>"),p.push(""),p.push(`<svg xmlns="http://www.w3.org/2000/svg" width="${r.frame.width}" height="${r.frame.height}" viewBox="${r.frame.viewBox}">`),d.length>0&&p.push(`${n}<defs>${d}</defs>`);for(let f of l)p.push(f);return p.push("</svg>"),p.push(""),p.join(`
84
+ `)}function dm(t,e){return Ux(t,e).code}function Ux(t,e){let n=new to;return{code:_c(n,()=>oz(t,e)),diagnostics:n.diagnostics}}function oz(t,e){let n=sz(t,e),r={...e};switch(r.format){case"svg":return om(n,r);case"react":return sm(n,r);case"vue":return am(n,r);case"d3":return cm(n,r);case"css":return lm(n,r);default:throw new Error(`Unsupported code format: ${r.format}`)}}function sz(t,e){if(Array.isArray(t)){let n=Hv(t);return{shapes:t,viewboxes:[{id:"default",x:0,y:0,width:e.width??800,height:e.height??600}],...n.length>0?{library:n}:{}}}return t}var um=class t{_snapshot;constructor(e={}){let{width:n=800,height:r=600,viewboxId:i}=e,o=Zi(0,0,n,r,i);this._snapshot=Xo({viewboxes:[o]})}static fromSnapshot(e){let n=new t;return n._snapshot=JSON.parse(JSON.stringify(e)),n}static fromJSON(e,n){let r=of(e,n),i=new t;return i._snapshot=r,i}static fromSVG(e,n){return t.fromSnapshot(Ef(e,n))}add(e){let n="build"in e&&typeof e.build=="function"?e.build():e;return this._snapshot.shapes.push(n),this}addAll(...e){for(let n of e)this.add(n);return this}remove(e){let n=this._snapshot.shapes.length;return this._snapshot.shapes=this._snapshot.shapes.filter(r=>r.id!==e),this._snapshot.shapes.length<n}get shapes(){return this._snapshot.shapes}findShape(e){return this._snapshot.shapes.find(n=>n.id===e)}size(e,n){return this._snapshot.viewboxes.length>0?(this._snapshot.viewboxes[0].width=e,this._snapshot.viewboxes[0].height=n):this._snapshot.viewboxes=[Zi(0,0,e,n)],this}get width(){return this._snapshot.viewboxes[0]?.width??800}get height(){return this._snapshot.viewboxes[0]?.height??600}title(e){return this._ensureMetadata(),this._snapshot.documentMetadata.title=e,this}description(e){return this._ensureMetadata(),this._snapshot.documentMetadata.description=e,this}author(e){return this._ensureMetadata(),this._snapshot.documentMetadata.author=e,this}keywords(...e){return this._ensureMetadata(),this._snapshot.documentMetadata.keywords=e,this}license(e,n){return this._ensureMetadata(),this._snapshot.documentMetadata.license=e,n!==void 0&&(this._snapshot.documentMetadata.licenseUrl=n),this}language(e){return this._ensureMetadata(),this._snapshot.documentMetadata.language=e,this}customMetadata(e){return this._ensureMetadata(),this._snapshot.documentMetadata.customMetadata={...this._snapshot.documentMetadata.customMetadata,...e},this}get meta(){return this._snapshot.documentMetadata}defineSymbol(e,n,r){let i=J(),o=n.map(l=>"build"in l&&typeof l.build=="function"?l.build():l),s={kind:"symbol",id:i,name:e,shapes:o};r?.thumbnail&&(s.thumbnail=r.thumbnail),r?.defKind&&(s.defKind=r.defKind);let a={...r?.rootAttributes??{}},c=a.viewBox;delete a.viewBox,r?.viewBox!==null&&(s.viewBox=r?.viewBox??c??"0 0 100 100");for(let l of["preserveAspectRatio","x","y","width","height","refX","refY"])r?.[l]!==void 0?s[l]=r[l]:s[l]===void 0&&a[l]!==void 0&&(s[l]=a[l]),delete a[l];return Object.keys(a).length>0&&(s.rootAttributes=a),r?.variantAxes&&(s.variantAxes=r.variantAxes),r?.variants&&(s.variants=Object.fromEntries(Object.entries(r.variants).map(([l,d])=>[l,d]))),r?.variantThumbnails&&(s.variantThumbnails=r.variantThumbnails),this._pushLibraryDef(s),i}placeSymbolInstance(e,n,r,i={}){let o=i.width,s=i.height,a={symbolId:e,x:n,y:r,width:o??100,height:s??100},c=i.authoredUseGeometry??{x:String(n),y:String(r),...o!==void 0?{width:String(o)}:{},...s!==void 0?{height:String(s)}:{}};Object.keys(c).length>0&&(a.authoredUseGeometry=c),i.variantKey&&(a.variantKey=i.variantKey),i.symbolOverrides&&(a.symbolOverrides=i.symbolOverrides),i.instancePresentation&&(a.instancePresentation=i.instancePresentation);let l={id:J(),type:"symbol-instance",state:a};return this._snapshot.shapes.push(l),this}removeSymbol(e){if(!this._snapshot.library)return!1;let n=this._snapshot.library.length;return this._snapshot.library=this._snapshot.library.filter(r=>!(r.kind==="symbol"&&r.id===e)),this._snapshot.library.length<n}get symbols(){return(this._snapshot.library??[]).filter(e=>e.kind==="symbol")}defineMarker(e,n,r){let i=J(),o=n.map(a=>"build"in a&&typeof a.build=="function"?a.build():a),s={kind:"marker",id:i,name:e,viewBox:r?.viewBox??"0 0 10 10",refX:r?.refX??5,refY:r?.refY??5,markerWidth:r?.markerWidth??10,markerHeight:r?.markerHeight??10,markerUnits:r?.markerUnits??"strokeWidth",orient:r?.orient??"auto",shapes:o};return r?.preserveAspectRatio!==void 0&&(s.preserveAspectRatio=r.preserveAspectRatio),r?.authoredGeometry&&(s.authoredGeometry={...r.authoredGeometry}),r?.rootAttributes&&(s.rootAttributes={...r.rootAttributes}),r?.thumbnail&&(s.thumbnail=r.thumbnail),this._pushLibraryDef(s),i}defineFilter(e,n,r){let i=J(),o={kind:"filter",id:i,name:e,filters:n};return r?.colorInterpolation&&(o.colorInterpolation=r.colorInterpolation),r?.filterUnits&&(o.filterUnits=r.filterUnits),r?.primitiveUnits&&(o.primitiveUnits=r.primitiveUnits),r?.x!==void 0&&(o.x=r.x),r?.y!==void 0&&(o.y=r.y),r?.width!==void 0&&(o.width=r.width),r?.height!==void 0&&(o.height=r.height),r?.thumbnail&&(o.thumbnail=r.thumbnail),this._pushLibraryDef(o),i}defineLinearGradientLibrary(e,n,r){let i=J(),o="build"in n?n.build():n,{id:s,sourceId:a,...c}=o,l={kind:"linear-gradient",id:i,name:e,gradient:c};return r?.thumbnail&&(l.thumbnail=r.thumbnail),this._pushLibraryDef(l),i}defineRadialGradientLibrary(e,n,r){let i=J(),o="build"in n?n.build():n,{id:s,sourceId:a,...c}=o,l={kind:"radial-gradient",id:i,name:e,gradient:c};return r?.thumbnail&&(l.thumbnail=r.thumbnail),this._pushLibraryDef(l),i}definePatternLibrary(e,n,r){let i=J(),o="build"in n?n.build():n,{id:s,sourceId:a,customPatternId:c,...l}=o,d={kind:"pattern",id:i,name:e,pattern:l};return r?.thumbnail&&(d.thumbnail=r.thumbnail),this._pushLibraryDef(d),i}removeLibraryDef(e){if(!this._snapshot.library)return!1;let n=this._snapshot.library.length;return this._snapshot.library=this._snapshot.library.filter(r=>r.id!==e),this._snapshot.library.length<n}get library(){return this._snapshot.library??[]}_pushLibraryDef(e){this._snapshot.library||(this._snapshot.library=[]);let n=this._snapshot.library.findIndex(r=>r.id===e.id);n>=0?this._snapshot.library[n]=e:this._snapshot.library.push(e)}addClipGroup(e,n,r){this._snapshot.clipMaskGroups||(this._snapshot.clipMaskGroups=[]);let i=J(),o={id:i,type:"clip",clipShapeIds:e,contentShapeIds:n,parentId:null};return r?.clipPathUnits&&(o.clipPathUnits=r.clipPathUnits),r?.clipRule&&(o.clipRule=r.clipRule),r?.rawDefinition&&(o.rawDefinition=r.rawDefinition),this._snapshot.clipMaskGroups.push(o),i}addMaskGroup(e,n,r){this._snapshot.clipMaskGroups||(this._snapshot.clipMaskGroups=[]);let i=J(),o={id:i,type:"mask",clipShapeIds:e,contentShapeIds:n,parentId:null};return r?.maskUnits&&(o.maskUnits=r.maskUnits),r?.maskContentUnits&&(o.maskContentUnits=r.maskContentUnits),r?.maskBounds&&(o.maskBounds=r.maskBounds),r?.maskType&&(o.maskType=r.maskType),r?.rawDefinition&&(o.rawDefinition=r.rawDefinition),this._snapshot.clipMaskGroups.push(o),i}removeClipMaskGroup(e){if(!this._snapshot.clipMaskGroups)return!1;let n=this._snapshot.clipMaskGroups.length;return this._snapshot.clipMaskGroups=this._snapshot.clipMaskGroups.filter(r=>r.id!==e),this._snapshot.clipMaskGroups.length<n}addGuide(e,n,r){this._snapshot.guides||(this._snapshot.guides=[]);let i=J(),o={id:i,orientation:e,position:n,controlPointOffset:0};return r?.color&&(o.color=r.color),r?.opacity!==void 0&&(o.opacity=r.opacity),this._snapshot.guides.push(o),i}removeGuide(e){if(!this._snapshot.guides)return!1;let n=this._snapshot.guides.length;return this._snapshot.guides=this._snapshot.guides.filter(r=>r.id!==e),this._snapshot.guides.length<n}clearGuides(){return this._snapshot.guides=[],this}get guides(){return this._snapshot.guides??[]}addMeasurement(e,n,r){this._snapshot.measurements||(this._snapshot.measurements=[]);let i=J(),o={id:i,type:e,points:n,visible:r?.visible??!0,snapDivisions:r?.snapDivisions??1};return r?.color&&(o.color=r.color),r?.opacity!==void 0&&(o.opacity=r.opacity),this._snapshot.measurements.push(o),i}removeMeasurement(e){if(!this._snapshot.measurements)return!1;let n=this._snapshot.measurements.length;return this._snapshot.measurements=this._snapshot.measurements.filter(r=>r.id!==e),this._snapshot.measurements.length<n}get measurements(){return this._snapshot.measurements??[]}addCustomPattern(e,n,r,i){let o=J();return this._pushLibraryDef(os({id:o,name:e,svgContent:n,width:r,height:i})),o}removeCustomPattern(e){let n=this._snapshot.library;if(!n)return!1;let r=n.length;return this._snapshot.library=n.filter(i=>!(i.kind==="pattern"&&i.id===e)),this._snapshot.library.length<r}get customPatterns(){let e=[];for(let n of this._snapshot.library??[]){if(n.kind!=="pattern")continue;let r=qp(n);r&&e.push(r)}return e}bringToFront(e){let n=this._snapshot.shapes.findIndex(r=>r.id===e);if(n>=0){let[r]=this._snapshot.shapes.splice(n,1);this._snapshot.shapes.push(r)}return this}sendToBack(e){let n=this._snapshot.shapes.findIndex(r=>r.id===e);if(n>=0){let[r]=this._snapshot.shapes.splice(n,1);this._snapshot.shapes.unshift(r)}return this}reorder(e,n){let r=this._snapshot.shapes.findIndex(i=>i.id===e);if(r>=0){let[i]=this._snapshot.shapes.splice(r,1),o=Math.max(0,Math.min(n,this._snapshot.shapes.length));this._snapshot.shapes.splice(o,0,i)}return this}defineVariable(e,n,r,i){this._snapshot.templateVariables||(this._snapshot.templateVariables=[]);let o=this._snapshot.templateVariables.find(s=>s.name===e);if(o)o.type=n,o.defaultValue=r,i?.label!==void 0&&(o.label=i.label),i?.description!==void 0&&(o.description=i.description);else{let s={name:e,type:n,defaultValue:r};i?.label!==void 0&&(s.label=i.label),i?.description!==void 0&&(s.description=i.description),this._snapshot.templateVariables.push(s)}return this}removeVariable(e){return this._snapshot.templateVariables&&(this._snapshot.templateVariables=this._snapshot.templateVariables.filter(n=>n.name!==e)),this}get variables(){return this._snapshot.templateVariables??[]}inspectVariables(){return uf(this._snapshot)}setTimeline(e){return"build"in e&&typeof e.build=="function"?this._snapshot.animationTimeline=e.build():this._snapshot.animationTimeline=e,this}clearTimeline(){return delete this._snapshot.animationTimeline,this}get timeline(){return this._snapshot.animationTimeline}toSVG(e){let{variables:n,...r}=e??{},i=Mc(this._snapshot,n);return Ps(i,r)}toSVGWithDiagnostics(e){let{variables:n,...r}=e??{},i=Mc(this._snapshot,n);return xl(i,r)}toJSON(e){return rf(this._snapshot,e)}toSnapshot(){return JSON.parse(JSON.stringify(this._snapshot))}toCode(e,n){return dm(this._snapshot,{...n,format:e})}_ensureMetadata(){this._snapshot.documentMetadata||(this._snapshot.documentMetadata={title:"",description:"",author:"",keywords:[],license:"",licenseUrl:"",language:"en",customMetadata:{}})}};var pm=class{_track;constructor(e,n){this._track={id:J(),shapeId:e,property:n,keyframes:[],enabled:!0,locked:!1}}id(e){return this._track.id=e,this}keyframe(e,n,r="linear"){return this._track.keyframes.push({id:J(),time:e,value:n,easing:r}),this}keyframeBezier(e,n,r){return this._track.keyframes.push({id:J(),time:e,value:n,easing:"custom-bezier",customBezier:r}),this}keyframeLinear(e,n,r){return this._track.keyframes.push({id:J(),time:e,value:n,easing:"linear-function",linearPoints:r}),this}keyframes(...e){return this._track.keyframes.push(...e.map(n=>({...n,id:n.id??J()}))),this}disabled(){return this._track.enabled=!1,this}locked(){return this._track.locked=!0,this}motionPath(e){return this._track.motionPath=e,this}motionPathRef(e,n="trackShape"){return this._track.motionPathRef={shapeId:e,mode:n},this}beginTrigger(e,n){return this._track.beginTrigger={type:e,value:n},this}endTrigger(e,n){return this._track.endTrigger={type:e,value:n},this}cycleDuration(e){return this._track.cycleDuration=e,this}cycleRepeats(e){return this._track.cycleRepeats=e,this}infinite(){return this._track.cycleInfinite=!0,this}cycle(e){return this._track.cycleBehavior=e,this}transformOrigin(e,n){return this._track.transformOrigin={x:e,y:n},this}motionRotate(e){return this._track.motionRotate=e,this}additive(e){return this._track.additive=e,this}fill(e){return this._track.fill=e,this}fillBackwards(e=!0){return this._track.fillBackwards=e,this}build(){let e=[...this._track.keyframes].sort((n,r)=>n.time-r.time);return{...this._track,keyframes:e}}},fm=class{_duration;_loop=!1;_playbackSpeed=1;_tracks=[];constructor(e){this._duration=e}loop(e=!0){return this._loop=e,this}speed(e){return this._playbackSpeed=e,this}duration(e){return this._duration=e,this}addTrack(e){return this._tracks.push(e),this}addTracks(...e){return this._tracks.push(...e),this}buildTimeline(){return{duration:this._duration,loop:this._loop,playbackSpeed:this._playbackSpeed,tracks:this._tracks.map(e=>e.build())}}build(){let e=this.buildTimeline();return{duration:e.duration,loop:e.loop,playbackSpeed:e.playbackSpeed,tracks:e.tracks.map(n=>({id:n.id,shapeId:n.shapeId,property:n.property,enabled:n.enabled,locked:n.locked||void 0,motionPath:n.motionPath,motionPathRef:n.motionPathRef,beginTrigger:n.beginTrigger,endTrigger:n.endTrigger,cycleDuration:n.cycleDuration,cycleRepeats:n.cycleRepeats,cycleInfinite:n.cycleInfinite,cycleBehavior:n.cycleBehavior,fillBackwards:n.fillBackwards,transformOrigin:n.transformOrigin,motionRotate:n.motionRotate,additive:n.additive,fill:n.fill,keyframes:n.keyframes.map(r=>({id:r.id,time:r.time,value:r.value,easing:r.easing,...r.customBezier?{customBezier:r.customBezier}:{},...r.linearPoints?{linearPoints:r.linearPoints}:{}}))}))}}};var wt=class{_id;_type;_state={};constructor(e,n){this._type=e,this._id=n??J()}id(e){return this._id=e,this}locked(e=!0){return this._state.locked=e,this}visible(e=!0){return this._state.visible=e,this}displayMode(e){return this._state.displayMode=e,this}motionOnly(){return this._state.displayMode="motionOnly",this}fill(e,n){return this._state.fillColor=e,this._state.fillType="solid",n!==void 0&&(this._state.fillOpacity=n),this}noFill(){return this._state.fillType="none",this}fillGradient(e){let n="build"in e?e.build():e;return this._state.fillType=n.type,this._state.fillGradient=n,this}fillPattern(e){let n="build"in e?e.build():e;return this._state.fillType="pattern",this._state.fillGradient=n,this}fillOpacity(e){return this._state.fillOpacity=e,this}fillRule(e){return this._state.fillRule=e,this}stroke(e,n){return this._state.borderColor=e,n!==void 0&&(this._state.borderWidth=n),this}noStroke(){return this._state.borderColor="none",this._state.borderWidth=0,this}strokeWidth(e){return this._state.borderWidth=e,this}strokeOpacity(e){return this._state.strokeOpacity=e,this}strokeGradient(e){let n="build"in e?e.build():e;return this._state.strokeType=n.type,this._state.strokeGradient=n,this}strokePattern(e){let n="build"in e?e.build():e;return this._state.strokeType="pattern",this._state.strokeGradient=n,this}strokeLinejoin(e){return this._state.strokeLinejoin=e,this}strokeLinecap(e){return this._state.strokeLinecap=e,this}strokeMiterlimit(e){return this._state.strokeMiterlimit=e,this}dashOffset(e){return this._state.dashOffset=e,this}strokeDasharray(e){return this._state.strokeDasharray=e,this}dash(e,n,r){return this._state.lineStyle=e,e==="custom"&&(n!==void 0&&(this._state.dashLength=n),r!==void 0&&(this._state.gapLength=r)),this}opacity(e){return this._state.opacity=e,this}rotate(e){return this._state.rotation=e,this.refreshTransformMatrix(),this}skew(e,n){return this._state.skewX=e,this._state.skewY=n,this.refreshTransformMatrix(),this}scale(e,n){return this._state.scaleX=e,this._state.scaleY=n??e,this.refreshTransformMatrix(),this}pivot(e,n){return this._state.customPivot={x:e,y:n},this.refreshTransformMatrix(),this}transformMatrix(e){if(e.length<6||!e.slice(0,6).every(Number.isFinite))throw new RangeError("transformMatrix must contain six finite numbers");return this._state.transformMatrix=e.slice(0,6),this}refreshTransformMatrix(){this._state.transformMatrix=ot(la(this._state,this.defaultTransformPivot()))}defaultTransformPivot(){let e=this._state.customPivot;if(e)return e;let n=this._state.x,r=this._state.y,i=this._state.width,o=this._state.height;if(n!==void 0&&r!==void 0&&i!==void 0&&o!==void 0)return{x:n+i/2,y:r+o/2};let s=this._state.radius;if(n!==void 0&&r!==void 0&&s!==void 0)return{x:n,y:r};let a=this._state.cx,c=this._state.cy;if(a!==void 0&&c!==void 0)return{x:a,y:c};let l=this._state.x1,d=this._state.y1,u=this._state.x2,p=this._state.y2;if(l!==void 0&&d!==void 0&&u!==void 0&&p!==void 0)return{x:(l+u)/2,y:(d+p)/2};let f=this._state.pathPoints;if(f?.[0])return{x:f[0].x,y:f[0].y};let m=this._state.polylinePoints;if(m?.[0])return m[0]}filter(...e){let n=this._state.filters??[];return this._state.filters=[...n,...e],this}dropShadow(e={}){let n={id:`drop-shadow-${J()}`,type:"drop-shadow",enabled:!0,offsetX:e.offsetX??4,offsetY:e.offsetY??4,blurRadius:e.blurRadius??8,spread:e.spread??0,color:e.color??"#000000",opacity:e.opacity??.3};return this.filter(n)}innerShadow(e={}){let n={id:`inner-shadow-${J()}`,type:"inner-shadow",enabled:!0,offsetX:e.offsetX??2,offsetY:e.offsetY??2,blurRadius:e.blurRadius??4,choke:e.choke??0,color:e.color??"#000000",opacity:e.opacity??.5};return this.filter(n)}blur(e,n,r){let i=e??4,o=n??i,s={id:`gaussian-blur-${J()}`,type:"gaussian-blur",enabled:!0,blurX:i,blurY:o,linked:i===o,quality:r?.quality??"normal"};return this.filter(s)}glow(e={}){let n={id:`glow-${J()}`,type:"glow",enabled:!0,color:e.color??"#ffffff",radius:e.radius??10,intensity:e.intensity??.8};return this.filter(n)}innerGlow(e={}){let n={id:`inner-glow-${J()}`,type:"inner-glow",enabled:!0,color:e.color??"#ffffff",radius:e.radius??10,intensity:e.intensity??.8};return this.filter(n)}grayscale(e=1){let n={id:`grayscale-${J()}`,type:"grayscale",enabled:!0,amount:e};return this.filter(n)}sepia(e=1){let n={id:`sepia-${J()}`,type:"sepia",enabled:!0,amount:e};return this.filter(n)}outline(e={}){return this.filter({id:`outline-${J()}`,type:"outline",enabled:!0,width:e.width??3,color:e.color??"#000000",opacity:e.opacity??1,position:e.position??"outside"})}motionBlur(e={}){let n={id:`motion-blur-${J()}`,type:"motion-blur",enabled:!0,distance:e.distance??10,angle:e.angle??0,quality:e.quality??"normal"};return this.filter(n)}pointLight(e={}){let n={id:`point-light-${J()}`,type:"point-light",enabled:!0,x:e.x??100,y:e.y??100,z:e.z??200,color:e.color??"#ffffff",surfaceScale:e.surfaceScale??5,diffuseConstant:e.diffuseConstant??1,specularConstant:e.specularConstant??1,specularExponent:e.specularExponent??20};return this.filter(n)}spotLight(e={}){let n={id:`spot-light-${J()}`,type:"spot-light",enabled:!0,x:e.x??100,y:e.y??0,z:e.z??200,pointsAtX:e.pointsAtX??100,pointsAtY:e.pointsAtY??100,pointsAtZ:e.pointsAtZ??0,coneAngle:e.coneAngle??30,color:e.color??"#ffffff",surfaceScale:e.surfaceScale??5,specularConstant:e.specularConstant??1,specularExponent:e.specularExponent??20};return this.filter(n)}sharpen(e=1){let n={id:`sharpen-${J()}`,type:"sharpen",enabled:!0,amount:e};return this.filter(n)}pixelate(e=8){let n={id:`pixelate-${J()}`,type:"pixelate",enabled:!0,blockSize:e};return this.filter(n)}warp(e={}){let n={id:`warp-${J()}`,type:"warp",enabled:!0,scale:e.scale??10,frequency:e.frequency??.02,octaves:e.octaves??1,warpType:e.warpType??"turbulence"};return this.filter(n)}morphology(e={}){let n=e.radiusX??2,r=e.radiusY??n,i={id:`morphology-${J()}`,type:"morphology",enabled:!0,operator:e.operator??"dilate",radiusX:n,radiusY:r,linked:e.linked??n===r};return this.filter(i)}contouring(e={}){if((e.mode??"discrete")==="table"){let i={id:`contouring-table-${J()}`,type:"contouring-table",enabled:!0,levels:e.levels??4,contrast:e.contrast??1};return this.filter(i)}let r={id:`contouring-discrete-${J()}`,type:"contouring-discrete",enabled:!0,levels:e.levels??4};return this.filter(r)}roundEdges(e=4){let n={id:`round-edges-${J()}`,type:"round-edges",enabled:!0,radius:e};return this.filter(n)}channelPainter(e={}){let n={id:`channel-painter-${J()}`,type:"channel-painter",enabled:!0,red:e.red??1,green:e.green??1,blue:e.blue??1};return this.filter(n)}brightness(e=1){let n={id:`brightness-${J()}`,type:"brightness",enabled:!0,amount:e};return this.filter(n)}contrast(e=1){let n={id:`contrast-${J()}`,type:"contrast",enabled:!0,amount:e};return this.filter(n)}filterOpacity(e=1){let n={id:`opacity-${J()}`,type:"opacity",enabled:!0,amount:e};return this.filter(n)}invert(e=1){let n={id:`invert-${J()}`,type:"invert",enabled:!0,amount:e};return this.filter(n)}hueRotate(e=0){let n={id:`hue-rotate-${J()}`,type:"hue-rotate",enabled:!0,angle:e};return this.filter(n)}saturate(e=1){let n={id:`saturate-${J()}`,type:"saturate",enabled:!0,amount:e};return this.filter(n)}blackAndWhite(e=.5){let n={id:`black-and-white-${J()}`,type:"black-and-white",enabled:!0,threshold:e};return this.filter(n)}duotone(e={}){let n={id:`duotone-${J()}`,type:"duotone",enabled:!0,shadowColor:e.shadowColor??"#000000",highlightColor:e.highlightColor??"#ffffff"};return this.filter(n)}xray(e=1){let n={id:`xray-${J()}`,type:"xray",enabled:!0,intensity:e};return this.filter(n)}noise(e={}){let n={id:`noise-${J()}`,type:"noise",enabled:!0,amount:e.amount??.3,scale:e.scale??1};return this.filter(n)}emboss(e={}){let n={id:`emboss-${J()}`,type:"emboss",enabled:!0,strength:e.strength??1,angle:e.angle??135};return this.filter(n)}filmGrain(e={}){let n={id:`film-grain-${J()}`,type:"film-grain",enabled:!0,amount:e.amount??.3,size:e.size??1};return this.filter(n)}watercolor(e={}){let n={id:`watercolor-${J()}`,type:"watercolor",enabled:!0,wetness:e.wetness??.5,turbulence:e.turbulence??.5};return this.filter(n)}gouache(e={}){let n={id:`gouache-${J()}`,type:"gouache",enabled:!0,thickness:e.thickness??.5,texture:e.texture??.5};return this.filter(n)}inkBlot(e={}){let n={id:`ink-blot-${J()}`,type:"ink-blot",enabled:!0,spread:e.spread??.5,edges:e.edges??.5};return this.filter(n)}crumpledPlastic(e={}){let n={id:`crumpled-plastic-${J()}`,type:"crumpled-plastic",enabled:!0,wrinkles:e.wrinkles??.5,shine:e.shine??.5};return this.filter(n)}riddled(e={}){let n={id:`riddled-${J()}`,type:"riddled",enabled:!0,density:e.density??.5,size:e.size??1};return this.filter(n)}cssClipPath(e){return this._state.cssClipPath=e,this}cssMaskProperties(e){return this._state.cssMaskProperties=e,this}vectorEffect(e){return this._state.vectorEffect=e,this}transformBox(e){return this._state.transformBox=e,this}paintOrder(e){return this._state.paintOrder=e,this}blendMode(e){return this._state.blendMode=e,this}visibility(e){return this._state.visibility=e,this}shapeRendering(e){return this._state.shapeRendering=e,this}filterColorInterpolation(e){return this._state.filterColorInterpolation=e,this}inheritFill(e=!0){return this._state.inheritFill=e,this}inheritStroke(e=!0){return this._state.inheritStroke=e,this}systemLanguage(e){return this._state.systemLanguage=e,this}requiredExtensions(e){return this._state.requiredExtensions=e,this}fillLibrary(e,n="linear-gradient"){return this._state.fillLibraryId=e,this._state.fillType=n,this}strokeLibrary(e,n="linear-gradient"){return this._state.strokeLibraryId=e,this._state.strokeType=n,this}filterLibrary(...e){let n=this._state.filterLibraryIds??[];return this._state.filterLibraryIds=[...n,...e],this}markerStartRef(e){return this._state.markerStart=e,this}markerMidRef(e){return this._state.markerMid=e,this}markerEndRef(e){return this._state.markerEnd=e,this}bind(e,n){let r=this._state.bindings??{};return this._state.bindings={...r,[e]:n},this}metadata(e){return this._state.metadata={...this._state.metadata,...e},this}build(){return{id:this._id,type:this._type,state:{...this._state}}}},mm=class extends wt{constructor(e,n,r){if(r<0)throw new RangeError("Circle radius must be non-negative");super("circle"),this._state.x=e,this._state.y=n,this._state.radius=r}position(e,n){return this._state.x=e,this._state.y=n,this}radius(e){return this._state.radius=e,this}},gm=class extends wt{constructor(e,n,r,i){if(r<0||i<0)throw new RangeError("Ellipse radii must be non-negative");super("ellipse"),this._state.cx=e,this._state.cy=n,this._state.rx=r,this._state.ry=i}position(e,n){return this._state.cx=e,this._state.cy=n,this}radii(e,n){return this._state.rx=e,this._state.ry=n,this}},hm=class extends wt{constructor(e,n,r,i){if(r<0||i<0)throw new RangeError("Rectangle dimensions must be non-negative");super("rectangle"),this._state.x=e,this._state.y=n,this._state.width=r,this._state.height=i}position(e,n){return this._state.x=e,this._state.y=n,this}size(e,n){return this._state.width=e,this._state.height=n,this}cornerRadius(e){return this._state.cornerRadius=e,this._state.rx=e,this._state.ry=e,this}radii(e,n){return this._state.rx=e,this._state.ry=n,e===n&&(this._state.cornerRadius=e),this}},ym=class extends wt{constructor(e,n,r){if(r<0)throw new RangeError("Square size must be non-negative");super("square"),this._state.x=e,this._state.y=n,this._state.width=r,this._state.height=r}position(e,n){return this._state.x=e,this._state.y=n,this}size(e){return this._state.width=e,this._state.height=e,this}cornerRadius(e){return this._state.cornerRadius=e,this._state.rx=e,this._state.ry=e,this}radii(e,n){return this._state.rx=e,this._state.ry=n,e===n&&(this._state.cornerRadius=e),this}},Sm=class extends wt{constructor(e,n,r,i){super("line"),this._state.x1=e,this._state.y1=n,this._state.x2=r,this._state.y2=i}from(e,n){return this._state.x1=e,this._state.y1=n,this}to(e,n){return this._state.x2=e,this._state.y2=n,this}markerStart(e){return this._state.startEndpoint=e,this}markerEnd(e){return this._state.endEndpoint=e,this}markers(e,n){return this._state.startEndpoint=e,this._state.endEndpoint=n,this}},bm=class extends wt{constructor(e,n,r){super("text"),this._state.x=e,this._state.y=n,this._state.text=r}position(e,n){return this._state.x=e,this._state.y=n,this}content(e){return this._state.text=e,this}fontSize(e){return this._state.fontSize=e,this}fontFamily(e){return this._state.fontFamily=e,this}fontWeight(e){return this._state.fontWeight=e,this}fontStyle(e){return this._state.fontStyle=e,this}fontVariant(e){return this._state.fontVariant=e,this}fontVariantLigatures(e){return this._state.fontVariantLigatures=e,this}fontVariantPosition(e){return this._state.fontVariantPosition=e,this}fontVariantCaps(e){return this._state.fontVariantCaps=e,this}fontVariantNumeric(e){return this._state.fontVariantNumeric=e,this}fontVariantEastAsian(e){return this._state.fontVariantEastAsian=e,this}anchor(e){return this._state.textAnchor=e,this}letterSpacing(e){return this._state.letterSpacing=e,this}lineHeight(e){return this._state.lineHeight=e,this}decoration(e){return this._state.textDecoration=e,this}transform(e){return this._state.textTransform=e,this}textPath(e,n=0){return this._state.isTextPath=!0,this._state.textPathPoints=e,this._state.textPathStartOffset=n,this}textPathOffset(e){return this._state.textPathStartOffset=e,this}textPathSide(e){return this._state.textPathSide=e,this}direction(e){return this._state.textDirection=e,this}unicodeBidi(e){return this._state.unicodeBidi=e,this}dominantBaseline(e){return this._state.dominantBaseline=e,this}writingMode(e){return this._state.writingMode=e,this}wordSpacing(e){return this._state.wordSpacing=e,this}baselineShift(e){return this._state.baselineShift=e,this}inlineSize(e){return this._state.inlineSize=e,this}overflowWrap(e){return this._state.overflowWrap=e,this}whiteSpace(e){return this._state.whiteSpace=e,this}fontVariationSettings(e){return this._state.fontVariationSettings=e,this}charOffsets(e){return this._state.charOffsets=e,this}shapeInsideRef(e){return this._state.shapeInsideRef=e,this}shapePadding(e){return this._state.shapePadding=e,this}richTextSegments(e){return this._state.richTextRuns=ar(e),this}richTextRuns(e){let n=Si(e);return this._state.richTextRuns=n,this}useRichText(e=!0){return this._state.useRichText=e,this}linePositions(e){return this._state.linePositions=e,this}textLength(e){return this._state.textLength=e,this}lengthAdjust(e){return this._state.lengthAdjust=e,this}},jt=class extends wt{constructor(e,n,r,i){super(e),this._state.cx=n,this._state.cy=r,this._state.radius=i}position(e,n){return this._state.cx=e,this._state.cy=n,this}radius(e){return this._state.radius=e,this}shiftAngle(e){return this._state.shiftAngle=e,this}cornerRadius(e){return this._state.cornerRadius=e,this}},vm=class extends jt{constructor(e,n,r){super("triangle",e,n,r)}},xm=class extends jt{constructor(e,n,r,i=5){super("ngon",e,n,r),this._state.sides=i}sides(e){return this._state.sides=e,this}},Im=class extends jt{constructor(e,n,r){super("star",e,n,r),this._state.arms=5,this._state.innerRadiusPercent=40}arms(e){return this._state.arms=e,this}innerRadius(e){return this._state.innerRadiusPercent=e,this}},wm=class extends jt{constructor(e,n,r){super("cross",e,n,r),this._state.armWidthPercent=35}armWidth(e){return this._state.armWidthPercent=e,this}},km=class extends jt{constructor(e,n,r){super("ring",e,n,r),this._state.innerRadiusPercent=60}innerRadius(e){return this._state.innerRadiusPercent=e,this}},Pm=class extends jt{constructor(e,n,r){super("spiral",e,n,r),this._state.turns=3,this._state.thicknessPercent=15,this._state.spiralDirection=1}turns(e){return this._state.turns=e,this}thickness(e){return this._state.thicknessPercent=e,this}direction(e){return this._state.spiralDirection=e,this}},Tm=class extends jt{constructor(e,n,r){super("gear",e,n,r),this._state.teeth=8,this._state.toothDepthPercent=25}teeth(e){return this._state.teeth=e,this}toothDepth(e){return this._state.toothDepthPercent=e,this}holeRadius(e){return this._state.holeRadiusPercent=e,this}},Rm=class extends jt{constructor(e,n,r){super("arrow",e,n,r),this._state.headWidthPercent=100,this._state.headLengthPercent=35,this._state.shaftWidthPercent=35}headWidth(e){return this._state.headWidthPercent=e,this}headLength(e){return this._state.headLengthPercent=e,this}shaftWidth(e){return this._state.shaftWidthPercent=e,this}},Cm=class extends jt{constructor(e,n,r){super("heart",e,n,r),this._state.lobeRadiusPercent=50,this._state.cleftDepthPercent=25}lobeRadius(e){return this._state.lobeRadiusPercent=e,this}cleftDepth(e){return this._state.cleftDepthPercent=e,this}},$m=class extends jt{constructor(e,n,r){super("lightning",e,n,r),this._state.boltSegments=3,this._state.boltJaggednessPercent=40,this._state.boltWidthPercent=30}segments(e){return this._state.boltSegments=e,this}jaggedness(e){return this._state.boltJaggednessPercent=e,this}thickness(e){return this._state.boltWidthPercent=e,this}},Nm=class extends jt{constructor(e,n,r){super("cloud",e,n,r),this._state.cloudBumps=5,this._state.cloudPuffinessPercent=60}bumps(e){return this._state.cloudBumps=e,this}puffiness(e){return this._state.cloudPuffinessPercent=e,this}},Am=class extends jt{constructor(e,n,r){super("speechBubble",e,n,r),this._state.tailAngleDeg=45,this._state.tailLengthPercent=40,this._state.tailWidthPercent=25}tailAngle(e){return this._state.tailAngleDeg=e,this}tailLength(e){return this._state.tailLengthPercent=e,this}tailWidth(e){return this._state.tailWidthPercent=e,this}},di=class extends wt{add(e){let n="build"in e&&typeof e.build=="function"?e.build():e,r=this._state.children??[];return this._state.children=[...r,n],this}addAll(...e){for(let n of e)this.add(n);return this}children(e){return this._state.children=e.map(n=>"build"in n&&typeof n.build=="function"?n.build():n),this}},Em=class extends di{constructor(e){super("hyperlink"),e!==void 0&&(this._state.href=e)}href(e){return this._state.href=e,this}hrefXlink(e){return this._state.hrefXlink=e,this}target(e){return this._state.linkTarget=e,this}download(e){return this._state.linkDownload=e,this}rel(e){return this._state.linkRel=e,this}ping(e){return this._state.linkPing=e,this}hreflang(e){return this._state.linkHreflang=e,this}type(e){return this._state.linkType=e,this}referrerPolicy(e){return this._state.linkReferrerPolicy=e,this}},Mm=class extends di{constructor(){super("switch")}},Om=class extends di{constructor(){super("container")}},Dm=class extends wt{constructor(e){super("view"),e&&(this._state.viewBoxX=e.x,this._state.viewBoxY=e.y,this._state.viewBoxWidth=e.width,this._state.viewBoxHeight=e.height)}viewBox(e,n,r,i){return this._state.viewBoxX=e,this._state.viewBoxY=n,this._state.viewBoxWidth=r,this._state.viewBoxHeight=i,this}name(e){return this._state.viewName=e,this}preserveAspectRatio(e){return this._state.viewPreserveAspectRatio=e,this}zoomAndPan(e){return this._state.viewZoomAndPan=e,this}viewTarget(e){return this._state.viewTarget=e,this}},zm=class extends di{constructor(e=0,n=0,r=100,i=100){super("svg"),this._state.svgX=e,this._state.svgY=n,this._state.svgWidth=r,this._state.svgHeight=i}position(e,n){return this._state.svgX=e,this._state.svgY=n,this}size(e,n){return this._state.svgWidth=e,this._state.svgHeight=n,this}viewBox(e,n,r,i){return this._state.svgViewBoxX=e,this._state.svgViewBoxY=n,this._state.svgViewBoxWidth=r,this._state.svgViewBoxHeight=i,this}preserveAspectRatio(e){return this._state.svgPreserveAspectRatio=e,this}asRoot(e=!0){return this._state.isRootSvg=e,this}},_m=class extends wt{constructor(e){super("shape-reference"),e!==void 0&&(this._state.targetShapeId=e)}target(e){return this._state.targetShapeId=e,this}offset(e,n){return this._state.offsetX=e,this._state.offsetY=n,this}size(e,n){return this._state.width=e,this._state.height=n,this}},kl=class extends wt{position(e,n){return this._state.x=e,this._state.y=n,this}size(e,n){return this._state.width=e,this._state.height=n,this}src(e){return this._state.href=e,this}mimeType(e){return this._state.mediaMimeType=e,this}naturalDuration(e){return this._state.naturalDuration=e,this}begin(e){return this._state.begin=e,this}trim(e,n){return this._state.trimStart=e,this._state.trimEnd=n,this}volume(e){return this._state.volume=e,this}muted(e=!0){return this._state.muted=e,this}loop(e=!0){return this._state.loop=e,this}playbackRate(e){return this._state.playbackRate=e,this}fade(e,n){return this._state.fadeInDuration=e,this._state.fadeOutDuration=n,this}language(e){return this._state.systemLanguage=e,this}},Fm=class extends kl{constructor(e){super("video"),this._state.mediaKind="video",e!==void 0&&(this._state.href=e)}poster(e){return this._state.posterHref=e,this}sourceRect(e){return this._state.sourceRect=e,this}},Lm=class extends kl{constructor(e){super("audio"),this._state.mediaKind="audio",e!==void 0&&(this._state.href=e)}},Bm=class extends wt{constructor(e=[]){super("path"),this._state.pathPoints=[...e],this._state.pathCurveType="cubic",this._state.pathClosed=!1}points(e){return this._state.pathPoints=[...e],this}addPoint(e,n){let r=this._state.pathPoints??[];return r.push({x:e,y:n}),this._state.pathPoints=r,this}curveType(e){return this._state.pathCurveType=e,this}closed(e=!0){return this._state.pathClosed=e,this}tension(e){return this._state.pathTension=e,this}arcParams(e){return this._state.pathArcParams=e,this}markerStart(e){return this._state.startEndpoint=e,this}markerEnd(e){return this._state.endEndpoint=e,this}markers(e,n){return this._state.startEndpoint=e,this._state.endEndpoint=n,this}toD(){let e=this._state.pathPoints??[],n=this._state.pathCurveType??"CUBIC",r=this._state.pathClosed??!1,i=this._state.pathTension??.5,o=this._state.pathArcParams;return Ur(e,n,r,i,o)}},Gm=class extends wt{constructor(e=[]){super("polyline"),this._state.polylinePoints=[...e],this._state.polylineClosed=!1}points(e){return this._state.polylinePoints=[...e],this}addPoint(e,n){let r=this._state.polylinePoints??[];return r.push({x:e,y:n}),this._state.polylinePoints=r,this}closed(e=!0){return this._state.polylineClosed=e,this}markerStart(e){return this._state.startEndpoint=e,this}markerEnd(e){return this._state.endEndpoint=e,this}markers(e,n){return this._state.startEndpoint=e,this._state.endEndpoint=n,this}},Vm=class extends wt{constructor(e,n,r,i,o){super("image"),this._state.x=e,this._state.y=n,this._state.width=r,this._state.height=i,this._state.href=o}position(e,n){return this._state.x=e,this._state.y=n,this}size(e,n){return this._state.width=e,this._state.height=n,this}src(e){return this._state.href=e,this}preserveAspectRatio(e){return this._state.preserveAspectRatio=e,this}};var Pl=class{_x1;_y1;_x2;_y2;_stops=[];_spreadMethod="pad";_opacity=1;_id;constructor(e=0,n=0,r=1,i=0){this._x1=e,this._y1=n,this._x2=r,this._y2=i,this._id=J()}stop(e,n,r=1){return this._stops.push({offset:e,color:n,opacity:r}),this}direction(e,n,r,i){return this._x1=e,this._y1=n,this._x2=r,this._y2=i,this}spread(e){return this._spreadMethod=e,this}opacity(e){return this._opacity=e,this}build(){return{type:"linear-gradient",id:this._id,x1:this._x1,y1:this._y1,x2:this._x2,y2:this._y2,stops:[...this._stops],spreadMethod:this._spreadMethod,opacity:this._opacity}}},Tl=class{_cx=.5;_cy=.5;_fx=.5;_fy=.5;_r=.5;_ry=.5;_rotation=0;_stops=[];_spreadMethod="pad";_opacity=1;_id;constructor(){this._id=J()}center(e,n){return this._cx=e,this._cy=n,this}focus(e,n){return this._fx=e,this._fy=n,this}radius(e,n){return this._r=e,this._ry=n??e,this}rotation(e){return this._rotation=e,this}stop(e,n,r=1){return this._stops.push({offset:e,color:n,opacity:r}),this}spread(e){return this._spreadMethod=e,this}opacity(e){return this._opacity=e,this}build(){return{type:"radial-gradient",id:this._id,cx:this._cx,cy:this._cy,fx:this._fx,fy:this._fy,r:this._r,ry:this._ry,rotation:this._rotation,stops:[...this._stops],spreadMethod:this._spreadMethod,opacity:this._opacity}}},Rl=class{_patternType;_color;_backgroundColor;_scale=1;_rotation=0;_opacity=1;_patternParams;_id;_svgContent;_width;_height;_patternUnits;_patternContentUnits;_patternTransform;_viewBox;_preserveAspectRatio;_x;_y;_customPatternId;constructor(e="stripes",n="#000000",r="#ffffff"){this._patternType=e,this._color=n,this._backgroundColor=r,this._id=J()}scale(e){return this._scale=e,this}rotation(e){return this._rotation=e,this}opacity(e){return this._opacity=e,this}params(e){return this._patternParams=e,this}svgContent(e){return this._svgContent=e,this}size(e,n){return this._width=e,this._height=n,this}patternUnits(e){return this._patternUnits=e,this}patternContentUnits(e){return this._patternContentUnits=e,this}patternTransform(e){return this._patternTransform=e,this}viewBox(e){return this._viewBox=e,this}preserveAspectRatio(e){return this._preserveAspectRatio=e,this}position(e,n){return this._x=e,this._y=n,this}customPatternId(e){return this._customPatternId=e,this}build(){let e,n,r;if(this._svgContent!==void 0)e=this._svgContent,n=this._width??10,r=this._height??10;else{let o=ep(this._patternType,this._scale,this._color,this._backgroundColor,this._patternParams);e=o.svgContent,n=this._width??o.width,r=this._height??o.height}let i={type:"pattern",id:this._id,patternType:this._svgContent!==void 0?"custom":this._patternType,color:this._color,backgroundColor:this._backgroundColor,scale:this._scale,rotation:this._rotation,opacity:this._opacity,svgContent:e,width:n,height:r,patternUnits:this._patternUnits??"userSpaceOnUse",patternParams:this._patternParams,patternTransform:this._patternTransform??(this._rotation?`rotate(${this._rotation})`:void 0)};return this._patternContentUnits&&(i.patternContentUnits=this._patternContentUnits),this._viewBox&&(i.viewBox=this._viewBox),this._preserveAspectRatio&&(i.preserveAspectRatio=this._preserveAspectRatio),this._x!==void 0&&(i.x=this._x),this._y!==void 0&&(i.y=this._y),this._customPatternId&&(i.customPatternId=this._customPatternId),i}};function az(t=0,e=0,n=1,r=0){return new Pl(t,e,n,r)}function cz(){return new Tl}function lz(t="stripes",e="#000000",n="#ffffff"){return new Rl(t,e,n)}var Yx={rows:4,cols:4,style:"classic",tabDepthPercent:20,tabPattern:"random",seed:1},dz=.04,uz=0;function pz(t){let e=t>>>0;return()=>{e=e+1831565813>>>0;let n=e;return n=Math.imul(n^n>>>15,n|1),n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}}function ae(t){return Number(t.toFixed(3)).toString()}function fz(t,e,n,r,i,o,s,a,c,l,d,u){return[[0,0],[.2,a],[.5+c+d,-o+l],[.5-o+c,o+l],[.5-2*o+c-d,3*o+l],[.5+2*o+c-d,3*o+l],[.5+o+c,o+l],[.5+c+d,-o+l],[.8,u],[1,0]].map(([f,m])=>{let g=e+f*r,h=n+m*i*s;return t?{x:g,y:h}:{x:h,y:g}})}function Hx(t,e,n,r,i,o,s,a,c,l,d){let u=[],p=(x,k)=>c==="alternating"?0:x+l()*(k-x),f=()=>l()<.5,m=p(-a,a),g=c==="alternating"?d%2===0:f(),h=null,y=m,b=p(-a,a),v=p(-a,a),I=p(-a,a);m=p(-a,a);for(let x=0;x<t;x++){x>0&&(h=g,g=c==="alternating"?(d+x)%2===0:f(),y=g===h?-m:m,b=p(-a,a),v=p(-a,a),I=p(-a,a),m=p(-a,a));let k=g?-1:1,T=n+x*i;u.push(fz(e,T,r,i,o,s,k,y,b,v,I,m))}return u}function Wx(t,e,n,r,i,o,s){let a=2*o;return[[0,0],[.2,0],[.4,0],[.4,a],[.4,a],[.6,a],[.6,a],[.6,0],[.8,0],[1,0]].map(([l,d])=>{let u=e+l*r,p=n+d*i*s;return t?{x:u,y:p}:{x:p,y:u}})}function Kx(t,e){return t+` C ${ae(e[1].x)} ${ae(e[1].y)} ${ae(e[2].x)} ${ae(e[2].y)} ${ae(e[3].x)} ${ae(e[3].y)} C ${ae(e[4].x)} ${ae(e[4].y)} ${ae(e[5].x)} ${ae(e[5].y)} ${ae(e[6].x)} ${ae(e[6].y)} C ${ae(e[7].x)} ${ae(e[7].y)} ${ae(e[8].x)} ${ae(e[8].y)} ${ae(e[9].x)} ${ae(e[9].y)}`}function Xx(t,e){return t+` C ${ae(e[8].x)} ${ae(e[8].y)} ${ae(e[7].x)} ${ae(e[7].y)} ${ae(e[6].x)} ${ae(e[6].y)} C ${ae(e[5].x)} ${ae(e[5].y)} ${ae(e[4].x)} ${ae(e[4].y)} ${ae(e[3].x)} ${ae(e[3].y)} C ${ae(e[2].x)} ${ae(e[2].y)} ${ae(e[1].x)} ${ae(e[1].y)} ${ae(e[0].x)} ${ae(e[0].y)}`}function mz(t,e={}){let n={...Yx,...e};if(n.rows<1||n.cols<1)throw new Error("generatePuzzlePieces: rows and cols must be >= 1");if(!Number.isFinite(t.width)||!Number.isFinite(t.height))throw new Error("generatePuzzlePieces: bounds must have finite width/height");if(t.width<=0||t.height<=0)throw new Error("generatePuzzlePieces: bounds must have positive width/height");let{rows:r,cols:i,style:o,tabDepthPercent:s,tabPattern:a,seed:c}=n,l=pz(c),d=t.width/i,u=t.height/r,p=Math.max(0,Math.min(.4,s/200)),f=(o==="classic"||o==="curved")&&p>0,m=o==="square-tabs"&&p>0,g=o==="classic"&&a==="random"?dz:uz,h=[];for(let v=0;v<r-1;v++){let I=t.y+(v+1)*u;if(f)h.push(Hx(i,!0,t.x,I,d,u,p,g,a,l,v));else if(m){let x=[];for(let k=0;k<i;k++){let T=a==="alternating"?(v+k)%2===0?1:-1:l()<.5?1:-1;x.push(Wx(!0,t.x+k*d,I,d,u,p,T))}h.push(x)}else h.push(new Array(i).fill(null))}let y=[];for(let v=0;v<i-1;v++){let I=t.x+(v+1)*d;if(f)y.push(Hx(r,!1,t.y,I,u,d,p,g,a,l,v));else if(m){let x=[];for(let k=0;k<r;k++){let T=a==="alternating"?(k+v)%2===0?1:-1:l()<.5?1:-1;x.push(Wx(!1,t.y+k*u,I,u,d,p,T))}y.push(x)}else y.push(new Array(r).fill(null))}let b=[];for(let v=0;v<r;v++)for(let I=0;I<i;I++){let x=t.x+I*d,k=t.y+v*u,T=x+d,w=k+u,P=`M ${ae(x)} ${ae(k)}`;if(v===0)P+=` L ${ae(T)} ${ae(k)}`;else{let N=h[v-1][I];N?P=Kx(P,N):P+=` L ${ae(T)} ${ae(k)}`}if(I===i-1)P+=` L ${ae(T)} ${ae(w)}`;else{let N=y[I][v];N?P=Kx(P,N):P+=` L ${ae(T)} ${ae(w)}`}if(v===r-1)P+=` L ${ae(x)} ${ae(w)}`;else{let N=h[v][I];N?P=Xx(P,N):P+=` L ${ae(x)} ${ae(w)}`}if(I===0)P+=` L ${ae(x)} ${ae(k)}`;else{let N=y[I-1][v];N?P=Xx(P,N):P+=` L ${ae(x)} ${ae(k)}`}P+=" Z",b.push({id:`puzzle-${c}-r${v}-c${I}`,row:v,col:I,d:P})}return b}var Jx=[1,2,3,4,5,6,7,8,9],gz={easy:{minGivens:40,maxGivens:45,maxRating:"singles"},medium:{minGivens:34,maxGivens:39,maxRating:"hidden-singles"},hard:{minGivens:28,maxGivens:33,maxRating:"search"},expert:{minGivens:24,maxGivens:27,maxRating:"search"}};function Rs(t){return t.map(e=>[...e])}function hz(){return Array.from({length:9},()=>Array.from({length:9},()=>0))}function Qx(t){let e=t>>>0;return()=>{e=e+1831565813>>>0;let n=e;return n=Math.imul(n^n>>>15,n|1),n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}}function eI(t,e){let n=[...t];for(let r=n.length-1;r>0;r--){let i=Math.floor(e()*(r+1));[n[r],n[i]]=[n[i],n[r]]}return n}function fo(t){return 1<<t-1}function tI(t){let e=0,n=t;for(;n;)n&=n-1,e++;return e}function yz(t){for(let e=1;e<=9;e++)if(t===fo(e))return e;return 0}function Um(t,e){return Math.floor(t/3)*3+Math.floor(e/3)}function jm(t){let e=0;for(let n of t)for(let r of n)r!==0&&e++;return e}function Sz(t){if(!Number.isFinite(t))return 1;let e=Math.floor(t);return e===0?1:e}function nI(t,e){if(!Array.isArray(t)||t.length!==9)return e.push("Grid must contain 9 rows."),!1;let n=!0;for(let r=0;r<9;r++){if(!Array.isArray(t[r])||t[r].length!==9){e.push(`Row ${r+1} must contain 9 cells.`),n=!1;continue}for(let i=0;i<9;i++){let o=t[r][i];(!Number.isInteger(o)||o<0||o>9)&&(e.push(`Cell R${r+1}C${i+1} must be a digit from 0 to 9.`),n=!1)}}return n}function rI(t,e){let n=!0,r=(i,o)=>{let s=0;for(let a of o){if(a===0)continue;let c=fo(a);if(s&c){e.push(`${i} contains duplicate ${a}.`),n=!1;return}s|=c}};for(let i=0;i<9;i++)r(`Row ${i+1}`,t[i]);for(let i=0;i<9;i++)r(`Column ${i+1}`,t.map(o=>o[i]));for(let i=0;i<9;i+=3)for(let o=0;o<9;o+=3){let s=[];for(let a=i;a<i+3;a++)for(let c=o;c<o+3;c++)s.push(t[a][c]);r(`Box ${Math.floor(i/3)*3+Math.floor(o/3)+1}`,s)}return n}function Hm(t){let e=Array.from({length:9},()=>0),n=Array.from({length:9},()=>0),r=Array.from({length:9},()=>0);for(let i=0;i<9;i++)for(let o=0;o<9;o++){let s=t[i][o];if(s===0)continue;let a=fo(s),c=Um(i,o);if(e[i]&a||n[o]&a||r[c]&a)return null;e[i]|=a,n[o]|=a,r[c]|=a}return{rows:e,cols:n,boxes:r}}function Wm(t,e,n,r,i){return 511&~(n[t]|r[e]|i[Um(t,e)])}function iI(t,e,n){let r=Hm(t);if(!r)return[];let i=Rs(t),o=[],{rows:s,cols:a,boxes:c}=r,l=()=>{if(o.length>=e)return;let d=-1,u=-1,p=0,f=10;for(let g=0;g<9;g++){for(let h=0;h<9;h++){if(i[g][h]!==0)continue;let y=Wm(g,h,s,a,c),b=tI(y);if(b===0)return;if(b<f&&(d=g,u=h,p=y,f=b,b===1))break}if(f===1)break}if(d===-1){o.push(Rs(i));return}let m=Jx.filter(g=>p&fo(g));n&&(m=eI(m,n));for(let g of m){let h=fo(g),y=Um(d,u);if(i[d][u]=g,s[d]|=h,a[u]|=h,c[y]|=h,l(),c[y]&=~h,a[u]&=~h,s[d]&=~h,i[d][u]=0,o.length>=e)return}};return l(),o}function bz(t){let e=hz(),n=Qx(t),[r]=iI(e,1,n);if(!r)throw new Error("generateSudokuPuzzle: failed to generate solved grid");return r}function vz(t){let e=Hm(t);if(!e)return null;for(let n=0;n<9;n++)for(let r=0;r<9;r++){if(t[n][r]!==0)continue;let i=Wm(n,r,e.rows,e.cols,e.boxes);if(tI(i)===1)return{row:n,col:r,value:yz(i)}}return null}function xz(t){let e=Hm(t);if(!e)return null;let n=r=>{for(let i of Jx){let o=fo(i),s=null;for(let a of r)if(!(t[a.row][a.col]!==0||!(Wm(a.row,a.col,e.rows,e.cols,e.boxes)&o))){if(s){s=null;break}s=a}if(s)return{...s,value:i}}return null};for(let r=0;r<9;r++){let i=n(Array.from({length:9},(o,s)=>({row:r,col:s})));if(i)return i}for(let r=0;r<9;r++){let i=n(Array.from({length:9},(o,s)=>({row:s,col:r})));if(i)return i}for(let r=0;r<9;r+=3)for(let i=0;i<9;i+=3){let o=[];for(let a=r;a<r+3;a++)for(let c=i;c<i+3;c++)o.push({row:a,col:c});let s=n(o);if(s)return s}return null}function qx(t){let e=Rs(t),n=!1;for(;jm(e)<81;){let r=vz(e);if(r){e[r.row][r.col]=r.value;continue}let i=xz(e);if(i){n=!0,e[i.row][i.col]=i.value;continue}return"search"}return n?"hidden-singles":"singles"}function Zx(t,e){let n={singles:0,"hidden-singles":1,search:2};return n[t]<=n[e]}function Cl(t,e={}){let n=[];return nI(t,n)?rI(t,n)?iI(t,Math.max(1,Math.floor(e.maxSolutions??2))):[]:[]}function Iz(t){let e=[];if(!nI(t,e))return{valid:!1,unique:!1,solution:null,errors:e};if(rI(t,e),e.length>0)return{valid:!1,unique:!1,solution:null,errors:e};let r=Cl(t,{maxSolutions:2});return r.length===0?e.push("Puzzle has no solution."):r.length>1&&e.push("Puzzle has more than one solution."),{valid:e.length===0,unique:r.length===1,solution:r[0]?Rs(r[0]):null,errors:e}}function wz(t){let e=t.difficulty,n=gz[e];if(!n)throw new Error(`generateSudokuPuzzle: unsupported difficulty "${e}"`);let r=Sz(t.seed);for(let i=0;i<30;i++){let o=r+i*104729>>>0,s=Qx(o),a=bz(o),c=Rs(a),l=n.minGivens+Math.floor(s()*(n.maxGivens-n.minGivens+1)),d=eI(Array.from({length:81},(m,g)=>({row:Math.floor(g/9),col:g%9})),s);for(let m of d){if(jm(c)<=l)break;let g=c[m.row][m.col];if(c[m.row][m.col]=0,Cl(c,{maxSolutions:2}).length!==1){c[m.row][m.col]=g;continue}let y=qx(c);Zx(y,n.maxRating)||(c[m.row][m.col]=g)}let u=jm(c),p=qx(c);if(Cl(c,{maxSolutions:2}).length===1&&u>=n.minGivens&&u<=n.maxGivens&&Zx(p,n.maxRating))return{puzzle:c,solution:a,difficulty:e,seed:r,givens:u,rating:p}}throw new Error(`generateSudokuPuzzle: unable to generate a ${e} puzzle`)}var oI="ABCDEFGHIJKLMNOPQRSTUVWXYZ";var kz={E:{direction:"E",dr:0,dc:1},S:{direction:"S",dr:1,dc:0},SE:{direction:"SE",dr:1,dc:1},NE:{direction:"NE",dr:-1,dc:1},W:{direction:"W",dr:0,dc:-1},N:{direction:"N",dr:-1,dc:0},NW:{direction:"NW",dr:-1,dc:-1},SW:{direction:"SW",dr:1,dc:-1}};function aI(t){if(!Number.isFinite(t))return 1;let e=Math.floor(t);return e===0?1:e}function cI(t){let e=t>>>0;return()=>{e=e+1831565813>>>0;let n=e;return n=Math.imul(n^n>>>15,n|1),n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}}function mo(t){let e=globalThis.Intl.Segmenter;return e?Array.from(new e(void 0,{granularity:"grapheme"}).segment(t),n=>n.segment.normalize("NFC")):Array.from(t.normalize("NFC"))}function Pz(t,e,n,r){return t>=0&&e>=0&&t<r&&e<n}function Km(t,e){return Array.from({length:e},()=>Array.from({length:t},()=>!0))}function lI(t,e,n,r){if(!n)return Km(t,e);if(!Array.isArray(n)||n.length!==e)return r.push(`Mask must contain exactly ${e} rows.`),Km(t,e);let i=[];for(let o=0;o<e;o++){if(!Array.isArray(n[o])||n[o].length!==t)return r.push(`Mask row ${o+1} must contain exactly ${t} cells.`),Km(t,e);i.push(n[o].map(Boolean))}return i}function Tz(t){let e=0;for(let n of t)for(let r of n)r&&e++;return e}function Rz(t){return t.trim().normalize("NFC")}function Cz(t){return t.replace(/\r/g,"").split(/[,\n]+/).map(e=>e.trim()).filter(e=>e.length>0)}function dI(t,e){let n=[];return t.across&&(n.push("E"),e&&n.push("W")),t.down&&(n.push("S"),e&&n.push("N")),t.diagonal&&(n.push("SE","NE"),e&&n.push("NW","SW")),n}function $z(t,e,n,r,i,o,s,a){let c=mo(t),l=[];for(let d=0;d<c.length;d++){let u=e+r.dr*d,p=n+r.dc*d;if(!Pz(u,p,o,s)||!i[u][p])return null;l.push({row:u,col:p,grapheme:c[d]})}return{word:t,graphemes:c,row:e,col:n,direction:r.direction,dr:r.dr,dc:r.dc,cells:l,jitter:a}}function uI(t,e,n,r,i,o){let s=[];for(let a of e){let c=kz[a];for(let l=0;l<i;l++)for(let d=0;d<r;d++){let u=$z(t,l,d,c,n,r,i,o());u&&s.push(u)}}return s}function pI(t){let e=[],n=[],r=[],i=Math.floor(t.width),o=Math.floor(t.height);(!Number.isInteger(i)||i<2||i>64)&&e.push("Width must be an integer from 2 to 64."),(!Number.isInteger(o)||o<2||o>64)&&e.push("Height must be an integer from 2 to 64.");let s=dI(t.axes,t.allowBackwards);s.length===0&&e.push("At least one word direction must be enabled.");let a=lI(Math.max(1,i),Math.max(1,o),t.mask,e),c=Tz(a);c===0&&e.push("Mask must contain at least one active cell.");let l=new Set,d=[];for(let f of t.words){let m=Rz(f);if(m){if(/\s/u.test(m)){r.push({input:f,reason:"Words cannot contain whitespace."});continue}if(l.has(m)){r.push({input:f,reason:"Duplicate word."});continue}l.add(m),d.push(m)}}d.length===0&&e.push("Enter at least one word.");let u=cI(aI(t.seed));if(e.length===0)for(let f=d.length-1;f>=0;f--){let m=d[f];uI(m,s,a,i,o,u).length===0&&(r.push({input:m,reason:"No legal placement exists for the current size, mask, and directions."}),d.splice(f,1))}r.length>0&&e.push(`${r.length} word${r.length===1?"":"s"} rejected.`);let p=Math.max(0,c);return d.length>p&&n.push("The word count exceeds the active cell count; overlaps may be required for this puzzle."),{valid:e.length===0,acceptedWords:d,rejectedWords:r,errors:e,warnings:n,minWords:1,maxWords:p,activeCells:c,directions:s}}function Nz(t,e){for(let n of e.cells){let r=t[n.row][n.col];if(r!==null&&r!==n.grapheme)return!0}return!1}function Az(t,e){let n=[];for(let r of e.cells)t[r.row][r.col]===null&&(n.push({row:r.row,col:r.col}),t[r.row][r.col]=r.grapheme);return n}function Ez(t,e){for(let n of e)t[n.row][n.col]=null}function sI(t,e){let n=0;for(let r of e.cells)t[r.row][r.col]===r.grapheme&&n++;return n}function Mz(t){return{word:t.word,row:t.row,col:t.col,direction:t.direction,path:t.cells.map(e=>({...e}))}}function Oz(t){let e=t.fillerAlphabet??oI,n=typeof e=="string"?mo(e):e.flatMap(i=>mo(i)),r=n.filter((i,o)=>i.trim()&&n.indexOf(i)===o);return r.length>0?r:mo(oI)}function Dz(t){let e=Math.floor(t.width),n=Math.floor(t.height),r=aI(t.seed),i=pI({...t,width:e,height:n,seed:r});if(!i.valid)throw new Error(`generateWordSearch: ${i.errors[0]??"invalid options"}`);let o=lI(e,n,t.mask,[]),s=Math.max(1,Math.floor(t.maxBacktrackNodes??15e4));for(let a=0;a<24;a++){let c=cI(r+a*104729>>>0),l=i.directions,d=new Map;for(let b of i.acceptedWords)d.set(b,uI(b,l,o,e,n,c));let u=[...i.acceptedWords].sort((b,v)=>{let I=d.get(b)?.length??0,x=d.get(v)?.length??0;return I!==x?I-x:mo(v).length-mo(b).length}),p=Array.from({length:n},(b,v)=>Array.from({length:e},(I,x)=>o[v][x]?null:"")),f=[],m=new Map,g=0,h=b=>{if(++g>s)return!1;if(b>=u.length)return!0;let v=u[b],I=[...d.get(v)??[]].filter(x=>!Nz(p,x)).sort((x,k)=>{let T=sI(p,k)-sI(p,x);if(T!==0)return T;let w=(m.get(x.direction)??0)-(m.get(k.direction)??0);return w!==0?w:x.jitter-k.jitter});for(let x of I){let k=Az(p,x);if(f.push(Mz(x)),m.set(x.direction,(m.get(x.direction)??0)+1),h(b+1))return!0;m.set(x.direction,(m.get(x.direction)??1)-1),f.pop(),Ez(p,k)}return!1};if(!h(0))continue;let y=Oz(t);for(let b=0;b<n;b++)for(let v=0;v<e;v++)o[b][v]?p[b][v]===null&&(p[b][v]=y[Math.floor(c()*y.length)]):p[b][v]="";return{width:e,height:n,grid:p,mask:o.map(b=>[...b]),normalizedWords:[...i.acceptedWords],placements:[...f],seed:r,title:t.title,creator:t.creator,lint:i}}throw new Error("generateWordSearch: unable to place all words with the current settings")}function zz(t,e,n){let r=!1;for(let i=0,o=n.length-1;i<n.length;o=i++){let s=n[i],a=n[o];s.y>e!=a.y>e&&t<(a.x-s.x)*(e-s.y)/(a.y-s.y)+s.x&&(r=!r)}return r}function _z(){let t=[];for(let e=0;e<10;e++){let n=e%2===0?.5:.23,r=-Math.PI/2+e*Math.PI/5;t.push({x:.5+Math.cos(r)*n,y:.5+Math.sin(r)*n})}return t}function Fz(t,e,n){let r=Math.max(1,Math.floor(t)),i=Math.max(1,Math.floor(e)),o=_z();return Array.from({length:i},(s,a)=>Array.from({length:r},(c,l)=>{let d=(l+.5)/r,u=(a+.5)/i,p=d*2-1,f=u*2-1;switch(n){case"rectangle":return!0;case"circle":return p*p+f*f<=1;case"triangle":return u>=.08&&u<=.95&&Math.abs(p)<=u;case"diamond":return Math.abs(p)+Math.abs(f)<=1;case"star":return zz(d,u,o);case"heart":{let m=p*1.25,g=-f*1.25;return Math.pow(m*m+g*g-1,3)-m*m*g*g*g<=0}case"cross":return Math.abs(p)<=.32||Math.abs(f)<=.32;default:return!0}}))}export{zu as ANIMATION_MANAGER_INTERPOLATION_POLICY,Rm as Arrow,Lm as Audio,MP as BROWSER_SVG_EXTENSION_URIS,Lc as BUILTIN_MARKER_ID_MAP,XO as CANONICAL_NORMALIZATION_FAULT_POINTS,Qr as CC_NS,yw as COLLAB_PROTOCOL_VERSION,Je as COMMON_PROP_DEFAULTS,Zm as COMMON_TRANSFORM_NODE_DEFAULTS,Lt as CURRENT_SCHEMA_VERSION,wi as CanonicalDocument,mm as Circle,Nm as Cloud,Om as Container,di as ContainerShapeBuilder,wm as Cross,Zt as DC_NS,Oc as DEFAULT_COORDINATE_PRECISION,yi as DEFAULT_RICH_TEXT_STYLE,$t as DOCUMENT_FIELDS,od as DOCUMENT_FIELD_LIVE_AUTHORITY,zc as DOCUMENT_INGEST_POLICIES,sf as DOCUMENT_SECTION_ORDER,um as DocumentBuilder,Br as DocumentModel,ld as DocumentSession,ui as EASING_CURVES,nr as EasingType,gm as Ellipse,Tm as Gear,Db as HEADLESS_SVG_STYLE_ENVIRONMENT,Cm as Heart,Em as Hyperlink,_e as IDENTITY_AFFINE,X0 as INGEST_APPLY_STAGES,_0 as INGEST_DIAGNOSTIC_CODES,Ma as INGEST_DOCUMENT_ROOT_IDENTITY,Ea as INGEST_FEATURES,Kd as INGEST_FEATURE_CAPABILITIES,Oi as INGEST_PLAN_VERSION,Eo as INGRESS_INTENTS,js as INLINE_CHILD_CONTAINER_TYPES,Vm as ImageShape,Fa as IngestApplicationError,yc as KNOWN_METADATA_PREFIXES,ng as KNOWN_STATE_KEYS,sd as LIBRARY_ASSEMBLY_KIND_ORDER,Lv as LIBRARY_EMIT_ORDER,$m as Lightning,Sm as Line,Pl as LinearGradientBuilder,yf as MARKER_HEIGHT,Fc as MARKER_VIEWBOX,hf as MARKER_WIDTH,Cy as MATHML_EXTENSION_URI,pf as MAX_COORDINATE_PRECISION,av as MIGRATIONS,xm as NGon,CI as NON_WIRE_PROP_KEYS,Cs as NUMERIC_SHAPE_TRANSFORM_STATE_KEYS,zm as NestedSvg,Ms as NodeSchemaRegistry,Xs as PAINT_SERVER_PASSTHROUGH_ATTR,gc as PRESENTATION_SEMANTICS,Yx as PUZZLE_DEFAULTS,Bm as Path,Xm as PathCurveType,fI as PathPointType,Rl as PatternBuilder,Gm as Polyline,Xi as RDF_NS,gf as RENDER_DIAGNOSTIC_CODES,cM as RENDER_FEATURES,lM as RENDER_FEATURE_CAPABILITIES,PM as RENDER_TARGETS,xo as RICH_TEXT_STYLE_KEYS,Tl as RadialGradientBuilder,hm as Rectangle,km as Ring,gy as SAXES_SVG_XML_PARSER_HOST,Ym as SERIALIZED_SHAPE_STATE_KEYS,TM as SHAPE_ENVELOPE_KEYS,qm as SHAPE_TRANSFORM_STATE_KEYS,Jr as SVGSKETCH_NS,Ek as SVGSKETCH_PATH_EXTENSIONS,ou as SVG_CONDITIONAL_PROCESSING_ATTRIBUTES,Ey as SVG_IMPORT_CAPABILITY_OWNERS,Y as SVG_NAMESPACE,rA as SVG_NS,ja as SVG_PRESENTATION_PROPERTIES,zr as SceneGraph,rn as SceneNode,wt as ShapeBuilder,_m as ShapeReference,Am as SpeechBubble,Pm as Spiral,ym as Square,Im as Star,nl as SvgImportError,Oo as SvgXmlParserHostError,Mm as Switch,Sc as TYPED_FIELD_PREDICATES,bm as Text,Gc as TextLayoutEngine,fm as Timeline,pm as Track,vm as Triangle,Qa as VARIANT_INTERPOLATION_POLICY,Fm as Video,Dm as View,Ry as XHTML_EXTENSION_URI,Ta as addSmilPointsValues,ht as affine,ia as affineFromArray,ot as affineToArray,CF as almostEqualAffine,ah as animationBackwardsFillTrack,ih as animationCycleDuration,sh as animationTrackActiveEnd,oh as animationTrackDocumentBegin,Ye as applyAffineToPoint,fd as applyAffineToVector,cr as applyClipMaskGroupDelta,$x as applyClipMaskPlanToShapes,uh as applyCssAnimationLonghandOverrides,_s as applyGuideDeltaOp,J0 as applyIngestPlan,Fs as applyMeasurementDeltaOp,HI as applyMetadataDeltaOp,id as applyOpToSnapshot,Hg as applyOpsInPlace,gw as applyOpsToSnapshot,Wg as applyOpsToSnapshotWithAccepted,Gs as applyRichTextFormat,KI as applyTextSplice,ai as applyTextTransform,th as applyTimingFunctionToKeyframe,Ia as arcEndpointToCenter,Ix as areTracksTimingEquivalent,vh as around,Zg as assembleLibraryDefs,Mx as assembleSvgFromPlan,B0 as assertIngestFeatureRegistry,fv as assertIngestPolicyRegistry,HP as assertSvgImportCapabilityOwners,Bf as buildCompoundTransformValues,fp as buildFreshMetadataBlock,VI as buildGuideDeltaOps,gp as buildManagedChildren,pb as buildManagedDescription,jI as buildMeasurementDeltaOps,UI as buildMetadataDeltaOps,Pn as buildRenderPlan,Mr as buildSmilKeyframeData,An as buildSmilKeyframes,uB as buildSvgDestinationIdentityIndex,KO as buildSvgIngestPlan,Vf as buildSymbolMaterializationPlan,kh as canonicalPolygonTransformString,hn as canonicalTransformMatrix,Rt as canonicalTransformString,ti as classifySvgExternalAssetUrl,ql as clipMaskDefinitionFromGroup,jn as clipMaskDefinitionsFromGroups,Sl as clipMaskGroupDefId,Ot as clipMaskGroupDefinitionId,Yl as clipMaskGroupIsRawBacked,vi as clipMaskGroupWithDefinition,Yf as clipMaskOwnedDefIds,Ag as collaborationResourceKey,kf as collectDocumentEnvelopeLibraryReferenceIds,rx as collectFontFamiliesFromPlan,Di as collectMarkerReferences,Yc as collectReferencedLibraryDefs,K0 as collectReferencedMarkerIds,Fv as collectSvgFragmentLibraryReferenceIds,af as collectUnknownDocumentFields,Es as compareOrderKeys,la as composeDecomposedTransformMatrix,vd as computeArrowVertices,kd as computeCloudPath,bd as computeCrossVertices,Nd as computeDashArray,$d as computeFlowchartBoxPath,Rd as computeGearPath,_h as computeGearVertices,wd as computeHeartPath,Id as computeLightningVertices,Sa as computePolygonVertices,Cd as computeRectanglePath,Pd as computeRingPath,xd as computeSpeechBubbleVertices,Td as computeSpiralPath,Ur as computeSplinePath,Sd as computeStarVertices,Gt as containerTransformNeedsContentPivot,Xo as createDocument,gi as createSceneNode,KA as createShape,pB as createSvgDestinationIdAllocator,GD as createSvgPathMetrics,PV as createTextLayoutKey,TV as createTextLayoutProduct,Zi as createViewbox,Fz as createWordSearchPrimitiveMask,fh as cssAnimationFillField,Lo as cssNamedColorToRgb,Od as cubicBezierExtent1D,dd as cubicBezierToEasingFields,os as customPatternDefToLibraryDef,jl as declaredRichTextDeltaKeys,Po as decodeCssEscapes,aa as decomposeAffine2D,Vz as defaultVariableMode,ew as deriveRichTextFormatRanges,Kl as deriveSegments,WI as deriveTextSplice,NE as documentObjectBounds,Uh as ellipticalArcBounds,ad as emptyDocumentMetadata,fe as escXml,nh as evaluateParsedTimingFunction,FP as evaluateSvgConditionalProcessing,uf as extractVariables,ZN as filterAttr,ZS as filterChainExtendsBounds,op as filterDefinitionEnvelope,uc as filterReferenceValue,Tf as finalizeRenderPlan,Ks as findShapeById,Oa as fingerprintIngestSource,Ol as flattenShapeStateTree,Dr as flattenStateExtra,us as flattenUnknownDocumentFields,wh as foldSchemaV2AncestorTransformIntoMatrix,W0 as forEachLibraryRefInState,H0 as forEachMarkerRefInState,_a as forEachReachableShape,Xd as forEachShapeInLibraryDefs,GI as formatOperationValidationIssues,Of as formatSmilKeySpline,Et as formatSmilKeyTime,Da as freezeIngestPlan,Ws as freezeSiblingOrderKeys,dm as generateCode,Ux as generateCodeWithDiagnostics,lm as generateCssCode,cm as generateD3Code,J as generateId,ep as generatePatternSvgContent,mz as generatePuzzlePieces,sm as generateReactCode,wz as generateSudokuPuzzle,om as generateSvgCode,am as generateVueCode,Dz as generateWordSearch,CM as getBuiltInMarkerDefs,Lz as getEasingCubicBezier,ff as getEffectivePrecision,L0 as getIngestFeatureCapability,La as getIngestFieldPolicy,bx as getKeyframeCubicBezier,ub as getLicenseLabel,db as getLicenseUrl,no as getMarkerDescriptors,ac as getPatternElements,Ao as getShapeGeometryKernel,cl as getSmilAdditive,lo as getSmilBeginValue,ci as getSmilFillMode,Ff as getSmilMotionKeyPoints,_f as getSmilRepeatCount,zf as getSmilSetBeginValue,Er as getSmilTrackDuration,Xr as getSvgPropertySemantics,C as getSvgSourceAttribute,Be as getSvgSourceHref,dI as getWordSearchDirections,pp as hasAnyTypedMetadataField,yt as hasSvgSourceAttribute,Ef as importSvg,hx as importSvgWithDiagnostics,qo as indexLibraryDefinitions,El as initialOrderKeys,Jf as injectClipMaskReference,Gf as injectDomTargetAnimationElements,zh as inspectCssTransformValue,vS as interpolateAngle,nC as interpolateCharOffsetArray,IS as interpolateColor,NL as interpolateDasharrayLists,rC as interpolateGradient,Du as interpolateNumericArray,CL as interpolatePathData,iC as interpolatePlainObject,eC as interpolatePointArray,$L as interpolatePolylinePoints,pC as interpolateShapeTrees,tC as interpolateSplinePointArray,$F as invertAffine,TL as isColorValue,Ou as isCssNamedColor,Df as isDefaultKeyPoints,ol as isDefaultKeyTimes,pr as isFiniteAffineArray,hS as isGradientLike,Dt as isIdentityAffine,xx as isIdentityLinearSplines,sl as isIndefiniteSetTrack,Pr as isNumericArray,qb as isReusablePatternTile,al as isSetSequenceTrack,uu as isSvgPresentationProperty,As as isValidOrderKey,yo as keyBetween,Al as keysBetween,MM as layoutText,za as legacyEndpointMarkerId,Oe as lerpNumber,az as linearGradient,rp as linearGradientEnvelope,pI as lintWordSearchOptions,xF as mapAnimationTrackTime,kw as matchCubicBezierToPreset,hw as materializeSceneTreeOrderKeys,ca as matrixTransformPart,ow as maxCollaborationTimestamp,vo as mergeRichTextStyle,ls as migrateSnapshot,sv as migrateV11toV12,ov as migrateV6toV7,cs as migrateViewboxSidecarToViews,vl as motionPathD,bo as moveResourceById,he as multiplyAffine,NA as mutateSvgClipMaskDefinitionMarkup,pe as nodeSchemas,Tn as normalizeClipMaskGroups,qs as normalizePaintServerDef,Si as normalizeRichTextRuns,Vn as normalizeRichTextStyle,Bs as normalizeRichTextStyleDelta,d0 as normalizeSmilPointsValue,QO as normalizeSnapshotStructure,rD as normalizeSnapshotToCanonicalDocument,mt as orderSiblings,ec as parseColor,pd as parseCssAnimationShorthand,ki as parseCssTimingFunction,fa as parseCssTransformOrigin,of as parseDocument,uv as parseDocumentWithDiagnostics,RL as parseInterpolationNumbers,Do as parsePreserveAspectRatio,Bd as parseSmilAdditive,dr as parseSmilClockValue,Gd as parseSmilDuration,Jh as parseSmilFillField,yr as parseSmilKeySplines,hr as parseSmilKeyTimes,Zh as parseSmilRepeatSettings,Hr as parseSmilValues,Wt as parseSvgAbsoluteLength,Re as parseSvgLength,Ti as parseSvgLengthList,gt as parseSvgLengthToken,Nn as parseSvgPathData,Qd as parseSvgRootFrame,ln as parseSvgSourceDocument,tR as parseSvgStyleAttribute,Kt as parseSvgTransformList,at as parseSvgViewBox,SM as parseVariableArgs,Cz as parseWordSearchWords,Ml as partitionShapeStateTree,Ds as partitionStateExtra,ps as partitionUnknownDocumentFields,QR as pathCommandStructuresMatch,Sn as pathDataBounds,lz as pattern,np as patternDefinitionEnvelope,qp as patternLibraryDefToCustomPatternDef,Zb as patternTileSize,ea as pickCssAnimationListItem,Zf as planClipMaskGroups,VA as planSnapshotExternalEffects,Ru as planSvgAnimations,yu as planSvgAuthoredAttributes,ju as planSvgClipMasks,su as planSvgConditionalProcessing,ru as planSvgContainerHierarchy,tu as planSvgEmbeddedFrames,Op as planSvgExternalEffects,Ju as planSvgFilters,Wu as planSvgGradients,Cc as planSvgImport,Mu as planSvgLeafGeometry,Uu as planSvgMarkers,kp as planSvgMetadata,qu as planSvgPaintServerDefinitions,Ku as planSvgPatterns,hu as planSvgResourceDependencies,Qu as planSvgScripts,cu as planSvgSourceIdentifiers,Pu as planSvgStyleCascade,fu as planSvgSymbolUses,du as planSvgUseOccurrences,eu as planSvgViews,Lf as planTransformFusion,JD as planVariantTransitionsCss,YD as planVariantTransitionsSmil,QD as planVariantTransitionsWaapi,bc as prepareSvgAuthorCssForLiveProjection,Rb as prepareSvgExternalAssetUrlForLiveProjection,RA as prepareSvgMarkupForLiveProjection,fy as prepareSvgXmlSource,hy as preserveAspectRatioAlignFactor,ha as projectCssTransformStops,Ho as projectPresentation,lp as projectPresentationEntry,Us as projectSceneTreeOntoClipMaskGroups,Ii as projectSceneTreeOntoShapes,sy as projectSvgAnimationPlan,Na as projectSvgAnimationTimeline,wu as projectSvgCustomProperties,gx as projectSvgImportToIngestPlan,Af as projectSvgImportToSnapshot,fb as promoteManagedDescription,sw as promoteRebasedShapeUpdateClock,bl as pruneAndWrapSubtree,Dd as quadraticBezierExtent1D,cz as radialGradient,ip as radialGradientEnvelope,QI as rebaseRichTextFormatRanges,nw as rebaseRichTextRuns,il as reflectCubicBezier,a0 as registeredShapeGeometryTypes,Bt as removeResourceById,Fl as removeResourceByKey,Bl as removeResourceByName,Gg as removeTrackKeyframe,fl as renderAnimationElements,wf as renderBuiltinMarkerDefs,vv as renderCircle,yp as renderDescriptiveElements,Wf as renderDocumentScripts,Hf as renderDocumentStyles,xv as renderEllipse,qN as renderFilterDefs,dc as renderFilterElement,Uv as renderFilterLibraryDef,sp as renderFilterPrimitive,rb as renderFilterPrimitivesForType,Ev as renderFlowchartBox,Cv as renderForeignObject,QM as renderGradientDefs,Rv as renderImage,Hc as renderLibraryDef,Xc as renderLibraryDefs,wv as renderLine,gs as renderLinearGradient,Gv as renderLinearGradientLibraryDef,Bv as renderMarkerLibraryDef,Xf as renderPaintServerDefs,jv as renderPatternLibraryDef,Vt as renderPlanDefsBody,Mv as renderPolygonShape,Tv as renderPolyline,hs as renderRadialGradient,Vv as renderRadialGradientLibraryDef,Iv as renderRectangle,eO as renderReferencedLibraryDefs,ys as renderResolvedSymbolLibraryDef,fn as renderShape,Qn as renderShapeContextForLibrary,Pv as renderSpline,nb as renderSvgPrimitiveChainFilter,Av as renderSymbolInstance,Wc as renderSymbolLibraryDef,Uf as renderTemplateVariablesStyle,kv as renderText,Ps as renderToSvg,xl as renderToSvgWithDiagnostics,Zl as replaceClipMaskDefinition,lr as replaceClipMaskGroupsInSceneTree,Sw as replaySceneTreePlacements,Zo as resolveContainerTransform,$c as resolveContainerTransformFromContentBounds,dh as resolveCssAnimationEasingType,ii as resolveEmbeddedSvgTransform,TE as resolveEmbeddedSvgViewportFrameBounds,Yp as resolveInlineContainerTransform,mp as resolveMetadataQName,ZI as resolveRichTextStyleAt,cn as resolveShapeGeometry,is as resolveShapeLocalObjectBounds,rs as resolveShapeObjectBounds,Kp as resolveShapeReferenceTransform,FS as resolveSvgGradientGeometry,ur as resolveSvgLengthToken,GS as resolveSvgPatternTile,zo as resolveSvgViewport,Ai as resolveSymbolInstanceContent,Yk as resolveSymbolInstanceShapes,Xp as resolveSymbolInstanceTransform,Qo as resolveSymbolViewport,dM as rewriteDocumentEmbeddedPayloads,Jc as rewriteIdReferencesInMarkup,nf as rewriteShapeStateEmbeddedPayloads,MT as rewriteSvgResourceReferenceValue,fs as richTextFontVariantCss,kg as richTextLineSpans,bi as richTextRunsFromState,Gl as richTextStyleDelta,Hl as richTextStyleDeltasEqual,sr as richTextStylesEqual,Sf as richTextTspanAttributes,hp as rootMetadataAttrs,Ys as rootPaintServerDefId,Ro as rotateAffine,zn as roundCoord,Jv as roundMarkupCoordinates,Dc as roundNumberString,pv as roundSerializedShape,IM as roundSnapshot,ar as runsFromSegments,Xl as sanitizeRichTextFormatRanges,qn as sanitizeXmlId,Ci as scaleAffine,Cn as scanCssFunctionTokens,Wn as scanCssLocalUrlTokens,pw as senderCorrectionsForOp,Md as serializeSvgPathData,Ki as serializedPresentationReader,Pa as shapeLocalObjectBounds,Ld as shapeLocalObjectCenter,jp as shapeObjectBoundsInSpace,oa as skewXAffine,sa as skewYAffine,ll as smilKeyframeAttributes,Zn as snapshotBoundsView,vx as solveCubicBezier,Cl as solveSudoku,Wk as splinePathBounds,Qs as splitCssAnimationList,Pi as splitCssTopLevel,Hn as splitCssTopLevelRanges,Ss as splitTopLevelElements,rf as stringifyDocument,hl as stripAnimationDeclarations,cf as substituteString,Mc as substituteVariables,Pf as symbolDefinitionSemanticHash,No as symbolInstanceTargetId,ph as synthesizeCssAnimationShorthand,yl as templateVariablesCss,Ls as transformSplice,Lk as transformSvgPathData,qe as translateAffine,Fk as translateSvgPathData,on as tryParseSvgTransformList,Mt as upsertResourceById,_l as upsertResourceByKey,Ll as upsertResourceByName,Bg as upsertTrackKeyframe,LI as validateDocumentOperations,zl as validateOperation,BI as validatePresenceOperation,ni as validateSnapshot,Iz as validateSudokuPuzzle,$n as verticesToPath,mn as visitShapeTree,rt as visitSnapshotShapeTrees};