@svgsketch/core 2.0.0 → 2.2.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.d.mts +404 -49
- package/dist/index.d.ts +404 -49
- package/dist/index.js +17 -17
- package/dist/index.mjs +17 -17
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
"use strict";var pi=Object.defineProperty;var No=Object.getOwnPropertyDescriptor;var Oo=Object.getOwnPropertyNames;var zo=Object.prototype.hasOwnProperty;var Go=(t,e)=>{for(var r in e)pi(t,r,{get:e[r],enumerable:!0})},Vo=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Oo(e))!zo.call(t,i)&&i!==r&&pi(t,i,{get:()=>e[i],enumerable:!(n=No(e,i))||n.enumerable});return t};var Uo=t=>Vo(pi({},"__esModule",{value:!0}),t);var ef={};Go(ef,{Arrow:()=>qn,Audio:()=>ui,BUILTIN_MARKER_ID_MAP:()=>Xi,COMMON_PROP_DEFAULTS:()=>H,COMMON_TRANSFORM_NODE_DEFAULTS:()=>bi,CURRENT_SCHEMA_VERSION:()=>ae,Circle:()=>Bn,Cloud:()=>Jn,Container:()=>ni,ContainerShapeBuilder:()=>Oe,Cross:()=>jn,DEFAULT_COORDINATE_PRECISION:()=>Aa,DEFAULT_RICH_TEXT_STYLE:()=>Tt,Document:()=>Qt,DocumentBuilder:()=>Qt,EASING_CURVES:()=>sr,EasingType:()=>ir,Ellipse:()=>Nn,Gear:()=>Yn,Heart:()=>Zn,Hyperlink:()=>ti,IDENTITY_AFFINE:()=>Ct,ImageShape:()=>fi,KNOWN_STATE_KEYS:()=>$i,LIBRARY_EMIT_ORDER:()=>as,Lightning:()=>Qn,Line:()=>Gn,LinearGradientBuilder:()=>Jt,MARKER_HEIGHT:()=>an,MARKER_VIEWBOX:()=>jt,MARKER_WIDTH:()=>sn,MAX_COORDINATE_PRECISION:()=>Ma,MIGRATIONS:()=>Oi,NGon:()=>Wn,NON_WIRE_PROP_KEYS:()=>Us,NUMERIC_SHAPE_TRANSFORM_STATE_KEYS:()=>mt,NestedSvg:()=>si,NodeSchemaRegistry:()=>St,PUZZLE_DEFAULTS:()=>Ps,Path:()=>ci,PathCurveType:()=>mi,PathPointType:()=>Ns,PatternBuilder:()=>tr,Polyline:()=>di,RICH_TEXT_STYLE_KEYS:()=>et,RadialGradientBuilder:()=>er,Rectangle:()=>On,Ring:()=>Xn,SERIALIZED_SHAPE_STATE_KEYS:()=>gi,SHAPE_TRANSFORM_STATE_KEYS:()=>yi,SceneGraph:()=>dr,SceneNode:()=>ke,ShapeBuilder:()=>q,ShapeReference:()=>ai,SpeechBubble:()=>ei,Spiral:()=>Kn,Square:()=>zn,Star:()=>Hn,Switch:()=>ri,Text:()=>Vn,Timeline:()=>Ln,Track:()=>En,Triangle:()=>Un,Video:()=>li,View:()=>ii,affine:()=>Re,affineFromArray:()=>wr,affineToArray:()=>De,almostEqualAffine:()=>yl,applyAffineToPoint:()=>xl,applyAffineToVector:()=>Sl,applyOpToSnapshot:()=>Ai,applyOpsToSnapshot:()=>ua,applyRichTextFormat:()=>wt,applyTextSplice:()=>Hs,applyTextTransform:()=>Xt,arcEndpointToCenter:()=>vs,areTracksTimingEquivalent:()=>bs,around:()=>Fi,buildCompoundTransformValues:()=>$n,buildSmilKeyframeData:()=>Ne,canonicalPolygonTransformString:()=>Li,canonicalTransformString:()=>at,collectMarkerReferences:()=>Wt,collectReferencedLibraryDefs:()=>Yt,collectReferencedMarkerIds:()=>Ua,compareOrderKeys:()=>xt,composeLegacyTransformMatrix:()=>Et,computeArrowVertices:()=>Vr,computeCloudPath:()=>jr,computeCrossVertices:()=>Gr,computeDashArray:()=>lt,computeFlowchartBoxPath:()=>Zr,computeGearPath:()=>Yr,computeGearVertices:()=>Ui,computeHeartPath:()=>Hr,computeLightningVertices:()=>Wr,computePolygonVertices:()=>Gt,computeRectanglePath:()=>qr,computeRingPath:()=>Xr,computeSpeechBubbleVertices:()=>Ur,computeSpiralPath:()=>Kr,computeSplinePath:()=>Fe,computeStarVertices:()=>zr,createDocument:()=>Ar,createSceneNode:()=>Ge,createShape:()=>_a,createViewbox:()=>Ot,createWordSearchPrimitiveMask:()=>Bo,cubicBezierExtent1D:()=>_n,customPatternDefToLibraryDef:()=>rt,declaredRichTextDeltaKeys:()=>pr,decomposeAffine2D:()=>Ul,defaultVariableMode:()=>Ho,deriveRichTextFormatRanges:()=>Qs,deriveSegments:()=>_e,deriveTextSplice:()=>Ws,downTranslateAnimationKeyframeOps:()=>fa,downTranslateCollectionMoveOps:()=>pa,downTranslateScenePlaceOps:()=>da,downTranslateTextFormatOps:()=>ha,ellipticalArcBounds:()=>Ts,escXml:()=>W,extractVariables:()=>Lr,filterAttr:()=>rn,findShapeById:()=>tt,flattenShapeStateTree:()=>$t,flattenStateExtra:()=>Te,foldLegacyAncestorTransformIntoMatrix:()=>Ei,forEachLibraryRefInState:()=>Va,forEachMarkerRefInState:()=>Ga,forEachReachableShape:()=>Ut,forEachShapeInLibraryDefs:()=>za,formatSmilKeySpline:()=>fn,formatSmilKeyTime:()=>ie,freezeSiblingOrderKeys:()=>Rt,generateCode:()=>Fn,generateCssCode:()=>Dn,generateD3Code:()=>In,generateId:()=>_,generatePatternSvgContent:()=>nn,generatePuzzlePieces:()=>yo,generateReactCode:()=>Mn,generateSudokuPuzzle:()=>Ro,generateSvgCode:()=>An,generateVueCode:()=>Cn,generateWordSearch:()=>Lo,getBuiltInMarkerDefs:()=>Wa,getEasingCubicBezier:()=>Wo,getEffectivePrecision:()=>Ca,getKeyframeCubicBezier:()=>ps,getMarkerDescriptors:()=>je,getPatternElements:()=>Ht,getSmilAdditive:()=>bn,getSmilBeginValue:()=>Xe,getSmilFillMode:()=>Ke,getSmilMotionKeyPoints:()=>xn,getSmilRepeatCount:()=>yn,getSmilSetBeginValue:()=>gn,getSmilTrackDuration:()=>Be,getWordSearchDirections:()=>Is,initialOrderKeys:()=>ur,invertAffine:()=>bl,isDefaultKeyPoints:()=>hn,isDefaultKeyTimes:()=>qt,isFiniteAffineArray:()=>it,isIdentityAffine:()=>Di,isIdentityLinearSplines:()=>ys,isIndefiniteSetTrack:()=>pn,isReusablePatternTile:()=>Mi,isSetSequenceTrack:()=>mn,isValidOrderKey:()=>bt,keyBetween:()=>Ze,keysBetween:()=>lr,legacyEndpointMarkerId:()=>Vt,linearGradient:()=>uo,lintWordSearchOptions:()=>Ds,materializeSceneTreeOrderKeys:()=>ca,matrixTransformPart:()=>Ii,mergeRichTextStyle:()=>fr,migrateSnapshot:()=>Rr,moveResourceById:()=>Sr,multiplyAffine:()=>K,nodeSchemas:()=>D,normalizeRichTextRuns:()=>Ve,normalizeRichTextStyle:()=>ge,normalizeRichTextStyleDelta:()=>kt,orderSiblings:()=>We,parseDocument:()=>Cr,parseSvgTransformList:()=>Pr,parseVariableArgs:()=>Ra,parseWordSearchWords:()=>Fo,partitionShapeStateTree:()=>ze,partitionStateExtra:()=>cr,pathDataBounds:()=>ws,pattern:()=>fo,patternLibraryDefToCustomPatternDef:()=>Tr,patternTileSize:()=>Ci,planTransformFusion:()=>Sn,projectSceneTreeOntoClipMaskGroups:()=>Pt,projectSceneTreeOntoShapes:()=>$r,quadraticBezierExtent1D:()=>Rn,radialGradient:()=>co,rebaseRichTextFormatRanges:()=>Zs,rebaseRichTextRuns:()=>Js,reflectCubicBezier:()=>gs,removeTrackKeyframe:()=>Ri,renderAnimationElements:()=>kn,renderBuiltinMarkerDefs:()=>Se,renderCircle:()=>Yi,renderEllipse:()=>qi,renderFilterDefs:()=>Na,renderFilterLibraryDef:()=>hs,renderFilterPrimitive:()=>tn,renderFilterPrimitivesForType:()=>Hi,renderFlowchartBox:()=>is,renderImage:()=>rs,renderLibraryDef:()=>os,renderLibraryDefs:()=>Kt,renderLine:()=>Qi,renderLinearGradientLibraryDef:()=>cs,renderMarkerLibraryDef:()=>us,renderPatternLibraryDef:()=>fs,renderPolygonShape:()=>ss,renderPolyline:()=>ts,renderRadialGradientLibraryDef:()=>ds,renderRectangle:()=>Zi,renderReferencedLibraryDefs:()=>Ee,renderShape:()=>ee,renderSpline:()=>es,renderSvgPrimitiveChainFilter:()=>Wi,renderSymbolInstance:()=>ns,renderSymbolLibraryDef:()=>ls,renderText:()=>Ji,renderToSvg:()=>dt,resolveRichTextStyleAt:()=>qs,resolveSymbolInstanceShapes:()=>on,richTextFontVariantCss:()=>ct,richTextLineSpans:()=>ki,richTextRunsFromState:()=>yr,richTextStyleDelta:()=>hr,richTextStyleDeltasEqual:()=>gr,richTextStylesEqual:()=>mr,richTextTspanAttributes:()=>ln,rotateAffine:()=>st,roundCoord:()=>Nr,roundNumberString:()=>zi,roundSerializedShape:()=>Br,roundSnapshot:()=>Ia,runsFromSegments:()=>Ue,sanitizeRichTextFormatRanges:()=>br,scaleAffine:()=>It,skewXAffine:()=>Dt,skewYAffine:()=>Ft,smilKeyframeAttributes:()=>Zt,solveCubicBezier:()=>ms,solveSudoku:()=>nr,splinePathBounds:()=>io,stringifyDocument:()=>Mr,substituteString:()=>Ir,substituteVariables:()=>Er,symbolInstanceTargetId:()=>ut,transformSplice:()=>vt,translateAffine:()=>de,tryParseSvgTransformList:()=>Sa,upsertTrackKeyframe:()=>_i,validateSnapshot:()=>Nt,validateSudokuPuzzle:()=>_o,verticesToPath:()=>he});module.exports=Uo(ef);var ir=(A=>(A.LINEAR="linear",A.EASE="ease",A.EASE_IN="ease-in",A.EASE_OUT="ease-out",A.EASE_IN_OUT="ease-in-out",A.EASE_IN_QUAD="ease-in-quad",A.EASE_OUT_QUAD="ease-out-quad",A.EASE_IN_OUT_QUAD="ease-in-out-quad",A.EASE_IN_CUBIC="ease-in-cubic",A.EASE_OUT_CUBIC="ease-out-cubic",A.EASE_IN_OUT_CUBIC="ease-in-out-cubic",A.EASE_IN_QUART="ease-in-quart",A.EASE_OUT_QUART="ease-out-quart",A.EASE_IN_OUT_QUART="ease-in-out-quart",A.EASE_IN_SINE="ease-in-sine",A.EASE_OUT_SINE="ease-out-sine",A.EASE_IN_OUT_SINE="ease-in-out-sine",A.EASE_IN_QUINT="ease-in-quint",A.EASE_OUT_QUINT="ease-out-quint",A.EASE_IN_OUT_QUINT="ease-in-out-quint",A.EASE_IN_EXPO="ease-in-expo",A.EASE_OUT_EXPO="ease-out-expo",A.EASE_IN_OUT_EXPO="ease-in-out-expo",A.EASE_IN_CIRC="ease-in-circ",A.EASE_OUT_CIRC="ease-out-circ",A.EASE_IN_OUT_CIRC="ease-in-out-circ",A.EASE_IN_BACK="ease-in-back",A.EASE_OUT_BACK="ease-out-back",A.EASE_IN_OUT_BACK="ease-in-out-back",A.CUSTOM_BEZIER="custom-bezier",A.LINEAR_FUNCTION="linear-function",A.STEPS="steps",A))(ir||{}),sr={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 Wo(t){let e=sr[t];return e?`cubic-bezier(${e.join(", ")})`:"linear"}var mi=(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))(mi||{}),Ns=(n=>(n.SMOOTH="smooth",n.CORNER="corner",n.SYMMETRIC="symmetric",n))(Ns||{});function Ho(t){return t==="color"?"live":"stamped"}var gi=["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","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","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"],ae=6;var yi=["transformMatrix","scaleX","scaleY","translateX","translateY","rotation","skewX","skewY","customPivot","rawTransform"],mt=["transformMatrix","scaleX","scaleY","translateX","translateY","rotation","skewX","skewY"],bi={transformMatrix:null,translateX:0,translateY:0,rotation:0,skewX:0,skewY:0,customPivot:null,rawTransform:null};var $e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",or=$e.length,ve=$e[0],Os=$e[or-1],Gs=$e[Math.floor(or/2)],xi=97,jo=122;function qe(t){let e=$e.indexOf(t);if(e===-1)throw new Error(`order-key: invalid digit '${t}'`);return e}function Xo(t){let e=t.charCodeAt(0);if(e<xi||e>jo)throw new Error(`order-key: invalid head '${t}'`);return e-xi+1}function Ce(t){if(t<1||t>26)throw new Error(`order-key: integer length ${t} out of range`);return String.fromCharCode(xi+t-1)}function gt(t){let e=Xo(t[0]);if(t.length<1+e)throw new Error(`order-key: '${t}' shorter than its integer part`);let r=t.slice(1,1+e),n=t.slice(1+e);for(let i of r)qe(i);for(let i of n)qe(i);return{integer:r,fraction:n}}function ar(t){for(let e of t)if(e!==ve)return!1;return!0}function bt(t){if(t.length===0)return!1;try{let{integer:e,fraction:r}=gt(t);return!(r.endsWith(ve)||ar(e)&&r.length===0||e.length>1&&e[0]===ve)}catch{return!1}}function zs(t,e){if(!bt(t))throw new Error(`order-key: invalid ${e} '${t}'`)}function xt(t,e){return t<e?-1:t>e?1:0}function Ko(t){let e=t.split("");for(let r=e.length-1;r>=0;r--){let n=qe(e[r]);if(n<or-1){e[r]=$e[n+1];for(let i=r+1;i<e.length;i++)e[i]=ve;return e.join("")}}return null}function Si(t){let{integer:e}=gt(t),r=Ko(e);if(r!==null)return Ce(e.length)+r;let n="1"+ve.repeat(e.length);return Ce(n.length)+n}function Yo(t){let e=t.split("");for(let r=e.length-1;r>=0;r--){let n=qe(e[r]);if(n>0){e[r]=$e[n-1];for(let i=r+1;i<e.length;i++)e[i]=Os;return e.join("")}e[r]=Os}throw new Error(`order-key: cannot decrement zero integer '${t}'`)}function qo(t){let e=0;for(;e<t.length-1&&t[e]===ve;)e++;return t.slice(e)}function Zo(t){let{integer:e,fraction:r}=gt(t);if(!ar(e)){let n=Yo(e);if(!ar(n)){let i=qo(n);return Ce(i.length)+i}return Ce(1)+ve+Gs}return Ce(1)+ve+yt("",r)}function yt(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]??ve)===e[i];)i++;if(i>0)return e.slice(0,i)+yt(t.slice(i),e.slice(i))}let r=t.length>0?qe(t[0]):0,n=e!==null?qe(e[0]):or;return n-r>1?$e[Math.floor((r+n)/2)]:$e[r]+yt(t.slice(1),null)}function Ze(t,e){if(t!==null&&zs(t,"lower bound"),e!==null&&zs(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 Ce(1)+"1";if(t===null)return Zo(e);if(e===null)return Si(t);let r=gt(t),n=gt(e),i=Ce(r.integer.length)+r.integer,s=Ce(n.integer.length)+n.integer;if(i===s)return i+yt(r.fraction,n.fraction);let o=Si(i+(ar(r.integer)?Gs:""));return xt(o,e)<0?o:i+yt(r.fraction,null)}function lr(t,e,r){if(r<=0)return[];let n=[],i=t;for(let s=0;s<r;s++){let o=Ze(i,e);n.push(o),i=o}return n}function ur(t){if(t<=0)return[];let e=[],r=Ze(null,null);e.push(r);for(let n=1;n<t;n++)r=Si(r),e.push(r);return e}var St=class{schemas=new Map;register(e,r){this.schemas.set(e,r)}get(e){return this.schemas.get(e)}typeIds(){return[...this.schemas.keys()]}getDefaults(e){let r=this.schemas.get(e);if(!r)return{};let n={};for(let i of Object.keys(r))n[i]=r[i].default;return n}validate(e,r,n){let i=this.schemas.get(e);if(!i)return n;let s=i[r];return s?.validate?s.validate(n):n}},I=t=>Math.max(0,t),Qe=t=>Math.max(0,Math.min(1,t)),X=t=>Math.max(0,Math.min(100,t)),Qo=t=>Math.max(1,t),Jo=t=>Math.max(3,Math.min(100,Math.floor(t))),el=t=>Math.max(3,Math.min(50,Math.floor(t))),tl=t=>Math.max(3,Math.min(30,Math.floor(t))),rl=t=>Math.max(1,Math.min(10,t));function nl(t){return Object.fromEntries(Object.entries(t).map(([e,r])=>[e,{default:r}]))}var il=nl(bi),H={layerName:{default:null},fillColor:{default:"#ffffff"},borderColor:{default:"#000000"},borderWidth:{default:1},opacity:{default:1,validate:Qe},fillOpacity:{default:1,validate:Qe},strokeOpacity:{default:1,validate:Qe},...il,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:Qo},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}},le={...H,cx:{default:0},cy:{default:0},radius:{default:50,validate:I},cornerRadius:{default:0,validate:I},shiftAngle:{default:0}},Je={...H,x:{default:0},y:{default:0},width:{default:100,validate:I},height:{default:60,validate:I}},Vs={...H,x:{default:0},y:{default:0},width:{default:0,validate:I},height:{default:0,validate:I},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:Qe},muted:{default:!1},loop:{default:!1},playbackRate:{default:1},mediaOpacity:{default:1,validate:Qe},fadeInDuration:{default:0,validate:I},fadeOutDuration:{default:0,validate:I},posterHref:{default:""},sourceRect:{default:null}},D=new St;D.register("rectangle",{...H,x:{default:0},y:{default:0},width:{default:100,validate:I},height:{default:100,validate:I},rx:{default:0,validate:I},ry:{default:0,validate:I},cornerRadius:{default:0,validate:I},cornerShape:{default:"round"},cornerMode:{default:"uniform"},cornerRadiusTL:{default:0,validate:I},cornerRadiusTR:{default:0,validate:I},cornerRadiusBL:{default:0,validate:I},cornerRadiusBR:{default:0,validate:I},cornerShapeTL:{default:"round"},cornerShapeTR:{default:"round"},cornerShapeBL:{default:"round"},cornerShapeBR:{default:"round"}});D.register("square",{...H,x:{default:0},y:{default:0},width:{default:100,validate:I},height:{default:100,validate:I},rx:{default:0,validate:I},ry:{default:0,validate:I},cornerRadius:{default:0,validate:I},cornerShape:{default:"round"},cornerMode:{default:"uniform"},cornerRadiusTL:{default:0,validate:I},cornerRadiusTR:{default:0,validate:I},cornerRadiusBL:{default:0,validate:I},cornerRadiusBR:{default:0,validate:I},cornerShapeTL:{default:"round"},cornerShapeTR:{default:"round"},cornerShapeBL:{default:"round"},cornerShapeBR:{default:"round"}});D.register("circle",{...H,x:{default:0},y:{default:0},radius:{default:50,validate:I}});D.register("ellipse",{...H,cx:{default:0},cy:{default:0},rx:{default:50,validate:I},ry:{default:30,validate:I}});D.register("line",{...H,x1:{default:0},y1:{default:0},x2:{default:100},y2:{default:0},startEndpoint:{default:"none"},endEndpoint:{default:"none"}});D.register("text",{...H,x:{default:0},y:{default:0},width:{default:0,validate:I},height:{default:0,validate:I},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}});D.register("image",{...H,x:{default:0},y:{default:0},width:{default:100,validate:I},height:{default:100,validate:I},href:{default:""},originalWidth:{default:0},originalHeight:{default:0},preserveAspectRatio:{default:!0},imageOpacity:{default:1,validate:Qe}});D.register("path",{...H,x:{default:0},y:{default:0},width:{default:0,validate:I},height:{default:0,validate:I},pathPoints:{default:[]},pathArcParams:{default:[]},pathControlBounds:{default:null},startEndpoint:{default:"none"},endEndpoint:{default:"none"}});D.register("polyline",{...H,x:{default:0},y:{default:0},width:{default:0,validate:I},height:{default:0,validate:I},polylinePoints:{default:[]},polylineClosed:{default:!1}});D.register("triangle",{...le,sides:{default:3}});D.register("ngon",{...le,sides:{default:6,validate:Jo}});D.register("star",{...le,arms:{default:5,validate:el},innerRadiusPercent:{default:40,validate:X}});D.register("cross",{...le,armWidthPercent:{default:30,validate:X}});D.register("ring",{...le,innerRadiusPercent:{default:50,validate:X}});D.register("spiral",{...le,turns:{default:3,validate:rl},thicknessPercent:{default:15,validate:X},spiralDirection:{default:1}});D.register("gear",{...le,teeth:{default:8,validate:tl},toothDepthPercent:{default:25,validate:X},holeRadiusPercent:{default:20,validate:X}});D.register("arrow",{...le,headWidthPercent:{default:100,validate:X},headLengthPercent:{default:40,validate:X},shaftWidthPercent:{default:40,validate:X}});D.register("symbol-instance",{...H,x:{default:0},y:{default:0},width:{default:100,validate:I},height:{default:100,validate:I},symbolId:{default:""}});D.register("group",{...H,groupId:{default:null}});D.register("cloud",{...le,cloudBumps:{default:5},cloudPuffinessPercent:{default:60,validate:X}});D.register("heart",{...le,lobeRadiusPercent:{default:50,validate:X},cleftDepthPercent:{default:25,validate:X}});D.register("lightning",{...le,boltSegments:{default:3},boltWidthPercent:{default:30,validate:X},boltJaggednessPercent:{default:40,validate:X}});D.register("speechBubble",{...le,tailAngleDeg:{default:45},tailLengthPercent:{default:40,validate:X},tailWidthPercent:{default:25,validate:X}});D.register("diamond",{...Je});D.register("parallelogram",{...Je,slantPercent:{default:20,validate:X}});D.register("trapezoid",{...Je,topWidthPercent:{default:70,validate:X}});D.register("terminator",{...Je});D.register("cylinder",{...Je,capHeightPercent:{default:15,validate:X}});D.register("document-shape",{...Je,waveAmplitudePercent:{default:15,validate:X}});D.register("hyperlink",{...H,href:{default:""},hrefXlink:{default:""},linkTarget:{default:""},linkDownload:{default:""},linkPing:{default:""},linkRel:{default:""},linkHreflang:{default:""},linkType:{default:""},linkReferrerPolicy:{default:""}});D.register("switch",{...H,switchSystemLanguage:{default:""},switchRequiredExtensions:{default:""}});D.register("svg",{...H,svgX:{default:0},svgY:{default:0},svgWidth:{default:0,validate:I},svgHeight:{default:0,validate:I},svgViewBoxX:{default:0},svgViewBoxY:{default:0},svgViewBoxWidth:{default:0,validate:I},svgViewBoxHeight:{default:0,validate:I},svgPreserveAspectRatio:{default:""}});D.register("view",{...H,viewBoxX:{default:0},viewBoxY:{default:0},viewBoxWidth:{default:0,validate:I},viewBoxHeight:{default:0,validate:I},viewName:{default:""},viewPreserveAspectRatio:{default:""},viewTarget:{default:""}});D.register("shape-reference",{...H,targetShapeId:{default:""},offsetX:{default:0},offsetY:{default:0},targetWidth:{default:0,validate:I},targetHeight:{default:0,validate:I},broken:{default:!1}});D.register("video",{...Vs,mediaKind:{default:"video"}});D.register("audio",{...Vs,mediaKind:{default:"audio"}});D.register("document",{});function sl(){let t=new Set(gi);for(let e of yi)t.add(e);for(let e of D.typeIds())for(let r of Object.keys(D.getDefaults(e)))t.add(r);return t.delete("scaleAnchor"),t.delete("extra"),t}var $i=sl(),Us=new Set(["scaleAnchor","displayAttr"]);function cr(t){let e=t.extra&&typeof t.extra=="object"&&!Array.isArray(t.extra)?t.extra:void 0;for(let r of Object.keys(t)){if(r==="extra"||$i.has(r))continue;let n=t[r];delete t[r],n!==void 0&&((e??={})[r]=n)}return e&&Object.keys(e).length>0?t.extra=e:delete t.extra,t}function ze(t){if(!t?.state||typeof t.state!="object")return t;let e=t.state,r=e.children;if(Array.isArray(r))for(let i of r)ze(i);let n=e.symbolOverrides;if(n&&typeof n=="object"&&!Array.isArray(n))for(let i of Object.values(n))i&&typeof i=="object"&&!Array.isArray(i)&&cr(i);return cr(e),t}function $t(t){if(!t?.state||typeof t.state!="object")return t;let e=t.state,r=e.children;if(Array.isArray(r))for(let i of r)$t(i);let n=e.symbolOverrides;if(n&&typeof n=="object"&&!Array.isArray(n))for(let i of Object.values(n))i&&typeof i=="object"&&!Array.isArray(i)&&Te(i);return Te(e),t}function Te(t){let e=t.extra;if(!e||typeof e!="object"||Array.isArray(e))return delete t.extra,t;for(let[r,n]of Object.entries(e))r!=="extra"&&(r in t||(t[r]=n));return delete t.extra,t}function Ge(t,e,r,n="verbatim"){if(n==="verbatim")return new ke(t,e,r&&"extra"in r?Te({...r}):r);let i={...D.getDefaults(e),...r},s=D.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 ke(t,e,i)}var ke=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;_overlay=null;_propTimestamps=new Map;constructor(e,r,n){this.id=e,this.type=r,this._props=n?{...n}:{}}get(e){return this._overlay!==null&&t._baseReadDepth===0&&this._overlay.has(e)?this._overlay.get(e):this._props[e]}set(e,r){this._props[e]!==r&&(t.writeHook?.(this,e),this._props[e]=r,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,r){this._props[e]!==r&&(t.writeHook?.(this,e),this._props[e]=r,this._dirty.add(e),this.onChange?.(this,this._dirty))}setMany(e){let r=!1;for(let[n,i]of Object.entries(e))this._props[n]!==i&&(t.writeHook?.(this,n),this._props[n]=i,this._dirty.add(n),r=!0);r&&this.onChange?.(this,this._dirty)}setOverlayValue(e,r){this._overlay===null&&(this._overlay=new Map),this._overlay.set(e,r)}deleteOverlayValue(e){if(this._overlay===null)return!1;let r=this._overlay.delete(e);return this._overlay.size===0&&(this._overlay=null),r}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 r of Object.keys(this._props))this._dirty.add(r);this.onChange?.(this,this._dirty)}getPropStamp(e){return this._propTimestamps.get(e)??null}stampProp(e,r,n){this._propTimestamps.set(e,{ts:r,clientId:n})}stampProps(e,r,n){let i={ts:r,clientId:n};for(let s of e)this._propTimestamps.set(s,i)}getPropStampsForKeys(e){let r={};for(let n of e){let i=this._propTimestamps.get(n);i&&(r[n]=i.ts)}return r}setPropIfWins(e,r,n,i){let s=this._propTimestamps.get(e),o=s?.ts??0,a=s?.clientId??"";return n>o||n===o&&i>a?(this._props[e]=r,this._propTimestamps.set(e,{ts:n,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 Ge(e.id,e.type,e.state,"verbatim")}static create(e,r,n){return Ge(e,r,n,"authoring")}};var al=5e3,ol=1e4;function ll(t){return t===null||t.size===0?"":[...t.entries()].sort((e,r)=>r[1].count-e[1].count).slice(0,5).map(([e,r])=>`${e.type}#${e.id} x${r.count} keys=[${[...r.keys].join(",")}]`).join("; ")}var dr=class t{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}root;_nodesById=new Map;_batchDepth=0;_batchDirtyNodes=new Map;_draining=!1;_changeListeners=[];_structureListeners=[];constructor(){this.root=Ge("__root__","document"),this._nodesById.set(this.root.id,this.root)}onNodeChange(e){return this._changeListeners.push(e),()=>{let r=this._changeListeners.indexOf(e);r>=0&&this._changeListeners.splice(r,1)}}onStructureChange(e){return this._structureListeners.push(e),()=>{let r=this._structureListeners.indexOf(e);r>=0&&this._structureListeners.splice(r,1)}}addNode(e,r,n){let i=r??this.root;n!==void 0&&n>=0&&n<i.children.length?i.children.splice(n,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 r=this._nodesById.get(e);if(!r||r===this.root)return null;let n=r.parent,i=null;if(n){let s=n.children.indexOf(r);i={parentId:n===this.root?null:n.id,index:s},s>=0&&n.children.splice(s,1)}return r.parent=null,r.onChange=null,this._nodesById.delete(e),this._batchDirtyNodes.delete(r),this._removeDescendants(r),this._batchDirtyNodes.size===0&&t._pendingGraphs.delete(this),this._emitStructure("remove",r,n,null,i),r}getNode(e){return this._nodesById.get(e)??null}moveNode(e,r,n){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)}n!==void 0&&n>=0&&n<r.children.length?r.children.splice(n,0,i):r.children.push(i),i.parent=r,this._emitStructure("move",i,s,r,o)}moveNodeToParentId(e,r,n){let i=r?this._nodesById.get(r):this.root;i&&this.moveNode(e,i,n)}getChildren(e){let r=e?this._nodesById.get(e):this.root;return r?[...r.children]:[]}getRootShapes(){return[...this.root.children]}getParentId(e){let r=this._nodesById.get(e);return!r||!r.parent||r.parent===this.root?null:r.parent.id}getSiblingIndex(e){let r=this._nodesById.get(e);return!r||!r.parent?-1:r.parent.children.indexOf(r)}getAncestorIds(e){let r=[],n=this.getParentId(e);for(;n;)r.push(n),n=this.getParentId(n);return r}isAncestor(e,r){if(e===r)return!1;let n=this.getParentId(r);for(;n;){if(n===e)return!0;n=this.getParentId(n)}return!1}isDocumentRootNode(e){let r=this._nodesById.get(e);return!!r&&r!==this.root&&r.getProp("isRootSvg")===!0}contains(e,r){if(e===r)return!1;if(this.isDocumentRootNode(e)){let n=this._nodesById.get(r);return!!n&&n!==this.root&&!this.isDocumentRootNode(r)}return this.isAncestor(e,r)}getDepth(e){let r=this._nodesById.get(e);if(!r||r===this.root)return-1;let n=0,i=r.parent;for(;i&&i!==this.root;)n++,i=i.parent;return n}getAllNodes(){let e=[];for(let r of this._nodesById.values())r!==this.root&&e.push(r);return e}getDirtyNodes(){let e=[];for(let r of this._nodesById.values())r.isDirty()&&e.push(r);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(){t._pendingGraphs.delete(this),this._batchDirtyNodes.clear(),this._changeListeners.length=0,this._structureListeners.length=0}notifyNodeChanged(e,r){this._handleNodeChange(e,r)}_handleNodeChange(e,r){if(this._batchDepth>0){let n=this._batchDirtyNodes.get(e);n||(n=new Set,this._batchDirtyNodes.set(e,n),t._pendingGraphs.add(this));for(let i of r)n.add(i);return}this._fireChangeListeners(e,r)}_drainBatched(){if(this._draining)return;this._draining=!0;let e=0,r=null;try{for(;this._batchDirtyNodes.size>0;){if(++e>ol){console.error("[SceneGraph] batched-notification drain did not converge \u2014 render loop?",ll(r)),this._batchDirtyNodes.clear();break}let[n,i]=this._batchDirtyNodes.entries().next().value;if(this._batchDirtyNodes.delete(n),this._batchDirtyNodes.size===0&&t._pendingGraphs.delete(this),e>al){r===null&&(r=new Map);let s=r.get(n);if(s){s.count++;for(let o of i)s.keys.add(o)}else r.set(n,{count:1,keys:new Set(i)})}this._fireChangeListeners(n,i)}}finally{this._draining=!1,this._batchDirtyNodes.size===0&&t._pendingGraphs.delete(this)}}_fireChangeListeners(e,r){let n=[...this._changeListeners];for(let i of n)i(e,r)}_emitStructure(e,r,n,i,s=null){let o=[...this._structureListeners];for(let a of o)a(e,r,n,i,s)}_removeDescendants(e){for(let r of e.children)r.onChange=null,this._nodesById.delete(r.id),this._batchDirtyNodes.delete(r),this._removeDescendants(r)}serializeShapes(){let e=[],r=n=>{for(let i of n)i.type!=="document"&&i.type!=="group"&&i.getProp("structural")!==!0&&e.push(i.toSerialized()),i.children.length>0&&r(i.children)};return r(this.root.children),e}static fromShapes(e){let r=new t;for(let n of e){let i=ke.fromSerialized(n);r.addNode(i)}return r}};function ce(t,e,r){let n=typeof e.id=="string"?e.id:"",i=(t??[]).filter(o=>o.id!==n),s=typeof r=="number"&&Number.isFinite(r)?Math.max(0,Math.min(r,i.length)):i.length;return i.splice(s,0,e),i}function me(t,e){return(t??[]).filter(r=>r.id!==e)}function Ws(t,e){if(t===e)return null;let r=0,n=Math.min(t.length,e.length);for(;r<n&&t.charCodeAt(r)===e.charCodeAt(r);)r++;let i=0,s=Math.min(t.length,e.length)-r;for(;i<s&&t.charCodeAt(t.length-1-i)===e.charCodeAt(e.length-1-i);)i++;return{start:r,deleteCount:t.length-r-i,insert:e.slice(r,e.length-i)}}function Hs(t,e){return t.slice(0,e.start)+e.insert+t.slice(e.start+e.deleteCount)}function vt(t,e){let r=e.start,n=e.start+e.deleteCount,i=e.insert.length-e.deleteCount,s=t.start,o=t.start+t.deleteCount;return n<=s?{start:s+i,deleteCount:t.deleteCount,insert:t.insert}:r>=o?{start:s,deleteCount:t.deleteCount,insert:t.insert}:r<=s&&n>=o?{start:r+e.insert.length,deleteCount:0,insert:t.insert}:r>=s&&n<=o?{start:s,deleteCount:t.deleteCount+i,insert:t.insert}:r<s?{start:r+e.insert.length,deleteCount:t.deleteCount-(n-s),insert:t.insert}:{start:s,deleteCount:r-s,insert:t.insert}}var Tt={fontFamily:"Arial",fontSize:16,fontWeight:"normal",fontStyle:"normal",fontVariant:"",fontVariantLigatures:"",fontVariantPosition:"",fontVariantCaps:"",fontVariantNumeric:"",fontVariantEastAsian:"",textDecoration:{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:{},fill:"#000000",fillOpacity:1,stroke:"none",strokeWidth:0,strokeOpacity:1},et=Object.keys(Tt);function Pe(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function we(t){return typeof t=="string"?t:void 0}function Z(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 Ie(t){return e=>typeof e=="string"&&t.includes(e)?e:void 0}function ul(t){return t==="normal"||t==="bold"?t:Z(t)}function cl(t){return t==="baseline"||t==="super"||t==="sub"?t:Z(t)}function Xs(t){if(typeof t=="string"){let r=t.toLowerCase();return{underline:r.includes("underline"),strikethrough:r.includes("line-through")||r.includes("strikethrough"),overline:r.includes("overline")}}if(!Pe(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 Ks(t){if(!Pe(t))return;let e={};for(let[r,n]of Object.entries(t)){let i=Z(n);i!==void 0&&(e[r]=i)}return e}var Ys={fontFamily:we,fontSize:Z,fontWeight:ul,fontStyle:Ie(["normal","italic","oblique"]),fontVariant:we,fontVariantLigatures:we,fontVariantPosition:we,fontVariantCaps:we,fontVariantNumeric:we,fontVariantEastAsian:we,textTransform:Ie(["none","capitalize","uppercase","lowercase"]),baselineShift:cl,dominantBaseline:Ie(["auto","alphabetic","central","middle","hanging","ideographic","mathematical","text-top","text-bottom"]),writingMode:Ie(["horizontal-tb","vertical-rl","vertical-lr"]),whiteSpace:Ie(["normal","nowrap","pre","pre-wrap","pre-line","break-spaces"]),direction:Ie(["ltr","rtl"]),unicodeBidi:Ie(["normal","embed","bidi-override","isolate","isolate-override","plaintext"]),textAnchor:Ie(["start","middle","end"]),letterSpacing:Z,wordSpacing:Z,lineHeight:Z,fill:we,fillOpacity:Z,stroke:we,strokeWidth:Z,strokeOpacity:Z};function fr(t,e){return{...t,...e,textDecoration:{...t.textDecoration,...e.textDecoration??{}},fontVariationSettings:{...e.fontVariationSettings??t.fontVariationSettings}}}function Ti(t,e){let r=Object.keys(t);return r.length!==Object.keys(e).length?!1:r.every(n=>Object.prototype.hasOwnProperty.call(e,n)&&t[n]===e[n])}function mr(t,e){for(let r of et)if(r==="textDecoration"){if(t.textDecoration.underline!==e.textDecoration.underline||t.textDecoration.strikethrough!==e.textDecoration.strikethrough||t.textDecoration.overline!==e.textDecoration.overline)return!1}else if(r==="fontVariationSettings"){if(!Ti(t.fontVariationSettings,e.fontVariationSettings))return!1}else if(t[r]!==e[r])return!1;return!0}function gr(t,e){let r=Object.keys(t).sort(),n=Object.keys(e).sort();if(r.length!==n.length||r.some((i,s)=>i!==n[s]))return!1;for(let i of r)if(i==="textDecoration"){let s=t.textDecoration??{},o=e.textDecoration??{},a=new Set([...Object.keys(s),...Object.keys(o)]);for(let u of a){let c=u;if(s[c]!==o[c])return!1}}else if(i==="fontVariationSettings"){if(!Ti(t.fontVariationSettings??{},e.fontVariationSettings??{}))return!1}else{let s=i;if(t[s]!==e[s])return!1}return!0}function hr(t,e){let r={};for(let i of et)i==="textDecoration"||i==="fontVariationSettings"||t[i]!==e[i]&&(r[i]=t[i]);let n={};return t.textDecoration.underline!==e.textDecoration.underline&&(n.underline=t.textDecoration.underline),t.textDecoration.strikethrough!==e.textDecoration.strikethrough&&(n.strikethrough=t.textDecoration.strikethrough),t.textDecoration.overline!==e.textDecoration.overline&&(n.overline=t.textDecoration.overline),Object.keys(n).length>0&&(r.textDecoration=n),Ti(t.fontVariationSettings,e.fontVariationSettings)||(r.fontVariationSettings={...t.fontVariationSettings}),r}function ge(t,e=Tt){let r=Pe(t)?t:{},n={...e};for(let i of et){if(i==="textDecoration"||i==="fontVariationSettings")continue;let s=Ys[i](r[i]);s!==void 0&&(n[i]=s)}return n.textDecoration={...e.textDecoration,...Xs(r.textDecoration)??{}},n.fontVariationSettings={...Ks(r.fontVariationSettings)??e.fontVariationSettings},n}function kt(t){let e=Pe(t)?t:{},r={};for(let n of et){if(n==="textDecoration"||n==="fontVariationSettings"||e[n]===void 0)continue;let i=Ys[n](e[n]);i!==void 0&&(r[n]=i)}if(e.textDecoration!==void 0){let n=Xs(e.textDecoration);n&&Object.keys(n).length>0&&(r.textDecoration=n)}if(e.fontVariationSettings!==void 0){let n=Ks(e.fontVariationSettings);n&&(r.fontVariationSettings=n)}return r}function ki(t){let e=[],r=0;for(;;){let n=t.indexOf(`
|
|
2
|
-
`,
|
|
3
|
-
`),a+=1);let d=i[f]?.segments,
|
|
4
|
-
`)&&
|
|
5
|
-
`,
|
|
6
|
-
`;return r&&n}function Js(t,e,r){let n=[];for(let i of t){let s=i.start===i.end,o=vt({start:i.start,deleteCount:i.end-i.start,insert:""},e),a=o.start,u=o.start+o.deleteCount;a===u&&(!s||!hl(r,a))||n.push({start:a,end:u,style:i.style})}return n}function na(t,e=null){let r=[];return t.forEach((n,i)=>{r.push({id:n.id,parentId:e,index:i});let s=n.state.children;Array.isArray(s)&&r.push(...na(s,n.id))}),r}function xr(t){return t.sceneTree&&t.sceneTree.length>0?t.sceneTree:na(t.shapes)}function _t(t){let e=new Map;for(let n of t){let i=e.get(n.parentId)??[];i.push(n),e.set(n.parentId,i)}let r=[];for(let n of e.values())We(n).forEach((i,s)=>r.push({...i,index:s}));return r}function We(t){let e=[...t].sort((i,s)=>i.index-s.index);if(!e.some(i=>i.orderKey))return e;let r=ur(e.length),n=new Map;return e.forEach((i,s)=>{n.set(i.id,i.orderKey??r[s])}),e.sort((i,s)=>{let o=xt(n.get(i.id)??"",n.get(s.id)??"");return o!==0?o:i.id<s.id?-1:i.id>s.id?1:0})}function Rt(t,e){let r=t.filter(u=>u.parentId===e);if(r.every(u=>u.orderKey))return t;let n=We(r),i=new Map,s=[],o=null,a=u=>{if(s.length===0)return;let c=lr(o,u,s.length);s.forEach((f,d)=>i.set(f.id,c[d])),s=[]};for(let u of n)u.orderKey?(a(u.orderKey),o=u.orderKey):s.push(u);return a(null),t.map(u=>i.has(u.id)?{...u,orderKey:i.get(u.id)}:u)}function ea(t,e){let r=t.find(a=>a.id===e.id);if(r&&!ia(e,r))return t;let n=t.filter(a=>a.id!==e.id),i=n.filter(a=>a.parentId!==e.parentId);if(n.some(a=>a.parentId===e.parentId&&a.orderKey)){let a=Rt(n,e.parentId),u=We(a.filter(p=>p.parentId===e.parentId)),c=Math.min(Math.max(0,e.index),u.length),f=c>0?u[c-1].orderKey??null:null,d=c<u.length?u[c].orderKey??null:null,h=f!==null&&d!==null&&f>=d?f:Ze(f,d);return _t([...i,...u,{...e,orderKey:h}])}let s=n.filter(a=>a.parentId===e.parentId).sort((a,u)=>a.index-u.index).map((a,u)=>({...a,index:u})),o=Math.min(Math.max(0,e.index),s.length);return _t([...i,...s,{...e,index:o-.5}])}function Sr(t,e,r){let n=t?[...t]:[],i=n.find(s=>s.id===e);return i?ce(n,i,r):n}function pl(t){t.keyframes.sort((e,r)=>{if(e.time!==r.time)return e.time-r.time;let n=e.id??"",i=r.id??"";return n<i?-1:n>i?1:0})}function _i(t,e){let r=t.keyframes.findIndex(n=>n.id===e.id);r>=0?t.keyframes[r]=e:t.keyframes.push(e),pl(t)}function Ri(t,e){t.keyframes=t.keyframes.filter(r=>r.id!==e)}function ta(t,e){let r=t.animationTimeline?.tracks;return Array.isArray(r)?r.find(n=>n.id===e)??null:null}function ia(t,e){let r=t.updatedAt??0,n=e.updatedAt??0;return r!==n?r>n:(t.clientId??"")>=(e.clientId??"")}function At(t){let e=t.state.children;return Array.isArray(e)?e:void 0}var Pi=new Set(["group","hyperlink","switch","container","svg"]);function sa(t,e,r,n){for(let i of t){r.set(i.id,e),n.set(i.id,i);let s=At(i);s&&sa(s,i.id,r,n)}}function $r(t){let e=t.sceneTree;if(!e||e.length===0)return;let r=new Map,n=new Map;if(sa(t.shapes,null,r,n),n.size===0)return;let i=new Map;for(let d of e){let h=i.get(d.parentId)??[];h.push(d),i.set(d.parentId,h)}let s=new Map,o=(d,h)=>{let p=s.get(d);p?p.push(h):s.set(d,[h])},a=new Set,u=new Set,c=(d,h)=>{for(let p of We(i.get(d)??[])){if(u.has(p.id))continue;u.add(p.id);let g=n.get(p.id);if(!g){c(p.id,h);continue}o(h,g),a.add(g.id),Pi.has(g.type)&&c(p.id,g.id)}};if(c(null,null),a.size===0)return;let f=d=>{let h=r.get(d)??null,p=new Set;for(;h!==null&&!p.has(h);){p.add(h);let g=n.get(h);if(g&&Pi.has(g.type))return h;h=r.get(h)??null}return null};for(let[d,h]of n)a.has(d)||o(f(d),h);for(let[d,h]of n){if(!Pi.has(h.type))continue;let p=h.state,g=s.get(d);g&&g.length>0?p.children=g:"children"in p&&delete p.children}t.shapes=s.get(null)??[]}function ml(t){let e=`structural:${t.type}:${t.id}`;return{group:`${e}:group`,path:`${e}:path`,content:`${e}:content`}}function Pt(t){let e=t.clipMaskGroups;if(!e||e.length===0)return;let r=t.sceneTree;if(!r||r.length===0)return;let n=new Set(r.map(o=>o.id)),i=new Map;for(let o of r){if(o.parentId===null)continue;let a=i.get(o.parentId);a?a.push(o):i.set(o.parentId,[o])}let s=o=>We(i.get(o)??[]).map(a=>a.id).filter(a=>!a.startsWith("structural:"));t.clipMaskGroups=e.map(o=>{let a=ml(o);if(!n.has(a.group))return o;let u=n.has(a.path)?s(a.path):o.clipShapeIds,c=n.has(a.content)?s(a.content):o.contentShapeIds;if(ra(u,o.clipShapeIds)&&ra(c,o.contentShapeIds))return o;let f={...o,clipShapeIds:u,contentShapeIds:c};return(f.clipShapeId!==void 0||u.length>0)&&(f.clipShapeId=u[0]),f})}function ra(t,e){return!e||t.length!==e.length?!1:t.every((r,n)=>r===e[n])}function aa(t,e){e.add(t.id);let r=At(t);if(r)for(let n of r)aa(n,e)}function tt(t,e){for(let r of t){if(r.id===e)return r;let n=At(r);if(!n)continue;let i=tt(n,e);if(i)return i}return null}function vr(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function gl(t){let e=t.richTextRuns;return!vr(e)||typeof e.text!="string"?null:Ve(e)}function oa(t,e,r){for(let n of t){if(n.id===e){let s=n.state;"extra"in s&&Te(s);let o=new Set;for(let[a,u]of Object.entries(r))u===null?o.add(a):s[a]=u;if(o.size>0){let a={};for(let[u,c]of Object.entries(s))o.has(u)||(a[u]=c);n.state=a}return!0}let i=At(n);if(i&&oa(i,e,r))return!0}return!1}function la(t,e,r){let n=[];for(let i of t){if(i.id===e){aa(i,r);continue}let s=At(i);if(s){let o=la(s,e,r),a=i.state;o.length>0?a.children=o:delete a.children}n.push(i)}return n}function Ai(t,e){switch(e.type){case"shape:add":{if(!(tt(t.shapes,e.shape.id)!==null)){t.shapes.push($t(structuredClone(e.shape)));let n=xr(t),i=Math.max(0,n.filter(s=>s.parentId===null).length-1);t.sceneTree=ea(n,{id:e.shape.id,parentId:null,index:i})}break}case"shape:update":{oa(t.shapes,e.id,e.state);break}case"text:format":{let r=tt(t.shapes,e.id);if(!r)break;let n=r.state;"extra"in n&&Te(n);let i=gl(n);if(!i)break;let s=br(e.ranges,i.text.length);if(s.length===0)break;let o={...i,runs:wt(i.runs,s)};n.richTextRuns=o,vr(n.richTextData)&&(n.richTextData=_e(o));break}case"shape:remove":{let r=new Set;t.shapes=la(t.shapes,e.id,r),r.size===0&&r.add(e.id),t.sceneTree=xr(t).filter(n=>!r.has(n.id)),Pt(t);break}case"scene:move":t.sceneTree=ea(xr(t),{id:e.id,parentId:e.parentId,index:e.index,updatedAt:e.updatedAt,clientId:e.clientId}),$r(t),Pt(t);break;case"scene:place":{if(!bt(e.orderKey))break;let r=xr(t),n=r.find(o=>o.id===e.id),i={id:e.id,parentId:e.parentId,index:n?.index??Number.MAX_SAFE_INTEGER,orderKey:e.orderKey,updatedAt:e.updatedAt,clientId:e.clientId};if(n&&!ia(i,n))break;let s=Rt(r,e.parentId);t.sceneTree=_t([...s.filter(o=>o.id!==e.id),i]),$r(t),Pt(t);break}case"shapes:reorder":{let r=new Map(t.shapes.map(i=>[i.id,i])),n=e.ids.map(i=>r.get(i)).filter(i=>i!==void 0);for(let i of t.shapes)e.ids.includes(i.id)||n.push(i);if(t.shapes=n,t.sceneTree){let i=new Map(e.ids.map((s,o)=>[s,o]));t.sceneTree=t.sceneTree.map(s=>{let o=i.get(s.id);return s.parentId===null&&o!==void 0?{...s,index:o}:s}),t.sceneTree=_t(t.sceneTree)}break}case"groups:set":t.groups=e.groups;break;case"clipmasks:set":t.clipMaskGroups=e.clipMaskGroups;break;case"clipMask:upsert":t.clipMaskGroups=ce(t.clipMaskGroups,e.clipMaskGroup,e.index);break;case"clipMask:remove":t.clipMaskGroups=me(t.clipMaskGroups,e.id);break;case"guides:set":t.guides=e.guides;break;case"guide:upsert":t.guides=ce(t.guides,e.guide,e.index);break;case"guide:remove":t.guides=me(t.guides,e.id);break;case"guide:move":t.guides=Sr(t.guides,e.id,e.index);break;case"measurements:set":t.measurements=e.measurements;break;case"measurement:upsert":t.measurements=ce(t.measurements,e.measurement,e.index);break;case"measurement:remove":t.measurements=me(t.measurements,e.id);break;case"measurement:move":t.measurements=Sr(t.measurements,e.id,e.index);break;case"metadata:set":t.documentMetadata=e.metadata;break;case"metadata:patch":{let r=Object.fromEntries(Object.entries({...t.documentMetadata??{},...e.patch}).filter(([n])=>!(e.removeKeys??[]).includes(n)));t.documentMetadata=r;break}case"documentScripts:set":t.documentScripts=e.documentScripts;break;case"documentScript:upsert":t.documentScripts=ce(t.documentScripts,e.documentScript,e.index);break;case"documentScript:remove":t.documentScripts=me(t.documentScripts,e.id);break;case"documentStyles:set":t.documentStyles=e.documentStyles;break;case"documentStyle:upsert":t.documentStyles=ce(t.documentStyles,e.documentStyle,e.index);break;case"documentStyle:remove":t.documentStyles=me(t.documentStyles,e.id);break;case"animation:set":t.animationTimeline=e.animationTimeline;break;case"animation:config":t.animationTimeline={duration:e.config.duration,loop:e.config.loop,playbackSpeed:e.config.playbackSpeed,tracks:Array.isArray(t.animationTimeline?.tracks)?t.animationTimeline.tracks:[]};break;case"animation:clear":delete t.animationTimeline;break;case"animationTrack:upsert":t.animationTimeline={duration:typeof t.animationTimeline?.duration=="number"?t.animationTimeline.duration:0,loop:typeof t.animationTimeline?.loop=="boolean"?t.animationTimeline.loop:!1,playbackSpeed:typeof t.animationTimeline?.playbackSpeed=="number"?t.animationTimeline.playbackSpeed:1,tracks:ce(Array.isArray(t.animationTimeline?.tracks)?t.animationTimeline.tracks:[],e.track,e.index)};break;case"animationTrack:remove":{let r=me(Array.isArray(t.animationTimeline?.tracks)?t.animationTimeline.tracks:[],e.id);r.length>0&&t.animationTimeline?t.animationTimeline={...t.animationTimeline,tracks:r}:delete t.animationTimeline;break}case"animationKeyframe:upsert":{let r=ta(t,e.trackId);if(!r)break;_i(r,structuredClone(e.keyframe));break}case"animationKeyframe:remove":{let r=ta(t,e.trackId);if(!r)break;Ri(r,e.keyframeId);break}case"symbols:set":t.symbols=e.symbols,t.library=e.symbols.map(r=>({...r,kind:"symbol"}));break;case"customPatterns:set":t.customPatterns=e.customPatterns;break;case"customPattern:upsert":t.customPatterns=ce(t.customPatterns,e.customPattern,e.index);break;case"customPattern:remove":t.customPatterns=me(t.customPatterns,e.id);break;case"library:set":t.library=e.library;break;case"library:upsert":t.library=ce(t.library,e.def,e.index);break;case"library:remove":t.library=me(t.library,e.id);break;case"rawPaintServerDefs:set":t.rawPaintServerDefs=e.rawPaintServerDefs,delete t.paintServerDefs;break;case"paintServerDefs:set":t.paintServerDefs=e.paintServerDefs,t.rawPaintServerDefs=e.paintServerDefs.map(r=>r.markup);break;case"paintServerDef:upsert":t.paintServerDefs=ce(t.paintServerDefs,e.paintServerDef,e.index),t.rawPaintServerDefs=t.paintServerDefs.map(r=>r.markup);break;case"paintServerDef:remove":t.paintServerDefs=me(t.paintServerDefs,e.id),t.rawPaintServerDefs=t.paintServerDefs.map(r=>r.markup);break;case"presence:cursor":case"presence:selection":break}}function ua(t,e){let r=structuredClone(t);for(let n of e)Ai(r,n);return r}function ca(t){if(!t||t.length===0||t.every(r=>r.orderKey))return t;let e=t;for(let r of new Set(t.map(n=>n.parentId)))e=Rt(e,r);return _t(e)}function da(t,e){if(!t.some(n=>n.type==="scene:place"))return t;let r=new Map((e??[]).map(n=>[n.id,n]));return t.map(n=>{if(n.type!=="scene:place")return n;let i=r.get(n.id);return{type:"scene:move",id:n.id,parentId:i?.parentId??n.parentId,index:i?.index??0,updatedAt:n.updatedAt,clientId:n.clientId}})}function fa(t,e){if(!t.some(i=>i.type==="animationKeyframe:upsert"||i.type==="animationKeyframe:remove"))return t;let r=Array.isArray(e?.tracks)?e.tracks:[],n=[];for(let i of t){if(i.type!=="animationKeyframe:upsert"&&i.type!=="animationKeyframe:remove"){n.push(i);continue}let s=r.findIndex(o=>o.id===i.trackId);s!==-1&&n.push({type:"animationTrack:upsert",track:structuredClone(r[s]),index:s,updatedAt:i.updatedAt,clientId:i.clientId})}return n}function ha(t,e){if(!t.some(n=>n.type==="text:format"))return t;let r=[];for(let n of t){if(n.type!=="text:format"){r.push(n);continue}let i=tt(e,n.id);if(!i)continue;let s=i.state.richTextRuns;if(!vr(s))continue;let o={richTextRuns:structuredClone(s)},a=i.state.richTextData;vr(a)&&(o.richTextData=structuredClone(a)),r.push({type:"shape:update",id:n.id,state:o,...typeof n.updatedAt=="number"?{propTimestamps:Object.fromEntries(Object.keys(o).map(u=>[u,n.updatedAt]))}:{},...n.clientId!==void 0?{clientId:n.clientId}:{}})}return r}function pa(t,e){if(!t.some(n=>n.type==="guide:move"||n.type==="measurement:move"))return t;let r=[];for(let n of t)if(n.type==="guide:move"){let i=e.guides??[],s=i.findIndex(o=>o.id===n.id);if(s===-1)continue;r.push({type:"guide:upsert",guide:structuredClone(i[s]),index:s,updatedAt:n.updatedAt,clientId:n.clientId})}else if(n.type==="measurement:move"){let i=e.measurements??[],s=i.findIndex(o=>o.id===n.id);if(s===-1)continue;r.push({type:"measurement:upsert",measurement:structuredClone(i[s]),index:s,updatedAt:n.updatedAt,clientId:n.clientId})}else r.push(n);return r}function rt(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 Mi(t){if(t.builtIn)return!1;let e=t.pattern;return e.patternType==="custom"&&typeof e.svgContent=="string"}function Ci(t){let e=(t.viewBox??"").trim().split(/[\s,]+/).filter(s=>s.length>0).map(Number),r=e.length===4&&e.every(s=>Number.isFinite(s)),n=r&&e[2]>0?e[2]:t.width??10,i=r&&e[3]>0?e[3]:t.height??10;return{width:n,height:i}}function Tr(t){if(!Mi(t))return null;let{width:e,height:r}=Ci(t.pattern);return{id:t.id,name:t.name,svgContent:t.pattern.svgContent??"",width:e,height:r}}var Ct=Object.freeze([1,0,0,1,0,0]);function Re(t,e,r,n,i,s){return[t,e,r,n,i,s]}function wr(t){return Re(t[0]??1,t[1]??0,t[2]??0,t[3]??1,t[4]??0,t[5]??0)}function De(t){return[t[0],t[1],t[2],t[3],t[4],t[5]]}function it(t){return Array.isArray(t)&&t.length>=6&&t.slice(0,6).every(Number.isFinite)}function Di(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 yl(t,e,r=1e-9){for(let n=0;n<6;n++)if(Math.abs(t[n]-e[n])>r)return!1;return!0}function K(t,e){return Re(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 bl(t){let e=t[0]*t[3]-t[2]*t[1];if(Math.abs(e)<1e-10)return null;let r=1/e;return Re(t[3]*r,-t[1]*r,-t[2]*r,t[0]*r,(t[2]*t[5]-t[3]*t[4])*r,(t[1]*t[4]-t[0]*t[5])*r)}function xl(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 Sl(t,e){return{x:t[0]*e.x+t[2]*e.y,y:t[1]*e.x+t[3]*e.y}}function de(t,e=0){return Re(1,0,0,1,t,e)}function It(t,e=t){return Re(t,0,0,e,0,0)}function st(t){let e=t*Math.PI/180,r=Math.cos(e),n=Math.sin(e);return Re(r,n,-n,r,0,0)}function Dt(t){return Re(1,0,Math.tan(t*Math.PI/180),1,0,0)}function Ft(t){return Re(1,Math.tan(t*Math.PI/180),0,1,0,0)}function Fi(t,e){return K(K(de(t.x,t.y),e),de(-t.x,-t.y))}var $l=9,vl=10,Tl=12,kl=13,wl=32,ma=43,Pl=44,ga=45,_l=46,Rl=48,Al=57,Ml=40,Cl=41,Il=69,Dl=101,Fl=0,El=1,ba=2,Ll=new Map([["matrix",[6]],["translate",[1,2]],["scale",[1,2]],["rotate",[1,3]],["skewX",[1]],["skewY",[1]]]);function Bl(t){return t===wl||t===$l||t===vl||t===kl||t===Tl}function kr(t){return t>=Rl&&t<=Al}function Nl(t){let e=t>=65&&t<=90,r=t>=97&&t<=122;return e||r||kr(t)}function nt(t){for(;t.pos<t.src.length&&Bl(t.src.charCodeAt(t.pos));)t.pos++}function xa(t){let e=t.pos;return nt(t),t.src.charCodeAt(t.pos)===Pl?(t.pos++,nt(t),ba):t.pos>e?El:Fl}function ya(t){let e=t.src,r=t.pos,n=r,i=e.charCodeAt(n);(i===ma||i===ga)&&n++;let s=!1;for(;n<e.length&&kr(e.charCodeAt(n));)n++,s=!0;if(e.charCodeAt(n)===_l){let u=n+1;for(;u<e.length&&kr(e.charCodeAt(u));)u++;u>n+1&&(n=u,s=!0)}if(!s)return null;let o=e.charCodeAt(n);if(o===Dl||o===Il){let u=n+1,c=e.charCodeAt(u);(c===ma||c===ga)&&u++;let f=u;for(;f<e.length&&kr(e.charCodeAt(f));)f++;f>u&&(n=f)}let a=Number(e.slice(r,n));return Number.isFinite(a)?(t.pos=n,a):null}function Ol(t,e){switch(t){case"matrix":return wr(e);case"translate":return de(e[0],e[1]??0);case"scale":return It(e[0],e[1]??e[0]);case"rotate":return e.length===3?Fi({x:e[1],y:e[2]},st(e[0])):st(e[0]);case"skewX":return Dt(e[0]);case"skewY":return Ft(e[0]);default:return null}}function zl(t){let e=t.src,r=t.pos;for(;t.pos<e.length&&Nl(e.charCodeAt(t.pos));)t.pos++;if(t.pos===r)return null;let n=e.slice(r,t.pos),i=Ll.get(n);if(!i||(nt(t),e.charCodeAt(t.pos)!==Ml))return null;t.pos++,nt(t);let s=i[i.length-1],o=ya(t);if(o===null)return null;let a=[o];for(;;){let u=t.pos;xa(t);let c=ya(t);if(c===null){t.pos=u;break}if(a.push(c),a.length>s)return null}return nt(t),e.charCodeAt(t.pos)!==Cl||(t.pos++,!i.includes(a.length))?null:Ol(n,a)}function Gl(t){let e={src:t,pos:0};if(nt(e),e.pos>=t.length)return Ct;let r=Ct;for(;;){let n=zl(e);if(n===null)return null;r=K(r,n);let i=xa(e);if(e.pos>=t.length)return i===ba?null:r}}var Vl=2048,Mt=new Map;function Sa(t){if(!t)return Ct;let e=Mt.get(t);if(e!==void 0)return e;let r=Gl(t),n=r===null?null:Object.freeze(r);if(Mt.size>=Vl){let i=Mt.keys().next().value;i!==void 0&&Mt.delete(i)}return Mt.set(t,n),n}function Pr(t){return Sa(t)??Ct}function Ul(t){let e=t[0],r=t[1],n=t[2],i=t[3],s=Math.sqrt(e*e+r*r);if(s<1e-12)return{rotation:0,scaleX:0,scaleY:Math.sqrt(n*n+i*i),skewX:0};let o=Math.atan2(r,e),u=(e*i-r*n)/s,c=u!==0?(e*n+r*i)/(s*s):0,f=Math.atan(c),d=180/Math.PI;return{rotation:o*d,scaleX:s,scaleY:u,skewX:f*d}}function Ii(t){return!it(t)||Di(t)?null:`matrix(${t[0]}, ${t[1]}, ${t[2]}, ${t[3]}, ${t[4]}, ${t[5]})`}function Et(t,e){let r=t.translateX??0,n=t.translateY??0,i=typeof t.rawTransform=="string"?t.rawTransform:"",s=de(r,n);if(i)return K(s,Pr(i));let o=t.rotation??0,a=t.skewX??0,u=t.skewY??0,c=t.scaleX??1,f=t.scaleY??1;if(o===0&&a===0&&u===0&&c===1&&f===1)return s;let d=t.customPivot??e;if(!d)return s;let h=K(K(K(st(o),It(c,f)),Dt(a)),Ft(u));return K(s,Fi(d,h))}function at(t,e){let r=Ii(t.transformMatrix);return r||(Ii(De(Et(t,e)))??null)}function Ei(t,e){let r=t.ancestorTransform;if(!it(r)){delete t.ancestorTransform;return}if(Di(r)){delete t.ancestorTransform;return}let n=it(t.transformMatrix)?wr(t.transformMatrix):Et(t,e);t.transformMatrix=De(K(wr(r),n)),delete t.ancestorTransform}function Li(t,e,r){let n=at(t,{x:e,y:r});return n?`${n} translate(${e}, ${r})`:`translate(${e}, ${r})`}function Ta(t){let e=t.customPivot;if(e)return e;let r=t.x,n=t.y,i=t.width,s=t.height;if(typeof r=="number"&&typeof n=="number"&&typeof i=="number"&&typeof s=="number")return{x:r+i/2,y:n+s/2};let o=t.radius;if(typeof r=="number"&&typeof n=="number"&&typeof o=="number")return{x:r,y:n};let a=t.cx,u=t.cy;if(typeof a=="number"&&typeof u=="number")return{x:a,y:u};let c=t.x1,f=t.y1,d=t.x2,h=t.y2;if(typeof c=="number"&&typeof f=="number"&&typeof d=="number"&&typeof h=="number")return{x:(c+d)/2,y:(f+h)/2};let p=t.pathPoints;if(p?.[0])return{x:p[0].x,y:p[0].y};let g=t.polylinePoints;if(g?.[0])return{x:g[0].x,y:g[0].y}}function Lt(t){if(Array.isArray(t))for(let e of t){let r=e.state;Ei(r,Ta(r));let n=e.state.children;Lt(n)}}function Wl(t){Lt(t.shapes);for(let e of t.library??[])if(e.kind==="symbol"){Lt(e.shapes);for(let r of Object.values(e.variants??{}))Lt(r)}else e.kind==="marker"&&Lt(e.shapes);return t.schemaVersion=3,t}function Bi(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 Hl(t,e){let r=t.translateX??0,n=t.translateY??0,i=typeof t.rawTransform=="string"?t.rawTransform:"",s=de(r,n);if(i)return De(K(s,Pr(i)));let o=t.rotation??0,a=t.skewX??0,u=t.skewY??0;if(o!==0||a!==0||u!==0){let d=Bi(t.customPivot)??e??Bi(t.scaleAnchor);d&&(s=K(s,de(d.x,d.y)),o!==0&&(s=K(s,st(o))),a!==0&&(s=K(s,Dt(a))),u!==0&&(s=K(s,Ft(u))),s=K(s,de(-d.x,-d.y)))}let c=t.scaleX??1,f=t.scaleY??1;if(c!==1||f!==1){let d=Bi(t.scaleAnchor)??e;d&&(s=K(s,de(d.x,d.y)),s=K(s,It(c,f)),s=K(s,de(-d.x,-d.y)))}return De(s)}function Bt(t){if(Array.isArray(t))for(let e of t){let r=e.state;"scaleAnchor"in r&&(e.type==="text"&&!it(r.transformMatrix)&&(r.transformMatrix=Hl(r,Ta(r))),delete r.scaleAnchor);let n=e.state.children;Bt(n)}}function jl(t){Bt(t.shapes);for(let e of t.library??[])if(e.kind==="symbol"){Bt(e.shapes);for(let r of Object.values(e.variants??{}))Bt(r)}else e.kind==="marker"&&Bt(e.shapes);return t.schemaVersion=4,t}function Xl(t){let e=Array.isArray(t.library)?[...t.library]:[],r=new Set(e.map(u=>u.id));if(Array.isArray(t.symbols))for(let u of t.symbols)!u||r.has(u.id)||(e.push({...u,kind:"symbol"}),r.add(u.id));if(Array.isArray(t.markers))for(let u of t.markers)!u||r.has(u.id)||(e.push({...u,kind:"marker"}),r.add(u.id));let n=new Map,i=(u,c)=>{let{id:f,sourceId:d,...h}=u,p=JSON.stringify({kind:c,...h}),g=n.get(p);if(g)return g;let m=r.has(u.id)?`grd-${_r()}`:u.id;r.add(m),n.set(p,m);let b=c==="linear-gradient"?{kind:"linear-gradient",id:m,name:u.sourceId??m,sourceId:u.sourceId,gradient:$a(u)}:{kind:"radial-gradient",id:m,name:u.sourceId??m,sourceId:u.sourceId,gradient:$a(u)};return e.push(b),m},s=new Map;if(Array.isArray(t.customPatterns))for(let u of t.customPatterns){if(!u)continue;let c=r.has(u.id)?`pat-${_r()}`:u.id;r.add(c),s.set(u.id,c),e.push(rt(u,c))}let o=u=>{if(u.customPatternId){let x=s.get(u.customPatternId);if(x)return x}let{id:c,sourceId:f,customPatternId:d,...h}=u,p=JSON.stringify({kind:"pattern",...h}),g=n.get(p);if(g)return g;let m=r.has(u.id)?`pat-${_r()}`:u.id;r.add(m),n.set(p,m);let b={kind:"pattern",id:m,name:u.sourceId??m,sourceId:u.sourceId,pattern:h};return e.push(b),m};for(let u of t.shapes??[]){let c=u.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 h=c.filters;if(Array.isArray(h)&&h.length>0){let p=a(h,c,u.id);c.filterLibraryIds=[p]}}return t.library=e,t;function a(u,c,f){let d={filters:u,colorInterpolation:c.filterColorInterpolation,filterUnits:c.filterUnits,primitiveUnits:c.primitiveUnits,x:c.filterX,y:c.filterY,width:c.filterWidth,height:c.filterHeight},h=JSON.stringify({kind:"filter",...d}),p=n.get(h);if(p)return p;let g=`filter-${f}`,m=r.has(g)?`flt-${_r()}`:g;r.add(m),n.set(h,m);let b={kind:"filter",id:m,name:m,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),m}}function $a(t){let{id:e,sourceId:r,...n}=t;return n}var Ni=0;function _r(){return Ni=Ni+1&65535,`${Date.now().toString(36)}-${Ni.toString(36)}`}function Kl(t){let e=r=>{if(Array.isArray(r))for(let n of r)ze(n)};e(t.shapes);for(let r of t.library??[])if(r.kind==="symbol"){e(r.shapes);for(let n of Object.values(r.variants??{}))e(n)}else r.kind==="marker"&&e(r.shapes);return t.schemaVersion=5,t}function va(t){if(!t||typeof t!="object"||Array.isArray(t))return;let e=t;if(e.richTextRuns!==void 0&&e.richTextRuns!==null)return;let r=e.richTextData;!r||typeof r!="object"||Array.isArray(r)||Array.isArray(r.lines)&&(e.richTextRuns=Ue(r))}function ka(t){if(!t?.state||typeof t.state!="object")return;let e=t.state,r=e.children;if(Array.isArray(r))for(let i of r)ka(i);let n=e.symbolOverrides;if(n&&typeof n=="object"&&!Array.isArray(n))for(let i of Object.values(n))va(i);va(e)}function Yl(t){let e=r=>{if(Array.isArray(r))for(let n of r)ka(n)};e(t.shapes);for(let r of t.library??[])if(r.kind==="symbol"){e(r.shapes);for(let n of Object.values(r.variants??{}))e(n)}else r.kind==="marker"&&e(r.shapes);return t.schemaVersion=6,t}var Oi=Object.freeze({1:Xl,2:Wl,3:jl,4:Kl,5:Yl});function ql(t){let e=t.schemaVersion;return typeof e!="number"||!Number.isFinite(e)||e<1?1:Math.floor(e)}function Rr(t,e=Oi){let r=JSON.parse(JSON.stringify(t)),n=ql(r);if(n>ae)return r;if(n===ae)return r.schemaVersion=ae,r;for(;n<ae;){let i=e[n];if(!i)throw new Error(`[svgsketch/core] No migration registered for schema version ${n} \u2192 ${n+1}. Cannot safely upgrade this document to version ${ae}.`);r=i(r),n+=1}return r.schemaVersion=ae,r}var Zl=new Set(["circle","rectangle","square","ellipse","text","triangle","ngon","star","cross","ring","spiral","gear","arrow","line","path","polyline","image"]);function Nt(t){let e=[],r=[];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:r};let n=t;if(n.schemaVersion!==void 0&&(typeof n.schemaVersion!="number"||!Number.isInteger(n.schemaVersion)?e.push({path:"schemaVersion",message:"schemaVersion must be an integer",severity:"error"}):n.schemaVersion>ae&&r.push({path:"schemaVersion",message:`schemaVersion ${n.schemaVersion} is newer than supported (${ae})`,severity:"warning"})),!Array.isArray(n.shapes))e.push({path:"shapes",message:"shapes must be an array",severity:"error"});else{let i=new Set;n.shapes.forEach((s,o)=>{ru(s,`shapes[${o}]`,e,r,i)})}if(!Array.isArray(n.viewboxes))e.push({path:"viewboxes",message:"viewboxes must be an array",severity:"error"});else{let i=new Set;n.viewboxes.forEach((s,o)=>{su(s,`viewboxes[${o}]`,e,r,i)})}if(n.guides!==void 0&&(Array.isArray(n.guides)?n.guides.forEach((i,s)=>{au(i,`guides[${s}]`,e,r)}):e.push({path:"guides",message:"guides must be an array",severity:"error"})),n.groups!==void 0&&(Array.isArray(n.groups)?n.groups.forEach((i,s)=>{ou(i,`groups[${s}]`,e)}):e.push({path:"groups",message:"groups must be an array",severity:"error"})),n.sceneTree!==void 0)if(!Array.isArray(n.sceneTree))e.push({path:"sceneTree",message:"sceneTree must be an array",severity:"error"});else{let i=Ql(n.shapes),s=new Set;n.sceneTree.forEach((o,a)=>{Jl(o,`sceneTree[${a}]`,e,r,i,s)})}if(n.clipMaskGroups!==void 0&&(Array.isArray(n.clipMaskGroups)?n.clipMaskGroups.forEach((i,s)=>{lu(i,`clipMaskGroups[${s}]`,e)}):e.push({path:"clipMaskGroups",message:"clipMaskGroups must be an array",severity:"error"})),n.paintServerDefs!==void 0)if(!Array.isArray(n.paintServerDefs))e.push({path:"paintServerDefs",message:"paintServerDefs must be an array",severity:"error"});else{let i=new Set;n.paintServerDefs.forEach((s,o)=>{tu(s,`paintServerDefs[${o}]`,e,i)})}return n.measurements!==void 0&&(Array.isArray(n.measurements)||e.push({path:"measurements",message:"measurements must be an array",severity:"error"})),{valid:e.length===0,errors:e,warnings:r}}function Ql(t){let e=new Set;if(!Array.isArray(t))return e;let r=n=>{if(n===null||typeof n!="object")return;let i=n;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)r(a)};for(let n of t)r(n);return e}function wa(t){return t.startsWith("structural:")}function Jl(t,e,r,n,i,s){if(t===null||typeof t!="object"){r.push({path:e,message:"Scene tree entry must be a non-null object",severity:"error"});return}let o=t;typeof o.id!="string"||o.id.length===0?r.push({path:`${e}.id`,message:"Scene tree id must be a non-empty string",severity:"error"}):(s.has(o.id)&&r.push({path:`${e}.id`,message:`Duplicate scene tree id: "${o.id}"`,severity:"error"}),s.add(o.id),!i.has(o.id)&&!wa(o.id)&&n.push({path:`${e}.id`,message:`Scene tree id "${o.id}" is not present in shapes`,severity:"warning"})),o.parentId!==null&&typeof o.parentId!="string"?r.push({path:`${e}.parentId`,message:"Scene tree parentId must be a string or null",severity:"error"}):typeof o.parentId=="string"&&!i.has(o.parentId)&&!wa(o.parentId)&&n.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)&&r.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)&&r.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"&&r.push({path:`${e}.clientId`,message:"Scene tree clientId must be a string",severity:"error"})}var eu=new Set(["mask","clipPath","filter","linearGradient","radialGradient","pattern","symbol"]);function tu(t,e,r,n){if(t===null||typeof t!="object"){r.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?r.push({path:`${e}.id`,message:"Paint server def id must be a non-empty string",severity:"error"}):n.has(i.id)?r.push({path:`${e}.id`,message:`Duplicate paint server def id: "${i.id}"`,severity:"error"}):n.add(i.id),(typeof i.type!="string"||!eu.has(i.type))&&r.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)&&r.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"&&r.push({path:`${e}.passthrough`,message:"Paint server def passthrough must be a boolean when present",severity:"error"})}function ru(t,e,r,n,i){if(t===null||typeof t!="object"){r.push({path:e,message:"Shape must be a non-null object",severity:"error"});return}let s=t;typeof s.id!="string"||s.id.length===0?r.push({path:`${e}.id`,message:"Shape id must be a non-empty string",severity:"error"}):i.has(s.id)?r.push({path:`${e}.id`,message:`Duplicate shape id: "${s.id}"`,severity:"error"}):i.add(s.id),typeof s.type!="string"?r.push({path:`${e}.type`,message:"Shape type must be a string",severity:"error"}):Zl.has(s.type)||n.push({path:`${e}.type`,message:`Unknown shape type: "${s.type}"`,severity:"warning"}),s.state===void 0||s.state===null||typeof s.state!="object"?r.push({path:`${e}.state`,message:"Shape state must be a non-null object",severity:"error"}):iu(s.state,`${e}.state`,r,n)}var nu=/^\s*\{\{\s*[\w.\-]+\s*\}\}\s*$/;function Pa(t){return typeof t=="number"?isFinite(t):typeof t=="string"?nu.test(t):!1}function iu(t,e,r,n){let i=["x","y","width","height","radius","rx","ry","fontSize"];for(let o of i)t[o]!==void 0&&!Pa(t[o])&&r.push({path:`${e}.${o}`,message:`${o} must be a finite number or a {{variable}} reference`,severity:"error"});for(let o of mt){let a=t[o];if(a!=null){if(o==="transformMatrix"){(!Array.isArray(a)||a.length<6||!a.slice(0,6).every(u=>typeof u=="number"&&Number.isFinite(u)))&&r.push({path:`${e}.${o}`,message:`${o} must be a 6-element finite affine matrix`,severity:"error"});continue}Pa(a)||r.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=t[o];typeof a=="number"&&a<=0&&n.push({path:`${e}.${o}`,message:`${o} should be positive (got ${a})`,severity:"warning"})}}function su(t,e,r,n,i){if(t===null||typeof t!="object"){r.push({path:e,message:"Viewbox must be a non-null object",severity:"error"});return}let s=t;typeof s.id!="string"||s.id.length===0?r.push({path:`${e}.id`,message:"Viewbox id must be a non-empty string",severity:"error"}):i.has(s.id)?r.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]))&&r.push({path:`${e}.${o}`,message:`${o} must be a finite number`,severity:"error"});typeof s.width=="number"&&s.width<=0&&r.push({path:`${e}.width`,message:"Viewbox width must be positive",severity:"error"}),typeof s.height=="number"&&s.height<=0&&r.push({path:`${e}.height`,message:"Viewbox height must be positive",severity:"error"})}function au(t,e,r,n){if(t===null||typeof t!="object"){r.push({path:e,message:"Guide must be a non-null object",severity:"error"});return}let i=t;(typeof i.id!="string"||i.id.length===0)&&r.push({path:`${e}.id`,message:"Guide id must be a non-empty string",severity:"error"}),i.orientation!=="horizontal"&&i.orientation!=="vertical"&&r.push({path:`${e}.orientation`,message:'Guide orientation must be "horizontal" or "vertical"',severity:"error"}),(typeof i.position!="number"||!isFinite(i.position))&&r.push({path:`${e}.position`,message:"Guide position must be a finite number",severity:"error"})}function ou(t,e,r){if(t===null||typeof t!="object"){r.push({path:e,message:"Group must be a non-null object",severity:"error"});return}let n=t;(typeof n.id!="string"||n.id.length===0)&&r.push({path:`${e}.id`,message:"Group id must be a non-empty string",severity:"error"}),n.parentId!==null&&typeof n.parentId!="string"&&r.push({path:`${e}.parentId`,message:"Group parentId must be a string or null",severity:"error"})}function lu(t,e,r){if(t===null||typeof t!="object"){r.push({path:e,message:"ClipMaskGroup must be a non-null object",severity:"error"});return}let n=t;(typeof n.id!="string"||n.id.length===0)&&r.push({path:`${e}.id`,message:"ClipMaskGroup id must be a non-empty string",severity:"error"}),n.type!=="clip"&&n.type!=="mask"&&r.push({path:`${e}.type`,message:'ClipMaskGroup type must be "clip" or "mask"',severity:"error"}),(typeof n.clipShapeId!="string"||n.clipShapeId.length===0)&&r.push({path:`${e}.clipShapeId`,message:"clipShapeId must be a non-empty string",severity:"error"}),Array.isArray(n.contentShapeIds)||r.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 Ar(t={}){let e={schemaVersion:ae,shapes:t.shapes?t.shapes.map(r=>({...r})):[],viewboxes:t.viewboxes?t.viewboxes.map(r=>({...r})):[]};return t.metadata&&(e.documentMetadata={title:"",description:"",author:"",keywords:[],license:"",licenseUrl:"",language:"en",customMetadata:{},...t.metadata}),e}function _a(t){let{type:e,id:r,...n}=t,i={};for(let[s,o]of Object.entries(n))o!==void 0&&(i[s]=o);return{id:r??_(),type:e,state:i}}function Ot(t,e,r,n,i){return{id:i??_(),x:t,y:e,width:r,height:n}}var uu=["schemaVersion","documentMetadata","documentScripts","documentStyles","templateVariables","viewboxes","guides","measurements","groups","sceneTree","clipMaskGroups","customPatterns","symbols","markers","library","colorGlyphLibrary","paintServerDefs","rawPaintServerDefs","animationTimeline","shapes"];function Mr(t,e={}){let{indent:r=2,trailingNewline:n=!0,validate:i=!1}=e;if(i){let a=Nt(t);if(!a.valid){let u=a.errors.map(c=>` ${c.path}: ${c.message}`).join(`
|
|
1
|
+
"use strict";var Hi=Object.defineProperty;var uu=Object.getOwnPropertyDescriptor;var cu=Object.getOwnPropertyNames;var du=Object.prototype.hasOwnProperty;var fu=(n,e)=>{for(var t in e)Hi(n,t,{get:e[t],enumerable:!0})},pu=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of cu(e))!du.call(n,i)&&i!==t&&Hi(n,i,{get:()=>e[i],enumerable:!(r=uu(e,i))||r.enumerable});return n};var mu=n=>pu(Hi({},"__esModule",{value:!0}),n);var Np={};fu(Np,{Arrow:()=>_i,Audio:()=>zi,BUILTIN_MARKER_ID_MAP:()=>Os,COLLAB_PROTOCOL_VERSION:()=>No,COMMON_PROP_DEFAULTS:()=>J,COMMON_TRANSFORM_NODE_DEFAULTS:()=>Yi,CURRENT_SCHEMA_VERSION:()=>xe,Circle:()=>mi,Cloud:()=>Ii,Container:()=>Fi,ContainerShapeBuilder:()=>tt,Cross:()=>ki,DEFAULT_COORDINATE_PRECISION:()=>tl,DEFAULT_RICH_TEXT_STYLE:()=>Kt,Document:()=>Tn,DocumentBuilder:()=>Tn,EASING_CURVES:()=>Mn,EasingType:()=>In,Ellipse:()=>hi,Gear:()=>Pi,Heart:()=>Ri,Hyperlink:()=>Ci,IDENTITY_AFFINE:()=>nn,ImageShape:()=>Ui,KNOWN_STATE_KEYS:()=>Ji,LIBRARY_EMIT_ORDER:()=>Ys,Lightning:()=>Ai,Line:()=>bi,LinearGradientBuilder:()=>wn,MARKER_HEIGHT:()=>Lr,MARKER_VIEWBOX:()=>bn,MARKER_WIDTH:()=>Or,MAX_COORDINATE_PRECISION:()=>nl,MIGRATIONS:()=>Ps,NGon:()=>$i,NON_WIRE_PROP_KEYS:()=>Ca,NUMERIC_SHAPE_TRANSFORM_STATE_KEYS:()=>Nt,NestedSvg:()=>Oi,NodeSchemaRegistry:()=>Ut,PUZZLE_DEFAULTS:()=>ha,Path:()=>Gi,PathCurveType:()=>ji,PathPointType:()=>_a,PatternBuilder:()=>_n,Polyline:()=>Vi,RICH_TEXT_STYLE_KEYS:()=>vt,RadialGradientBuilder:()=>Pn,Rectangle:()=>gi,Ring:()=>Ti,SERIALIZED_SHAPE_STATE_KEYS:()=>Ki,SHAPE_TRANSFORM_STATE_KEYS:()=>Xi,SceneGraph:()=>Ln,SceneNode:()=>Be,ShapeBuilder:()=>ae,ShapeReference:()=>Li,SpeechBubble:()=>Mi,Spiral:()=>wi,Square:()=>yi,Star:()=>vi,Switch:()=>Di,Text:()=>Si,Timeline:()=>pi,Track:()=>fi,Triangle:()=>xi,Video:()=>Bi,View:()=>Ei,affine:()=>We,affineFromArray:()=>nr,affineToArray:()=>Ye,almostEqualAffine:()=>ec,applyAffineToPoint:()=>nc,applyAffineToVector:()=>rc,applyOpToSnapshot:()=>Mo,applyOpsInPlace:()=>ys,applyOpsToSnapshot:()=>Co,applyOpsToSnapshotWithAccepted:()=>bs,applyRichTextFormat:()=>Yt,applyTextSplice:()=>eo,applyTextTransform:()=>Sn,arcEndpointToCenter:()=>da,areTracksTimingEquivalent:()=>oa,around:()=>$s,buildCompoundTransformValues:()=>Jr,buildSmilKeyframeData:()=>et,canonicalPolygonTransformString:()=>ks,canonicalTransformString:()=>At,collaborationResourceKey:()=>ls,collectMarkerReferences:()=>gn,collectReferencedLibraryDefs:()=>$n,collectReferencedMarkerIds:()=>hl,compareOrderKeys:()=>Vt,composeLegacyTransformMatrix:()=>on,computeArrowVertices:()=>xr,computeCloudPath:()=>Tr,computeCrossVertices:()=>Sr,computeDashArray:()=>Mt,computeFlowchartBoxPath:()=>Ar,computeGearPath:()=>_r,computeGearVertices:()=>Cs,computeHeartPath:()=>kr,computeLightningVertices:()=>vr,computePolygonVertices:()=>pn,computeRectanglePath:()=>Rr,computeRingPath:()=>wr,computeSpeechBubbleVertices:()=>$r,computeSpiralPath:()=>Pr,computeSplinePath:()=>qe,computeStarVertices:()=>br,createDocument:()=>or,createSceneNode:()=>rt,createShape:()=>Qo,createViewbox:()=>dn,createWordSearchPrimitiveMask:()=>lu,cubicBezierExtent1D:()=>ii,customPatternDefToLibraryDef:()=>Ue,declaredRichTextDeltaKeys:()=>Kn,decomposeAffine2D:()=>Pc,defaultVariableMode:()=>gu,deriveRichTextFormatRanges:()=>oo,deriveSegments:()=>Ve,deriveTextSplice:()=>Qa,downTranslateAnimationKeyframeOps:()=>Eo,downTranslateCollectionMoveOps:()=>Lo,downTranslateDocumentFieldOps:()=>Bo,downTranslateScenePlaceOps:()=>Fo,downTranslateTextFormatOps:()=>Oo,ellipticalArcBounds:()=>fa,escXml:()=>Z,extractVariables:()=>mr,filterAttr:()=>Fr,findShapeById:()=>ct,flattenShapeStateTree:()=>Wt,flattenStateExtra:()=>Ne,foldLegacyAncestorTransformIntoMatrix:()=>vs,forEachLibraryRefInState:()=>ml,forEachMarkerRefInState:()=>pl,forEachReachableShape:()=>hn,forEachShapeInLibraryDefs:()=>fl,formatOperationValidationIssues:()=>Ja,formatSmilKeySpline:()=>Ur,formatSmilKeyTime:()=>be,freezeSiblingOrderKeys:()=>en,generateCode:()=>di,generateCssCode:()=>ci,generateD3Code:()=>ui,generateId:()=>_,generatePatternSvgContent:()=>Er,generatePuzzlePieces:()=>Vl,generateReactCode:()=>oi,generateSudokuPuzzle:()=>Ql,generateSvgCode:()=>ai,generateVueCode:()=>li,generateWordSearch:()=>ou,getBuiltInMarkerDefs:()=>gl,getEasingCubicBezier:()=>hu,getEffectivePrecision:()=>rl,getKeyframeCubicBezier:()=>ra,getMarkerDescriptors:()=>pt,getPatternElements:()=>yn,getSmilAdditive:()=>Yr,getSmilBeginValue:()=>mt,getSmilFillMode:()=>ht,getSmilMotionKeyPoints:()=>qr,getSmilRepeatCount:()=>Xr,getSmilSetBeginValue:()=>Kr,getSmilTrackDuration:()=>Qe,getWordSearchDirections:()=>$a,initialOrderKeys:()=>En,invertAffine:()=>tc,isDefaultKeyPoints:()=>Wr,isDefaultKeyTimes:()=>vn,isFiniteAffineArray:()=>_t,isIdentityAffine:()=>xs,isIdentityLinearSplines:()=>aa,isIndefiniteSetTrack:()=>Hr,isReusablePatternTile:()=>qt,isSetSequenceTrack:()=>jr,isValidOrderKey:()=>Gt,keyBetween:()=>bt,keysBetween:()=>Fn,legacyEndpointMarkerId:()=>mn,linearGradient:()=>El,lintWordSearchOptions:()=>va,materializeSceneTreeOrderKeys:()=>Do,matrixTransformPart:()=>Ss,maxCollaborationTimestamp:()=>yo,mergeRichTextStyle:()=>Hn,migrateSnapshot:()=>sr,moveResourceById:()=>Qn,multiplyAffine:()=>ne,nodeSchemas:()=>O,normalizeRichTextRuns:()=>st,normalizeRichTextStyle:()=>Me,normalizeRichTextStyleDelta:()=>Xt,orderSiblings:()=>Pe,parseDocument:()=>ur,parseSvgTransformList:()=>rr,parseVariableArgs:()=>el,parseWordSearchWords:()=>su,partitionShapeStateTree:()=>nt,partitionStateExtra:()=>On,pathDataBounds:()=>ma,pattern:()=>Ll,patternLibraryDefToCustomPatternDef:()=>kt,patternTileSize:()=>ss,planTransformFusion:()=>Zr,projectSceneTreeOntoClipMaskGroups:()=>Tt,projectSceneTreeOntoShapes:()=>hs,promoteRebasedShapeUpdateClock:()=>bo,quadraticBezierExtent1D:()=>si,radialGradient:()=>Ol,rebaseRichTextFormatRanges:()=>ao,rebaseRichTextRuns:()=>lo,reflectCubicBezier:()=>sa,removeResourceById:()=>ye,removeResourceByKey:()=>Vn,removeResourceByName:()=>Wn,removeTrackKeyframe:()=>ms,renderAnimationElements:()=>ti,renderBuiltinMarkerDefs:()=>Ee,renderCircle:()=>Ns,renderEllipse:()=>Bs,renderFilterDefs:()=>cl,renderFilterLibraryDef:()=>na,renderFilterPrimitive:()=>Dr,renderFilterPrimitivesForType:()=>Fs,renderFlowchartBox:()=>Ks,renderImage:()=>Hs,renderLibraryDef:()=>qs,renderLibraryDefs:()=>xn,renderLine:()=>Gs,renderLinearGradientLibraryDef:()=>Qs,renderMarkerLibraryDef:()=>Js,renderPatternLibraryDef:()=>ta,renderPolygonShape:()=>Xs,renderPolyline:()=>Ws,renderRadialGradientLibraryDef:()=>ea,renderRectangle:()=>zs,renderReferencedLibraryDefs:()=>Ze,renderShape:()=>de,renderSpline:()=>Us,renderSvgPrimitiveChainFilter:()=>Ds,renderSymbolInstance:()=>js,renderSymbolLibraryDef:()=>Zs,renderText:()=>Vs,renderToSvg:()=>Ft,resolveRichTextStyleAt:()=>so,resolveSymbolInstanceShapes:()=>Nr,rewriteDocumentEmbeddedPayloads:()=>qo,rewriteShapeStateEmbeddedPayloads:()=>ar,richTextFontVariantCss:()=>Dt,richTextLineSpans:()=>rs,richTextRunsFromState:()=>qn,richTextStyleDelta:()=>jn,richTextStyleDeltasEqual:()=>Yn,richTextStylesEqual:()=>Xn,richTextTspanAttributes:()=>Br,rotateAffine:()=>Rt,roundCoord:()=>gr,roundNumberString:()=>As,roundSerializedShape:()=>hr,roundSnapshot:()=>il,runsFromSegments:()=>at,sanitizeRichTextFormatRanges:()=>Zn,scaleAffine:()=>rn,senderCorrectionsForOp:()=>Ao,skewXAffine:()=>sn,skewYAffine:()=>an,smilKeyframeAttributes:()=>kn,solveCubicBezier:()=>ia,solveSudoku:()=>An,splinePathBounds:()=>Il,stringifyDocument:()=>lr,substituteString:()=>cr,substituteVariables:()=>pr,symbolInstanceTargetId:()=>Ct,transformSplice:()=>jt,translateAffine:()=>_e,tryParseSvgTransformList:()=>Ho,upsertResourceById:()=>ge,upsertResourceByKey:()=>Gn,upsertResourceByName:()=>Un,upsertTrackKeyframe:()=>ps,validateDocumentOperations:()=>qa,validateOperation:()=>zn,validatePresenceOperation:()=>Za,validateSnapshot:()=>cn,validateSudokuPuzzle:()=>Jl,verticesToPath:()=>Ae});module.exports=mu(Np);var In=(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))(In||{}),Mn={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 hu(n){let e=Mn[n];return e?`cubic-bezier(${e.join(", ")})`:"linear"}var ji=(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))(ji||{}),_a=(r=>(r.SMOOTH="smooth",r.CORNER="corner",r.SYMMETRIC="symmetric",r))(_a||{});function gu(n){return n==="color"?"live":"stamped"}var Ki=["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","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"],xe=6;var Xi=["transformMatrix","scaleX","scaleY","translateX","translateY","rotation","skewX","skewY","customPivot","rawTransform"],Nt=["transformMatrix","scaleX","scaleY","translateX","translateY","rotation","skewX","skewY"],Yi={transformMatrix:null,translateX:0,translateY:0,rotation:0,skewX:0,skewY:0,customPivot:null,rawTransform:null};var Oe="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",Dn=Oe.length,Le=Oe[0],Ra=Oe[Dn-1],Ia=Oe[Math.floor(Dn/2)],qi=97,yu=122;function yt(n){let e=Oe.indexOf(n);if(e===-1)throw new Error(`order-key: invalid digit '${n}'`);return e}function bu(n){let e=n.charCodeAt(0);if(e<qi||e>yu)throw new Error(`order-key: invalid head '${n}'`);return e-qi+1}function Ke(n){if(n<1||n>26)throw new Error(`order-key: integer length ${n} out of range`);return String.fromCharCode(qi+n-1)}function Bt(n){let e=bu(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)yt(i);for(let i of r)yt(i);return{integer:t,fraction:r}}function Cn(n){for(let e of n)if(e!==Le)return!1;return!0}function Gt(n){if(n.length===0)return!1;try{let{integer:e,fraction:t}=Bt(n);return!(t.endsWith(Le)||Cn(e)&&t.length===0||e.length>1&&e[0]===Le)}catch{return!1}}function Aa(n,e){if(!Gt(n))throw new Error(`order-key: invalid ${e} '${n}'`)}function Vt(n,e){return n<e?-1:n>e?1:0}function Su(n){let e=n.split("");for(let t=e.length-1;t>=0;t--){let r=yt(e[t]);if(r<Dn-1){e[t]=Oe[r+1];for(let i=t+1;i<e.length;i++)e[i]=Le;return e.join("")}}return null}function Zi(n){let{integer:e}=Bt(n),t=Su(e);if(t!==null)return Ke(e.length)+t;let r="1"+Le.repeat(e.length);return Ke(r.length)+r}function xu(n){let e=n.split("");for(let t=e.length-1;t>=0;t--){let r=yt(e[t]);if(r>0){e[t]=Oe[r-1];for(let i=t+1;i<e.length;i++)e[i]=Ra;return e.join("")}e[t]=Ra}throw new Error(`order-key: cannot decrement zero integer '${n}'`)}function $u(n){let e=0;for(;e<n.length-1&&n[e]===Le;)e++;return n.slice(e)}function vu(n){let{integer:e,fraction:t}=Bt(n);if(!Cn(e)){let r=xu(e);if(!Cn(r)){let i=$u(r);return Ke(i.length)+i}return Ke(1)+Le+Ia}return Ke(1)+Le+zt("",t)}function zt(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]??Le)===e[i];)i++;if(i>0)return e.slice(0,i)+zt(n.slice(i),e.slice(i))}let t=n.length>0?yt(n[0]):0,r=e!==null?yt(e[0]):Dn;return r-t>1?Oe[Math.floor((t+r)/2)]:Oe[t]+zt(n.slice(1),null)}function bt(n,e){if(n!==null&&Aa(n,"lower bound"),e!==null&&Aa(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 Ke(1)+"1";if(n===null)return vu(e);if(e===null)return Zi(n);let t=Bt(n),r=Bt(e),i=Ke(t.integer.length)+t.integer,s=Ke(r.integer.length)+r.integer;if(i===s)return i+zt(t.fraction,r.fraction);let o=Zi(i+(Cn(t.integer)?Ia:""));return Vt(o,e)<0?o:i+zt(t.fraction,null)}function Fn(n,e,t){if(t<=0)return[];let r=[],i=n;for(let s=0;s<t;s++){let o=bt(i,e);r.push(o),i=o}return r}function En(n){if(n<=0)return[];let e=[],t=bt(null,null);e.push(t);for(let r=1;r<n;r++)t=Zi(t),e.push(t);return e}var Ut=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),St=n=>Math.max(0,Math.min(1,n)),te=n=>Math.max(0,Math.min(100,n)),ku=n=>Math.max(1,n),Tu=n=>Math.max(3,Math.min(100,Math.floor(n))),wu=n=>Math.max(3,Math.min(50,Math.floor(n))),Pu=n=>Math.max(3,Math.min(30,Math.floor(n))),_u=n=>Math.max(1,Math.min(10,n));function Ru(n){return Object.fromEntries(Object.entries(n).map(([e,t])=>[e,{default:t}]))}var Au=Ru(Yi),J={layerName:{default:null},fillColor:{default:"#ffffff"},borderColor:{default:"#000000"},borderWidth:{default:1},opacity:{default:1,validate:St},fillOpacity:{default:1,validate:St},strokeOpacity:{default:1,validate:St},...Au,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:ku},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={...J,cx:{default:0},cy:{default:0},radius:{default:50,validate:E},cornerRadius:{default:0,validate:E},shiftAngle:{default:0}},xt={...J,x:{default:0},y:{default:0},width:{default:100,validate:E},height:{default:60,validate:E}},Ma={...J,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:St},muted:{default:!1},loop:{default:!1},playbackRate:{default:1},mediaOpacity:{default:1,validate:St},fadeInDuration:{default:0,validate:E},fadeOutDuration:{default:0,validate:E},posterHref:{default:""},sourceRect:{default:null}},O=new Ut;O.register("rectangle",{...J,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",{...J,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",{...J,x:{default:0},y:{default:0},radius:{default:50,validate:E}});O.register("ellipse",{...J,cx:{default:0},cy:{default:0},rx:{default:50,validate:E},ry:{default:30,validate:E}});O.register("line",{...J,x1:{default:0},y1:{default:0},x2:{default:100},y2:{default:0},startEndpoint:{default:"none"},endEndpoint:{default:"none"}});O.register("text",{...J,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",{...J,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:St}});O.register("path",{...J,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",{...J,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:Tu}});O.register("star",{...ke,arms:{default:5,validate:wu},innerRadiusPercent:{default:40,validate:te}});O.register("cross",{...ke,armWidthPercent:{default:30,validate:te}});O.register("ring",{...ke,innerRadiusPercent:{default:50,validate:te}});O.register("spiral",{...ke,turns:{default:3,validate:_u},thicknessPercent:{default:15,validate:te},spiralDirection:{default:1}});O.register("gear",{...ke,teeth:{default:8,validate:Pu},toothDepthPercent:{default:25,validate:te},holeRadiusPercent:{default:20,validate:te}});O.register("arrow",{...ke,headWidthPercent:{default:100,validate:te},headLengthPercent:{default:40,validate:te},shaftWidthPercent:{default:40,validate:te}});O.register("symbol-instance",{...J,x:{default:0},y:{default:0},width:{default:100,validate:E},height:{default:100,validate:E},symbolId:{default:""}});O.register("group",{...J,groupId:{default:null}});O.register("cloud",{...ke,cloudBumps:{default:5},cloudPuffinessPercent:{default:60,validate:te}});O.register("heart",{...ke,lobeRadiusPercent:{default:50,validate:te},cleftDepthPercent:{default:25,validate:te}});O.register("lightning",{...ke,boltSegments:{default:3},boltWidthPercent:{default:30,validate:te},boltJaggednessPercent:{default:40,validate:te}});O.register("speechBubble",{...ke,tailAngleDeg:{default:45},tailLengthPercent:{default:40,validate:te},tailWidthPercent:{default:25,validate:te}});O.register("diamond",{...xt});O.register("parallelogram",{...xt,slantPercent:{default:20,validate:te}});O.register("trapezoid",{...xt,topWidthPercent:{default:70,validate:te}});O.register("terminator",{...xt});O.register("cylinder",{...xt,capHeightPercent:{default:15,validate:te}});O.register("document-shape",{...xt,waveAmplitudePercent:{default:15,validate:te}});O.register("hyperlink",{...J,href:{default:""},hrefXlink:{default:""},linkTarget:{default:""},linkDownload:{default:""},linkPing:{default:""},linkRel:{default:""},linkHreflang:{default:""},linkType:{default:""},linkReferrerPolicy:{default:""}});O.register("switch",{...J,switchSystemLanguage:{default:""},switchRequiredExtensions:{default:""}});O.register("svg",{...J,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",{...J,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",{...J,targetShapeId:{default:""},offsetX:{default:0},offsetY:{default:0},targetWidth:{default:0,validate:E},targetHeight:{default:0,validate:E},broken:{default:!1}});O.register("video",{...Ma,mediaKind:{default:"video"}});O.register("audio",{...Ma,mediaKind:{default:"audio"}});O.register("document",{});function Iu(){let n=new Set(Ki);for(let e of Xi)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 Ji=Iu(),Ca=new Set(["scaleAnchor","displayAttr"]);function On(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"||Ji.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 nt(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)nt(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)&&On(i);return On(e),n}function Wt(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)Wt(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)&&Ne(i);return Ne(e),n}function Ne(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 rt(n,e,t,r="verbatim"){if(r==="verbatim")return new Be(n,e,t&&"extra"in t?Ne({...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 Be(n,e,i)}var Be=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 rt(e.id,e.type,e.state,"verbatim")}static create(e,t,r){return rt(e,t,r,"authoring")}};var Mu=5e3,Cu=1e4;function Du(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 Ln=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=rt("__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>Cu){console.error("[SceneGraph] batched-notification drain did not converge \u2014 render loop?",Du(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>Mu){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=Be.fromSerialized(r);t.addNode(i)}return t}};var G=["updatedAt","clientId"];function z(n,e,t){n.push({path:e,message:t})}function Ha(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}function U(n,e,t){return Ha(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 oe(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 oe(n,e,t,r)?Number.isInteger(n)?!0:(z(t,e,"must be an integer"),!1):!1}function $t(n,e,t){return typeof n!="boolean"?(z(t,e,"must be a boolean"),!1):!0}function Q(n,e,t,r,i=!1){n[e]!==void 0&&A(n[e],`${t}.${e}`,r,i)}function Qi(n,e,t,r,i){n[e]!==void 0&&oe(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 Nn(n,e,t,r){n[e]!==void 0&&$t(n[e],`${t}.${e}`,r)}function it(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 ie(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(Ha(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){Qi(n,"updatedAt",e,t,0),Q(n,"clientId",e,t)}function Bn(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 Ht(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"),ie(s,`${e}.state`,t),s.children!==void 0&&X(s.children,`${e}.state.children`,t,(o,a,l)=>Ht(o,a,l,r+1)))}function Fu(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"),ie(r,e,t),r.children!==void 0&&X(r.children,`${e}.children`,t,(i,s,o)=>Ht(i,s,o)))}function es(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),Q(r,"pluginId",e,t),Q(r,"pluginData",e,t,!0),r.attributes!==void 0&&Bn(r.attributes,`${e}.attributes`,t),ie(r,e,t))}function Da(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&&it(r.clipShapeIds,`${e}.clipShapeIds`,t),r.clipShapeId!==void 0&&Q(r,"clipShapeId",e,t),r.clipShapeIds===void 0&&r.clipShapeId===void 0&&z(t,`${e}.clipShapeIds`,"or clipShapeId is required"),it(r.contentShapeIds,`${e}.contentShapeIds`,t),r.parentId!==null&&A(r.parentId,`${e}.parentId`,t),se(r,"siblingIndex",e,t),ie(r,e,t))}function Fa(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)'),oe(r.position,`${e}.position`,t),i&&oe(r.controlPointOffset,`${e}.controlPointOffset`,t),Q(r,"color",e,t,!0),Qi(r,"opacity",e,t),ie(r,e,t)}function Ea(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&&(oe(c.x,`${a}.x`,l),oe(c.y,`${a}.y`,l))}),$t(r.visible,`${e}.visible`,t),we(r.snapDivisions,`${e}.snapDivisions`,t,1)):s||z(t,e,"must be a current or legacy measurement payload"),Q(r,"color",e,t,!0),Qi(r,"opacity",e,t),ie(r,e,t)}var Oa=["title","description","author","keywords","license","licenseUrl","language","customMetadata","rawMetadata","rawDescription","rawHtmlMetadata","coordinatePrecision"];function La(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?Oa:Oa.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)&&it(i.keywords,`${e}.keywords`,t),(!r||i.customMetadata!==void 0)&&Bn(i.customMetadata,`${e}.customMetadata`,t),Q(i,"rawMetadata",e,t,!0),Q(i,"rawDescription",e,t,!0),Q(i,"rawHtmlMetadata",e,t,!0),se(i,"coordinatePrecision",e,t)}function Na(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),Q(r,"svgId",e,t,!0),Q(r,"href",e,t,!0),Nn(r,"async",e,t),Nn(r,"defer",e,t),r.customAttrs!==void 0&&Bn(r.customAttrs,`${e}.customAttrs`,t),ie(r,e,t))}function Ba(n,e,t){let r=U(n,e,t);r&&(A(r.id,`${e}.id`,t),A(r.css,`${e}.css`,t,!0),$t(r.preserved,`${e}.preserved`,t),Q(r,"svgId",e,t,!0),Q(r,"type",e,t,!0),Q(r,"media",e,t,!0),r.customAttrs!==void 0&&Bn(r.customAttrs,`${e}.customAttrs`,t),ie(r,e,t))}function za(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),Q(r,"label",e,t,!0),Q(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"')}ie(r,e,t)}}function Ga(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),ie(r,e,t))}function Eu(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),Q(r,"glyphName",e,t,!0),se(r,"advanceWidth",e,t),Q(r,"sourceFamily",e,t,!0),se(r,"sourceGlyphId",e,t),Q(r,"label",e,t,!0),ie(r,e,t))}function Va(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),oe(r.width,`${e}.width`,t,0),oe(r.height,`${e}.height`,t,0),ie(r,e,t))}function Ua(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),Nn(r,"passthrough",e,t),ie(r,e,t))}function Wa(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,Ht),r.groups!==void 0&&X(r.groups,`${e}.groups`,t,es)),i==="symbol"&&A(r.viewBox,`${e}.viewBox`,t,!0),i==="marker"){for(let s of["refX","refY","markerWidth","markerHeight"])oe(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)}),ie(r,e,t)}function Ou(n,e,t){let r=U(n,e,t);r&&(A(r.id,`${e}.id`,t),Q(r,"viewBox",e,t,!0),r.shapes!==void 0&&X(r.shapes,`${e}.shapes`,t,Ht),r.groups!==void 0&&X(r.groups,`${e}.groups`,t,es),ie(r,e,t))}function ja(n,e,t,r){let i=U(n,e,t);i&&((r||i.id!==void 0)&&A(i.id,`${e}.id`,t),oe(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),ie(i,e,t))}function Ka(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),$t(r.enabled,`${e}.enabled`,t),Nn(r,"locked",e,t),X(r.keyframes,`${e}.keyframes`,t,(i,s,o)=>ja(i,s,o,!1)),ie(r,e,t))}function Lu(n,e,t){let r=U(n,e,t);r&&(oe(r.duration,`${e}.duration`,t,0),$t(r.loop,`${e}.loop`,t),oe(r.playbackSpeed,`${e}.playbackSpeed`,t,0),X(r.tracks,`${e}.tracks`,t,Ka))}function Nu(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"),ie(r,e,t)}function Bu(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 Xa={"shape:add":(n,e,t)=>{I(n,e,["shape"],[],t),Ht(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),Fu(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))oe(s,`${e}.propTimestamps.${i}`,t,0)}Q(n,"clientId",e,t),n.textSplices!==void 0&&X(n.textSplices,`${e}.textSplices`,t,Bu),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,Nu),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),it(n.ids,`${e}.ids`,t)},"groups:set":(n,e,t)=>{I(n,e,["groups"],[],t),X(n.groups,`${e}.groups`,t,es)},"clipmasks:set":(n,e,t)=>{I(n,e,["clipMaskGroups"],[],t),X(n.clipMaskGroups,`${e}.clipMaskGroups`,t,Da)},"clipMask:upsert":(n,e,t)=>{I(n,e,["clipMaskGroup"],["index",...G],t),Da(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,Fa)},"guide:upsert":(n,e,t)=>{I(n,e,["guide"],["index",...G],t),Fa(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,Ea)},"measurement:upsert":(n,e,t)=>{I(n,e,["measurement"],["index",...G],t),Ea(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),La(n.metadata,`${e}.metadata`,t,!1)},"metadata:patch":(n,e,t)=>{I(n,e,["patch"],["removeKeys",...G],t),La(n.patch,`${e}.patch`,t,!0),n.removeKeys!==void 0&&it(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,Na)},"documentScript:upsert":(n,e,t)=>{I(n,e,["documentScript"],["index",...G],t),Na(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,Ba)},"documentStyle:upsert":(n,e,t)=>{I(n,e,["documentStyle"],["index",...G],t),Ba(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,za),V(n,e,t)},"templateVariable:upsert":(n,e,t)=>{I(n,e,["templateVariable"],["index",...G],t),za(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,Ga),V(n,e,t)},"exportItem:upsert":(n,e,t)=>{I(n,e,["exportItem"],["index",...G],t),Ga(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,Eu),ie(r,`${e}.colorGlyphLibrary`,t))}V(n,e,t)},"animation:set":(n,e,t)=>{I(n,e,["animationTimeline"],[],t),n.animationTimeline!==void 0&&Lu(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),oe(r.duration,`${e}.config.duration`,t,0),$t(r.loop,`${e}.config.loop`,t),oe(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),Ka(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),ja(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,Ou)},"customPatterns:set":(n,e,t)=>{I(n,e,["customPatterns"],[],t),X(n.customPatterns,`${e}.customPatterns`,t,Va)},"customPattern:upsert":(n,e,t)=>{I(n,e,["customPattern"],["index",...G],t),Va(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,Wa)},"library:upsert":(n,e,t)=>{I(n,e,["def"],["index",...G],t),Wa(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),it(n.rawPaintServerDefs,`${e}.rawPaintServerDefs`,t)},"paintServerDefs:set":(n,e,t)=>{I(n,e,["paintServerDefs"],[],t),X(n.paintServerDefs,`${e}.paintServerDefs`,t,Ua)},"paintServerDef:upsert":(n,e,t)=>{I(n,e,["paintServerDef"],["index",...G],t),Ua(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),oe(r.x,`${e}.position.x`,t),oe(r.y,`${e}.position.y`,t))},"presence:selection":(n,e,t)=>{I(n,e,["shapeIds"],[],t),it(n.shapeIds,`${e}.shapeIds`,t)}},zu=new Set(Object.keys(Xa)),Ya=new Set(["presence:cursor","presence:selection"]);function zn(n,e="operation"){let t=[],r=U(n,e,t);return r?!A(r.type,`${e}.type`,t)||!zu.has(r.type)?(typeof r.type=="string"&&r.type.length>0&&z(t,`${e}.type`,`unknown operation type "${r.type}"`),{valid:!1,issues:t}):(Xa[r.type](r,e,t),t.length===0?{valid:!0,value:r}:{valid:!1,issues:t}):{valid:!1,issues:t}}function qa(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=zn(o,`ops[${a}]`);if(!l.valid){t.push(...l.issues);return}if(Ya.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 Za(n){let e=zn(n,"op");return e.valid?Ya.has(e.value.type)?{valid:!0,value:e.value}:{valid:!1,issues:[{path:"op.type",message:"must be a presence operation"}]}:e}function Ja(n){return n.slice(0,5).map(({path:e,message:t})=>`${e} ${t}`).join("; ")}function Gn(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 Vn(n,e,t){return(n??[]).filter(r=>r[e]!==t)}function ge(n,e,t){return Gn(n,e,"id",t)}function ye(n,e){return Vn(n,"id",e)}function Un(n,e,t){return Gn(n,e,"name",t)}function Wn(n,e){return Vn(n,"name",e)}function Qa(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 eo(n,e){return n.slice(0,e.start)+e.insert+n.slice(e.start+e.deleteCount)}function jt(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 Kt=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}),vt=Object.keys(Kt);function Ge(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function ze(n){return typeof n=="string"?n:void 0}function le(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 Xe(n){return e=>typeof e=="string"&&n.includes(e)?e:void 0}function Gu(n){return n==="normal"||n==="bold"?n:le(n)}function Vu(n){return n==="baseline"||n==="super"||n==="sub"?n:le(n)}function no(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(!Ge(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 ro(n){if(!Ge(n))return;let e={};for(let[t,r]of Object.entries(n)){let i=le(r);i!==void 0&&(e[t]=i)}return e}var io={fontFamily:ze,fontSize:le,fontWeight:Gu,fontStyle:Xe(["normal","italic","oblique"]),fontVariant:ze,fontVariantLigatures:ze,fontVariantPosition:ze,fontVariantCaps:ze,fontVariantNumeric:ze,fontVariantEastAsian:ze,textTransform:Xe(["none","capitalize","uppercase","lowercase"]),baselineShift:Vu,dominantBaseline:Xe(["auto","alphabetic","central","middle","hanging","ideographic","mathematical","text-top","text-bottom"]),writingMode:Xe(["horizontal-tb","vertical-rl","vertical-lr"]),whiteSpace:Xe(["normal","nowrap","pre","pre-wrap","pre-line","break-spaces"]),direction:Xe(["ltr","rtl"]),unicodeBidi:Xe(["normal","embed","bidi-override","isolate","isolate-override","plaintext"]),textAnchor:Xe(["start","middle","end"]),letterSpacing:le,wordSpacing:le,lineHeight:le,fill:ze,fillOpacity:le,stroke:ze,strokeWidth:le,strokeOpacity:le};function Hn(n,e){return{...n,...e,textDecoration:{...n.textDecoration,...e.textDecoration??{}},fontVariationSettings:{...e.fontVariationSettings??n.fontVariationSettings}}}function ns(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 Xn(n,e){for(let t of vt)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(!ns(n.fontVariationSettings,e.fontVariationSettings))return!1}else if(n[t]!==e[t])return!1;return!0}function Yn(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(!ns(n.fontVariationSettings??{},e.fontVariationSettings??{}))return!1}else{let s=i;if(n[s]!==e[s])return!1}return!0}function jn(n,e){let t={};for(let i of vt)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),ns(n.fontVariationSettings,e.fontVariationSettings)||(t.fontVariationSettings={...n.fontVariationSettings}),t}function Me(n,e=Kt){let t=Ge(n)?n:{},r={...e};for(let i of vt){if(i==="textDecoration"||i==="fontVariationSettings")continue;let s=io[i](t[i]);s!==void 0&&(r[i]=s)}return r.textDecoration={...e.textDecoration,...no(t.textDecoration)??{}},r.fontVariationSettings={...ro(t.fontVariationSettings)??e.fontVariationSettings},r}function Xt(n){let e=Ge(n)?n:{},t={};for(let r of vt){if(r==="textDecoration"||r==="fontVariationSettings"||e[r]===void 0)continue;let i=io[r](e[r]);i!==void 0&&(t[r]=i)}if(e.textDecoration!==void 0){let r=no(e.textDecoration);r&&Object.keys(r).length>0&&(t.textDecoration=r)}if(e.fontVariationSettings!==void 0){let r=ro(e.fontVariationSettings);r&&(t.fontVariationSettings=r)}return t}function rs(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 Uu(n,e,t){return n.start===n.end?t&&n.start===e:n.start<=e&&e<n.end}function ts(n,e,t,r){let i=n;for(let s of e)Uu(s,t,r)&&(i=Hn(i,s.style));return i===n?Hn(n,{}):i}function so(n,e,t={}){let r=Me(n.baseStyle),i=typeof n.text=="string"?n.text:"";return ts(r,is(n.runs,i.length),e,t.collapsed===!0)}function st(n,e=Kt){let t=Ge(n)?n:{},r=Me(t.baseStyle,e),i=typeof t.text=="string"?t.text:"";return{text:i,runs:is(t.runs,i.length),baseStyle:r,lineHeight:le(t.lineHeight)??r.lineHeight}}function is(n,e){if(!Array.isArray(n))return[];let t=[];for(let r of n){if(!Ge(r))continue;let i=le(r.start),s=le(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:Xt(r.style)})}return t}function Ve(n){let e=typeof n.text=="string"?n.text:"",t=Me(n.baseStyle),r=is(n.runs,e.length),i=le(n.lineHeight)??t.lineHeight;return{lines:rs(e).map(o=>{if(o.text.length===0)return{segments:[{text:"",style:ts(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=ts(t,r,d,!1),h=c[c.length-1];h&&Xn(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 at(n){let e=Me(n?.baseStyle),t=le(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=Me(h?.style,e),$=jn(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=Me(p[0]?.style,e),g=jn(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
|
+
`)&&Yn(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 qn(n){let e=n.richTextRuns;if(Ge(e))return st(e);let t=n.richTextData;return Ge(t)&&Array.isArray(t.lines)&&t.lines.length>0?at(t):null}function Kn(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 Wu(n,e){if(n.start===n.end||e.start>=e.end||n.start<e.start||n.end>e.end)return!1;let t=Kn(e.style);for(let r of Kn(n.style))if(!t.has(r))return!1;return!0}function Yt(n,e){let t=[...n];for(let r of e)r.start>=r.end||Object.keys(r.style).length!==0&&(t=t.filter(i=>!Wu(i,r)),t.push({start:r.start,end:r.end,style:r.style}));return t}function Zn(n,e){if(!Array.isArray(n))return[];let t=[];for(let r of n){if(!Ge(r))continue;let i=le(r.start),s=le(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=Xt(r.style);Object.keys(l).length!==0&&t.push({start:o,end:a,style:l})}return t}function ao(n,e){let t=[];for(let r of n){let i=jt({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 to(n,e){return n.start===e.start&&n.end===e.end&&Yn(n.style,e.style)}function oo(n,e){if(n.text!==e.text||n.lineHeight!==e.lineHeight||!Xn(Me(n.baseStyle),Me(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(to(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=Yt(t,o);if(a.length!==r.length)return null;for(let l=0;l<a.length;l++)if(!to(a[l],r[l]))return null;return o.map(l=>({start:l.start,end:l.end,style:Xt(l.style)}))}function Hu(n,e){let t=e===0||n.charAt(e-1)===`
|
|
5
|
+
`,r=e===n.length||n.charAt(e)===`
|
|
6
|
+
`;return t&&r}function lo(n,e,t){let r=[];for(let i of n){let s=i.start===i.end,o=jt({start:i.start,deleteCount:i.end-i.start,insert:""},e),a=o.start,l=o.start+o.deleteCount;a===l&&(!s||!Hu(t,a))||r.push({start:a,end:l,style:i.style})}return r}function Ue(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 qt(n){if(n.builtIn)return!1;let e=n.pattern;return!e||typeof e!="object"?!1:e.patternType==="custom"&&typeof e.svgContent=="string"}function ss(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 kt(n){if(!qt(n))return null;let{width:e,height:t}=ss(n.pattern);return{id:n.id,name:n.name,svgContent:n.pattern.svgContent??"",width:e,height:t}}function Pe(n){let e=[...n].sort((i,s)=>i.index-s.index);if(!e.some(i=>i.orderKey))return e;let t=En(e.length),r=new Map;return e.forEach((i,s)=>{r.set(i.id,i.orderKey??t[s])}),e.sort((i,s)=>{let o=Vt(r.get(i.id)??"",r.get(s.id)??"");return o!==0?o:i.id<s.id?-1:i.id>s.id?1:0})}var ju=/^structural:(clip|mask):(.+):(group|path|content)$/;function uo(n,e){let t=`structural:${n}:${e}`;return{group:`${t}:group`,path:`${t}:path`,content:`${t}:content`}}function co(n,e){for(let t of n){e.add(t.id);let r=t.state.children;Array.isArray(r)&&co(r,e)}}function fo(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(...fo(s,r.id))}),t}function Jn(n){let e=n.sceneTree&&n.sceneTree.length>0?n.sceneTree:fo(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,Pe(x));let i=S=>ju.test(S),s=new Set(e.filter(S=>!i(S.id)).map(S=>S.id)),o=new Set;co(n.shapes,o);let a=new Map,l=new Set,c=(S,x)=>{let k=[];for(let w of r.get(S)??[]){if(!i(w.id)){l.has(w.id)||(l.add(w.id),k.push(w.id));continue}if(x.has(w.id))continue;let T=new Set(x);T.add(w.id),k.push(...c(w.id,T))}return k},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,k=x!==null&&s.has(x)?x:null,w=a.get(k)??[];w.push(S),a.set(k,w),l.add(S)}let d=S=>{for(let[x,k]of a){let w=k.indexOf(S);if(w>=0)return{parentId:x,index:w}}return null},p=S=>{for(let x of a.values()){let k=x.indexOf(S);k>=0&&x.splice(k,1)}},m=n.clipMaskGroups??[],h=new Map(m.map(S=>[uo(S.type,S.id).content,S])),g=(S,x=new Set)=>{if(x.has(S.id))return Number.MAX_SAFE_INTEGER;let k=S.parentId?h.get(S.parentId):void 0;if(!k)return 0;let w=new Set(x);return w.add(S.id),1+g(k,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)),k=S.contentShapeIds.filter(L=>o.has(L));if(k.length===0||x.length===0&&!S.rawDefinition)continue;let w=[...k,...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,...k])p(L);let M=uo(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,[...k]),$.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 v=[];for(let[S,x]of a)x.forEach((k,w)=>{let T=$.get(k);if(T){v.push({...T,parentId:S,index:w});return}let P=t.get(k);P&&P.parentId===S?v.push({...P,index:w}):v.push({id:k,parentId:S,index:w})});n.sceneTree=v}function $e(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function as(n){return $e(n)&&typeof n.updatedAt=="number"&&Number.isSafeInteger(n.updatedAt)&&n.updatedAt>=0&&typeof n.clientId=="string"}function ot(n,e){return{updatedAt:typeof n=="number"&&Number.isSafeInteger(n)&&n>=0?n:0,clientId:e??""}}function Zt(n,e){return as(e)?n.updatedAt>e.updatedAt||n.updatedAt===e.updatedAt&&n.clientId>=e.clientId:!0}function po(n){return $e(n.collaborationState)||(n.collaborationState={}),n.collaborationState}function mo(n,e){let t=po(n);$e(t.shapeProps)||(t.shapeProps={});let r=t.shapeProps;return $e(r[e])||(r[e]={}),r[e]}function Jt(n,e){let t=n.collaborationState?.shapeProps;if(!$e(t))return{};let r=t[e];return $e(r)?r:{}}function ho(n,e,t,r){if(t.length===0)return;let i=mo(n,e);for(let s of t)Zt(r,i[s])&&(i[s]=r)}function os(n,e){let t=n.collaborationState?.shapeProps;if($e(t)){for(let r of e)delete t[r];Ku(n)}}function Ku(n){let e=n.collaborationState;if($e(e)){for(let t of["shapeProps","resources"]){let r=e[t];$e(r)&&Object.keys(r).length===0&&delete e[t]}Object.keys(e).length===0&&delete n.collaborationState}}function ls(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 go(n,e,t){if(e.type==="shape:update"&&e.propTimestamps){if(!t)return null;let a=Jt(n,e.id),l={},c={},f=[];for(let[p,m]of Object.entries(e.state)){let h=ot(e.propTimestamps[p],e.clientId);Zt(h,a[p])&&(l[p]=m,c[p]=h.updatedAt,f.push([p,h]))}if(f.length===0)return null;let d=mo(n,e.id);for(let[p,m]of f)d[p]=m;return{...e,state:l,propTimestamps:c}}let r=ls(e);if(r===null||!("updatedAt"in e)||e.updatedAt===void 0)return e;let i=ot(e.updatedAt,e.clientId),s=po(n);$e(s.resources)||(s.resources={});let o=s.resources;return Zt(i,o[r])?(o[r]=i,{...e,updatedAt:i.updatedAt,clientId:i.clientId}):null}function yo(n){let e=0,t=n.collaborationState?.shapeProps;if($e(t)){for(let i of Object.values(t))if($e(i))for(let s of Object.values(i))as(s)&&(e=Math.max(e,s.updatedAt))}let r=n.collaborationState?.resources;if($e(r))for(let i of Object.values(r))as(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 bo(n,e){let t=Object.keys(e.state);if(t.length===0)return;let r=Jt(n,e.id),i=0;for(let o of t){let a=ot(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 lt(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=>kt(e)).filter(e=>e!==null))}function To(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(...To(s,r.id))}),t}function pe(n,e){if(n===e)return!0;let t=n??So,r=e??So;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 So=[];function Qt(n){return n.sceneTree&&n.sceneTree.length>0?n.sceneTree:To(n.shapes)}function Xu(n,e){let t=n,r=new Set(n.map(o=>o.id)),i=(o,a,l)=>{r.has(o.id)||(t=cs(t,{id:o.id,parentId:a,index:l}),r.add(o.id)),wt(o)?.forEach((f,d)=>i(f,o.id,d))},s=t.filter(o=>o.parentId===null).length;return i(e,null,s),t}function wo(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())Pe(r).forEach((i,s)=>t.push({...i,index:s}));return t}function en(n,e){let t=n.filter(l=>l.parentId===e);if(t.every(l=>l.orderKey))return n;let r=Pe(t),i=new Map,s=[],o=null,a=l=>{if(s.length===0)return;let c=Fn(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 cs(n,e){let t,r=[],i=[],s=!1;for(let l of n){if(l.id===e.id){if(t=l,!ds(e,t))return n;continue}l.parentId===e.parentId?(r.push(l),l.orderKey&&(s=!0)):i.push(l)}if(s){let l=en([...i,...r],e.parentId),c=Pe(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:bt(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 Qn(n,e,t){let r=n?[...n]:[],i=r.find(s=>s.id===e);return i?ge(r,i,t):r}function Yu(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 ps(n,e){let t=n.keyframes.findIndex(r=>r.id===e.id);t>=0?n.keyframes[t]=e:n.keyframes.push(e),Yu(n)}function ms(n,e){n.keyframes=n.keyframes.filter(t=>t.id!==e)}function xo(n,e){let t=n.animationTimeline?.tracks;return Array.isArray(t)?t.find(r=>r.id===e)??null:null}function ds(n,e){let t=n.updatedAt??0,r=e.updatedAt??0;return t!==r?t>r:(n.clientId??"")>=(e.clientId??"")}function wt(n){let e=n.state.children;return Array.isArray(e)?e:void 0}var us=new Set(["group","hyperlink","switch","container","svg"]);function Po(n,e,t,r){for(let i of n){t.set(i.id,e),r.set(i.id,i);let s=wt(i);s&&Po(s,i.id,t,r)}}function hs(n){let e=n.sceneTree;if(!e||e.length===0)return;let t=new Map,r=new Map;if(Po(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 Pe(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),us.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&&us.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(!us.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 qu(n){let e=`structural:${n.type}:${n.id}`;return{group:`${e}:group`,path:`${e}:path`,content:`${e}:content`}}function Tt(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=>Pe(i.get(o)??[]).map(a=>a.id).filter(a=>!a.startsWith("structural:"));n.clipMaskGroups=e.map(o=>{let a=qu(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($o(l,o.clipShapeIds)&&$o(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 $o(n,e){return!e||n.length!==e.length?!1:n.every((t,r)=>t===e[r])}function gs(n,e){e.add(n.id);let t=wt(n);if(t)for(let r of t)gs(r,e)}function fs(n,e){for(let t of n){e.set(t.id,t);let r=wt(t);r&&fs(r,e)}}var er=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,fs(this.snapshot.shapes,this.shapeIndex)),t=this.shapeIndex.get(e)??null):t=ct(this.snapshot.shapes,e),this.memoId=e,this.memoShape=t,t}noteShapesAdded(e){this.memoId=null,this.memoShape=null,this.shapeIndex!==null&&fs([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=wo(e))}this.inlineProjectionPending&&(this.inlineProjectionPending=!1,hs(this.snapshot))}};function ct(n,e){for(let t of n){if(t.id===e)return t;let r=wt(t);if(!r)continue;let i=ct(r,e);if(i)return i}return null}function ut(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function Zu(n){let e=n.richTextRuns;return!ut(e)||typeof e.text!="string"?null:st(e)}function Ju(n,e){let t=n.state;"extra"in t&&Ne(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 _o(n,e,t){let r=[];for(let i of n){if(i.id===e){gs(i,t);continue}let s=wt(i);if(s){let o=_o(s,e,t),a=i.state;o.length>0?a.children=o:delete a.children}r.push(i)}return r}function Ro(n,e){let t=n.snapshot,r=t,i=go(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=Qt(r),c=Wt(structuredClone(s.shape));r.shapes.push(c),r.sceneTree=Xu(l,c),n.noteShapesAdded(c),n.requestSceneTreeNormalize(),n.requestInlineProjection();let f=new Set;gs(c,f),os(t,f)}break}case"shape:update":{let a=n.findShape(s.id);if(!a)return null;Ju(a,s.state);break}case"text:format":{let a=n.findShape(s.id);if(!a)return null;let l=a.state;"extra"in l&&Ne(l);let c=Zu(l);if(!c)return null;let f=Zn(s.ranges,c.text.length);if(f.length===0)return null;let d={...c,runs:Yt(c.runs,f)};l.richTextRuns=d;let p=["richTextRuns"];if(ut(l.richTextData)&&(l.richTextData=Ve(d),p.push("richTextData")),s.updatedAt!==void 0){let m=ot(s.updatedAt,s.clientId),h=Jt(t,s.id);if(p.some(b=>!Zt(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}}ho(t,s.id,p,m)}break}case"shape:remove":{let a=new Set,l=_o(r.shapes,s.id,a),c=a.size>0;c||a.add(s.id);let f=Qt(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(),os(t,a),Tt(r);break}case"scene:move":{let a=Qt(r),l=a.find(d=>d.id===s.id),c=s.updatedAt===void 0?void 0:ot(s.updatedAt,s.clientId),f={id:s.id,parentId:s.parentId,index:s.index,updatedAt:c?.updatedAt,clientId:c?.clientId};if(l&&!ds(f,l))return null;r.sceneTree=cs(a,f),n.requestSceneTreeNormalize(),c&&(o={...s,...c}),n.requestInlineProjection(),Tt(r);break}case"scene:place":{if(!Gt(s.orderKey))return null;let a=Qt(r),l=a.find(p=>p.id===s.id),c=s.updatedAt===void 0?void 0:ot(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&&!ds(f,l))return null;let d=en(a,s.parentId);r.sceneTree=[...d.filter(p=>p.id!==s.id),f],n.requestSceneTreeNormalize(),n.requestInlineProjection(),Tt(r),c&&(o={...s,...c});break}case"shapes:reorder":{let a=Qt(r);s.ids.forEach((l,c)=>{a.some(f=>f.id===l&&f.parentId===null)&&(a=cs(a,{id:l,parentId:null,index:c}))}),r.sceneTree=a,n.requestSceneTreeNormalize(),n.requestInlineProjection(),Tt(r);break}case"groups:set":r.groups=s.groups;break;case"clipmasks:set":r.clipMaskGroups=s.clipMaskGroups,Jn(r);break;case"clipMask:upsert":r.clipMaskGroups=ge(r.clipMaskGroups,s.clipMaskGroup,s.index),Jn(r);break;case"clipMask:remove":{let a=ye(r.clipMaskGroups,s.id);if(pe(r.clipMaskGroups,a))return null;r.clipMaskGroups=a,Jn(r);break}case"guides:set":r.guides=s.guides;break;case"guide:upsert":r.guides=ge(r.guides,s.guide,s.index);break;case"guide:remove":{let a=ye(r.guides,s.id);if(pe(r.guides,a))return null;r.guides=a;break}case"guide:move":{let a=Qn(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=ge(r.measurements,s.measurement,s.index);break;case"measurement:remove":{let a=ye(r.measurements,s.id);if(pe(r.measurements,a))return null;r.measurements=a;break}case"measurement:move":{let a=Qn(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=ge(r.documentScripts,s.documentScript,s.index);break;case"documentScript:remove":{let a=ye(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=ge(r.documentStyles,s.documentStyle,s.index);break;case"documentStyle:remove":{let a=ye(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=Un(r.templateVariables,s.templateVariable,s.index);break;case"templateVariable:remove":{let a=Wn(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=ge(r.exportItems,s.exportItem,s.index);break;case"exportItem:remove":{let a=ye(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:ge(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=ye(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=xo(r,s.trackId);if(!a)return null;ps(a,structuredClone(s.keyframe));break}case"animationKeyframe:remove":{let a=xo(r,s.trackId);if(!a)return null;let l=a.keyframes;if(ms(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],lt(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"||!qt(c)));r.library=[...l,...s.customPatterns.map(c=>Ue(c))]}lt(r);break;case"customPattern:upsert":{r.customPatterns=ge(r.customPatterns,s.customPattern,s.index);let a=Ue(s.customPattern),l=[...r.library??[]],c=l.findIndex(f=>f.id===a.id);c>=0?l[c]=a:l.push(a),r.library=l,lt(r);break}case"customPattern:remove":{let a=ye(r.customPatterns,s.id),l=ye(r.library,s.id);if(pe(r.customPatterns,a)&&pe(r.library,l))return null;r.customPatterns=a,r.library=l,lt(r);break}case"library:set":r.library=s.library,lt(r);break;case"library:upsert":r.library=ge(r.library,s.def,s.index),lt(r);break;case"library:remove":{let a=ye(r.library,s.id);if(pe(r.library,a))return null;r.library=a,lt(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=ge(r.paintServerDefs,s.paintServerDef,s.index),r.rawPaintServerDefs=r.paintServerDefs.map(a=>a.markup);break;case"paintServerDef:remove":{let a=ye(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 Ao(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 vo(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=ct(n.shapes,e.id)?.state,s=i&&ut(Io(i,"richTextData"))?["richTextRuns","richTextData"]:["richTextRuns"];return vo(n,e.id,s)}return[]}function Io(n,e){if(e in n)return n[e];let t=n.extra;return ut(t)?t[e]:void 0}function Qu(n,e){if(e in n)return!0;let t=n.extra;return ut(t)&&e in t}function vo(n,e,t){if(t.length===0)return[];let r=ct(n.shapes,e);if(!r)return[];let i=r.state,s=Jt(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]=Qu(i,p)?structuredClone(Io(i,p)):null,d[p]=s[p].updatedAt;a.push({type:"shape:update",id:e,state:f,propTimestamps:d,clientId:l})}return a}function Mo(n,e){let t=new er(n,!1),r=Ro(t,e);return t.settle(),r}function ys(n,e){let t=new er(n,e.length>1),r=[];for(let i of e){let s=Ro(t,i);s&&r.push(s)}return t.settle(),r}function bs(n,e){let t=structuredClone(n);return{snapshot:t,acceptedOps:ys(t,e)}}function Co(n,e){return bs(n,e).snapshot}function Do(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=en(e,t);return wo(e)}function Fo(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 Eo(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 Oo(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=ct(e,r.id);if(!i)continue;let s=i.state.richTextRuns;if(!ut(s))continue;let o={richTextRuns:structuredClone(s)},a=i.state.richTextData;ut(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 Lo(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 No=6,ko=new Set(["templateVariables:set","templateVariable:upsert","templateVariable:remove","exportItems:set","exportItem:upsert","exportItem:remove","colorGlyphLibrary:set"]);function Bo(n){return n.some(e=>ko.has(e.type))?n.filter(e=>!ko.has(e.type)):n}var nn=Object.freeze([1,0,0,1,0,0]);function We(n,e,t,r,i,s){return[n,e,t,r,i,s]}function nr(n){return We(n[0]??1,n[1]??0,n[2]??0,n[3]??1,n[4]??0,n[5]??0)}function Ye(n){return[n[0],n[1],n[2],n[3],n[4],n[5]]}function _t(n){return Array.isArray(n)&&n.length>=6&&n.slice(0,6).every(Number.isFinite)}function xs(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 ec(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 ne(n,e){return We(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 tc(n){let e=n[0]*n[3]-n[2]*n[1];if(Math.abs(e)<1e-10)return null;let t=1/e;return We(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 nc(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 rc(n,e){return{x:n[0]*e.x+n[2]*e.y,y:n[1]*e.x+n[3]*e.y}}function _e(n,e=0){return We(1,0,0,1,n,e)}function rn(n,e=n){return We(n,0,0,e,0,0)}function Rt(n){let e=n*Math.PI/180,t=Math.cos(e),r=Math.sin(e);return We(t,r,-r,t,0,0)}function sn(n){return We(1,0,Math.tan(n*Math.PI/180),1,0,0)}function an(n){return We(1,Math.tan(n*Math.PI/180),0,1,0,0)}function $s(n,e){return ne(ne(_e(n.x,n.y),e),_e(-n.x,-n.y))}var ic=9,sc=10,ac=12,oc=13,lc=32,zo=43,uc=44,Go=45,cc=46,dc=48,fc=57,pc=40,mc=41,hc=69,gc=101,yc=0,bc=1,Uo=2,Sc=new Map([["matrix",[6]],["translate",[1,2]],["scale",[1,2]],["rotate",[1,3]],["skewX",[1]],["skewY",[1]]]);function xc(n){return n===lc||n===ic||n===sc||n===oc||n===ac}function tr(n){return n>=dc&&n<=fc}function $c(n){let e=n>=65&&n<=90,t=n>=97&&n<=122;return e||t||tr(n)}function Pt(n){for(;n.pos<n.src.length&&xc(n.src.charCodeAt(n.pos));)n.pos++}function Wo(n){let e=n.pos;return Pt(n),n.src.charCodeAt(n.pos)===uc?(n.pos++,Pt(n),Uo):n.pos>e?bc:yc}function Vo(n){let e=n.src,t=n.pos,r=t,i=e.charCodeAt(r);(i===zo||i===Go)&&r++;let s=!1;for(;r<e.length&&tr(e.charCodeAt(r));)r++,s=!0;if(e.charCodeAt(r)===cc){let l=r+1;for(;l<e.length&&tr(e.charCodeAt(l));)l++;l>r+1&&(r=l,s=!0)}if(!s)return null;let o=e.charCodeAt(r);if(o===gc||o===hc){let l=r+1,c=e.charCodeAt(l);(c===zo||c===Go)&&l++;let f=l;for(;f<e.length&&tr(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 vc(n,e){switch(n){case"matrix":return nr(e);case"translate":return _e(e[0],e[1]??0);case"scale":return rn(e[0],e[1]??e[0]);case"rotate":return e.length===3?$s({x:e[1],y:e[2]},Rt(e[0])):Rt(e[0]);case"skewX":return sn(e[0]);case"skewY":return an(e[0]);default:return null}}function kc(n){let e=n.src,t=n.pos;for(;n.pos<e.length&&$c(e.charCodeAt(n.pos));)n.pos++;if(n.pos===t)return null;let r=e.slice(t,n.pos),i=Sc.get(r);if(!i||(Pt(n),e.charCodeAt(n.pos)!==pc))return null;n.pos++,Pt(n);let s=i[i.length-1],o=Vo(n);if(o===null)return null;let a=[o];for(;;){let l=n.pos;Wo(n);let c=Vo(n);if(c===null){n.pos=l;break}if(a.push(c),a.length>s)return null}return Pt(n),e.charCodeAt(n.pos)!==mc||(n.pos++,!i.includes(a.length))?null:vc(r,a)}function Tc(n){let e={src:n,pos:0};if(Pt(e),e.pos>=n.length)return nn;let t=nn;for(;;){let r=kc(e);if(r===null)return null;t=ne(t,r);let i=Wo(e);if(e.pos>=n.length)return i===Uo?null:t}}var wc=2048,tn=new Map;function Ho(n){if(!n)return nn;let e=tn.get(n);if(e!==void 0)return e;let t=Tc(n),r=t===null?null:Object.freeze(t);if(tn.size>=wc){let i=tn.keys().next().value;i!==void 0&&tn.delete(i)}return tn.set(n,r),r}function rr(n){return Ho(n)??nn}function Pc(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 Ss(n){return!_t(n)||xs(n)?null:`matrix(${n[0]}, ${n[1]}, ${n[2]}, ${n[3]}, ${n[4]}, ${n[5]})`}function on(n,e){let t=n.translateX??0,r=n.translateY??0,i=typeof n.rawTransform=="string"?n.rawTransform:"",s=_e(t,r);if(i)return ne(s,rr(i));let o=n.rotation??0,a=n.skewX??0,l=n.skewY??0,c=n.scaleX??1,f=n.scaleY??1;if(o===0&&a===0&&l===0&&c===1&&f===1)return s;let d=n.customPivot??e;if(!d)return s;let p=ne(ne(ne(Rt(o),rn(c,f)),sn(a)),an(l));return ne(s,$s(d,p))}function At(n,e){let t=Ss(n.transformMatrix);return t||(Ss(Ye(on(n,e)))??null)}function vs(n,e){let t=n.ancestorTransform;if(!_t(t)){delete n.ancestorTransform;return}if(xs(t)){delete n.ancestorTransform;return}let r=_t(n.transformMatrix)?nr(n.transformMatrix):on(n,e);n.transformMatrix=Ye(ne(nr(t),r)),delete n.ancestorTransform}function ks(n,e,t){let r=At(n,{x:e,y:t});return r?`${r} translate(${e}, ${t})`:`translate(${e}, ${t})`}function Xo(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 ln(n){if(Array.isArray(n))for(let e of n){let t=e.state;vs(t,Xo(t));let r=e.state.children;ln(r)}}function _c(n){ln(n.shapes);for(let e of n.library??[])if(e.kind==="symbol"){ln(e.shapes);for(let t of Object.values(e.variants??{}))ln(t)}else e.kind==="marker"&&ln(e.shapes);return n.schemaVersion=3,n}function Ts(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 Rc(n,e){let t=n.translateX??0,r=n.translateY??0,i=typeof n.rawTransform=="string"?n.rawTransform:"",s=_e(t,r);if(i)return Ye(ne(s,rr(i)));let o=n.rotation??0,a=n.skewX??0,l=n.skewY??0;if(o!==0||a!==0||l!==0){let d=Ts(n.customPivot)??e??Ts(n.scaleAnchor);d&&(s=ne(s,_e(d.x,d.y)),o!==0&&(s=ne(s,Rt(o))),a!==0&&(s=ne(s,sn(a))),l!==0&&(s=ne(s,an(l))),s=ne(s,_e(-d.x,-d.y)))}let c=n.scaleX??1,f=n.scaleY??1;if(c!==1||f!==1){let d=Ts(n.scaleAnchor)??e;d&&(s=ne(s,_e(d.x,d.y)),s=ne(s,rn(c,f)),s=ne(s,_e(-d.x,-d.y)))}return Ye(s)}function un(n){if(Array.isArray(n))for(let e of n){let t=e.state;"scaleAnchor"in t&&(e.type==="text"&&!_t(t.transformMatrix)&&(t.transformMatrix=Rc(t,Xo(t))),delete t.scaleAnchor);let r=e.state.children;un(r)}}function Ac(n){un(n.shapes);for(let e of n.library??[])if(e.kind==="symbol"){un(e.shapes);for(let t of Object.values(e.variants??{}))un(t)}else e.kind==="marker"&&un(e.shapes);return n.schemaVersion=4,n}function Ic(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-${ir()}`: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:jo(l)}:{kind:"radial-gradient",id:g,name:l.sourceId??g,sourceId:l.sourceId,gradient:jo(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-${ir()}`:l.id;t.add(c),s.set(l.id,c),e.push(Ue(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-${ir()}`: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-${ir()}`: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 jo(n){let{id:e,sourceId:t,...r}=n;return r}var ws=0;function ir(){return ws=ws+1&65535,`${Date.now().toString(36)}-${ws.toString(36)}`}function Mc(n){let e=t=>{if(Array.isArray(t))for(let r of t)nt(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 Ko(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=at(t))}function Yo(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)Yo(i);let r=e.symbolOverrides;if(r&&typeof r=="object"&&!Array.isArray(r))for(let i of Object.values(r))Ko(i);Ko(e)}function Cc(n){let e=t=>{if(Array.isArray(t))for(let r of t)Yo(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 Ps=Object.freeze({1:Ic,2:_c,3:Ac,4:Mc,5:Cc});function Dc(n){let e=n.schemaVersion;return typeof e!="number"||!Number.isFinite(e)||e<1?1:Math.floor(e)}function sr(n,e=Ps){let t=JSON.parse(JSON.stringify(n)),r=Dc(t);if(r>xe)return t;if(r===xe)return t.schemaVersion=xe,t;for(;r<xe;){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 ${xe}.`);t=i(t),r+=1}return t.schemaVersion=xe,t}function dt(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}async function Rs(n,e,t,r){let i=n[e];typeof i=="string"&&(n[e]=await r(i,t))}async function _s(n,e){dt(n)&&await Rs(n,"svgContent","svgMarkup",e)}async function ar(n,e){if(!dt(n))return;await Rs(n,"href","href",e),await _s(n.fillGradient,e),await _s(n.strokeGradient,e);let t=n.children;if(Array.isArray(t))for(let r of t)dt(r)&&await ar(r.state,e)}async function qo(n,e){if(!dt(n))return;let t=n.shapes;if(Array.isArray(t))for(let s of t)dt(s)&&await ar(s.state,e);let r=n.library;if(Array.isArray(r))for(let s of r)dt(s)&&s.kind==="pattern"&&await _s(s.pattern,e);let i=n.customPatterns;if(Array.isArray(i))for(let s of i)dt(s)&&await Rs(s,"svgContent","svgMarkup",e)}var Fc=new Set(["circle","rectangle","square","ellipse","text","triangle","ngon","star","cross","ring","spiral","gear","arrow","line","path","polyline","image"]);function cn(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>xe&&t.push({path:"schemaVersion",message:`schemaVersion ${r.schemaVersion} is newer than supported (${xe})`,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)=>{Bc(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)=>{Vc(s,`viewboxes[${o}]`,e,t,i)})}if(r.guides!==void 0&&(Array.isArray(r.guides)?r.guides.forEach((i,s)=>{Uc(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)=>{Wc(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=Ec(r.shapes),s=new Set;r.sceneTree.forEach((o,a)=>{Oc(o,`sceneTree[${a}]`,e,t,i,s)})}if(r.clipMaskGroups!==void 0&&(Array.isArray(r.clipMaskGroups)?r.clipMaskGroups.forEach((i,s)=>{Hc(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)=>{Nc(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 Ec(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 Zo(n){return n.startsWith("structural:")}function Oc(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)&&!Zo(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)&&!Zo(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 Lc=new Set(["mask","clipPath","filter","linearGradient","radialGradient","pattern","symbol"]);function Nc(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"||!Lc.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 Bc(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"}):Fc.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"}):Gc(s.state,`${e}.state`,t,r)}var zc=/^\s*\{\{\s*[\w.\-]+\s*\}\}\s*$/;function Jo(n){return typeof n=="number"?isFinite(n):typeof n=="string"?zc.test(n):!1}function Gc(n,e,t,r){let i=["x","y","width","height","radius","rx","ry","fontSize"];for(let o of i)n[o]!==void 0&&!Jo(n[o])&&t.push({path:`${e}.${o}`,message:`${o} must be a finite number or a {{variable}} reference`,severity:"error"});for(let o of Nt){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}Jo(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 Vc(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 Uc(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 Wc(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 Hc(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 or(n={}){let e={schemaVersion:xe,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 Qo(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 dn(n,e,t,r,i){return{id:i??_(),x:n,y:e,width:t,height:r}}var jc=["schemaVersion","documentMetadata","documentScripts","documentStyles","templateVariables","viewboxes","guides","measurements","groups","sceneTree","clipMaskGroups","customPatterns","symbols","markers","library","colorGlyphLibrary","paintServerDefs","rawPaintServerDefs","animationTimeline","shapes"];function lr(n,e={}){let{indent:t=2,trailingNewline:r=!0,validate:i=!1}=e;if(i){let a=cn(n);if(!a.valid){let l=a.errors.map(c=>` ${c.path}: ${c.message}`).join(`
|
|
7
7
|
`);throw new Error(`Invalid document:
|
|
8
|
-
${
|
|
9
|
-
`:o}function
|
|
8
|
+
${l}`)}}let s={};for(let a of jc){let l=n[a];if(l!==void 0)switch(a){case"shapes":s[a]=l.map(c=>Xc(nt(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:Kc(l).map(ft);break;case"documentMetadata":s[a]=ft(l);break;case"animationTimeline":s[a]=ft(l);break;case"colorGlyphLibrary":s[a]=ft(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=sr(s)),t){let o=cn(s);if(!o.valid){let a=o.errors.map(l=>` ${l.path}: ${l.message}`).join(`
|
|
10
10
|
`);throw new Error(`Invalid .svgs document:
|
|
11
|
-
${a}`)}}return s}function cu(t){return[...t].sort((e,r)=>e.id.localeCompare(r.id))}function He(t){if(t==null)return t;if(Array.isArray(t))return t.map(He);if(typeof t!="object")return t;let e={},r=Object.keys(t).sort();for(let n of r)e[n]=He(t[n]);return e}function du(t){let e={};return e.id=t.id,e.type=t.type,e.state=He(t.state),e}var fe=/\{\{\s*([\w.\-]+)\s*\}\}/g;function Ir(t,e){return t.replace(fe,(r,n)=>{let i=e[n];return i!==void 0?String(i):r})}function Er(t,e={}){let r={};if(t.templateVariables)for(let i of t.templateVariables)i.defaultValue!==void 0&&i.defaultValue!==""&&(r[i.name]=i.defaultValue);if(Object.assign(r,e),Object.keys(r).length===0)return JSON.parse(JSON.stringify(t));let n=JSON.parse(JSON.stringify(t));for(let i of n.shapes)Dr(i.state,r);if(n.documentMetadata){let i=n.documentMetadata;Dr(i,r)}return n}function Dr(t,e){for(let r of Object.keys(t)){let n=t[r];if(typeof n=="string"){if(fe.lastIndex=0,fe.test(n)){fe.lastIndex=0;let i=Ir(n,e);if(fu(n)){let s=Number(i);if(!isNaN(s)&&pu(r)){t[r]=s;continue}}t[r]=i}}else if(Array.isArray(n))for(let i=0;i<n.length;i++)typeof n[i]=="string"?(fe.lastIndex=0,fe.test(n[i])&&(fe.lastIndex=0,n[i]=Ir(n[i],e))):n[i]!==null&&typeof n[i]=="object"&&Dr(n[i],e);else n!==null&&typeof n=="object"&&Dr(n,e)}}function fu(t){return/^\s*\{\{\s*[\w.\-]+\s*\}\}\s*$/.test(t)}var hu=new Set(["x","y","width","height","radius","rx","ry","cx","cy","x1","y1","x2","y2","fontSize","borderWidth","cornerRadius","opacity","fillOpacity","strokeOpacity",...mt,"letterSpacing","wordSpacing","lineHeight","sides","arms","innerRadiusPercent","armWidthPercent","teeth","toothDepthPercent","holeRadiusPercent","turns","thicknessPercent","direction","headWidthPercent","headLengthPercent","shaftWidthPercent","shiftAngle","dashLength","gapLength","textPathStartOffset","imageOpacity"]);function pu(t){return hu.has(t)}function Lr(t){let e=t.templateVariables??[],r=new Set(e.map(s=>s.name)),n=new Set;for(let s of t.shapes)Fr(s.state,n);t.documentMetadata&&Fr(t.documentMetadata,n);let i=[...n].filter(s=>!r.has(s)).sort();return{defined:[...e],undeclared:i}}function Fr(t,e){for(let r of Object.values(t))if(typeof r=="string"){let n;for(fe.lastIndex=0;(n=fe.exec(r))!==null;)e.add(n[1])}else if(Array.isArray(r))for(let n of r)if(typeof n=="string"){let i;for(fe.lastIndex=0;(i=fe.exec(n))!==null;)e.add(i[1])}else n!==null&&typeof n=="object"&&Fr(n,e);else r!==null&&typeof r=="object"&&Fr(r,e)}function Ra(t){let e={};for(let r of t){let n=r.indexOf("=");if(n===-1)throw new Error(`Invalid variable format: "${r}". Expected "name=value".`);let i=r.slice(0,n).trim(),s=r.slice(n+1);if(!i)throw new Error(`Invalid variable format: "${r}". Variable name cannot be empty.`);e[i]=s}return e}var Aa=3,Ma=12;function Ca(t){return t==null||!Number.isFinite(t)?3:t<0?0:t>12?12:Math.floor(t)}function Nr(t,e){if(!Number.isFinite(t))return t;let r=Math.pow(10,e);return Math.round(t*r)/r}var mu=/-?\d+(?:\.\d+)?(?:[eE][-+]?\d+)?/g;function zi(t,e){return t.replace(mu,r=>{let n=parseFloat(r);return Number.isFinite(n)?String(Nr(n,e)):r})}var gu=new Set(["rawTransform","strokeDasharray","filterX","filterY","filterWidth","filterHeight","cssClipPath"]),yu=new Set(["metadata","customMetadata","customAttrs","customData","bindings","richTextRuns","richTextData","cssMaskProperties","rawMetadata"]);function ye(t,e,r){if(e==null)return e;if(typeof e=="number")return Nr(e,r);if(typeof e=="string")return gu.has(t)?zi(e,r):e;if(typeof e=="boolean")return e;if(Array.isArray(e))return e.map(n=>ye(t,n,r));if(typeof e=="object"){if(yu.has(t))return e;if(t==="symbolOverrides"){let i={};for(let[s,o]of Object.entries(e))i[s]=ye("state",o,r);return i}let n={};for(let[i,s]of Object.entries(e))n[i]=ye(i,s,r);return n}return e}function Br(t,e){return{id:t.id,type:t.type,state:ye("state",t.state,e)}}function Ia(t,e){let r={...t,shapes:t.shapes.map(n=>Br(n,e)),viewboxes:t.viewboxes.map(n=>ye("viewbox",n,e))};return t.guides&&(r.guides=t.guides.map(n=>ye("guide",n,e))),t.measurements&&(r.measurements=t.measurements.map(n=>ye("measurement",n,e))),t.animationTimeline&&(r.animationTimeline=ye("animationTimeline",t.animationTimeline,e)),t.symbols&&(r.symbols=t.symbols.map(n=>({...n,shapes:n.shapes.map(i=>Br(i,e))}))),t.markers&&(r.markers=t.markers.map(n=>ye("marker",n,e))),t.customPatterns&&(r.customPatterns=t.customPatterns.map(n=>ye("customPattern",n,e))),r}function Gt(t,e,r=-90){let n=[],i=r*Math.PI/180;for(let s=0;s<t;s++){let o=i+s*2*Math.PI/t;n.push({x:e*Math.cos(o),y:e*Math.sin(o)})}return n}function zr(t,e,r,n=-90){let i=[],s=e*(r/100),o=n*Math.PI/180;for(let a=0;a<t*2;a++){let u=o+a*Math.PI/t,c=a%2===0?e:s;i.push({x:c*Math.cos(u),y:c*Math.sin(u)})}return i}function Gr(t,e,r=0){let n=t*(e/100)/2,i=[{x:-n,y:-t},{x:n,y:-t},{x:n,y:-n},{x:t,y:-n},{x:t,y:n},{x:n,y:n},{x:n,y:t},{x:-n,y:t},{x:-n,y:n},{x:-t,y:n},{x:-t,y:-n},{x:-n,y:-n}];if(r===0)return i;let s=Math.cos(r*Math.PI/180),o=Math.sin(r*Math.PI/180);return i.map(a=>({x:a.x*s-a.y*o,y:a.x*o+a.y*s}))}function Vr(t,e,r,n,i=-90){let o=t*2*(r/100),a=t*(e/100),u=a*(n/100),c=[{x:t,y:0},{x:t-o,y:-a/2},{x:t-o,y:-u/2},{x:-t,y:-u/2},{x:-t,y:u/2},{x:t-o,y:u/2},{x:t-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(h=>({x:h.x*f-h.y*d,y:h.x*d+h.y*f}))}function Ur(t,e,r,n,i=0){let s=t,o=s*(r/100),a=s*(n/100),u=a/2,c=e*Math.PI/180,f=Math.cos(c),d=Math.sin(c),h=Math.abs(f),p=Math.abs(d),g=Math.max(h,p)||1,m={x:f*(s/g),y:d*(s/g)},b={x:m.x+f*o,y:m.y+d*o},x=Math.min(a,s-u),S=-s+u+x,$=s-u-x,v={x:-s,y:-s},k={x:s,y:-s},P={x:s,y:s},T={x:-s,y:s},w;if(h>=p&&f>0){let B=Math.max(S,Math.min($,m.y)),E={x:s,y:B-u},C={x:s,y:B+u};w=[v,k,E,b,C,P,T]}else if(h>=p&&f<=0){let B=Math.max(S,Math.min($,m.y)),E={x:-s,y:B+u},C={x:-s,y:B-u};w=[v,k,P,T,E,b,C]}else if(d<0){let B=Math.max(S,Math.min($,m.x)),E={x:B-u,y:-s},C={x:B+u,y:-s};w=[v,E,b,C,k,P,T]}else{let B=Math.max(S,Math.min($,m.x)),E={x:B+u,y:s},C={x:B-u,y:s};w=[v,k,P,E,b,C,T]}if(i===0)return w;let R=Math.cos(i*Math.PI/180),F=Math.sin(i*Math.PI/180);return w.map(B=>({x:B.x*R-B.y*F,y:B.x*F+B.y*R}))}function Wr(t,e,r,n,i=0){let s=Math.max(2,Math.round(e)),o=t*(r/100),a=t*(n/100)/2,u=s+1,c=[];for(let m=0;m<u;m++){let b=m/(u-1),x=-t+b*2*t,S=0;m>0&&m<u-1&&(S=m%2===1?o:-o),c.push({x:S,y:x})}let f=[],d=[];for(let m=0;m<u;m++){if(m===0||m===u-1){f.push({...c[m]}),d.push({...c[m]});continue}let b=c[m-1],x=c[m],S=c[m+1],$=x.x-b.x,v=x.y-b.y,k=Math.hypot($,v)||1,P=$/k,T=v/k,w=S.x-x.x,R=S.y-x.y,F=Math.hypot(w,R)||1,B=w/F,E=R/F,C=(P+B)/2,L=(T+E)/2,G=Math.hypot(C,L),A,Y;G<1e-6?(A=-T,Y=P):(A=-L/G,Y=C/G),f.push({x:x.x-A*a,y:x.y-Y*a}),d.push({x:x.x+A*a,y:x.y+Y*a})}let h=[];h.push(f[0]);for(let m=1;m<u-1;m++)h.push(d[m]);h.push(f[u-1]);for(let m=u-2;m>=1;m--)h.push(f[m]);if(i===0)return h;let p=Math.cos(i*Math.PI/180),g=Math.sin(i*Math.PI/180);return h.map(m=>({x:m.x*p-m.y*g,y:m.x*g+m.y*p}))}function Hr(t,e,r,n=0){let i=t,s=Math.max(.3,Math.min(.9,e/100)),o=-i*(r/100),a={x:0,y:i},u={x:0,y:o},c={x:-i*s,y:i*.4},f={x:-i*s,y:-i},d={x:i*s,y:-i},h={x:i*s,y:i*.4},p=[a,c,f,u,d,h,a],g=n===0?p:(()=>{let k=Math.cos(n*Math.PI/180),P=Math.sin(n*Math.PI/180);return p.map(T=>({x:T.x*k-T.y*P,y:T.x*P+T.y*k}))})(),[m,b,x,S,$,v]=g;return`M ${m.x} ${m.y} C ${b.x} ${b.y} ${x.x} ${x.y} ${S.x} ${S.y} C ${$.x} ${$.y} ${v.x} ${v.y} ${m.x} ${m.y} Z`}function jr(t,e,r,n=0){let i=Math.max(3,Math.round(e)),s=Math.max(.3,Math.min(1,r/100)),o=t,a=o*1.7,u=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:-(u/2)*Math.sin(R)})}let f=.15,d=0;for(let T=0;T<i;T++){let w=c[T],R=c[(T+1)%i];d=Math.max(d,Math.hypot(R.x-w.x,R.y-w.y))}let h=d/(2*(1-f))+.001,p=Math.max(h,d*(.68+s*.35)),g=c.map(T=>{let w=T.y/(u/2);return p*(1-f*w)});function m(T){let w=c[T],R=c[(T+1)%i],F=g[T],B=g[(T+1)%i],E=R.x-w.x,C=R.y-w.y,L=Math.hypot(E,C)||1,G=(F*F-B*B+L*L)/(2*L),A=Math.sqrt(Math.max(0,F*F-G*G)),Y=w.x+G/L*E,j=w.y+G/L*C,U=-C/L,re=E/L,V={x:Y+U*A,y:j+re*A},N={x:Y-U*A,y:j-re*A};return V.x*V.x+V.y*V.y>N.x*N.x+N.y*N.y?V:N}let b=[];for(let T=0;T<i;T++)b.push(m(T));let x=14,S=[];for(let T=0;T<i;T++){let w=c[T],R=g[T],F=b[(T-1+i)%i],B=b[T],E=Math.atan2(F.y-w.y,F.x-w.x),L=Math.atan2(B.y-w.y,B.x-w.x)-E;L<=0&&(L+=2*Math.PI);let G=2*Math.PI-L,A=E+L/2,Y=E-G/2,j={x:w.x+R*Math.cos(A),y:w.y+R*Math.sin(A)},U={x:w.x+R*Math.cos(Y),y:w.y+R*Math.sin(Y)},V=j.x*j.x+j.y*j.y>U.x*U.x+U.y*U.y?L:-G;for(let N=0;N<x;N++){let te=N/x,ne=E+te*V;S.push({x:w.x+R*Math.cos(ne),y:w.y+R*Math.sin(ne)})}}let $=0;for(let T of S){let w=Math.max(Math.abs(T.x),Math.abs(T.y));w>$&&($=w)}if($>0&&$!==o){let T=o/$;for(let w of S)w.x*=T,w.y*=T}let v=T=>{if(n===0)return T;let w=Math.cos(n*Math.PI/180),R=Math.sin(n*Math.PI/180);return{x:T.x*w-T.y*R,y:T.x*R+T.y*w}},k=S.map(v),P=`M ${k[0].x} ${k[0].y}`;for(let T=1;T<k.length;T++)P+=` L ${k[T].x} ${k[T].y}`;return P+=" Z",P}function he(t,e=0,r=0){if(t.length<3)return"";if(e<=0)return t.map((s,o)=>(o===0?"M":"L")+`${s.x},${s.y}`).join(" ")+" Z";let n=Math.min(e,r*.4),i="";for(let s=0;s<t.length;s++){let o=t[(s-1+t.length)%t.length],a=t[s],u=t[(s+1)%t.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:u.x-a.x,y:u.y-a.y},h=Math.hypot(d.x,d.y);d.x/=h,d.y/=h;let p=Math.min(n,f/2),g=Math.min(n,h/2),m={x:a.x+c.x*p,y:a.y+c.y*p},b={x:a.x+d.x*g,y:a.y+d.y*g};i+=s===0?`M${m.x},${m.y}`:` L${m.x},${m.y}`,i+=` Q${a.x},${a.y} ${b.x},${b.y}`}return i+" Z"}function Xr(t,e,r="evenodd"){let n=t*(e/100),i=r==="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 ${n} 0 A ${n} ${n} 0 1 ${i} ${-n} 0 A ${n} ${n} 0 1 ${i} ${n} 0 Z`}function Kr(t,e,r,n=1,i=0){let s=t*(r/100),a=Math.round(e*36),u=e*2*Math.PI,c=(t-s/2)/u,f=i*Math.PI/180,d=[],h=[];for(let m=0;m<=a;m++){let b=m/a,x=b*u*n+f,S=c*(b*u)+s/2,$=s/2;d.push({x:(S+$*.3)*Math.cos(x),y:(S+$*.3)*Math.sin(x)}),h.push({x:Math.max(0,S-$*.3)*Math.cos(x),y:Math.max(0,S-$*.3)*Math.sin(x)})}let p=`M ${d[0].x} ${d[0].y}`;for(let m=1;m<d.length;m++)p+=` L ${d[m].x} ${d[m].y}`;let g=h[h.length-1];p+=` L ${g.x} ${g.y}`;for(let m=h.length-2;m>=0;m--)p+=` L ${h[m].x} ${h[m].y}`;return p+=" Z",p}var bu=.2;function Ui(t,e,r,n=0){let i=e*(r/100),s=e,o=e-i,a=2*Math.PI/t,u=a*bu/2,c=a/4,f=n*Math.PI/180,d=[];for(let h=0;h<t;h++){let p=f+h*a;d.push({x:o*Math.cos(p),y:o*Math.sin(p)}),d.push({x:s*Math.cos(p+c-u),y:s*Math.sin(p+c-u)}),d.push({x:s*Math.cos(p+c+u),y:s*Math.sin(p+c+u)}),d.push({x:o*Math.cos(p+a/2),y:o*Math.sin(p+a/2)})}return d}function Yr(t,e,r,n=0,i=0,s="evenodd",o=0){let a=Ui(t,e,r,o),u=Math.min(n,e*.1),c=he(a,u,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 qr(t,e,r,n,i,s="round",o="uniform",a){let u=Math.min(r,n)/2,c,f,d,h,p,g,m,b;if(o==="non-uniform"&&a?(c=Math.min(a.radiusTL??i,u),f=Math.min(a.radiusTR??i,u),d=Math.min(a.radiusBR??i,u),h=Math.min(a.radiusBL??i,u),p=a.shapeTL??s,g=a.shapeTR??s,m=a.shapeBR??s,b=a.shapeBL??s):(c=f=d=h=Math.min(i,u),p=g=m=b=s),!(s!=="round"||o==="non-uniform"||c>0&&p!=="round"||f>0&&g!=="round"||d>0&&m!=="round"||h>0&&b!=="round")&&c===f&&f===d&&d===h)return null;let S=`M${t+c},${e}`;return S+=` L${t+r-f},${e}`,S+=Or(g,f,t+r,e,"tr"),S+=` L${t+r},${e+n-d}`,S+=Or(m,d,t+r,e+n,"br"),S+=` L${t+h},${e+n}`,S+=Or(b,h,t,e+n,"bl"),S+=` L${t},${e+c}`,S+=Or(p,c,t,e,"tl"),S+=" Z",S}function Or(t,e,r,n,i){if(e<=0)return"";switch(t){case"round":switch(i){case"tr":return` A${e},${e} 0 0 1 ${r},${n+e}`;case"br":return` A${e},${e} 0 0 1 ${r-e},${n}`;case"bl":return` A${e},${e} 0 0 1 ${r},${n-e}`;case"tl":return` A${e},${e} 0 0 1 ${r+e},${n}`}break;case"scoop":switch(i){case"tr":return` A${e},${e} 0 0 0 ${r},${n+e}`;case"br":return` A${e},${e} 0 0 0 ${r-e},${n}`;case"bl":return` A${e},${e} 0 0 0 ${r},${n-e}`;case"tl":return` A${e},${e} 0 0 0 ${r+e},${n}`}break;case"bevel":switch(i){case"tr":return` L${r},${n+e}`;case"br":return` L${r-e},${n}`;case"bl":return` L${r},${n-e}`;case"tl":return` L${r+e},${n}`}break;case"notch":switch(i){case"tr":return` L${r-e},${n+e} L${r},${n+e}`;case"br":return` L${r-e},${n-e} L${r-e},${n}`;case"bl":return` L${r+e},${n-e} L${r},${n-e}`;case"tl":return` L${r+e},${n+e} L${r+e},${n}`}break}return""}function Zr(t,e,r,n,i,s={}){let o=e+n/2,a=r+i/2;switch(t){case"diamond":return`M${o},${r} L${e+n},${a} L${o},${r+i} L${e},${a} Z`;case"parallelogram":{let u=(s.slantPercent??20)/100*n;return`M${e+u},${r} L${e+n},${r} L${e+n-u},${r+i} L${e},${r+i} Z`}case"trapezoid":{let u=(s.topWidthPercent??70)/100*n,c=(n-u)/2;return`M${e+c},${r} L${e+c+u},${r} L${e+n},${r+i} L${e},${r+i} Z`}case"terminator":{let u=i/2;return`M${e+u},${r} L${e+n-u},${r} A${u},${u} 0 0 1 ${e+n-u},${r+i} L${e+u},${r+i} A${u},${u} 0 0 1 ${e+u},${r} Z`}case"cylinder":{let u=n/2,c=Math.min((s.capHeightPercent??15)/100*i,i/2);return`M${e},${r+c} A${u},${c} 0 0 1 ${e+n},${r+c} A${u},${c} 0 0 1 ${e},${r+c} L${e},${r+i-c} A${u},${c} 0 0 0 ${e+n},${r+i-c} L${e+n},${r+c} M${o-u},${r+c} A${u},${c} 0 0 0 ${o+u},${r+c}`}case"document-shape":{let u=(s.waveAmplitudePercent??15)/100*i;return`M${e},${r} L${e+n},${r} L${e+n},${r+i} C${e+n*.75},${r+i-u*2} ${o+n*.25},${r+i+u} ${o},${r+i} C${o-n*.25},${r+i-u} ${e+n*.25},${r+i+u*.5} ${e},${r+i} Z`}}}function Fe(t,e,r=!1,n=.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 vu(t,r,n);case"BASIS":case"basis":return Tu(t,r);case"ARC":case"arc":return i&&i.length>0?xu(t,r,i):zt(t,r,"CUBIC");case"LINEAR":case"linear":return zt(t,r,"LINEAR");case"QUADRATIC":case"quadratic":return zt(t,r,"QUADRATIC");case"CUBIC":case"cubic":return zt(t,r,"CUBIC");default:return zt(t,r)}}function xu(t,e,r){let n=`M ${t[0].x} ${t[0].y}`,i=0,s={rx:50,ry:50,rotation:0,largeArc:!1,sweep:!0};for(let o=0;o<t.length-1;o++){let a=t[o+1];if(a.isSubpathStart){if(e&&o-i>=1){let c=t[i],f=r?.[o]??s;n+=` A ${f.rx} ${f.ry} ${f.rotation} ${f.largeArc?1:0} ${f.sweep?1:0} ${c.x} ${c.y} Z`}n+=` M ${a.x} ${a.y}`,i=o+1;continue}let u=r?.[o]??s;n+=` A ${u.rx} ${u.ry} ${u.rotation} ${u.largeArc?1:0} ${u.sweep?1:0} ${a.x} ${a.y}`}if(e&&t.length-i>1){let o=t[i],a=r?.[t.length-1]??s;n+=` A ${a.rx} ${a.ry} ${a.rotation} ${a.largeArc?1:0} ${a.sweep?1:0} ${o.x} ${o.y} Z`}return n}function zt(t,e,r){let n=`M ${t[0].x} ${t[0].y}`,i=0,s=null,o=null;for(let a=0;a<t.length-1;a++){let u=t[a],c=t[a+1];if(c.isSubpathStart){if(e&&a-i>=1){let d=t[i];n+=Gi(u,d,d.segmentType,s,o,r),n+=" Z"}n+=` M ${c.x} ${c.y}`,i=a+1,s=null,o=null;continue}n+=Gi(u,c,c.segmentType,s,o,r);let f=$u(c.segmentType??r,u,c);s=f,f==="quad"?o=u.handleOut??null:o=null}if(e&&t.length-i>1){let a=t[t.length-1],u=t[i],c=(u.segmentType??r??(a.handleOut||u.handleIn?"CUBIC":"LINEAR")).toUpperCase();c==="LINEAR"||c==="HORIZONTAL"||c==="VERTICAL"||(n+=Gi(a,u,u.segmentType,s,o,r)),n+=" Z"}return n}var Su=.001;function ot(t,e){return Math.abs(t-e)<Su}function $u(t,e,r){let n=(t??(e.handleOut||r.handleIn?"CUBIC":"LINEAR")).toUpperCase();return n==="CUBIC"||n==="SMOOTH_CUBIC"?"cubic":n==="QUADRATIC"||n==="SMOOTH_QUADRATIC"?"quad":null}function Gi(t,e,r,n,i,s){let o=(r??s??(t.handleOut||e.handleIn?"CUBIC":"LINEAR")).toUpperCase();if(o==="LINEAR"||o==="HORIZONTAL"||o==="VERTICAL")return(o==="HORIZONTAL"||o==="LINEAR")&&ot(t.y,e.y)?` H ${e.x}`:(o==="VERTICAL"||o==="LINEAR")&&ot(t.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=t.handleOut??{x:(t.x+e.x)/2,y:(t.y+e.y)/2};return n==="quad"&&i&&ot(c.x,2*t.x-i.x)&&ot(c.y,2*t.y-i.y)?` T ${e.x} ${e.y}`:` Q ${c.x} ${c.y} ${e.x} ${e.y}`}let a=t.handleOut??{x:t.x,y:t.y},u=e.handleIn??{x:e.x,y:e.y};return n==="cubic"&&t.handleIn&&t.handleOut&&ot(t.handleOut.x,2*t.x-t.handleIn.x)&&ot(t.handleOut.y,2*t.y-t.handleIn.y)?` S ${u.x} ${u.y} ${e.x} ${e.y}`:` C ${a.x} ${a.y} ${u.x} ${u.y} ${e.x} ${e.y}`}function vu(t,e,r){if(t.length<2)return t.length===1?`M ${t[0].x} ${t[0].y}`:"";let n=r,i=e?[t[t.length-1],...t,t[0],t[1]]:[t[0],...t,t[t.length-1]],s=`M ${t[0].x} ${t[0].y}`,o=e?t.length:t.length-1;for(let a=0;a<o;a++){let u=i[a],c=i[a+1],f=i[a+2],d=i[a+3],h=Math.hypot(f.x-c.x,f.y-c.y),p=Math.hypot(c.x-u.x,c.y-u.y),g=Math.hypot(d.x-f.x,d.y-f.y),m=Math.pow(p,n),b=Math.pow(h,n),x=Math.pow(g,n),S=Math.pow(p,2*n),$=Math.pow(h,2*n),v=Math.pow(g,2*n),k,P,T,w;p<1e-8?(k=c.x,P=c.y):(k=(S*f.x-$*u.x+(2*S+3*m*b+$)*c.x)/(3*m*(m+b)),P=(S*f.y-$*u.y+(2*S+3*m*b+$)*c.y)/(3*m*(m+b))),g<1e-8?(T=f.x,w=f.y):(T=(v*c.x-$*d.x+(2*v+3*x*b+$)*f.x)/(3*x*(x+b)),w=(v*c.y-$*d.y+(2*v+3*x*b+$)*f.y)/(3*x*(x+b))),s+=` C ${k} ${P} ${T} ${w} ${f.x} ${f.y}`}return e&&(s+=" Z"),s}function Tu(t,e){let r=t.length;if(r<2)return r===1?`M ${t[0].x} ${t[0].y}`:"";if(r===2)return`M ${t[0].x} ${t[0].y} L ${t[1].x} ${t[1].y}`;if(e){let s=(t[0].x+4*t[1].x+t[2].x)/6,o=(t[0].y+4*t[1].y+t[2].y)/6,a=`M ${s} ${o}`;for(let u=0;u<r;u++){let c=t[(u+1)%r],f=t[(u+2)%r],d=t[(u+3)%r];a+=Vi(c,f,d)}return a+=" Z",a}let n=t,i=`M ${n[0].x} ${n[0].y}`;i+=` L ${(5*n[0].x+n[1].x)/6} ${(5*n[0].y+n[1].y)/6}`;for(let s=0;s<=r-3;s++)i+=Vi(n[s],n[s+1],n[s+2]);return i+=Vi(n[r-2],n[r-1],n[r-1]),i+=` L ${n[r-1].x} ${n[r-1].y}`,i}function Vi(t,e,r){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+r.x)/6} ${(t.y+4*e.y+r.y)/6}`}function lt(t,e,r){let n=Number.isFinite(e)?Math.max(1,e):8,i=Number.isFinite(r)?Math.max(1,r):4;switch(t){case"dashed":case"dotted":case"custom":return`${n} ${i}`;default:return null}}var ku=[["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 W(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function wu(t){let e=t.fillType;return e||(t.fillGradient?t.fillGradient.r!==void 0?"radial-gradient":"linear-gradient":t.linearGradient?"linear-gradient":t.radialGradient?"radial-gradient":"solid")}function Qr(t){let e=new Map,r=t.state,n=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 v=r.rx??r.cornerRadius??0,k=r.ry??r.cornerRadius??0;(v>0||k>0)&&(e.set("rx",String(v)),e.set("ry",String(k)))}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",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));{let v=ku.map(([k,P])=>{let T=typeof r[k]=="string"?String(r[k]).trim():"";return T?`${P}: ${T}`:""}).filter(Boolean).join("; ");v&&e.set("style",v)}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)),n.href&&e.set("href",String(n.href));break}let i=wu(n);i==="none"?e.set("fill","none"):i==="linear-gradient"||i==="radial-gradient"?e.set("fill",`url(#gradient-fill-${t.id})`):i==="pattern"?e.set("fill",`url(#pattern-fill-${t.id})`):e.set("fill",r.fillColor??"#000000");let s=r.opacity;s!==void 0&&s<1&&e.set("opacity",String(s));let o=r.fillOpacity;o!==void 0&&o<1&&e.set("fill-opacity",String(o)),r.fillRule&&r.fillRule!=="nonzero"&&e.set("fill-rule",r.fillRule);let a=n.strokeType??"solid";if(a==="none")e.set("stroke","none");else if(a==="linear-gradient"||a==="radial-gradient")e.set("stroke",`url(#gradient-stroke-${t.id})`);else{let v=r.borderColor??"none";v!=="none"&&e.set("stroke",v)}let u=r.borderWidth;u!=null&&u!==0&&e.set("stroke-width",String(u));let c=r.strokeOpacity;c!==void 0&&c<1&&e.set("stroke-opacity",String(c));let f=r.lineStyle??"solid",d=r.dashLength??8,h=r.gapLength??4,p=lt(f,d,h);p&&(e.set("stroke-dasharray",p),f==="dotted"&&e.set("stroke-linecap","round"));let g=Pu(n);g&&e.set("transform",g);let m=n.filters;m&&m.length>0&&e.set("filter",`url(#filter-${t.id})`);let b=r.shapeRendering;b&&b!=="auto"&&e.set("shape-rendering",b),r.pathLength!==void 0&&e.set("pathLength",String(r.pathLength));let x=n.startEndpoint,S=n.endEndpoint;x&&x!=="none"&&e.set("marker-start",`url(#line-marker-${x})`),S&&S!=="none"&&e.set("marker-end",`url(#line-marker-${S})`);let $=n.metadata;return $&&($.role&&e.set("role",$.role),$.ariaLabel&&e.set("aria-label",$.ariaLabel)),e}function Da(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 Pu(t){return at(t)}function be(t,e){let r=t.viewboxes?.[0];return{width:e.width??r?.width??800,height:e.height??r?.height??600}}function l(t,e){return e==null||e===""?"":` ${t}="${W(String(e))}"`}function en(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 _u(t,e,r){let{offsetX:n,offsetY:i,blurRadius:s,spread:o,color:a,opacity:u}=t,c="";if(o===0)c+=`<feDropShadow${l("in",e)}${l("dx",n)}${l("dy",i)}${l("stdDeviation",s/2)}${l("flood-color",a)}${l("flood-opacity",u)}${l("result",`${r}_shadow`)}/>`,c+=`<feMerge${l("result",r)}><feMergeNode${l("in",`${r}_shadow`)}/><feMergeNode${l("in",e)}/></feMerge>`;else{c+=`<feColorMatrix${l("in",e)}${l("type","matrix")}${l("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0")}${l("result",`${r}_alpha`)}/>`;let f=o>0?"dilate":"erode",d=Math.abs(o);c+=`<feMorphology${l("in",`${r}_alpha`)}${l("operator",f)}${l("radius",d)}${l("result",`${r}_spread`)}/>`,c+=`<feGaussianBlur${l("in",`${r}_spread`)}${l("stdDeviation",s/2)}${l("result",`${r}_blur`)}/>`,c+=`<feOffset${l("in",`${r}_blur`)}${l("dx",n)}${l("dy",i)}${l("result",`${r}_offset`)}/>`,c+=`<feFlood${l("flood-color",a)}${l("flood-opacity",u)}${l("result",`${r}_color`)}/>`,c+=`<feComposite${l("in",`${r}_color`)}${l("in2",`${r}_offset`)}${l("operator","in")}${l("result",`${r}_shadow`)}/>`,c+=`<feMerge${l("result",r)}><feMergeNode${l("in",`${r}_shadow`)}/><feMergeNode${l("in",e)}/></feMerge>`}return c}function Ru(t,e,r){let{offsetX:n,offsetY:i,blurRadius:s,choke:o,color:a,opacity:u}=t,c=s*(1-o/100),f="";return f+=`<feColorMatrix${l("in",e)}${l("type","matrix")}${l("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0")}${l("result",`${r}_alpha`)}/>`,f+=`<feComponentTransfer${l("in",`${r}_alpha`)}${l("result",`${r}_inverted`)}><feFuncA${l("type","table")}${l("tableValues","1 0")}/></feComponentTransfer>`,f+=`<feGaussianBlur${l("in",`${r}_inverted`)}${l("stdDeviation",c/2)}${l("result",`${r}_blur`)}/>`,f+=`<feOffset${l("in",`${r}_blur`)}${l("dx",n)}${l("dy",i)}${l("result",`${r}_offset`)}/>`,f+=`<feFlood${l("flood-color",a)}${l("flood-opacity",u)}${l("result",`${r}_color`)}/>`,f+=`<feComposite${l("in",`${r}_color`)}${l("in2",`${r}_offset`)}${l("operator","in")}${l("result",`${r}_coloredShadow`)}/>`,f+=`<feComposite${l("in",`${r}_coloredShadow`)}${l("in2",`${r}_alpha`)}${l("operator","in")}${l("result",`${r}_innerShadow`)}/>`,f+=`<feComposite${l("in",`${r}_innerShadow`)}${l("in2",e)}${l("operator","over")}${l("result",r)}/>`,f}function Au(t,e,r){let{blurX:n,blurY:i}=t;return n===0&&i===0?O(e,r):`<feGaussianBlur${l("in",e)}${l("stdDeviation",`${n/2} ${i/2}`)}${l("result",r)}/>`}function Mu(t,e,r){let{distance:n,angle:i}=t;if(n===0)return O(e,r);let s=i*Math.PI/180,o=Math.abs(Math.cos(s)*n),a=Math.abs(Math.sin(s)*n);return`<feGaussianBlur${l("in",e)}${l("stdDeviation",`${o/2} ${a/2}`)}${l("result",r)}/>`}function Fa(t,e,r){let{x:n,y:i,z:s,color:o,surfaceScale:a,diffuseConstant:u,specularConstant:c,specularExponent:f}=t,d="";return d+=`<feDiffuseLighting${l("in","SourceAlpha")}${l("surfaceScale",a)}${l("diffuseConstant",u)}${l("lighting-color",o)}${l("result",`${r}_diffuse`)}>`,d+=`<fePointLight${l("x",n)}${l("y",i)}${l("z",s)}/>`,d+="</feDiffuseLighting>",d+=`<feSpecularLighting${l("in","SourceAlpha")}${l("surfaceScale",a)}${l("specularConstant",c)}${l("specularExponent",f)}${l("lighting-color",o)}${l("result",`${r}_specular`)}>`,d+=`<fePointLight${l("x",n)}${l("y",i)}${l("z",s)}/>`,d+="</feSpecularLighting>",d+=`<feComposite${l("in",e)}${l("in2",`${r}_diffuse`)}${l("operator","arithmetic")}${l("k1",1)}${l("k2",0)}${l("k3",0)}${l("k4",0)}${l("result",`${r}_lit`)}/>`,d+=`<feComposite${l("in",`${r}_specular`)}${l("in2",`${r}_lit`)}${l("operator","arithmetic")}${l("k1",0)}${l("k2",1)}${l("k3",1)}${l("k4",0)}${l("result",r)}/>`,d}function Ea(t,e,r){let{x:n,y:i,z:s,pointsAtX:o,pointsAtY:a,pointsAtZ:u,coneAngle:c,color:f,surfaceScale:d,specularConstant:h,specularExponent:p}=t,g="";return g+=`<feSpecularLighting${l("in","SourceAlpha")}${l("surfaceScale",d)}${l("specularConstant",h)}${l("specularExponent",p)}${l("lighting-color",f)}${l("result",`${r}_specular`)}>`,g+=`<feSpotLight${l("x",n)}${l("y",i)}${l("z",s)}${l("pointsAtX",o)}${l("pointsAtY",a)}${l("pointsAtZ",u)}${l("limitingConeAngle",c)}/>`,g+="</feSpecularLighting>",g+=`<feComposite${l("in",`${r}_specular`)}${l("in2","SourceAlpha")}${l("operator","in")}${l("result",`${r}_clipped`)}/>`,g+=`<feComposite${l("in",`${r}_clipped`)}${l("in2",e)}${l("operator","arithmetic")}${l("k1",0)}${l("k2",1)}${l("k3",1)}${l("k4",0)}${l("result",r)}/>`,g}function La(t){switch(t.kind){case"point":return`<fePointLight${l("x",t.x)}${l("y",t.y)}${l("z",t.z)}/>`;case"spot":{let e=`<feSpotLight${l("x",t.x)}${l("y",t.y)}${l("z",t.z)}${l("pointsAtX",t.pointsAtX)}${l("pointsAtY",t.pointsAtY)}${l("pointsAtZ",t.pointsAtZ)}`;return t.limitingConeAngle!==void 0&&(e+=l("limitingConeAngle",t.limitingConeAngle)),t.specularExponent!==void 0&&(e+=l("specularExponent",t.specularExponent)),e+"/>"}case"distant":return`<feDistantLight${l("azimuth",t.azimuth)}${l("elevation",t.elevation)}/>`}}function Cu(t,e,r){return`<feDiffuseLighting${l("in",e)}${l("surfaceScale",t.surfaceScale)}${l("diffuseConstant",t.diffuseConstant)}${l("lighting-color",t.color)}${l("result",r)}>`+La(t.lightSource)+"</feDiffuseLighting>"}function Iu(t,e,r){return`<feSpecularLighting${l("in",e)}${l("surfaceScale",t.surfaceScale)}${l("specularConstant",t.specularConstant)}${l("specularExponent",t.specularExponent)}${l("lighting-color",t.color)}${l("result",r)}>`+La(t.lightSource)+"</feSpecularLighting>"}function Du(t,e,r){let{width:n,color:i,opacity:s,position:o}=t,a="";if(o==="inside")a+=`<feMorphology${l("in","SourceAlpha")}${l("operator","erode")}${l("radius",n)}${l("result",`${r}_eroded`)}/>`,a+=`<feComposite${l("in","SourceAlpha")}${l("in2",`${r}_eroded`)}${l("operator","out")}${l("result",`${r}_outlineAlpha`)}/>`,a+=`<feFlood${l("flood-color",i)}${l("flood-opacity",s)}${l("result",`${r}_color`)}/>`,a+=`<feComposite${l("in",`${r}_color`)}${l("in2",`${r}_outlineAlpha`)}${l("operator","in")}${l("result",`${r}_outline`)}/>`,a+=`<feComposite${l("in",`${r}_outline`)}${l("in2",e)}${l("operator","over")}${l("result",r)}/>`;else{let u=o==="outside"?n:n/2;a+=`<feMorphology${l("in","SourceAlpha")}${l("operator","dilate")}${l("radius",u)}${l("result",`${r}_dilated`)}/>`,a+=`<feComposite${l("in",`${r}_dilated`)}${l("in2","SourceAlpha")}${l("operator","out")}${l("result",`${r}_outlineAlpha`)}/>`,a+=`<feFlood${l("flood-color",i)}${l("flood-opacity",s)}${l("result",`${r}_color`)}/>`,a+=`<feComposite${l("in",`${r}_color`)}${l("in2",`${r}_outlineAlpha`)}${l("operator","in")}${l("result",`${r}_outline`)}/>`,a+=`<feMerge${l("result",r)}><feMergeNode${l("in",`${r}_outline`)}/><feMergeNode${l("in",e)}/></feMerge>`}return a}function Fu(t,e,r){let{amount:n}=t;if(n===0)return O(e,r);let i=1+4*n,s=-n,o=[0,s,0,s,i,s,0,s,0].join(" ");return`<feConvolveMatrix${l("in",e)}${l("order","3")}${l("kernelMatrix",o)}${l("divisor","1")}${l("bias","0")}${l("preserveAlpha","true")}${l("edgeMode","duplicate")}${l("result",r)}/>`}function Eu(t,e,r){let{blockSize:n}=t;if(n<=1)return O(e,r);let i=n/2,s="";return s+=`<feMorphology${l("in",e)}${l("operator","erode")}${l("radius",i)}${l("result",`${r}_eroded`)}/>`,s+=`<feMorphology${l("in",`${r}_eroded`)}${l("operator","dilate")}${l("radius",i)}${l("result",r)}/>`,s}function Lu(t,e,r){let{scale:n,frequency:i,octaves:s,warpType:o}=t;if(n===0)return O(e,r);let a="";return a+=`<feTurbulence${l("type",o)}${l("baseFrequency",i)}${l("numOctaves",s)}${l("seed",0)}${l("result",`${r}_turbulence`)}/>`,a+=`<feDisplacementMap${l("in",e)}${l("in2",`${r}_turbulence`)}${l("scale",n)}${l("xChannelSelector","R")}${l("yChannelSelector","G")}${l("result",r)}/>`,a}function Bu(t,e,r){let{operator:n,radiusX:i,radiusY:s}=t;return i===0&&s===0?O(e,r):`<feMorphology${l("in",e)}${l("operator",n)}${l("radius",`${i} ${s}`)}${l("result",r)}/>`}function Nu(t,e,r){let{levels:n}=t;if(n<2)return O(e,r);let i=[];for(let a=0;a<n;a++)i.push(a/(n-1));let s=i.join(" "),o=`<feComponentTransfer${l("in",e)}${l("result",r)}>`;return o+=`<feFuncR${l("type","discrete")}${l("tableValues",s)}/>`,o+=`<feFuncG${l("type","discrete")}${l("tableValues",s)}/>`,o+=`<feFuncB${l("type","discrete")}${l("tableValues",s)}/>`,o+="</feComponentTransfer>",o}function Ou(t,e,r){let{levels:n,contrast:i}=t;if(n<2)return O(e,r);let s=[];for(let u=0;u<n;u++){let c=u/(n-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${l("in",e)}${l("result",r)}>`;return a+=`<feFuncR${l("type","table")}${l("tableValues",o)}/>`,a+=`<feFuncG${l("type","table")}${l("tableValues",o)}/>`,a+=`<feFuncB${l("type","table")}${l("tableValues",o)}/>`,a+="</feComponentTransfer>",a}function zu(t,e,r){let{radius:n}=t;if(n===0)return O(e,r);let i="";return i+=`<feGaussianBlur${l("in","SourceAlpha")}${l("stdDeviation",n)}${l("result",`${r}_blurredAlpha`)}/>`,i+=`<feComponentTransfer${l("in",`${r}_blurredAlpha`)}${l("result",`${r}_thresholdAlpha`)}><feFuncA${l("type","linear")}${l("slope",20)}${l("intercept",-9)}/></feComponentTransfer>`,i+=`<feComposite${l("in",e)}${l("in2",`${r}_thresholdAlpha`)}${l("operator","in")}${l("result",r)}/>`,i}function Gu(t,e,r){let{amount:n}=t;if(n===0)return O(e,r);let i=1-n;return`<feColorMatrix${l("color-interpolation-filters","sRGB")}${l("in",e)}${l("type","saturate")}${l("values",i)}${l("result",r)}/>`}function Vu(t,e,r){let{red:n,green:i,blue:s}=t;if(n===1&&i===1&&s===1)return O(e,r);let o=`<feComponentTransfer${l("in",e)}${l("result",r)}>`;return o+=`<feFuncR${l("type","linear")}${l("slope",n)}${l("intercept",0)}/>`,o+=`<feFuncG${l("type","linear")}${l("slope",i)}${l("intercept",0)}/>`,o+=`<feFuncB${l("type","linear")}${l("slope",s)}${l("intercept",0)}/>`,o+="</feComponentTransfer>",o}function Uu(t,e,r){let{amount:n}=t;if(n===1)return O(e,r);let i=`<feComponentTransfer${l("color-interpolation-filters","sRGB")}${l("in",e)}${l("result",r)}>`;return i+=`<feFuncR${l("type","linear")}${l("slope",n)}${l("intercept",0)}/>`,i+=`<feFuncG${l("type","linear")}${l("slope",n)}${l("intercept",0)}/>`,i+=`<feFuncB${l("type","linear")}${l("slope",n)}${l("intercept",0)}/>`,i+="</feComponentTransfer>",i}function Wu(t,e,r){let{amount:n}=t;if(n===1)return O(e,r);let i=.5*(1-n),s=`<feComponentTransfer${l("color-interpolation-filters","sRGB")}${l("in",e)}${l("result",r)}>`;return s+=`<feFuncR${l("type","linear")}${l("slope",n)}${l("intercept",i)}/>`,s+=`<feFuncG${l("type","linear")}${l("slope",n)}${l("intercept",i)}/>`,s+=`<feFuncB${l("type","linear")}${l("slope",n)}${l("intercept",i)}/>`,s+="</feComponentTransfer>",s}function Hu(t,e,r){let{amount:n}=t;if(n===1)return O(e,r);let i=`<feComponentTransfer${l("color-interpolation-filters","sRGB")}${l("in",e)}${l("result",r)}>`;return i+=`<feFuncA${l("type","linear")}${l("slope",n)}${l("intercept",0)}/>`,i+="</feComponentTransfer>",i}function ju(t,e,r){let{amount:n}=t;if(n===0)return O(e,r);let i=n,s=1-n,o=`${i} ${s}`,a=`<feComponentTransfer${l("color-interpolation-filters","sRGB")}${l("in",e)}${l("result",r)}>`;return a+=`<feFuncR${l("type","table")}${l("tableValues",o)}/>`,a+=`<feFuncG${l("type","table")}${l("tableValues",o)}/>`,a+=`<feFuncB${l("type","table")}${l("tableValues",o)}/>`,a+="</feComponentTransfer>",a}function Xu(t,e,r){let{angle:n}=t;return n===0||n===360?O(e,r):`<feColorMatrix${l("color-interpolation-filters","sRGB")}${l("in",e)}${l("type","hueRotate")}${l("values",n)}${l("result",r)}/>`}function Ku(t,e,r){let{amount:n}=t;return n===1?O(e,r):`<feColorMatrix${l("color-interpolation-filters","sRGB")}${l("in",e)}${l("type","saturate")}${l("values",n)}${l("result",r)}/>`}function Yu(t,e,r){let{threshold:n}=t,i="";if(i+=`<feColorMatrix${l("in",e)}${l("type","saturate")}${l("values",0)}${l("result",`${r}_gray`)}/>`,n===.5)i+=`<feComponentTransfer${l("in",`${r}_gray`)}${l("result",r)}>`,i+=`<feFuncR${l("type","discrete")}${l("tableValues","0 1")}/>`,i+=`<feFuncG${l("type","discrete")}${l("tableValues","0 1")}/>`,i+=`<feFuncB${l("type","discrete")}${l("tableValues","0 1")}/>`,i+="</feComponentTransfer>";else{let o=[];for(let u=0;u<256;u++)o.push(u/255<n?0:1);let a=o.join(" ");i+=`<feComponentTransfer${l("in",`${r}_gray`)}${l("result",r)}>`,i+=`<feFuncR${l("type","table")}${l("tableValues",a)}/>`,i+=`<feFuncG${l("type","table")}${l("tableValues",a)}/>`,i+=`<feFuncB${l("type","table")}${l("tableValues",a)}/>`,i+="</feComponentTransfer>"}return i}function qu(t,e,r){let{amount:n}=t;if(n===0)return O(e,r);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],u=[0,1,0,0,0],c=[0,0,1,0,0],f=(m,b)=>m.map((x,S)=>x*(1-n)+b[S]*n),d=f(a,i),h=f(u,s),p=f(c,o),g=[...d,...h,...p,0,0,0,1,0].join(" ");return`<feColorMatrix${l("color-interpolation-filters","sRGB")}${l("in",e)}${l("type","matrix")}${l("values",g)}${l("result",r)}/>`}function Zu(t,e,r){let{shadowColor:n,highlightColor:i}=t,s=en(n),o=en(i),a="";return a+=`<feColorMatrix${l("in",e)}${l("type","saturate")}${l("values",0)}${l("result",`${r}_gray`)}/>`,a+=`<feComponentTransfer${l("in",`${r}_gray`)}${l("result",r)}>`,a+=`<feFuncR${l("type","table")}${l("tableValues",`${s.r} ${o.r}`)}/>`,a+=`<feFuncG${l("type","table")}${l("tableValues",`${s.g} ${o.g}`)}/>`,a+=`<feFuncB${l("type","table")}${l("tableValues",`${s.b} ${o.b}`)}/>`,a+="</feComponentTransfer>",a}function Qu(t,e,r){let{intensity:n}=t;if(n===0)return O(e,r);let i="";i+=`<feComponentTransfer${l("in",e)}${l("result",`${r}_invert`)}>`,i+=`<feFuncR${l("type","table")}${l("tableValues","1 0")}/>`,i+=`<feFuncG${l("type","table")}${l("tableValues","1 0")}/>`,i+=`<feFuncB${l("type","table")}${l("tableValues","1 0")}/>`,i+="</feComponentTransfer>",i+=`<feColorMatrix${l("in",`${r}_invert`)}${l("type","saturate")}${l("values",0)}${l("result",`${r}_gray`)}/>`;let s=[.1,.1,.1,0,0],o=[.3,.4,.3,0,0],a=[.5,.5,.8,0,0],u=[1,0,0,0,0],c=[0,1,0,0,0],f=[0,0,1,0,0],d=(b,x)=>b.map((S,$)=>S*(1-n)+x[$]*n),h=d(u,s),p=d(c,o),g=d(f,a),m=[...h,...p,...g,0,0,0,1,0].join(" ");return i+=`<feColorMatrix${l("in",`${r}_gray`)}${l("type","matrix")}${l("values",m)}${l("result",r)}/>`,i}function Ju(t,e,r){let{amount:n,scale:i}=t;if(n===0)return O(e,r);let s=1/i,o="";return o+=`<feTurbulence${l("type","fractalNoise")}${l("baseFrequency",s)}${l("numOctaves",3)}${l("seed",0)}${l("result",`${r}_noise`)}/>`,o+=`<feColorMatrix${l("in",`${r}_noise`)}${l("type","saturate")}${l("values",0)}${l("result",`${r}_noiseGray`)}/>`,o+=`<feBlend${l("in",e)}${l("in2",`${r}_noiseGray`)}${l("mode","overlay")}${l("result",`${r}_blended`)}/>`,o+=`<feComposite${l("in",`${r}_blended`)}${l("in2",e)}${l("operator","arithmetic")}${l("k1",0)}${l("k2",n)}${l("k3",1-n)}${l("k4",0)}${l("result",`${r}_amt`)}/>`,o+=`<feComposite${l("in",`${r}_amt`)}${l("in2",e)}${l("operator","in")}${l("result",r)}/>`,o}function ec(t,e,r){let{strength:n,angle:i}=t;if(n===0)return O(e,r);let s=i*Math.PI/180,o=Math.cos(s),a=Math.sin(s),u=n,c=[-(u*(o+a)),-(u*a),u*(-o+a),-(u*o),1,u*o,u*(o-a),u*a,u*(o+a)].join(" ");return`<feConvolveMatrix${l("in",e)}${l("order","3 3")}${l("kernelMatrix",c)}${l("divisor",1)}${l("bias",.5)}${l("preserveAlpha","true")}${l("result",r)}/>`}function tc(t,e,r){let{amount:n,size:i}=t;if(n===0)return O(e,r);let s=.5/i,o="";return o+=`<feTurbulence${l("type","fractalNoise")}${l("baseFrequency",`${s} ${s}`)}${l("numOctaves",5)}${l("seed",0)}${l("stitchTiles","stitch")}${l("result",`${r}_grain`)}/>`,o+=`<feColorMatrix${l("in",`${r}_grain`)}${l("type","saturate")}${l("values",0)}${l("result",`${r}_grainGray`)}/>`,o+=`<feBlend${l("in",e)}${l("in2",`${r}_grainGray`)}${l("mode","soft-light")}${l("result",`${r}_blended`)}/>`,o+=`<feComposite${l("in",`${r}_blended`)}${l("in2",e)}${l("operator","arithmetic")}${l("k1",0)}${l("k2",n)}${l("k3",1-n)}${l("k4",0)}${l("result",`${r}_amt`)}/>`,o+=`<feComposite${l("in",`${r}_amt`)}${l("in2",e)}${l("operator","in")}${l("result",r)}/>`,o}function rc(t,e,r){let{wetness:n,turbulence:i}=t;if(n===0&&i===0)return O(e,r);let s="";return s+=`<feTurbulence${l("type","fractalNoise")}${l("baseFrequency",.02+i*.03)}${l("numOctaves",4)}${l("seed",42)}${l("result",`${r}_turb`)}/>`,s+=`<feDisplacementMap${l("in",e)}${l("in2",`${r}_turb`)}${l("scale",n*15)}${l("xChannelSelector","R")}${l("yChannelSelector","G")}${l("result",`${r}_disp`)}/>`,s+=`<feGaussianBlur${l("in",`${r}_disp`)}${l("stdDeviation",n*2)}${l("result",`${r}_blur`)}/>`,s+=`<feBlend${l("in",`${r}_blur`)}${l("in2",e)}${l("mode","multiply")}${l("result",r)}/>`,s}function nc(t,e,r){let{thickness:n,texture:i}=t;if(n===0&&i===0)return O(e,r);let s="";s+=`<feTurbulence${l("type","turbulence")}${l("baseFrequency",.03+i*.02)}${l("numOctaves",3)}${l("seed",1e3)}${l("result",`${r}_brush`)}/>`;let o=Math.max(3,8-Math.floor(n*5)),a=Array.from({length:o+1},(u,c)=>c/o).join(" ");s+=`<feComponentTransfer${l("in",e)}${l("result",`${r}_poster`)}>`;for(let u of["R","G","B"])s+=`<feFunc${u}${l("type","discrete")}${l("tableValues",a)}/>`;return s+="</feComponentTransfer>",s+=`<feDisplacementMap${l("in",`${r}_poster`)}${l("in2",`${r}_brush`)}${l("scale",i*4)}${l("xChannelSelector","R")}${l("yChannelSelector","G")}${l("result",`${r}_disp`)}/>`,s+=`<feMorphology${l("in",`${r}_disp`)}${l("operator","dilate")}${l("radius",n*.5)}${l("result",`${r}_thick`)}/>`,s+=`<feComposite${l("in",`${r}_thick`)}${l("in2",e)}${l("operator","in")}${l("result",r)}/>`,s}function ic(t,e,r){let{spread:n,edges:i}=t;if(n===0&&i===0)return O(e,r);let s="";return s+=`<feTurbulence${l("type","fractalNoise")}${l("baseFrequency",.01+i*.02)}${l("numOctaves",5)}${l("seed",1100)}${l("result",`${r}_ink`)}/>`,s+=`<feMorphology${l("in",e)}${l("operator","dilate")}${l("radius",n*3)}${l("result",`${r}_dilate`)}/>`,s+=`<feDisplacementMap${l("in",`${r}_dilate`)}${l("in2",`${r}_ink`)}${l("scale",i*10)}${l("xChannelSelector","R")}${l("yChannelSelector","G")}${l("result",`${r}_disp`)}/>`,s+=`<feGaussianBlur${l("in",`${r}_disp`)}${l("stdDeviation",n*.5)}${l("result",r)}/>`,s}function sc(t,e,r){let{wrinkles:n,shine:i}=t;if(n===0&&i===0)return O(e,r);let s="";return s+=`<feTurbulence${l("type","turbulence")}${l("baseFrequency",.02)}${l("numOctaves",4)}${l("seed",1200)}${l("result",`${r}_wrinkle`)}/>`,s+=`<feDisplacementMap${l("in",e)}${l("in2",`${r}_wrinkle`)}${l("scale",n*15)}${l("xChannelSelector","R")}${l("yChannelSelector","G")}${l("result",`${r}_disp`)}/>`,s+=`<feSpecularLighting${l("in",`${r}_wrinkle`)}${l("surfaceScale",n*2)}${l("specularConstant",i*1.5)}${l("specularExponent",20)}${l("result",`${r}_sheen`)}>`,s+=`<feDistantLight${l("azimuth",45)}${l("elevation",60)}/>`,s+="</feSpecularLighting>",s+=`<feBlend${l("in",`${r}_disp`)}${l("in2",`${r}_sheen`)}${l("mode","screen")}${l("result",`${r}_blend`)}/>`,s+=`<feComposite${l("in",`${r}_blend`)}${l("in2",e)}${l("operator","in")}${l("result",r)}/>`,s}function ac(t,e,r){let{density:n,size:i}=t;if(n===0)return O(e,r);let s="",o=1-n;s+=`<feTurbulence${l("type","turbulence")}${l("baseFrequency",.1/i)}${l("numOctaves",1)}${l("seed",1400)}${l("result",`${r}_hole`)}/>`,s+=`<feComponentTransfer${l("in",`${r}_hole`)}${l("result",`${r}_thresh`)}>`;for(let a of["R","G","B","A"])s+=`<feFunc${a}${l("type","linear")}${l("slope",10)}${l("intercept",-o*10+5)}/>`;s+="</feComponentTransfer>",s+=`<feComponentTransfer${l("in",`${r}_thresh`)}${l("result",`${r}_clamp`)}>`;for(let a of["R","G","B","A"])s+=`<feFunc${a}${l("type","table")}${l("tableValues","0 0 1 1")}/>`;return s+="</feComponentTransfer>",s+=`<feComposite${l("in",e)}${l("in2",`${r}_clamp`)}${l("operator","in")}${l("result",r)}/>`,s}function oc(t,e,r){let{color:n,radius:i,intensity:s}=t;if(s===0||i===0)return O(e,r);let{r:o,g:a,b:u}=en(n),c="";return c+=`<feColorMatrix${l("in",e)}${l("type","matrix")}${l("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0")}${l("result",`${r}_alpha`)}/>`,c+=`<feGaussianBlur${l("in",`${r}_alpha`)}${l("stdDeviation",i/2)}${l("result",`${r}_blur`)}/>`,c+=`<feColorMatrix${l("in",`${r}_blur`)}${l("type","matrix")}${l("values",`0 0 0 0 ${o} 0 0 0 0 ${a} 0 0 0 0 ${u} 0 0 0 ${s} 0`)}${l("result",`${r}_color`)}/>`,c+=`<feMerge${l("result",r)}><feMergeNode${l("in",`${r}_color`)}/><feMergeNode${l("in",e)}/></feMerge>`,c}function lc(t,e,r){let{color:n,radius:i,intensity:s}=t;if(s===0||i===0)return O(e,r);let{r:o,g:a,b:u}=en(n),c="";return c+=`<feColorMatrix${l("in",e)}${l("type","matrix")}${l("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0")}${l("result",`${r}_alpha`)}/>`,c+=`<feMorphology${l("in",`${r}_alpha`)}${l("operator","erode")}${l("radius",i/4)}${l("result",`${r}_erode`)}/>`,c+=`<feComposite${l("in",`${r}_alpha`)}${l("in2",`${r}_erode`)}${l("operator","out")}${l("result",`${r}_edge`)}/>`,c+=`<feGaussianBlur${l("in",`${r}_edge`)}${l("stdDeviation",i/3)}${l("result",`${r}_blur`)}/>`,c+=`<feColorMatrix${l("in",`${r}_blur`)}${l("type","matrix")}${l("values",`0 0 0 0 ${o} 0 0 0 0 ${a} 0 0 0 0 ${u} 0 0 0 ${s*2} 0`)}${l("result",`${r}_color`)}/>`,c+=`<feComposite${l("in",`${r}_color`)}${l("in2",`${r}_alpha`)}${l("operator","in")}${l("result",`${r}_clipped`)}/>`,c+=`<feComposite${l("in",`${r}_clipped`)}${l("in2",e)}${l("operator","over")}${l("result",r)}/>`,c}function O(t,e){return`<feMerge${l("result",e)}><feMergeNode${l("in",t)}/></feMerge>`}function tn(t){switch(t.type){case"feBlend":return uc(t);case"feColorMatrix":return cc(t);case"feComponentTransfer":return dc(t);case"feComposite":return fc(t);case"feConvolveMatrix":return hc(t);case"feDiffuseLighting":return pc(t);case"feSpecularLighting":return mc(t);case"feDisplacementMap":return gc(t);case"feDropShadow":return yc(t);case"feFlood":return bc(t);case"feGaussianBlur":return xc(t);case"feImage":return Sc(t);case"feMerge":return $c(t);case"feMorphology":return vc(t);case"feOffset":return Tc(t);case"feTile":return kc(t);case"feTurbulence":return wc(t)}}function Q(t){let e="";if(e+=l("in",t.in),e+=l("x",t.x),e+=l("y",t.y),e+=l("width",t.width),e+=l("height",t.height),e+=l("color-interpolation-filters",t.colorInterpolationFilters),e+=l("result",t.result),t.unknownAttrs){let r=Object.keys(t.unknownAttrs).sort();for(let n of r)e+=l(n,t.unknownAttrs[n])}return e}function J(t){return t.animations&&t.animations.length>0?t.animations.join(""):""}function uc(t){let e=`<feBlend${Q(t)}${l("in2",t.in2)}${l("mode",t.mode)}`;t.noComposite&&(e+=' no-composite="no-composite"');let r=J(t);return r?`${e}>${r}</feBlend>`:`${e}/>`}function cc(t){let e=`<feColorMatrix${Q(t)}${l("type",t.matrixType)}${l("values",t.values)}`,r=J(t);return r?`${e}>${r}</feColorMatrix>`:`${e}/>`}function Jr(t,e){if(!e)return"";let r=`feFunc${t}`;switch(e.type){case"identity":return`<${r} type="identity"/>`;case"table":case"discrete":return`<${r} type="${e.type}"${l("tableValues",e.tableValues.join(" "))}/>`;case"linear":return`<${r} type="linear"${l("slope",e.slope)}${l("intercept",e.intercept)}/>`;case"gamma":return`<${r} type="gamma"${l("amplitude",e.amplitude)}${l("exponent",e.exponent)}${l("offset",e.offset)}/>`}}function dc(t){let e="";return e+=Jr("R",t.funcR),e+=Jr("G",t.funcG),e+=Jr("B",t.funcB),e+=Jr("A",t.funcA),e+=J(t),`<feComponentTransfer${Q(t)}>${e}</feComponentTransfer>`}function fc(t){let e=`<feComposite${Q(t)}${l("in2",t.in2)}${l("operator",t.operator)}`;t.operator==="arithmetic"&&(e+=l("k1",t.k1),e+=l("k2",t.k2),e+=l("k3",t.k3),e+=l("k4",t.k4));let r=J(t);return r?`${e}>${r}</feComposite>`:`${e}/>`}function hc(t){let e=`<feConvolveMatrix${Q(t)}`;e+=l("order",t.order),e+=l("kernelMatrix",t.kernelMatrix),e+=l("divisor",t.divisor),e+=l("bias",t.bias),e+=l("targetX",t.targetX),e+=l("targetY",t.targetY),e+=l("edgeMode",t.edgeMode),e+=l("kernelUnitLength",t.kernelUnitLength),t.preserveAlpha!==void 0&&(e+=l("preserveAlpha",t.preserveAlpha?"true":"false"));let r=J(t);return r?`${e}>${r}</feConvolveMatrix>`:`${e}/>`}function Ba(t){switch(t.kind){case"feDistantLight":return`<feDistantLight${l("azimuth",t.azimuth)}${l("elevation",t.elevation)}/>`;case"fePointLight":return`<fePointLight${l("x",t.x)}${l("y",t.y)}${l("z",t.z)}/>`;case"feSpotLight":{let e=`<feSpotLight${l("x",t.x)}${l("y",t.y)}${l("z",t.z)}${l("pointsAtX",t.pointsAtX)}${l("pointsAtY",t.pointsAtY)}${l("pointsAtZ",t.pointsAtZ)}`;return e+=l("specularExponent",t.specularExponent),e+=l("limitingConeAngle",t.limitingConeAngle),e+"/>"}}}function pc(t){let e=`<feDiffuseLighting${Q(t)}`;e+=l("surfaceScale",t.surfaceScale),e+=l("diffuseConstant",t.diffuseConstant),e+=l("kernelUnitLength",t.kernelUnitLength),e+=l("lighting-color",t.lightingColor);let r="";return t.lightSource&&(r+=Ba(t.lightSource)),r+=J(t),`${e}>${r}</feDiffuseLighting>`}function mc(t){let e=`<feSpecularLighting${Q(t)}`;e+=l("surfaceScale",t.surfaceScale),e+=l("specularConstant",t.specularConstant),e+=l("specularExponent",t.specularExponent),e+=l("kernelUnitLength",t.kernelUnitLength),e+=l("lighting-color",t.lightingColor);let r="";return t.lightSource&&(r+=Ba(t.lightSource)),r+=J(t),`${e}>${r}</feSpecularLighting>`}function gc(t){let e=`<feDisplacementMap${Q(t)}`;e+=l("in2",t.in2),e+=l("scale",t.scale),e+=l("xChannelSelector",t.xChannelSelector),e+=l("yChannelSelector",t.yChannelSelector);let r=J(t);return r?`${e}>${r}</feDisplacementMap>`:`${e}/>`}function yc(t){let e=`<feDropShadow${Q(t)}`;e+=l("dx",t.dx),e+=l("dy",t.dy),e+=l("stdDeviation",t.stdDeviation),e+=l("flood-color",t.floodColor),e+=l("flood-opacity",t.floodOpacity);let r=J(t);return r?`${e}>${r}</feDropShadow>`:`${e}/>`}function bc(t){let e=`<feFlood${Q(t)}${l("flood-color",t.floodColor)}${l("flood-opacity",t.floodOpacity)}`,r=J(t);return r?`${e}>${r}</feFlood>`:`${e}/>`}function xc(t){let e=`<feGaussianBlur${Q(t)}${l("stdDeviation",t.stdDeviation)}${l("edgeMode",t.edgeMode)}`,r=J(t);return r?`${e}>${r}</feGaussianBlur>`:`${e}/>`}function Sc(t){let e=`<feImage${Q(t)}`;t.href!==void 0?e+=l("href",t.href):t.xlinkHref!==void 0&&(e+=l("xlink:href",t.xlinkHref)),e+=l("preserveAspectRatio",t.preserveAspectRatio),e+=l("crossorigin",t.crossorigin);let r=J(t);return r?`${e}>${r}</feImage>`:`${e}/>`}function $c(t){let e="";for(let r of t.nodes)e+=`<feMergeNode${l("in",r.in)}/>`;return e+=J(t),`<feMerge${Q(t)}>${e}</feMerge>`}function vc(t){let e=`<feMorphology${Q(t)}${l("operator",t.operator)}${l("radius",t.radius)}`,r=J(t);return r?`${e}>${r}</feMorphology>`:`${e}/>`}function Tc(t){let e=`<feOffset${Q(t)}${l("dx",t.dx)}${l("dy",t.dy)}`,r=J(t);return r?`${e}>${r}</feOffset>`:`${e}/>`}function kc(t){let e=`<feTile${Q(t)}`,r=J(t);return r?`${e}>${r}</feTile>`:`${e}/>`}function wc(t){let e=`<feTurbulence${Q(t)}`;e+=l("baseFrequency",t.baseFrequency),e+=l("numOctaves",t.numOctaves),e+=l("seed",t.seed),e+=l("stitchTiles",t.stitchTiles),e+=l("type",t.turbulenceType);let r=J(t);return r?`${e}>${r}</feTurbulence>`:`${e}/>`}function Wi(t,e){let r=`<filter${l("id",t)}`;r+=l("x",e.x),r+=l("y",e.y),r+=l("width",e.width),r+=l("height",e.height),r+=l("filterUnits",e.filterUnits),r+=l("primitiveUnits",e.primitiveUnits),e.filterColorInterpolation&&e.filterColorInterpolation!=="auto"&&(r+=l("color-interpolation-filters",e.filterColorInterpolation)),r+=l("flood-color",e.floodColor),r+=l("flood-opacity",e.floodOpacity),r+=l("lighting-color",e.lightingColor),r+=">",e.filterTitle&&(r+=`<title>${W(e.filterTitle)}</title>`),e.filterDescription&&(r+=`<desc>${W(e.filterDescription)}</desc>`);for(let n of e.primitives)r+=tn(n);if(e.filterAnimations)for(let n of e.filterAnimations)r+=n;return r+="</filter>",r}function Hi(t,e,r,n){switch(t.type){case"drop-shadow":return _u(t,e,r);case"inner-shadow":return Ru(t,e,r);case"gaussian-blur":return Au(t,e,r);case"motion-blur":return Mu(t,e,r);case"point-light":{let i=t;return Fa(n?{...i,x:i.x+n.x,y:i.y+n.y}:i,e,r)}case"spot-light":{let i=t;return Ea(n?{...i,x:i.x+n.x,y:i.y+n.y,pointsAtX:i.pointsAtX+n.x,pointsAtY:i.pointsAtY+n.y}:i,e,r)}case"diffuse-lighting":return Cu(t,e,r);case"specular-lighting":return Iu(t,e,r);case"outline":return Du(t,e,r);case"sharpen":return Fu(t,e,r);case"pixelate":return Eu(t,e,r);case"warp":return Lu(t,e,r);case"morphology":return Bu(t,e,r);case"contouring-discrete":return Nu(t,e,r);case"contouring-table":return Ou(t,e,r);case"round-edges":return zu(t,e,r);case"grayscale":return Gu(t,e,r);case"channel-painter":return Vu(t,e,r);case"brightness":return Uu(t,e,r);case"contrast":return Wu(t,e,r);case"opacity":return Hu(t,e,r);case"invert":return ju(t,e,r);case"hue-rotate":return Xu(t,e,r);case"saturate":return Ku(t,e,r);case"black-and-white":return Yu(t,e,r);case"sepia":return qu(t,e,r);case"duotone":return Zu(t,e,r);case"xray":return Qu(t,e,r);case"noise":return Ju(t,e,r);case"emboss":return ec(t,e,r);case"film-grain":return tc(t,e,r);case"watercolor":return rc(t,e,r);case"gouache":return nc(t,e,r);case"ink-blot":return ic(t,e,r);case"crumpled-plastic":return sc(t,e,r);case"riddled":return ac(t,e,r);case"glow":return oc(t,e,r);case"inner-glow":return lc(t,e,r);case"raw-svg":return t.svgContent;case"svg-primitive-chain":return t.primitives.map(tn).join("");default:return O(e,r)}}function Pc(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(r=>r.type==="feGaussianBlur"||r.type==="feDropShadow"||r.type==="feOffset"||r.type==="feMorphology"||r.type==="feDisplacementMap"||r.type==="feTurbulence"))}function ji(t,e,r={}){let n=e.filter(v=>v.enabled);if(n.length===0)return"";let i=r.colorInterpolation&&r.colorInterpolation!=="auto"?l("color-interpolation-filters",r.colorInterpolation):"",s=n.find(v=>v.type==="raw-svg");if(s){let v=r.colorInterpolation&&r.colorInterpolation!=="auto"?r.colorInterpolation:s.colorInterpolationFilters,k=r.filterUnits??s.filterUnits,P=r.primitiveUnits??s.primitiveUnits,T=r.x??s.x,w=r.y??s.y,R=r.width??s.width,F=r.height??s.height;return`<filter${l("id",t)}${l("x",T)}${l("y",w)}${l("width",R)}${l("height",F)}${l("filterUnits",k)}${l("primitiveUnits",P)}${l("color-interpolation-filters",v)}${l("flood-color",s.floodColor)}${l("flood-opacity",s.floodOpacity)}${l("lighting-color",s.lightingColor)}${l("display",s.display)}>${s.svgContent}</filter>`}let o=n.find(v=>v.type==="svg-primitive-chain");if(o){let v={...o,x:r.x??o.x,y:r.y??o.y,width:r.width??o.width,height:r.height??o.height,filterUnits:r.filterUnits??o.filterUnits,primitiveUnits:r.primitiveUnits??o.primitiveUnits,filterColorInterpolation:r.colorInterpolation&&r.colorInterpolation!=="auto"?r.colorInterpolation:o.filterColorInterpolation};return Wi(t,v)}let a=n.some(v=>v.type==="gaussian-blur"&&v.quality==="high"||v.type==="motion-blur"&&v.quality==="high"),u=Pc(n),c=u?a?"-200%":"-100%":"-10%",f=u?a?"500%":"300%":"120%",d="",h="SourceGraphic",p=0;for(let v of n){let k=`result${p++}`;d+=Hi(v,h,k),h=k}let g=r.filterUnits??"objectBoundingBox",m=r.primitiveUnits??"userSpaceOnUse",b=r.x??c,x=r.y??c,S=r.width??f,$=r.height??f;return`<filter${l("id",t)}${l("x",b)}${l("y",x)}${l("width",S)}${l("height",$)}${l("filterUnits",g)}${l("primitiveUnits",m)}${i}>${d}</filter>`}function Na(t){let e="",r=new Set;for(let n of t){let i=n.state.filters;if(!i||i.length===0)continue;let s=i.filter(c=>c.enabled);if(s.length===0)continue;let o=n.state.filterLibraryIds,a=Array.isArray(o)&&o.length>0?o[0]:`filter-${n.id}`;if(r.has(a))continue;r.add(a);let u=n.state;e+=ji(a,s,{colorInterpolation:u.filterColorInterpolation,filterUnits:u.filterUnits,primitiveUnits:u.primitiveUnits,x:u.filterX,y:u.filterY,width:u.filterWidth,height:u.filterHeight})}return e}function rn(t,e,r){return!e||e.length===0||e.filter(i=>i.enabled).length===0?"":Array.isArray(r)&&r.length>0?` filter="${r.map(s=>`url(#${W(s)})`).join(" ")}"`:` filter="url(#filter-${W(t)})"`}function _c(t){if(t instanceof Map)return t;let e=new Map;for(let r of t)e.set(r.id,r);return e}function Rc(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 r of Object.values(t.variants))e.push(...r);return e}function Oa(t,e,r,n){let i=_c(r),s=new Set,o=[],a=[],u=d=>{if(typeof d!="string"||!d||s.has(d))return;let h=i.get(d);h&&(h.kind!=="symbol"&&h.kind!=="marker"||(s.add(d),o.push(h)))},c=d=>{a.push(d)},f=d=>{let h=d.state;if(!h)return;u(h.symbolId),u(h.markerStart),u(h.markerMid),u(h.markerEnd);let p=h.children;if(Array.isArray(p))for(let m of p)c(m);let g=h.symbolOverrides;if(g&&typeof g=="object"&&!Array.isArray(g))for(let[m,b]of Object.entries(g))!b||typeof b!="object"||Array.isArray(b)||c({id:m,type:"symbol-override",state:b})};for(let d of t)c(d);for(let d of e)u(d);for(;;){let d=a.shift();if(d){n(d),f(d);continue}let h=o.shift();if(!h)break;for(let p of Rc(h))c(p)}}var Ac=[],Mc=[];function Ut(t,e,r){Oa(t,Mc,e,r)}function za(t,e,r){Oa(Ac,t,e,r)}function Ga(t,e){if(!t)return;let r=t,n=r.markerStart;typeof n=="string"&&n&&e(n);let i=r.markerMid;typeof i=="string"&&i&&e(i);let s=r.markerEnd;typeof s=="string"&&s&&e(s);let o=r.startEndpoint;typeof o=="string"&&o&&o!=="none"&&e(Vt(o));let a=r.endEndpoint;typeof a=="string"&&a&&a!=="none"&&e(Vt(a))}function Vt(t){return`line-marker-${t}`}function Va(t,e,r){if(!t)return;let n=t,i=o=>{typeof o=="string"&&o&&r(o)};i(n.fillLibraryId),i(n.strokeLibraryId),i(n.markerStart),i(n.markerMid),i(n.markerEnd),i(n.symbolId);let s=n.filterLibraryIds;if(Array.isArray(s)&&s.length>0)for(let o of s)i(o);else Array.isArray(n.filters)&&n.filters.length>0&&r(`filter-${e}`);n.fillLibraryId||i(n.fillGradient?.id),n.strokeLibraryId||i(n.strokeGradient?.id)}function Wt(t,e=[]){let r=new Set,n=new Set;return Ut(t,e,i=>{let s=i.state;if(!s)return;typeof s.markerStart=="string"&&s.markerStart&&r.add(s.markerStart),typeof s.markerMid=="string"&&s.markerMid&&r.add(s.markerMid),typeof s.markerEnd=="string"&&s.markerEnd&&r.add(s.markerEnd);let o=s.startEndpoint,a=s.endEndpoint;typeof o=="string"&&o&&o!=="none"&&n.add(o),typeof a=="string"&&a&&a!=="none"&&n.add(a)}),{ids:r,legacyEndpoints:n}}function Ua(t,e){let{ids:r,legacyEndpoints:n}=Wt(t,e);for(let i of n)r.add(Vt(i));return r}function Ht(t,e,r,n){let i=n?.strokeWidth!=null?Math.max(.5,e*n.strokeWidth):Math.max(1,e/10);switch(t){case"stripes":return[{tag:"rect",attrs:{width:n?.strokeWidth!=null?Math.max(.01,Math.min(1,n.strokeWidth))*e:e/2,height:e,fill:r}}];case"dots":{let s=n?.dotRadius!=null?Math.max(.05,Math.min(.45,n.dotRadius)):.25;return[{tag:"circle",attrs:{cx:e/2,cy:e/2,r:e*s,fill:r}}]}case"grid":return[{tag:"path",attrs:{d:`M ${e} 0 L 0 0 0 ${e}`,fill:"none",stroke:r,"stroke-width":i}}];case"checkerboard":return[{tag:"rect",attrs:{width:e/2,height:e/2,fill:r}},{tag:"rect",attrs:{x:e/2,y:e/2,width:e/2,height:e/2,fill:r}}];case"diagonal":{let s=n?.strokeWidth!=null?Math.max(.5,e*n.strokeWidth):Math.max(1,e/5);return[{tag:"path",attrs:{d:`M 0 ${e} L ${e} 0`,stroke:r,"stroke-width":s}}]}case"crosshatch":return[{tag:"path",attrs:{d:`M 0 ${e} L ${e} 0 M 0 0 L ${e} ${e}`,stroke:r,"stroke-width":i}}];case"zigzag":{let s=n?.amplitude!=null?Math.max(.05,Math.min(.5,n.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:r,"stroke-width":i}}]}case"waves":{let s=n?.amplitude!=null?Math.max(.05,Math.min(.5,n.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:r,"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:r,"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:r,"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:r,"stroke-width":i}}];case"circles":return[{tag:"circle",attrs:{cx:e/2,cy:e/2,r:e/3,fill:"none",stroke:r,"stroke-width":i}}];case"bricks":{let s=n?.strokeWidth!=null?Math.max(.5,e*n.strokeWidth):Math.max(1,e/15);return[{tag:"rect",attrs:{x:0,y:0,width:e,height:e/2,fill:"none",stroke:r,"stroke-width":s}},{tag:"rect",attrs:{x:-e/2,y:e/2,width:e,height:e/2,fill:"none",stroke:r,"stroke-width":s}},{tag:"rect",attrs:{x:e/2,y:e/2,width:e,height:e/2,fill:"none",stroke:r,"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:r,"stroke-width":i}}];default:return[]}}function Cc(t){let e=Object.entries(t.attrs).map(([r,n])=>` ${r}="${n}"`).join("");return`<${t.tag}${e}/>`}function nn(t,e,r,n,i){let s=10*e,o="";o+=`<rect width="${s}" height="${s}" fill="${n}"/>`;let a=Ht(t,s,r,i);for(let u of a)o+=Cc(u);return{svgContent:o,width:s,height:s}}var jt="0 0 10 10",sn=6,an=6;function je(){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 Xi={"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"},Ic={"mkr-builtin-arrow":"Arrow","mkr-builtin-open-arrow":"Open Arrow","mkr-builtin-circle":"Circle","mkr-builtin-diamond":"Diamond","mkr-builtin-square":"Square"};function Wa(){return je().map(t=>{let e=Xi[t.id]??t.id;return{kind:"marker",id:e,name:Ic[e]??e,viewBox:jt,refX:t.refX,refY:t.refY,markerWidth:6,markerHeight:6,markerUnits:"strokeWidth",orient:"auto-start-reverse",shapes:[],builtIn:!0}})}function Dc(t){return t.replace(/[^a-zA-Z0-9_-]/g,"_")}function Fc(t){let e=t.state.symbolOverrides;return!!e&&Object.keys(e).length>0}function ut(t){let e=t.state.symbolId??"",r=t.state.variantKey??"";return Fc(t)?`${e}--ovr-${t.id}`:r?`${e}--${Dc(r)}`:e}function on(t,e){let r=e.state.variantKey??"",n=r?t.variants?.[r]??t.shapes:t.shapes,i=e.state.symbolOverrides;return!i||Object.keys(i).length===0?n:n.map(s=>{let o=i[s.id];return!o||Object.keys(o).length===0?s:{...s,state:{...s.state,...o}}})}function Xt(t,e){switch(e){case"uppercase":return t.toLocaleUpperCase();case"lowercase":return t.toLocaleLowerCase();case"capitalize":return t.replace(/\b\p{L}/gu,r=>r.toLocaleUpperCase());default:return t}}var Ec=[["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 ct(t){return Ec.map(([e,r])=>{let n=t[e],i=typeof n=="string"?n.trim():"";return i?`${r}: ${i}`:""}).filter(Boolean).join("; ")}function ln(t,e){let r=[],n=(a,u)=>{u!==""&&r.push({name:a,value:u})};t.fontFamily!==e.fontFamily&&n("font-family",String(t.fontFamily)),t.fontSize!==e.fontSize&&n("font-size",String(t.fontSize)),t.fontWeight!==e.fontWeight&&n("font-weight",String(t.fontWeight)),t.fontStyle!==e.fontStyle&&n("font-style",String(t.fontStyle));let i=ct(t);i&&i!==ct(e)&&n("style",i);let s=t.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"),n("text-decoration",a.join(" "))}if(t.baselineShift!==e.baselineShift){let a=t.baselineShift;a==="super"||a==="sub"?n("baseline-shift",a):typeof a=="number"&&n("baseline-shift",`${a}px`)}return t.letterSpacing!==e.letterSpacing&&n("letter-spacing",String(t.letterSpacing)),t.fill!==e.fill&&n("fill",String(t.fill)),t.fillOpacity!==e.fillOpacity&&n("fill-opacity",String(t.fillOpacity)),t.direction!==e.direction&&n("direction",String(t.direction)),t.unicodeBidi!==e.unicodeBidi&&n("unicode-bidi",String(t.unicodeBidi)),r}function y(t,e){return e==null||e===""?"":` ${t}="${W(String(e))}"`}function Lc(t){let e=t.map(r=>(r??"").trim().replace(/;$/,"")).filter(Boolean).join("; ");return e?y("style",e):""}function Bc(t,e){return typeof e=="number"&&e>0?`${t}: ${e}px`:""}function Nc(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 Ha(t,e){let r=-1;for(let i=t.length-1;i>=0;i--)if(t[i][e]!==null){r=i;break}if(r<0)return[];let n=new Array(r+1);for(let i=0;i<=r;i++)n[i]=t[i][e]??0;return n}function ja(t,e){let r=-1;for(let i=t.length-1;i>=0;i--)if(t[i][e]!==0){r=i;break}if(r<0)return[];let n=new Array(r+1);for(let i=0;i<=r;i++)n[i]=t[i][e];return n}function Oc(t){if(t.length===0)return[];let e=t.length-1,r=t[e].rotate;for(;e>0&&t[e-1].rotate===r;)e--;if(e===0&&r===0)return[];let n=new Array(e+1);for(let i=0;i<=e;i++)n[i]=t[i].rotate;return n}function xe(t,e){return at(t,e)}function zc(t,e,r){return Li(t,e,r)}function Gc(t){if(typeof t=="string"){let n=t.trim();return n.length>0?n:void 0}if(!t||typeof t!="object")return;let e=t,r=[];return e.underline&&r.push("underline"),e.strikethrough&&r.push("line-through"),e.overline&&r.push("overline"),r.length>0?r.join(" "):void 0}function Vc(t){if(typeof t.strokeDasharray=="string")return t.strokeDasharray;let e=t.lineStyle??"solid",r=t.dashLength??8,n=t.gapLength??4;return lt(e,r,n)}function un(t,e){let r=t[e];return r!==void 0?r:t.extra?.[e]}function Uc(t){let e=t.fillType;return e||(t.fillGradient?t.fillGradient.r!==void 0?"radial-gradient":"linear-gradient":un(t,"linearGradient")?"linear-gradient":un(t,"radialGradient")?"radial-gradient":"solid")}function Wc(t){return t.fillGradient??un(t,"linearGradient")??un(t,"radialGradient")??void 0}function pe(t,e){let r=y("data-shape-id",e),n=Uc(t),i=Wc(t);if(n==="none")r+=y("fill","none");else if(n==="linear-gradient"||n==="radial-gradient"){let w=t.fillLibraryId??i?.id;r+=y("fill",`url(#${w??`gradient-fill-${e}`})`)}else if(n==="pattern"){let w=t.fillLibraryId??i?.id;r+=y("fill",`url(#${w??`pattern-fill-${e}`})`)}else r+=y("fill",t.fillColor??"#000000");let s=t.opacity;s!==void 0&&s<1&&(r+=y("opacity",s));let o=t.fillOpacity;o!==void 0&&o<1&&(r+=y("fill-opacity",o));let a=t.fillRule;a&&a!=="nonzero"&&(r+=y("fill-rule",a));let u=t.strokeType??"solid",c=t.strokeGradient;if(u==="none")r+=y("stroke","none");else if(u==="linear-gradient"||u==="radial-gradient"){let w=t.strokeLibraryId??c?.id;r+=y("stroke",`url(#${w??`gradient-stroke-${e}`})`)}else if(u==="pattern"){let w=t.strokeLibraryId??c?.id;r+=y("stroke",`url(#${w??`pattern-stroke-${e}`})`)}else r+=y("stroke",t.borderColor??"none");let f=t.borderWidth;f!=null&&(r+=y("stroke-width",f));let d=t.strokeOpacity;d!==void 0&&d<1&&(r+=y("stroke-opacity",d));let h=t.paintOrder;h&&h!=="normal"&&(r+=y("paint-order",h));let p=t.markerStart,g=t.markerMid,m=t.markerEnd;p&&(r+=y("marker-start",`url(#${p})`)),g&&(r+=y("marker-mid",`url(#${g})`)),m&&(r+=y("marker-end",`url(#${m})`));let b=Vc(t);b&&(r+=y("stroke-dasharray",b),!t.strokeDasharray&&t.lineStyle==="dotted"&&(r+=y("stroke-linecap","round")));let x=t.dashOffset;x!==void 0&&x!==0&&(r+=y("stroke-dashoffset",x));let S=t.shapeRendering;S&&S!=="auto"&&(r+=y("shape-rendering",S)),r+=rn(e,t.filters,t.filterLibraryIds);let $=t.systemLanguage;$&&(r+=y("systemLanguage",$));let v=t.requiredExtensions;v&&(r+=y("requiredExtensions",v));let k=t.vectorEffect;k&&k!=="none"&&(r+=y("vector-effect",k));let P=t.visibility;P&&P!=="visible"&&(r+=y("visibility",P));let T=t.metadata;return T&&(T.role&&(r+=y("role",T.role)),T.ariaLabel&&(r+=y("aria-label",T.ariaLabel))),r}function Hc(t){let e=t.metadata;if(!e)return"";let r="";return e.title&&(r+=`<title>${W(e.title)}</title>`),e.description&&(r+=`<desc>${W(e.description)}</desc>`),r}function jc(t,e){let r=Hc(e);if(!r)return t;let n=t.lastIndexOf("/>");if(n===-1){let o=t.indexOf(">");return o===-1?t:t.slice(0,o+1)+r+t.slice(o+1)}let i=t.match(/^<(\w+)/),s=i?i[1]:"g";return t.slice(0,n)+">"+r+`</${s}>`}function Ki(t){let e="",r=t.startEndpoint,n=t.endEndpoint;return r&&r!=="none"&&(e+=y("marker-start",`url(#line-marker-${r})`)),n&&n!=="none"&&(e+=y("marker-end",`url(#line-marker-${n})`)),e}function Yi(t){let e=t.state,r=e.x??0,n=e.y??0,i=e.radius??50,s=xe(e,{x:r,y:n});return`<circle${y("cx",r)}${y("cy",n)}${y("r",i)}${pe(e,t.id)}${s?y("transform",s):""}/>`}function qi(t){let e=t.state,r=e.cx??0,n=e.cy??0,i=e.rx??50,s=e.ry??30,o=e.pathLength,a=xe(e,{x:r,y:n});return`<ellipse${y("cx",r)}${y("cy",n)}${y("rx",i)}${y("ry",s)}${o!==void 0?y("pathLength",o):""}${pe(e,t.id)}${a?y("transform",a):""}/>`}function Zi(t){let e=t.state,r=e,n=e.x??0,i=e.y??0,s=e.width??100,o=e.height??100,a=e.cornerRadius??0,u=e.rx??a,c=e.ry??a,f=r.cornerShape??"round",d=r.cornerMode??"uniform",h={x:n+s/2,y:i+o/2},p=xe(e,h);if(f!=="round"||d==="non-uniform"){let g=qr(n,i,s,o,a,f,d,d==="non-uniform"?{radiusTL:r.cornerRadiusTL,radiusTR:r.cornerRadiusTR,radiusBR:r.cornerRadiusBR,radiusBL:r.cornerRadiusBL,shapeTL:r.cornerShapeTL,shapeTR:r.cornerShapeTR,shapeBR:r.cornerShapeBR,shapeBL:r.cornerShapeBL}:void 0);if(g)return`<path${y("d",g)}${pe(e,t.id)}${p?y("transform",p):""}/>`}return`<rect${y("x",n)}${y("y",i)}${y("width",s)}${y("height",o)}${u>0||c>0?`${y("rx",u)}${y("ry",c)}`:""}${pe(e,t.id)}${p?y("transform",p):""}/>`}function Qi(t){let e=t.state,r=e.x1??0,n=e.y1??0,i=e.x2??0,s=e.y2??0,o={x:(r+i)/2,y:(n+s)/2},a=xe(e,o),u={...e,fillType:"none"};return`<line${y("x1",r)}${y("y1",n)}${y("x2",i)}${y("y2",s)}${pe(u,t.id)}${Ki(e)}${a?y("transform",a):""}/>`}function Ji(t){let e=t.state,r=e.x??0,n=e.y??0,i=Xt(e.text??"",e.textTransform),s=e.fontSize??16,o=e.fontFamily??"sans-serif",a=e.fontWeight??"normal",u=e.fontStyle??"normal",c=e.textAnchor??"start",f=Gc(e.textDecoration),d=e.letterSpacing,h=e.wordSpacing,p=e.lineHeight??1.25,m=xe(e,{x:r,y:n}),b=y("x",r)+y("y",n);b+=y("font-size",s),b+=y("font-family",o),a!=="normal"&&(b+=y("font-weight",a)),u!=="normal"&&(b+=y("font-style",u)),c!=="start"&&(b+=y("text-anchor",c)),f&&(b+=y("text-decoration",f)),d&&(b+=y("letter-spacing",d)),h&&(b+=y("word-spacing",h));let x=e.baselineShift;x&&x!=="baseline"&&(b+=y("baseline-shift",x));let S=e.dominantBaseline;S&&S!=="auto"&&(b+=y("dominant-baseline",S));let $=e.writingMode;$&&$!=="horizontal-tb"&&(b+=y("writing-mode",$));let v=e.textLength;v!==void 0&&v>0&&(b+=y("textLength",v),e.lengthAdjust==="spacingAndGlyphs"&&(b+=y("lengthAdjust","spacingAndGlyphs")));let k=e.textDirection;k&&k!=="ltr"&&(b+=y("direction",k));let P=e.unicodeBidi;P&&P!=="normal"&&(b+=y("unicode-bidi",P));let T=e.shapeInsideRef;if(T){b+=y("shape-inside",`url(#${T})`);let C=e.shapePadding;C!==void 0&&(b+=y("shape-padding",C))}let w=ct(e),R=e.fontVariationSettings,F="";if(R&&Object.keys(R).length>0&&(F=`font-variation-settings: ${Object.entries(R).map(([L,G])=>`'${L}' ${G}`).join(", ")}`),b+=Lc([w,F,Bc("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+=pe(e,t.id),m&&(b+=y("transform",m)),e.isTextPath&&e.textPathPoints){let C=e.textPathPoints,L=e.textPathStartOffset??0,G=e.textPathSide,A=`text-path-${t.id}`,Y=e.textPathMethod,j=e.textPathSpacing,U=e.textPathLengthAdjust,re=e.textPathLength,V="";if(C.length>=2)if(G==="right"){let N=C[C.length-1];V=`M ${N.x} ${N.y}`;for(let te=C.length-1;te>0;te--){let ne=C[te],ue=C[te-1],oe=ne.handleIn??ne,Ye=ue.handleOut??ue;V+=` C ${oe.x} ${oe.y}, ${Ye.x} ${Ye.y}, ${ue.x} ${ue.y}`}}else{V=`M ${C[0].x} ${C[0].y}`;for(let N=0;N<C.length-1;N++){let te=C[N],ne=C[N+1],ue=te.handleOut??te,oe=ne.handleIn??ne;V+=` C ${ue.x} ${ue.y}, ${oe.x} ${oe.y}, ${ne.x} ${ne.y}`}}return`<defs><path id="${W(A)}"${y("d",V)} fill="none"/></defs><text${b}><textPath href="#${W(A)}"${y("startOffset",`${L}%`)}${y("method",Y)}${y("spacing",j)}${y("lengthAdjust",U)}${y("textLength",re)}>${W(i)}</textPath></text>`}if(e.charOffsets&&Array.isArray(e.charOffsets)&&e.charOffsets.length>0){let C=e.charOffsets.map(Nc),L=i.split(`
|
|
12
|
-
`),G=e.linePositions??[],A=s*p,Y="",j=0;return L.forEach((U,re)=>{let V=Array.from(U).length,N=C.slice(j,j+V),te=G[re],ne=te?r+te.x:re>0?r:NaN,ue=te?te.dy:re>0?A:NaN,oe="",Ye=Ha(N,"x");if(Number.isFinite(ne)||Ye.length>0){let hi=Ye.length>0?Ye.slice():[];Number.isFinite(ne)&&(hi[0]=hi[0]??ne),oe+=y("x",hi.join(" "))}let Fs=Ha(N,"y");Fs.length>0&&(oe+=y("y",Fs.join(" ")));let Es=ja(N,"dx");Es.length>0&&(oe+=y("dx",Es.join(" ")));let Ls=ja(N,"dy"),Me=Ls.length>0||Number.isFinite(ue)?Ls.slice():[];for(Number.isFinite(ue)&&(Me[0]=(Me[0]??0)+ue);Me.length>0&&Me[Me.length-1]===0;)Me.pop();Me.length>0&&(oe+=y("dy",Me.join(" ")));let Bs=Oc(N);Bs.length>0&&(oe+=y("rotate",Bs.join(" "))),Y+=`<tspan${oe}>${W(U)}</tspan>`,j+=V+1}),`<text${b}>${Y}</text>`}let E=yr(e);if(E){let C=_e(E),L=e.linePositions,G=s*C.lineHeight,A="";return C.lines.forEach((Y,j)=>{Y.segments.forEach((U,re)=>{let V="";if(re===0){let N=L?.[j];N?((Math.abs(N.x)>.001||j>0)&&(V+=y("x",r+N.x)),(Math.abs(N.dy)>.001||j>0)&&(V+=y("dy",N.dy))):j>0&&(V+=y("x",r),V+=y("dy",`${G}px`))}for(let{name:N,value:te}of ln(U.style,C.baseStyle))V+=y(N,te);V+=' xml:space="preserve"',A+=`<tspan${V}>${W(Xt(U.text,U.style.textTransform))}</tspan>`})}),`<text${b}>${A}</text>`}return`<text${b}>${W(i)}</text>`}function es(t){let e=t.state,r=e.pathPoints??[],n=e.pathCurveType??"CUBIC",i=e.pathClosed??!1,s=e.pathTension??.5,o=e.pathArcParams,a=Fe(r,n,i,s,o),u=r.length>0?e.customPivot??{x:r[0].x,y:r[0].y}:void 0,c=u?xe(e,u):null;return`<path${y("d",a)}${pe(e,t.id)}${Ki(e)}${c?y("transform",c):""}/>`}function ts(t){let e=t.state,r=e.polylinePoints??[],n=e.polylineClosed??!1,i=r.map(u=>`${u.x},${u.y}`).join(" "),s=r.length>0?e.customPivot??{x:r[0].x,y:r[0].y}:void 0,o=s?xe(e,s):null;return`<${n?"polygon":"polyline"}${y("points",i)}${pe(e,t.id)}${Ki(e)}${o?y("transform",o):""}/>`}function rs(t){let e=t.state,r=e.x??0,n=e.y??0,i=e.width??100,s=e.height??100,o=e.href??"",a=e.imageOpacity,u=e.preserveAspectRatio?"xMidYMid meet":"none",c={x:r+i/2,y:n+s/2},f=xe(e,c);return`<image${y("x",r)}${y("y",n)}${y("width",i)}${y("height",s)}${y("href",o)}${y("preserveAspectRatio",u)}${a!==void 0&&a<1?y("opacity",a):""}${pe(e,t.id)}${f?y("transform",f):""}/>`}function cn(t){return!t||t.length===0?"":t.map(e=>ee(e)).join("")}function Xc(t){let e=t.state,r=e.href,n=e.hrefXlink,i="<a";return r!==void 0&&(i+=y("href",r)),n!==void 0&&(i+=y("xlink:href",n)),i+=y("target",e.linkTarget),i+=y("rel",e.linkRel),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+=y("data-shape-id",t.id),i+=">",i+=cn(e.children),i+="</a>",i}function Kc(t){let e=t.state,r="<switch";return r+=y("data-shape-id",t.id),r+=">",r+=cn(e.children),r+="</switch>",r}function Yc(t){let e=t.state,r=xe(e),n="<g";return n+=y("data-shape-id",t.id),r&&(n+=y("transform",r)),e.opacity!==void 0&&e.opacity<1&&(n+=y("opacity",e.opacity)),e.visibility&&(n+=y("visibility",e.visibility)),e.blendMode&&(n+=y("style",`mix-blend-mode:${e.blendMode}`)),n+=">",n+=cn(e.children),n+="</g>",n}function qc(t){let e=t.state,r=e.viewBoxX,n=e.viewBoxY,i=e.viewBoxWidth,s=e.viewBoxHeight,o=r!==void 0&&n!==void 0&&i!==void 0&&s!==void 0?`${r} ${n} ${i} ${s}`:void 0,a="<view";return a+=y("id",t.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 Zc(t){let e=t.state,r=e.svgX,n=e.svgY,i=e.svgWidth,s=e.svgHeight,o=e.svgViewBoxX,a=e.svgViewBoxY,u=e.svgViewBoxWidth,c=e.svgViewBoxHeight,f=o!==void 0&&a!==void 0&&u!==void 0&&c!==void 0?`${o} ${a} ${u} ${c}`:void 0,d="<svg";return d+=y("xmlns","http://www.w3.org/2000/svg"),d+=y("x",r),d+=y("y",n),d+=y("width",i),d+=y("height",s),d+=y("viewBox",f),d+=y("preserveAspectRatio",e.svgPreserveAspectRatio),d+=y("data-shape-id",t.id),d+=">",d+=cn(e.children),d+="</svg>",d}function Qc(t){let e=t.state,r=e.targetShapeId;if(!r)return`<!-- shape-reference ${W(t.id)} has no targetShapeId -->`;let n=e.offsetX??0,i=e.offsetY??0,s="<use";return s+=y("href",`#${r}`),s+=y("x",n),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",t.id),e.opacity!==void 0&&e.opacity<1&&(s+=y("opacity",e.opacity)),s+="/>",s}function ns(t){let e=t.state,r=ut(t),n=e.x??0,i=e.y??0,s=e.width??100,o=e.height??100;return`<use href="#${W(r)}" x="${n}" y="${i}" width="${s}" height="${o}"/>`}function Jc(t){let e=t.state,r=e.mediaKind??t.type,n=e.x??0,i=e.y??0,s=e.width??320,o=e.height??180,a=e.href??"",u=e.mediaMimeType,c=e.posterHref,f=e.mediaOpacity,d=`<${r} xmlns="http://www.w3.org/1999/xhtml"`;d+=y("src",a),u&&(d+=y("type",u)),c&&r==="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+=r==="video"?' style="width:100%;height:100%;display:block;"></video>':"></audio>";let h="<foreignObject";return h+=y("x",n),h+=y("y",i),h+=y("width",s),h+=y("height",o),h+=y("data-shape-id",t.id),h+=y("data-media-kind",r),e.naturalDuration!==void 0&&(h+=y("data-natural-duration",e.naturalDuration)),e.begin!==void 0&&(h+=y("data-begin",e.begin)),e.trimStart!==void 0&&(h+=y("data-trim-start",e.trimStart)),e.trimEnd!==void 0&&(h+=y("data-trim-end",e.trimEnd)),e.fadeInDuration!==void 0&&(h+=y("data-fade-in",e.fadeInDuration)),e.fadeOutDuration!==void 0&&(h+=y("data-fade-out",e.fadeOutDuration)),e.systemLanguage&&(h+=y("systemLanguage",e.systemLanguage)),e.requiredExtensions&&(h+=y("requiredExtensions",e.requiredExtensions)),f!==void 0&&f<1&&(h+=y("opacity",f)),h+=">",h+=d,h+="</foreignObject>",h}function is(t){let e=t.state,r=e.x??0,n=e.y??0,i=e.width??100,s=e.height??60,o={x:r+i/2,y:n+s/2},a=xe(e,o),u=Zr(t.type,r,n,i,s,{slantPercent:e.slantPercent,topWidthPercent:e.topWidthPercent,capHeightPercent:e.capHeightPercent,waveAmplitudePercent:e.waveAmplitudePercent});return`<path${y("d",u)}${pe(e,t.id)}${a?y("transform",a):""}/>`}function ss(t){let e=t.state,r=e.cx??0,n=e.cy??0,i=e.radius??50,s=e.cornerRadius??0,o=e.shiftAngle??-90,a=e.fillRule??"nonzero",u=zc(e,r,n),c="";switch(t.type){case"triangle":c=he(Gt(3,i,o),s,i);break;case"ngon":{let d=e.sides??6;c=he(Gt(d,i,o),s,i);break}case"star":{let d=e.arms??5,h=e.innerRadiusPercent??50;c=he(zr(d,i,h,o),s,i);break}case"cross":{let d=e.armWidthPercent??40;c=he(Gr(i,d,o),s,i);break}case"ring":{let d=e.innerRadiusPercent??50;c=Xr(i,d,a);break}case"spiral":{let d=e.turns??3,h=e.thicknessPercent??20,p=e.spiralDirection??1;c=Kr(i,d,h,p,o);break}case"gear":{let d=e.teeth??8,h=e.toothDepthPercent??30,p=e.holeRadiusPercent??0;c=Yr(d,i,h,s,p,a,o);break}case"arrow":{let d=e.headWidthPercent??100,h=e.headLengthPercent??30,p=e.shaftWidthPercent??40;c=he(Vr(i,d,h,p,o),s,i);break}case"speechBubble":{let d=e.tailAngleDeg??45,h=e.tailLengthPercent??40,p=e.tailWidthPercent??25;c=he(Ur(i,d,h,p,o),s,i);break}case"lightning":{let d=e.boltSegments??3,h=e.boltJaggednessPercent??40,p=e.boltWidthPercent??30;c=he(Wr(i,d,h,p,o),s,i);break}case"heart":{let d=e.lobeRadiusPercent??50,h=e.cleftDepthPercent??25;c=Hr(i,d,h,o);break}case"cloud":{let d=e.cloudBumps??5,h=e.cloudPuffinessPercent??60;c=jr(i,d,h,o);break}default:return`<!-- unsupported polygon shape: ${W(t.type)} -->`}let f="";return(t.type==="ring"||t.type==="gear")&&(f=y("fill-rule",a)),`<path${y("d",c)}${f}${pe(e,t.id)}${y("transform",u)}/>`}function ee(t){let e;switch(t.type){case"circle":e=Yi(t);break;case"ellipse":e=qi(t);break;case"rectangle":case"square":e=Zi(t);break;case"line":e=Qi(t);break;case"text":e=Ji(t);break;case"path":e=es(t);break;case"polyline":e=ts(t);break;case"image":e=rs(t);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=ss(t);break;case"diamond":case"parallelogram":case"trapezoid":case"terminator":case"cylinder":case"document-shape":e=is(t);break;case"hyperlink":e=Xc(t);break;case"switch":e=Kc(t);break;case"container":case"group":e=Yc(t);break;case"view":e=qc(t);break;case"svg":e=Zc(t);break;case"shape-reference":e=Qc(t);break;case"symbol-instance":e=ns(t);break;case"audio":case"video":e=Jc(t);break;default:return`<!-- unsupported shape type: ${W(t.type)} -->`}return jc(e,t.state)}function Xa(t,e){let r=(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(""),n=e.gradientUnits==="userSpaceOnUse",i=o=>n?String(o):`${o*100}%`,s=n?y("gradientUnits","userSpaceOnUse"):"";return`<linearGradient${y("id",t)}${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):""}>${r}</linearGradient>`}function Ka(t,e){let r=(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(""),n=e.gradientUnits==="userSpaceOnUse",i=f=>n?String(f):`${f*100}%`,s=n?y("gradientUnits","userSpaceOnUse"):"",o="",a=e.ry!==void 0&&e.ry!==e.r,u=!!e.rotation;if(a||u){let f=e.cx??(n?0:.5),d=e.cy??(n?0:.5),h=[];h.push(`translate(${f}, ${d})`),u&&h.push(`rotate(${e.rotation})`),a&&e.ry!==0&&h.push(`scale(1, ${e.ry/e.r})`),h.push(`translate(-${f}, -${d})`),o=y("gradientTransform",h.join(" "))}let c=e.fr!==void 0&&e.fr>0?y("fr",i(e.fr)):"";return`<radialGradient${y("id",t)}${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}>${r}</radialGradient>`}function Ya(t,e){if(e.svgContent!=null){let a=e.width??10,u=e.height??10,c=e.patternUnits??"userSpaceOnUse",f=e.patternContentUnits,d=e.patternTransform,h=e.viewBox,p=e.preserveAspectRatio,g=e.x??0,m=e.y??0,b=`<pattern${y("id",t)}`;return b+=y("patternUnits",c),f&&(b+=y("patternContentUnits",f)),g&&(b+=y("x",g)),m&&(b+=y("y",m)),b+=y("width",a),b+=y("height",u),h&&(b+=y("viewBox",h)),p&&(b+=y("preserveAspectRatio",p)),d&&(b+=y("patternTransform",d)),b+=`>${e.svgContent}</pattern>`,b}let r=10*(e.scale??1),n=e.rotation??0,i=e.color||"#000000",s=e.backgroundColor||"#ffffff",o="";return o+=`<rect${y("width",r)}${y("height",r)}${y("fill",s)}/>`,o+=ed(e.patternType,r,i),`<pattern${y("id",t)}${y("patternUnits","userSpaceOnUse")}${y("width",r)}${y("height",r)}${n?y("patternTransform",`rotate(${n})`):""}>${o}</pattern>`}function ed(t,e,r){return Ht(t,e,r).map(i=>{let s=Object.entries(i.attrs).map(([o,a])=>y(o,a)).join("");return`<${i.tag}${s}/>`}).join("")}function Se(t,e=[]){let r=Array.isArray(t)?Wt(t,e):t;if(r.ids.size===0&&r.legacyEndpoints.size===0)return"";let n="",i=je();for(let s of i){let o=s.id,a=o.replace("line-marker-",""),u=`mkr-builtin-${a}`,c=r.legacyEndpoints.has(a)||r.ids.has(o),f=r.ids.has(u);if(!c&&!f)continue;let d=s.element,h=Object.entries(d.attrs).map(([m,b])=>y(m,b)).join(""),p=`<${d.tag}${h}/>`,g=m=>{n+=`<marker${y("id",m)}${y("viewBox",jt)}${y("refX",s.refX)}${y("refY",s.refY)}${y("markerWidth",6)}${y("markerHeight",6)}${y("orient","auto-start-reverse")}>${p}</marker>`};c&&g(o),f&&g(u)}return n}var Ae=t=>t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),as=["linear-gradient","radial-gradient","pattern","filter","marker","symbol"];function os(t){switch(t.kind){case"symbol":return ls(t);case"marker":return us(t);case"linear-gradient":return cs(t);case"radial-gradient":return ds(t);case"pattern":return fs(t);case"filter":return hs(t)}}function ls(t){let e=t.shapes.map(i=>ee(i)).join(""),r=t.viewBox?` viewBox="${Ae(t.viewBox)}"`:"",n=t.overflow?` overflow="${Ae(t.overflow)}"`:"";return`<symbol id="${Ae(t.id)}"${r}${n}>${e}</symbol>`}function us(t){let e;if(t.builtIn){let s=je().find(o=>t.id.includes(o.id)||t.id===o.id);if(s){let o=Object.entries(s.element.attrs).map(([a,u])=>` ${a}="${Ae(String(u))}"`).join("");e=`<${s.element.tag}${o}/>`}else e=""}else e=t.shapes.map(s=>ee(s)).join("");let r=typeof t.orient=="number"?String(t.orient):t.orient,n=t.viewBox?` viewBox="${Ae(t.viewBox)}"`:"",i=t.overflow?` overflow="${Ae(t.overflow)}"`:"";return`<marker id="${Ae(t.id)}"${n} refX="${t.refX}" refY="${t.refY}" markerWidth="${t.markerWidth}" markerHeight="${t.markerHeight}" markerUnits="${Ae(t.markerUnits)}" orient="${Ae(r)}"${i}>${e}</marker>`}function cs(t){let e={...t.gradient,type:"linear-gradient",id:t.id};return Xa(t.id,e)}function ds(t){let e={...t.gradient,type:"radial-gradient",id:t.id};return Ka(t.id,e)}function fs(t){let e={...t.pattern,type:"pattern",id:t.id};return Ya(t.id,e)}function hs(t){return ji(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})}function Kt(t){let e=new Map;for(let n of t){let i=e.get(n.kind);i?i.push(n):e.set(n.kind,[n])}let r="";for(let n of as){let i=e.get(n);if(i)for(let s of i)r+=os(s)}return r}function Ee(t,e){let r=Yt(t,e);return r.length===0?"":Kt(r)}function Yt(t,e){let r=new Map;for(let u of e)r.set(u.id,u);let n=new Map,i=u=>{if(!u)return;let c=r.get(u);c&&n.set(u,c)},s=(u,c)=>{if(!u||typeof u!="object")return;let f=u;if(!f.id||n.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:h,sourceId:p,...g}=u,m;if(d==="linear-gradient")m={kind:"linear-gradient",id:f.id,name:p??f.id,sourceId:p,gradient:g};else if(d==="radial-gradient")m={kind:"radial-gradient",id:f.id,name:p??f.id,sourceId:p,gradient:g};else{let{customPatternId:b,...x}=g;m={kind:"pattern",id:f.id,name:p??f.id,sourceId:p,pattern:x}}n.set(f.id,m)},o=(u,c)=>{let f=u.filters;if(!Array.isArray(f)||f.length===0)return;let d=`filter-${c}`;n.has(d)||n.set(d,{kind:"filter",id:d,name:d,filters:f,...u.filterColorInterpolation&&u.filterColorInterpolation!=="auto"?{colorInterpolation:u.filterColorInterpolation}:{},...u.filterUnits?{filterUnits:u.filterUnits}:{},...u.primitiveUnits?{primitiveUnits:u.primitiveUnits}:{},...typeof u.filterX=="string"?{x:u.filterX}:{},...typeof u.filterY=="string"?{y:u.filterY}:{},...typeof u.filterWidth=="string"?{width:u.filterWidth}:{},...typeof u.filterHeight=="string"?{height:u.filterHeight}:{}})},a=u=>{let c=u.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,u.id)};for(let u of t)a(u);return Ut(t,e,a),Array.from(n.values())}function ps(t){return t.easing==="custom-bezier"&&t.customBezier?t.customBezier:sr[t.easing]??null}function ms(t,e,r,n,i){if(t===e&&r===n)return i;let s=1e-6,o=8,a=p=>(((1-3*r+3*t)*p+(3*r-6*t))*p+3*t)*p,u=p=>(((1-3*n+3*e)*p+(3*n-6*e))*p+3*e)*p,c=p=>(3*(1-3*r+3*t)*p+2*(3*r-6*t))*p+3*t,f=i;for(let p=0;p<o;p++){let g=a(f)-i;if(Math.abs(g)<s)return u(f);let m=c(f);if(Math.abs(m)<s)break;f-=g/m}let d=0,h=1;for(f=i;d<h;){let p=a(f);if(Math.abs(p-i)<s)return u(f);i>p?d=f:h=f;let g=(h-d)*.5+d;if(g===f)break;f=g}return u(f)}function gs(t){let e=t.split(/\s+/).map(parseFloat);if(e.length!==4||e.some(o=>!Number.isFinite(o)))return t;let[r,n,i,s]=e;return`${1-i} ${1-s} ${1-r} ${1-n}`}function ie(t){return!Number.isFinite(t)||Math.abs(t)<1e-9?"0":Math.abs(t-1)<1e-9?"1":parseFloat(t.toFixed(6)).toString()}function fn([t,e,r,n]){let i=s=>Number.isFinite(s)?parseFloat(s.toFixed(6)).toString():"0";return`${i(t)} ${i(e)} ${i(r)} ${i(n)}`}function ys(t){return t.length>0&&t.every(e=>e==="0 0 1 1")}function qt(t){if(t.length<2)return!1;let e=t.length-1,r=1e-4;for(let n=0;n<t.length;n++){let i=n/e,s=parseFloat(t[n]);if(!Number.isFinite(s)||Math.abs(s-i)>r)return!1}return!0}function hn(t){if(t.length<2)return!1;let e=t.length-1,r=1e-4;for(let n=0;n<t.length;n++)if(Math.abs(t[n]-n/e)>r)return!1;return!0}function Be(t){let e=t.cycleDuration??(t.keyframes.length>0?t.keyframes[t.keyframes.length-1].time:0);return t.cycleBehavior==="alternate"?e*2:e}function Xe(t){let e=t.beginTrigger;if(e)switch(e.type){case"time":{let n=parseFloat(e.value);return Number.isNaN(n)?"":Number.isFinite(n)?n!==0?`${n}s`:"":"indefinite"}case"event":return e.value;case"expression":return"";default:break}let r=t.keyframes[0]?.time??0;return r!==0?`${r}s`:""}function pn(t){return t.keyframes.length===1&&t.cycleDuration===void 0}function mn(t){return t.calcMode!=="discrete"?!1:t.sourceSmilElement==="set"?!0:!t.sourceSmilElement&&!t.cycleInfinite&&t.keyframes.every(e=>e.easing!=="steps")}function gn(t,e){if(e<=0)return Xe(t);if(Xe(t)==="indefinite")return"indefinite";let r=t.keyframes[e]?.time??0;return r!==0?`${r}s`:""}function yn(t){return t.cycleInfinite?"indefinite":t.cycleRepeats&&t.cycleRepeats>1?String(t.cycleRepeats):null}function Ke(t){return t.cycleInfinite||t.fill==="remove"?null:"freeze"}function bn(t){return t.additive==="sum"?"sum":null}function xn(t){return t.keyframes.map(e=>{let r=typeof e.value=="number"?e.value:parseFloat(String(e.value));return Number.isFinite(r)?Math.max(0,Math.min(1,r)):0})}function td(t){let e=r=>Math.max(0,Math.min(1,r));return[t[0],e(t[1]),t[2],e(t[3])]}function rd(t){let[e,r,n,i]=t,s=new Set,o=8;for(let d=1;d<=o;d++)s.add(d/o);let a=r-2*i+1,u=2*(i-2*r),c=r,f=d=>{if(!Number.isFinite(d)||d<=0||d>=1)return;let h=3*(1-d)**2*d*e+3*(1-d)*d**2*n+d**3;h>0&&h<1&&s.add(Number(h.toFixed(6)))};if(Math.abs(a)<1e-9)Math.abs(u)>=1e-9&&f(-c/u);else{let d=u*u-4*a*c;if(d>=0){let h=Math.sqrt(d);f((-u+h)/(2*a)),f((-u-h)/(2*a))}}return[...s].sort((d,h)=>d-h)}function nd(t,e,r,n,i,s){let o=typeof t.value=="number"&&typeof e.value=="number",a=Le(e.value);if(e.easing==="linear-function"&&e.linearPoints&&e.linearPoints.length>=2){if(o){let b=e.linearPoints;for(let x=1;x<b.length;x++){let S=b[x],$=t.time+(e.time-t.time)*S.position,v=t.value+(e.value-t.value)*S.value;n.push(v),i.push(ie(r($))),s.push("0 0 1 1")}return}n.push(a),i.push(ie(r(e.time))),s.push("0 0 1 1");return}if(e.easing==="steps"){n.push(a),i.push(ie(r(e.time))),s.push("0 0 1 1");return}let u=ps(e);if(!u){n.push(a),i.push(ie(r(e.time))),s.push("0 0 1 1");return}let[,c,,f]=u;if(!(c<0||c>1||f<0||f>1)){n.push(a),i.push(ie(r(e.time))),s.push(fn(u));return}if(!o){n.push(a),i.push(ie(r(e.time))),s.push(fn(td(u)));return}let h=rd(u),p=t.value,g=e.value,m=e.time-t.time;for(let b of h){let x=ms(u[0],u[1],u[2],u[3],b),S=t.time+m*b,$=p+(g-p)*x;n.push($),i.push(ie(r(S))),s.push("0 0 1 1")}}function Le(t){return Array.isArray(t)?t.join(" "):t}function id(t,e,r){let n=[],{count:i,position:s}=r,o=e.time-t.time,a=Le(t.value),u=Le(e.value),c=typeof a=="number"&&typeof u=="number",f=typeof a=="string"&&typeof u=="string",d=g=>f?g<.5?a:u:c?a+(u-a)*g:g>=1?u:a,h=g=>{let m=Math.floor(g*i);(s==="jump-start"||s==="jump-both")&&(m+=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 m>b&&(m=b),m<0&&(m=0),m/b},p=h(0);for(let g=1;g<=i;g++){let m=g/i,b=h(m);if(b===p)continue;let x=t.time+m*o;n.push({value:d(b),time:x}),p=b}return n.length===0||n[n.length-1].time<e.time?n.push({value:u,time:e.time}):n[n.length-1]={value:u,time:e.time},n}function sd(t,e){let r=[],n=[],i=(s,o)=>{r.push(s),n.push(ie(e(o)))};i(Le(t[0].value),t[0].time);for(let s=1;s<t.length;s++){let o=t[s-1],a=t[s];if(a.easing==="steps"&&a.stepsParams){let u=id(o,a,a.stepsParams);for(let c of u)i(c.value,c.time)}else i(Le(a.value),a.time)}return{values:r,keyTimes:n}}function dn(t,e,r,n,i){if(i.cycleBehavior!=="alternate"||t.length<2)return{values:t,keyTimes:e,keySplines:r,calcMode:n};let s=t.slice(0,-1).reverse(),o=e.slice(0,-1).reverse().map(u=>ie(1-parseFloat(u))),a=r.slice().reverse().map(gs);return{values:[...t,...s],keyTimes:[...e,...o],keySplines:[...r,...a],calcMode:n}}function Ne(t){let e=t.keyframes;if(e.length===0)return{values:[],keyTimes:[],keySplines:[],calcMode:"spline"};let r=Be(t),n=e[0]?.time??0,i=c=>r>0?(c-n)/r:0;if(e.some(c=>c.easing==="steps")){let{values:c,keyTimes:f}=sd(e,i);return dn(c,f,[],"discrete",t)}if(t.calcMode==="discrete"){let c=e.map(d=>Le(d.value)),f=e.map(d=>ie(i(d.time)));return dn(c,f,[],"discrete",t)}if(t.calcMode==="paced"){let c=e.map(d=>Le(d.value)),f=e.map(d=>ie(i(d.time)));return dn(c,f,[],"paced",t)}let o=[Le(e[0].value)],a=[ie(i(e[0].time))],u=[];for(let c=1;c<e.length;c++)nd(e[c-1],e[c],i,o,a,u);return dn(o,a,u,"spline",t)}function Zt(t,e={}){let r=e.defaultCalcMode??"linear",n={};if(t.calcMode==="paced")return r!=="paced"&&(n.calcMode="paced"),n;if(t.calcMode==="discrete")return n.keyTimes=t.keyTimes.join(";"),n.calcMode="discrete",n;let i=t.keySplines.length>0&&!ys(t.keySplines);return qt(t.keyTimes)||(n.keyTimes=t.keyTimes.join(";")),i&&(n.calcMode="spline",n.keySplines=t.keySplines.join(";")),n}function bs(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 r=(n,i)=>!n&&!i||!!n&&!!i&&n.type===i.type&&n.value===i.value;if(!r(t.beginTrigger,e.beginTrigger)||!r(t.endTrigger,e.endTrigger))return!1;for(let n=0;n<t.keyframes.length;n++){let i=t.keyframes[n],s=e.keyframes[n];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 u=0;u<4;u++)if(o[u]!==a[u])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 Sn(t){let e=new Map,r=new Set,n=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 s=n.get(i.shapeId)??[];s.push(i),n.set(i.shapeId,s)}for(let i of n.values()){let s=new Set;for(let o=0;o<i.length;o++){let a=i[o];if(s.has(a.id))continue;let u=a.property==="translateX"||a.property==="translateY",c=u?"translateX":"scaleX",f=u?"translateY":"scaleY";if(!(a.property!==c&&a.property!==f))for(let d=o+1;d<i.length;d++){let h=i[d];if(s.has(h.id)||!(a.property===c&&h.property===f||a.property===f&&h.property===c)||!bs(a,h))continue;let p=a.property===c?a:h,g=a.property===f?a:h;e.set(p.id,g),r.add(g.id),s.add(p.id),s.add(g.id);break}}}return{partner:e,skip:r}}function $n(t,e,r,n){if(n){let s=e?n.values:t.values,o=e?t.values:n.values,a=Math.min(s.length,o.length),u=[];for(let c=0;c<a;c++)u.push(`${s[c]} ${o[c]}`);return u}let i=r?"1":"0";return t.values.map(s=>e?`${i} ${s}`:`${s} ${i}`)}var Za={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"},Qa=new Set(["transformMatrix","rotation","skewX","skewY"]),Ja=new Set(["translateX","translateY","scaleX","scaleY"]);function vn(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function z(t,e){return e==null?"":` ${t}="${vn(e)}"`}function xs(t,e){let r=Zt(t,e);return z("keyTimes",r.keyTimes)+z("calcMode",r.calcMode)+z("keySplines",r.keySplines)}function Tn(t,e){return z("dur",`${e}s`)+z("begin",Xe(t)||null)+z("repeatCount",yn(t))}function ad(t){let e=Za[t.property];if(!e)return"";let r=Be(t);if(r<=0)return"";let n=Ne(t);return n.values.length<2?"":"<animate"+z("attributeName",e)+z("values",n.values.join(";"))+xs(n)+Tn(t,r)+z("fill",Ke(t))+"/>"}function od(t){let e;switch(t.property){case"transformMatrix":e="matrix";break;case"rotation":e="rotate";break;case"skewX":e="skewX";break;case"skewY":e="skewY";break;default:return""}let r=Be(t);if(r<=0)return"";let n=Ne(t),i=e==="matrix"?n.values.map(o=>ud(o)):n.values.map(o=>String(o));if(i.length<2||i.some(o=>o.length===0))return"";let s=e==="rotate"&&t.transformOrigin?i.map(o=>`${o} ${t.transformOrigin.x} ${t.transformOrigin.y}`):i;return'<animateTransform attributeName="transform"'+z("type",e)+z("values",s.join(";"))+xs(n)+Tn(t,r)+z("additive",bn(t))+z("fill",Ke(t))+"/>"}function ld(t,e,r){let n=t.property==="scaleX"||t.property==="scaleY",i=t.property==="translateY"||t.property==="scaleY",s=n?"scale":"translate",o=Be(t);if(o<=0)return"";let a=Ne(t);if(a.values.length<2)return"";let u=e?Ne(e):void 0,c=$n(a,i,n,u);if(c.length<2)return"";let f=!t.replacesCarrierBase||r?"sum":null;return'<animateTransform attributeName="transform"'+z("type",s)+z("values",c.join(";"))+xs(a)+Tn(t,o)+z("additive",f)+z("fill",Ke(t))+"/>"}function ud(t){if(Array.isArray(t)&&t.length>=6){let e=t.slice(0,6);if(e.every(r=>typeof r=="number"&&Number.isFinite(r)))return e.join(" ")}if(typeof t=="string"){let e=t.trim(),r=/^matrix\(([^)]+)\)$/i.exec(e),i=(r?r[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 cd(t){if(!t.motionPath)return"";let e=Be(t);if(e<=0)return"";let r=Ne(t),n=xn(t),i=!!t.motionPathRef&&(t.motionPathRef.mode??"trackShape")==="curveTemplate",s=Zt(r,{defaultCalcMode:"paced"}),o=hn(n)&&qt(r.keyTimes)&&r.calcMode!=="discrete"&&s.calcMode===void 0,a="<animateMotion";return i||(a+=z("path",t.motionPath)),a+=z("keyTimes",s.keyTimes),o||(a+=z("keyPoints",n.join(";"))),a+=z("calcMode",s.calcMode)+z("keySplines",s.keySplines),a+=Tn(t,e),a+=z("fill",Ke(t)),t.motionRotate!==void 0&&(a+=z("rotate",typeof t.motionRotate=="number"?String(t.motionRotate):t.motionRotate)),i?a+=`><mpath href="#${vn(t.motionPathRef.shapeId)}"/></animateMotion>`:a+="/>",a}function qa(t,e){if(Qa.has(t.property)||Ja.has(t.property)||t.property==="pathMotion")return"";let r=Za[t.property];if(!r)return"";let n=t.keyframes[e];return n?"<set"+z("attributeName",r)+z("to",Array.isArray(n.value)?n.value.join(" "):String(n.value))+z("begin",gn(t,e)||null)+"/>":""}function dd(t){let e=Xe(t);return e?`<discard begin="${vn(e)}"/>`:"<discard/>"}function kn(t){let e=new Map,r=t.tracks.map(a=>({...a,locked:a.locked??!1,keyframes:[...a.keyframes].sort((u,c)=>u.time-c.time).map(u=>({...u,time:u.time,value:u.value,easing:u.easing}))})),n=Sn(r),i=new Set,s=new Set,o=(a,u,c)=>{if(!u)return;let f=u;c.sourceSmilId&&!i.has(c.sourceSmilId)&&(i.add(c.sourceSmilId),f=u.replace(/^(<[a-zA-Z]+)/,`$1 id="${vn(c.sourceSmilId)}"`));let d=e.get(a)??[];d.push(f),e.set(a,d)};for(let a of r){if(!a.enabled||n.skip.has(a.id)||a.keyframes.length<1)continue;if(a.property==="discard"){o(a.shapeId,dd(a),a);continue}if(pn(a)){o(a.shapeId,qa(a,0),a);continue}if(mn(a)){for(let c=0;c<a.keyframes.length;c++)o(a.shapeId,qa(a,c),a);continue}if(a.keyframes.length<2)continue;let u="";a.property==="pathMotion"&&a.motionPath?u=cd(a):Qa.has(a.property)?(u=od(a),u&&s.add(a.shapeId)):Ja.has(a.property)?(u=ld(a,n.partner.get(a.id),s.has(a.shapeId)),u&&s.add(a.shapeId)):u=ad(a),o(a.shapeId,u,a)}return e}function dt(t,e={}){let{xmlDeclaration:r=!0,backgroundColor:n,indent:i=!0,className:s}=e,o=t.viewboxes?.[0],a=e.width??o?.width??800,u=e.height??o?.height??600,c=e.viewBox??`0 0 ${a} ${u}`,f=i?`
|
|
13
|
-
`:"",d=i?" ":"",h=t.shapes??[],p=h.filter(C=>C.state?.displayMode==="motionOnly"),g=h.filter(C=>C.state?.displayMode!=="motionOnly"),m=md(t),b=gd(t),x=[...Array.isArray(t.library)?t.library:[],...(b??[]).filter(C=>!C.builtIn&&!(Array.isArray(t.library)&&t.library.some(L=>L.id===C.id)))],S=Yt(g,x),$=S.length>0?Kt(S):"",v=Se(g,x),k=yd(m,g,new Set(S.map(C=>C.id))),P=fd(p),T=$.length>0||v.length>0||k.length>0||P.length>0,w="";T&&(w=`${f}${d}<defs>${f}`,$.length>0&&(w+=`${d}${d}${$}${f}`),v.length>0&&(w+=`${d}${d}${v}${f}`),k.length>0&&(w+=`${d}${d}${k}${f}`),P.length>0&&(w+=`${d}${d}${P}${f}`),w+=`${d}</defs>`);let R="";n&&(R=`${f}${d}<rect width="${a}" height="${u}" fill="${n}"/>`);let F=t.animationTimeline?kn(t.animationTimeline):null,B=g.map(C=>{let L=ee(C),G=F?.get(C.id);return G&&G.length>0&&(L=bd(L,G,d)),`${d}${L}`}).join(f),E="";return r&&(E+=`<?xml version="1.0" encoding="UTF-8"?>${f}`),E+='<svg xmlns="http://www.w3.org/2000/svg"',E+=` width="${a}" height="${u}"`,E+=` viewBox="${c}"`,s&&(E+=` class="${s}"`),E+=">",E+=w,E+=R,g.length>0&&(E+=`${f}${B}`),E+=`${f}</svg>${f}`,E}function fd(t){if(t.length===0)return"";let e=[];for(let r of t){let n=hd(r);if(!n)continue;let i=pd(n);e.push(`<path id="${eo(r.id)}" d="${eo(i)}"/>`)}return e.join("")}function hd(t){let e=t.state;if(typeof e?.d=="string")return e.d;switch(t.type){case"rectangle":{let r=e?.x??0,n=e?.y??0,i=e?.width??0,s=e?.height??0;return i<=0||s<=0?null:`M${r},${n}h${i}v${s}h${-i}Z`}case"circle":{let r=e?.cx??0,n=e?.cy??0,i=e?.radius??0;return i<=0?null:`M${r-i},${n}A${i},${i} 0 1 0 ${r+i},${n}A${i},${i} 0 1 0 ${r-i},${n}Z`}case"ellipse":{let r=e?.cx??0,n=e?.cy??0,i=e?.rx??0,s=e?.ry??0;return i<=0||s<=0?null:`M${r-i},${n}A${i},${s} 0 1 0 ${r+i},${n}A${i},${s} 0 1 0 ${r-i},${n}Z`}case"line":{let r=e?.x1??0,n=e?.y1??0,i=e?.x2??0,s=e?.y2??0;return`M${r},${n}L${i},${s}`}default:return null}}function pd(t){let e=/[Mm]\s*(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)[\s,]+(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)/.exec(t);if(!e)return t;let r=parseFloat(e[1]),n=parseFloat(e[2]);if(!isFinite(r)||!isFinite(n)||r===0&&n===0)return t;let i=!0;return t.replace(/([MLCQSTHVAZ])\s*([\d\s.,e+-]*)/gi,(s,o,a)=>{let u=o.toUpperCase(),c=o!==u,f=i;if(i=!1,u==="Z")return s;let d=a.trim().split(/[\s,]+/).filter(p=>p.length>0).map(Number);if(d.length===0||c&&!f)return s;let h=[];if(u==="H")for(let p of d)h.push(p-r);else if(u==="V")for(let p of d)h.push(p-n);else if(u==="A")for(let p=0;p<d.length;p+=7)h.push(d[p],d[p+1],d[p+2],d[p+3],d[p+4]),p+5<d.length&&h.push(d[p+5]-r),p+6<d.length&&h.push(d[p+6]-n);else for(let p=0;p<d.length;p+=2)h.push(d[p]-r),p+1<d.length&&h.push(d[p+1]-n);return`${o} ${h.join(" ")}`})}function eo(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<")}function md(t){let r=(Array.isArray(t.library)?t.library:[]).filter(n=>n.kind==="symbol");return r.length>0?r:t.symbols??[]}function gd(t){let r=(Array.isArray(t.library)?t.library:[]).filter(n=>n.kind==="marker");return r.length>0?r:t.markers}var Ss=t=>t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""");function yd(t,e,r=new Set){if(t.length===0)return"";let n=new Map;for(let u of t)n.set(u.id,u);let i=new Map,s=new Set,o=[...e];for(let u=0;u<o.length;u++){let c=o[u],f=c.state?.children;if(Array.isArray(f)&&o.push(...f),c.type!=="symbol-instance")continue;let d=n.get(c.state.symbolId??"");if(!d)continue;let h=ut(c);if(s.has(h))continue;s.add(h);let p=on(d,c);o.push(...p),!r.has(h)&&i.set(h,{def:d,resolved:p})}if(i.size===0)return"";let a=[];for(let[u,{def:c,resolved:f}]of i){let d=f.map(g=>ee(g)).join(""),h=c.viewBox?` viewBox="${Ss(c.viewBox)}"`:"",p=c.overflow?` overflow="${Ss(c.overflow)}"`:"";a.push(`<symbol id="${Ss(u)}"${h}${p}>${d}</symbol>`)}return a.join("")}function bd(t,e,r){let n=e.join(""),i=0;for(;i<t.length;){let c=t.slice(i);if(!/^<defs[\s>]/.test(c))break;let f=t.indexOf("</defs>",i);if(f===-1)break;i=f+7}let s=t.slice(0,i),o=t.slice(i),a=o.lastIndexOf("/>");if(a!==-1){let c=o.match(/^<(\w+)/),f=c?c[1]:"g";return s+o.slice(0,a)+">"+n+`</${f}>`}let u=o.match(/<\/(\w+)>$/);if(u){let c=o.lastIndexOf(`</${u[1]}>`);return s+o.slice(0,c)+n+o.slice(c)}return s+o+n}var ft=Math.PI*2;function xd(t,e,r,n){let i=e*e-4*t*r;if(!(i>=0))return;let s=Math.sqrt(i),o=-.5*(e+(e>=0?s:-s));if(t!==0){let a=o/t;a>0&&a<1&&n.push(a)}if(o!==0){let a=r/o;a>0&&a<1&&n.push(a)}}function Sd(t,e,r,n,i){let s=1-i;return s*s*s*t+3*s*s*i*e+3*s*i*i*r+i*i*i*n}function $d(t,e,r,n){let i=1-n;return i*i*t+2*i*n*e+n*n*r}function _n(t,e,r,n){let i=t<n?t:n,s=t>n?t:n,o=-t+3*e-3*r+n,a=2*(t-2*e+r),u=e-t,c=[];xd(o,a,u,c);for(let f of c){let d=Sd(t,e,r,n,f);d<i&&(i=d),d>s&&(s=d)}return{min:i,max:s}}function Rn(t,e,r){let n=t<r?t:r,i=t>r?t:r,s=t-2*e+r;if(s!==0){let o=(t-e)/s;if(o>0&&o<1){let a=$d(t,e,r,o);a<n&&(n=a),a>i&&(i=a)}}return{min:n,max:i}}function to(t,e,r,n){let i=t*n-e*r>=0?1:-1,s=Math.sqrt((t*t+e*e)*(r*r+n*n));if(s===0)return 0;let o=(t*r+e*n)/s;return o<-1?o=-1:o>1&&(o=1),i*Math.acos(o)}function vs(t,e,r,n,i,s,o,a,u){if(t===a&&e===u||r===0||n===0)return null;let c=Math.abs(r),f=Math.abs(n),d=i%360*Math.PI/180,h=Math.cos(d),p=Math.sin(d),g=(t-a)/2,m=(e-u)/2,b=h*g+p*m,x=-p*g+h*m,S=b*b,$=x*x,v=c*c,k=f*f,P=S/v+$/k;if(P>1){let re=Math.sqrt(P);c*=re,f*=re,v=c*c,k=f*f}let T=v*$+k*S;if(T===0)return null;let w=(v*k-T)/T;w<0&&(w=0);let R=Math.sqrt(w);s===o&&(R=-R);let F=R*(c*x/f),B=R*(-(f*b)/c),E=h*F-p*B+(t+a)/2,C=p*F+h*B+(e+u)/2,L=(b-F)/c,G=(x-B)/f,A=(-b-F)/c,Y=(-x-B)/f,j=to(1,0,L,G),U=to(L,G,A,Y);return!o&&U>0?U-=ft:o&&U<0&&(U+=ft),{cx:E,cy:C,rx:c,ry:f,phi:d,theta1:j,deltaTheta:U}}function vd(t,e){let r=Math.cos(t.phi),n=Math.sin(t.phi),i=Math.cos(e),s=Math.sin(e);return{x:t.cx+t.rx*r*i-t.ry*n*s,y:t.cy+t.rx*n*i+t.ry*r*s}}function Td(t,e,r){if(r>=0){let i=(t-e)%ft;return i<0&&(i+=ft),i<=r}let n=(e-t)%ft;return n<0&&(n+=ft),n<=-r}function Ts(t,e,r,n,i,s,o,a,u){let c={minX:Math.min(t,a),minY:Math.min(e,u),maxX:Math.max(t,a),maxY:Math.max(e,u)},f=vs(t,e,r,n,i,s,o,a,u);if(!f)return c;let d=Math.cos(f.phi),h=Math.sin(f.phi),p=Math.atan2(-f.ry*h,f.rx*d),g=Math.atan2(f.ry*d,f.rx*h),m=[p,p+Math.PI,g,g+Math.PI];for(let b of m){if(!Td(b,f.theta1,f.deltaTheta))continue;let x=vd(f,b);x.x<c.minX&&(c.minX=x.x),x.x>c.maxX&&(c.maxX=x.x),x.y<c.minY&&(c.minY=x.y),x.y>c.maxY&&(c.maxY=x.y)}return c}var kd="MmLlHhVvCcSsQqTtAaZz";function wn(t){return t>=48&&t<=57}function wd(t){return t===32||t===9||t===10||t===12||t===13}var $s=class{constructor(e){this.d=e}d;i=0;skipWsp(){for(;this.i<this.d.length&&wd(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&&kd.indexOf(e)>=0?(this.i++,e):null}nextIsNumber(){this.skipCommaWsp();let e=this.d.charCodeAt(this.i);return wn(e)||e===43||e===45||e===46}readNumber(){this.skipCommaWsp();let e=this.d,r=this.i,n=this.i,i=e.charCodeAt(n);(i===43||i===45)&&n++;let s=0;for(;n<e.length&&wn(e.charCodeAt(n));)n++,s++;if(e.charCodeAt(n)===46)for(n++;n<e.length&&wn(e.charCodeAt(n));)n++,s++;if(s===0)return null;let o=e.charCodeAt(n);if(o===101||o===69){let u=n+1,c=e.charCodeAt(u);(c===43||c===45)&&u++;let f=0;for(;u<e.length&&wn(e.charCodeAt(u));)u++,f++;f>0&&(n=u)}let a=Number.parseFloat(e.slice(r,n));return Number.isFinite(a)?(this.i=n,a):null}readFlag(){this.skipCommaWsp();let e=this.d[this.i];return e==="0"?(this.i++,!1):e==="1"?(this.i++,!0):null}};function Pn(t,e,r){e<t.minX&&(t.minX=e),e>t.maxX&&(t.maxX=e),r<t.minY&&(t.minY=r),r>t.maxY&&(t.maxY=r),t.any=!0}function ks(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 ro(t,e,r,n,i,s,o,a,u){let c=_n(e,n,s,a),f=_n(r,i,o,u);ks(t,{minX:c.min,maxX:c.max,minY:f.min,maxY:f.max})}function no(t,e,r,n,i,s,o){let a=Rn(e,n,s),u=Rn(r,i,o);ks(t,{minX:a.min,maxX:a.max,minY:u.min,maxY:u.max})}function ws(t){if(!t)return null;let e=new $s(t),r={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,any:!1},n=0,i=0,s=0,o=0,a=0,u=0,c=null,f="",d=!1,h=()=>r.any?{minX:r.minX,minY:r.minY,maxX:r.maxX,maxY:r.maxY}:null;for(;!e.atEnd();){let p=e.readCommand();if(p!==null)f=p;else if(f===""||f==="Z"||f==="z"||!e.nextIsNumber())break;if(!d){if(f!=="M"&&f!=="m")return null;d=!0}let g=f>="a"&&f<="z";switch(f){case"M":case"m":{let m=e.readNumber(),b=e.readNumber();if(m===null||b===null)return h();n=g?n+m:m,i=g?i+b:b,s=n,o=i,Pn(r,n,i),c=null,f=g?"l":"L";break}case"L":case"l":{let m=e.readNumber(),b=e.readNumber();if(m===null||b===null)return h();n=g?n+m:m,i=g?i+b:b,Pn(r,n,i),c=null;break}case"H":case"h":{let m=e.readNumber();if(m===null)return h();n=g?n+m:m,Pn(r,n,i),c=null;break}case"V":case"v":{let m=e.readNumber();if(m===null)return h();i=g?i+m:m,Pn(r,n,i),c=null;break}case"C":case"c":{let m=e.readNumber(),b=e.readNumber(),x=e.readNumber(),S=e.readNumber(),$=e.readNumber(),v=e.readNumber();if(m===null||b===null||x===null||S===null||$===null||v===null)return h();let k=g?n+m:m,P=g?i+b:b,T=g?n+x:x,w=g?i+S:S,R=g?n+$:$,F=g?i+v:v;ro(r,n,i,k,P,T,w,R,F),a=T,u=w,c="cubic",n=R,i=F;break}case"S":case"s":{let m=e.readNumber(),b=e.readNumber(),x=e.readNumber(),S=e.readNumber();if(m===null||b===null||x===null||S===null)return h();let $=c==="cubic"?2*n-a:n,v=c==="cubic"?2*i-u:i,k=g?n+m:m,P=g?i+b:b,T=g?n+x:x,w=g?i+S:S;ro(r,n,i,$,v,k,P,T,w),a=k,u=P,c="cubic",n=T,i=w;break}case"Q":case"q":{let m=e.readNumber(),b=e.readNumber(),x=e.readNumber(),S=e.readNumber();if(m===null||b===null||x===null||S===null)return h();let $=g?n+m:m,v=g?i+b:b,k=g?n+x:x,P=g?i+S:S;no(r,n,i,$,v,k,P),a=$,u=v,c="quad",n=k,i=P;break}case"T":case"t":{let m=e.readNumber(),b=e.readNumber();if(m===null||b===null)return h();let x=c==="quad"?2*n-a:n,S=c==="quad"?2*i-u:i,$=g?n+m:m,v=g?i+b:b;no(r,n,i,x,S,$,v),a=x,u=S,c="quad",n=$,i=v;break}case"A":case"a":{let m=e.readNumber(),b=e.readNumber(),x=e.readNumber(),S=e.readFlag(),$=e.readFlag(),v=e.readNumber(),k=e.readNumber();if(m===null||b===null||x===null||S===null||$===null||v===null||k===null)return h();let P=g?n+v:v,T=g?i+k:k;ks(r,Ts(n,i,m,b,x,S,$,P,T)),n=P,i=T,c=null;break}case"Z":case"z":{n=s,i=o,c=null;break}default:return h()}}return h()}function io(t,e,r=!1,n=.5,i){return t.length===0?null:ws(Fe(t,e,r,n,i))}function An(t,e){let r=be(t,e);return dt(t,{width:r.width,height:r.height,xmlDeclaration:e.xmlDeclaration??!1,indent:!0})}function Pd(t){return t==="class"?"className":t==="for"?"htmlFor":t.replace(/-([a-z])/g,(e,r)=>r.toUpperCase())}function so(t){return t.replace(/\s([a-z][a-z-]*?)=/g,(e,r)=>r.startsWith("data-")||r.startsWith("aria-")?e:` ${Pd(r)}=`)}function Mn(t,e){let r=e.componentName??"SvgComponent",n=be(t,e),i=e.indent??" ",s=t.shapes??[],o=e.typescript??!1,a=Array.isArray(t.library)?t.library:[],u=Ee(s,a),c=Se(s,a),f=u+c,d=f.length>0,h=s.map(g=>{let m=ee(g);return`${i}${i}${i}${so(m)}`}),p=[];p.push("import React from 'react';"),p.push(""),o?(p.push(`interface ${r}Props {`),p.push(`${i}className?: string;`),p.push(`${i}style?: React.CSSProperties;`),p.push("}"),p.push(""),p.push(`const ${r}: React.FC<${r}Props> = ({ className, style }) => {`)):p.push(`const ${r} = ({ className, style }) => {`),p.push(`${i}return (`),p.push(`${i}${i}<svg xmlns="http://www.w3.org/2000/svg" width="${n.width}" height="${n.height}" viewBox="0 0 ${n.width} ${n.height}" className={className} style={style}>`),d&&(p.push(`${i}${i}${i}<defs>`),p.push(`${i}${i}${i}${i}${so(f)}`),p.push(`${i}${i}${i}</defs>`));for(let g of h)p.push(g);return p.push(`${i}${i}</svg>`),p.push(`${i});`),p.push("};"),p.push(""),p.push(`export default ${r};`),p.push(""),p.join(`
|
|
14
|
-
`)}function
|
|
15
|
-
`)}var
|
|
16
|
-
`)}function
|
|
17
|
-
${
|
|
11
|
+
${a}`)}}return s}function Kc(n){return[...n].sort((e,t)=>e.id.localeCompare(t.id))}function ft(n){if(n==null)return n;if(Array.isArray(n))return n.map(ft);if(typeof n!="object")return n;let e={},t=Object.keys(n).sort();for(let r of t)e[r]=ft(n[r]);return e}function Xc(n){let e={};return e.id=n.id,e.type=n.type,e.state=ft(n.state),e}var Re=/\{\{\s*([\w.\-]+)\s*\}\}/g;function cr(n,e){return n.replace(Re,(t,r)=>{let i=e[r];return i!==void 0?String(i):t})}function pr(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)dr(i.state,t);if(r.documentMetadata){let i=r.documentMetadata;dr(i,t)}return r}function dr(n,e){for(let t of Object.keys(n)){let r=n[t];if(typeof r=="string"){if(Re.lastIndex=0,Re.test(r)){Re.lastIndex=0;let i=cr(r,e);if(Yc(r)){let s=Number(i);if(!isNaN(s)&&Zc(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"?(Re.lastIndex=0,Re.test(r[i])&&(Re.lastIndex=0,r[i]=cr(r[i],e))):r[i]!==null&&typeof r[i]=="object"&&dr(r[i],e);else r!==null&&typeof r=="object"&&dr(r,e)}}function Yc(n){return/^\s*\{\{\s*[\w.\-]+\s*\}\}\s*$/.test(n)}var qc=new Set(["x","y","width","height","radius","rx","ry","cx","cy","x1","y1","x2","y2","fontSize","borderWidth","cornerRadius","opacity","fillOpacity","strokeOpacity",...Nt,"letterSpacing","wordSpacing","lineHeight","sides","arms","innerRadiusPercent","armWidthPercent","teeth","toothDepthPercent","holeRadiusPercent","turns","thicknessPercent","direction","headWidthPercent","headLengthPercent","shaftWidthPercent","shiftAngle","dashLength","gapLength","textPathStartOffset","imageOpacity"]);function Zc(n){return qc.has(n)}function mr(n){let e=n.templateVariables??[],t=new Set(e.map(s=>s.name)),r=new Set;for(let s of n.shapes)fr(s.state,r);n.documentMetadata&&fr(n.documentMetadata,r);let i=[...r].filter(s=>!t.has(s)).sort();return{defined:[...e],undeclared:i}}function fr(n,e){for(let t of Object.values(n))if(typeof t=="string"){let r;for(Re.lastIndex=0;(r=Re.exec(t))!==null;)e.add(r[1])}else if(Array.isArray(t))for(let r of t)if(typeof r=="string"){let i;for(Re.lastIndex=0;(i=Re.exec(r))!==null;)e.add(i[1])}else r!==null&&typeof r=="object"&&fr(r,e);else t!==null&&typeof t=="object"&&fr(t,e)}function el(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 tl=3,nl=12;function rl(n){return n==null||!Number.isFinite(n)?3:n<0?0:n>12?12:Math.floor(n)}function gr(n,e){if(!Number.isFinite(n))return n;let t=Math.pow(10,e);return Math.round(n*t)/t}var Jc=/-?\d+(?:\.\d+)?(?:[eE][-+]?\d+)?/g;function As(n,e){return n.replace(Jc,t=>{let r=parseFloat(t);return Number.isFinite(r)?String(gr(r,e)):t})}var Qc=new Set(["rawTransform","strokeDasharray","filterX","filterY","filterWidth","filterHeight","cssClipPath"]),ed=new Set(["metadata","customMetadata","customAttrs","customData","bindings","richTextRuns","richTextData","cssMaskProperties","rawMetadata"]);function Ce(n,e,t){if(e==null)return e;if(typeof e=="number")return gr(e,t);if(typeof e=="string")return Qc.has(n)?As(e,t):e;if(typeof e=="boolean")return e;if(Array.isArray(e))return e.map(r=>Ce(n,r,t));if(typeof e=="object"){if(ed.has(n))return e;if(n==="symbolOverrides"){let i={};for(let[s,o]of Object.entries(e))i[s]=Ce("state",o,t);return i}let r={};for(let[i,s]of Object.entries(e))r[i]=Ce(i,s,t);return r}return e}function hr(n,e){return{id:n.id,type:n.type,state:Ce("state",n.state,e)}}function il(n,e){let t={...n,shapes:n.shapes.map(r=>hr(r,e)),viewboxes:n.viewboxes.map(r=>Ce("viewbox",r,e))};return n.guides&&(t.guides=n.guides.map(r=>Ce("guide",r,e))),n.measurements&&(t.measurements=n.measurements.map(r=>Ce("measurement",r,e))),n.animationTimeline&&(t.animationTimeline=Ce("animationTimeline",n.animationTimeline,e)),n.symbols&&(t.symbols=n.symbols.map(r=>({...r,shapes:r.shapes.map(i=>hr(i,e))}))),n.markers&&(t.markers=n.markers.map(r=>Ce("marker",r,e))),n.customPatterns&&(t.customPatterns=n.customPatterns.map(r=>Ce("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 br(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 Sr(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 xr(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 $r(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),v=-s+l+$,S=s-l-$,x={x:-s,y:-s},k={x:s,y:-s},w={x:s,y:s},T={x:-s,y:s},P;if(p>=m&&f>0){let N=Math.max(v,Math.min(S,g.y)),B={x:s,y:N-l},D={x:s,y:N+l};P=[x,k,B,b,D,w,T]}else if(p>=m&&f<=0){let N=Math.max(v,Math.min(S,g.y)),B={x:-s,y:N+l},D={x:-s,y:N-l};P=[x,k,w,T,B,b,D]}else if(d<0){let N=Math.max(v,Math.min(S,g.x)),B={x:N-l,y:-s},D={x:N+l,y:-s};P=[x,B,b,D,k,w,T]}else{let N=Math.max(v,Math.min(S,g.x)),B={x:N+l,y:s},D={x:N-l,y:s};P=[x,k,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 vr(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,v=0;g>0&&g<l-1&&(v=g%2===1?o:-o),c.push({x:v,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],v=c[g+1],S=$.x-b.x,x=$.y-b.y,k=Math.hypot(S,x)||1,w=S/k,T=x/k,P=v.x-$.x,R=v.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,re;K<1e-6?(C=-T,re=w):(C=-L/K,re=D/K),f.push({x:$.x-C*a,y:$.y-re*a}),d.push({x:$.x+C*a,y:$.y+re*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 kr(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 k=Math.cos(r*Math.PI/180),w=Math.sin(r*Math.PI/180);return m.map(T=>({x:T.x*k-T.y*w,y:T.x*w+T.y*k}))})(),[g,b,$,v,S,x]=h;return`M ${g.x} ${g.y} C ${b.x} ${b.y} ${$.x} ${$.y} ${v.x} ${v.y} C ${S.x} ${S.y} ${x.x} ${x.y} ${g.x} ${g.y} Z`}function Tr(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)),re=P.x+K/L*B,ee=P.y+K/L*D,q=-D/L,me=B/L,Y={x:re+q*C,y:ee+me*C},W={x:re-q*C,y:ee-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,v=[];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,re=B-K/2,ee={x:P.x+R*Math.cos(C),y:P.y+R*Math.sin(C)},q={x:P.x+R*Math.cos(re),y:P.y+R*Math.sin(re)},Y=ee.x*ee.x+ee.y*ee.y>q.x*q.x+q.y*q.y?L:-K;for(let W=0;W<$;W++){let fe=W/$,he=B+fe*Y;v.push({x:P.x+R*Math.cos(he),y:P.y+R*Math.sin(he)})}}let S=0;for(let T of v){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 v)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}},k=v.map(x),w=`M ${k[0].x} ${k[0].y}`;for(let T=1;T<k.length;T++)w+=` L ${k[T].x} ${k[T].y}`;return w+=" Z",w}function Ae(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 wr(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 Pr(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,v=c*(b*l)+s/2,S=s/2;d.push({x:(v+S*.3)*Math.cos($),y:(v+S*.3)*Math.sin($)}),p.push({x:Math.max(0,v-S*.3)*Math.cos($),y:Math.max(0,v-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 td=.2;function Cs(n,e,t,r=0){let i=e*(t/100),s=e,o=e-i,a=2*Math.PI/n,l=a*td/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 _r(n,e,t,r=0,i=0,s="evenodd",o=0){let a=Cs(n,e,t,o),l=Math.min(r,e*.1),c=Ae(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 Rr(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 v=`M${n+c},${e}`;return v+=` L${n+t-f},${e}`,v+=yr(h,f,n+t,e,"tr"),v+=` L${n+t},${e+r-d}`,v+=yr(g,d,n+t,e+r,"br"),v+=` L${n+p},${e+r}`,v+=yr(b,p,n,e+r,"bl"),v+=` L${n},${e+c}`,v+=yr(m,c,n,e,"tl"),v+=" Z",v}function yr(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 Ar(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 qe(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 sd(n,t,r);case"BASIS":case"basis":return ad(n,t);case"ARC":case"arc":return i&&i.length>0?nd(n,t,i):fn(n,t,"CUBIC");case"LINEAR":case"linear":return fn(n,t,"LINEAR");case"QUADRATIC":case"quadratic":return fn(n,t,"QUADRATIC");case"CUBIC":case"cubic":return fn(n,t,"CUBIC");default:return fn(n,t)}}function nd(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 fn(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+=Is(l,d,d.segmentType,s,o,t),r+=" Z"}r+=` M ${c.x} ${c.y}`,i=a+1,s=null,o=null;continue}r+=Is(l,c,c.segmentType,s,o,t);let f=id(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+=Is(a,l,l.segmentType,s,o,t)),r+=" Z"}return r}var rd=.001;function It(n,e){return Math.abs(n-e)<rd}function id(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 Is(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")&&It(n.y,e.y)?` H ${e.x}`:(o==="VERTICAL"||o==="LINEAR")&&It(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&&It(c.x,2*n.x-i.x)&&It(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&&It(n.handleOut.x,2*n.x-n.handleIn.x)&&It(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 sd(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),v=Math.pow(m,2*r),S=Math.pow(p,2*r),x=Math.pow(h,2*r),k,w,T,P;m<1e-8?(k=c.x,w=c.y):(k=(v*f.x-S*l.x+(2*v+3*g*b+S)*c.x)/(3*g*(g+b)),w=(v*f.y-S*l.y+(2*v+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 ${k} ${w} ${T} ${P} ${f.x} ${f.y}`}return e&&(s+=" Z"),s}function ad(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+=Ms(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+=Ms(r[s],r[s+1],r[s+2]);return i+=Ms(r[t-2],r[t-1],r[t-1]),i+=` L ${r[t-1].x} ${r[t-1].y}`,i}function Ms(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 Mt(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 od=[["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 Z(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function ld(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 Ir(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,k=t.ry??t.cornerRadius??0;(x>0||k>0)&&(e.set("rx",String(x)),e.set("ry",String(k)))}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=od.map(([k,w])=>{let T=typeof t[k]=="string"?String(t[k]).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=ld(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=Mt(f,d,p);m&&(e.set("stroke-dasharray",m),f==="dotted"&&e.set("stroke-linecap","round"));let h=ud(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,v=r.endEndpoint;$&&$!=="none"&&e.set("marker-start",`url(#line-marker-${$})`),v&&v!=="none"&&e.set("marker-end",`url(#line-marker-${v})`);let S=r.metadata;return S&&(S.role&&e.set("role",S.role),S.ariaLabel&&e.set("aria-label",S.ariaLabel)),e}function sl(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 ud(n){return At(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}="${Z(String(e))}"`}function Cr(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 cd(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 dd(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 fd(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 pd(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 al(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 ol(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 ll(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 md(n,e,t){return`<feDiffuseLighting${u("in",e)}${u("surfaceScale",n.surfaceScale)}${u("diffuseConstant",n.diffuseConstant)}${u("lighting-color",n.color)}${u("result",t)}>`+ll(n.lightSource)+"</feDiffuseLighting>"}function hd(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)}>`+ll(n.lightSource)+"</feSpecularLighting>"}function gd(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 yd(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 bd(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 Sd(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 xd(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 $d(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 vd(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 kd(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 Td(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 wd(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 Pd(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 _d(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 Rd(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 Ad(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 Id(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 Md(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 Cd(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 Dd(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(($,v)=>$*(1-r)+b[v]*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 Fd(n,e,t){let{shadowColor:r,highlightColor:i}=n,s=Cr(r),o=Cr(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 Ed(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((v,S)=>v*(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 Od(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 Ld(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 Nd(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 Bd(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 zd(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 Gd(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 Vd(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 Ud(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 Wd(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}=Cr(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 Hd(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}=Cr(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 Dr(n){switch(n.type){case"feBlend":return jd(n);case"feColorMatrix":return Kd(n);case"feComponentTransfer":return Xd(n);case"feComposite":return Yd(n);case"feConvolveMatrix":return qd(n);case"feDiffuseLighting":return Zd(n);case"feSpecularLighting":return Jd(n);case"feDisplacementMap":return Qd(n);case"feDropShadow":return ef(n);case"feFlood":return tf(n);case"feGaussianBlur":return nf(n);case"feImage":return rf(n);case"feMerge":return sf(n);case"feMorphology":return af(n);case"feOffset":return of(n);case"feTile":return lf(n);case"feTurbulence":return uf(n)}}function ue(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 ce(n){return n.animations&&n.animations.length>0?n.animations.join(""):""}function jd(n){let e=`<feBlend${ue(n)}${u("in2",n.in2)}${u("mode",n.mode)}`;n.noComposite&&(e+=' no-composite="no-composite"');let t=ce(n);return t?`${e}>${t}</feBlend>`:`${e}/>`}function Kd(n){let e=`<feColorMatrix${ue(n)}${u("type",n.matrixType)}${u("values",n.values)}`,t=ce(n);return t?`${e}>${t}</feColorMatrix>`:`${e}/>`}function Mr(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 Xd(n){let e="";return e+=Mr("R",n.funcR),e+=Mr("G",n.funcG),e+=Mr("B",n.funcB),e+=Mr("A",n.funcA),e+=ce(n),`<feComponentTransfer${ue(n)}>${e}</feComponentTransfer>`}function Yd(n){let e=`<feComposite${ue(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=ce(n);return t?`${e}>${t}</feComposite>`:`${e}/>`}function qd(n){let e=`<feConvolveMatrix${ue(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=ce(n);return t?`${e}>${t}</feConvolveMatrix>`:`${e}/>`}function ul(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 Zd(n){let e=`<feDiffuseLighting${ue(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+=ul(n.lightSource)),t+=ce(n),`${e}>${t}</feDiffuseLighting>`}function Jd(n){let e=`<feSpecularLighting${ue(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+=ul(n.lightSource)),t+=ce(n),`${e}>${t}</feSpecularLighting>`}function Qd(n){let e=`<feDisplacementMap${ue(n)}`;e+=u("in2",n.in2),e+=u("scale",n.scale),e+=u("xChannelSelector",n.xChannelSelector),e+=u("yChannelSelector",n.yChannelSelector);let t=ce(n);return t?`${e}>${t}</feDisplacementMap>`:`${e}/>`}function ef(n){let e=`<feDropShadow${ue(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=ce(n);return t?`${e}>${t}</feDropShadow>`:`${e}/>`}function tf(n){let e=`<feFlood${ue(n)}${u("flood-color",n.floodColor)}${u("flood-opacity",n.floodOpacity)}`,t=ce(n);return t?`${e}>${t}</feFlood>`:`${e}/>`}function nf(n){let e=`<feGaussianBlur${ue(n)}${u("stdDeviation",n.stdDeviation)}${u("edgeMode",n.edgeMode)}`,t=ce(n);return t?`${e}>${t}</feGaussianBlur>`:`${e}/>`}function rf(n){let e=`<feImage${ue(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=ce(n);return t?`${e}>${t}</feImage>`:`${e}/>`}function sf(n){let e="";for(let t of n.nodes)e+=`<feMergeNode${u("in",t.in)}/>`;return e+=ce(n),`<feMerge${ue(n)}>${e}</feMerge>`}function af(n){let e=`<feMorphology${ue(n)}${u("operator",n.operator)}${u("radius",n.radius)}`,t=ce(n);return t?`${e}>${t}</feMorphology>`:`${e}/>`}function of(n){let e=`<feOffset${ue(n)}${u("dx",n.dx)}${u("dy",n.dy)}`,t=ce(n);return t?`${e}>${t}</feOffset>`:`${e}/>`}function lf(n){let e=`<feTile${ue(n)}`,t=ce(n);return t?`${e}>${t}</feTile>`:`${e}/>`}function uf(n){let e=`<feTurbulence${ue(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=ce(n);return t?`${e}>${t}</feTurbulence>`:`${e}/>`}function Ds(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>${Z(e.filterTitle)}</title>`),e.filterDescription&&(t+=`<desc>${Z(e.filterDescription)}</desc>`);for(let r of e.primitives)t+=Dr(r);if(e.filterAnimations)for(let r of e.filterAnimations)t+=r;return t+="</filter>",t}function Fs(n,e,t,r){switch(n.type){case"drop-shadow":return cd(n,e,t);case"inner-shadow":return dd(n,e,t);case"gaussian-blur":return fd(n,e,t);case"motion-blur":return pd(n,e,t);case"point-light":{let i=n;return al(r?{...i,x:i.x+r.x,y:i.y+r.y}:i,e,t)}case"spot-light":{let i=n;return ol(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 md(n,e,t);case"specular-lighting":return hd(n,e,t);case"outline":return gd(n,e,t);case"sharpen":return yd(n,e,t);case"pixelate":return bd(n,e,t);case"warp":return Sd(n,e,t);case"morphology":return xd(n,e,t);case"contouring-discrete":return $d(n,e,t);case"contouring-table":return vd(n,e,t);case"round-edges":return kd(n,e,t);case"grayscale":return Td(n,e,t);case"channel-painter":return wd(n,e,t);case"brightness":return Pd(n,e,t);case"contrast":return _d(n,e,t);case"opacity":return Rd(n,e,t);case"invert":return Ad(n,e,t);case"hue-rotate":return Id(n,e,t);case"saturate":return Md(n,e,t);case"black-and-white":return Cd(n,e,t);case"sepia":return Dd(n,e,t);case"duotone":return Fd(n,e,t);case"xray":return Ed(n,e,t);case"noise":return Od(n,e,t);case"emboss":return Ld(n,e,t);case"film-grain":return Nd(n,e,t);case"watercolor":return Bd(n,e,t);case"gouache":return zd(n,e,t);case"ink-blot":return Gd(n,e,t);case"crumpled-plastic":return Vd(n,e,t);case"riddled":return Ud(n,e,t);case"glow":return Wd(n,e,t);case"inner-glow":return Hd(n,e,t);case"raw-svg":return n.svgContent;case"svg-primitive-chain":return n.primitives.map(Dr).join("");default:return H(e,t)}}function cf(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 Es(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,k=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",k)}${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 Ds(n,x)}let a=r.some(x=>x.type==="gaussian-blur"&&x.quality==="high"||x.type==="motion-blur"&&x.quality==="high"),l=cf(r),c=l?a?"-200%":"-100%":"-10%",f=l?a?"500%":"300%":"120%",d="",p="SourceGraphic",m=0;for(let x of r){let k=`result${m++}`;d+=Fs(x,p,k),p=k}let h=t.filterUnits??"objectBoundingBox",g=t.primitiveUnits??"userSpaceOnUse",b=t.x??c,$=t.y??c,v=t.width??f,S=t.height??f;return`<filter${u("id",n)}${u("x",b)}${u("y",$)}${u("width",v)}${u("height",S)}${u("filterUnits",h)}${u("primitiveUnits",g)}${i}>${d}</filter>`}function cl(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+=Es(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 Fr(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(#${Z(s)})`).join(" ")}"`:` filter="url(#filter-${Z(n)})"`}function df(n){if(n instanceof Map)return n;let e=new Map;for(let t of n)e.set(t.id,t);return e}function ff(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 dl(n,e,t,r){let i=df(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 ff(p))c(m)}}var pf=[],mf=[];function hn(n,e,t){dl(n,mf,e,t)}function fl(n,e,t){dl(pf,n,e,t)}function pl(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(mn(o));let a=t.endEndpoint;typeof a=="string"&&a&&a!=="none"&&e(mn(a))}function mn(n){return`line-marker-${n}`}function ml(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 gn(n,e=[]){let t=new Set,r=new Set;return hn(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 hl(n,e){let{ids:t,legacyEndpoints:r}=gn(n,e);for(let i of r)t.add(mn(i));return t}function yn(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 hf(n){let e=Object.entries(n.attrs).map(([t,r])=>` ${t}="${r}"`).join("");return`<${n.tag}${e}/>`}function Er(n,e,t,r,i){let s=10*e,o="";o+=`<rect width="${s}" height="${s}" fill="${r}"/>`;let a=yn(n,s,t,i);for(let l of a)o+=hf(l);return{svgContent:o,width:s,height:s}}var bn="0 0 10 10",Or=6,Lr=6;function pt(){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 Os={"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"},gf={"mkr-builtin-arrow":"Arrow","mkr-builtin-open-arrow":"Open Arrow","mkr-builtin-circle":"Circle","mkr-builtin-diamond":"Diamond","mkr-builtin-square":"Square"};function gl(){return pt().map(n=>{let e=Os[n.id]??n.id;return{kind:"marker",id:e,name:gf[e]??e,viewBox:bn,refX:n.refX,refY:n.refY,markerWidth:6,markerHeight:6,markerUnits:"strokeWidth",orient:"auto-start-reverse",shapes:[],builtIn:!0}})}function yf(n){return n.replace(/[^a-zA-Z0-9_-]/g,"_")}function bf(n){let e=n.state.symbolOverrides;return!!e&&Object.keys(e).length>0}function Ct(n){let e=n.state.symbolId??"",t=n.state.variantKey??"";return bf(n)?`${e}--ovr-${n.id}`:t?`${e}--${yf(t)}`:e}function Nr(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 Sn(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 Sf=[["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 Dt(n){return Sf.map(([e,t])=>{let r=n[e],i=typeof r=="string"?r.trim():"";return i?`${t}: ${i}`:""}).filter(Boolean).join("; ")}function Br(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=Dt(n);i&&i!==Dt(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}="${Z(String(e))}"`}function xf(n){let e=n.map(t=>(t??"").trim().replace(/;$/,"")).filter(Boolean).join("; ");return e?y("style",e):""}function $f(n,e){return typeof e=="number"&&e>0?`${n}: ${e}px`:""}function vf(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 yl(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 bl(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 kf(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 Fe(n,e){return At(n,e)}function Tf(n,e,t){return ks(n,e,t)}function wf(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 Pf(n){if(typeof n.strokeDasharray=="string")return n.strokeDasharray;let e=n.lineStyle??"solid",t=n.dashLength??8,r=n.gapLength??4;return Mt(e,t,r)}function zr(n,e){let t=n[e];return t!==void 0?t:n.extra?.[e]}function _f(n){let e=n.fillType;return e||(n.fillGradient?n.fillGradient.r!==void 0?"radial-gradient":"linear-gradient":zr(n,"linearGradient")?"linear-gradient":zr(n,"radialGradient")?"radial-gradient":"solid")}function Rf(n){return n.fillGradient??zr(n,"linearGradient")??zr(n,"radialGradient")??void 0}function Ie(n,e){let t=y("data-shape-id",e),r=_f(n),i=Rf(n);if(r==="none")t+=y("fill","none");else if(r==="linear-gradient"||r==="radial-gradient"){let P=n.fillLibraryId??i?.id;t+=y("fill",`url(#${P??`gradient-fill-${e}`})`)}else if(r==="pattern"){let P=n.fillLibraryId??i?.id;t+=y("fill",`url(#${P??`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 P=n.strokeLibraryId??c?.id;t+=y("stroke",`url(#${P??`gradient-stroke-${e}`})`)}else if(l==="pattern"){let P=n.strokeLibraryId??c?.id;t+=y("stroke",`url(#${P??`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=Pf(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 v=n.shapeRendering;v&&v!=="auto"&&(t+=y("shape-rendering",v)),t+=Fr(e,n.filters,n.filterLibraryIds);let S=n.systemLanguage;S&&(t+=y("systemLanguage",S));let x=n.requiredExtensions;x&&(t+=y("requiredExtensions",x));let k=n.vectorEffect;k&&k!=="none"&&(t+=y("vector-effect",k));let w=n.visibility;w&&w!=="visible"&&(t+=y("visibility",w));let T=n.metadata;return T&&(T.role&&(t+=y("role",T.role)),T.ariaLabel&&(t+=y("aria-label",T.ariaLabel))),t}function Af(n){let e=n.metadata;if(!e)return"";let t="";return e.title&&(t+=`<title>${Z(e.title)}</title>`),e.description&&(t+=`<desc>${Z(e.description)}</desc>`),t}function If(n,e){let t=Af(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 Ls(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 Ns(n){let e=n.state,t=e.x??0,r=e.y??0,i=e.radius??50,s=Fe(e,{x:t,y:r});return`<circle${y("cx",t)}${y("cy",r)}${y("r",i)}${Ie(e,n.id)}${s?y("transform",s):""}/>`}function Bs(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=Fe(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):""}${Ie(e,n.id)}${a?y("transform",a):""}/>`}function zs(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=Fe(e,p);if(f!=="round"||d==="non-uniform"){let h=Rr(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)}${Ie(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)}`:""}${Ie(e,n.id)}${m?y("transform",m):""}/>`}function Gs(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=Fe(e,o),l={...e,fillType:"none"};return`<line${y("x1",t)}${y("y1",r)}${y("x2",i)}${y("y2",s)}${Ie(l,n.id)}${Ls(e)}${a?y("transform",a):""}/>`}function Vs(n){let e=n.state,t=e.x??0,r=e.y??0,i=Sn(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=wf(e.textDecoration),d=e.letterSpacing,p=e.wordSpacing,m=e.lineHeight??1.25,g=Fe(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 v=e.dominantBaseline;v&&v!=="auto"&&(b+=y("dominant-baseline",v));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 k=e.textDirection;k&&k!=="ltr"&&(b+=y("direction",k));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=Dt(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+=xf([P,M,$f("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+=Ie(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}`,re=e.textPathMethod,ee=e.textPathSpacing,q=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 fe=D.length-1;fe>0;fe--){let he=D[fe],Te=D[fe-1],ve=he.handleIn??he,gt=Te.handleOut??Te;Y+=` C ${ve.x} ${ve.y}, ${gt.x} ${gt.y}, ${Te.x} ${Te.y}`}}else{Y=`M ${D[0].x} ${D[0].y}`;for(let W=0;W<D.length-1;W++){let fe=D[W],he=D[W+1],Te=fe.handleOut??fe,ve=he.handleIn??he;Y+=` C ${Te.x} ${Te.y}, ${ve.x} ${ve.y}, ${he.x} ${he.y}`}}return`<defs><path id="${Z(C)}"${y("d",Y)} fill="none"/></defs><text${b}><textPath href="#${Z(C)}"${y("startOffset",`${L}%`)}${y("method",re)}${y("spacing",ee)}${y("lengthAdjust",q)}${y("textLength",me)}>${Z(i)}</textPath></text>`}if(e.charOffsets&&Array.isArray(e.charOffsets)&&e.charOffsets.length>0){let D=e.charOffsets.map(vf),L=i.split(`
|
|
12
|
+
`),K=e.linePositions??[],C=s*m,re="",ee=0;return L.forEach((q,me)=>{let Y=Array.from(q).length,W=D.slice(ee,ee+Y),fe=K[me],he=fe?t+fe.x:me>0?t:NaN,Te=fe?fe.dy:me>0?C:NaN,ve="",gt=yl(W,"x");if(Number.isFinite(he)||gt.length>0){let Wi=gt.length>0?gt.slice():[];Number.isFinite(he)&&(Wi[0]=Wi[0]??he),ve+=y("x",Wi.join(" "))}let ka=yl(W,"y");ka.length>0&&(ve+=y("y",ka.join(" ")));let Ta=bl(W,"dx");Ta.length>0&&(ve+=y("dx",Ta.join(" ")));let wa=bl(W,"dy"),je=wa.length>0||Number.isFinite(Te)?wa.slice():[];for(Number.isFinite(Te)&&(je[0]=(je[0]??0)+Te);je.length>0&&je[je.length-1]===0;)je.pop();je.length>0&&(ve+=y("dy",je.join(" ")));let Pa=kf(W);Pa.length>0&&(ve+=y("rotate",Pa.join(" "))),re+=`<tspan${ve}>${Z(q)}</tspan>`,ee+=Y+1}),`<text${b}>${re}</text>`}let B=qn(e);if(B){let D=Ve(B),L=e.linePositions,K=s*D.lineHeight,C="";return D.lines.forEach((re,ee)=>{re.segments.forEach((q,me)=>{let Y="";if(me===0){let W=L?.[ee];W?((Math.abs(W.x)>.001||ee>0)&&(Y+=y("x",t+W.x)),(Math.abs(W.dy)>.001||ee>0)&&(Y+=y("dy",W.dy))):ee>0&&(Y+=y("x",t),Y+=y("dy",`${K}px`))}for(let{name:W,value:fe}of Br(q.style,D.baseStyle))Y+=y(W,fe);Y+=' xml:space="preserve"',C+=`<tspan${Y}>${Z(Sn(q.text,q.style.textTransform))}</tspan>`})}),`<text${b}>${C}</text>`}return`<text${b}>${Z(i)}</text>`}function Us(n){let e=n.state,t=e.pathPoints??[],r=e.pathCurveType??"CUBIC",i=e.pathClosed??!1,s=e.pathTension??.5,o=e.pathArcParams,a=qe(t,r,i,s,o),l=t.length>0?e.customPivot??{x:t[0].x,y:t[0].y}:void 0,c=l?Fe(e,l):null;return`<path${y("d",a)}${Ie(e,n.id)}${Ls(e)}${c?y("transform",c):""}/>`}function Ws(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?Fe(e,s):null;return`<${r?"polygon":"polyline"}${y("points",i)}${Ie(e,n.id)}${Ls(e)}${o?y("transform",o):""}/>`}function Hs(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=Fe(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):""}${Ie(e,n.id)}${f?y("transform",f):""}/>`}function Gr(n){return!n||n.length===0?"":n.map(e=>de(e)).join("")}function Mf(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),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+=y("data-shape-id",n.id),i+=">",i+=Gr(e.children),i+="</a>",i}function Cf(n){let e=n.state,t="<switch";return t+=y("data-shape-id",n.id),t+=">",t+=Gr(e.children),t+="</switch>",t}function Df(n){let e=n.state,t=Fe(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+=Gr(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 Ef(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+=Gr(e.children),d+="</svg>",d}function Of(n){let e=n.state,t=e.targetShapeId;if(!t)return`<!-- shape-reference ${Z(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 js(n){let e=n.state,t=Ct(n),r=e.x??0,i=e.y??0,s=e.width??100,o=e.height??100;return`<use href="#${Z(t)}" x="${r}" y="${i}" width="${s}" height="${o}"/>`}function Lf(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)),e.systemLanguage&&(p+=y("systemLanguage",e.systemLanguage)),e.requiredExtensions&&(p+=y("requiredExtensions",e.requiredExtensions)),f!==void 0&&f<1&&(p+=y("opacity",f)),p+=">",p+=d,p+="</foreignObject>",p}function Ks(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=Fe(e,o),l=Ar(n.type,t,r,i,s,{slantPercent:e.slantPercent,topWidthPercent:e.topWidthPercent,capHeightPercent:e.capHeightPercent,waveAmplitudePercent:e.waveAmplitudePercent});return`<path${y("d",l)}${Ie(e,n.id)}${a?y("transform",a):""}/>`}function Xs(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=Tf(e,t,r),c="";switch(n.type){case"triangle":c=Ae(pn(3,i,o),s,i);break;case"ngon":{let d=e.sides??6;c=Ae(pn(d,i,o),s,i);break}case"star":{let d=e.arms??5,p=e.innerRadiusPercent??50;c=Ae(br(d,i,p,o),s,i);break}case"cross":{let d=e.armWidthPercent??40;c=Ae(Sr(i,d,o),s,i);break}case"ring":{let d=e.innerRadiusPercent??50;c=wr(i,d,a);break}case"spiral":{let d=e.turns??3,p=e.thicknessPercent??20,m=e.spiralDirection??1;c=Pr(i,d,p,m,o);break}case"gear":{let d=e.teeth??8,p=e.toothDepthPercent??30,m=e.holeRadiusPercent??0;c=_r(d,i,p,s,m,a,o);break}case"arrow":{let d=e.headWidthPercent??100,p=e.headLengthPercent??30,m=e.shaftWidthPercent??40;c=Ae(xr(i,d,p,m,o),s,i);break}case"speechBubble":{let d=e.tailAngleDeg??45,p=e.tailLengthPercent??40,m=e.tailWidthPercent??25;c=Ae($r(i,d,p,m,o),s,i);break}case"lightning":{let d=e.boltSegments??3,p=e.boltJaggednessPercent??40,m=e.boltWidthPercent??30;c=Ae(vr(i,d,p,m,o),s,i);break}case"heart":{let d=e.lobeRadiusPercent??50,p=e.cleftDepthPercent??25;c=kr(i,d,p,o);break}case"cloud":{let d=e.cloudBumps??5,p=e.cloudPuffinessPercent??60;c=Tr(i,d,p,o);break}default:return`<!-- unsupported polygon shape: ${Z(n.type)} -->`}let f="";return(n.type==="ring"||n.type==="gear")&&(f=y("fill-rule",a)),`<path${y("d",c)}${f}${Ie(e,n.id)}${y("transform",l)}/>`}function de(n){let e;switch(n.type){case"circle":e=Ns(n);break;case"ellipse":e=Bs(n);break;case"rectangle":case"square":e=zs(n);break;case"line":e=Gs(n);break;case"text":e=Vs(n);break;case"path":e=Us(n);break;case"polyline":e=Ws(n);break;case"image":e=Hs(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=Xs(n);break;case"diamond":case"parallelogram":case"trapezoid":case"terminator":case"cylinder":case"document-shape":e=Ks(n);break;case"hyperlink":e=Mf(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=Ef(n);break;case"shape-reference":e=Of(n);break;case"symbol-instance":e=js(n);break;case"audio":case"video":e=Lf(n);break;default:return`<!-- unsupported shape type: ${Z(n.type)} -->`}return If(e,n.state)}function Sl(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 xl(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 $l(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+=Nf(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 Nf(n,e,t){return yn(n,e,t).map(i=>{let s=Object.entries(i.attrs).map(([o,a])=>y(o,a)).join("");return`<${i.tag}${s}/>`}).join("")}function Ee(n,e=[]){let t=Array.isArray(n)?gn(n,e):n;if(t.ids.size===0&&t.legacyEndpoints.size===0)return"";let r="",i=pt();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",bn)}${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 He=n=>n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),Ys=["linear-gradient","radial-gradient","pattern","filter","marker","symbol"];function qs(n){switch(n.kind){case"symbol":return Zs(n);case"marker":return Js(n);case"linear-gradient":return Qs(n);case"radial-gradient":return ea(n);case"pattern":return ta(n);case"filter":return na(n)}}function Zs(n){let e=n.shapes.map(i=>de(i)).join(""),t=n.viewBox?` viewBox="${He(n.viewBox)}"`:"",r=n.overflow?` overflow="${He(n.overflow)}"`:"";return`<symbol id="${He(n.id)}"${t}${r}>${e}</symbol>`}function Js(n){let e;if(n.builtIn){let s=pt().find(o=>n.id.includes(o.id)||n.id===o.id);if(s){let o=Object.entries(s.element.attrs).map(([a,l])=>` ${a}="${He(String(l))}"`).join("");e=`<${s.element.tag}${o}/>`}else e=""}else e=n.shapes.map(s=>de(s)).join("");let t=typeof n.orient=="number"?String(n.orient):n.orient,r=n.viewBox?` viewBox="${He(n.viewBox)}"`:"",i=n.overflow?` overflow="${He(n.overflow)}"`:"";return`<marker id="${He(n.id)}"${r} refX="${n.refX}" refY="${n.refY}" markerWidth="${n.markerWidth}" markerHeight="${n.markerHeight}" markerUnits="${He(n.markerUnits)}" orient="${He(t)}"${i}>${e}</marker>`}function Qs(n){let e={...n.gradient,type:"linear-gradient",id:n.id};return Sl(n.id,e)}function ea(n){let e={...n.gradient,type:"radial-gradient",id:n.id};return xl(n.id,e)}function ta(n){let e={...n.pattern,type:"pattern",id:n.id};return $l(n.id,e)}function na(n){return Es(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 xn(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 Ys){let i=e.get(r);if(i)for(let s of i)t+=qs(s)}return t}function Ze(n,e){let t=$n(n,e);return t.length===0?"":xn(t)}function $n(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 hn(n,e,a),Array.from(r.values())}function ra(n){return n.easing==="custom-bezier"&&n.customBezier?n.customBezier:Mn[n.easing]??null}function ia(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 sa(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 be(n){return!Number.isFinite(n)||Math.abs(n)<1e-9?"0":Math.abs(n-1)<1e-9?"1":parseFloat(n.toFixed(6)).toString()}function Ur([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 aa(n){return n.length>0&&n.every(e=>e==="0 0 1 1")}function vn(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 Wr(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 Qe(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 mt(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 Hr(n){return n.keyframes.length===1&&n.cycleDuration===void 0}function jr(n){return n.calcMode!=="discrete"?!1:n.sourceSmilElement==="set"?!0:!n.sourceSmilElement&&!n.cycleInfinite&&n.keyframes.every(e=>e.easing!=="steps")}function Kr(n,e){if(e<=0)return mt(n);if(mt(n)==="indefinite")return"indefinite";let t=n.keyframes[e]?.time??0;return t!==0?`${t}s`:""}function Xr(n){return n.cycleInfinite?"indefinite":n.cycleRepeats&&n.cycleRepeats>1?String(n.cycleRepeats):null}function ht(n){return n.cycleInfinite||n.fill==="remove"?null:"freeze"}function Yr(n){return n.additive==="sum"?"sum":null}function qr(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 Bf(n){let e=t=>Math.max(0,Math.min(1,t));return[n[0],e(n[1]),n[2],e(n[3])]}function zf(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 Gf(n,e,t,r,i,s){let o=typeof n.value=="number"&&typeof e.value=="number",a=Je(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 v=b[$],S=n.time+(e.time-n.time)*v.position,x=n.value+(e.value-n.value)*v.value;r.push(x),i.push(be(t(S))),s.push("0 0 1 1")}return}r.push(a),i.push(be(t(e.time))),s.push("0 0 1 1");return}if(e.easing==="steps"){r.push(a),i.push(be(t(e.time))),s.push("0 0 1 1");return}let l=ra(e);if(!l){r.push(a),i.push(be(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(be(t(e.time))),s.push(Ur(l));return}if(!o){r.push(a),i.push(be(t(e.time))),s.push(Ur(Bf(l)));return}let p=zf(l),m=n.value,h=e.value,g=e.time-n.time;for(let b of p){let $=ia(l[0],l[1],l[2],l[3],b),v=n.time+g*b,S=m+(h-m)*$;r.push(S),i.push(be(t(v))),s.push("0 0 1 1")}}function Je(n){return Array.isArray(n)?n.join(" "):n}function Vf(n,e,t){let r=[],{count:i,position:s}=t,o=e.time-n.time,a=Je(n.value),l=Je(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 Uf(n,e){let t=[],r=[],i=(s,o)=>{t.push(s),r.push(be(e(o)))};i(Je(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=Vf(o,a,a.stepsParams);for(let c of l)i(c.value,c.time)}else i(Je(a.value),a.time)}return{values:t,keyTimes:r}}function Vr(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=>be(1-parseFloat(l))),a=t.slice().reverse().map(sa);return{values:[...n,...s],keyTimes:[...e,...o],keySplines:[...t,...a],calcMode:r}}function et(n){let e=n.keyframes;if(e.length===0)return{values:[],keyTimes:[],keySplines:[],calcMode:"spline"};let t=Qe(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}=Uf(e,i);return Vr(c,f,[],"discrete",n)}if(n.calcMode==="discrete"){let c=e.map(d=>Je(d.value)),f=e.map(d=>be(i(d.time)));return Vr(c,f,[],"discrete",n)}if(n.calcMode==="paced"){let c=e.map(d=>Je(d.value)),f=e.map(d=>be(i(d.time)));return Vr(c,f,[],"paced",n)}let o=[Je(e[0].value)],a=[be(i(e[0].time))],l=[];for(let c=1;c<e.length;c++)Gf(e[c-1],e[c],i,o,a,l);return Vr(o,a,l,"spline",n)}function kn(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&&!aa(n.keySplines);return vn(n.keyTimes)||(r.keyTimes=n.keyTimes.join(";")),i&&(r.calcMode="spline",r.keySplines=n.keySplines.join(";")),r}function oa(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 Zr(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)||!oa(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 Jr(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 kl={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"},Tl=new Set(["transformMatrix","rotation","skewX","skewY"]),wl=new Set(["translateX","translateY","scaleX","scaleY"]);function Qr(n){return n.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function j(n,e){return e==null?"":` ${n}="${Qr(e)}"`}function la(n,e){let t=kn(n,e);return j("keyTimes",t.keyTimes)+j("calcMode",t.calcMode)+j("keySplines",t.keySplines)}function ei(n,e){return j("dur",`${e}s`)+j("begin",mt(n)||null)+j("repeatCount",Xr(n))}function Wf(n){let e=kl[n.property];if(!e)return"";let t=Qe(n);if(t<=0)return"";let r=et(n);return r.values.length<2?"":"<animate"+j("attributeName",e)+j("values",r.values.join(";"))+la(r)+ei(n,t)+j("fill",ht(n))+"/>"}function Hf(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=Qe(n);if(t<=0)return"";let r=et(n),i=e==="matrix"?r.values.map(o=>Kf(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(";"))+la(r)+ei(n,t)+j("additive",Yr(n))+j("fill",ht(n))+"/>"}function jf(n,e,t){let r=n.property==="scaleX"||n.property==="scaleY",i=n.property==="translateY"||n.property==="scaleY",s=r?"scale":"translate",o=Qe(n);if(o<=0)return"";let a=et(n);if(a.values.length<2)return"";let l=e?et(e):void 0,c=Jr(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(";"))+la(a)+ei(n,o)+j("additive",f)+j("fill",ht(n))+"/>"}function Kf(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 Xf(n){if(!n.motionPath)return"";let e=Qe(n);if(e<=0)return"";let t=et(n),r=qr(n),i=!!n.motionPathRef&&(n.motionPathRef.mode??"trackShape")==="curveTemplate",s=kn(t,{defaultCalcMode:"paced"}),o=Wr(r)&&vn(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+=ei(n,e),a+=j("fill",ht(n)),n.motionRotate!==void 0&&(a+=j("rotate",typeof n.motionRotate=="number"?String(n.motionRotate):n.motionRotate)),i?a+=`><mpath href="#${Qr(n.motionPathRef.shapeId)}"/></animateMotion>`:a+="/>",a}function vl(n,e){if(Tl.has(n.property)||wl.has(n.property)||n.property==="pathMotion")return"";let t=kl[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",Kr(n,e)||null)+"/>":""}function Yf(n){let e=mt(n);return e?`<discard begin="${Qr(e)}"/>`:"<discard/>"}function ti(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=Zr(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="${Qr(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,Yf(a),a);continue}if(Hr(a)){o(a.shapeId,vl(a,0),a);continue}if(jr(a)){for(let c=0;c<a.keyframes.length;c++)o(a.shapeId,vl(a,c),a);continue}if(a.keyframes.length<2)continue;let l="";a.property==="pathMotion"&&a.motionPath?l=Xf(a):Tl.has(a.property)?(l=Hf(a),l&&s.add(a.shapeId)):wl.has(a.property)?(l=jf(a,r.partner.get(a.id),s.has(a.shapeId)),l&&s.add(a.shapeId)):l=Wf(a),o(a.shapeId,l,a)}return e}function Ft(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=Qf(n),b=ep(n),$=[...Array.isArray(n.library)?n.library:[],...(b??[]).filter(D=>!D.builtIn&&!(Array.isArray(n.library)&&n.library.some(L=>L.id===D.id)))],v=$n(h,$),S=v.length>0?xn(v):"",x=Ee(h,$),k=tp(g,h,new Set(v.map(D=>D.id))),w=qf(m),T=S.length>0||x.length>0||k.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}`),k.length>0&&(P+=`${d}${d}${k}${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?ti(n.animationTimeline):null,N=h.map(D=>{let L=de(D),K=M?.get(D.id);return K&&K.length>0&&(L=np(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 qf(n){if(n.length===0)return"";let e=[];for(let t of n){let r=Zf(t);if(!r)continue;let i=Jf(r);e.push(`<path id="${Pl(t.id)}" d="${Pl(i)}"/>`)}return e.join("")}function Zf(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 Jf(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 Pl(n){return n.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<")}function Qf(n){let t=(Array.isArray(n.library)?n.library:[]).filter(r=>r.kind==="symbol");return t.length>0?t:n.symbols??[]}function ep(n){let t=(Array.isArray(n.library)?n.library:[]).filter(r=>r.kind==="marker");return t.length>0?t:n.markers}var ua=n=>n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""");function tp(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=Ct(c);if(s.has(p))continue;s.add(p);let m=Nr(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=>de(h)).join(""),p=c.viewBox?` viewBox="${ua(c.viewBox)}"`:"",m=c.overflow?` overflow="${ua(c.overflow)}"`:"";a.push(`<symbol id="${ua(l)}"${p}${m}>${d}</symbol>`)}return a.join("")}function np(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 Et=Math.PI*2;function rp(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 ip(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 sp(n,e,t,r){let i=1-r;return i*i*n+2*i*r*e+r*r*t}function ii(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=[];rp(o,a,l,c);for(let f of c){let d=ip(n,e,t,r,f);d<i&&(i=d),d>s&&(s=d)}return{min:i,max:s}}function si(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=sp(n,e,t,o);a<r&&(r=a),a>i&&(i=a)}}return{min:r,max:i}}function _l(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 da(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,v=b*b,S=$*$,x=c*c,k=f*f,w=v/x+S/k;if(w>1){let me=Math.sqrt(w);c*=me,f*=me,x=c*c,k=f*f}let T=x*S+k*v;if(T===0)return null;let P=(x*k-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,re=(-$-N)/f,ee=_l(1,0,L,K),q=_l(L,K,C,re);return!o&&q>0?q-=Et:o&&q<0&&(q+=Et),{cx:B,cy:D,rx:c,ry:f,phi:d,theta1:ee,deltaTheta:q}}function ap(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 op(n,e,t){if(t>=0){let i=(n-e)%Et;return i<0&&(i+=Et),i<=t}let r=(e-n)%Et;return r<0&&(r+=Et),r<=-t}function fa(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=da(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(!op(b,f.theta1,f.deltaTheta))continue;let $=ap(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 lp="MmLlHhVvCcSsQqTtAaZz";function ni(n){return n>=48&&n<=57}function up(n){return n===32||n===9||n===10||n===12||n===13}var ca=class{constructor(e){this.d=e}d;i=0;skipWsp(){for(;this.i<this.d.length&&up(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&&lp.indexOf(e)>=0?(this.i++,e):null}nextIsNumber(){this.skipCommaWsp();let e=this.d.charCodeAt(this.i);return ni(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&&ni(e.charCodeAt(r));)r++,s++;if(e.charCodeAt(r)===46)for(r++;r<e.length&&ni(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&&ni(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 ri(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 pa(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 Rl(n,e,t,r,i,s,o,a,l){let c=ii(e,r,s,a),f=ii(t,i,o,l);pa(n,{minX:c.min,maxX:c.max,minY:f.min,maxY:f.max})}function Al(n,e,t,r,i,s,o){let a=si(e,r,s),l=si(t,i,o);pa(n,{minX:a.min,maxX:a.max,minY:l.min,maxY:l.max})}function ma(n){if(!n)return null;let e=new ca(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,ri(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,ri(t,r,i),c=null;break}case"H":case"h":{let g=e.readNumber();if(g===null)return p();r=h?r+g:g,ri(t,r,i),c=null;break}case"V":case"v":{let g=e.readNumber();if(g===null)return p();i=h?i+g:g,ri(t,r,i),c=null;break}case"C":case"c":{let g=e.readNumber(),b=e.readNumber(),$=e.readNumber(),v=e.readNumber(),S=e.readNumber(),x=e.readNumber();if(g===null||b===null||$===null||v===null||S===null||x===null)return p();let k=h?r+g:g,w=h?i+b:b,T=h?r+$:$,P=h?i+v:v,R=h?r+S:S,M=h?i+x:x;Rl(t,r,i,k,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(),v=e.readNumber();if(g===null||b===null||$===null||v===null)return p();let S=c==="cubic"?2*r-a:r,x=c==="cubic"?2*i-l:i,k=h?r+g:g,w=h?i+b:b,T=h?r+$:$,P=h?i+v:v;Rl(t,r,i,S,x,k,w,T,P),a=k,l=w,c="cubic",r=T,i=P;break}case"Q":case"q":{let g=e.readNumber(),b=e.readNumber(),$=e.readNumber(),v=e.readNumber();if(g===null||b===null||$===null||v===null)return p();let S=h?r+g:g,x=h?i+b:b,k=h?r+$:$,w=h?i+v:v;Al(t,r,i,S,x,k,w),a=S,l=x,c="quad",r=k,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,v=c==="quad"?2*i-l:i,S=h?r+g:g,x=h?i+b:b;Al(t,r,i,$,v,S,x),a=$,l=v,c="quad",r=S,i=x;break}case"A":case"a":{let g=e.readNumber(),b=e.readNumber(),$=e.readNumber(),v=e.readFlag(),S=e.readFlag(),x=e.readNumber(),k=e.readNumber();if(g===null||b===null||$===null||v===null||S===null||x===null||k===null)return p();let w=h?r+x:x,T=h?i+k:k;pa(t,fa(r,i,g,b,$,v,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 Il(n,e,t=!1,r=.5,i){return n.length===0?null:ma(qe(n,e,t,r,i))}function ai(n,e){let t=De(n,e);return Ft(n,{width:t.width,height:t.height,xmlDeclaration:e.xmlDeclaration??!1,indent:!0})}function cp(n){return n==="class"?"className":n==="for"?"htmlFor":n.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}function Ml(n){return n.replace(/\s([a-z][a-z-]*?)=/g,(e,t)=>t.startsWith("data-")||t.startsWith("aria-")?e:` ${cp(t)}=`)}function oi(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=Ze(s,a),c=Ee(s,a),f=l+c,d=f.length>0,p=s.map(h=>{let g=de(h);return`${i}${i}${i}${Ml(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}${Ml(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 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=Ze(s,a),c=Ee(s,a),f=l+c,d=f.length>0,p=s.map(h=>`${i}${i}${de(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 dp=new Set(["circle","ellipse","rectangle","square","line","text","image"]);function Cl(n){return n.replace(/\\/g,"\\\\").replace(/'/g,"\\'")}function Dl(n){return n.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${")}function fp(n){if(!dp.has(n.type))return!0;let e=n.state.metadata;return!!(e?.title||e?.description||n.type==="text"&&n.state.isTextPath)}function ui(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=Ze(s,l),f=Ee(s,l),d=`${c}${f}`;d.length>0&&(a.push(`${i}svg.append('defs').html(\`${Dl(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}`:""}`),fp(m)){a.push(`${i}svg.append('g').html(\`${Dl(de(m))}\`);`),a.push("");continue}let h=sl(m),g=Ir(m),b=`shape${p+1}`;a.push(`${i}const ${b} = svg.append('${h}')`);for(let[$,v]of g)a.push(`${i}${i}.attr('${$}', '${Cl(v)}')`);m.type==="text"&&m.state.text&&a.push(`${i}${i}.text('${Cl(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 Fl(n,e){let t=n.state.metadata?.name;return t?t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""):`${n.type}-${e+1}`}var pp=new Set(["fill","fill-opacity","fill-rule","stroke","stroke-width","stroke-opacity","stroke-dasharray","stroke-linecap","opacity","transform","filter"]);function ci(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=Fl(c,l),d=Ir(c),p=[];for(let[m,h]of d)pp.has(m)&&p.push(`${r}${m}: ${h};`);p.length>0&&s.push(`.${f} {
|
|
17
|
+
${p.join(`
|
|
18
18
|
`)}
|
|
19
|
-
}`)}let o=[];for(let
|
|
20
|
-
`)}function Fn(t,e){let r=Md(t,e),n={...e};switch(n.format){case"svg":return An(r,n);case"react":return Mn(r,n);case"vue":return Cn(r,n);case"d3":return In(r,n);case"css":return Dn(r,n);default:throw new Error(`Unsupported code format: ${n.format}`)}}function Md(t,e){return Array.isArray(t)?{shapes:t,viewboxes:[{id:"default",x:0,y:0,width:e.width??800,height:e.height??600}]}:t}var Qt=class t{_snapshot;constructor(e={}){let{width:r=800,height:n=600,viewboxId:i}=e,s=Ot(0,0,r,n,i);this._snapshot=Ar({viewboxes:[s]})}static fromSnapshot(e){let r=new t;return r._snapshot=JSON.parse(JSON.stringify(e)),r}static fromJSON(e,r){let n=Cr(e,r),i=new t;return i._snapshot=n,i}add(e){let r="build"in e&&typeof e.build=="function"?e.build():e;return this._snapshot.shapes.push(r),this}addAll(...e){for(let r of e)this.add(r);return this}remove(e){let r=this._snapshot.shapes.length;return this._snapshot.shapes=this._snapshot.shapes.filter(n=>n.id!==e),this._snapshot.shapes.length<r}get shapes(){return this._snapshot.shapes}findShape(e){return this._snapshot.shapes.find(r=>r.id===e)}size(e,r){return this._snapshot.viewboxes.length>0?(this._snapshot.viewboxes[0].width=e,this._snapshot.viewboxes[0].height=r):this._snapshot.viewboxes=[Ot(0,0,e,r)],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,r){return this._ensureMetadata(),this._snapshot.documentMetadata.license=e,r!==void 0&&(this._snapshot.documentMetadata.licenseUrl=r),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,r,n){this._snapshot.symbols||(this._snapshot.symbols=[]);let i=_(),s=r.map(a=>"build"in a&&typeof a.build=="function"?a.build():a),o={kind:"symbol",id:i,name:e,viewBox:n?.viewBox??"0 0 100 100",shapes:s};return n?.groups&&(o.groups=n.groups),n?.thumbnail&&(o.thumbnail=n.thumbnail),n?.defKind&&(o.defKind=n.defKind),n?.wrapperAttrs&&(o.wrapperAttrs=n.wrapperAttrs),n?.variantAxes&&(o.variantAxes=n.variantAxes),n?.variants&&(o.variants=n.variants),n?.variantThumbnails&&(o.variantThumbnails=n.variantThumbnails),this._snapshot.symbols.push(o),i}placeSymbolInstance(e,r,n,i,s){let o,a={};typeof i=="number"||i===void 0?o=i:(a=i,o=a.width,s=a.height??s);let u={symbolId:e,x:r,y:n,width:o??100,height:s??100};a.variantKey&&(u.variantKey=a.variantKey),a.symbolOverrides&&(u.symbolOverrides=a.symbolOverrides),a.instancePresentation&&(u.instancePresentation=a.instancePresentation);let c={id:_(),type:"symbol-instance",state:u};return this._snapshot.shapes.push(c),this}removeSymbol(e){if(!this._snapshot.symbols)return!1;let r=this._snapshot.symbols.length;return this._snapshot.symbols=this._snapshot.symbols.filter(n=>n.id!==e),this._snapshot.symbols.length<r}get symbols(){return this._snapshot.symbols??[]}defineMarker(e,r,n){let i=_(),s=r.map(a=>"build"in a&&typeof a.build=="function"?a.build():a),o={kind:"marker",id:i,name:e,viewBox:n?.viewBox??"0 0 10 10",refX:n?.refX??5,refY:n?.refY??5,markerWidth:n?.markerWidth??10,markerHeight:n?.markerHeight??10,markerUnits:n?.markerUnits??"strokeWidth",orient:n?.orient??"auto",shapes:s};return n?.groups&&(o.groups=n.groups),n?.thumbnail&&(o.thumbnail=n.thumbnail),this._pushLibraryDef(o),i}defineFilter(e,r,n){let i=_(),s={kind:"filter",id:i,name:e,filters:r};return n?.colorInterpolation&&(s.colorInterpolation=n.colorInterpolation),n?.filterUnits&&(s.filterUnits=n.filterUnits),n?.primitiveUnits&&(s.primitiveUnits=n.primitiveUnits),n?.x!==void 0&&(s.x=n.x),n?.y!==void 0&&(s.y=n.y),n?.width!==void 0&&(s.width=n.width),n?.height!==void 0&&(s.height=n.height),n?.thumbnail&&(s.thumbnail=n.thumbnail),this._pushLibraryDef(s),i}defineLinearGradientLibrary(e,r,n){let i=_(),s="build"in r?r.build():r,{id:o,sourceId:a,...u}=s,c={kind:"linear-gradient",id:i,name:e,gradient:u};return n?.thumbnail&&(c.thumbnail=n.thumbnail),this._pushLibraryDef(c),i}defineRadialGradientLibrary(e,r,n){let i=_(),s="build"in r?r.build():r,{id:o,sourceId:a,...u}=s,c={kind:"radial-gradient",id:i,name:e,gradient:u};return n?.thumbnail&&(c.thumbnail=n.thumbnail),this._pushLibraryDef(c),i}definePatternLibrary(e,r,n){let i=_(),s="build"in r?r.build():r,{id:o,sourceId:a,customPatternId:u,...c}=s,f={kind:"pattern",id:i,name:e,pattern:c};return n?.thumbnail&&(f.thumbnail=n.thumbnail),this._pushLibraryDef(f),i}removeLibraryDef(e){if(!this._snapshot.library)return!1;let r=this._snapshot.library.length;return this._snapshot.library=this._snapshot.library.filter(n=>n.id!==e),this._snapshot.library.length<r}get library(){return this._snapshot.library??[]}_pushLibraryDef(e){this._snapshot.library||(this._snapshot.library=[]);let r=this._snapshot.library.findIndex(n=>n.id===e.id);r>=0?this._snapshot.library[r]=e:this._snapshot.library.push(e)}addClipGroup(e,r,n){this._snapshot.clipMaskGroups||(this._snapshot.clipMaskGroups=[]);let i=_(),s={id:i,type:"clip",clipShapeIds:e,contentShapeIds:r,parentId:null};return n?.clipPathUnits&&(s.clipPathUnits=n.clipPathUnits),n?.clipRule&&(s.clipRule=n.clipRule),n?.rawDefinition&&(s.rawDefinition=n.rawDefinition),this._snapshot.clipMaskGroups.push(s),i}addMaskGroup(e,r,n){this._snapshot.clipMaskGroups||(this._snapshot.clipMaskGroups=[]);let i=_(),s={id:i,type:"mask",clipShapeIds:e,contentShapeIds:r,parentId:null};return n?.maskUnits&&(s.maskUnits=n.maskUnits),n?.maskContentUnits&&(s.maskContentUnits=n.maskContentUnits),n?.maskBounds&&(s.maskBounds=n.maskBounds),n?.maskType&&(s.maskType=n.maskType),n?.rawDefinition&&(s.rawDefinition=n.rawDefinition),this._snapshot.clipMaskGroups.push(s),i}removeClipMaskGroup(e){if(!this._snapshot.clipMaskGroups)return!1;let r=this._snapshot.clipMaskGroups.length;return this._snapshot.clipMaskGroups=this._snapshot.clipMaskGroups.filter(n=>n.id!==e),this._snapshot.clipMaskGroups.length<r}addGuide(e,r,n){this._snapshot.guides||(this._snapshot.guides=[]);let i=_(),s={id:i,orientation:e,position:r,controlPointOffset:0};return n?.color&&(s.color=n.color),n?.opacity!==void 0&&(s.opacity=n.opacity),this._snapshot.guides.push(s),i}removeGuide(e){if(!this._snapshot.guides)return!1;let r=this._snapshot.guides.length;return this._snapshot.guides=this._snapshot.guides.filter(n=>n.id!==e),this._snapshot.guides.length<r}clearGuides(){return this._snapshot.guides=[],this}get guides(){return this._snapshot.guides??[]}addMeasurement(e,r,n){this._snapshot.measurements||(this._snapshot.measurements=[]);let i=_(),s={id:i,type:e,points:r,visible:n?.visible??!0,snapDivisions:n?.snapDivisions??1};return n?.color&&(s.color=n.color),n?.opacity!==void 0&&(s.opacity=n.opacity),this._snapshot.measurements.push(s),i}removeMeasurement(e){if(!this._snapshot.measurements)return!1;let r=this._snapshot.measurements.length;return this._snapshot.measurements=this._snapshot.measurements.filter(n=>n.id!==e),this._snapshot.measurements.length<r}get measurements(){return this._snapshot.measurements??[]}addCustomPattern(e,r,n,i){let s=_();return this._pushLibraryDef(rt({id:s,name:e,svgContent:r,width:n,height:i})),s}removeCustomPattern(e){let r=this._snapshot.library;if(!r)return!1;let n=r.length;return this._snapshot.library=r.filter(i=>!(i.kind==="pattern"&&i.id===e)),this._snapshot.library.length<n}get customPatterns(){let e=[];for(let r of this._snapshot.library??[]){if(r.kind!=="pattern")continue;let n=Tr(r);n&&e.push(n)}return e}addGroup(e,r){this._snapshot.groups||(this._snapshot.groups=[]);let n=e??_();return this._snapshot.groups.push({id:n,parentId:r??null}),n}removeGroup(e){if(!this._snapshot.groups)return!1;let r=this._snapshot.groups.length;this._snapshot.groups=this._snapshot.groups.filter(n=>n.id!==e);for(let n of this._snapshot.shapes)n.state.groupId===e&&delete n.state.groupId;return this._snapshot.groups.length<r}moveToGroup(e,r){let n=this._snapshot.shapes.find(i=>i.id===e);return n&&(n.state.groupId=r),this}removeFromGroup(e){let r=this._snapshot.shapes.find(n=>n.id===e);return r&&delete r.state.groupId,this}bringToFront(e){let r=this._snapshot.shapes.findIndex(n=>n.id===e);if(r>=0){let[n]=this._snapshot.shapes.splice(r,1);this._snapshot.shapes.push(n)}return this}sendToBack(e){let r=this._snapshot.shapes.findIndex(n=>n.id===e);if(r>=0){let[n]=this._snapshot.shapes.splice(r,1);this._snapshot.shapes.unshift(n)}return this}reorder(e,r){let n=this._snapshot.shapes.findIndex(i=>i.id===e);if(n>=0){let[i]=this._snapshot.shapes.splice(n,1),s=Math.max(0,Math.min(r,this._snapshot.shapes.length));this._snapshot.shapes.splice(s,0,i)}return this}defineVariable(e,r,n,i){this._snapshot.templateVariables||(this._snapshot.templateVariables=[]);let s=this._snapshot.templateVariables.find(o=>o.name===e);if(s)s.type=r,s.defaultValue=n,i?.label!==void 0&&(s.label=i.label),i?.description!==void 0&&(s.description=i.description);else{let o={name:e,type:r,defaultValue:n};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(r=>r.name!==e)),this}get variables(){return this._snapshot.templateVariables??[]}inspectVariables(){return Lr(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:r,...n}=e??{},i=Er(this._snapshot,r);return dt(i,n)}toJSON(e){return Mr(this._snapshot,e)}toSnapshot(){return JSON.parse(JSON.stringify(this._snapshot))}toCode(e,r){return Fn(this._snapshot,{...r,format:e})}_ensureMetadata(){this._snapshot.documentMetadata||(this._snapshot.documentMetadata={title:"",description:"",author:"",keywords:[],license:"",licenseUrl:"",language:"en",customMetadata:{}})}};var En=class{_track;constructor(e,r){this._track={id:_(),shapeId:e,property:r,keyframes:[],enabled:!0,locked:!1}}id(e){return this._track.id=e,this}keyframe(e,r,n="linear"){return this._track.keyframes.push({id:_(),time:e,value:r,easing:n}),this}keyframeBezier(e,r,n){return this._track.keyframes.push({id:_(),time:e,value:r,easing:"custom-bezier",customBezier:n}),this}keyframeLinear(e,r,n){return this._track.keyframes.push({id:_(),time:e,value:r,easing:"linear-function",linearPoints:n}),this}keyframes(...e){return this._track.keyframes.push(...e.map(r=>r.id?r:{...r,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,r="trackShape"){return this._track.motionPathRef={shapeId:e,mode:r},this}beginTrigger(e,r){return this._track.beginTrigger={type:e,value:r},this}endTrigger(e,r){return this._track.endTrigger={type:e,value:r},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,r){return this._track.transformOrigin={x:e,y:r},this}motionRotate(e){return this._track.motionRotate=e,this}additive(e){return this._track.additive=e,this}build(){let e=[...this._track.keyframes].sort((r,n)=>r.time-n.time);return{...this._track,keyframes:e}}},Ln=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(r=>({id:r.id,shapeId:r.shapeId,property:r.property,enabled:r.enabled,locked:r.locked||void 0,motionPath:r.motionPath,motionPathRef:r.motionPathRef,beginTrigger:r.beginTrigger,endTrigger:r.endTrigger,cycleDuration:r.cycleDuration,cycleRepeats:r.cycleRepeats,cycleInfinite:r.cycleInfinite,cycleBehavior:r.cycleBehavior,transformOrigin:r.transformOrigin,motionRotate:r.motionRotate,additive:r.additive,keyframes:r.keyframes.map(n=>({...n.id?{id:n.id}:{},time:n.time,value:n.value,easing:n.easing,...n.customBezier?{customBezier:n.customBezier}:{},...n.linearPoints?{linearPoints:n.linearPoints}:{}}))}))}}};var q=class{_id;_type;_state={};constructor(e,r){this._type=e,this._id=r??_()}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,r){return this._state.fillColor=e,this._state.fillType="solid",r!==void 0&&(this._state.fillOpacity=r),this}noFill(){return this._state.fillType="none",this}fillGradient(e){let r="build"in e?e.build():e;return this._state.fillType=r.type,this._state.fillGradient=r,this}fillPattern(e){let r="build"in e?e.build():e;return this._state.fillType="pattern",this._state.fillGradient=r,this}fillOpacity(e){return this._state.fillOpacity=e,this}fillRule(e){return this._state.fillRule=e,this}stroke(e,r){return this._state.borderColor=e,r!==void 0&&(this._state.borderWidth=r),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 r="build"in e?e.build():e;return this._state.strokeType=r.type,this._state.strokeGradient=r,this}strokePattern(e){let r="build"in e?e.build():e;return this._state.strokeType="pattern",this._state.strokeGradient=r,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,r,n){return this._state.lineStyle=e,e==="custom"&&(r!==void 0&&(this._state.dashLength=r),n!==void 0&&(this._state.gapLength=n)),this}opacity(e){return this._state.opacity=e,this}rotate(e){return this._state.rotation=e,this.refreshTransformMatrix(),this}skew(e,r){return this._state.skewX=e,this._state.skewY=r,this.refreshTransformMatrix(),this}scale(e,r){return this._state.scaleX=e,this._state.scaleY=r??e,this.refreshTransformMatrix(),this}pivot(e,r){return this._state.customPivot={x:e,y:r},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=De(Et(this._state,this.defaultTransformPivot()))}defaultTransformPivot(){let e=this._state.customPivot;if(e)return e;let r=this._state.x,n=this._state.y,i=this._state.width,s=this._state.height;if(r!==void 0&&n!==void 0&&i!==void 0&&s!==void 0)return{x:r+i/2,y:n+s/2};let o=this._state.radius;if(r!==void 0&&n!==void 0&&o!==void 0)return{x:r,y:n};let a=this._state.cx,u=this._state.cy;if(a!==void 0&&u!==void 0)return{x:a,y:u};let c=this._state.x1,f=this._state.y1,d=this._state.x2,h=this._state.y2;if(c!==void 0&&f!==void 0&&d!==void 0&&h!==void 0)return{x:(c+d)/2,y:(f+h)/2};let p=this._state.pathPoints;if(p?.[0])return{x:p[0].x,y:p[0].y};let g=this._state.polylinePoints;if(g?.[0])return g[0]}filter(...e){let r=this._state.filters??[];return this._state.filters=[...r,...e],this}dropShadow(e={}){let r={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(r)}innerShadow(e={}){let r={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(r)}blur(e,r,n){let i=e??4,s=r??i,o={id:`gaussian-blur-${_()}`,type:"gaussian-blur",enabled:!0,blurX:i,blurY:s,linked:i===s,quality:n?.quality??"normal"};return this.filter(o)}glow(e={}){let r={id:`glow-${_()}`,type:"glow",enabled:!0,color:e.color??"#ffffff",radius:e.radius??10,intensity:e.intensity??.8};return this.filter(r)}innerGlow(e={}){let r={id:`inner-glow-${_()}`,type:"inner-glow",enabled:!0,color:e.color??"#ffffff",radius:e.radius??10,intensity:e.intensity??.8};return this.filter(r)}grayscale(e=1){let r={id:`grayscale-${_()}`,type:"grayscale",enabled:!0,amount:e};return this.filter(r)}sepia(e=1){let r={id:`sepia-${_()}`,type:"sepia",enabled:!0,amount:e};return this.filter(r)}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 r={id:`motion-blur-${_()}`,type:"motion-blur",enabled:!0,distance:e.distance??10,angle:e.angle??0,quality:e.quality??"normal"};return this.filter(r)}pointLight(e={}){let r={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(r)}spotLight(e={}){let r={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(r)}sharpen(e=1){let r={id:`sharpen-${_()}`,type:"sharpen",enabled:!0,amount:e};return this.filter(r)}pixelate(e=8){let r={id:`pixelate-${_()}`,type:"pixelate",enabled:!0,blockSize:e};return this.filter(r)}warp(e={}){let r={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(r)}morphology(e={}){let r=e.radiusX??2,n=e.radiusY??r,i={id:`morphology-${_()}`,type:"morphology",enabled:!0,operator:e.operator??"dilate",radiusX:r,radiusY:n,linked:e.linked??r===n};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 n={id:`contouring-discrete-${_()}`,type:"contouring-discrete",enabled:!0,levels:e.levels??4};return this.filter(n)}roundEdges(e=4){let r={id:`round-edges-${_()}`,type:"round-edges",enabled:!0,radius:e};return this.filter(r)}channelPainter(e={}){let r={id:`channel-painter-${_()}`,type:"channel-painter",enabled:!0,red:e.red??1,green:e.green??1,blue:e.blue??1};return this.filter(r)}brightness(e=1){let r={id:`brightness-${_()}`,type:"brightness",enabled:!0,amount:e};return this.filter(r)}contrast(e=1){let r={id:`contrast-${_()}`,type:"contrast",enabled:!0,amount:e};return this.filter(r)}filterOpacity(e=1){let r={id:`opacity-${_()}`,type:"opacity",enabled:!0,amount:e};return this.filter(r)}invert(e=1){let r={id:`invert-${_()}`,type:"invert",enabled:!0,amount:e};return this.filter(r)}hueRotate(e=0){let r={id:`hue-rotate-${_()}`,type:"hue-rotate",enabled:!0,angle:e};return this.filter(r)}saturate(e=1){let r={id:`saturate-${_()}`,type:"saturate",enabled:!0,amount:e};return this.filter(r)}blackAndWhite(e=.5){let r={id:`black-and-white-${_()}`,type:"black-and-white",enabled:!0,threshold:e};return this.filter(r)}duotone(e={}){let r={id:`duotone-${_()}`,type:"duotone",enabled:!0,shadowColor:e.shadowColor??"#000000",highlightColor:e.highlightColor??"#ffffff"};return this.filter(r)}xray(e=1){let r={id:`xray-${_()}`,type:"xray",enabled:!0,intensity:e};return this.filter(r)}noise(e={}){let r={id:`noise-${_()}`,type:"noise",enabled:!0,amount:e.amount??.3,scale:e.scale??1};return this.filter(r)}emboss(e={}){let r={id:`emboss-${_()}`,type:"emboss",enabled:!0,strength:e.strength??1,angle:e.angle??135};return this.filter(r)}filmGrain(e={}){let r={id:`film-grain-${_()}`,type:"film-grain",enabled:!0,amount:e.amount??.3,size:e.size??1};return this.filter(r)}watercolor(e={}){let r={id:`watercolor-${_()}`,type:"watercolor",enabled:!0,wetness:e.wetness??.5,turbulence:e.turbulence??.5};return this.filter(r)}gouache(e={}){let r={id:`gouache-${_()}`,type:"gouache",enabled:!0,thickness:e.thickness??.5,texture:e.texture??.5};return this.filter(r)}inkBlot(e={}){let r={id:`ink-blot-${_()}`,type:"ink-blot",enabled:!0,spread:e.spread??.5,edges:e.edges??.5};return this.filter(r)}crumpledPlastic(e={}){let r={id:`crumpled-plastic-${_()}`,type:"crumpled-plastic",enabled:!0,wrinkles:e.wrinkles??.5,shine:e.shine??.5};return this.filter(r)}riddled(e={}){let r={id:`riddled-${_()}`,type:"riddled",enabled:!0,density:e.density??.5,size:e.size??1};return this.filter(r)}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,r="linear-gradient"){return this._state.fillLibraryId=e,this._state.fillType=r,this}strokeLibrary(e,r="linear-gradient"){return this._state.strokeLibraryId=e,this._state.strokeType=r,this}filterLibrary(...e){let r=this._state.filterLibraryIds??[];return this._state.filterLibraryIds=[...r,...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,r){let n=this._state.bindings??{};return this._state.bindings={...n,[e]:r},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}}}},Bn=class extends q{constructor(e,r,n){if(n<0)throw new RangeError("Circle radius must be non-negative");super("circle"),this._state.x=e,this._state.y=r,this._state.radius=n}position(e,r){return this._state.x=e,this._state.y=r,this}radius(e){return this._state.radius=e,this}},Nn=class extends q{constructor(e,r,n,i){if(n<0||i<0)throw new RangeError("Ellipse radii must be non-negative");super("ellipse"),this._state.cx=e,this._state.cy=r,this._state.rx=n,this._state.ry=i}position(e,r){return this._state.cx=e,this._state.cy=r,this}radii(e,r){return this._state.rx=e,this._state.ry=r,this}},On=class extends q{constructor(e,r,n,i){if(n<0||i<0)throw new RangeError("Rectangle dimensions must be non-negative");super("rectangle"),this._state.x=e,this._state.y=r,this._state.width=n,this._state.height=i}position(e,r){return this._state.x=e,this._state.y=r,this}size(e,r){return this._state.width=e,this._state.height=r,this}cornerRadius(e){return this._state.cornerRadius=e,this._state.rx=e,this._state.ry=e,this}radii(e,r){return this._state.rx=e,this._state.ry=r,e===r&&(this._state.cornerRadius=e),this}},zn=class extends q{constructor(e,r,n){if(n<0)throw new RangeError("Square size must be non-negative");super("square"),this._state.x=e,this._state.y=r,this._state.width=n,this._state.height=n}position(e,r){return this._state.x=e,this._state.y=r,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,r){return this._state.rx=e,this._state.ry=r,e===r&&(this._state.cornerRadius=e),this}},Gn=class extends q{constructor(e,r,n,i){super("line"),this._state.x1=e,this._state.y1=r,this._state.x2=n,this._state.y2=i}from(e,r){return this._state.x1=e,this._state.y1=r,this}to(e,r){return this._state.x2=e,this._state.y2=r,this}markerStart(e){return this._state.startEndpoint=e,this}markerEnd(e){return this._state.endEndpoint=e,this}markers(e,r){return this._state.startEndpoint=e,this._state.endEndpoint=r,this}},Vn=class extends q{constructor(e,r,n){super("text"),this._state.x=e,this._state.y=r,this._state.text=n}position(e,r){return this._state.x=e,this._state.y=r,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,r=0){return this._state.isTextPath=!0,this._state.textPathPoints=e,this._state.textPathStartOffset=r,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 r=Ue(e);return this._state.richTextRuns=r,this._state.richTextData=_e(r),this}richTextRuns(e){let r=Ve(e);return this._state.richTextRuns=r,this._state.richTextData=_e(r),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}},se=class extends q{constructor(e,r,n,i){super(e),this._state.cx=r,this._state.cy=n,this._state.radius=i}position(e,r){return this._state.cx=e,this._state.cy=r,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}},Un=class extends se{constructor(e,r,n){super("triangle",e,r,n)}},Wn=class extends se{constructor(e,r,n,i=5){super("ngon",e,r,n),this._state.sides=i}sides(e){return this._state.sides=e,this}},Hn=class extends se{constructor(e,r,n){super("star",e,r,n),this._state.arms=5,this._state.innerRadiusPercent=40}arms(e){return this._state.arms=e,this}innerRadius(e){return this._state.innerRadiusPercent=e,this}},jn=class extends se{constructor(e,r,n){super("cross",e,r,n),this._state.armWidthPercent=35}armWidth(e){return this._state.armWidthPercent=e,this}},Xn=class extends se{constructor(e,r,n){super("ring",e,r,n),this._state.innerRadiusPercent=60}innerRadius(e){return this._state.innerRadiusPercent=e,this}},Kn=class extends se{constructor(e,r,n){super("spiral",e,r,n),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}},Yn=class extends se{constructor(e,r,n){super("gear",e,r,n),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}},qn=class extends se{constructor(e,r,n){super("arrow",e,r,n),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}},Zn=class extends se{constructor(e,r,n){super("heart",e,r,n),this._state.lobeRadiusPercent=50,this._state.cleftDepthPercent=25}lobeRadius(e){return this._state.lobeRadiusPercent=e,this}cleftDepth(e){return this._state.cleftDepthPercent=e,this}},Qn=class extends se{constructor(e,r,n){super("lightning",e,r,n),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}},Jn=class extends se{constructor(e,r,n){super("cloud",e,r,n),this._state.cloudBumps=5,this._state.cloudPuffinessPercent=60}bumps(e){return this._state.cloudBumps=e,this}puffiness(e){return this._state.cloudPuffinessPercent=e,this}},ei=class extends se{constructor(e,r,n){super("speechBubble",e,r,n),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}},Oe=class extends q{add(e){let r="build"in e&&typeof e.build=="function"?e.build():e,n=this._state.children??[];return this._state.children=[...n,r],this}addAll(...e){for(let r of e)this.add(r);return this}children(e){return this._state.children=e.map(r=>"build"in r&&typeof r.build=="function"?r.build():r),this}},ti=class extends Oe{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}},ri=class extends Oe{constructor(){super("switch")}},ni=class extends Oe{constructor(){super("container")}},ii=class extends q{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,r,n,i){return this._state.viewBoxX=e,this._state.viewBoxY=r,this._state.viewBoxWidth=n,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}},si=class extends Oe{constructor(e=0,r=0,n=100,i=100){super("svg"),this._state.svgX=e,this._state.svgY=r,this._state.svgWidth=n,this._state.svgHeight=i}position(e,r){return this._state.svgX=e,this._state.svgY=r,this}size(e,r){return this._state.svgWidth=e,this._state.svgHeight=r,this}viewBox(e,r,n,i){return this._state.svgViewBoxX=e,this._state.svgViewBoxY=r,this._state.svgViewBoxWidth=n,this._state.svgViewBoxHeight=i,this}preserveAspectRatio(e){return this._state.svgPreserveAspectRatio=e,this}asRoot(e=!0){return this._state.isRootSvg=e,this}},ai=class extends q{constructor(e){super("shape-reference"),e!==void 0&&(this._state.targetShapeId=e)}target(e){return this._state.targetShapeId=e,this}offset(e,r){return this._state.offsetX=e,this._state.offsetY=r,this}size(e,r){return this._state.width=e,this._state.height=r,this}},oi=class extends q{position(e,r){return this._state.x=e,this._state.y=r,this}size(e,r){return this._state.width=e,this._state.height=r,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,r){return this._state.trimStart=e,this._state.trimEnd=r,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,r){return this._state.fadeInDuration=e,this._state.fadeOutDuration=r,this}language(e){return this._state.systemLanguage=e,this}},li=class extends oi{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}},ui=class extends oi{constructor(e){super("audio"),this._state.mediaKind="audio",e!==void 0&&(this._state.href=e)}},ci=class extends q{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,r){let n=this._state.pathPoints??[];return n.push({x:e,y:r}),this._state.pathPoints=n,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,r){return this._state.startEndpoint=e,this._state.endEndpoint=r,this}toD(){let e=this._state.pathPoints??[],r=this._state.pathCurveType??"CUBIC",n=this._state.pathClosed??!1,i=this._state.pathTension??.5,s=this._state.pathArcParams;return Fe(e,r,n,i,s)}},di=class extends q{constructor(e=[]){super("polyline"),this._state.polylinePoints=[...e],this._state.polylineClosed=!1}points(e){return this._state.polylinePoints=[...e],this}addPoint(e,r){let n=this._state.polylinePoints??[];return n.push({x:e,y:r}),this._state.polylinePoints=n,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,r){return this._state.startEndpoint=e,this._state.endEndpoint=r,this}},fi=class extends q{constructor(e,r,n,i,s){super("image"),this._state.x=e,this._state.y=r,this._state.width=n,this._state.height=i,this._state.href=s}position(e,r){return this._state.x=e,this._state.y=r,this}size(e,r){return this._state.width=e,this._state.height=r,this}src(e){return this._state.href=e,this}preserveAspectRatio(e){return this._state.preserveAspectRatio=e,this}};var Jt=class{_x1;_y1;_x2;_y2;_stops=[];_spreadMethod="pad";_opacity=1;_id;constructor(e=0,r=0,n=1,i=0){this._x1=e,this._y1=r,this._x2=n,this._y2=i,this._id=_()}stop(e,r,n=1){return this._stops.push({offset:e,color:r,opacity:n}),this}direction(e,r,n,i){return this._x1=e,this._y1=r,this._x2=n,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}}},er=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,r){return this._cx=e,this._cy=r,this}focus(e,r){return this._fx=e,this._fy=r,this}radius(e,r){return this._r=e,this._ry=r??e,this}rotation(e){return this._rotation=e,this}stop(e,r,n=1){return this._stops.push({offset:e,color:r,opacity:n}),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}}},tr=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",r="#000000",n="#ffffff"){this._patternType=e,this._color=r,this._backgroundColor=n,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,r){return this._width=e,this._height=r,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,r){return this._x=e,this._y=r,this}customPatternId(e){return this._customPatternId=e,this}build(){let e,r,n;if(this._svgContent!==void 0)e=this._svgContent,r=this._width??10,n=this._height??10;else{let s=nn(this._patternType,this._scale,this._color,this._backgroundColor,this._patternParams);e=s.svgContent,r=this._width??s.width,n=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:r,height:n,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 uo(t=0,e=0,r=1,n=0){return new Jt(t,e,r,n)}function co(){return new er}function fo(t="stripes",e="#000000",r="#ffffff"){return new tr(t,e,r)}var Ps={rows:4,cols:4,style:"classic",tabDepthPercent:20,tabPattern:"random",seed:1},Cd=.04,Id=0;function Dd(t){let e=t>>>0;return()=>{e=e+1831565813>>>0;let r=e;return r=Math.imul(r^r>>>15,r|1),r^=r+Math.imul(r^r>>>7,r|61),((r^r>>>14)>>>0)/4294967296}}function M(t){return Number(t.toFixed(3)).toString()}function Fd(t,e,r,n,i,s,o,a,u,c,f,d){return[[0,0],[.2,a],[.5+u+f,-s+c],[.5-s+u,s+c],[.5-2*s+u-f,3*s+c],[.5+2*s+u-f,3*s+c],[.5+s+u,s+c],[.5+u+f,-s+c],[.8,d],[1,0]].map(([p,g])=>{let m=e+p*n,b=r+g*i*o;return t?{x:m,y:b}:{x:b,y:m}})}function ho(t,e,r,n,i,s,o,a,u,c,f){let d=[],h=(k,P)=>u==="alternating"?0:k+c()*(P-k),p=()=>c()<.5,g=h(-a,a),m=u==="alternating"?f%2===0:p(),b=null,x=g,S=h(-a,a),$=h(-a,a),v=h(-a,a);g=h(-a,a);for(let k=0;k<t;k++){k>0&&(b=m,m=u==="alternating"?(f+k)%2===0:p(),x=m===b?-g:g,S=h(-a,a),$=h(-a,a),v=h(-a,a),g=h(-a,a));let P=m?-1:1,T=r+k*i;d.push(Fd(e,T,n,i,s,o,P,x,S,$,v,g))}return d}function po(t,e,r,n,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*n,h=r+f*i*o;return t?{x:d,y:h}:{x:h,y:d}})}function mo(t,e){return t+` C ${M(e[1].x)} ${M(e[1].y)} ${M(e[2].x)} ${M(e[2].y)} ${M(e[3].x)} ${M(e[3].y)} C ${M(e[4].x)} ${M(e[4].y)} ${M(e[5].x)} ${M(e[5].y)} ${M(e[6].x)} ${M(e[6].y)} C ${M(e[7].x)} ${M(e[7].y)} ${M(e[8].x)} ${M(e[8].y)} ${M(e[9].x)} ${M(e[9].y)}`}function go(t,e){return t+` C ${M(e[8].x)} ${M(e[8].y)} ${M(e[7].x)} ${M(e[7].y)} ${M(e[6].x)} ${M(e[6].y)} C ${M(e[5].x)} ${M(e[5].y)} ${M(e[4].x)} ${M(e[4].y)} ${M(e[3].x)} ${M(e[3].y)} C ${M(e[2].x)} ${M(e[2].y)} ${M(e[1].x)} ${M(e[1].y)} ${M(e[0].x)} ${M(e[0].y)}`}function yo(t,e={}){let r={...Ps,...e};if(r.rows<1||r.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:n,cols:i,style:s,tabDepthPercent:o,tabPattern:a,seed:u}=r,c=Dd(u),f=t.width/i,d=t.height/n,h=Math.max(0,Math.min(.4,o/200)),p=(s==="classic"||s==="curved")&&h>0,g=s==="square-tabs"&&h>0,m=s==="classic"&&a==="random"?Cd:Id,b=[];for(let $=0;$<n-1;$++){let v=t.y+($+1)*d;if(p)b.push(ho(i,!0,t.x,v,f,d,h,m,a,c,$));else if(g){let k=[];for(let P=0;P<i;P++){let T=a==="alternating"?($+P)%2===0?1:-1:c()<.5?1:-1;k.push(po(!0,t.x+P*f,v,f,d,h,T))}b.push(k)}else b.push(new Array(i).fill(null))}let x=[];for(let $=0;$<i-1;$++){let v=t.x+($+1)*f;if(p)x.push(ho(n,!1,t.y,v,d,f,h,m,a,c,$));else if(g){let k=[];for(let P=0;P<n;P++){let T=a==="alternating"?(P+$)%2===0?1:-1:c()<.5?1:-1;k.push(po(!1,t.y+P*d,v,d,f,h,T))}x.push(k)}else x.push(new Array(n).fill(null))}let S=[];for(let $=0;$<n;$++)for(let v=0;v<i;v++){let k=t.x+v*f,P=t.y+$*d,T=k+f,w=P+d,R=`M ${M(k)} ${M(P)}`;if($===0)R+=` L ${M(T)} ${M(P)}`;else{let F=b[$-1][v];F?R=mo(R,F):R+=` L ${M(T)} ${M(P)}`}if(v===i-1)R+=` L ${M(T)} ${M(w)}`;else{let F=x[v][$];F?R=mo(R,F):R+=` L ${M(T)} ${M(w)}`}if($===n-1)R+=` L ${M(k)} ${M(w)}`;else{let F=b[$][v];F?R=go(R,F):R+=` L ${M(k)} ${M(w)}`}if(v===0)R+=` L ${M(k)} ${M(P)}`;else{let F=x[v-1][$];F?R=go(R,F):R+=` L ${M(k)} ${M(P)}`}R+=" Z",S.push({id:`puzzle-${u}-r${$}-c${v}`,row:$,col:v,d:R})}return S}var So=[1,2,3,4,5,6,7,8,9],Ed={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 rr(t){return t.map(e=>[...e])}function Ld(){return Array.from({length:9},()=>Array.from({length:9},()=>0))}function $o(t){let e=t>>>0;return()=>{e=e+1831565813>>>0;let r=e;return r=Math.imul(r^r>>>15,r|1),r^=r+Math.imul(r^r>>>7,r|61),((r^r>>>14)>>>0)/4294967296}}function vo(t,e){let r=[...t];for(let n=r.length-1;n>0;n--){let i=Math.floor(e()*(n+1));[r[n],r[i]]=[r[i],r[n]]}return r}function ht(t){return 1<<t-1}function To(t){let e=0,r=t;for(;r;)r&=r-1,e++;return e}function Bd(t){for(let e=1;e<=9;e++)if(t===ht(e))return e;return 0}function Rs(t,e){return Math.floor(t/3)*3+Math.floor(e/3)}function _s(t){let e=0;for(let r of t)for(let n of r)n!==0&&e++;return e}function Nd(t){if(!Number.isFinite(t))return 1;let e=Math.floor(t);return e===0?1:e}function ko(t,e){if(!Array.isArray(t)||t.length!==9)return e.push("Grid must contain 9 rows."),!1;let r=!0;for(let n=0;n<9;n++){if(!Array.isArray(t[n])||t[n].length!==9){e.push(`Row ${n+1} must contain 9 cells.`),r=!1;continue}for(let i=0;i<9;i++){let s=t[n][i];(!Number.isInteger(s)||s<0||s>9)&&(e.push(`Cell R${n+1}C${i+1} must be a digit from 0 to 9.`),r=!1)}}return r}function wo(t,e){let r=!0,n=(i,s)=>{let o=0;for(let a of s){if(a===0)continue;let u=ht(a);if(o&u){e.push(`${i} contains duplicate ${a}.`),r=!1;return}o|=u}};for(let i=0;i<9;i++)n(`Row ${i+1}`,t[i]);for(let i=0;i<9;i++)n(`Column ${i+1}`,t.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 u=s;u<s+3;u++)o.push(t[a][u]);n(`Box ${Math.floor(i/3)*3+Math.floor(s/3)+1}`,o)}return r}function As(t){let e=Array.from({length:9},()=>0),r=Array.from({length:9},()=>0),n=Array.from({length:9},()=>0);for(let i=0;i<9;i++)for(let s=0;s<9;s++){let o=t[i][s];if(o===0)continue;let a=ht(o),u=Rs(i,s);if(e[i]&a||r[s]&a||n[u]&a)return null;e[i]|=a,r[s]|=a,n[u]|=a}return{rows:e,cols:r,boxes:n}}function Ms(t,e,r,n,i){return 511&~(r[t]|n[e]|i[Rs(t,e)])}function Po(t,e,r){let n=As(t);if(!n)return[];let i=rr(t),s=[],{rows:o,cols:a,boxes:u}=n,c=()=>{if(s.length>=e)return;let f=-1,d=-1,h=0,p=10;for(let m=0;m<9;m++){for(let b=0;b<9;b++){if(i[m][b]!==0)continue;let x=Ms(m,b,o,a,u),S=To(x);if(S===0)return;if(S<p&&(f=m,d=b,h=x,p=S,S===1))break}if(p===1)break}if(f===-1){s.push(rr(i));return}let g=So.filter(m=>h&ht(m));r&&(g=vo(g,r));for(let m of g){let b=ht(m),x=Rs(f,d);if(i[f][d]=m,o[f]|=b,a[d]|=b,u[x]|=b,c(),u[x]&=~b,a[d]&=~b,o[f]&=~b,i[f][d]=0,s.length>=e)return}};return c(),s}function Od(t){let e=Ld(),r=$o(t),[n]=Po(e,1,r);if(!n)throw new Error("generateSudokuPuzzle: failed to generate solved grid");return n}function zd(t){let e=As(t);if(!e)return null;for(let r=0;r<9;r++)for(let n=0;n<9;n++){if(t[r][n]!==0)continue;let i=Ms(r,n,e.rows,e.cols,e.boxes);if(To(i)===1)return{row:r,col:n,value:Bd(i)}}return null}function Gd(t){let e=As(t);if(!e)return null;let r=n=>{for(let i of So){let s=ht(i),o=null;for(let a of n)if(!(t[a.row][a.col]!==0||!(Ms(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 n=0;n<9;n++){let i=r(Array.from({length:9},(s,o)=>({row:n,col:o})));if(i)return i}for(let n=0;n<9;n++){let i=r(Array.from({length:9},(s,o)=>({row:o,col:n})));if(i)return i}for(let n=0;n<9;n+=3)for(let i=0;i<9;i+=3){let s=[];for(let a=n;a<n+3;a++)for(let u=i;u<i+3;u++)s.push({row:a,col:u});let o=r(s);if(o)return o}return null}function bo(t){let e=rr(t),r=!1;for(;_s(e)<81;){let n=zd(e);if(n){e[n.row][n.col]=n.value;continue}let i=Gd(e);if(i){r=!0,e[i.row][i.col]=i.value;continue}return"search"}return r?"hidden-singles":"singles"}function xo(t,e){let r={singles:0,"hidden-singles":1,search:2};return r[t]<=r[e]}function nr(t,e={}){let r=[];return ko(t,r)?wo(t,r)?Po(t,Math.max(1,Math.floor(e.maxSolutions??2))):[]:[]}function _o(t){let e=[];if(!ko(t,e))return{valid:!1,unique:!1,solution:null,errors:e};if(wo(t,e),e.length>0)return{valid:!1,unique:!1,solution:null,errors:e};let n=nr(t,{maxSolutions:2});return n.length===0?e.push("Puzzle has no solution."):n.length>1&&e.push("Puzzle has more than one solution."),{valid:e.length===0,unique:n.length===1,solution:n[0]?rr(n[0]):null,errors:e}}function Ro(t){let e=t.difficulty,r=Ed[e];if(!r)throw new Error(`generateSudokuPuzzle: unsupported difficulty "${e}"`);let n=Nd(t.seed);for(let i=0;i<30;i++){let s=n+i*104729>>>0,o=$o(s),a=Od(s),u=rr(a),c=r.minGivens+Math.floor(o()*(r.maxGivens-r.minGivens+1)),f=vo(Array.from({length:81},(g,m)=>({row:Math.floor(m/9),col:m%9})),o);for(let g of f){if(_s(u)<=c)break;let m=u[g.row][g.col];if(u[g.row][g.col]=0,nr(u,{maxSolutions:2}).length!==1){u[g.row][g.col]=m;continue}let x=bo(u);xo(x,r.maxRating)||(u[g.row][g.col]=m)}let d=_s(u),h=bo(u);if(nr(u,{maxSolutions:2}).length===1&&d>=r.minGivens&&d<=r.maxGivens&&xo(h,r.maxRating))return{puzzle:u,solution:a,difficulty:e,seed:n,givens:d,rating:h}}throw new Error(`generateSudokuPuzzle: unable to generate a ${e} puzzle`)}var Ao="ABCDEFGHIJKLMNOPQRSTUVWXYZ";var Vd={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 Co(t){if(!Number.isFinite(t))return 1;let e=Math.floor(t);return e===0?1:e}function Io(t){let e=t>>>0;return()=>{e=e+1831565813>>>0;let r=e;return r=Math.imul(r^r>>>15,r|1),r^=r+Math.imul(r^r>>>7,r|61),((r^r>>>14)>>>0)/4294967296}}function pt(t){let e=globalThis.Intl.Segmenter;return e?Array.from(new e(void 0,{granularity:"grapheme"}).segment(t),r=>r.segment.normalize("NFC")):Array.from(t.normalize("NFC"))}function Ud(t,e,r,n){return t>=0&&e>=0&&t<n&&e<r}function Cs(t,e){return Array.from({length:e},()=>Array.from({length:t},()=>!0))}function Do(t,e,r,n){if(!r)return Cs(t,e);if(!Array.isArray(r)||r.length!==e)return n.push(`Mask must contain exactly ${e} rows.`),Cs(t,e);let i=[];for(let s=0;s<e;s++){if(!Array.isArray(r[s])||r[s].length!==t)return n.push(`Mask row ${s+1} must contain exactly ${t} cells.`),Cs(t,e);i.push(r[s].map(Boolean))}return i}function Wd(t){let e=0;for(let r of t)for(let n of r)n&&e++;return e}function Hd(t){return t.trim().normalize("NFC")}function Fo(t){return t.replace(/\r/g,"").split(/[,\n]+/).map(e=>e.trim()).filter(e=>e.length>0)}function Is(t,e){let r=[];return t.across&&(r.push("E"),e&&r.push("W")),t.down&&(r.push("S"),e&&r.push("N")),t.diagonal&&(r.push("SE","NE"),e&&r.push("NW","SW")),r}function jd(t,e,r,n,i,s,o,a){let u=pt(t),c=[];for(let f=0;f<u.length;f++){let d=e+n.dr*f,h=r+n.dc*f;if(!Ud(d,h,s,o)||!i[d][h])return null;c.push({row:d,col:h,grapheme:u[f]})}return{word:t,graphemes:u,row:e,col:r,direction:n.direction,dr:n.dr,dc:n.dc,cells:c,jitter:a}}function Eo(t,e,r,n,i,s){let o=[];for(let a of e){let u=Vd[a];for(let c=0;c<i;c++)for(let f=0;f<n;f++){let d=jd(t,c,f,u,r,n,i,s());d&&o.push(d)}}return o}function Ds(t){let e=[],r=[],n=[],i=Math.floor(t.width),s=Math.floor(t.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=Is(t.axes,t.allowBackwards);o.length===0&&e.push("At least one word direction must be enabled.");let a=Do(Math.max(1,i),Math.max(1,s),t.mask,e),u=Wd(a);u===0&&e.push("Mask must contain at least one active cell.");let c=new Set,f=[];for(let p of t.words){let g=Hd(p);if(g){if(/\s/u.test(g)){n.push({input:p,reason:"Words cannot contain whitespace."});continue}if(c.has(g)){n.push({input:p,reason:"Duplicate word."});continue}c.add(g),f.push(g)}}f.length===0&&e.push("Enter at least one word.");let d=Io(Co(t.seed));if(e.length===0)for(let p=f.length-1;p>=0;p--){let g=f[p];Eo(g,o,a,i,s,d).length===0&&(n.push({input:g,reason:"No legal placement exists for the current size, mask, and directions."}),f.splice(p,1))}n.length>0&&e.push(`${n.length} word${n.length===1?"":"s"} rejected.`);let h=Math.max(0,u);return f.length>h&&r.push("The word count exceeds the active cell count; overlaps may be required for this puzzle."),{valid:e.length===0,acceptedWords:f,rejectedWords:n,errors:e,warnings:r,minWords:1,maxWords:h,activeCells:u,directions:o}}function Xd(t,e){for(let r of e.cells){let n=t[r.row][r.col];if(n!==null&&n!==r.grapheme)return!0}return!1}function Kd(t,e){let r=[];for(let n of e.cells)t[n.row][n.col]===null&&(r.push({row:n.row,col:n.col}),t[n.row][n.col]=n.grapheme);return r}function Yd(t,e){for(let r of e)t[r.row][r.col]=null}function Mo(t,e){let r=0;for(let n of e.cells)t[n.row][n.col]===n.grapheme&&r++;return r}function qd(t){return{word:t.word,row:t.row,col:t.col,direction:t.direction,path:t.cells.map(e=>({...e}))}}function Zd(t){let e=t.fillerAlphabet??Ao,r=typeof e=="string"?pt(e):e.flatMap(i=>pt(i)),n=r.filter((i,s)=>i.trim()&&r.indexOf(i)===s);return n.length>0?n:pt(Ao)}function Lo(t){let e=Math.floor(t.width),r=Math.floor(t.height),n=Co(t.seed),i=Ds({...t,width:e,height:r,seed:n});if(!i.valid)throw new Error(`generateWordSearch: ${i.errors[0]??"invalid options"}`);let s=Do(e,r,t.mask,[]),o=Math.max(1,Math.floor(t.maxBacktrackNodes??15e4));for(let a=0;a<24;a++){let u=Io(n+a*104729>>>0),c=i.directions,f=new Map;for(let S of i.acceptedWords)f.set(S,Eo(S,c,s,e,r,u));let d=[...i.acceptedWords].sort((S,$)=>{let v=f.get(S)?.length??0,k=f.get($)?.length??0;return v!==k?v-k:pt($).length-pt(S).length}),h=Array.from({length:r},(S,$)=>Array.from({length:e},(v,k)=>s[$][k]?null:"")),p=[],g=new Map,m=0,b=S=>{if(++m>o)return!1;if(S>=d.length)return!0;let $=d[S],v=[...f.get($)??[]].filter(k=>!Xd(h,k)).sort((k,P)=>{let T=Mo(h,P)-Mo(h,k);if(T!==0)return T;let w=(g.get(k.direction)??0)-(g.get(P.direction)??0);return w!==0?w:k.jitter-P.jitter});for(let k of v){let P=Kd(h,k);if(p.push(qd(k)),g.set(k.direction,(g.get(k.direction)??0)+1),b(S+1))return!0;g.set(k.direction,(g.get(k.direction)??1)-1),p.pop(),Yd(h,P)}return!1};if(!b(0))continue;let x=Zd(t);for(let S=0;S<r;S++)for(let $=0;$<e;$++)s[S][$]?h[S][$]===null&&(h[S][$]=x[Math.floor(u()*x.length)]):h[S][$]="";return{width:e,height:r,grid:h,mask:s.map(S=>[...S]),normalizedWords:[...i.acceptedWords],placements:[...p],seed:n,title:t.title,creator:t.creator,lint:i}}throw new Error("generateWordSearch: unable to place all words with the current settings")}function Qd(t,e,r){let n=!1;for(let i=0,s=r.length-1;i<r.length;s=i++){let o=r[i],a=r[s];o.y>e!=a.y>e&&t<(a.x-o.x)*(e-o.y)/(a.y-o.y)+o.x&&(n=!n)}return n}function Jd(){let t=[];for(let e=0;e<10;e++){let r=e%2===0?.5:.23,n=-Math.PI/2+e*Math.PI/5;t.push({x:.5+Math.cos(n)*r,y:.5+Math.sin(n)*r})}return t}function Bo(t,e,r){let n=Math.max(1,Math.floor(t)),i=Math.max(1,Math.floor(e)),s=Jd();return Array.from({length:i},(o,a)=>Array.from({length:n},(u,c)=>{let f=(c+.5)/n,d=(a+.5)/i,h=f*2-1,p=d*2-1;switch(r){case"rectangle":return!0;case"circle":return h*h+p*p<=1;case"triangle":return d>=.08&&d<=.95&&Math.abs(h)<=d;case"diamond":return Math.abs(h)+Math.abs(p)<=1;case"star":return Qd(f,d,s);case"heart":{let g=h*1.25,m=-p*1.25;return Math.pow(g*g+m*m-1,3)-g*g*m*m*m<=0}case"cross":return Math.abs(h)<=.32||Math.abs(p)<=.32;default:return!0}}))}0&&(module.exports={Arrow,Audio,BUILTIN_MARKER_ID_MAP,COMMON_PROP_DEFAULTS,COMMON_TRANSFORM_NODE_DEFAULTS,CURRENT_SCHEMA_VERSION,Circle,Cloud,Container,ContainerShapeBuilder,Cross,DEFAULT_COORDINATE_PRECISION,DEFAULT_RICH_TEXT_STYLE,Document,DocumentBuilder,EASING_CURVES,EasingType,Ellipse,Gear,Heart,Hyperlink,IDENTITY_AFFINE,ImageShape,KNOWN_STATE_KEYS,LIBRARY_EMIT_ORDER,Lightning,Line,LinearGradientBuilder,MARKER_HEIGHT,MARKER_VIEWBOX,MARKER_WIDTH,MAX_COORDINATE_PRECISION,MIGRATIONS,NGon,NON_WIRE_PROP_KEYS,NUMERIC_SHAPE_TRANSFORM_STATE_KEYS,NestedSvg,NodeSchemaRegistry,PUZZLE_DEFAULTS,Path,PathCurveType,PathPointType,PatternBuilder,Polyline,RICH_TEXT_STYLE_KEYS,RadialGradientBuilder,Rectangle,Ring,SERIALIZED_SHAPE_STATE_KEYS,SHAPE_TRANSFORM_STATE_KEYS,SceneGraph,SceneNode,ShapeBuilder,ShapeReference,SpeechBubble,Spiral,Square,Star,Switch,Text,Timeline,Track,Triangle,Video,View,affine,affineFromArray,affineToArray,almostEqualAffine,applyAffineToPoint,applyAffineToVector,applyOpToSnapshot,applyOpsToSnapshot,applyRichTextFormat,applyTextSplice,applyTextTransform,arcEndpointToCenter,areTracksTimingEquivalent,around,buildCompoundTransformValues,buildSmilKeyframeData,canonicalPolygonTransformString,canonicalTransformString,collectMarkerReferences,collectReferencedLibraryDefs,collectReferencedMarkerIds,compareOrderKeys,composeLegacyTransformMatrix,computeArrowVertices,computeCloudPath,computeCrossVertices,computeDashArray,computeFlowchartBoxPath,computeGearPath,computeGearVertices,computeHeartPath,computeLightningVertices,computePolygonVertices,computeRectanglePath,computeRingPath,computeSpeechBubbleVertices,computeSpiralPath,computeSplinePath,computeStarVertices,createDocument,createSceneNode,createShape,createViewbox,createWordSearchPrimitiveMask,cubicBezierExtent1D,customPatternDefToLibraryDef,declaredRichTextDeltaKeys,decomposeAffine2D,defaultVariableMode,deriveRichTextFormatRanges,deriveSegments,deriveTextSplice,downTranslateAnimationKeyframeOps,downTranslateCollectionMoveOps,downTranslateScenePlaceOps,downTranslateTextFormatOps,ellipticalArcBounds,escXml,extractVariables,filterAttr,findShapeById,flattenShapeStateTree,flattenStateExtra,foldLegacyAncestorTransformIntoMatrix,forEachLibraryRefInState,forEachMarkerRefInState,forEachReachableShape,forEachShapeInLibraryDefs,formatSmilKeySpline,formatSmilKeyTime,freezeSiblingOrderKeys,generateCode,generateCssCode,generateD3Code,generateId,generatePatternSvgContent,generatePuzzlePieces,generateReactCode,generateSudokuPuzzle,generateSvgCode,generateVueCode,generateWordSearch,getBuiltInMarkerDefs,getEasingCubicBezier,getEffectivePrecision,getKeyframeCubicBezier,getMarkerDescriptors,getPatternElements,getSmilAdditive,getSmilBeginValue,getSmilFillMode,getSmilMotionKeyPoints,getSmilRepeatCount,getSmilSetBeginValue,getSmilTrackDuration,getWordSearchDirections,initialOrderKeys,invertAffine,isDefaultKeyPoints,isDefaultKeyTimes,isFiniteAffineArray,isIdentityAffine,isIdentityLinearSplines,isIndefiniteSetTrack,isReusablePatternTile,isSetSequenceTrack,isValidOrderKey,keyBetween,keysBetween,legacyEndpointMarkerId,linearGradient,lintWordSearchOptions,materializeSceneTreeOrderKeys,matrixTransformPart,mergeRichTextStyle,migrateSnapshot,moveResourceById,multiplyAffine,nodeSchemas,normalizeRichTextRuns,normalizeRichTextStyle,normalizeRichTextStyleDelta,orderSiblings,parseDocument,parseSvgTransformList,parseVariableArgs,parseWordSearchWords,partitionShapeStateTree,partitionStateExtra,pathDataBounds,pattern,patternLibraryDefToCustomPatternDef,patternTileSize,planTransformFusion,projectSceneTreeOntoClipMaskGroups,projectSceneTreeOntoShapes,quadraticBezierExtent1D,radialGradient,rebaseRichTextFormatRanges,rebaseRichTextRuns,reflectCubicBezier,removeTrackKeyframe,renderAnimationElements,renderBuiltinMarkerDefs,renderCircle,renderEllipse,renderFilterDefs,renderFilterLibraryDef,renderFilterPrimitive,renderFilterPrimitivesForType,renderFlowchartBox,renderImage,renderLibraryDef,renderLibraryDefs,renderLine,renderLinearGradientLibraryDef,renderMarkerLibraryDef,renderPatternLibraryDef,renderPolygonShape,renderPolyline,renderRadialGradientLibraryDef,renderRectangle,renderReferencedLibraryDefs,renderShape,renderSpline,renderSvgPrimitiveChainFilter,renderSymbolInstance,renderSymbolLibraryDef,renderText,renderToSvg,resolveRichTextStyleAt,resolveSymbolInstanceShapes,richTextFontVariantCss,richTextLineSpans,richTextRunsFromState,richTextStyleDelta,richTextStyleDeltasEqual,richTextStylesEqual,richTextTspanAttributes,rotateAffine,roundCoord,roundNumberString,roundSerializedShape,roundSnapshot,runsFromSegments,sanitizeRichTextFormatRanges,scaleAffine,skewXAffine,skewYAffine,smilKeyframeAttributes,solveCubicBezier,solveSudoku,splinePathBounds,stringifyDocument,substituteString,substituteVariables,symbolInstanceTargetId,transformSplice,translateAffine,tryParseSvgTransformList,upsertTrackKeyframe,validateSnapshot,validateSudokuPuzzle,verticesToPath});
|
|
19
|
+
}`)}let o=[];for(let l=0;l<i.length;l++){let c=i[l],f=Fl(c,l),d=de(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 di(n,e){let t=mp(n,e),r={...e};switch(r.format){case"svg":return ai(t,r);case"react":return oi(t,r);case"vue":return li(t,r);case"d3":return ui(t,r);case"css":return ci(t,r);default:throw new Error(`Unsupported code format: ${r.format}`)}}function mp(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 Tn=class n{_snapshot;constructor(e={}){let{width:t=800,height:r=600,viewboxId:i}=e,s=dn(0,0,t,r,i);this._snapshot=or({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=[dn(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){this._snapshot.symbols||(this._snapshot.symbols=[]);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._snapshot.symbols.push(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.symbols)return!1;let t=this._snapshot.symbols.length;return this._snapshot.symbols=this._snapshot.symbols.filter(r=>r.id!==e),this._snapshot.symbols.length<t}get symbols(){return this._snapshot.symbols??[]}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(Ue({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=kt(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 mr(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=pr(this._snapshot,t);return Ft(i,r)}toJSON(e){return lr(this._snapshot,e)}toSnapshot(){return JSON.parse(JSON.stringify(this._snapshot))}toCode(e,t){return di(this._snapshot,{...t,format:e})}_ensureMetadata(){this._snapshot.documentMetadata||(this._snapshot.documentMetadata={title:"",description:"",author:"",keywords:[],license:"",licenseUrl:"",language:"en",customMetadata:{}})}};var fi=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}}},pi=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 ae=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=Ye(on(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}}}},mi=class extends ae{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 ae{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}},gi=class extends ae{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}},yi=class extends ae{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}},bi=class extends ae{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}},Si=class extends ae{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=at(e);return this._state.richTextRuns=t,this._state.richTextData=Ve(t),this}richTextRuns(e){let t=st(e);return this._state.richTextRuns=t,this._state.richTextData=Ve(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}},Se=class extends ae{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}},xi=class extends Se{constructor(e,t,r){super("triangle",e,t,r)}},$i=class extends Se{constructor(e,t,r,i=5){super("ngon",e,t,r),this._state.sides=i}sides(e){return this._state.sides=e,this}},vi=class extends Se{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}},ki=class extends Se{constructor(e,t,r){super("cross",e,t,r),this._state.armWidthPercent=35}armWidth(e){return this._state.armWidthPercent=e,this}},Ti=class extends Se{constructor(e,t,r){super("ring",e,t,r),this._state.innerRadiusPercent=60}innerRadius(e){return this._state.innerRadiusPercent=e,this}},wi=class extends Se{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}},Pi=class extends Se{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}},_i=class extends Se{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}},Ri=class extends Se{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}},Ai=class extends Se{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}},Ii=class extends Se{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}},Mi=class extends Se{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}},tt=class extends ae{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}},Ci=class extends tt{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}},Di=class extends tt{constructor(){super("switch")}},Fi=class extends tt{constructor(){super("container")}},Ei=class extends ae{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}},Oi=class extends tt{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}},Li=class extends ae{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}},Ni=class extends ae{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}},Bi=class extends Ni{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}},zi=class extends Ni{constructor(e){super("audio"),this._state.mediaKind="audio",e!==void 0&&(this._state.href=e)}},Gi=class extends ae{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 qe(e,t,r,i,s)}},Vi=class extends ae{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}},Ui=class extends ae{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 wn=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}}},Pn=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}}},_n=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=Er(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 El(n=0,e=0,t=1,r=0){return new wn(n,e,t,r)}function Ol(){return new Pn}function Ll(n="stripes",e="#000000",t="#ffffff"){return new _n(n,e,t)}var ha={rows:4,cols:4,style:"classic",tabDepthPercent:20,tabPattern:"random",seed:1},hp=.04,gp=0;function yp(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 bp(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 Nl(n,e,t,r,i,s,o,a,l,c,f){let d=[],p=(k,w)=>l==="alternating"?0:k+c()*(w-k),m=()=>c()<.5,h=p(-a,a),g=l==="alternating"?f%2===0:m(),b=null,$=h,v=p(-a,a),S=p(-a,a),x=p(-a,a);h=p(-a,a);for(let k=0;k<n;k++){k>0&&(b=g,g=l==="alternating"?(f+k)%2===0:m(),$=g===b?-h:h,v=p(-a,a),S=p(-a,a),x=p(-a,a),h=p(-a,a));let w=g?-1:1,T=t+k*i;d.push(bp(e,T,r,i,s,o,w,$,v,S,x,h))}return d}function Bl(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 zl(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 Gl(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 Vl(n,e={}){let t={...ha,...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=yp(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"?hp:gp,b=[];for(let S=0;S<r-1;S++){let x=n.y+(S+1)*d;if(m)b.push(Nl(i,!0,n.x,x,f,d,p,g,a,c,S));else if(h){let k=[];for(let w=0;w<i;w++){let T=a==="alternating"?(S+w)%2===0?1:-1:c()<.5?1:-1;k.push(Bl(!0,n.x+w*f,x,f,d,p,T))}b.push(k)}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(Nl(r,!1,n.y,x,d,f,p,g,a,c,S));else if(h){let k=[];for(let w=0;w<r;w++){let T=a==="alternating"?(w+S)%2===0?1:-1:c()<.5?1:-1;k.push(Bl(!1,n.y+w*d,x,d,f,p,T))}$.push(k)}else $.push(new Array(r).fill(null))}let v=[];for(let S=0;S<r;S++)for(let x=0;x<i;x++){let k=n.x+x*f,w=n.y+S*d,T=k+f,P=w+d,R=`M ${F(k)} ${F(w)}`;if(S===0)R+=` L ${F(T)} ${F(w)}`;else{let M=b[S-1][x];M?R=zl(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=zl(R,M):R+=` L ${F(T)} ${F(P)}`}if(S===r-1)R+=` L ${F(k)} ${F(P)}`;else{let M=b[S][x];M?R=Gl(R,M):R+=` L ${F(k)} ${F(P)}`}if(x===0)R+=` L ${F(k)} ${F(w)}`;else{let M=$[x-1][S];M?R=Gl(R,M):R+=` L ${F(k)} ${F(w)}`}R+=" Z",v.push({id:`puzzle-${l}-r${S}-c${x}`,row:S,col:x,d:R})}return v}var Hl=[1,2,3,4,5,6,7,8,9],Sp={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 Rn(n){return n.map(e=>[...e])}function xp(){return Array.from({length:9},()=>Array.from({length:9},()=>0))}function jl(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 Kl(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 Ot(n){return 1<<n-1}function Xl(n){let e=0,t=n;for(;t;)t&=t-1,e++;return e}function $p(n){for(let e=1;e<=9;e++)if(n===Ot(e))return e;return 0}function ya(n,e){return Math.floor(n/3)*3+Math.floor(e/3)}function ga(n){let e=0;for(let t of n)for(let r of t)r!==0&&e++;return e}function vp(n){if(!Number.isFinite(n))return 1;let e=Math.floor(n);return e===0?1:e}function Yl(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 ql(n,e){let t=!0,r=(i,s)=>{let o=0;for(let a of s){if(a===0)continue;let l=Ot(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 ba(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=Ot(o),l=ya(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 Sa(n,e,t,r,i){return 511&~(t[n]|r[e]|i[ya(n,e)])}function Zl(n,e,t){let r=ba(n);if(!r)return[];let i=Rn(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 $=Sa(g,b,o,a,l),v=Xl($);if(v===0)return;if(v<m&&(f=g,d=b,p=$,m=v,v===1))break}if(m===1)break}if(f===-1){s.push(Rn(i));return}let h=Hl.filter(g=>p&Ot(g));t&&(h=Kl(h,t));for(let g of h){let b=Ot(g),$=ya(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 kp(n){let e=xp(),t=jl(n),[r]=Zl(e,1,t);if(!r)throw new Error("generateSudokuPuzzle: failed to generate solved grid");return r}function Tp(n){let e=ba(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=Sa(t,r,e.rows,e.cols,e.boxes);if(Xl(i)===1)return{row:t,col:r,value:$p(i)}}return null}function wp(n){let e=ba(n);if(!e)return null;let t=r=>{for(let i of Hl){let s=Ot(i),o=null;for(let a of r)if(!(n[a.row][a.col]!==0||!(Sa(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 Ul(n){let e=Rn(n),t=!1;for(;ga(e)<81;){let r=Tp(e);if(r){e[r.row][r.col]=r.value;continue}let i=wp(e);if(i){t=!0,e[i.row][i.col]=i.value;continue}return"search"}return t?"hidden-singles":"singles"}function Wl(n,e){let t={singles:0,"hidden-singles":1,search:2};return t[n]<=t[e]}function An(n,e={}){let t=[];return Yl(n,t)?ql(n,t)?Zl(n,Math.max(1,Math.floor(e.maxSolutions??2))):[]:[]}function Jl(n){let e=[];if(!Yl(n,e))return{valid:!1,unique:!1,solution:null,errors:e};if(ql(n,e),e.length>0)return{valid:!1,unique:!1,solution:null,errors:e};let r=An(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]?Rn(r[0]):null,errors:e}}function Ql(n){let e=n.difficulty,t=Sp[e];if(!t)throw new Error(`generateSudokuPuzzle: unsupported difficulty "${e}"`);let r=vp(n.seed);for(let i=0;i<30;i++){let s=r+i*104729>>>0,o=jl(s),a=kp(s),l=Rn(a),c=t.minGivens+Math.floor(o()*(t.maxGivens-t.minGivens+1)),f=Kl(Array.from({length:81},(h,g)=>({row:Math.floor(g/9),col:g%9})),o);for(let h of f){if(ga(l)<=c)break;let g=l[h.row][h.col];if(l[h.row][h.col]=0,An(l,{maxSolutions:2}).length!==1){l[h.row][h.col]=g;continue}let $=Ul(l);Wl($,t.maxRating)||(l[h.row][h.col]=g)}let d=ga(l),p=Ul(l);if(An(l,{maxSolutions:2}).length===1&&d>=t.minGivens&&d<=t.maxGivens&&Wl(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 eu="ABCDEFGHIJKLMNOPQRSTUVWXYZ";var Pp={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 nu(n){if(!Number.isFinite(n))return 1;let e=Math.floor(n);return e===0?1:e}function ru(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 Lt(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 _p(n,e,t,r){return n>=0&&e>=0&&n<r&&e<t}function xa(n,e){return Array.from({length:e},()=>Array.from({length:n},()=>!0))}function iu(n,e,t,r){if(!t)return xa(n,e);if(!Array.isArray(t)||t.length!==e)return r.push(`Mask must contain exactly ${e} rows.`),xa(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.`),xa(n,e);i.push(t[s].map(Boolean))}return i}function Rp(n){let e=0;for(let t of n)for(let r of t)r&&e++;return e}function Ap(n){return n.trim().normalize("NFC")}function su(n){return n.replace(/\r/g,"").split(/[,\n]+/).map(e=>e.trim()).filter(e=>e.length>0)}function $a(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 Ip(n,e,t,r,i,s,o,a){let l=Lt(n),c=[];for(let f=0;f<l.length;f++){let d=e+r.dr*f,p=t+r.dc*f;if(!_p(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 au(n,e,t,r,i,s){let o=[];for(let a of e){let l=Pp[a];for(let c=0;c<i;c++)for(let f=0;f<r;f++){let d=Ip(n,c,f,l,t,r,i,s());d&&o.push(d)}}return o}function va(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=$a(n.axes,n.allowBackwards);o.length===0&&e.push("At least one word direction must be enabled.");let a=iu(Math.max(1,i),Math.max(1,s),n.mask,e),l=Rp(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=Ap(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=ru(nu(n.seed));if(e.length===0)for(let m=f.length-1;m>=0;m--){let h=f[m];au(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 Mp(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 Cp(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 Dp(n,e){for(let t of e)n[t.row][t.col]=null}function tu(n,e){let t=0;for(let r of e.cells)n[r.row][r.col]===r.grapheme&&t++;return t}function Fp(n){return{word:n.word,row:n.row,col:n.col,direction:n.direction,path:n.cells.map(e=>({...e}))}}function Ep(n){let e=n.fillerAlphabet??eu,t=typeof e=="string"?Lt(e):e.flatMap(i=>Lt(i)),r=t.filter((i,s)=>i.trim()&&t.indexOf(i)===s);return r.length>0?r:Lt(eu)}function ou(n){let e=Math.floor(n.width),t=Math.floor(n.height),r=nu(n.seed),i=va({...n,width:e,height:t,seed:r});if(!i.valid)throw new Error(`generateWordSearch: ${i.errors[0]??"invalid options"}`);let s=iu(e,t,n.mask,[]),o=Math.max(1,Math.floor(n.maxBacktrackNodes??15e4));for(let a=0;a<24;a++){let l=ru(r+a*104729>>>0),c=i.directions,f=new Map;for(let v of i.acceptedWords)f.set(v,au(v,c,s,e,t,l));let d=[...i.acceptedWords].sort((v,S)=>{let x=f.get(v)?.length??0,k=f.get(S)?.length??0;return x!==k?x-k:Lt(S).length-Lt(v).length}),p=Array.from({length:t},(v,S)=>Array.from({length:e},(x,k)=>s[S][k]?null:"")),m=[],h=new Map,g=0,b=v=>{if(++g>o)return!1;if(v>=d.length)return!0;let S=d[v],x=[...f.get(S)??[]].filter(k=>!Mp(p,k)).sort((k,w)=>{let T=tu(p,w)-tu(p,k);if(T!==0)return T;let P=(h.get(k.direction)??0)-(h.get(w.direction)??0);return P!==0?P:k.jitter-w.jitter});for(let k of x){let w=Cp(p,k);if(m.push(Fp(k)),h.set(k.direction,(h.get(k.direction)??0)+1),b(v+1))return!0;h.set(k.direction,(h.get(k.direction)??1)-1),m.pop(),Dp(p,w)}return!1};if(!b(0))continue;let $=Ep(n);for(let v=0;v<t;v++)for(let S=0;S<e;S++)s[v][S]?p[v][S]===null&&(p[v][S]=$[Math.floor(l()*$.length)]):p[v][S]="";return{width:e,height:t,grid:p,mask:s.map(v=>[...v]),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 Op(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 Lp(){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 lu(n,e,t){let r=Math.max(1,Math.floor(n)),i=Math.max(1,Math.floor(e)),s=Lp();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 Op(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}}))}0&&(module.exports={Arrow,Audio,BUILTIN_MARKER_ID_MAP,COLLAB_PROTOCOL_VERSION,COMMON_PROP_DEFAULTS,COMMON_TRANSFORM_NODE_DEFAULTS,CURRENT_SCHEMA_VERSION,Circle,Cloud,Container,ContainerShapeBuilder,Cross,DEFAULT_COORDINATE_PRECISION,DEFAULT_RICH_TEXT_STYLE,Document,DocumentBuilder,EASING_CURVES,EasingType,Ellipse,Gear,Heart,Hyperlink,IDENTITY_AFFINE,ImageShape,KNOWN_STATE_KEYS,LIBRARY_EMIT_ORDER,Lightning,Line,LinearGradientBuilder,MARKER_HEIGHT,MARKER_VIEWBOX,MARKER_WIDTH,MAX_COORDINATE_PRECISION,MIGRATIONS,NGon,NON_WIRE_PROP_KEYS,NUMERIC_SHAPE_TRANSFORM_STATE_KEYS,NestedSvg,NodeSchemaRegistry,PUZZLE_DEFAULTS,Path,PathCurveType,PathPointType,PatternBuilder,Polyline,RICH_TEXT_STYLE_KEYS,RadialGradientBuilder,Rectangle,Ring,SERIALIZED_SHAPE_STATE_KEYS,SHAPE_TRANSFORM_STATE_KEYS,SceneGraph,SceneNode,ShapeBuilder,ShapeReference,SpeechBubble,Spiral,Square,Star,Switch,Text,Timeline,Track,Triangle,Video,View,affine,affineFromArray,affineToArray,almostEqualAffine,applyAffineToPoint,applyAffineToVector,applyOpToSnapshot,applyOpsInPlace,applyOpsToSnapshot,applyOpsToSnapshotWithAccepted,applyRichTextFormat,applyTextSplice,applyTextTransform,arcEndpointToCenter,areTracksTimingEquivalent,around,buildCompoundTransformValues,buildSmilKeyframeData,canonicalPolygonTransformString,canonicalTransformString,collaborationResourceKey,collectMarkerReferences,collectReferencedLibraryDefs,collectReferencedMarkerIds,compareOrderKeys,composeLegacyTransformMatrix,computeArrowVertices,computeCloudPath,computeCrossVertices,computeDashArray,computeFlowchartBoxPath,computeGearPath,computeGearVertices,computeHeartPath,computeLightningVertices,computePolygonVertices,computeRectanglePath,computeRingPath,computeSpeechBubbleVertices,computeSpiralPath,computeSplinePath,computeStarVertices,createDocument,createSceneNode,createShape,createViewbox,createWordSearchPrimitiveMask,cubicBezierExtent1D,customPatternDefToLibraryDef,declaredRichTextDeltaKeys,decomposeAffine2D,defaultVariableMode,deriveRichTextFormatRanges,deriveSegments,deriveTextSplice,downTranslateAnimationKeyframeOps,downTranslateCollectionMoveOps,downTranslateDocumentFieldOps,downTranslateScenePlaceOps,downTranslateTextFormatOps,ellipticalArcBounds,escXml,extractVariables,filterAttr,findShapeById,flattenShapeStateTree,flattenStateExtra,foldLegacyAncestorTransformIntoMatrix,forEachLibraryRefInState,forEachMarkerRefInState,forEachReachableShape,forEachShapeInLibraryDefs,formatOperationValidationIssues,formatSmilKeySpline,formatSmilKeyTime,freezeSiblingOrderKeys,generateCode,generateCssCode,generateD3Code,generateId,generatePatternSvgContent,generatePuzzlePieces,generateReactCode,generateSudokuPuzzle,generateSvgCode,generateVueCode,generateWordSearch,getBuiltInMarkerDefs,getEasingCubicBezier,getEffectivePrecision,getKeyframeCubicBezier,getMarkerDescriptors,getPatternElements,getSmilAdditive,getSmilBeginValue,getSmilFillMode,getSmilMotionKeyPoints,getSmilRepeatCount,getSmilSetBeginValue,getSmilTrackDuration,getWordSearchDirections,initialOrderKeys,invertAffine,isDefaultKeyPoints,isDefaultKeyTimes,isFiniteAffineArray,isIdentityAffine,isIdentityLinearSplines,isIndefiniteSetTrack,isReusablePatternTile,isSetSequenceTrack,isValidOrderKey,keyBetween,keysBetween,legacyEndpointMarkerId,linearGradient,lintWordSearchOptions,materializeSceneTreeOrderKeys,matrixTransformPart,maxCollaborationTimestamp,mergeRichTextStyle,migrateSnapshot,moveResourceById,multiplyAffine,nodeSchemas,normalizeRichTextRuns,normalizeRichTextStyle,normalizeRichTextStyleDelta,orderSiblings,parseDocument,parseSvgTransformList,parseVariableArgs,parseWordSearchWords,partitionShapeStateTree,partitionStateExtra,pathDataBounds,pattern,patternLibraryDefToCustomPatternDef,patternTileSize,planTransformFusion,projectSceneTreeOntoClipMaskGroups,projectSceneTreeOntoShapes,promoteRebasedShapeUpdateClock,quadraticBezierExtent1D,radialGradient,rebaseRichTextFormatRanges,rebaseRichTextRuns,reflectCubicBezier,removeResourceById,removeResourceByKey,removeResourceByName,removeTrackKeyframe,renderAnimationElements,renderBuiltinMarkerDefs,renderCircle,renderEllipse,renderFilterDefs,renderFilterLibraryDef,renderFilterPrimitive,renderFilterPrimitivesForType,renderFlowchartBox,renderImage,renderLibraryDef,renderLibraryDefs,renderLine,renderLinearGradientLibraryDef,renderMarkerLibraryDef,renderPatternLibraryDef,renderPolygonShape,renderPolyline,renderRadialGradientLibraryDef,renderRectangle,renderReferencedLibraryDefs,renderShape,renderSpline,renderSvgPrimitiveChainFilter,renderSymbolInstance,renderSymbolLibraryDef,renderText,renderToSvg,resolveRichTextStyleAt,resolveSymbolInstanceShapes,rewriteDocumentEmbeddedPayloads,rewriteShapeStateEmbeddedPayloads,richTextFontVariantCss,richTextLineSpans,richTextRunsFromState,richTextStyleDelta,richTextStyleDeltasEqual,richTextStylesEqual,richTextTspanAttributes,rotateAffine,roundCoord,roundNumberString,roundSerializedShape,roundSnapshot,runsFromSegments,sanitizeRichTextFormatRanges,scaleAffine,senderCorrectionsForOp,skewXAffine,skewYAffine,smilKeyframeAttributes,solveCubicBezier,solveSudoku,splinePathBounds,stringifyDocument,substituteString,substituteVariables,symbolInstanceTargetId,transformSplice,translateAffine,tryParseSvgTransformList,upsertResourceById,upsertResourceByKey,upsertResourceByName,upsertTrackKeyframe,validateDocumentOperations,validateOperation,validatePresenceOperation,validateSnapshot,validateSudokuPuzzle,verticesToPath});
|