@svgsketch/core 6.3.0 → 6.4.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 +35 -33
- package/dist/index.d.ts +35 -33
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -38,7 +38,7 @@ ${c}
|
|
|
38
38
|
`);return S&&(o.rawMetadata=S),C1(o)}function wP(e){let t=[],n=[...e.children].reverse();for(;n.length>0;){let r=n.pop();r.kind==="element"&&(t.push(r),n.push(...[...r.children].reverse()))}return t}function kP(e,t,n){return cb(e,t,n)?.value??null}function N1(e){let t=e.toLowerCase();return t.includes("publicdomain")||t.includes("cc0")?"cc0":t.includes("by-nc-nd")?"cc-by-nc-nd":t.includes("by-nc-sa")?"cc-by-nc-sa":t.includes("by-nc")?"cc-by-nc":t.includes("by-nd")?"cc-by-nd":t.includes("by-sa")?"cc-by-sa":t.includes("/by/")||t.includes("attribution")?"cc-by":t.includes("mit")?"mit":t.includes("apache")?"apache-2.0":"custom"}function E1(e){let t=e.flatMap(f=>wP(f).filter(p=>p.namespaceUri===Go&&p.localName==="Description")),n=t.find(f=>kP(f,"managed",Zi)==="true")??t[0];if(!n)return{};let r={},i=wP(n),o=i.find(f=>f.namespaceUri===En&&f.localName==="creator");o?.children.length&&(r.author=jo(o).trim());let s=i.find(f=>f.namespaceUri===En&&f.localName==="subject");if(s){let f=jo(s).split(",").map(p=>p.trim()).filter(Boolean);f.length>0&&(r.keywords=f)}let a=i.find(f=>f.namespaceUri===Qi&&f.localName==="license"),c=i.find(f=>f.namespaceUri===En&&f.localName==="rights"),l=a?kP(a,"resource",Go)??jo(a).trim():c?jo(c).trim():"";l&&(r.license=N1(l),r.license==="custom"&&(r.licenseUrl=l));let d={},u=n.children.filter(f=>f.kind==="element");for(let f of u){if(f.namespaceUri===Zi&&f.localName==="custom"){let h=E(f,"key");h!==null&&(d[h]=E(f,"value")??"");continue}let p=f.namespaceUri??"";if(xl.has(`${p}|${f.localName}`))continue;let m=I1[p];if(!m)continue;let g=`${m}:${f.localName}`;g in d||(d[g]=jo(f).trim())}if(Object.keys(d).length===0)for(let f of u){if(f.namespaceUri!==En||f.localName!=="description")continue;let p=jo(f),m=p.indexOf(":");if(m<=0)continue;let g=p.slice(0,m).trim();g&&(d[g]=p.slice(m+1).trim())}return Object.keys(d).length>0&&(r.customMetadata=d),r}function O1(e){let t=e.root,n=AP(e,t),r=CP(t,"metadata"),i=E1(r);n.length>0&&(i.descriptiveElements=NP(n));let o=lb(t);o!==null&&(i.language=o);let s=E(t,"role");s&&(i.role=s);let a=E(t,"aria-label");a&&(i.ariaLabel=a);let c={};for(let m of t.attributes)m.namespaceUri===null&&m.name.startsWith("aria-")&&m.name!=="aria-label"&&m.value&&(c[m.name]=m.value);Object.keys(c).length>0&&(i.aria=c);let l=n.find(m=>m.kind==="title"),d=n.find(m=>m.kind==="desc");if(l?.text&&(i.title=l.text),d?.text&&(i.description=d.text),d){let m=e.index.element(d.sourceNodeId);m&&EP(m)&&(i.rawDescription=db(m,e))}let u=r.map(m=>Il(e,m)).join(`
|
|
39
39
|
`);u&&(i.rawMetadata=u,i.rawMetadataAuthoritative=!0);let f=Object.freeze(t.children.filter(m=>m.kind==="element"&&m.namespaceUri===sb&&["base","link","meta"].includes(m.localName.toLowerCase())).map(m=>Object.freeze({sourceNodeId:m.sourceNodeId,localName:m.localName.toLowerCase(),namespaceUri:sb,rawXml:Il(e,m)})));f.length>0&&(i.rawHtmlMetadata=f.map(m=>m.rawXml).join(`
|
|
40
40
|
`));let p=[];for(let m=t.children.length-1;m>=0;m--){let g=t.children[m];if(g.kind==="comment"){p.unshift(g.value);continue}if(!(g.kind==="text"&&!g.value.trim()))break}if(p.length>0&&(i.trailingComments=p),i.keywords&&Object.freeze(i.keywords),i.customMetadata&&Object.freeze(i.customMetadata),i.aria&&Object.freeze(i.aria),i.trailingComments&&Object.freeze(i.trailingComments),i.descriptiveElements){for(let m of i.descriptiveElements)Object.freeze(m);Object.freeze(i.descriptiveElements)}return Object.freeze({sourceNodeId:t.sourceNodeId,metadata:Object.freeze(i),descriptiveElements:n,htmlMetadata:f})}function D1(e,t){let n=e.index.parent(t.sourceNodeId);if(!n)return Object.freeze([]);let r=n.children.findIndex(o=>o.kind==="element"&&o.sourceNodeId===t.sourceNodeId);if(r<0)return Object.freeze([]);let i=[];for(let o=r-1;o>=0;o--){let s=n.children[o];if(s.kind==="comment"){i.unshift(s.value);continue}if(!(s.kind==="text"&&s.value.trim().length===0))break}return Object.freeze(i)}function Ep(e,t){let n=[],r=[];for(let a of e.index.elements){if(a===e.root||a.namespaceUri!==te)continue;let c=AP(e,a),l=A1(e,a,c,t,n),d=D1(e,a);Object.keys(l).length===0&&c.length===0&&d.length===0||r.push(Object.freeze({sourceNodeId:a.sourceNodeId,metadata:l,descriptiveElements:c,leadingComments:d}))}let i=Object.freeze(r),o=new Map(i.map(a=>[a.sourceNodeId,a]));return{value:Object.freeze({document:O1(e),candidates:i,candidate(a){return o.get(a)??null}}),diagnostics:Object.freeze(n)}}var $1="http://www.w3.org/1999/xhtml",OP="http://www.w3.org/2000/xmlns/",M1=new Set(["font-face","hatch","solidcolor"]),z1=new Set(["title","desc"]);function DP(e,t){return{name:e.name,localName:e.localName,prefix:e.prefix,namespaceUri:e.namespaceUri,value:t}}function ub(e,t){if(e.kind==="doctype")return null;if(e.kind!=="element")return{kind:e.kind,value:e.value};let n=t.attributeRewrites.get(e.sourceNodeId),r=t.textRewrites.get(e.sourceNodeId);return{kind:"element",name:e.name,localName:e.localName,prefix:e.prefix,namespaceUri:e.namespaceUri,attributes:e.attributes.filter(o=>o.namespaceUri!==OP).map(o=>{let s=o.localName==="id"&&o.namespaceUri===null?t.identifiers?.liveIdForSourceNodeId(e.sourceNodeId):void 0;return DP(o,s??n?.get(o.name)??o.value)}),children:r===void 0?e.children.flatMap(o=>{let s=ub(o,t);return s?[s]:[]}):[{kind:"text",value:r}]}}function fb(e){let t=new Map,n=new Map;for(let r of e?.rewrites??[]){if(r.target==="text-content"){n.set(r.sourceNodeId,r.value);continue}if(!r.name)continue;let i=t.get(r.sourceNodeId);i||(i=new Map,t.set(r.sourceNodeId,i)),i.set(r.name,r.value)}return{identifiers:e,attributeRewrites:t,textRewrites:n}}function $P(e,t){let n=fb(t),r=n.attributeRewrites.get(e.sourceNodeId);return Object.freeze(e.attributes.filter(i=>i.namespaceUri!==OP).map(i=>{let o=i.localName==="id"&&i.namespaceUri===null?n.identifiers?.liveIdForSourceNodeId(e.sourceNodeId):void 0;return DP(i,o??r?.get(i.name)??i.value)}))}function aa(e,t){let n=fb(t);return Object.freeze(e.flatMap(r=>{let i=ub(r,n);return i?[i]:[]}))}function F1(e){return e.namespaceUri!==null&&(e.namespaceUri!==te&&e.namespaceUri!==$1||e.namespaceUri===te&&M1.has(e.localName.toLowerCase()))}function L1(e,t){return e.kind!=="element"?!1:F1(e)?!0:t==="defs"&&e.namespaceUri===te&&z1.has(e.localName.toLowerCase())}function Op(e,t){let n=[],r=fb(t),i=1,o=(a,c,l)=>{let d=0,u=0;for(let f of a){if(f.kind!=="element")continue;let p=u++;if(!L1(f,c))continue;let m=d++,g=ub(f,r);!g||g.kind!=="element"||n.push({id:`document-extension-${i++}`,placement:c,order:m,...c==="defs"?{definitionOrder:p,definitionContainerId:l}:{},element:g})}};o(e.root.children,"root");let s=0;for(let a of e.root.children)a.kind==="element"&&a.namespaceUri===te&&a.localName.toLowerCase()==="defs"&&o(a.children,"defs",`svg-definition-container-${++s}`);return Object.freeze(n.map(a=>Object.freeze(a)))}function Uo(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function bn(e,t,n=""){if(!Uo(e))return;t.onShape?.(e,n);let r=e.state;if(!Uo(r))return;let i=r.children;if(Array.isArray(i)&&i.forEach((o,s)=>{bn(o,t,`${n}.state.children[${s}]`)}),t.onState){let o=r.symbolOverrides;if(Uo(o))for(let[s,a]of Object.entries(o))Uo(a)&&t.onState(a,`${n}.state.symbolOverrides[${s}]`);t.onState(r,`${n}.state`)}}function Dp(e,t,n){Array.isArray(e)&&e.forEach((r,i)=>bn(r,t,`${n}[${i}]`))}function mt(e,t){Uo(e)&&(Dp(e.shapes,t,"shapes"),Array.isArray(e.library)&&e.library.forEach((n,r)=>{if(Uo(n))if(n.kind==="symbol"){if(Dp(n.shapes,t,`library[${r}].shapes`),Uo(n.variants))for(let[i,o]of Object.entries(n.variants))Dp(o,t,`library[${r}].variants[${i}]`)}else n.kind==="marker"&&Dp(n.shapes,t,`library[${r}].shapes`)}))}var pb=new Set(["cursive","emoji","fangsong","fantasy","math","monospace","sans-serif","serif","system-ui","ui-monospace","ui-rounded","ui-sans-serif","ui-serif"]),_1=new Set(["inherit","initial","unset","revert","revert-layer"]);function MP(e){return e.trim().replace(/^["']|["']$/g,"").trim()}function ca(e){return pb.has(MP(e).toLowerCase())}function $p(e){let t=MP(e).toLowerCase();return t.length===0?!0:pb.has(t)||_1.has(t)}function wl(e){let t=[],n="",r=null;for(let o=0;o<e.length;o++){let s=e[o];if(r){s==="\\"&&o+1<e.length?n+=e[++o]:s===r?r=null:n+=s;continue}if(s==='"'||s==="'"){r=s;continue}if(s===","){let a=n.trim();a&&t.push(a),n="";continue}n+=s}let i=n.trim();return i&&t.push(i),t}function B1(e){let t=e.split(/[ ]+/);return t.length===0?!1:t.every(n=>/^-?[A-Za-z_\u0080-\uFFFF][A-Za-z0-9_\u0080-\uFFFF-]*$/.test(n))}function V1(e){let t=wl(e);return t.length===0?e:t.map(n=>ca(n)||B1(n)?n:`"${n.replace(/"/g,'\\"')}"`).join(", ")}function mb(e){let t=wl(e);return t.length===0?!0:t.every($p)}var kl=400;function Mp(e,t=kl){if(e===void 0)return t;let n=e.trim().toLowerCase();if(n===""||n==="normal")return 400;if(n==="bold")return 700;if(n==="bolder")return t<100||t<350?400:t<550?700:t<900?900:t;if(n==="lighter")return t<100?t:t<550?100:t<750?400:700;let r=Number.parseFloat(n);return Number.isFinite(r)?Math.min(1e3,Math.max(1,r)):t}function zp(e){if(e===void 0)return"normal";let t=e.trim().toLowerCase();return t==="italic"||t.startsWith("oblique")?"italic":"normal"}function zP(e){return`${e.family}\0${e.weight}\0${e.style}`}function gb(e){let t=new Set,n=[];for(let r of e){let i=zP(r);t.has(i)||(t.add(i),n.push(r))}return n}var G1="https://boxy-svg.com";function FP(e){return/[\t\n\f\r ]/u.test(e??"")}function Fp(e,t){if(e[t]!=="/"||e[t+1]!=="*")return t;let n=e.indexOf("*/",t+2);return n<0?e.length:n+2}function j1(e,t){let n=1,r=null,i=!1;for(let o=t+1;o<e.length;o++){let s=e[o];if(r){i?i=!1:s==="\\"?i=!0:s===r&&(r=null);continue}if(s==="/"&&e[o+1]==="*"){o=Math.max(o,Fp(e,o)-1);continue}if(s==='"'||s==="'"){r=s;continue}if(s==="{")n++;else if(s==="}"&&--n===0)return o}return e.length-1}function Lp(e){let t=[],n=null,r=!1;for(let i=0;i<e.length;i++){let o=e[i];if(n){r?r=!1:o==="\\"?r=!0:o===n&&(n=null);continue}if(o==="/"&&e[i+1]==="*"){i=Math.max(i,Fp(e,i)-1);continue}if(o==='"'||o==="'"){n=o;continue}if(o!=="@")continue;let s=i,a=i+1;for(;/[-_a-z0-9]/iu.test(e[a]??"");)a++;let c=e.slice(i+1,a).toLowerCase(),l=a,d=null,u=!1,f=0;for(;l<e.length;l++){let m=e[l];if(d){u?u=!1:m==="\\"?u=!0:m===d&&(d=null);continue}if(m==="/"&&e[l+1]==="*"){l=Math.max(l,Fp(e,l)-1);continue}if(m==='"'||m==="'"){d=m;continue}if(m==="(")f++;else if(m===")")f=Math.max(0,f-1);else if(f===0&&(m===";"||m==="{"))break}if(l>=e.length)continue;if(e[l]===";"){t.push(Object.freeze({name:c,start:s,end:l+1,preludeStart:a,preludeEnd:l,blockStart:null,blockEnd:null})),i=l;continue}let p=j1(e,l);t.push(Object.freeze({name:c,start:s,end:Math.min(e.length,p+1),preludeStart:a,preludeEnd:l,blockStart:l+1,blockEnd:p}))}return Object.freeze(t)}function _p(e){let t=e.trim();if(t.length>=2&&(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"))){let n=t.slice(1,-1);return ks(n)??n}return ks(t)??t}function Bp(e){let t=Ir(e).find(r=>r.name==="url");if(t)return _p(e.slice(t.argumentsStart,t.argumentsEnd));let n=e.trim();if(n.startsWith('"')||n.startsWith("'")){let r=n[0],i=n.indexOf(r,1);return i>0?n.slice(1,i):null}return null}function bb(e,t=0){let n=[];for(let r of Ir(e)){if(r.name==="url"){n.push(Object.freeze({rawUrl:_p(e.slice(r.argumentsStart,r.argumentsEnd)),tokenStart:t+r.tokenStart,tokenEnd:t+r.tokenEnd}));continue}n.push(...bb(e.slice(r.argumentsStart,r.argumentsEnd),t+r.argumentsStart))}return Object.freeze(n)}function U1(e){let t=Lp(e),n=t.filter(o=>o.name==="font-face"||o.name==="import"),r=[],i=0;for(let o of t){if(o.name!=="import")continue;let s=Bp(e.slice(o.preludeStart,o.preludeEnd));s!==null&&r.push(Object.freeze({url:s,channel:"css-import",tokenIndex:i})),i++}for(let o of bb(e))n.some(s=>o.tokenStart>=s.start&&o.tokenEnd<=s.end)||(r.push(Object.freeze({url:o.rawUrl,channel:"css-url",tokenIndex:i})),i++);return Object.freeze(r)}function eo(e){let t=e.trim();if(!t)return Object.freeze({status:"empty",requestUrl:null});if(/^data:/iu.test(t))return Object.freeze({status:"data",requestUrl:null});let n=Vp(t);return Object.freeze(n?{status:"external",requestUrl:n.href}:{status:"blocked",requestUrl:null})}function vb(e){return eo(e).status==="data"?e:""}var H1=new Set(["feimage","iframe","image","link","mpath","script","textpath","use"]),K1=new Set(["audio","embed","iframe","img","input","script","source","track","video"]);function xb(e){return e.replace(/&/gu,"&").replace(/</gu,"<").replace(/>/gu,">")}function _P(e){return xb(e).replace(/"/gu,""")}function hb(e){return e.trim().startsWith("#")?e:vb(e)}function BP(e,t){if(e.kind!=="element"){if(e.kind==="comment")return`<!--${e.value}-->`;if(e.kind==="processing-instruction"||e.kind==="doctype")return"";let a=t==="style"?Tl(e.value):e.value;return xb(a)}let n=e.localName.toLowerCase();if(n==="script"||n==="meta"&&e.attributes.some(a=>a.localName.toLowerCase()==="http-equiv"&&a.value.trim().toLowerCase()==="refresh"))return"";let i=[];for(let a of e.attributes){let c=a.name.toLowerCase(),l=a.localName.toLowerCase();if(/^on/iu.test(c))continue;let d=a.value;l==="style"?d=Tl(d):(c==="href"||c==="xlink:href")&&H1.has(n)||l==="src"&&K1.has(n)||l==="poster"&&n==="video"||l==="data"&&n==="object"?d=hb(d):l==="srcset"?d="":a.namespaceUri===null&&!c.startsWith("xmlns")&&(d=Tl(d)),i.push(`${a.name}="${_P(d)}"`)}let o=i.length>0?`<${e.name} ${i.join(" ")}>`:`<${e.name}>`,s=e.children.map(a=>BP(a,n)).join("");return`${o}${s}</${e.name}>`}function VP(e){let t=Rn(e,{source:"svg",entrypoint:"svg-document-import"});if(!t.value)return"";let n=BP(t.value.root,null);return e.trimStart().startsWith("<?xml")?`<?xml version="1.0" encoding="UTF-8"?>
|
|
41
|
-
${n}`:n}var W1=new Set(["animate","animatemotion","animatetransform","desc","metadata","mpath","set","title"]);function X1(e){switch(e.kind){case"text":return xb(e.value);case"comment":return`<!--${e.value}-->`;case"cdata":return`<![CDATA[${e.value.replaceAll("]]>","]]]]><![CDATA[>")}]]>`;case"processing-instruction":return`<?${e.value}?>`;case"doctype":return`<!DOCTYPE ${e.value}>`}}function GP(e,t,n){let r=e.sourceNodeId===t,i=new Map(e.attributes.map(u=>[u.name,u.value])),o=e.attributes.map(u=>u.name),s=(u,f)=>{if(f===null){i.delete(u);return}i.has(u)||o.push(u),i.set(u,f)};r&&Object.prototype.hasOwnProperty.call(n,"clipPathUnits")&&s("clipPathUnits",n.clipPathUnits??null),n.clipRule!==void 0&&(r||!W1.has(e.localName.toLowerCase()))&&s("clip-rule",n.clipRule);let a=o.filter((u,f)=>o.indexOf(u)===f&&i.has(u)).map(u=>`${u}="${_P(i.get(u))}"`),c=`<${e.name}${a.length>0?` ${a.join(" ")}`:""}`,l=e.children.map(u=>u.kind==="element"?GP(u,t,n):X1(u)).join(""),d=/\/\s*>\s*$/u.test(e.rawXml??"");return l.length===0&&d?`${c}/>`:`${c}>${l}</${e.name}>`}function jP(e,t){let n=Rn(`<svg xmlns="${te}">${e}</svg>`,{source:"native-document",entrypoint:"full-snapshot-restore"});if(!n.value)return null;let r=n.value.index.children(n.value.root.sourceNodeId)[0];if(!r)return null;let i=r.localName.toLowerCase();return i!=="clippath"&&i!=="mask"?null:GP(r,r.sourceNodeId,t)}function Vp(e){let t=/^(https?):\/\/([^/?#\s\\]+)([^\s\\]*)$/iu.exec(e);if(!t)return null;let n=t[1].toLowerCase(),r=t[2],i=r.lastIndexOf("@"),o=i>=0?r.slice(0,i+1):"",s=r.slice(i+1);if(!s)return null;let a=s.startsWith("[")?s.slice(0,Math.max(0,s.indexOf("]")+1)).toLowerCase():s.split(":")[0].toLowerCase();if(!a)return null;let c=t[3]||"/",l=c.indexOf("?"),d=c.indexOf("#",Math.max(0,l)),u=l<0?"":c.slice(l+1,d<0?void 0:d);return Object.freeze({href:`${n}://${o}${s.toLowerCase()}${c}`,hostname:a,query:u})}function LP(e){try{return decodeURIComponent(e.replace(/\+/gu," "))}catch{return e.replace(/\+/gu," ")}}function Ib(e){let t=[],n=0,r=null,i=!1,o=0;for(let s=0;s<e.length;s++){let a=e[s];if(r){i?i=!1:a==="\\"?i=!0:a===r&&(r=null);continue}if(a==="/"&&e[s+1]==="*"){s=Math.max(s,Fp(e,s)-1);continue}a==='"'||a==="'"?r=a:a==="("||a==="["?o++:a===")"||a==="]"?o=Math.max(0,o-1):a===","&&o===0&&(t.push(e.slice(n,s).trim()),n=s+1)}return t.push(e.slice(n).trim()),Object.freeze(t.filter(Boolean))}function UP(e){let t=[],n=0;for(;n<e.length;){for(;n<e.length&&(FP(e[n])||e[n]===",");)n++;if(n>=e.length)break;let r=n;for(;n<e.length&&!FP(e[n]);)n++;let i=e.slice(r,n);if(i.endsWith(",")){i=i.replace(/,+$/u,""),i&&t.push(i);continue}i&&t.push(i);let o=0;for(;n<e.length;){let s=e[n++];if(s==="(")o++;else if(s===")")o=Math.max(0,o-1);else if(s===","&&o===0)break}}return Object.freeze(t)}function wb(e){if(typeof e!="string")return null;let t=_p(Ib(e)[0]??"").trim();return!t||ca(t)?null:t}function Y1(e){let t=[];for(let n of Hr(e,";")){let r=e.slice(n.start,n.end),i=Hr(r,":",!0)[0]?.end??r.length;if(i>=r.length)continue;let o=r.slice(0,i).trim().toLowerCase(),s=r.slice(i+1).trim();o&&t.push(Object.freeze({property:o,value:s}))}return Object.freeze(t)}function q1(e){let t=Ir(e).find(n=>n.name==="format");return t&&_p(e.slice(t.argumentsStart,t.argumentsEnd))||null}var Z1=Object.freeze({"font-style":"style","font-weight":"weight","font-stretch":"stretch","font-display":"display","unicode-range":"unicodeRange","font-feature-settings":"featureSettings","font-variation-settings":"variationSettings","ascent-override":"ascentOverride","descent-override":"descentOverride","line-gap-override":"lineGapOverride","size-adjust":"sizeAdjust"});function Q1(e){let t={};for(let n of e){let r=Z1[n.property];r&&n.value&&(t[r]=n.value)}return Object.keys(t).length>0?Object.freeze(t):void 0}function kb(e){let t=[];for(let n of Lp(e)){if(n.name!=="font-face"||n.blockStart===null||n.blockEnd===null)continue;let r=Y1(e.slice(n.blockStart,n.blockEnd)),i=wb(r.find(a=>a.property==="font-family")?.value),o=r.find(a=>a.property==="src")?.value;if(!i||!o)continue;let s=Q1(r);for(let a of Ib(o)){let c=Bp(a);if(c===null)continue;let l=eo(c);l.status!=="external"||!l.requestUrl||t.push(Object.freeze({family:i,url:l.requestUrl,format:q1(a),...s?{descriptors:s}:{}}))}}return Object.freeze(t)}function HP(e){let t=[];for(let n of Lp(e)){if(n.name!=="import")continue;let r=Bp(e.slice(n.preludeStart,n.preludeEnd));if(r===null)continue;let i=eo(r);if(i.status!=="external"||!i.requestUrl)continue;let o=Vp(i.requestUrl);if(!o||o.hostname!=="fonts.googleapis.com")continue;let s=o.query.split("&").map(a=>a.split("=",2)).filter(([a])=>LP(a).toLowerCase()==="family").map(([,a])=>LP(a??""));for(let a of s)for(let c of a.split("|")){let l=c.split(":")[0].trim();l&&!ca(l)&&t.push(l)}}return Object.freeze(t)}function J1(e){return Hr(e,";").map(t=>{let n=e.slice(t.start,t.end),r=Hr(n,":",!0)[0]?.end??n.length;if(r>=n.length||n.slice(0,r).trim().toLowerCase()!=="src")return n;let o=n.slice(0,r+1),s=Ib(n.slice(r+1)).filter(a=>{let c=Bp(a);return c===null||eo(c).status==="data"});return`${o} ${s.length>0?s.join(", "):'local("__svgsketch_quarantined_font__")'}`}).join(";")}function Tl(e){let t=[];for(let i of Lp(e)){if(i.name==="import"){t.push({start:i.start,end:i.end,value:"/* external stylesheet import quarantined */"});continue}i.name!=="font-face"||i.blockStart===null||i.blockEnd===null||t.push({start:i.blockStart,end:i.blockEnd,value:J1(e.slice(i.blockStart,i.blockEnd))})}let n=e;for(let i of t.sort((o,s)=>s.start-o.start))n=`${n.slice(0,i.start)}${i.value}${n.slice(i.end)}`;let r=bb(n).filter(i=>{let o=i.rawUrl.trim();return!o||o.startsWith("#")?!1:eo(o).status!=="data"}).sort((i,o)=>o.tokenStart-i.tokenStart);for(let i of r)n=`${n.slice(0,i.tokenStart)}url("data:application/octet-stream;base64,")${n.slice(i.tokenEnd)}`;return n}function eB(e,t,n){let r=[];for(let i of t.stylesheets)if(i.applicable){for(let o of HP(i.authoredText))r.push(Object.freeze({sourceNodeId:i.sourceNodeId,occurrenceId:null,origin:"google-font-import",family:o}));for(let o of kb(i.authoredText))r.push(Object.freeze({sourceNodeId:i.sourceNodeId,occurrenceId:null,origin:"external-font-face",family:o.family,url:o.url,format:o.format,...o.descriptors?{descriptors:o.descriptors}:{}}))}for(let i of e.index.elements)for(let o of i.attributes)if(!(o.namespaceUri!==G1||o.localName!=="fonts"))for(let s of o.value.split(",")){let a=s.replace(/\+/gu," ").trim();!a||a.includes("/")||ca(a)||r.push(Object.freeze({sourceNodeId:i.sourceNodeId,occurrenceId:null,origin:"boxy-fonts",family:a}))}for(let i of n.candidates){if(i.canonicalType!=="text"||i.status!=="materialized")continue;let o=a=>{let c=wb(a);c&&r.push(Object.freeze({sourceNodeId:i.sourceNodeId,occurrenceId:i.occurrenceId,origin:"text-font-family",family:c}))};o(i.state.fontFamily);let s=Si(i.state);if(s){o(s.baseStyle.fontFamily);for(let a of s.runs)o(a.style.fontFamily)}}return Object.freeze(r)}function Wn(e,t){return e.attributes.find(n=>n.namespaceUri===null&&n.localName.toLowerCase()===t.toLowerCase())?.value??null}function yb(e){return e.children.map(t=>t.kind==="text"||t.kind==="cdata"?t.value:"").join("")}function Pb(e,t){let n=[],r=[...e.index.children(t)].reverse();for(;r.length>0;){let i=r.pop();n.push(i),r.push(...[...e.index.children(i.sourceNodeId)].reverse())}return Object.freeze(n)}function Xn(e,t){let n=eo(t.href);e.push(Object.freeze({...t,...n}))}function Ji(e,t,n,r=new Set(["css-import","css-url"]),i=()=>!0){for(let o of U1(t))!r.has(o.channel)||!i(o)||o.url.trim().startsWith("#")||Xn(e,{...n,occurrenceId:`${n.occurrenceId}:css:${o.tokenIndex}`,channel:o.channel,href:o.url,hrefNamespace:null})}function KP(e,t,n,r){for(let i of Pb(t,n.sourceNodeId)){let o=i.localName.toLowerCase(),s=Wn(i,"id"),a={sourceNodeId:i.sourceNodeId,occurrenceId:`${r}:foreign:${i.sourceNodeId}`,sourceId:s,elementName:i.localName},c=[{attributeName:"src",channel:"html-src",applies:["img","video","audio","source","track","iframe","embed"].includes(o)||o==="input"&&Wn(i,"type")?.toLowerCase()==="image"},{attributeName:"poster",channel:"html-poster",applies:o==="video"},{attributeName:"data",channel:"html-data",applies:o==="object"},{attributeName:"href",channel:"html-src",applies:o==="link"&&(Wn(i,"rel")??"").split(/\s+/u).some(u=>u.toLowerCase()==="stylesheet")}];for(let u of c){if(!u.applies)continue;let f=Wn(i,u.attributeName);f!==null&&Xn(e,{...a,occurrenceId:`${a.occurrenceId}:${u.attributeName}`,attributeName:u.attributeName,channel:u.channel,href:f,hrefNamespace:null})}let l=Wn(i,"srcset");if(l!==null&&(o==="img"||o==="source"))for(let[u,f]of UP(l).entries())Xn(e,{...a,occurrenceId:`${a.occurrenceId}:srcset:${u}`,attributeName:"srcset",channel:"html-srcset",href:f,hrefNamespace:null});let d=Wn(i,"style");d!==null&&Ji(e,d,{...a,attributeName:"style"}),o==="style"&&Ji(e,yb(i),{...a,attributeName:"textContent"})}}function tB(e,t,n,r){let i=Wn(n,"data-shape-type")?.toLowerCase();if(i==="video"||i==="audio"){let o=Pb(t,n.sourceNodeId).find(s=>s.localName.toLowerCase()===i);if(o){let s=Wn(o,"src")??"";if(Xn(e,{sourceNodeId:o.sourceNodeId,occurrenceId:`${r}:media:src`,sourceId:Wn(o,"id"),elementName:i,attributeName:"src",channel:"html-src",href:s,hrefNamespace:null}),i==="video"){let a=Wn(n,"data-poster")??Wn(o,"poster");a!==null&&Xn(e,{sourceNodeId:n.sourceNodeId,occurrenceId:`${r}:media:poster`,sourceId:Wn(n,"id"),elementName:"video",attributeName:"poster",channel:"html-poster",href:a,hrefNamespace:null})}}return}KP(e,t,n,r)}function nB(e,t,n){let r=[];for(let i of t.occurrences){let o=e.index.element(i.correspondingSourceNodeId);if(!o||o.namespaceUri!==te)continue;let s=o.localName.toLowerCase();if(s==="image"||s==="feimage"){let a=et(o)??{value:"",namespace:"svg2"};Xn(r,{sourceNodeId:o.sourceNodeId,occurrenceId:i.occurrenceId,sourceId:E(o,"id"),elementName:s==="feimage"?"feImage":"image",attributeName:"href",channel:"svg-href",href:a.value,hrefNamespace:a.namespace})}else s==="foreignobject"&&tB(r,e,o,i.occurrenceId)}for(let i of n.stylesheets)i.applicable&&Ji(r,i.authoredText,{sourceNodeId:i.sourceNodeId,occurrenceId:`style:${i.sourceNodeId}`,sourceId:i.id,elementName:"style",attributeName:"textContent"},new Set(["css-import"]),o=>Vp(o.url)?.hostname!=="fonts.googleapis.com");for(let i of n.elements){let o=e.index.element(i.correspondingSourceNodeId);if(!(!o||o.namespaceUri!==te))for(let s of Object.values(i.cascadedValues))Ji(r,s.value,{sourceNodeId:s.sourceNodeId,occurrenceId:`style:${i.occurrenceId}:${s.propertyName}`,sourceId:null,elementName:"style-declaration",attributeName:s.propertyName})}return Object.freeze(r)}function WP(e,t,n){let r=[...new Set(e.filter(d=>d.origin==="google-font-import"||d.origin==="boxy-fonts").map(d=>d.family))].sort(),i=[],o=new Set;for(let d of e){if(d.origin!=="external-font-face"||!d.url)continue;let u=`${d.family}\0${d.url}\0${d.format??""}\0${JSON.stringify(d.descriptors??{})}`;o.has(u)||(o.add(u),i.push(Object.freeze({family:d.family,url:d.url,format:d.format??null,...d.descriptors?{descriptors:d.descriptors}:{}})))}i.sort((d,u)=>d.family.localeCompare(u.family)||d.url.localeCompare(u.url)||(d.format??"").localeCompare(u.format??""));let s=[...new Set([...r,...i.map(d=>d.family)])].sort(),a=[...new Set(t.filter(d=>d.status==="external"&&d.requestUrl).map(d=>d.requestUrl))].sort(),c=[];s.length>0&&c.push(Object.freeze({kind:"font-consent",families:s,googleFamilies:r,...i.length>0?{externalSources:i}:{}})),a.length>0&&c.push(Object.freeze({kind:"external-asset-resolution",urls:a})),Object.freeze(s),Object.freeze(r),Object.freeze(i),Object.freeze(a),Object.freeze(c);let l=Object.freeze({fontCandidates:e,assetCandidates:t,effects:c});return Object.freeze({value:l,diagnostics:n})}function Gp(e,t,n,r,i){return WP(eB(e,n,r),nB(e,t,n),Object.freeze([]))}function rB(e){let t=e.state,n=t.extra;return typeof n=="object"&&n!==null&&!Array.isArray(n)?{...n,...t}:t}function Tb(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Rb(e,t,n){for(let r of HP(t))e.push(Object.freeze({sourceNodeId:n,occurrenceId:null,origin:"google-font-import",family:r}));for(let r of kb(t))e.push(Object.freeze({sourceNodeId:n,occurrenceId:null,origin:"external-font-face",family:r.family,url:r.url,format:r.format,...r.descriptors?{descriptors:r.descriptors}:{}}))}function XP(e,t,n,r){Rb(e,n,r),Ji(t,n,{sourceNodeId:r,occurrenceId:r,sourceId:null,elementName:"style",attributeName:"textContent"},void 0,o=>Vp(o.url)?.hostname!=="fonts.googleapis.com");let i=new Set(kb(n).map(o=>o.url));for(let o=t.length-1;o>=0;o--){let s=t[o];s.sourceNodeId===r&&i.has(s.requestUrl??"")&&t.splice(o,1)}}function iB(e,t,n,r){let i=[],o=c=>{c.kind==="element"&&(i.push(c),c.children.forEach(o))};n.forEach(o);let s=(c,l)=>c.attributes.find(d=>d.namespaceUri===null&&d.localName.toLowerCase()===l)?.value??null,a=c=>c.children.flatMap(l=>l.kind==="text"||l.kind==="cdata"?[l.value]:[]).join("");for(let[c,l]of i.entries()){let d=l.localName.toLowerCase(),u=s(l,"id"),f={sourceNodeId:`${r}:foreign:${c}`,occurrenceId:`${r}:foreign:${c}`,sourceId:u,elementName:l.localName},p=[{attributeName:"src",channel:"html-src",applies:["img","video","audio","source","track","iframe","embed"].includes(d)||d==="input"&&s(l,"type")?.toLowerCase()==="image"},{attributeName:"poster",channel:"html-poster",applies:d==="video"},{attributeName:"data",channel:"html-data",applies:d==="object"},{attributeName:"href",channel:"html-src",applies:d==="link"&&(s(l,"rel")??"").split(/\s+/u).some(h=>h.toLowerCase()==="stylesheet")}];for(let h of p){if(!h.applies)continue;let y=s(l,h.attributeName);y!==null&&Xn(t,{...f,occurrenceId:`${f.occurrenceId}:${h.attributeName}`,attributeName:h.attributeName,channel:h.channel,href:y,hrefNamespace:null})}let m=s(l,"srcset");if(m!==null&&(d==="img"||d==="source"))for(let[h,y]of UP(m).entries())Xn(t,{...f,occurrenceId:`${f.occurrenceId}:srcset:${h}`,attributeName:"srcset",channel:"html-srcset",href:y,hrefNamespace:null});let g=s(l,"style");if(g!==null&&Ji(t,g,{...f,attributeName:"style"}),d==="style"){let h=a(l);Rb(e,h,f.sourceNodeId),Ji(t,h,{...f,attributeName:"textContent"})}}}function Cb(e,t,n,r){Ji(e,t,{sourceNodeId:n,occurrenceId:`${n}:${r}`,sourceId:null,elementName:"canonical-state",attributeName:r})}function Pl(e,t,n){if(Tb(t))for(let[r,i]of Object.entries(t))typeof i=="string"&&Cb(e,i,n,r)}function Ab(e,t,n,r,i,o){if(Array.isArray(n))for(let[s,a]of n.entries()){if(!Tb(a))continue;let c=`${r}:filter:${s}`;a.type==="feImage"&&Xn(t,{sourceNodeId:r,occurrenceId:c,sourceId:null,elementName:"feImage",attributeName:"href",channel:"canonical-state",href:typeof a.href=="string"?a.href:typeof a.xlinkHref=="string"?a.xlinkHref:"",hrefNamespace:typeof a.href=="string"?"svg2":"xlink"}),a.type==="raw-svg"&&typeof a.svgContent=="string"&&Rl(e,t,a.svgContent,`${c}:raw`,i,o),Ab(e,t,a.primitives,`${c}:primitives`,i,o)}}function Sb(e,t,n,r,i,o){!Tb(n)||typeof n.svgContent!="string"||Rl(e,t,n.svgContent,r,i,o)}function oB(e,t,n,r,i,o){let s=rB(n),a=`snapshot:${r}:${n.id}`;if(n.type==="text"){let c=d=>{let u=wb(d);u&&e.push(Object.freeze({sourceNodeId:a,occurrenceId:a,origin:"text-font-family",family:u}))};c(s.fontFamily);let l=Si(s);if(l){c(l.baseStyle.fontFamily);for(let d of l.runs)c(d.style.fontFamily)}}n.type==="image"?Xn(t,{sourceNodeId:a,occurrenceId:a,sourceId:n.id,elementName:"image",attributeName:"href",channel:"canonical-state",href:typeof s.href=="string"?s.href:"",hrefNamespace:null}):n.type==="video"||n.type==="audio"?(Xn(t,{sourceNodeId:a,occurrenceId:`${a}:src`,sourceId:n.id,elementName:n.type,attributeName:"href",channel:"canonical-state",href:typeof s.href=="string"?s.href:"",hrefNamespace:null}),n.type==="video"&&typeof s.posterHref=="string"&&Xn(t,{sourceNodeId:a,occurrenceId:`${a}:poster`,sourceId:n.id,elementName:"video",attributeName:"posterHref",channel:"canonical-state",href:s.posterHref,hrefNamespace:null})):n.type==="foreign-object"&&Array.isArray(s.foreignContent)&&iB(e,t,s.foreignContent,a),Sb(e,t,s.fillGradient,`${a}:fillGradient`,i,o),Sb(e,t,s.strokeGradient,`${a}:strokeGradient`,i,o),Ab(e,t,s.filters,a,i,o),Pl(t,s.authoredAttributes,`${a}:authored`),Pl(t,s.containerPresentation,`${a}:container-presentation`),Pl(t,s.instancePresentation,`${a}:instance-presentation`),Pl(t,s.cssMaskProperties,`${a}:mask`),typeof s.cssClipPath=="string"&&Cb(t,s.cssClipPath,a,"clip-path")}function Rl(e,t,n,r,i,o){let s=Rn(`<svg xmlns="${te}">${n}</svg>`,i);if(!s.value){o.push(...s.diagnostics.map(c=>Object.freeze({...c,severity:"warning",message:`Canonical raw definition could not be inspected for external requests: ${c.message}`,documentPath:r})));return}let a=new Set;for(let c of s.value.index.elements){if(c.localName.toLowerCase()!=="foreignobject")continue;let l=`${r}:${c.sourceNodeId}`;KP(t,s.value,c,l);for(let d of Pb(s.value,c.sourceNodeId))a.add(d.sourceNodeId),d.localName.toLowerCase()==="style"&&Rb(e,yb(d),`${r}:${d.sourceNodeId}`)}for(let c of s.value.index.elements){if(a.has(c.sourceNodeId))continue;let l=c.localName.toLowerCase();if(c.namespaceUri===te&&(l==="image"||l==="feimage")){let d=et(c)??{value:"",namespace:"svg2"};Xn(t,{sourceNodeId:`${r}:${c.sourceNodeId}`,occurrenceId:`${r}:${c.sourceNodeId}`,sourceId:Wn(c,"id"),elementName:l==="feimage"?"feImage":"image",attributeName:"href",channel:"canonical-state",href:d.value,hrefNamespace:d.namespace})}l==="style"&&XP(e,t,yb(c),`${r}:${c.sourceNodeId}:style`);for(let d of c.attributes)d.localName.toLowerCase()==="href"||d.localName.toLowerCase()==="src"||Cb(t,d.value,`${r}:${c.sourceNodeId}`,d.name)}}function YP(e,t){let n=[],r=[],i=[];for(let[s,a]of(e.documentStyles??[]).entries())XP(n,r,a.css,`snapshot:documentStyles[${s}]`);mt(e,{onShape:(s,a)=>oB(n,r,s,a,t,i)});for(let[s,a]of(e.library??[]).entries()){let c=`snapshot:library[${s}]`;a.kind==="pattern"?Sb(n,r,a.pattern,`${c}:pattern`,t,i):a.kind==="filter"?Ab(n,r,a.filters,`${c}:filters`,t,i):(a.kind==="symbol"||a.kind==="marker")&&Pl(r,a.rootAttributes,`${c}:root`)}let o=e.documentMetadata?.rawHtmlMetadata;typeof o=="string"&&Rl(n,r,o,"snapshot:documentMetadata.rawHtmlMetadata",t,i);for(let[s,a]of(e.paintServerDefs??[]).entries())Rl(n,r,a.markup,`snapshot:paintServerDefs[${s}]`,t,i);for(let[s,a]of(e.clipMaskGroups??[]).entries())a.rawDefinition&&Rl(n,r,a.rawDefinition,`snapshot:clipMaskGroups[${s}].rawDefinition`,t,i);return WP(Object.freeze(n),Object.freeze(r),Object.freeze(i))}function sB(e,t,n){let r=new Set,i=o=>{let s=o;for(;s;){let a=s.localName.toLowerCase();if(a==="clippath"||a==="mask")return!0;s=e.index.parent(s.sourceNodeId)}return!1};for(let o of n.css){let s=t.occurrence(o.occurrenceId);if(!s)continue;let a=e.index.element(s.correspondingSourceNodeId);a&&i(a)&&r.add(a.sourceNodeId)}return e.index.elements.filter(o=>r.has(o.sourceNodeId)).map(o=>o.sourceNodeId)}var Nb=Object.freeze({matchesMedia(e){let t=e.trim().toLowerCase();return t===""||t==="all"||t==="screen"},supportsCondition(){return!1}}),aB=new Map([["clippath","clip-path"],["marker","marker"],["mask","mask"],["pattern","pattern"]]);function cB(e){return Object.freeze(e.index.elements.flatMap(t=>{let n=aB.get(t.localName.toLowerCase());return n?[Object.freeze({sourceNodeId:t.sourceNodeId,capability:n})]:[]}))}function lB(e,t,n){let r=new Map(e.occurrences.map(i=>[i.occurrenceId,i]));return Object.freeze([...t.candidates.filter(i=>i.status==="materialized").map(i=>i.occurrenceId),...n.uses.filter(i=>["symbol-instance","linked-reference"].includes(i.status)).map(i=>i.useOccurrenceId)].filter(i=>r.get(i)?.role!=="definition"))}function Cl(e,t={}){let n={source:t.source??"svg",entrypoint:t.entrypoint??"svg-document-import"},r=Rn(e,n,t.xmlHost);if(!r.value)return Object.freeze({value:null,diagnostics:r.diagnostics});let i=r.value,o=mf(i.root,n),s=Object.freeze({width:o.value.viewBoxWidth??300,height:o.value.viewBoxHeight??150}),a=t.rootFontSize??16,c=Object.freeze({viewport:Object.freeze({x:o.value.viewBoxX??0,y:o.value.viewBoxY??0,...s}),rootFontSize:a}),l=wf(i,n),d=l.value.condition(i.root.sourceNodeId),u=lp(i,n),f=Ep(i,n),p=Tf(i,{...n,resourceRoots:cB(i),...t.maxUseDepth!==void 0?{maxDepth:t.maxUseDepth}:{},...t.maxUseOccurrences!==void 0?{maxOccurrences:t.maxUseOccurrences}:{}}),m=$f(i,p,{...n,environment:t.styleEnvironment??Nb}),g=Zs(i,p,m.value,{viewport:s,rootFontSize:a}),h=Yf(i,p,m.value,{...n,viewport:s,rootFontSize:a,viewportPlan:g,...t.textMetricsHost?{textMetricsHost:t.textMetricsHost}:{}}),y=zf(i,p,m.value,{...n,leafGeometry:h.value}),S=kf(i,{...t.claimedIds?{claimedIds:t.claimedIds}:{},cssAnimationTargetSourceNodeIds:sB(i,p,y.value)}),b=S.liveIdForSourceNodeId(i.root.sourceNodeId),I=Object.freeze({...o.value,...b?{svgId:b}:{},...d?.systemLanguage!==null&&d?.systemLanguage!==void 0?{systemLanguage:d.systemLanguage}:{},...d?.requiredExtensions!==null&&d?.requiredExtensions!==void 0?{requiredExtensions:d.requiredExtensions}:{}}),v=Op(i,S),w=Of(i,{...n,appliedDeclarations:m.value.appliedResourceDeclarations}),k=Qf(i,p,m.value,w,h.value,{...n,viewport:s,rootFontSize:a}),C=new Set;for(let H of k.value.definitions)if(H.representation==="decomposed")for(let ie of H.geometrySourceNodeIds)C.add(ie);for(let H of y.value.smil)H.motionPathSourceNodeId&&C.add(H.motionPathSourceNodeId);let P=Nf(i,p,m.value,{...n,nativeDefinitionSourceNodeIds:C,privateGeometrySourceNodeIds:new Set(h.value.privateTextPathGeometry.map(H=>H.pathSourceNodeId))}),R=ap(i,p,m.value,w,{...n,viewport:s,rootFontSize:a}),N=Jf(i,p,m.value,w,{...n,viewport:s,rootFontSize:a}),M=ep(i,p,m.value,w,{...n,viewport:s,rootFontSize:a}),A=tp(i,p,m.value,w,{...n,viewport:s,rootFontSize:a}),$=rp(i,S,n),_=hf(i,n),z=Sf(i,p,g,n),j=Df(i),G=Gp(i,p,m.value,h.value,n),W=bf(i,p,{...n,materializedOccurrenceIds:lB(p,h.value,P)}),V=[...r.diagnostics,...o.diagnostics,...l.diagnostics,...u.diagnostics,...f.diagnostics,...p.diagnostics,...m.diagnostics,...y.diagnostics,...P.diagnostics,...h.diagnostics,...w.diagnostics,...k.diagnostics,...R.diagnostics,...N.diagnostics,...M.diagnostics,...A.diagnostics,...$.diagnostics,..._.diagnostics,...z.diagnostics,...G.diagnostics,...W.diagnostics],X=Object.freeze({projectionContext:c,sourceDocument:i,rootFrame:I,identifiers:S,conditionalProcessing:l.value,scripts:u.value,metadata:f.value,documentExtensions:v,useOccurrences:p,styles:m.value,viewportContexts:g,animations:y.value,symbolUses:P,leafGeometry:h.value,resourceDependencies:w,clipMasks:k.value,filters:R.value,markers:N.value,gradients:M.value,patterns:A.value,paintServerDefinitions:$.value,views:_.value,embeddedFrames:z.value,authoredAttributes:j,externalEffects:G.value,hierarchy:W.value});return Object.freeze({value:X,diagnostics:Object.freeze(V)})}function me(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`id-${crypto.randomUUID()}`:`id-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}function la(e={}){let t={schemaVersion:Pn,shapes:e.shapes?e.shapes.map(n=>({...n})):[],viewboxes:e.viewboxes?e.viewboxes.map(n=>({...n})):[]};return e.metadata&&(t.documentMetadata={title:"",description:"",author:"",keywords:[],license:"",licenseUrl:"",language:"en",customMetadata:{},...e.metadata}),t}function qP(e){let{type:t,id:n,...r}=e,i={};for(let[o,s]of Object.entries(r))s!==void 0&&(i[o]=s);return{id:n??me(),type:t,state:i}}function Ho(e,t,n,r,i){return{id:i??me(),x:e,y:t,width:n,height:r}}var Al=class{schemas=new Map;register(t,n){this.schemas.set(t,n)}get(t){return this.schemas.get(t)}typeIds(){return[...this.schemas.keys()]}getDefaults(t){let n=this.schemas.get(t);if(!n)return{};let r={};for(let i of Object.keys(n))r[i]=n[i].default;return r}validate(t,n,r){let i=this.schemas.get(t);if(!i)return r;let o=i[n];return o?.validate?o.validate(r):r}},Ee=e=>Math.max(0,e),da=e=>Math.max(0,Math.min(1,e)),Ft=e=>Math.max(0,Math.min(100,e)),dB=e=>Math.max(1,e),uB=e=>Math.max(3,Math.min(100,Math.floor(e))),fB=e=>Math.max(3,Math.min(50,Math.floor(e))),pB=e=>Math.max(3,Math.min(30,Math.floor(e))),mB=e=>Math.max(1,Math.min(10,e)),gB=e=>!e||typeof e!="object"||Array.isArray(e)||e.kind!=="shape"&&e.kind!=="definition"||typeof e.targetId!="string"||e.targetId.length===0||e.element!=="href"&&e.element!=="mpath"?null:{kind:e.kind,targetId:e.targetId,element:e.element};function hB(e){return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,{default:n}]))}var yB=hB(Yh),bt={layerName:{default:null},fillColor:{default:"#ffffff"},borderColor:{default:"#000000"},borderWidth:{default:1},opacity:{default:1,validate:da},fillOpacity:{default:1,validate:da},strokeOpacity:{default:1,validate:da},...yB,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:dB},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}},fr={...bt,cx:{default:0},cy:{default:0},radius:{default:50,validate:Ee},cornerRadius:{default:0,validate:Ee},shiftAngle:{default:0}},ua={...bt,x:{default:0},y:{default:0},width:{default:100,validate:Ee},height:{default:60,validate:Ee}},ZP={...bt,x:{default:0},y:{default:0},width:{default:0,validate:Ee},height:{default:0,validate:Ee},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:da},muted:{default:!1},loop:{default:!1},playbackRate:{default:1},mediaOpacity:{default:1,validate:da},fadeInDuration:{default:0,validate:Ee},fadeOutDuration:{default:0,validate:Ee},posterHref:{default:""},sourceRect:{default:null}},Pe=new Al;Pe.register("rectangle",{...bt,x:{default:0},y:{default:0},width:{default:100,validate:Ee},height:{default:100,validate:Ee},rx:{default:0,validate:Ee},ry:{default:0,validate:Ee},cornerRadius:{default:0,validate:Ee},cornerShape:{default:"round"},cornerMode:{default:"uniform"},cornerRadiusTL:{default:0,validate:Ee},cornerRadiusTR:{default:0,validate:Ee},cornerRadiusBL:{default:0,validate:Ee},cornerRadiusBR:{default:0,validate:Ee},cornerShapeTL:{default:"round"},cornerShapeTR:{default:"round"},cornerShapeBL:{default:"round"},cornerShapeBR:{default:"round"}});Pe.register("square",{...bt,x:{default:0},y:{default:0},size:{default:100,validate:Ee},width:{default:100,validate:Ee},height:{default:100,validate:Ee},rx:{default:0,validate:Ee},ry:{default:0,validate:Ee},cornerRadius:{default:0,validate:Ee},cornerShape:{default:"round"},cornerMode:{default:"uniform"},cornerRadiusTL:{default:0,validate:Ee},cornerRadiusTR:{default:0,validate:Ee},cornerRadiusBL:{default:0,validate:Ee},cornerRadiusBR:{default:0,validate:Ee},cornerShapeTL:{default:"round"},cornerShapeTR:{default:"round"},cornerShapeBL:{default:"round"},cornerShapeBR:{default:"round"}});Pe.register("circle",{...bt,x:{default:0},y:{default:0},radius:{default:50,validate:Ee}});Pe.register("ellipse",{...bt,x:{default:0},y:{default:0},rx:{default:50,validate:Ee},ry:{default:30,validate:Ee}});Pe.register("line",{...bt,fillType:{default:"none"},x1:{default:0},y1:{default:0},x2:{default:100},y2:{default:0},startEndpoint:{default:"none"},endEndpoint:{default:"none"}});Pe.register("text",{...bt,x:{default:0},y:{default:0},width:{default:0,validate:Ee},height:{default:0,validate:Ee},textX:{default:0},textY:{default:0},fontSize:{default:24},text:{default:""},fontFamily:{default:"Arial"},fontWeight:{default:"normal"},fontStyle:{default:"normal"},fontStretch:{default:"normal"},fontSizeAdjust:{default:"none"},fontVariant:{default:""},fontVariantLigatures:{default:""},fontVariantPosition:{default:""},fontVariantCaps:{default:""},fontVariantNumeric:{default:""},fontVariantEastAsian:{default:""},textDecoration:{default:{}},textTransform:{default:"none"},baselineShift:{default:"baseline"},dominantBaseline:{default:"auto"},alignmentBaseline:{default:"auto"},writingMode:{default:"horizontal-tb"},textAnchor:{default:"start"},letterSpacing:{default:0},wordSpacing:{default:0},lineHeight:{default:1.2},inlineSize:{default:0},overflowWrap:{default:"normal"},whiteSpace:{default:"pre-wrap"},textDirection:{default:"ltr"},unicodeBidi:{default:"normal"},scaleX:{default:1},scaleY:{default:1},scaleAnchor:{default:null},useRichText:{default:!1},richTextRuns:{default:null},charOffsets:{default:null},fontVariationSettings:{default:{}},isTextPath:{default:!1},textPathPoints:{default:null},textPathStartOffset:{default:0},textPathSide:{default:"left"},textPathReference:{default:null,validate:gB},shapeInsideRef:{default:null},shapePadding:{default:0}});Pe.register("image",{...bt,x:{default:0},y:{default:0},width:{default:100,validate:Ee},height:{default:100,validate:Ee},href:{default:""},originalWidth:{default:0},originalHeight:{default:0},preserveAspectRatio:{default:!0},imageOpacity:{default:1,validate:da}});Pe.register("path",{...bt,x:{default:0},y:{default:0},width:{default:0,validate:Ee},height:{default:0,validate:Ee},pathPoints:{default:[]},pathArcParams:{default:[]},pathControlBounds:{default:null},startEndpoint:{default:"none"},endEndpoint:{default:"none"}});Pe.register("polyline",{...bt,x:{default:0},y:{default:0},width:{default:0,validate:Ee},height:{default:0,validate:Ee},polylinePoints:{default:[]},polylineClosed:{default:!1}});Pe.register("triangle",{...fr,sides:{default:3}});Pe.register("ngon",{...fr,sides:{default:6,validate:uB}});Pe.register("star",{...fr,arms:{default:5,validate:fB},innerRadiusPercent:{default:40,validate:Ft}});Pe.register("cross",{...fr,armWidthPercent:{default:30,validate:Ft}});Pe.register("ring",{...fr,innerRadiusPercent:{default:50,validate:Ft}});Pe.register("spiral",{...fr,turns:{default:3,validate:mB},thicknessPercent:{default:15,validate:Ft},spiralDirection:{default:1}});Pe.register("gear",{...fr,teeth:{default:8,validate:pB},toothDepthPercent:{default:25,validate:Ft},holeRadiusPercent:{default:20,validate:Ft}});Pe.register("arrow",{...fr,headWidthPercent:{default:100,validate:Ft},headLengthPercent:{default:40,validate:Ft},shaftWidthPercent:{default:40,validate:Ft}});Pe.register("symbol-instance",{...bt,x:{default:0},y:{default:0},width:{default:100,validate:Ee},height:{default:100,validate:Ee},symbolId:{default:""}});Pe.register("group",{...bt});Pe.register("container",{...bt});Pe.register("cloud",{...fr,cloudBumps:{default:5},cloudPuffinessPercent:{default:60,validate:Ft}});Pe.register("heart",{...fr,lobeRadiusPercent:{default:50,validate:Ft},cleftDepthPercent:{default:25,validate:Ft}});Pe.register("lightning",{...fr,boltSegments:{default:3},boltWidthPercent:{default:30,validate:Ft},boltJaggednessPercent:{default:40,validate:Ft}});Pe.register("speechBubble",{...fr,tailAngleDeg:{default:45},tailLengthPercent:{default:40,validate:Ft},tailWidthPercent:{default:25,validate:Ft}});Pe.register("diamond",{...ua});Pe.register("parallelogram",{...ua,slantPercent:{default:20,validate:Ft}});Pe.register("trapezoid",{...ua,topWidthPercent:{default:70,validate:Ft}});Pe.register("terminator",{...ua});Pe.register("cylinder",{...ua,capHeightPercent:{default:15,validate:Ft}});Pe.register("document-shape",{...ua,waveAmplitudePercent:{default:15,validate:Ft}});Pe.register("hyperlink",{...bt,href:{default:""},hrefXlink:{default:""},linkTarget:{default:""},linkPing:{default:""},linkRel:{default:""},linkHreflang:{default:""},linkType:{default:""},linkReferrerPolicy:{default:""}});Pe.register("switch",{...bt,switchSystemLanguage:{default:null},switchRequiredExtensions:{default:null}});Pe.register("svg",{...bt});Pe.register("view",{...bt,viewBoxX:{default:0},viewBoxY:{default:0},viewBoxWidth:{default:0,validate:Ee},viewBoxHeight:{default:0,validate:Ee},viewName:{default:""},viewPreserveAspectRatio:{default:""},viewTarget:{default:""}});Pe.register("shape-reference",{...bt,targetShapeId:{default:""},offsetX:{default:0},offsetY:{default:0},targetWidth:{default:0,validate:Ee},targetHeight:{default:0,validate:Ee},broken:{default:!1}});Pe.register("foreign-object",{...bt,x:{default:0},y:{default:0},width:{default:0,validate:Ee},height:{default:0,validate:Ee},foreignContent:{default:[]}});Pe.register("video",{...ZP,mediaKind:{default:"video"}});Pe.register("audio",{...ZP,mediaKind:{default:"audio"}});Pe.register("document",{});function Eb(e){let t=new Set;for(let n of e??[])bn(n,{onShape:r=>{r.id&&t.add(r.id)}});return t}function pr(e){let t=Eb(e.shapes),n=new Map;for(let i of e.library??[]){let o=new Set([i.id]);if(i.kind==="symbol"||i.kind==="marker")for(let s of Eb(i.shapes))o.add(s);if(i.kind==="symbol")for(let s of Object.values(i.variants??{}))for(let a of Eb(s))o.add(a);for(let s of o){let a=n.get(s)??new Set;a.add(i.id),n.set(s,a)}}let r=new Map;for(let[i,o]of n)r.set(i,Object.freeze([...o].sort()));return{documentParentIds:t,definitionIdsByParentId:r,resolve(i){if(i.parentDefinitionId!==void 0)return(r.get(i.parentId)??[]).includes(i.parentDefinitionId)?{kind:"library",definitionId:i.parentDefinitionId}:{kind:"missing"};if(t.has(i.parentId))return{kind:"document"};let o=r.get(i.parentId)??[];return o.length===1?{kind:"library",definitionId:o[0]}:o.length>1?{kind:"ambiguous",definitionIds:o}:{kind:"missing"}}}}var SB;function bB(){return SB??=new Set([...Pe.typeIds().filter(e=>e!=="document"),"spline"])}function to(e){let t=[],n=[];if(e==null||typeof e!="object")return t.push({path:"",message:"Snapshot must be a non-null object",severity:"error"}),{valid:!1,errors:t,warnings:n};let r=e;for(let o of Object.keys(r))o in an||n.push({path:o,message:`Unknown top-level field "${o}" (likely written by a newer version); it is preserved in the unknownFields quarantine on save`,severity:"warning"});let i={doc:r,errors:t,warnings:n};for(let o of Object.keys(an)){let s=r[o];s===void 0&&!an[o].required||NB[o](s,i)}return IB(r,t),{valid:t.length===0,errors:t,warnings:n}}function de(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function vB(e){let t=new Map,n=r=>{if(Array.isArray(r)){for(let i of r)if(!(!de(i)||!de(i.state))){if(typeof i.id=="string"&&i.type==="text"){let o=new Map,s=i.state.textSpanTree,a=c=>{if(Array.isArray(c))for(let l of c)de(l)&&(typeof l.spanId=="string"&&l.spanId.length>0&&o.set(l.spanId,{start:l.start,end:l.end}),a(l.children))};de(s)&&a(s.spans),t.set(i.id,o)}n(i.state.children)}}};return n(e),t}function Ut(e,t,n){return Array.isArray(e)?!0:(n.push({path:t,message:`${t} must be an array`,severity:"error"}),!1)}function fa(e,t,n){e!==void 0&&(typeof e!="number"||!Number.isInteger(e)||e<0)&&n.push({path:t,message:"Definition order must be a non-negative integer",severity:"error"})}function pa(e,t,n){e!==void 0&&(typeof e!="string"||e.length===0)&&n.push({path:t,message:"Definition container id must be a non-empty string",severity:"error"})}function xB(e,t,n,r){if(e===void 0||!Ut(e,t,r))return;let i=new Set;e.forEach((o,s)=>{let a=`${t}[${s}]`;if(!de(o)){r.push({path:a,message:"Animation track must be an object",severity:"error"});return}if(typeof o.id!="string"||o.id.length===0?r.push({path:`${a}.id`,message:"Animation track id must be a non-empty string",severity:"error"}):i.has(o.id)?r.push({path:`${a}.id`,message:`Duplicate animation track id: "${o.id}"`,severity:"error"}):i.add(o.id),(typeof o.shapeId!="string"||!n.has(o.shapeId))&&r.push({path:`${a}.shapeId`,message:"Definition animation must target a shape owned by the definition",severity:"error"}),!Array.isArray(o.keyframes)){r.push({path:`${a}.keyframes`,message:"Animation track keyframes must be an array",severity:"error"});return}let c=new Set;o.keyframes.forEach((l,d)=>{let u=`${a}.keyframes[${d}].id`;!de(l)||typeof l.id!="string"||!l.id?r.push({path:u,message:"Animation keyframe id must be a non-empty string",severity:"error"}):c.has(l.id)?r.push({path:u,message:`Duplicate animation keyframe id: "${l.id}"`,severity:"error"}):c.add(l.id)})})}function IB(e,t){let n=new Set(Array.isArray(e.definitionContainers)?e.definitionContainers.flatMap(s=>de(s)&&typeof s.id=="string"?[s.id]:[]):[]),r=(s,a)=>{!de(s)||s.definitionContainerId===void 0||typeof s.definitionContainerId!="string"||s.definitionContainerId.length===0||n.has(s.definitionContainerId)||t.push({path:`${a}.definitionContainerId`,message:`Definition container "${s.definitionContainerId}" does not exist`,severity:"error"})};for(let[s,a]of[["documentExtensions",e.documentExtensions],["documentStyles",e.documentStyles],["library",e.library],["paintServerDefs",e.paintServerDefs],["clipMaskGroups",e.clipMaskGroups]])Array.isArray(a)&&a.forEach((c,l)=>r(c,`${s}[${l}]`));de(e.animationTimeline)&&Array.isArray(e.animationTimeline.tracks)&&e.animationTimeline.tracks.forEach((s,a)=>{if(!de(s)||s.sourceSmilDefinitionContainerId===void 0)return;let c=s.sourceSmilDefinitionContainerId;typeof c!="string"||c.length===0||n.has(c)||t.push({path:`animationTimeline.tracks[${a}].sourceSmilDefinitionContainerId`,message:`Definition container "${c}" does not exist`,severity:"error"})});let i=new Set(Array.isArray(e.library)?e.library.flatMap(s=>de(s)&&typeof s.id=="string"?[s.id]:[]):[]);Array.isArray(e.documentStyles)&&e.documentStyles.forEach((s,a)=>{!de(s)||s.scopeDefinitionId===void 0||typeof s.scopeDefinitionId!="string"||s.scopeDefinitionId.length===0||i.has(s.scopeDefinitionId)||t.push({path:`documentStyles[${a}].scopeDefinitionId`,message:`Scoped definition "${s.scopeDefinitionId}" does not exist`,severity:"error"})});let o=(s,a)=>{Array.isArray(s)&&s.forEach((c,l)=>{let d=`${a}[${l}]`;!de(c)||!de(c.state)||(r(c.state,`${d}.state`),o(c.state.children,`${d}.state.children`))})};o(e.shapes,"shapes"),Array.isArray(e.library)&&e.library.forEach((s,a)=>{de(s)&&o(s.shapes,`library[${a}].shapes`)})}var wB=new Set(["text","comment","cdata","processing-instruction"]);function eT(e,t,n){if(!de(e)){n.push({path:t,message:"Document extension attribute must be a plain object",severity:"error"});return}for(let r of["name","localName","value"])typeof e[r]!="string"&&n.push({path:`${t}.${r}`,message:`${r} must be a string`,severity:"error"});for(let r of["prefix","namespaceUri"])e[r]!==null&&typeof e[r]!="string"&&n.push({path:`${t}.${r}`,message:`${r} must be a string or null`,severity:"error"})}function tT(e,t,n){let r=[{node:e,path:t,depth:0}];for(;r.length>0;){let i=r.pop();if(i.depth>64){n.push({path:i.path,message:"Document extension nesting exceeds 64 levels",severity:"error"});continue}if(!de(i.node)){n.push({path:i.path,message:"Document extension node must be a plain object",severity:"error"});continue}let o=i.node;if(o.kind==="element"){for(let s of["name","localName"])(typeof o[s]!="string"||o[s].length===0)&&n.push({path:`${i.path}.${s}`,message:`${s} must be a non-empty string`,severity:"error"});for(let s of["prefix","namespaceUri"])o[s]!==null&&typeof o[s]!="string"&&n.push({path:`${i.path}.${s}`,message:`${s} must be a string or null`,severity:"error"});Ut(o.attributes,`${i.path}.attributes`,n)&&o.attributes.forEach((s,a)=>eT(s,`${i.path}.attributes[${a}]`,n)),Ut(o.children,`${i.path}.children`,n)&&o.children.forEach((s,a)=>r.push({node:s,path:`${i.path}.children[${a}]`,depth:i.depth+1}));continue}wB.has(String(o.kind))||n.push({path:`${i.path}.kind`,message:"Unsupported document extension node kind",severity:"error"}),typeof o.value!="string"&&n.push({path:`${i.path}.value`,message:"Document extension character value must be a string",severity:"error"})}}function kB(e,t,n,r){if(!de(e)){n.push({path:t,message:"Document extension must be a plain object",severity:"error"});return}typeof e.id!="string"||e.id.length===0?n.push({path:`${t}.id`,message:"Document extension id must be a non-empty string",severity:"error"}):r.has(e.id)?n.push({path:`${t}.id`,message:`Duplicate document extension id: "${e.id}"`,severity:"error"}):r.add(e.id),e.placement!=="root"&&e.placement!=="defs"&&n.push({path:`${t}.placement`,message:"Document extension placement must be root or defs",severity:"error"}),(typeof e.order!="number"||!Number.isInteger(e.order)||e.order<0)&&n.push({path:`${t}.order`,message:"Document extension order must be a non-negative integer",severity:"error"}),fa(e.definitionOrder,`${t}.definitionOrder`,n),pa(e.definitionContainerId,`${t}.definitionContainerId`,n),tT(e.element,`${t}.element`,n)}var PB=new Set(["x1","y1","x2","y2","gradientTransform"]),TB=new Set(["cx","cy","fx","fy","r","fr","gradientTransform"]),RB=new Set(["x","y","width","height"]);function Cn(e,t,n){e.push({path:t,message:n,severity:"error"})}function CB(e,t,n,r){if(!de(e)){Cn(r,t,"Gradient must be a plain object");return}if(e.templateId!==void 0&&typeof e.templateId!="string"&&Cn(r,`${t}.templateId`,"templateId must be a string"),e.rootAttributes!==void 0)if(!de(e.rootAttributes))Cn(r,`${t}.rootAttributes`,"Gradient rootAttributes must be a plain object");else for(let[o,s]of Object.entries(e.rootAttributes))vi(o)||Cn(r,`${t}.rootAttributes.${o}`,"Gradient root attributes must be safe non-typed attributes"),typeof s!="string"&&Cn(r,`${t}.rootAttributes.${o}`,"Gradient root attribute values must be strings");let i=n==="linear-gradient"?["x1","y1","x2","y2","opacity"]:["cx","cy","fx","fy","r","ry","rotation","opacity"];for(let o of i)e[o]!==void 0&&(typeof e[o]!="number"||!Number.isFinite(e[o]))&&Cn(r,`${t}.${o}`,`${o} must be a finite number`);if(e.fr!==void 0&&(typeof e.fr!="number"||!Number.isFinite(e.fr))&&Cn(r,`${t}.fr`,"fr must be a finite number"),e.authoredGeometry!==void 0)if(!de(e.authoredGeometry))Cn(r,`${t}.authoredGeometry`,"Gradient authoredGeometry must be a plain object");else{let o=n==="linear-gradient"?PB:TB;for(let[s,a]of Object.entries(e.authoredGeometry))o.has(s)?typeof a!="string"&&Cn(r,`${t}.authoredGeometry.${s}`,"Authored gradient geometry declarations must be strings"):Cn(r,`${t}.authoredGeometry.${s}`,"is not a supported authored gradient geometry field")}e.gradientTransform!==void 0&&(!Array.isArray(e.gradientTransform)||e.gradientTransform.length!==6||!e.gradientTransform.every(o=>typeof o=="number"&&Number.isFinite(o)))&&Cn(r,`${t}.gradientTransform`,"gradientTransform must be a 6-element finite affine matrix"),Array.isArray(e.stops)?e.stops.forEach((o,s)=>{if(!de(o)){Cn(r,`${t}.stops[${s}]`,"Gradient stop must be an object");return}o.id!==void 0&&(typeof o.id!="string"||o.id.length===0)&&Cn(r,`${t}.stops[${s}].id`,"id must be a nonempty string");for(let a of["offset","opacity"])o[a]!==void 0&&(typeof o[a]!="number"||!Number.isFinite(o[a]))&&Cn(r,`${t}.stops[${s}].${a}`,`${a} must be a finite number`)}):Cn(r,`${t}.stops`,"Gradient stops must be an array")}function AB(e,t,n){if(!de(e)){n.push({path:t,message:"Pattern must be a plain object",severity:"error"});return}if(e.templateId!==void 0&&typeof e.templateId!="string"&&n.push({path:`${t}.templateId`,message:"templateId must be a string",severity:"error"}),e.rootAttributes!==void 0)if(!de(e.rootAttributes))n.push({path:`${t}.rootAttributes`,message:"Pattern rootAttributes must be a plain object",severity:"error"});else for(let[r,i]of Object.entries(e.rootAttributes))xi(r)||n.push({path:`${t}.rootAttributes.${r}`,message:"Pattern root attributes must be safe non-typed attributes",severity:"error"}),typeof i!="string"&&n.push({path:`${t}.rootAttributes.${r}`,message:"Pattern root attribute values must be strings",severity:"error"});for(let r of["x","y","width","height","scale","rotation","opacity"])e[r]!==void 0&&(typeof e[r]!="number"||!Number.isFinite(e[r]))&&n.push({path:`${t}.${r}`,message:`${r} must be a finite number`,severity:"error"});e.patternUnits!==void 0&&e.patternUnits!=="userSpaceOnUse"&&e.patternUnits!=="objectBoundingBox"&&n.push({path:`${t}.patternUnits`,message:"patternUnits must be userSpaceOnUse or objectBoundingBox",severity:"error"}),e.patternContentUnits!==void 0&&e.patternContentUnits!=="userSpaceOnUse"&&e.patternContentUnits!=="objectBoundingBox"&&n.push({path:`${t}.patternContentUnits`,message:"patternContentUnits must be userSpaceOnUse or objectBoundingBox",severity:"error"});for(let r of["svgContent","patternTransform","viewBox","preserveAspectRatio"])e[r]!==void 0&&typeof e[r]!="string"&&n.push({path:`${t}.${r}`,message:`${r} must be a string`,severity:"error"});if(e.authoredGeometry!==void 0)if(!de(e.authoredGeometry))n.push({path:`${t}.authoredGeometry`,message:"Pattern authoredGeometry must be a plain object",severity:"error"});else for(let[r,i]of Object.entries(e.authoredGeometry))RB.has(r)?typeof i!="string"&&n.push({path:`${t}.authoredGeometry.${r}`,message:"Authored pattern geometry declarations must be strings",severity:"error"}):n.push({path:`${t}.authoredGeometry.${r}`,message:"is not a supported authored pattern geometry field",severity:"error"})}var NB={schemaVersion:(e,{errors:t,warnings:n})=>{typeof e!="number"||!Number.isInteger(e)?t.push({path:"schemaVersion",message:"schemaVersion must be an integer",severity:"error"}):e>Pn&&n.push({path:"schemaVersion",message:`schemaVersion ${e} is newer than supported (${Pn})`,severity:"warning"})},shapes:(e,{errors:t,warnings:n})=>{if(!Ut(e,"shapes",t))return;let r=new Set;e.forEach((i,o)=>{Db(i,`shapes[${o}]`,t,n,r)})},viewboxes:(e,{errors:t})=>{if(!Ut(e,"viewboxes",t))return;let n=new Set;e.forEach((r,i)=>{LB(r,`viewboxes[${i}]`,t,n)})},guides:(e,{errors:t})=>{Ut(e,"guides",t)&&e.forEach((n,r)=>{_B(n,`guides[${r}]`,t)})},measurements:(e,{errors:t})=>{Ut(e,"measurements",t)&&e.forEach((n,r)=>{let i=`measurements[${r}]`;if(!de(n)){t.push({path:i,message:"Measurement must be a non-null object",severity:"error"});return}(typeof n.id!="string"||n.id.length===0)&&t.push({path:`${i}.id`,message:"Measurement id must be a non-empty string",severity:"error"})})},sceneTree:(e,{doc:t,errors:n,warnings:r})=>{if(!Ut(e,"sceneTree",n))return;let i=Ob(t.shapes),o=new Set;e.forEach((s,a)=>{EB(s,`sceneTree[${a}]`,n,r,i,o)})},clipMaskGroups:(e,{doc:t,errors:n,warnings:r})=>{if(!Ut(e,"clipMaskGroups",n))return;let i=Ob(t.shapes),o=pr(t);e.forEach((s,a)=>{BB(s,`clipMaskGroups[${a}]`,n,r,i,o)})},documentMetadata:(e,{errors:t})=>{de(e)||t.push({path:"documentMetadata",message:"documentMetadata must be a plain object",severity:"error"})},documentExtensions:(e,{errors:t})=>{if(!Ut(e,"documentExtensions",t))return;let n=new Set;e.forEach((r,i)=>kB(r,`documentExtensions[${i}]`,t,n))},definitionContainers:(e,{doc:t,errors:n})=>{if(!Ut(e,"definitionContainers",n))return;let r=new Set,i=new Set,o=pr(t);e.forEach((s,a)=>{let c=`definitionContainers[${a}]`;if(!de(s)){n.push({path:c,message:"Definition container must be a plain object",severity:"error"});return}typeof s.id!="string"||s.id.length===0?n.push({path:`${c}.id`,message:"Definition container id must be a non-empty string",severity:"error"}):r.has(s.id)?n.push({path:`${c}.id`,message:`Duplicate definition container id: "${s.id}"`,severity:"error"}):r.add(s.id),s.svgId!==void 0&&(typeof s.svgId!="string"||s.svgId.length===0)&&n.push({path:`${c}.svgId`,message:"Definition container svgId must be a non-empty string",severity:"error"}),typeof s.order!="number"||!Number.isInteger(s.order)||s.order<0?n.push({path:`${c}.order`,message:"Definition container order must be a non-negative integer",severity:"error"}):i.has(s.order)?n.push({path:`${c}.order`,message:`Duplicate definition container order: ${s.order}`,severity:"error"}):i.add(s.order),Nl(s.authoredPlacement,`${c}.authoredPlacement`,n,o,"Definition container"),s.attributes!==void 0&&Ut(s.attributes,`${c}.attributes`,n)&&s.attributes.forEach((l,d)=>{let u=`${c}.attributes[${d}]`;eT(l,u,n),de(l)&&l.localName==="id"&&l.namespaceUri===null&&n.push({path:u,message:"Definition container attributes must not duplicate svgId authority",severity:"error"})})})},documentScripts:(e,{errors:t})=>{Ut(e,"documentScripts",t)&&e.forEach((n,r)=>{let i=`documentScripts[${r}]`;if(!de(n)){t.push({path:i,message:"Document script must be a non-null object",severity:"error"});return}(typeof n.id!="string"||n.id.length===0)&&t.push({path:`${i}.id`,message:"Document script id must be a non-empty string",severity:"error"})})},documentStyles:(e,{doc:t,errors:n})=>{if(!Ut(e,"documentStyles",n))return;let r=pr(t);e.forEach((i,o)=>{let s=`documentStyles[${o}]`;if(!de(i)){n.push({path:s,message:"Document style must be a non-null object",severity:"error"});return}(typeof i.id!="string"||i.id.length===0)&&n.push({path:`${s}.id`,message:"Document style id must be a non-empty string",severity:"error"}),typeof i.css!="string"&&n.push({path:`${s}.css`,message:"Document style css must be a string",severity:"error"}),i.placement!=="root"&&i.placement!=="defs"&&n.push({path:`${s}.placement`,message:'Document style placement must be "root" or "defs"',severity:"error"}),fa(i.definitionOrder,`${s}.definitionOrder`,n),pa(i.definitionContainerId,`${s}.definitionContainerId`,n),Nl(i.authoredPlacement,`${s}.authoredPlacement`,n,r,"Document style"),i.scopeDefinitionId!==void 0&&(typeof i.scopeDefinitionId!="string"||i.scopeDefinitionId.length===0)&&n.push({path:`${s}.scopeDefinitionId`,message:"Document style scopeDefinitionId must be a non-empty string",severity:"error"}),i.scopeDefinitionId!==void 0&&i.placement!=="defs"&&n.push({path:`${s}.scopeDefinitionId`,message:"A definition-scoped document style must use defs placement",severity:"error"})})},templateVariables:(e,{errors:t})=>{Ut(e,"templateVariables",t)&&e.forEach((n,r)=>{let i=`templateVariables[${r}]`;if(!de(n)){t.push({path:i,message:"Template variable must be a non-null object",severity:"error"});return}(typeof n.name!="string"||n.name.length===0)&&t.push({path:`${i}.name`,message:"Template variable name must be a non-empty string",severity:"error"})})},animationTimeline:(e,{doc:t,errors:n})=>{if(!de(e)){n.push({path:"animationTimeline",message:"animationTimeline must be a plain object",severity:"error"});return}if(e.tracks!==void 0&&!Array.isArray(e.tracks)){n.push({path:"animationTimeline.tracks",message:"animationTimeline.tracks must be an array",severity:"error"});return}if(e.cssAnimationDocumentStylesFingerprint!==void 0&&(typeof e.cssAnimationDocumentStylesFingerprint!="string"||e.cssAnimationDocumentStylesFingerprint.length===0)&&n.push({path:"animationTimeline.cssAnimationDocumentStylesFingerprint",message:"CSS animation document-style fingerprint must be a non-empty string",severity:"error"}),e.cssAnimationInlineStylesFingerprint!==void 0&&(typeof e.cssAnimationInlineStylesFingerprint!="string"||e.cssAnimationInlineStylesFingerprint.length===0)&&n.push({path:"animationTimeline.cssAnimationInlineStylesFingerprint",message:"CSS animation inline-style fingerprint must be a non-empty string",severity:"error"}),e.cssAnimationSources!==void 0)if(!Array.isArray(e.cssAnimationSources))n.push({path:"animationTimeline.cssAnimationSources",message:"CSS animation sources must be an array",severity:"error"});else{let r=new Set,i=new Set;e.cssAnimationSources.forEach((o,s)=>{let a=`animationTimeline.cssAnimationSources[${s}]`;if(!de(o)){n.push({path:a,message:"CSS animation source must be an object",severity:"error"});return}if(typeof o.id!="string"||o.id.length===0?n.push({path:`${a}.id`,message:"CSS animation source id must be a non-empty string",severity:"error"}):r.has(o.id)?n.push({path:`${a}.id`,message:`Duplicate CSS animation source id: "${o.id}"`,severity:"error"}):r.add(o.id),!Array.isArray(o.trackIds)||!Array.isArray(o.trackFingerprints)){n.push({path:a,message:"CSS animation source track ids and fingerprints must be arrays",severity:"error"});return}o.trackIds.length!==o.trackFingerprints.length&&n.push({path:a,message:"CSS animation source track ids and fingerprints must have equal lengths",severity:"error"}),o.trackIds.forEach((c,l)=>{typeof c!="string"||c.length===0?n.push({path:`${a}.trackIds[${l}]`,message:"CSS animation source track id must be a non-empty string",severity:"error"}):i.has(c)?n.push({path:`${a}.trackIds[${l}]`,message:`Duplicate CSS animation source track id: "${c}"`,severity:"error"}):i.add(c)}),o.trackFingerprints.forEach((c,l)=>{(typeof c!="string"||c.length===0)&&n.push({path:`${a}.trackFingerprints[${l}]`,message:"CSS animation track fingerprint must be a non-empty string",severity:"error"})})})}if(Array.isArray(e.tracks)&&Number(t.schemaVersion)>=11){let r=vB(t.shapes);e.tracks.forEach((i,o)=>{if(!de(i)||!Array.isArray(i.keyframes))return;if(i.sourceCssAnimationId!==void 0&&(typeof i.sourceCssAnimationId!="string"||!i.sourceCssAnimationId)&&n.push({path:`animationTimeline.tracks[${o}].sourceCssAnimationId`,message:"CSS animation source id must be a non-empty string",severity:"error"}),i.definitionTarget!==void 0){let a=`animationTimeline.tracks[${o}].definitionTarget`;if(!de(i.definitionTarget))n.push({path:a,message:"must be an object",severity:"error"});else{let c=i.definitionTarget.definitionId,l=i.definitionTarget.nodeId;if((typeof c!="string"||c.length===0)&&n.push({path:`${a}.definitionId`,message:"must be a non-empty string",severity:"error"}),l!==void 0&&(typeof l!="string"||l.length===0)&&n.push({path:`${a}.nodeId`,message:"must be a non-empty string when present",severity:"error"}),typeof c=="string"&&c.length>0){let d=`definition:${c}${typeof l=="string"&&l.length>0?`/${l}`:""}`;i.shapeId!==d&&n.push({path:`animationTimeline.tracks[${o}].shapeId`,message:`definition target tracks must use ${d}`,severity:"error"})}}}if(i.simpleDuration!==void 0&&i.simpleDuration!=="indefinite"&&n.push({path:`animationTimeline.tracks[${o}].simpleDuration`,message:'SMIL simple duration must be "indefinite" when present',severity:"error"}),i.simpleDuration==="indefinite"&&i.cycleDuration!==void 0&&n.push({path:`animationTimeline.tracks[${o}].cycleDuration`,message:"Finite and indefinite SMIL simple durations are mutually exclusive",severity:"error"}),i.sourceSmilPlacement!==void 0&&i.sourceSmilPlacement!=="document"&&i.sourceSmilPlacement!=="defs"&&n.push({path:`animationTimeline.tracks[${o}].sourceSmilPlacement`,message:'SMIL source placement must be "document" or "defs" when present',severity:"error"}),i.sourceSmilParentTarget!==void 0&&i.sourceSmilParentTarget!==!0&&n.push({path:`animationTimeline.tracks[${o}].sourceSmilParentTarget`,message:"SMIL implicit parent target must be true when present",severity:"error"}),i.sourceSmilParentTarget===!0&&i.sourceSmilPlacement!=="document"&&n.push({path:`animationTimeline.tracks[${o}].sourceSmilPlacement`,message:"SMIL implicit parent target requires document placement",severity:"error"}),i.sourceSmilOrder!==void 0&&(!Number.isInteger(i.sourceSmilOrder)||Number(i.sourceSmilOrder)<0)&&n.push({path:`animationTimeline.tracks[${o}].sourceSmilOrder`,message:"SMIL source order must be a non-negative integer when present",severity:"error"}),i.sourceSmilDefinitionOrder!==void 0&&(!Number.isInteger(i.sourceSmilDefinitionOrder)||Number(i.sourceSmilDefinitionOrder)<0)&&n.push({path:`animationTimeline.tracks[${o}].sourceSmilDefinitionOrder`,message:"SMIL definition order must be a non-negative integer when present",severity:"error"}),i.sourceSmilDefinitionContainerId!==void 0&&(typeof i.sourceSmilDefinitionContainerId!="string"||i.sourceSmilDefinitionContainerId.length===0)&&n.push({path:`animationTimeline.tracks[${o}].sourceSmilDefinitionContainerId`,message:"SMIL definition container id must be a non-empty string when present",severity:"error"}),(i.sourceSmilDefinitionOrder!==void 0||i.sourceSmilDefinitionContainerId!==void 0)&&i.sourceSmilPlacement!=="defs"&&n.push({path:`animationTimeline.tracks[${o}].sourceSmilPlacement`,message:'SMIL definition placement fields require sourceSmilPlacement "defs"',severity:"error"}),i.textPathStartOffsetUnit!==void 0&&i.textPathStartOffsetUnit!=="%"&&i.textPathStartOffsetUnit!=="user"&&n.push({path:`animationTimeline.tracks[${o}].textPathStartOffsetUnit`,message:'Text path start-offset unit must be "%" or "user" when present',severity:"error"}),i.textSpanTarget!==void 0){let a=`animationTimeline.tracks[${o}].textSpanTarget`;if(!de(i.textSpanTarget))n.push({path:a,message:"Text span target must be a plain object",severity:"error"});else{let c=i.textSpanTarget;if((typeof c.attributeName!="string"||c.attributeName.length===0)&&n.push({path:`${a}.attributeName`,message:"Text span target attribute name must be a non-empty string",severity:"error"}),!Array.isArray(c.spanIds)||c.spanIds.length===0||c.spanIds.some(l=>typeof l!="string"||l.length===0)||new Set(c.spanIds).size!==c.spanIds.length)n.push({path:`${a}.spanIds`,message:"Text span target ids must be unique non-empty strings",severity:"error"});else{let l=typeof i.shapeId=="string"?r.get(i.shapeId):void 0;if(!l)n.push({path:a,message:"Text span animation must target a canonical text shape",severity:"error"});else{c.spanIds.forEach((u,f)=>{l.has(u)||n.push({path:`${a}.spanIds[${f}]`,message:`Text span animation target "${u}" does not exist on shape "${i.shapeId}"`,severity:"error"})});let d=c.spanIds.map(u=>l.get(u));if(d.every(u=>u&&typeof u.start=="number"&&Number.isInteger(u.start)&&typeof u.end=="number"&&Number.isInteger(u.end))){let u=d[0].end;d.slice(1).every(p=>{let m=p;return m.start!==u?!1:(u=m.end,!0)})||n.push({path:`${a}.spanIds`,message:"Text span animation target ids must describe one ordered contiguous range",severity:"error"})}}}}}let s=new Set;i.keyframes.forEach((a,c)=>{let l=`animationTimeline.tracks[${o}].keyframes[${c}].id`;if(!de(a)||typeof a.id!="string"||!a.id){n.push({path:l,message:"Animation keyframe id must be a non-empty string",severity:"error"});return}if(s.has(a.id)){n.push({path:l,message:`Duplicate animation keyframe id: "${a.id}"`,severity:"error"});return}s.add(a.id)})})}},library:(e,{doc:t,errors:n,warnings:r})=>{if(!Ut(e,"library",n))return;let i=new Set,o=pr(t);e.forEach((c,l)=>{let d=`library[${l}]`;if(!de(c)){n.push({path:d,message:"Library def must be a non-null object",severity:"error"});return}if(typeof c.id!="string"||c.id.length===0?n.push({path:`${d}.id`,message:"Library def id must be a non-empty string",severity:"error"}):i.has(c.id)?n.push({path:`${d}.id`,message:`Duplicate library def id: "${c.id}"`,severity:"error"}):i.add(c.id),(typeof c.kind!="string"||c.kind.length===0)&&n.push({path:`${d}.kind`,message:"Library def kind must be a non-empty string",severity:"error"}),c.definitionPlacement!==void 0&&!["defs","document"].includes(String(c.definitionPlacement))&&n.push({path:`${d}.definitionPlacement`,message:"Library definitionPlacement must be defs or document",severity:"error"}),fa(c.definitionOrder,`${d}.definitionOrder`,n),pa(c.definitionContainerId,`${d}.definitionContainerId`,n),Nl(c.authoredPlacement,`${d}.authoredPlacement`,n,o,"Library"),c.kind==="symbol"||c.kind==="marker"){let u=Ob(c.shapes);if(typeof c.id=="string"&&c.id.length>0&&u.add(c.id),xB(c.animations,`${d}.animations`,u,n),c.kind==="symbol"){let f=typeof t.schemaVersion=="number"&&t.schemaVersion>=8;if(c.defKind!==void 0&&!["symbol","group","shape"].includes(String(c.defKind))&&n.push({path:`${d}.defKind`,message:"Symbol defKind must be symbol, group, or shape",severity:"error"}),c.definitionPlacement==="document"&&(c.defKind??"symbol")!=="symbol"&&n.push({path:`${d}.definitionPlacement`,message:"Only symbol roots may use document definition placement",severity:"error"}),c.defKind==="shape"&&(!Array.isArray(c.shapes)||c.shapes.length!==1)&&n.push({path:`${d}.shapes`,message:"Native shape definitions must contain exactly one root shape",severity:"error"}),f)for(let p of["wrapperAttrs","groups","overflow"])c[p]!==void 0&&n.push({path:`${d}.${p}`,message:`Symbol ${p} is schema-v7 migration input only`,severity:"error"});for(let p of["viewBox","preserveAspectRatio","x","y","width","height","refX","refY"])c[p]!==void 0&&typeof c[p]!="string"&&n.push({path:`${d}.${p}`,message:`Symbol ${p} must be a string when present`,severity:"error"});if(c.rootAttributes!==void 0)if(!de(c.rootAttributes))n.push({path:`${d}.rootAttributes`,message:"Symbol rootAttributes must be a plain object",severity:"error"});else for(let[p,m]of Object.entries(c.rootAttributes))f&&["viewBox","preserveAspectRatio","x","y","width","height","refX","refY"].includes(p)&&n.push({path:`${d}.rootAttributes.${p}`,message:`Symbol ${p} must use its typed root field`,severity:"error"}),typeof m!="string"&&n.push({path:`${d}.rootAttributes.${p}`,message:"Symbol root attribute values must be strings",severity:"error"});if(c.definitionContentOrder!==void 0)if(!Array.isArray(c.definitionContentOrder))n.push({path:`${d}.definitionContentOrder`,message:"Symbol definitionContentOrder must be an array",severity:"error"});else{let p=new Set(Array.isArray(c.shapes)?c.shapes.filter(g=>de(g)).map(g=>g.id).filter(g=>typeof g=="string"&&g.length>0):[]),m=new Set;c.definitionContentOrder.forEach((g,h)=>{let y=`${d}.definitionContentOrder[${h}]`;if(!de(g)){n.push({path:y,message:"Definition content entry must be a plain object",severity:"error"});return}if(g.kind!=="shape"&&g.kind!=="definition"&&n.push({path:`${y}.kind`,message:"Definition content kind must be shape or definition",severity:"error"}),typeof g.id!="string"||g.id.length===0){n.push({path:`${y}.id`,message:"Definition content id must be a non-empty string",severity:"error"});return}let S=`${String(g.kind)}\0${g.id}`;m.has(S)&&n.push({path:y,message:`Duplicate definition content entry: ${String(g.kind)} "${g.id}"`,severity:"error"}),m.add(S),g.kind==="shape"&&!p.has(g.id)&&n.push({path:`${y}.id`,message:`Definition content shape "${g.id}" is not a root shape of this definition`,severity:"error"})})}}if(c.kind==="marker"){for(let f of["viewBox","preserveAspectRatio"])c[f]!==void 0&&typeof c[f]!="string"&&n.push({path:`${d}.${f}`,message:`Marker ${f} must be a string when present`,severity:"error"});if(c.authoredGeometry!==void 0)if(!de(c.authoredGeometry))n.push({path:`${d}.authoredGeometry`,message:"Marker authoredGeometry must be a plain object",severity:"error"});else for(let[f,p]of Object.entries(c.authoredGeometry))typeof p!="string"&&n.push({path:`${d}.authoredGeometry.${f}`,message:"Marker authored geometry declarations must be strings",severity:"error"});if(c.rootAttributes!==void 0)if(!de(c.rootAttributes))n.push({path:`${d}.rootAttributes`,message:"Marker rootAttributes must be a plain object",severity:"error"});else for(let[f,p]of Object.entries(c.rootAttributes))["id","viewBox","preserveAspectRatio","refX","refY","markerWidth","markerHeight","markerUnits","orient"].includes(f)&&n.push({path:`${d}.rootAttributes.${f}`,message:`Marker ${f} must use its typed root field`,severity:"error"}),typeof p!="string"&&n.push({path:`${d}.rootAttributes.${f}`,message:"Marker root attribute values must be strings",severity:"error"})}if(Array.isArray(c.shapes)){let f=new Set;c.shapes.forEach((p,m)=>{Db(p,`${d}.shapes[${m}]`,n,r,f)})}if(c.kind==="symbol"&&de(c.variants))for(let[f,p]of Object.entries(c.variants)){if(!Array.isArray(p))continue;let m=new Set;p.forEach((g,h)=>{Db(g,`${d}.variants[${f}][${h}]`,n,r,m)})}}(c.kind==="linear-gradient"||c.kind==="radial-gradient")&&CB(c.gradient,`${d}.gradient`,c.kind,n),c.kind==="pattern"&&AB(c.pattern,`${d}.pattern`,n),c.kind==="appearance-style"&&DB(c.layers,`${d}.layers`,n)});let s=new Map;e.forEach((c,l)=>{de(c)&&c.kind==="symbol"&&typeof c.id=="string"&&c.id.length>0&&s.set(c.id,{def:c,index:l})});let a=new Map;for(let[c,{def:l,index:d}]of s)Array.isArray(l.definitionContentOrder)&&l.definitionContentOrder.forEach((u,f)=>{if(!de(u)||u.kind!=="definition"||typeof u.id!="string")return;let p=`library[${d}].definitionContentOrder[${f}].id`;if(u.id===c){n.push({path:p,message:`Symbol definition "${c}" cannot contain itself`,severity:"error"});return}if(!s.has(u.id)){n.push({path:p,message:`Nested symbol definition "${u.id}" does not exist`,severity:"error"});return}let m=a.get(u.id);if(m&&m!==c){n.push({path:p,message:`Nested symbol definition "${u.id}" already belongs to "${m}"`,severity:"error"});return}a.set(u.id,c)});for(let c of s.keys()){let l=new Set,d=c;for(;d!==void 0;){if(l.has(d)){let u=s.get(c);n.push({path:`library[${u?.index??0}].definitionContentOrder`,message:`Symbol definition forest contains a cycle through "${d}"`,severity:"error"});break}l.add(d),d=a.get(d)}}},paintServerDefs:(e,{doc:t,errors:n})=>{if(!Ut(e,"paintServerDefs",n))return;let r=new Set,i=pr(t);e.forEach((o,s)=>{$B(o,`paintServerDefs[${s}]`,n,r,i)})},colorGlyphLibrary:(e,{errors:t})=>{if(!de(e)){t.push({path:"colorGlyphLibrary",message:"colorGlyphLibrary must be a plain object",severity:"error"});return}e.version!==void 0&&!Number.isInteger(e.version)&&t.push({path:"colorGlyphLibrary.version",message:"colorGlyphLibrary.version must be an integer",severity:"error"}),e.entries!==void 0&&!Array.isArray(e.entries)&&t.push({path:"colorGlyphLibrary.entries",message:"colorGlyphLibrary.entries must be an array",severity:"error"})},exportItems:(e,{errors:t})=>{Ut(e,"exportItems",t)&&e.forEach((n,r)=>{let i=`exportItems[${r}]`;if(!de(n)){t.push({path:i,message:"Export item must be a non-null object",severity:"error"});return}(typeof n.id!="string"||n.id.length===0)&&t.push({path:`${i}.id`,message:"Export item id must be a non-empty string",severity:"error"}),typeof n.filename!="string"&&t.push({path:`${i}.filename`,message:"Export item filename must be a string",severity:"error"}),typeof n.format!="string"&&t.push({path:`${i}.format`,message:"Export item format must be a string",severity:"error"})})},unknownFields:(e,{errors:t})=>{de(e)||t.push({path:"unknownFields",message:"unknownFields must be a plain object (forward-compat quarantine bag)",severity:"error"})}};function Ob(e){let t=new Set;if(!Array.isArray(e))return t;for(let n of e)bn(n,{onShape:r=>{typeof r.id=="string"&&r.id.length>0&&t.add(r.id)}});return t}function QP(e){return e.startsWith("structural:")}function EB(e,t,n,r,i,o){if(e===null||typeof e!="object"){n.push({path:t,message:"Scene tree entry must be a non-null object",severity:"error"});return}let s=e;typeof s.id!="string"||s.id.length===0?n.push({path:`${t}.id`,message:"Scene tree id must be a non-empty string",severity:"error"}):(o.has(s.id)&&n.push({path:`${t}.id`,message:`Duplicate scene tree id: "${s.id}"`,severity:"error"}),o.add(s.id),!i.has(s.id)&&!QP(s.id)&&r.push({path:`${t}.id`,message:`Scene tree id "${s.id}" is not present in shapes`,severity:"warning"})),s.parentId!==null&&typeof s.parentId!="string"?n.push({path:`${t}.parentId`,message:"Scene tree parentId must be a string or null",severity:"error"}):typeof s.parentId=="string"&&!i.has(s.parentId)&&!QP(s.parentId)&&r.push({path:`${t}.parentId`,message:`Scene tree parentId "${s.parentId}" is not present in shapes`,severity:"warning"}),(typeof s.index!="number"||!Number.isInteger(s.index)||s.index<0)&&n.push({path:`${t}.index`,message:"Scene tree index must be a non-negative integer",severity:"error"}),s.updatedAt!==void 0&&(typeof s.updatedAt!="number"||!Number.isFinite(s.updatedAt)||s.updatedAt<0)&&n.push({path:`${t}.updatedAt`,message:"Scene tree updatedAt must be a non-negative finite number",severity:"error"}),s.clientId!==void 0&&typeof s.clientId!="string"&&n.push({path:`${t}.clientId`,message:"Scene tree clientId must be a string",severity:"error"})}var OB=new Set(["mask","clipPath","filter","linearGradient","radialGradient","pattern","symbol"]);function Nl(e,t,n,r,i){if(e===void 0)return;if(!de(e)){n.push({path:t,message:`${i} authoredPlacement must be an object`,severity:"error"});return}let o=e.parentId,s=e.parentDefinitionId,a=e.siblingIndex,c=!0;if((typeof o!="string"||o.length===0)&&(n.push({path:`${t}.parentId`,message:"Definition placement parentId must be a non-empty string",severity:"error"}),c=!1),s!==void 0&&(typeof s!="string"||s.length===0)&&(n.push({path:`${t}.parentDefinitionId`,message:"Definition placement parentDefinitionId must be a non-empty string when present",severity:"error"}),c=!1),c){let l=r.resolve(e);l.kind==="missing"?n.push({path:s===void 0?`${t}.parentId`:`${t}.parentDefinitionId`,message:s===void 0?`Definition placement parentId "${String(o)}" does not exist`:`Definition placement parent "${String(o)}" does not exist in library definition "${String(s)}"`,severity:"error"}):l.kind==="ambiguous"&&n.push({path:`${t}.parentId`,message:`Definition placement parentId "${String(o)}" is ambiguous across library definitions: ${l.definitionIds.join(", ")}`,severity:"error"})}(typeof a!="number"||!Number.isInteger(a)||a<0)&&n.push({path:`${t}.siblingIndex`,message:"Definition placement siblingIndex must be a non-negative integer",severity:"error"})}function DB(e,t,n){if(!Array.isArray(e)){n.push({path:t,message:"Appearance style layers must be an array",severity:"error"});return}let r=new Set;e.forEach((i,o)=>{let s=`${t}[${o}]`;if(!de(i)){n.push({path:s,message:"Appearance style layer must be an object",severity:"error"});return}if(i.kind!=="fill"&&i.kind!=="stroke"&&n.push({path:`${s}.kind`,message:"Appearance style layer kind must be fill or stroke",severity:"error"}),typeof i.id!="string"||i.id.length===0){n.push({path:`${s}.id`,message:"Appearance style layer id must be a non-empty string",severity:"error"});return}r.has(i.id)?n.push({path:`${s}.id`,message:`Duplicate appearance style layer id: "${i.id}"`,severity:"error"}):r.add(i.id)})}function $B(e,t,n,r,i){if(e===null||typeof e!="object"){n.push({path:t,message:"Paint server def must be a non-null object",severity:"error"});return}let o=e;typeof o.id!="string"||o.id.length===0?n.push({path:`${t}.id`,message:"Paint server def id must be a non-empty string",severity:"error"}):r.has(o.id)?n.push({path:`${t}.id`,message:`Duplicate paint server def id: "${o.id}"`,severity:"error"}):r.add(o.id),o.sourceId!==void 0&&(typeof o.sourceId!="string"||o.sourceId.length===0)&&n.push({path:`${t}.sourceId`,message:"Paint server def sourceId must be a non-empty string when present",severity:"error"});let s=o.role===void 0?"resource":o.role;s!=="resource"&&s!=="referenced-fragment"&&n.push({path:`${t}.role`,message:"Paint server def role must be resource or referenced-fragment",severity:"error"}),typeof o.type=="string"&&(s==="resource"&&OB.has(o.type)||s==="referenced-fragment"&&/^[A-Za-z][\w.-]*$/u.test(o.type))||n.push({path:`${t}.type`,message:"Paint server def type must be a supported SVG defs element type",severity:"error"}),(typeof o.markup!="string"||o.markup.length===0)&&n.push({path:`${t}.markup`,message:"Paint server def markup must be a non-empty string",severity:"error"}),o.passthrough!==void 0&&typeof o.passthrough!="boolean"&&n.push({path:`${t}.passthrough`,message:"Paint server def passthrough must be a boolean when present",severity:"error"});for(let c of["definitionChildIds","sourceDefinitionChildIds"]){let l=o[c];l!==void 0&&(!Array.isArray(l)||l.some(d=>typeof d!="string"||d.length===0))&&n.push({path:`${t}.${c}`,message:"Definition child ids must be non-empty strings",severity:"error"})}Array.isArray(o.definitionChildIds)&&Array.isArray(o.sourceDefinitionChildIds)&&o.definitionChildIds.length!==o.sourceDefinitionChildIds.length&&n.push({path:t,message:"Definition child id arrays must have equal lengths",severity:"error"}),Nl(o.authoredPlacement,`${t}.authoredPlacement`,n,i,"Paint server def"),fa(o.definitionOrder,`${t}.definitionOrder`,n),pa(o.definitionContainerId,`${t}.definitionContainerId`,n)}function Db(e,t,n,r,i){if(e===null||typeof e!="object"||Array.isArray(e)){n.push({path:t,message:"Shape must be a non-null object",severity:"error"});return}bn(e,{onShape:(o,s)=>{MB(o,`${t}${s}`,n,r,i)}})}function MB(e,t,n,r,i){if(typeof e.id!="string"||e.id.length===0?n.push({path:`${t}.id`,message:"Shape id must be a non-empty string",severity:"error"}):i.has(e.id)?n.push({path:`${t}.id`,message:`Duplicate shape id: "${e.id}"`,severity:"error"}):i.add(e.id),typeof e.type!="string"?n.push({path:`${t}.type`,message:"Shape type must be a string",severity:"error"}):bB().has(e.type)||r.push({path:`${t}.type`,message:`Unknown shape type: "${e.type}"`,severity:"warning"}),e.state===void 0||e.state===null||typeof e.state!="object")n.push({path:`${t}.state`,message:"Shape state must be a non-null object",severity:"error"});else{let o=e.state;FB(o,`${t}.state`,n,r),e.type==="foreign-object"&&(Object.hasOwn(o,"rawContent")&&n.push({path:`${t}.state.rawContent`,message:"rawContent is noncanonical; use structured foreignContent nodes",severity:"error"}),o.foreignContent!==void 0&&Ut(o.foreignContent,`${t}.state.foreignContent`,n)&&o.foreignContent.forEach((s,a)=>tT(s,`${t}.state.foreignContent[${a}]`,n))),o.children!==void 0&&!Array.isArray(o.children)?n.push({path:`${t}.state.children`,message:"children must be an array",severity:"error"}):Array.isArray(o.children)&&o.children.forEach((s,a)=>{(s===null||typeof s!="object"||Array.isArray(s))&&n.push({path:`${t}.state.children[${a}]`,message:"Shape must be a non-null object",severity:"error"})})}}var zB=/^\s*\{\{\s*[\w.\-]+\s*\}\}\s*$/;function JP(e){return typeof e=="number"?isFinite(e):typeof e=="string"?zB.test(e):!1}function FB(e,t,n,r){if(fa(e.definitionOrder,`${t}.definitionOrder`,n),pa(e.definitionContainerId,`${t}.definitionContainerId`,n),de(e.metadata))for(let s of["linkUrl","linkTarget"])Object.hasOwn(e.metadata,s)&&n.push({path:`${t}.metadata.${s}`,message:`${s} is noncanonical; use a Hyperlink container shape`,severity:"error"});if((e.fillType==="linear-gradient"||e.fillType==="radial-gradient"||e.fillType==="pattern")&&e.fillColor==="none"&&e.fillOpacity===0&&n.push({path:`${t}.fillOpacity`,message:"Painted shapes cannot carry the noncanonical no-fill opacity encoding",severity:"error"}),e.charOffsets!==void 0&&e.charOffsets!==null&&(Array.isArray(e.charOffsets)?e.charOffsets.forEach((s,a)=>{let c=`${t}.charOffsets[${a}]`;if(!de(s)){n.push({path:c,message:"Each charOffsets entry must be a plain object",severity:"error"});return}for(let l of["x","y"]){let d=s[l];d!==null&&(typeof d!="number"||!Number.isFinite(d))&&n.push({path:`${c}.${l}`,message:`${l} must be null or a finite number`,severity:"error"})}for(let l of["dx","dy","rotate"]){let d=s[l];(typeof d!="number"||!Number.isFinite(d))&&n.push({path:`${c}.${l}`,message:`${l} must be a finite number`,severity:"error"})}if(s.raw!==void 0)if(!de(s.raw))n.push({path:`${c}.raw`,message:"raw must be a plain object",severity:"error"});else for(let[l,d]of Object.entries(s.raw))(!["x","y","dx","dy"].includes(l)||typeof d!="string")&&n.push({path:`${c}.raw.${l}`,message:"raw accepts only string x/y/dx/dy members",severity:"error"})}):n.push({path:`${t}.charOffsets`,message:"charOffsets must be an array",severity:"error"})),e.textPathReference!==void 0&&e.textPathReference!==null){let s=e.textPathReference;(!de(s)||s.kind!=="shape"&&s.kind!=="definition"||typeof s.targetId!="string"||s.targetId.length===0||s.element!=="href"&&s.element!=="mpath"||Object.keys(s).some(a=>!["kind","targetId","element"].includes(a)))&&n.push({path:`${t}.textPathReference`,message:"textPathReference requires an exact shape/definition target and href/mpath element",severity:"error"})}for(let s of["textPathRefShapeId","textPathImportRefId"])e[s]!==void 0&&n.push({path:`${t}.${s}`,message:`${s} is noncanonical; use textPathReference`,severity:"error"});if(e.authoredTextPosition!==void 0)if(!de(e.authoredTextPosition))n.push({path:`${t}.authoredTextPosition`,message:"authoredTextPosition must be a plain object",severity:"error"});else for(let[s,a]of Object.entries(e.authoredTextPosition)){let c=`${t}.authoredTextPosition.${s}`;if(!["x","y"].includes(s)||!de(a)){n.push({path:c,message:"Authored text position accepts only x/y coordinate objects",severity:"error"});continue}(typeof a.raw!="string"||a.raw.length===0||typeof a.resolved!="number"||!Number.isFinite(a.resolved))&&n.push({path:c,message:"Authored text coordinates require non-empty raw and finite resolved values",severity:"error"});for(let l of Object.keys(a))["raw","resolved"].includes(l)||n.push({path:`${c}.${l}`,message:"Authored text coordinates accept only raw/resolved members",severity:"error"})}if(e.textSpanTree!==void 0){let s=`${t}.textSpanTree`;if(!de(e.textSpanTree))n.push({path:s,message:"textSpanTree must be a plain object",severity:"error"});else{let a=e.textSpanTree,c=a.text,l=a.spans;if(typeof c!="string"||!Array.isArray(l))n.push({path:s,message:"Text span trees require text and spans",severity:"error"});else{let d=new Set,u=(f,p,m,g)=>{let h=p;f.forEach((y,S)=>{let b=`${g}[${S}]`,I=de(y)?y.start:void 0,v=de(y)?y.end:void 0,w=de(y)?y.children:void 0,k=de(y)?y.spanId:void 0,C=de(y)?y.id:void 0,P=de(y)?y.lineIndex:void 0,R=de(y)?y.rotate:void 0;!de(y)||typeof I!="number"||typeof v!="number"||!Number.isInteger(I)||!Number.isInteger(v)||I<h||v<I||I<p||v>m||!Array.isArray(w)||typeof k!="string"||k.length===0||d.has(k)||C!==void 0&&(typeof C!="string"||C.length===0)||P!==void 0&&(typeof P!="number"||!Number.isInteger(P)||P<0)||R!==void 0&&(!Array.isArray(R)||R.length===0||R.some(N=>typeof N!="number"||!Number.isFinite(N)))||Object.keys(y).some(N=>!["spanId","start","end","id","lineIndex","rotate","children"].includes(N))?n.push({path:b,message:"Text span nodes require nested ordered ranges, child arrays, and valid optional identity/line fields",severity:"error"}):(d.add(k),u(w,I,v,`${b}.children`),h=v)})};u(l,0,c.length,`${s}.spans`),a.rotate!==void 0&&(!Array.isArray(a.rotate)||a.rotate.length===0||a.rotate.some(f=>typeof f!="number"||!Number.isFinite(f)))&&n.push({path:`${s}.rotate`,message:"Text span root rotate must be a non-empty finite number list",severity:"error"});for(let f of Object.keys(a))["text","rotate","spans"].includes(f)||n.push({path:`${s}.${f}`,message:"Text span trees accept only text/spans members",severity:"error"})}}}if(e.authoredUseGeometry!==void 0)if(!de(e.authoredUseGeometry))n.push({path:`${t}.authoredUseGeometry`,message:"authoredUseGeometry must be a plain object",severity:"error"});else for(let[s,a]of Object.entries(e.authoredUseGeometry))(!["x","y","width","height"].includes(s)||typeof a!="string")&&n.push({path:`${t}.authoredUseGeometry.${s}`,message:"Authored use geometry accepts only string x/y/width/height members",severity:"error"});let i=["x","y","width","height","radius","rx","ry","fontSize"];for(let s of i)e[s]!==void 0&&!JP(e[s])&&n.push({path:`${t}.${s}`,message:`${s} must be a finite number or a {{variable}} reference`,severity:"error"});for(let s of oc){let a=e[s];if(a!=null){if(s==="transformMatrix"){(!Array.isArray(a)||a.length<6||!a.slice(0,6).every(c=>typeof c=="number"&&Number.isFinite(c)))&&n.push({path:`${t}.${s}`,message:`${s} must be a 6-element finite affine matrix`,severity:"error"});continue}JP(a)||n.push({path:`${t}.${s}`,message:`${s} must be a finite number or a {{variable}} reference`,severity:"error"})}}let o=["width","height","radius","fontSize"];for(let s of o){let a=e[s];typeof a=="number"&&a<=0&&r.push({path:`${t}.${s}`,message:`${s} should be positive (got ${a})`,severity:"warning"})}}function LB(e,t,n,r){if(e===null||typeof e!="object"){n.push({path:t,message:"Viewbox must be a non-null object",severity:"error"});return}let i=e;typeof i.id!="string"||i.id.length===0?n.push({path:`${t}.id`,message:"Viewbox id must be a non-empty string",severity:"error"}):r.has(i.id)?n.push({path:`${t}.id`,message:`Duplicate viewbox id: "${i.id}"`,severity:"error"}):r.add(i.id);for(let o of["x","y","width","height"])(typeof i[o]!="number"||!isFinite(i[o]))&&n.push({path:`${t}.${o}`,message:`${o} must be a finite number`,severity:"error"});typeof i.width=="number"&&i.width<=0&&n.push({path:`${t}.width`,message:"Viewbox width must be positive",severity:"error"}),typeof i.height=="number"&&i.height<=0&&n.push({path:`${t}.height`,message:"Viewbox height must be positive",severity:"error"})}function _B(e,t,n){if(e===null||typeof e!="object"){n.push({path:t,message:"Guide must be a non-null object",severity:"error"});return}let r=e;(typeof r.id!="string"||r.id.length===0)&&n.push({path:`${t}.id`,message:"Guide id must be a non-empty string",severity:"error"}),r.orientation!=="horizontal"&&r.orientation!=="vertical"&&n.push({path:`${t}.orientation`,message:'Guide orientation must be "horizontal" or "vertical"',severity:"error"}),(typeof r.position!="number"||!isFinite(r.position))&&n.push({path:`${t}.position`,message:"Guide position must be a finite number",severity:"error"})}function BB(e,t,n,r,i,o){if(e===null||typeof e!="object"){n.push({path:t,message:"ClipMaskGroup must be a non-null object",severity:"error"});return}let s=e;(typeof s.id!="string"||s.id.length===0)&&n.push({path:`${t}.id`,message:"ClipMaskGroup id must be a non-empty string",severity:"error"}),s.type!=="clip"&&s.type!=="mask"&&n.push({path:`${t}.type`,message:'ClipMaskGroup type must be "clip" or "mask"',severity:"error"}),s.definitionPlacement!==void 0&&s.definitionPlacement!=="defs"&&s.definitionPlacement!=="document"&&n.push({path:`${t}.definitionPlacement`,message:'definitionPlacement must be "defs" or "document"',severity:"error"}),s.referenceChannel!==void 0&&s.referenceChannel!=="attribute"&&s.referenceChannel!=="style"&&s.referenceChannel!=="stylesheet"&&n.push({path:`${t}.referenceChannel`,message:'referenceChannel must be "attribute", "style", or "stylesheet"',severity:"error"}),s.referenceStyleOrder!==void 0&&(typeof s.referenceStyleOrder!="number"||!Number.isInteger(s.referenceStyleOrder)||s.referenceStyleOrder<0)&&n.push({path:`${t}.referenceStyleOrder`,message:"referenceStyleOrder must be a non-negative integer",severity:"error"}),fa(s.definitionOrder,`${t}.definitionOrder`,n),pa(s.definitionContainerId,`${t}.definitionContainerId`,n),Nl(s.authoredPlacement,`${t}.authoredPlacement`,n,o,"Clip/mask");let a=s.clipShapeIds,c=typeof s.rawDefinition=="string"&&s.rawDefinition.length>0;a!==void 0&&!Array.isArray(a)?n.push({path:`${t}.clipShapeIds`,message:"clipShapeIds must be an array",severity:"error"}):a===void 0?n.push({path:`${t}.clipShapeIds`,message:"ClipMaskGroup must carry clipShapeIds",severity:"error"}):Array.isArray(a)&&a.length===0&&!c&&r.push({path:`${t}.clipShapeIds`,message:"ClipMaskGroup has no clip shapes and no rawDefinition; it will clip nothing",severity:"warning"}),Array.isArray(s.contentShapeIds)||n.push({path:`${t}.contentShapeIds`,message:"contentShapeIds must be an array",severity:"error"})}function Qt(e){let t=[...e].sort((i,o)=>i.index-o.index);if(!t.some(i=>i.orderKey))return t;let n=iu(t.length),r=new Map;return t.forEach((i,o)=>{r.set(i.id,i.orderKey??n[o])}),t.sort((i,o)=>{let s=lc(r.get(i.id)??"",r.get(o.id)??"");return s!==0?s:i.id<o.id?-1:i.id>o.id?1:0})}function Lt(e){return e.definitionId??`${e.type}-${e.id}`}function jp(e){return e.rawDefinition!==void 0?!0:e.clipShapeIds.length===0}function Up(e){let t=jp(e);return e.type==="clip"?{type:"clip",...e.definitionPlacement!==void 0?{definitionPlacement:e.definitionPlacement}:{},...e.definitionOrder!==void 0?{definitionOrder:e.definitionOrder}:{},...e.definitionContainerId!==void 0?{definitionContainerId:e.definitionContainerId}:{},...e.authoredPlacement!==void 0?{authoredPlacement:structuredClone(e.authoredPlacement)}:{},...e.clipPathUnits!==void 0?{clipPathUnits:e.clipPathUnits}:{},...!t&&e.clipRule!==void 0?{clipRule:e.clipRule}:{},...t&&e.rawDefinition!==void 0?{rawDefinition:e.rawDefinition}:{}}:{type:"mask",...e.definitionPlacement!==void 0?{definitionPlacement:e.definitionPlacement}:{},...e.definitionOrder!==void 0?{definitionOrder:e.definitionOrder}:{},...e.definitionContainerId!==void 0?{definitionContainerId:e.definitionContainerId}:{},...e.authoredPlacement!==void 0?{authoredPlacement:structuredClone(e.authoredPlacement)}:{},...e.maskUnits!==void 0?{maskUnits:e.maskUnits}:{},...e.maskContentUnits!==void 0?{maskContentUnits:e.maskContentUnits}:{},...e.maskType!==void 0?{maskType:e.maskType}:{},...e.maskBounds!==void 0?{maskBounds:structuredClone(e.maskBounds)}:{},...t&&e.rawDefinition!==void 0?{rawDefinition:e.rawDefinition}:{}}}function Ko(e,t,n){let{clipPathUnits:r,clipRule:i,maskUnits:o,maskContentUnits:s,maskType:a,maskBounds:c,definitionPlacement:l,definitionOrder:d,definitionContainerId:u,authoredPlacement:f,rawDefinition:p,...m}=structuredClone(e),g=t.rawDefinition!==void 0||jp(e);return e.type==="clip"?{...m,type:"clip",...t.definitionPlacement!==void 0?{definitionPlacement:t.definitionPlacement}:{},...t.definitionOrder!==void 0?{definitionOrder:t.definitionOrder}:{},...t.definitionContainerId!==void 0?{definitionContainerId:t.definitionContainerId}:{},...t.authoredPlacement!==void 0?{authoredPlacement:structuredClone(t.authoredPlacement)}:{},...t.clipPathUnits!==void 0?{clipPathUnits:t.clipPathUnits}:{},...!g&&t.clipRule!==void 0?{clipRule:t.clipRule}:{},...g&&n&&t.rawDefinition!==void 0?{rawDefinition:t.rawDefinition}:{}}:{...m,type:"mask",...t.definitionPlacement!==void 0?{definitionPlacement:t.definitionPlacement}:{},...t.definitionOrder!==void 0?{definitionOrder:t.definitionOrder}:{},...t.definitionContainerId!==void 0?{definitionContainerId:t.definitionContainerId}:{},...t.authoredPlacement!==void 0?{authoredPlacement:structuredClone(t.authoredPlacement)}:{},...t.maskUnits!==void 0?{maskUnits:t.maskUnits}:{},...t.maskContentUnits!==void 0?{maskContentUnits:t.maskContentUnits}:{},...t.maskType!==void 0?{maskType:t.maskType}:{},...t.maskBounds!==void 0?{maskBounds:structuredClone(t.maskBounds)}:{},...g&&n&&t.rawDefinition!==void 0?{rawDefinition:t.rawDefinition}:{}}}function ei(e){let t=new Map;for(let n of e??[]){let r=Lt(n),i=Up(n),o=t.get(r);t.set(r,o?.type===i.type?{...o,...i}:i)}return t}function Yn(e){let t=structuredClone(e??[]),n=ei(t),r=new Set;return t.map(i=>{let o=Lt(i),s=n.get(o)??Up(i),a=s.rawDefinition!==void 0&&!r.has(o);return a&&r.add(o),Ko(i,s,a)})}function wi(e,t){let n=structuredClone(e??[]);if(t.type==="clipMask:remove"){let c=n.find(p=>p.id===t.id);if(!c)return Yn(n);let l=Lt(c),d=ei(n).get(l),u=n.filter(p=>p.id!==t.id),f=u.findIndex(p=>Lt(p)===l);return d&&f>=0&&(u[f]=Ko(u[f],d,!0)),Yn(u)}let r=n.findIndex(c=>c.id===t.clipMaskGroup.id),i=r>=0?n[r]:void 0,o=i?ei(n).get(Lt(i)):void 0;r>=0&&n.splice(r,1);let s=Math.min(Math.max(0,t.index??n.length),n.length),a=structuredClone(t.clipMaskGroup);return o?.rawDefinition!==void 0&&a.rawDefinition===void 0&&Lt(i)===Lt(a)&&(a=Ko(a,o,!0)),n.splice(s,0,a),Yn(n)}function Hp(e,t,n,r){if(!e.some(o=>o.id===t))throw new Error(`Unknown clip/mask group: ${t}`);let i=e.map(o=>o.id===t?Ko({...o,definitionId:n},r,r.rawDefinition!==void 0):Lt(o)!==n?structuredClone(o):Ko(o,r,!1));return Yn(i)}var VB=/^structural:(clip|mask):(.+):(group|path|content)$/;function nT(e,t){let n=`structural:${e}:${t}`;return{group:`${n}:group`,path:`${n}:path`,content:`${n}:content`}}function rT(e,t){for(let n of e){t.add(n.id);let r=n.state.children;Array.isArray(r)&&rT(r,t)}}function iT(e,t=null){let n=[];return e.forEach((r,i)=>{n.push({id:r.id,parentId:t,index:i});let o=r.state.children;Array.isArray(o)&&n.push(...iT(o,r.id))}),n}function Nr(e){let t=e.sceneTree&&e.sceneTree.length>0?e.sceneTree:iT(e.shapes),n=new Map(t.map(v=>[v.id,v])),r=new Map;for(let v of t){let w=r.get(v.parentId)??[];w.push(v),r.set(v.parentId,w)}for(let[v,w]of r)r.set(v,Qt(w));let i=v=>VB.test(v),o=new Set(t.filter(v=>!i(v.id)).map(v=>v.id)),s=new Set;rT(e.shapes,s);let a=new Map,c=new Set,l=(v,w)=>{let k=[];for(let C of r.get(v)??[]){if(!i(C.id)){c.has(C.id)||(c.add(C.id),k.push(C.id));continue}if(w.has(C.id))continue;let P=new Set(w);P.add(C.id),k.push(...l(C.id,P))}return k},d=[null,...o];for(let v of d){let w=l(v,new Set);w.length>0&&a.set(v,w)}for(let v of o){if(c.has(v))continue;let w=n.get(v)?.parentId??null,k=w!==null&&o.has(w)?w:null,C=a.get(k)??[];C.push(v),a.set(k,C),c.add(v)}let u=v=>{for(let[w,k]of a){let C=k.indexOf(v);if(C>=0)return{parentId:w,index:C}}return null},f=v=>{for(let w of a.values()){let k=w.indexOf(v);k>=0&&w.splice(k,1)}},p=e.clipMaskGroups??[],m=ei(p),g=new Set(p.filter(v=>v.clipShapeIds.some(w=>s.has(w))).map(v=>`${v.type}\0${Lt(v)}`)),h=new Map(p.map(v=>[nT(v.type,v.id).content,v])),y=(v,w=new Set)=>{if(w.has(v.id))return Number.MAX_SAFE_INTEGER;let k=v.parentId?h.get(v.parentId):void 0;if(!k)return 0;let C=new Set(w);return C.add(v.id),1+y(k,C)},S=[...p].sort((v,w)=>y(v)-y(w)||(v.siblingIndex??0)-(w.siblingIndex??0)),b=new Map;for(let v of S){let w=v.clipShapeIds.filter(W=>s.has(W)),k=v.contentShapeIds.filter(W=>s.has(W)),C=Lt(v),R=m.get(C)?.rawDefinition!==void 0||g.has(`${v.type}\0${C}`);if(k.length===0||!R)continue;let N=[...k,...w].map(u).filter(W=>W!==null),M=N[0]?.parentId??null,A=N.length>0?Math.min(...N.map(W=>W.index)):void 0,$=v.parentId===null||o.has(v.parentId)||h.has(v.parentId)?v.parentId:M;for(let W of[...w,...k])f(W);let _=nT(v.type,v.id),z=a.get($)??[],j=v.siblingIndex??A??z.length,G=Math.min(Math.max(0,j),z.length);z.splice(G,0,_.group),a.set($,z),a.set(_.group,[_.path,_.content]),a.set(_.path,[...w]),a.set(_.content,[...k]),b.set(_.group,{id:_.group,parentId:$,index:0}),b.set(_.path,{id:_.path,parentId:_.group,index:0}),b.set(_.content,{id:_.content,parentId:_.group,index:1})}let I=[];for(let[v,w]of a)w.forEach((k,C)=>{let P=b.get(k);if(P){I.push({...P,parentId:v,index:C});return}let R=n.get(k);R&&R.parentId===v?I.push({...R,index:C}):I.push({id:k,parentId:v,index:C})});e.sceneTree=I}function mr(e){let t=[],n=new Map,r=new Set,i=new WeakSet,o=[...e].reverse();for(;o.length>0;){let a=o.pop();if(!a||typeof a!="object"||i.has(a))continue;i.add(a),t.push(a);let c=n.get(a.id);c&&c!==a?r.add(a.id):c||n.set(a.id,a);let l=a.state.children;if(Array.isArray(l))for(let d=l.length-1;d>=0;d--){let u=l[d];u&&typeof u=="object"&&typeof u.id=="string"&&o.push(u)}}let s=new Map(n);for(let a of r)s.delete(a);return{ordered:t,uniqueById:s,duplicateIds:r}}function ki(e){let t=[...e??[]],n=new Map;for(let o of t)n.set(o.id,(n.get(o.id)??0)+1);let r=new Set([...n].filter(([,o])=>o>1).map(([o])=>o)),i=new Map;for(let o of t)r.has(o.id)||i.set(o.id,o);return{ordered:t,uniqueById:i,duplicateIds:r,definition:o=>i.get(o),symbol:o=>{let s=i.get(o);return s?.kind==="symbol"?s:void 0}}}function GB(e){let t=e.groupData;if(!t||typeof t!="object"||Array.isArray(t))return null;let n=t.transform;return typeof n=="string"&&n.trim()?n:null}function ma(e,t){let n=sn(e,t);if(n)return{matrix:ir(e,t),attribute:n,owner:"canonical"};let r=GB(e);if(r){let i=Tn(r),o=e.customPivot;return{matrix:o?Ic(o,i):i,attribute:r,owner:"group-data"}}return{matrix:He,attribute:null,owner:"none"}}function An(e){let t=e.transformMatrix;return mi(t)&&!on(t)||e.customPivot||typeof e.rawTransform=="string"&&e.rawTransform?!1:(e.rotation??0)!==0||(e.skewX??0)!==0||(e.skewY??0)!==0||(e.scaleX??1)!==1||(e.scaleY??1)!==1}function El(e,t){let n=t?{x:(t.minX+t.maxX)/2,y:(t.minY+t.maxY)/2}:void 0;return ma(e,n)}var jB=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/,UB=/^([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?)px$/i,HB=/^([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?)%$/;function Ol(e,t,n,r){let i=e.trim();if(jB.test(i))return Number(i);let o=UB.exec(i);if(o)return Number(o[1]);let s=HB.exec(i);if(s)return t.percentBasis===void 0?(r.push({code:"unresolved-symbol-viewport",message:`Symbol ${t.axis} percentage ${e} needs a containing viewport basis.`}),null):Number(s[1])/100*t.percentBasis;let a=n.resolveLength?.(e,t)??null;return a!==null&&Number.isFinite(a)?a:(r.push({code:"invalid-symbol-length",message:`Symbol ${t.axis} length ${e} is invalid or requires an unavailable length host.`}),null)}function KB(e){let t=e.state.authoredUseGeometry;return t&&typeof t=="object"?t:{}}function Wo(e,t){let n=e[t];if(typeof n=="string")return n;if(["viewBox","preserveAspectRatio","x","y","width","height","refX","refY"].includes(t))return;let r=e.rootAttributes?.[t];return typeof r=="string"?r:void 0}function WB(e,t){if(e===void 0)return;let n=At(e);return n?n.width<0||n.height<0?(t.push({code:"invalid-symbol-viewbox",message:`Symbol viewBox ${e} has a non-finite or negative dimension and is ignored.`}),null):n:(t.push({code:"invalid-symbol-viewbox",message:`Symbol viewBox ${e} is not four finite SVG numbers and is ignored.`}),null)}function oT(e,t,n,r,i,o){return t===void 0?0:Ol(t,{axis:n,percentBasis:n==="x"?r?.width:r?.height},i,o)??0}function sT(e,t,n,r,i,o,s){let a=n==="width"?i?.width:i?.height,c=[r,Wo(t,n)];for(let l of c){if(l===void 0||l.trim().toLowerCase()==="auto")continue;let d=Ol(l,{axis:n,percentBasis:a},o,s);if(d!==null){if(d<0){s.push({code:"invalid-symbol-length",message:`Negative symbol ${n} ${l} is invalid and falls back to auto.`});continue}return d}}return a!==void 0?a:(s.push({code:"unresolved-symbol-viewport",message:`Symbol ${n} is auto and needs a containing viewport basis.`}),null)}function aT(e,t,n,r,i){if(e===void 0)return;let o=e.trim();if(t==="refX"){if(o==="left")return 0;if(o==="center")return(n?.width??0)/2;if(o==="right")return n?.width??0}else{if(o==="top")return 0;if(o==="center")return(n?.height??0)/2;if(o==="bottom")return n?.height??0}return Ol(e,{axis:t,percentBasis:t==="refX"?n?.width:n?.height},r,i)??void 0}function ga(e,t,n,r={}){let i=[],o=KB(e),s=oT(e,o.x,"x",n,r,i),a=oT(e,o.y,"y",n,r,i),c=lt(s,a),l=Wo(t,"transform"),d=l?Tn(l):He;if((t.defKind??"symbol")!=="symbol")return{kind:"group",renders:!0,useX:s,useY:a,useAttributes:o,contentMatrix:ve(c,d),childPercentBasis:n??null,viewport:null,diagnostics:i};let u=sT(e,t,"width",o.width,n,r,i),f=sT(e,t,"height",o.height,n,r,i),p=Wo(t,"x"),m=Wo(t,"y"),g=p!==void 0?Ol(p,{axis:"x",percentBasis:n?.width},r,i)??0:0,h=m!==void 0?Ol(m,{axis:"y",percentBasis:n?.height},r,i)??0:0,y=WB(t.viewBox,i),S=Do({width:u,height:f,...y?{viewBoxX:y.x,viewBoxY:y.y,viewBoxWidth:y.width,viewBoxHeight:y.height}:{},preserveAspectRatio:Wo(t,"preserveAspectRatio")},n);for(let C of S.diagnostics)i.push({code:C.code==="unresolved-viewport-size"?"unresolved-symbol-viewport":"invalid-symbol-viewbox",message:C.message.replace("Nested SVG","Symbol")});if(u===null||f===null||!S.renders||!S.contentMatrix)return{kind:"symbol",renders:!1,useX:s,useY:a,useAttributes:o,contentMatrix:ve(c,d),childPercentBasis:S.childPercentBasis,viewport:S,diagnostics:i};let b=aT(Wo(t,"refX"),"refX",S.childPercentBasis,r,i),I=aT(Wo(t,"refY"),"refY",S.childPercentBasis,r,i),v=Ye(S.contentMatrix,{x:b??0,y:I??0}),w=lt(g-(b===void 0?0:v.x),h-(I===void 0?0:v.y)),k=ve(ve(ve(c,d),w),S.contentMatrix);return{kind:"symbol",renders:!0,useX:s,useY:a,useAttributes:o,contentMatrix:k,childPercentBasis:S.childPercentBasis,viewport:S,diagnostics:i}}function Kp(){return{bounds:null,status:"empty",diagnostics:[]}}function ya(e,t,n){return n.resolveOwnTransform?.(e,t)??t}function Or(e,t){return{bounds:null,status:e,diagnostics:[t]}}function Dl(e,t){return e?t?{minX:Math.min(e.minX,t.minX),minY:Math.min(e.minY,t.minY),maxX:Math.max(e.maxX,t.maxX),maxY:Math.max(e.maxY,t.maxY)}:e:t}function Er(e,t,n="empty"){return e?{bounds:e,status:"resolved",diagnostics:t}:t.some(r=>r.code==="container-cycle"||r.code==="reference-cycle"||r.code==="symbol-cycle")?{bounds:null,status:"cycle",diagnostics:t}:t.some(r=>r.code==="unsupported-shape"||r.code==="deferred-tree-kind")?{bounds:null,status:"unsupported",diagnostics:t}:t.some(r=>r.code==="unresolved-shape"||r.code==="unresolved-reference-target"||r.code==="unresolved-reference-pivot"||r.code==="duplicate-shape-id"||r.code==="unresolved-svg-viewport"||r.code==="unresolved-symbol-definition"||r.code==="duplicate-library-id"||r.code==="unresolved-symbol-viewport"||r.code==="unresolved-symbol-pivot")?{bounds:null,status:"unresolved",diagnostics:t}:{bounds:null,status:n,diagnostics:t}}function zb(e){if(e.length===0)return null;let t=e[0].x,n=e[0].y,r=e[0].x,i=e[0].y;for(let o=1;o<e.length;o++){let s=e[o];t=Math.min(t,s.x),n=Math.min(n,s.y),r=Math.max(r,s.x),i=Math.max(i,s.y)}return{minX:t,minY:n,maxX:r,maxY:i}}function _b(e,t){return zb([Ye(t,{x:e.minX,y:e.minY}),Ye(t,{x:e.maxX,y:e.minY}),Ye(t,{x:e.maxX,y:e.maxY}),Ye(t,{x:e.minX,y:e.maxY})])}function cT(e,t,n,r,i){return n<0||r<0?null:_b({minX:e,minY:t,maxX:e+n,maxY:t+r},i)}function lT(e,t,n,r,i){if(n<0||r<0)return null;let o=Ye(i,{x:e,y:t}),s=Math.hypot(i[0]*n,i[2]*r),a=Math.hypot(i[1]*n,i[3]*r);return{minX:o.x-s,minY:o.y-a,maxX:o.x+s,maxY:o.y+a}}function XB(e,t){let n=Array.isArray(e)?e:[e],r=null;for(let i of n)r=Dl(r,_b(i,t));return r}function $b(e,t,n){return Or("unsupported",{code:t,shapeId:e.id,message:`Object bounds for ${n} require a document resolver policy.`,path:[e.id]})}function dT(e,t,n={}){return Fb(e,Vn(e),t,n)}function Fb(e,t,n,r){if(!t)return Or("unsupported",{code:"unsupported-shape",shapeId:e.id,message:`No geometry kernel is registered for shape type ${e.type}.`,path:[e.id]});let i;switch(t.kind){case"circle":i=lT(t.cx,t.cy,t.r,t.r,n);break;case"ellipse":i=lT(t.cx,t.cy,t.rx,t.ry,n);break;case"rectangle":if(t.width<0||t.height<0)i=null;else if(t.pathData)i=ar(t.pathData,n);else if(t.rx>0&&t.ry>0){let o=wS(t.x,t.y,t.width,t.height,t.rx,t.ry);i=o?ar(o,n):null}else i=cT(t.x,t.y,t.width,t.height,n);break;case"line":if(t.boundsPolicy==="linked-line")return $b(e,"deferred-tree-kind","linked line");i=zb([Ye(n,{x:t.x1,y:t.y1}),Ye(n,{x:t.x2,y:t.y2})]);break;case"text":{let o=r.measureText?.(e,t)??null;if(!o)return $b(e,"deferred-tree-kind","text");i=XB(o,n);break}case"path":{if(t.boundsPolicy==="empty")return Kp();let o=t.placement?ve(n,lt(t.placement.x,t.placement.y)):n;i=Fy(t,o);break}case"polyline":{let o=t.points.length>0?t.points:[{x:0,y:0}];i=zb(o.map(s=>Ye(n,s)));break}case"positioning-rect":i=cT(t.x,t.y,t.width,t.height,n);break;case"view":return Kp();case"container":case"embedded-svg":case"shape-reference":case"symbol-instance":return $b(e,"deferred-tree-kind",t.kind)}return i?{bounds:i,status:"resolved",diagnostics:[]}:{bounds:null,status:"empty",diagnostics:[]}}function Lb(e){let t=e.state.children;return Array.isArray(t)?t.filter(n=>!!n&&typeof n=="object"&&typeof n.id=="string"):[]}function Dr(e){let t=mr(e.shapes),n=ki(e.library),r=e.sceneTree??[];if(r.length===0)return{roots:()=>e.shapes,shape:l=>t.uniqueById.get(l),duplicateShapeIds:()=>t.duplicateIds,libraryDefinition:l=>n.definition(l),duplicateLibraryIds:()=>n.duplicateIds,children:Lb};let i=new Map,o=new Set;for(let l of r){let d=i.get(l.parentId)??[];i.set(l.parentId,[...d,l]),t.uniqueById.has(l.id)&&o.add(l.id)}let s=l=>{let d=[],u=new Set,f=p=>{for(let m of Qt([...i.get(p)??[]])){let g=t.uniqueById.get(m.id);if(g){d.push(g);continue}u.has(m.id)||(u.add(m.id),f(m.id),u.delete(m.id))}};return f(l),d};return{roots:()=>[...s(null),...e.shapes.filter(l=>!o.has(l.id))],shape:l=>t.uniqueById.get(l),duplicateShapeIds:()=>t.duplicateIds,libraryDefinition:l=>n.definition(l),duplicateLibraryIds:()=>n.duplicateIds,children:l=>[...s(l.id),...Lb(l).filter(d=>!o.has(d.id))]}}function uT(e,t){return`${t.identityPrefixes.at(-1)??"document"}\0${e.id}`}var YB=new Set(["block","contents","flex","flow","flow-root","grid","inherit","initial","inline","inline-block","inline-flex","inline-grid","inline-table","list-item","none","revert","revert-layer","ruby","ruby-base","ruby-base-container","ruby-text","ruby-text-container","run-in","table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row","table-row-group","unset"]),Mb=new Set(["block","inline","run-in"]),qB=new Set(["flow","flow-root","table","flex","grid","ruby"]);function ZB(e){let t=e.trim().toLowerCase();if(YB.has(t)||/^(?:var|env)\(/.test(t)&&t.endsWith(")"))return!0;let n=t.split(/\s+/);if(n.length<2||n.length>3||new Set(n).size!==n.length)return!1;if(n.includes("list-item")){let r=n.filter(i=>i!=="list-item");return r.filter(i=>Mb.has(i)).length<=1&&r.filter(i=>i==="flow"||i==="flow-root").length<=1&&r.every(i=>Mb.has(i)||i==="flow"||i==="flow-root")}return n.length===2&&n.some(r=>Mb.has(r))&&n.some(r=>qB.has(r))}function QB(e){if(!e)return null;let t=null;for(let n of xr(e,";")){let r=xr(n,":");if(r.length<2||r[0].trim().toLowerCase()!=="display")continue;let i=r.slice(1).join(":").trim(),o=/\s*!important\s*$/i.test(i),s=i.replace(/\s*!important\s*$/i,"").trim().toLowerCase();ZB(s)&&(!t||o||!t.important)&&(t={value:s,important:o})}return t}function fT(e,t){let n=QB(typeof t=="string"?t:void 0);return n?n.value!=="none":typeof e!="string"||e.trim().toLowerCase()!=="none"}function $l(e,t){if(e.state.visible===!1)return!1;let n=e.type==="symbol-instance"||e.type==="shape-reference"?e.state.instancePresentation:void 0,r=n?.display??e.state.display;return fT(r,n?.style)?t.participatesInRendering?.(e)??!0:!1}function pT(e,t,n){let r=e.rootAttributes;return fT(r?.display,r?.style)?n.participatesSymbolDefinition?.(e,t)??!0:!1}function JB(e,t={}){return{x:e.x,y:e.y,width:t.width!==void 0?t.width:e.width,height:t.height!==void 0?t.height:e.height,viewBoxX:e.viewBoxX,viewBoxY:e.viewBoxY,viewBoxWidth:e.viewBoxWidth,viewBoxHeight:e.viewBoxHeight,preserveAspectRatio:e.preserveAspectRatio}}function no(e,t,n={}){let r=Vn(e);if(!r||r.kind!=="embedded-svg")return{matrix:He,attribute:null,pivotRequired:!1,pivotResolved:!1,viewport:Do({})};let i=Do(JB(r,n),t),o=An(e.state),s=i.frame?{x:i.frame.x+i.frame.width/2,y:i.frame.y+i.frame.height/2}:void 0;return{matrix:ir(e.state,s),attribute:sn(e.state,s),pivotRequired:o,pivotResolved:!o||s!==void 0,viewport:i}}function mT(e,t,n){return t.diagnostics.map(r=>({code:r.code==="unresolved-viewport-size"?"unresolved-svg-viewport":"invalid-svg-viewport",shapeId:e.id,message:r.message,path:[...n,e.id]}))}function Wp(e,t,n,r){let i=null,o=[],s=n.forceInlineChildren>0?Lb(e):n.view.children(e);for(let a of s){if(!$l(a,n.host))continue;let c=Ml(a,t,n,r);i=Dl(i,c.bounds),o.push(...c.diagnostics)}return Er(i,o)}function gT(e,t){return{...e,diagnostics:e.diagnostics.map(n=>n.path.includes(t)?n:{...n,path:[t,...n.path]})}}function eV(e,t,n,r,i={}){let o=no(e,r,i),s=mT(e,o.viewport,n.path);if(o.pivotRequired&&!o.pivotResolved)return s.push({code:"unresolved-svg-viewport",shapeId:e.id,message:`Embedded SVG ${e.id} has decomposed rotation/scale/skew channels, but its auto viewport frame cannot be resolved without a parent viewport.`,path:[...n.path,e.id]}),Er(null,s,"unresolved");if(!o.viewport.renders)return Er(null,s,o.viewport.status==="zero-disabled"?"empty":"unresolved");let a=uT(e,n);n.active.add(a),n.path.push(e.id);let l=e.state.isRootSvg===!0?t:ve(ve(t,ya(e,o.matrix,n.host)),o.viewport.contentMatrix??He),d=Wp(e,l,n,o.viewport.childPercentBasis??r);return n.path.pop(),n.active.delete(a),Er(d.bounds,[...s,...d.diagnostics],d.status)}function hT(e,t,n={},r={}){let i=typeof t=="string"?e.shape(t):t;if(!i){let d=typeof t=="string"?t:t.id;return Or("unresolved",{code:"unresolved-shape",shapeId:d,message:`Shape ${d} is not present in the document bounds view.`,path:[d]})}let o=Vn(i);if(!o||o.kind!=="embedded-svg")return Or("unsupported",{code:"unsupported-shape",shapeId:i.id,message:`Shape ${i.id} is not an embedded SVG viewport.`,path:[i.id]});let s=no(i,n.parentViewport),a=mT(i,s.viewport,[]);if(!s.viewport.frame||s.pivotRequired&&!s.pivotResolved)return Er(null,a,"unresolved");let c=ve(n.toTarget??He,ya(i,s.matrix,r)),l=s.viewport.frame;return{bounds:_b({minX:l.x,minY:l.y,maxX:l.x+l.width,maxY:l.y+l.height},c),status:"resolved",diagnostics:a}}function yT(e,t,n){let r=n.view.duplicateShapeIds?.().has(t)??!1;return Or("unresolved",{code:r?"duplicate-shape-id":"unresolved-reference-target",shapeId:e.id,message:r?`Shape reference ${e.id} targets ambiguous duplicate id ${t}.`:t?`Shape reference ${e.id} targets ${t}, which is not present in the document.`:`Shape reference ${e.id} has no targetShapeId.`,path:t?[...n.path,t]:[...n.path]})}function tV(e,t){let n=[...t.path,e.id];return Or("cycle",{code:"reference-cycle",shapeId:e.id,message:`Shape reference cycle detected: ${n.join(" -> ")}.`,path:n})}function ST(e,t,n,r,i){if(!An(e.state))return{matrix:ir(e.state),attribute:sn(e.state),pivotRequired:!1,pivotResolved:!0,diagnostics:[],contentBounds:null};let s=lt(t.offsetX,t.offsetY),a={width:t.width,height:t.height},c=gT(Ml(n,s,r,i,a),e.id),l=c.diagnostics.some(u=>u.code==="unsupported-shape"||u.code==="deferred-tree-kind"||u.code==="unresolved-reference-pivot"),d=c.bounds&&!l?{x:(c.bounds.minX+c.bounds.maxX)/2,y:(c.bounds.minY+c.bounds.maxY)/2}:null;if(!d){let u=c.bounds===null&&(c.status==="empty"||c.status==="cycle"||c.status==="unresolved"),f={code:"unresolved-reference-pivot",shapeId:e.id,message:`Shape reference ${e.id} has decomposed rotation/scale/skew channels, but its translated target bounds require unavailable contextual geometry or measurement.`,path:[...r.path]};return{matrix:ir(e.state),attribute:sn(e.state),pivotRequired:!0,pivotResolved:u,diagnostics:u?c.diagnostics:[...c.diagnostics,f],contentBounds:c}}return{matrix:ir(e.state,d),attribute:sn(e.state,d),pivotRequired:!0,pivotResolved:!0,diagnostics:[],contentBounds:c}}function nV(e,t,n,r,i){if(r.activeReferences.has(e.id))return tV(e,r);r.activeReferences.add(e.id),r.path.push(e.id);let o=u=>(r.path.pop(),r.activeReferences.delete(e.id),u),s=t.targetShapeId?.trim()??"",a=s?r.view.shape(s):void 0;if(!a)return o(yT(e,s,r));if(!$l(a,r.host))return o(Kp());let c=ST(e,t,a,r,i);if(c.pivotRequired&&!c.pivotResolved)return o(Er(null,[...c.diagnostics],"unresolved"));if(c.contentBounds?.bounds===null&&c.pivotResolved)return o(c.contentBounds);let l=ve(ve(n,ya(e,c.matrix,r.host)),lt(t.offsetX,t.offsetY)),d=gT(Ml(a,l,r,i,{width:t.width,height:t.height}),e.id);return o({...d,diagnostics:[...c.diagnostics,...d.diagnostics]})}function ha(e,t){let n=e.state.instancePresentation?.transform,r=typeof n=="string"&&n.trim()?n.trim():null,i=ir(e.state,t),o=sn(e.state,t);return r?{matrix:ve(Tn(r),i),attribute:o?`${r} ${o}`:r}:{matrix:i,attribute:o}}function Xo(e,t,n,r){return{code:n,shapeId:e.id,message:r,path:[...t.path,e.id]}}function bT(e,t,n,r,i,o){let s=null,a=[];for(let c of n){if(!$l(c,i.host))continue;let l=Ml(c,r,i,o);s=Dl(s,l.bounds),a.push(...l.diagnostics)}for(let c of t.definitionContentOrder??[]){if(c.kind!=="definition")continue;let l=i.view.libraryDefinition?.(c.id);if(!l||l.kind!=="symbol"){a.push(Xo(e,i,"unresolved-symbol-definition",`Nested definition ${c.id} is missing from ${t.id}.`));continue}if((l.defKind??"symbol")==="symbol"||!pT(l,e,i.host))continue;let d=`definition-forest\0${l.id}`;if(i.activeSymbols.has(d)){a.push(Xo(e,i,"symbol-cycle",`Nested definition forest cycle detected through ${l.id}.`));continue}i.activeSymbols.add(d),i.path.push(l.id);let u=l.rootAttributes?.transform,f=u?ve(r,Tn(u)):r,p=bT(e,l,l.shapes,f,i,o);i.path.pop(),i.activeSymbols.delete(d),s=Dl(s,p.bounds),a.push(...p.diagnostics)}return Er(s,a)}function vT(e,t,n,r,i,o=!1){let s=Ro(t,e),a=ga(e,t,i,{resolveLength:r.host.resolveSymbolLength}),c=[...s.diagnostics.map(g=>Xo(e,r,g.code,g.message)),...a.diagnostics.map(g=>Xo(e,r,g.code==="invalid-symbol-length"||g.code==="invalid-symbol-viewbox"?"invalid-symbol-viewport":"unresolved-symbol-viewport",g.message))];if(!a.renders){let g=a.viewport?.status==="zero-disabled";return{...Er(null,c,g?"empty":"unresolved"),transform:{...ha(e),pivotRequired:An(e.state),pivotResolved:!0,diagnostics:c}}}if(!pT(t,e,r.host))return{...Kp(),transform:{...ha(e),pivotRequired:An(e.state),pivotResolved:!0,diagnostics:c}};if(r.activeSymbols.has(s.materializationKey)){let g=Xo(e,r,"symbol-cycle",`Symbol instance cycle detected through ${t.id}.`);return{...Or("cycle",g),transform:{...ha(e),pivotRequired:An(e.state),pivotResolved:!0,diagnostics:[g]}}}r.activeSymbols.add(s.materializationKey),r.identityPrefixes.push(s.materializationKey),r.forceInlineChildren++,r.path.push(e.id);let l=g=>bT(e,t,s.shapes,g,r,a.childPercentBasis??i),d=An(e.state),u=ha(e),f=!d,p=[];if(d){let g=l(a.contentMatrix),h=g.diagnostics.some(S=>S.code==="unsupported-shape"||S.code==="deferred-tree-kind"||S.code==="unresolved-symbol-viewport"),y=g.bounds&&!h?{x:(g.bounds.minX+g.bounds.maxX)/2,y:(g.bounds.minY+g.bounds.maxY)/2}:void 0;if(y)u=ha(e,y),f=!0;else{let S=g.bounds===null&&(g.status==="empty"||g.status==="cycle"||g.status==="unresolved");f=S,S||(p=[Xo(e,r,"unresolved-symbol-pivot",`Symbol instance ${e.id} needs unavailable contextual geometry or measurement for its decomposed transform pivot.`)]),S&&!o&&(p=[...g.diagnostics])}}let m;if(d&&!f)m=Er(null,[...c,...p],"unresolved");else{let g=ve(ve(n,ya(e,u.matrix,r.host)),a.contentMatrix),h=l(g);m=Er(h.bounds,[...c,...p,...h.diagnostics],h.status)}return r.path.pop(),r.forceInlineChildren--,r.identityPrefixes.pop(),r.activeSymbols.delete(s.materializationKey),{...m,transform:{...u,pivotRequired:d,pivotResolved:f,diagnostics:[...c,...p]}}}function rV(e,t,n,r){let i=String(e.state.symbolId??"").trim(),o=i?n.view.duplicateLibraryIds?.().has(i)??!1:!1,s=i?n.view.libraryDefinition?.(i):void 0;if(o||!s||s.kind!=="symbol")return Or("unresolved",Xo(e,n,o?"duplicate-library-id":"unresolved-symbol-definition",o?`Symbol instance ${e.id} targets duplicate library id ${i}.`:`Symbol instance ${e.id} targets missing symbol definition ${i||"(blank)"}.`));let a=vT(e,s,t,n,r),{transform:c,...l}=a;return l}function Ml(e,t,n,r,i={}){let o=uT(e,n);if(n.active.has(o)){if(!n.collectDiagnostics)return{bounds:null,status:"cycle",diagnostics:[]};let l=[...n.path,e.id];return Or("cycle",{code:"container-cycle",shapeId:e.id,message:`Container cycle detected: ${l.join(" -> ")}.`,path:l})}let s=Vn(e);if(!s)return Fb(e,s,t,n.host);if(s.kind==="shape-reference")return nV(e,s,t,n,r);if(s.kind==="embedded-svg")return eV(e,t,n,r,i);if(s.kind==="symbol-instance")return rV(e,t,n,r);if(s.kind!=="container"){let l=ir(e.state,s.defaultPivot??void 0);return Fb(e,s,ve(t,ya(e,l,n.host)),n.host)}n.active.add(o),n.path.push(e.id);let a=ma(e.state).matrix;if(An(e.state)){let l=n.collectDiagnostics;n.collectDiagnostics=!1;let d=Wp(e,He,n,r);n.collectDiagnostics=l;let u=d.diagnostics.some(f=>f.code==="unsupported-shape"||f.code==="deferred-tree-kind");a=El(e.state,u?null:d.bounds).matrix}let c=Wp(e,ve(t,ya(e,a,n.host)),n,r);return n.path.pop(),n.active.delete(o),c}function ti(e,t,n={},r={}){let i=typeof t=="string"?e.shape(t):t;if(!i){let o=typeof t=="string"?t:t.id;return Or("unresolved",{code:"unresolved-shape",shapeId:o,message:`Shape ${o} is not present in the document bounds view.`,path:[o]})}return Ml(i,n.toTarget??He,{view:e,host:r,active:new Set,activeReferences:new Set,activeSymbols:new Set,identityPrefixes:[],forceInlineChildren:0,path:[],collectDiagnostics:!0},n.parentViewport)}function Sa(e,t,n={},r={}){let i=typeof t=="string"?e.shape(t):t;if(!i){let s=typeof t=="string"?t:t.id;return Or("unresolved",{code:"unresolved-shape",shapeId:s,message:`Shape ${s} is not present in the document bounds view.`,path:[s]})}let o={...r,resolveOwnTransform:(s,a)=>s===i?He:r.resolveOwnTransform?.(s,a)??a};return ti(e,i,{parentViewport:n.parentViewport},o)}function Xp(e,t,n={},r){let i=Vn(t);if(!i||i.kind!=="shape-reference")return{matrix:He,attribute:null,pivotRequired:!1,pivotResolved:!1,diagnostics:[]};let o={view:e,host:n,active:new Set,activeReferences:new Set([t.id]),activeSymbols:new Set,identityPrefixes:[],forceInlineChildren:0,path:[t.id],collectDiagnostics:!0},s=i.targetShapeId?.trim()??"",a=s?e.shape(s):void 0;if(!a||!$l(a,n)){let l=An(t.state);return{matrix:ir(t.state),attribute:sn(t.state),pivotRequired:l,pivotResolved:!0,diagnostics:a?[]:yT(t,s,o).diagnostics}}let c=ST(t,i,a,o,r);return{matrix:c.matrix,attribute:c.attribute,pivotRequired:c.pivotRequired,pivotResolved:c.pivotResolved,diagnostics:c.diagnostics}}function Yp(e,t,n={},r){let i=An(t.state),o=String(t.state.symbolId??"").trim(),s=o?e.duplicateLibraryIds?.().has(o)??!1:!1,a=o?e.libraryDefinition?.(o):void 0;return s||!a||a.kind!=="symbol"?{...ha(t),pivotRequired:i,pivotResolved:!0,diagnostics:[]}:vT(t,a,He,{view:e,host:n,active:new Set,activeReferences:new Set,activeSymbols:new Set,identityPrefixes:[],forceInlineChildren:0,path:[],collectDiagnostics:!0},r,!0).transform}function xT(e,t={},n={}){let r=null,i=[];for(let o of e.roots()){if(!$l(o,n))continue;let s=ti(e,o,t,n);r=Dl(r,s.bounds),i.push(...s.diagnostics)}return Er(r,i)}function qp(e,t={}){if(!An(e.state))return{transform:ma(e.state),contentBounds:null,pivotRequired:!1,pivotResolved:!0};let i={view:Dr({shapes:[e],viewboxes:[]}),host:t,active:new Set([`document\0${e.id}`]),activeReferences:new Set,activeSymbols:new Set,identityPrefixes:[],forceInlineChildren:0,path:[e.id],collectDiagnostics:!0},o=Wp(e,He,i),a=o.diagnostics.some(c=>c.code==="unsupported-shape"||c.code==="deferred-tree-kind")?null:o.bounds;return{transform:El(e.state,a),contentBounds:o,pivotRequired:!0,pivotResolved:a!==null||o.status==="empty"}}function ba(e,t=e.id){return{kind:"pattern",id:t,name:e.name??t,pattern:{type:"pattern",svgContent:e.svgContent,width:e.width,height:e.height,patternType:"custom",color:"#000000",backgroundColor:"transparent",scale:1,rotation:0,opacity:1,patternUnits:"userSpaceOnUse"}}}function Zp(e){if(e.builtIn)return!1;let t=e.pattern;return!t||typeof t!="object"?!1:t.patternType==="custom"&&typeof t.svgContent=="string"}var iV=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?(?:px)?$/u;function IT(e,t){if(e.patternUnits!=="userSpaceOnUse")return;let n=e.authoredGeometry?.[t]?.trim();if(n===void 0||!iV.test(n))return;let r=Number.parseFloat(n);return Number.isFinite(r)&&r>0?r:void 0}function Qp(e){let t=(e.viewBox??"").trim().split(/[\s,]+/).filter(o=>o.length>0).map(Number),n=t.length===4&&t.every(o=>Number.isFinite(o)),r=n&&t[2]>0?t[2]:e.width??IT(e,"width")??10,i=n&&t[3]>0?t[3]:e.height??IT(e,"height")??10;return{width:r,height:i}}function Jp(e){if(!Zp(e))return null;let{width:t,height:n}=Qp(e.pattern);return{id:e.id,name:e.name,svgContent:e.pattern.svgContent??"",width:t,height:n}}function oV(e,t){let n=new Map(t.map(o=>[o.id,o])),r=typeof e=="string"?n.get(e):e,i=new Set;for(;r?.kind==="pattern";){if(i.has(r.id))return null;if(i.add(r.id),Zp(r))return r;let o=r.pattern?.templateId;if(!o)return null;r=n.get(o)}return null}function wT(e,t){let n=oV(e,t);if(!n)return null;let{width:r,height:i}=Qp(YS(n,t)??n.pattern);return{id:n.id,name:n.name,svgContent:n.pattern.svgContent??"",width:r,height:i}}function sV(){let e=new Set(Wh);for(let t of Xh)e.add(t);for(let t of Pe.typeIds())for(let n of Object.keys(Pe.getDefaults(t)))e.add(n);return e.delete("scaleAnchor"),e.delete("extra"),e}var Bb=sV(),kT=new Set(["scaleAnchor","displayAttr"]);function zl(e){let t=e.extra&&typeof e.extra=="object"&&!Array.isArray(e.extra)?e.extra:void 0;for(let n of Object.keys(e)){if(n==="extra"||Bb.has(n))continue;let r=e[n];delete e[n],r!==void 0&&((t??={})[n]=r)}return t&&Object.keys(t).length>0?e.extra=t:delete e.extra,e}function em(e){return bn(e,{onState:t=>{zl(t)}}),e}function tm(e){return bn(e,{onState:t=>{ro(t)}}),e}function ro(e){let t=e.extra;if(!t||typeof t!="object"||Array.isArray(t))return delete e.extra,e;for(let[n,r]of Object.entries(t))n!=="extra"&&(n in e||(e[n]=r));return delete e.extra,e}function Vb(e){return typeof e=="string"&&e.length>0?e:null}function aV(e){let t=Vb(e.groupId);if(t)return t;let n=e.extra;return!n||typeof n!="object"||Array.isArray(n)?null:Vb(n.groupId)}function PT(e){delete e.groupId;let t=e.extra;if(!t||typeof t!="object"||Array.isArray(t))return;let n=t;delete n.groupId,Object.keys(n).length===0&&delete e.extra}function cV(e){let t={};return e.transformOrigin&&(t.transformOrigin=e.transformOrigin),e.pluginId&&(t.pluginId=e.pluginId),e.pluginData&&(t.pluginData=e.pluginData),e.attributes&&Object.keys(e.attributes).length>0&&(t.attributes=e.attributes),e.fill&&(t.fill=e.fill),e.fillOpacity&&(t.fillOpacity=e.fillOpacity),e.strokeOpacity&&(t.strokeOpacity=e.strokeOpacity),e.opacity&&(t.opacity=e.opacity),e.filter&&(t.filter=e.filter),e.cssFilter&&(t.cssFilter=e.cssFilter),e.mixBlendMode&&(t.mixBlendMode=e.mixBlendMode),e.isolation&&(t.isolation=e.isolation),e.clipPath&&(t.clipPath=e.clipPath),e.mask&&(t.mask=e.mask),e.rawMetadata&&(t.rawMetadata=e.rawMetadata),e.transform&&(t.transform=e.transform),t}function lV(e){let t=cV(e),n={fillColor:null,borderColor:null,rotation:0,skewX:0,skewY:0,customPivot:null};return Object.keys(t).length>0&&(n.groupData=t),{id:e.id,type:"group",state:n}}function TT(e,t){let n=e.state.children;if(Array.isArray(n))for(let r of n)t.add(r.id),TT(r,t)}function RT(e,t=!1){let n=e.state,r=n.children;return t&&PT(n),Array.isArray(r)&&(n.children=r.map(i=>RT(i,!0))),e}function dV(e){if(e.length<2)return e.map(s=>s.shape);let t=e.filter(s=>s.shape.type==="group"&&s.siblingIndex!==void 0&&Number.isFinite(s.siblingIndex)).sort((s,a)=>(s.siblingIndex??0)-(a.siblingIndex??0));if(t.length===0)return[...e].sort((s,a)=>s.flatOrder-a.flatOrder).map(s=>s.shape);let n=Array(e.length).fill(null),r=new Set(t);for(let s of t){let a=Math.max(0,Math.min(e.length-1,s.siblingIndex??0));for(;a<n.length&&n[a]!==null;)a++;if(a>=n.length)for(a=n.length-1;a>=0&&n[a]!==null;)a--;a>=0&&(n[a]=s)}let i=e.filter(s=>!r.has(s)).sort((s,a)=>s.flatOrder-a.flatOrder),o=0;for(let s of i){for(;o<n.length&&n[o]!==null;)o++;o<n.length&&(n[o]=s)}return n.filter(s=>s!==null).map(s=>s.shape)}function Fl(e,t=[]){let n=structuredClone(e),r=structuredClone(t),i=new Map;for(let h of r)i.set(h.id,h);let o=n.map(h=>RT(h)),s=new Set;for(let h of o)TT(h,s);let a=new Map,c=new Map;o.forEach((h,y)=>{s.has(h.id)||c.has(h.id)||(a.set(h.id,y),c.set(h.id,h))});for(let h of r){if(s.has(h.id)||c.has(h.id))continue;let y=lV(h);a.set(y.id,Number.POSITIVE_INFINITY),c.set(y.id,y)}let l=new Map,d=new Map;for(let h of c.values()){let y=h.state,S=i.get(h.id),b=aV(y)??(h.type==="group"?Vb(S?.parentId):null),I=l.get(b)??[];d.set(h.id,b),I.push({shape:h,flatOrder:a.get(h.id)??Number.POSITIVE_INFINITY,siblingIndex:h.type==="group"?S?.siblingIndex:void 0}),l.set(b,I)}let u=new Set,f=h=>{if(u.has(h.id))return null;u.add(h.id);let y=h.state,S=Array.isArray(y.children)?y.children:[],b=p(h.id),I=new Set(S.map(w=>w.id)),v=[...S,...b.filter(w=>!I.has(w.id))];return v.length>0?y.children=v:delete y.children,PT(y),h},p=h=>{let y=[];for(let S of dV(l.get(h)??[])){let b=f(S);b&&y.push(b)}return y},m=p(null),g=h=>{if(!h)return;let y=f(h);y&&m.push(y)};for(let h of c.values()){let y=d.get(h.id);y&&!c.has(y)&&g(h)}for(let h of r)g(c.get(h.id));for(let h of c.values())g(h);return m}var Ll="data-svgsketch-passthrough",uV=new Set(["mask","clipPath","filter","linearGradient","radialGradient","pattern","symbol"]),fV=/^<([A-Za-z][\w:-]*)\b[^>]*>/;function CT(e){return fV.exec(e.trimStart())}function _l(e){let t=CT(e);if(!t)return null;let n=/\bid\s*=\s*(?:"([^"]*)"|'([^']*)')/.exec(t[0]);return n?n[1]??n[2]:null}function pV(e){let t=CT(e);if(!t)return null;let n=t[1],r=n.lastIndexOf(":");return r>=0?n.slice(r+1):n}var mV=new RegExp(`\\s+${Ll}\\s*=\\s*(?:"[^"]*"|'[^']*')`);function Bl(e){let t=e.markup.indexOf(">");if(t<0)return e;let n=e.markup.slice(0,t+1),r=mV.exec(n);if(!r)return e;let i=n.slice(0,r.index)+n.slice(r.index+r[0].length);return{...e,markup:i+e.markup.slice(t+1),passthrough:!0}}function AT(e){let t=[];for(let n of e){if(typeof n!="string")continue;let r=_l(n);if(!r)continue;let i=pV(n),o=i&&uV.has(i)?i:"mask";t.push(Bl({id:r,type:o,markup:n}))}return t}var gV=[["splinePoints","pathPoints"],["splineClosed","pathClosed"],["splineCurveType","pathCurveType"],["splineTension","pathTension"],["splineArcParams","pathArcParams"],["splineControlBounds","pathControlBounds"]];function hV(e){let t=!1;if(e.type==="spline"&&(e.type="path",t=!0),e.state&&typeof e.state=="object"){let n=e.state,r=n.extra&&typeof n.extra=="object"&&!Array.isArray(n.extra)?n.extra:null;for(let[i,o]of gV)Object.prototype.hasOwnProperty.call(n,i)&&(Object.prototype.hasOwnProperty.call(n,o)||(n[o]=n[i]),Reflect.deleteProperty(n,i),t=!0),r&&Object.prototype.hasOwnProperty.call(r,i)&&(Object.prototype.hasOwnProperty.call(n,o)||(n[o]=r[i]),delete r[i],t=!0);r&&Object.keys(r).length===0&&delete n.extra}return t}function NT(e){return mt(e,{onShape:t=>{hV(t)}}),e}function yV(e){if(e.type!=="connector")return;let t=e.state,n=Vl(t.sourcePoint),r=Vl(t.targetPoint);e.type="line",e.state={...e.state,x1:typeof t.x1=="number"?t.x1:n?.x??0,y1:typeof t.y1=="number"?t.y1:n?.y??0,x2:typeof t.x2=="number"?t.x2:r?.x??0,y2:typeof t.y2=="number"?t.y2:r?.y??0,routingMode:t.routingMode??"orthogonal"}}function $T(e){let t=e.customPivot;if(t)return t;let n=e.x,r=e.y,i=e.width,o=e.height;if(typeof n=="number"&&typeof r=="number"&&typeof i=="number"&&typeof o=="number")return{x:n+i/2,y:r+o/2};let s=e.radius;if(typeof n=="number"&&typeof r=="number"&&typeof s=="number")return{x:n,y:r};let a=e.cx,c=e.cy;if(typeof a=="number"&&typeof c=="number")return{x:a,y:c};let l=e.x1,d=e.y1,u=e.x2,f=e.y2;if(typeof l=="number"&&typeof d=="number"&&typeof u=="number"&&typeof f=="number")return{x:(l+u)/2,y:(d+f)/2};let p=e.pathPoints;if(p?.[0])return{x:p[0].x,y:p[0].y};let m=e.polylinePoints;if(m?.[0])return{x:m[0].x,y:m[0].y}}function SV(e){return mt(e,{onShape:t=>{let n=t.state;!n||typeof n!="object"||vy(n,$T(n))}}),e.schemaVersion=3,e}function Vl(e){let t=e;return t&&typeof t.x=="number"&&Number.isFinite(t.x)&&typeof t.y=="number"&&Number.isFinite(t.y)?{x:t.x,y:t.y}:null}function bV(e,t){let n=e.translateX??0,r=e.translateY??0,i=typeof e.rawTransform=="string"?e.rawTransform:"",o=lt(n,r);if(i)return Pt(ve(o,Tn(i)));let s=e.rotation??0,a=e.skewX??0,c=e.skewY??0;if(s!==0||a!==0||c!==0){let u=Vl(e.customPivot)??t??Vl(e.scaleAnchor);u&&(o=ve(o,lt(u.x,u.y)),s!==0&&(o=ve(o,Ts(s))),a!==0&&(o=ve(o,vc(a))),c!==0&&(o=ve(o,xc(c))),o=ve(o,lt(-u.x,-u.y)))}let l=e.scaleX??1,d=e.scaleY??1;if(l!==1||d!==1){let u=Vl(e.scaleAnchor)??t;u&&(o=ve(o,lt(u.x,u.y)),o=ve(o,wo(l,d)),o=ve(o,lt(-u.x,-u.y)))}return Pt(o)}function vV(e){return mt(e,{onShape:t=>{let n=t.state;!n||typeof n!="object"||!("scaleAnchor"in n)||(t.type==="text"&&!mi(n.transformMatrix)&&(n.transformMatrix=bV(n,$T(n))),delete n.scaleAnchor)}}),e.schemaVersion=4,e}function xV(e){let t=e,n=Array.isArray(e.library)?[...e.library]:[],r=new Set(n.map(l=>l.id));if(Array.isArray(t.symbols))for(let l of t.symbols)!l||r.has(l.id)||(n.push({...l,kind:"symbol"}),r.add(l.id));if(Array.isArray(t.markers))for(let l of t.markers)!l||r.has(l.id)||(n.push({...l,kind:"marker"}),r.add(l.id));let i=new Map,o=(l,d)=>{let{id:u,sourceId:f,...p}=l,m=JSON.stringify({kind:d,...p}),g=i.get(m);if(g)return g;let h=r.has(l.id)?`grd-${nm()}`:l.id;r.add(h),i.set(m,h);let y=d==="linear-gradient"?{kind:"linear-gradient",id:h,name:l.sourceId??h,sourceId:l.sourceId,gradient:ET(l)}:{kind:"radial-gradient",id:h,name:l.sourceId??h,sourceId:l.sourceId,gradient:ET(l)};return n.push(y),h},s=new Map;if(Array.isArray(t.customPatterns))for(let l of t.customPatterns){if(!l)continue;let d=r.has(l.id)?`pat-${nm()}`:l.id;r.add(d),s.set(l.id,d),n.push(ba(l,d))}let a=l=>{if(l.customPatternId){let S=s.get(l.customPatternId);if(S)return S}let{id:d,sourceId:u,customPatternId:f,...p}=l,m=JSON.stringify({kind:"pattern",...p}),g=i.get(m);if(g)return g;let h=r.has(l.id)?`pat-${nm()}`:l.id;r.add(h),i.set(m,h);let y={kind:"pattern",id:h,name:l.sourceId??h,sourceId:l.sourceId,pattern:p};return n.push(y),h};for(let l of e.shapes??[]){let d=l.state;if(!d)continue;let u=d.fillGradient;u&&(typeof d.fillType!="string"&&(d.fillType=u.type),u.type==="linear-gradient"||u.type==="radial-gradient"?d.fillLibraryId=o(u,u.type):u.type==="pattern"&&(d.fillLibraryId=a(u)));let f=d.strokeGradient;f&&(typeof d.strokeType!="string"&&(d.strokeType=f.type),f.type==="linear-gradient"||f.type==="radial-gradient"?d.strokeLibraryId=o(f,f.type):f.type==="pattern"&&(d.strokeLibraryId=a(f)));let p=d.filters;if(Array.isArray(p)&&p.length>0){let m=c(p,d,l.id);d.filterLibraryIds=[m]}}return e.library=n,mt(e,{onShape:yV}),delete t.customPatterns,delete t.symbols,delete t.markers,e;function c(l,d,u){let f={filters:l,colorInterpolation:d.filterColorInterpolation,filterUnits:d.filterUnits,primitiveUnits:d.primitiveUnits,x:d.filterX,y:d.filterY,width:d.filterWidth,height:d.filterHeight},p=JSON.stringify({kind:"filter",...f}),m=i.get(p);if(m)return m;let g=`filter-${u}`,h=r.has(g)?`flt-${nm()}`:g;r.add(h),i.set(p,h);let y={kind:"filter",id:h,name:h,filters:f.filters,...f.colorInterpolation?{colorInterpolation:f.colorInterpolation}:{},...f.filterUnits?{filterUnits:f.filterUnits}:{},...f.primitiveUnits?{primitiveUnits:f.primitiveUnits}:{},...f.x!==void 0?{x:f.x}:{},...f.y!==void 0?{y:f.y}:{},...f.width!==void 0?{width:f.width}:{},...f.height!==void 0?{height:f.height}:{}};return n.push(y),h}}function ET(e){let{id:t,sourceId:n,...r}=e;return r}var Gb=0;function nm(){return Gb=Gb+1&65535,`${Date.now().toString(36)}-${Gb.toString(36)}`}function IV(e){return mt(e,{onState:t=>{let n=t,r=Object.prototype.hasOwnProperty.call(n,"richTextData"),i=n.richTextData;if(zl(t),!r)return;n.richTextData=i;let o=t.extra;o&&(delete o.richTextData,Object.keys(o).length===0&&delete t.extra)}}),e.schemaVersion=5,e}function wV(e){if(!e||typeof e!="object"||Array.isArray(e))return;let t=e;if(t.richTextRuns!==void 0&&t.richTextRuns!==null)return;let n=t.richTextData;!n||typeof n!="object"||Array.isArray(n)||Array.isArray(n.lines)&&(t.richTextRuns=yi(n))}function kV(e){return mt(e,{onState:t=>wV(t)}),e.schemaVersion=6,e}function jb(e,t){if(!t.has(e))return e;let n=2;for(;t.has(`${e}-${n}`);)n++;return`${e}-${n}`}function va(e){let t=new Set,n=new Set,r=new Map;mt(e,{onShape:o=>{if(n.add(o.id),o.type!=="view")return;r.has(o.id)||r.set(o.id,o);let s=o.state.viewName;typeof s=="string"&&s&&t.add(s)}});let i=[];return(e.viewboxes??[]).filter(o=>{let s=r.get(o.id);return!(s&&s.state.viewBoxX===o.x&&s.state.viewBoxY===o.y&&s.state.viewBoxWidth===Math.max(1,o.width)&&s.state.viewBoxHeight===Math.max(1,o.height))}).forEach((o,s)=>{let a=jb(`view-${s+1}`,t);t.add(a);let c=jb(o.id||`legacy-view-${s+1}`,n);n.add(c),i.push({id:c,type:"view",state:{viewBoxX:o.x,viewBoxY:o.y,viewBoxWidth:Math.max(1,o.width),viewBoxHeight:Math.max(1,o.height),viewName:a}})}),i.length>0&&e.shapes.unshift(...i),e.viewboxes=[],e}var PV=["svgX","svgY","svgWidth","svgHeight","svgViewBoxX","svgViewBoxY","svgViewBoxWidth","svgViewBoxHeight","svgPreserveAspectRatio"];function TV(e){if(e.type!=="svg"||e.state.isRootSvg===!0)return;let t=e.state;if(![t.svgViewBoxX,t.svgViewBoxY,t.svgViewBoxWidth,t.svgViewBoxHeight].every(i=>i===0))return;if(t.svgX===0&&t.svgY===0&&t.svgWidth===0&&t.svgHeight===0&&t.svgPreserveAspectRatio===""){for(let i of PV)delete t[i];return}delete t.svgViewBoxX,delete t.svgViewBoxY,delete t.svgViewBoxWidth,delete t.svgViewBoxHeight}function Ub(e){return mt(e,{onShape:TV}),va(e),e.schemaVersion=7,e}var RV=["viewBox","preserveAspectRatio","x","y","width","height","refX","refY"];function CV(e,t){if(e.type!=="symbol-instance"||e.state.authoredUseGeometry!==void 0)return;let n={};for(let r of["x","y","width","height"]){if((r==="width"||r==="height")&&t.has(String(e.state.symbolId??"")))continue;let i=e.state[r];typeof i=="number"&&Number.isFinite(i)&&(n[r]=String(i))}Object.keys(n).length>0&&(e.state.authoredUseGeometry=n)}function AV(e){let t=new Set((e.library??[]).filter(n=>n.kind==="symbol"&&n.defKind==="group").map(n=>n.id));for(let n of e.library??[]){if(n.kind!=="symbol")continue;let r=n,i={...r.wrapperAttrs??{},...r.rootAttributes??{}};for(let s of RV){let a=i[s];r[s]===void 0&&a!==void 0&&(r[s]=a),delete i[s]}if(r.overflow!==void 0&&i.overflow===void 0&&(i.overflow=r.overflow),Object.keys(i).length>0?r.rootAttributes=i:delete r.rootAttributes,r.shapes=Fl(r.shapes,r.groups),r.variants)for(let[s,a]of Object.entries(r.variants))r.variants[s]=Fl(a,r.groups);let o=r;delete o.wrapperAttrs,delete o.groups,delete o.overflow}return mt(e,{onShape:n=>CV(n,t)}),e.schemaVersion=8,e}function NV(e){let t=e;Array.isArray(e.shapes)&&(e.shapes=Fl(e.shapes,t.groups)),delete t.groups,Array.isArray(t.rawPaintServerDefs)&&!Array.isArray(e.paintServerDefs)&&(e.paintServerDefs=AT(t.rawPaintServerDefs)),delete t.rawPaintServerDefs;for(let n of e.library??[]){if(n.kind!=="marker")continue;let r=n;r.shapes=Fl(r.shapes,r.groups),delete r.groups}return Array.isArray(t.clipMaskGroups)&&(e.clipMaskGroups=t.clipMaskGroups.map(n=>{let r=n,i=Array.isArray(r.clipShapeIds)?r.clipShapeIds:typeof r.clipShapeId=="string"&&r.clipShapeId.length>0?[r.clipShapeId]:[],o={...r,clipShapeIds:i};return delete o.clipShapeId,o})),e.schemaVersion=9,e}function EV(e){return mt(e,{onState:t=>{let n=t;n.richTextRuns===void 0&&n.richTextData!==null&&typeof n.richTextData=="object"&&Array.isArray(n.richTextData.lines)&&(n.richTextRuns=yi(n.richTextData)),delete n.richTextData}}),e.schemaVersion=10,e}function OV(e){let n=(Array.isArray(e)?e.slice(0,6).join(" "):String(e)).trim().toLowerCase();return n==="none"||n==="hidden"||n==="collapse"?"none":"inline"}function OT(e){let t=new Set(e.keyframes.flatMap(n=>n.id?[n.id]:[]));if(e.keyframes.forEach((n,r)=>{if(n.id)return;let i=`kf${r}`;for(;t.has(i);)i=`${i}x`;n.id=i,t.add(i)}),e.property==="visibility"&&e.sourceSmilAttribute==="display"){e.property="display";for(let n of e.keyframes)n.value=OV(n.value)}delete e.sourceSmilAttribute}function DV(e){if(!Array.isArray(e.shapes))return;let t=new Map,n=new Map,r=new Map,i=(s,a)=>{let c=a?n:t,l=c.get(s.id)??[];l.push(s),c.set(s.id,l),r.set(s.id,(r.get(s.id)??0)+1);let d=s.state.children;Array.isArray(d)&&d.forEach(u=>i(u,!0))};e.shapes.forEach(s=>i(s,!1));let o=new Set;for(let[s,a]of t)a.length!==1||r.get(s)!==2||(n.get(s)??[]).length===1&&o.add(s);e.shapes=e.shapes.filter(s=>!o.has(s.id))}function $V(e){if(!Array.isArray(e.shapes))return;mt(e,{onShape:a=>{if(a.type!=="view")return;let c=a.state;Reflect.deleteProperty(c,"viewLinkedSvgId"),typeof c.extra=="object"&&c.extra!==null&&!Array.isArray(c.extra)&&Reflect.deleteProperty(c.extra,"viewLinkedSvgId")}});let t=e.shapes.filter(a=>{if(a.type!=="view")return!1;let c=a.state;return c.isHomeView===!0||typeof c.extra=="object"&&c.extra!==null&&!Array.isArray(c.extra)&&c.extra.isHomeView===!0});if(t.length===0)return;let n=t[0].state,r=Number(n.viewBoxWidth??0),i=Number(n.viewBoxHeight??0),o=e.shapes.find(a=>a.type==="svg"&&a.state.isRootSvg===!0);if(o&&r>0&&i>0){let a=Number(o.state.svgViewBoxWidth??0),c=Number(o.state.svgViewBoxHeight??0);a>0&&c>0||(o.state.svgViewBoxX=Number(n.viewBoxX??0),o.state.svgViewBoxY=Number(n.viewBoxY??0),o.state.svgViewBoxWidth=r,o.state.svgViewBoxHeight=i,Number(o.state.svgWidth??0)>0||(o.state.svgWidth=r),Number(o.state.svgHeight??0)>0||(o.state.svgHeight=i))}let s=new Set(t.map(a=>a.id));e.shapes=e.shapes.filter(a=>!s.has(a.id)),e.sceneTree=e.sceneTree?.filter(a=>!s.has(a.id))}function MV(e){if(!Array.isArray(e.shapes))return;let t=new Set;mt(e,{onShape:i=>{typeof i.id=="string"&&t.add(i.id)}});let n=new Map,r=i=>i.map(o=>{let s=o.state.children;Array.isArray(s)&&(o.state.children=r(s));let a=o.state.metadata;if(!a||typeof a!="object"||Array.isArray(a))return o;let c=typeof a.linkUrl=="string"?a.linkUrl:"",l=typeof a.linkTarget=="string"?a.linkTarget:"";if(!Object.hasOwn(a,"linkUrl")&&!Object.hasOwn(a,"linkTarget"))return o;let{linkUrl:d,linkTarget:u,...f}=a;if(o.state.metadata=f,!c||o.type==="hyperlink")return o;let p=jb(`${o.id}-link`,t);return t.add(p),n.set(o.id,p),{id:p,type:"hyperlink",state:{href:c,...l?{linkTarget:l}:{},children:[o]}}});e.shapes=r(e.shapes);for(let i of e.library??[])if(!(i.kind!=="symbol"&&i.kind!=="marker")&&(i.shapes=r(i.shapes),i.kind==="symbol"&&i.variants))for(let[o,s]of Object.entries(i.variants))i.variants[o]=r(s);if(e.sceneTree&&n.size>0){let i=[];for(let o of e.sceneTree){let s=n.get(o.id);if(!s){i.push(o);continue}i.push({...o,id:s}),i.push({id:o.id,parentId:s,index:0})}e.sceneTree=i}}function zV(e){mt(e,{onState:t=>{(t.fillType==="linear-gradient"||t.fillType==="radial-gradient"||t.fillType==="pattern")&&t.fillColor==="none"&&t.fillOpacity===0&&(t.fillOpacity=1)}})}function FV(e){mt(e,{onState:t=>{Array.isArray(t.charOffsets)&&(t.charOffsets=t.charOffsets.map(n=>{if(!n||typeof n!="object"||"dx"in n||typeof n.x!="number")return n;let r=n;return{x:null,y:null,dx:r.x,dy:typeof r.y=="number"&&Number.isFinite(r.y)?r.y:0,rotate:typeof r.rotate=="number"&&Number.isFinite(r.rotate)?r.rotate:0}}))}})}function LV(e){mt(e,{onShape:t=>{if(t.type!=="group")return;let n=t.state,r=n.groupData;if(!r||typeof r!="object"||Array.isArray(r))return;let i=r,o=i.attributes;if(o&&typeof o=="object"&&!Array.isArray(o)){let s={...o};n.locked===void 0&&s["data-locked"]==="true"&&(n.locked=!0),n.visible===void 0&&s["data-hidden"]==="true"&&(n.visible=!1),delete s["data-locked"],delete s["data-hidden"],Object.keys(s).length>0?i.attributes=s:delete i.attributes}Array.isArray(i.classes)&&(i.classes=i.classes.map(s=>{let a=String(s);return a.startsWith("usr-")?a.slice(4):a}))}})}function _V(e){let t=NT(e);va(t),$V(t),DV(t),MV(t),zV(t),FV(t),LV(t);for(let n of t.animationTimeline?.tracks??[])OT(n);for(let n of t.library??[])if(!(n.kind!=="marker"&&n.kind!=="symbol"))for(let r of n.animations??[])OT(r);return t.schemaVersion=11,t}function Hb(e){return e.schemaVersion=12,e}function BV(e){return e.schemaVersion=13,e}function VV(e){return e.schemaVersion=14,e}function Kb(e){return mt(e,{onState:t=>{let n=t,r=n.authoredTextStructure;if(n.textSpanTree===void 0&&r&&typeof r.text=="string"&&Array.isArray(r.spans)){let i=r.spans.flatMap(o=>{if(!o||typeof o!="object"||Array.isArray(o))return[];let s=o;return typeof s.start=="number"&&typeof s.end=="number"&&typeof s.id=="string"?[{start:s.start,end:s.end,id:s.id,children:[]}]:[]});i.length===r.spans.length&&(n.textSpanTree={text:r.text,spans:i})}delete n.authoredTextStructure}}),e.schemaVersion=15,e}function Wb(e){return e.schemaVersion=16,e}function Xb(e){for(let t of e.documentStyles??[]){let n=t;n.placement??="root"}return e.schemaVersion=17,e}function Yb(e){return e.schemaVersion=18,e}function qb(e){return mt(e,{onState:t=>{let n=t;n.textPathReference===void 0&&typeof n.textPathRefShapeId=="string"&&n.textPathRefShapeId.length>0&&(n.textPathReference={kind:"shape",targetId:n.textPathRefShapeId,element:"href"}),delete n.textPathRefShapeId,delete n.textPathImportRefId}}),e.schemaVersion=19,e}function GV(e){return e.schemaVersion=20,e}function jV(e){return e.schemaVersion=21,e}function UV(e){let t=new Map,n=(r,i,o)=>{let s=r.textSpanTree;if(!s||typeof s!="object"||Array.isArray(s))return;let a=s.spans;if(!Array.isArray(a))return;let c=new Map,l=(d,u=[])=>{d.forEach((f,p)=>{if(!f||typeof f!="object"||Array.isArray(f))return;let m=f,g=[...u,p],h=typeof m.spanId=="string"&&m.spanId.length>0?m.spanId:`text-span:${i}:${g.join(".")}`;m.spanId=h,c.set(g.join("."),h),Array.isArray(m.children)&&l(m.children,g)})};l(a),o&&t.set(o,c)};return mt(e,{onShape:(r,i)=>n(r.state,r.id||i,r.id),onState:(r,i)=>n(r,i)}),e.animationTimeline&&(e.animationTimeline.tracks=e.animationTimeline.tracks.filter(r=>{let i=r.textSpanTarget;if(!i||Array.isArray(i.spanIds))return!0;let o=Array.isArray(i.path)?i.path:[],s=o.every(c=>Number.isInteger(c)&&Number(c)>=0)?o.join("."):"",a=s?t.get(r.shapeId)?.get(s):void 0;return a?(i.spanIds=[a],delete i.path,!0):!1})),e.schemaVersion=22,e}function HV(e){let t=pr(e),n=r=>{let i=r.authoredPlacement;if(!i||i.parentDefinitionId!==void 0)return;let o=t.resolve(i);o.kind==="library"&&(i.parentDefinitionId=o.definitionId)};for(let r of e.library??[])n(r);for(let r of e.paintServerDefs??[])n(r);for(let r of e.clipMaskGroups??[])n(r);return e.schemaVersion=23,e}function KV(e){return e.schemaVersion=24,e}function WV(e){return e.schemaVersion=25,e}function XV(e){return mt(e,{onShape(t){if(t.type!=="foreign-object")return;let n=t.state,r=n.rawContent;if(typeof r!="string")return;let i=Rn(`<svg xmlns="${te}"><foreignObject>${r}</foreignObject></svg>`,{source:"native-document",entrypoint:"full-snapshot-restore"}).value,o=i?.index.children(i.root.sourceNodeId).find(s=>s.localName.toLowerCase()==="foreignobject");n.foreignContent=o?structuredClone(aa(o.children)):r.length===0?[]:[{kind:"text",value:r}],delete n.rawContent}}),e.schemaVersion=26,e}function YV(e){let t=typeof e.shapeId=="string"?e.shapeId:"";if(t.startsWith("__dom__")&&t.length>7)return t.slice(7);let n=typeof e.domTargetSelector=="string"?e.domTargetSelector:"",r=/\[id\s*=\s*(["'])(.*?)\1\]/u.exec(n);return r?.[2]?r[2]:/^#([A-Za-z_][\w:.-]*)$/u.exec(n.trim())?.[1]??null}function DT(e,t){return e?Rn(`<svg xmlns="${te}">${e}</svg>`,{source:"native-document",entrypoint:"full-snapshot-restore"}).value?.nodes.some(r=>r.kind==="element"&&r.attributes.some(i=>i.namespaceUri===null&&i.localName==="id"&&i.value===t))??!1:!1}function qV(e,t){for(let n of e.clipMaskGroups??[]){let r=n.definitionId??`${n.type}-${n.id}`;if(r===t)return{definitionId:r};if(DT(n.rawDefinition,t))return{definitionId:r,nodeId:t}}for(let n of e.paintServerDefs??[]){if(n.id===t)return{definitionId:n.id};if(DT(n.markup,t))return{definitionId:n.id,nodeId:t}}for(let n of e.library??[]){if(n.id===t||n.sourceId===t)return{definitionId:n.id};if(n.kind==="filter")for(let r of n.filters){if(r.type!=="svg-primitive-chain")continue;let i=r.primitives.find(o=>o.id===t);if(i)return{definitionId:n.id,nodeId:i.id}}}return{definitionId:t}}function ZV(e){let t=typeof e.property=="string"?e.property:"";if(t==="domTransformStack")return"targetTransformStack";if(t==="domDisplay")return"targetDisplay";if(t==="domVisibility")return"targetVisibility";if(t!=="domAttribute")return t;let n=typeof e.domAttribute=="string"?e.domAttribute:"",r=n.toLowerCase();return new Map([["class","className"],["fill","fillColor"],["stroke","strokeColor"],["preserveaspectratio","svgPreserveAspectRatio"],["xlink:href","referenceTargetShapeId"],["href","referenceTargetShapeId"],["clippathunits","clipPathUnits"],["spreadmethod","spreadMethod"]]).get(r)??n}function QV(e){let t=e.animationTimeline;for(let n of t?.tracks??[]){let r=n,i=YV(r);if(!i)continue;let o=qV(e,i);r.definitionTarget=o,r.shapeId=vr(o),r.property=ZV(r),typeof r.domAttribute=="string"&&(r.targetAttribute=r.domAttribute),typeof r.domAttributeValueType=="string"&&(r.targetAttributeValueType=r.domAttributeValueType),delete r.domTargetSelector,delete r.domTargetIdGenerated,delete r.domAttribute,delete r.domAttributeValueType}return e.schemaVersion=27,e}function JV(e){return e.schemaVersion=28,e}function eG(e){let t=e.clipMaskGroups;if(!Array.isArray(t)||t.length===0)return e.schemaVersion=29,e;let n=new Set;for(let o of e.shapes)bn(o,{onShape:s=>n.add(s.id)});let r=new Set;for(let o of t){let s=typeof o.rawDefinition=="string"&&o.rawDefinition.length>0,a=o.clipShapeIds.some(c=>n.has(c));(s||a)&&r.add(`${o.type}\0${Lt(o)}`)}let i=t.filter(o=>r.has(`${o.type}\0${Lt(o)}`));return i.length!==t.length&&(e.clipMaskGroups=Yn(i),Nr(e)),e.schemaVersion=29,e}var Zb=Object.freeze({1:xV,2:SV,3:vV,4:IV,5:kV,6:Ub,7:AV,8:NV,9:EV,10:_V,11:Hb,12:BV,13:VV,14:Kb,15:Wb,16:Xb,17:Yb,18:qb,19:GV,20:jV,21:UV,22:HV,23:KV,24:WV,25:XV,26:QV,27:JV,28:eG});function tG(e){let t=e.schemaVersion;return typeof t!="number"||!Number.isFinite(t)||t<1?1:Math.floor(t)}function xa(e,t=Zb){let n=JSON.parse(JSON.stringify(e)),r=tG(n);if(r>Pn)return n;if(r===Pn)return n.schemaVersion=Pn,n;for(;r<Pn;){let i=t[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 ${Pn}.`);n=i(n),r+=1}return n.schemaVersion=Pn,n}var LT=["unknown-shape-diagnostic","symbol-variants-overrides","smil-timeline","motion-only-partition","paint-server-references","filter-references","document-definition-context","inline-child-containers","isolated-flowchart-nodes","text-path","common-presentation","gradient-definition-envelope","filter-definition-envelope","export-precision-rounding","defs-deduplication","source-id-restoration","orphan-def-exclusion","font-embedding","initial-value-elision","namespace-declaration-completion"],ge=e=>({mode:"supported",by:e}),io=e=>({mode:"diagnostic",signal:"warning",by:e}),Oe=e=>({mode:"outside-contract",reason:e}),_t=e=>e,MT=Oe("DXF is a static CAD geometry contract and has no representation for this SVG behavior."),zT=Oe("Mermaid is a static graph-structure contract and has no representation for this SVG behavior."),FT=Oe("PDF export produces a static page from the current editor SVG projection and does not promise animation playback."),_T={"unknown-shape-diagnostic":_t({renderToSvg:io("renderShape reports UNSUPPORTED_SHAPE_TYPE through renderToSvgWithDiagnostics"),codegen:io("buildRenderPlan carries UNSUPPORTED_SHAPE_TYPE into generateCodeWithDiagnostics"),dxf:io("DxfExportStats records unsupported types and the DXF export UI reports them"),mermaid:io("exportMermaidWithDiagnostics records unsupported nodes and both Mermaid UIs report them"),pdf:Oe("PDF conversion consumes an already-projected editor SVG; unknown model nodes never enter its input."),"editor-dom":Oe("Unknown nodes are preserved for round-trip but require a registered shape implementation for projection.")}),"symbol-variants-overrides":_t({renderToSvg:ge("buildRenderPlan materializes symbol variants and per-instance overrides before emission"),codegen:ge("every component backend consumes buildRenderPlan symbol materialization"),dxf:io("DXF unsupported-shape accounting reports symbol instances without a lowering"),mermaid:io("Mermaid node-skip diagnostics report symbol instances without a lowering"),pdf:ge("the editor projects SymbolInstance content into the SVG consumed by svg2pdf"),"editor-dom":ge("SymbolInstance projects resolved library variants and overrides")}),"smil-timeline":_t({renderToSvg:ge("buildRenderPlan injects renderAnimationElements output into target and document-root markup"),codegen:ge("component backends preserve SMIL elements in planned target and document-root markup"),dxf:MT,mermaid:zT,pdf:FT,"editor-dom":ge("AnimationManager and the shared SMIL kernel project live playback")}),"motion-only-partition":_t({renderToSvg:ge("buildRenderPlan diverts motionOnly templates into defs outside visible paint"),codegen:ge("component backends consume the render plan visible and motion-def partitions"),dxf:MT,mermaid:zT,pdf:FT,"editor-dom":Oe("The authoring DOM retains motion templates for editing instead of applying export partitioning.")}),"paint-server-references":_t({renderToSvg:ge("plan defs and shapes use one library-first paint-server reference resolver"),codegen:ge("buildShapeAttrs and plan defs use the library-first reference resolver"),dxf:Oe("DXF promises geometry and basic entity colors, not SVG paint-server definition graphs."),mermaid:Oe("Mermaid graph syntax has no SVG gradient or pattern paint-server model."),pdf:ge("the cloned SVG carries paint-server definitions and references into svg2pdf"),"editor-dom":ge("GradientManager maintains live defs matching shape paint references")}),"filter-references":_t({renderToSvg:ge("renderFilterDefs and filterReferenceValue emit matching identifiers"),codegen:ge("planned filter defs and buildShapeAttrs share filter reference resolution"),dxf:Oe("DXF entity geometry has no SVG filter graph or filter-reference representation."),mermaid:Oe("Mermaid graph syntax has no SVG filter graph or filter-reference representation."),pdf:ge("the cloned SVG carries filter definitions and references into svg2pdf"),"editor-dom":ge("FilterManager maintains live filter definitions and shape references")}),"document-definition-context":_t({renderToSvg:ge("buildRenderPlan consumes the full snapshot definition and style context"),codegen:ge("component codegen accepts snapshot context and clipboard supplies its definitions"),dxf:Oe("DXF consumes resolved shapes and does not serialize SVG document definition sections."),mermaid:Oe("Mermaid consumes graph nodes and does not serialize SVG definition sections."),pdf:ge("PDF receives a cloned SVG document with its referenced definition context"),"editor-dom":ge("the document aggregate and managers project referenced resources into defs")}),"inline-child-containers":_t({renderToSvg:ge("renderShape recursively renders INLINE_CHILD_CONTAINER_TYPES children"),codegen:ge("component backends preserve recursively rendered plan container markup"),dxf:ge("DXF walks INLINE_CHILD_CONTAINER_TYPES with transforms and cycle guards"),mermaid:io("unsupported container nodes are counted by exportMermaidWithDiagnostics"),pdf:ge("the cloned editor SVG preserves nested containers for svg2pdf"),"editor-dom":ge("registered containers project managed children into nested SVG elements")}),"isolated-flowchart-nodes":_t({renderToSvg:Oe("Isolated-node declarations are a Mermaid graph concern, not an SVG branch."),codegen:Oe("Isolated-node declarations are a Mermaid graph concern, not component SVG output."),dxf:Oe("DXF emits geometry independently and has no connector-enrolment requirement."),mermaid:ge("exportMermaid declares mapped nodes before emitting connector edges"),pdf:Oe("PDF paints SVG geometry independently and has no graph-node declaration requirement."),"editor-dom":Oe("The live SVG projects shapes independently and has no graph-node declaration requirement.")}),"text-path":_t({renderToSvg:ge("renderText emits textPath markup and its referenced or private path definition; the render plan routes textPathMorph SMIL into that private path or into textPath for the inline path form"),codegen:ge("component backends preserve planned textPath markup, path definitions and their textPathMorph SMIL children"),dxf:Oe("DXF text entities do not reproduce SVG textPath layout along arbitrary paths."),mermaid:Oe("Mermaid labels do not reproduce SVG textPath layout along arbitrary paths."),pdf:io("ExportPanel.generatePdfBlob detects textPath content and shows its localized warning"),"editor-dom":ge("Text projects textPath attributes and maintains its referenced path")}),"common-presentation":_t({renderToSvg:ge("commonAttrs projects the ordered PRESENTATION_SEMANTICS vocabulary"),codegen:ge("buildShapeAttrs projects the ordered PRESENTATION_SEMANTICS vocabulary"),dxf:Oe("DXF is not an SVG presentation-attribute serialization contract."),mermaid:Oe("Mermaid is not an SVG presentation-attribute serialization contract."),pdf:ge("svg2pdf consumes common presentation attributes from the cloned SVG"),"editor-dom":ge("COMMON_PROP_RENDERERS derives its dispatch from PRESENTATION_SEMANTICS")}),"gradient-definition-envelope":_t({renderToSvg:ge("gradient renderers serialize the shared typed definition envelopes"),codegen:ge("render plan defs contain gradients serialized from shared typed envelopes"),dxf:Oe("DXF has no SVG linearGradient or radialGradient definition envelope."),mermaid:Oe("Mermaid has no SVG linearGradient or radialGradient definition envelope."),pdf:ge("the cloned SVG supplies shared-envelope gradient definitions to svg2pdf"),"editor-dom":ge("GradientManager projects shared gradient envelopes into live defs")}),"filter-definition-envelope":_t({renderToSvg:ge("renderFilterElement serializes filterDefinitionEnvelope for each wrapper kind"),codegen:ge("render plan defs contain filters serialized from shared typed envelopes"),dxf:Oe("DXF has no SVG filter element or primitive graph envelope representation."),mermaid:Oe("Mermaid has no SVG filter element or primitive graph envelope representation."),pdf:ge("the cloned SVG supplies shared-envelope filter definitions to svg2pdf"),"editor-dom":ge("FilterManager projects filterDefinitionEnvelope before primitive emission")}),"export-precision-rounding":_t({renderToSvg:ge("finalizeRenderPlan rounds markup coordinates at the effective documentMetadata.coordinatePrecision"),codegen:Oe("Codegen backends consume the un-finalized render plan; component output precision is a code-style concern, not an export boundary."),dxf:Oe("DXF numeric precision is owned by the DXF writer, not the SVG export boundary."),mermaid:Oe("Mermaid emits graph syntax rather than SVG coordinate attribute streams."),pdf:ge("PDF viewbox pages consume the plan-assembled string (core rounding); selection pages pass through SvgExportFinalizer.roundSvgAttributes"),"editor-dom":ge("static string exports round through core finalizeRenderPlan (plan-assembled); the selection/subtree markup clone sinks round through SvgExportFinalizer.roundSvgAttributes; the raster clone sink skips rounding by design (spelling-only, pixel-irrelevant)")}),"defs-deduplication":_t({renderToSvg:ge("finalizeRenderPlan collapses content-identical gradient/pattern/marker defs and rewrites references"),codegen:Oe("Codegen backends consume the un-finalized render plan; def duplication in generated components is a code-size concern outside the export contract."),dxf:Oe("DXF output has no shared-definition graph in which duplicates could exist."),mermaid:Oe("Mermaid output has no shared-definition graph in which duplicates could exist."),pdf:ge("PDF viewbox pages consume the plan-assembled string (core dedup); selection pages pass through SvgExportFinalizer.deduplicateDefsForExport"),"editor-dom":ge("static string exports dedup through core finalizeRenderPlan (plan-assembled); the selection/subtree markup clone sinks run SvgExportFinalizer.deduplicateDefsForExport; the raster clone sink skips dedup by design (spelling-only, pixel-irrelevant)")}),"source-id-restoration":_t({renderToSvg:ge("finalizeRenderPlan restores uncontested library sourceIds and rewrites references"),codegen:Oe("Generated components keep collision-safe runtime ids; source ids are a document round-trip concern."),dxf:Oe("DXF entities carry no SVG id namespace for source ids to be restored into."),mermaid:Oe("Mermaid nodes carry no SVG id namespace for source ids to be restored into."),pdf:Oe("PDF output has no id namespace to restore; the intermediate SVG string restores ids for fidelity but the PDF consumer never observes them."),"editor-dom":ge("static string exports restore source ids through core finalizeRenderPlan (plan-assembled); the selection/subtree markup clone sinks run SvgExportFinalizer.restoreSourceIds; the raster clone sink skips restoration by design (ids are spelling, not pixels)")}),"orphan-def-exclusion":_t({renderToSvg:ge("def emission is demand-driven (collectReferencedLibraryDefs, the referenced-marker gate, the paint-server reachability fixed point) \u2014 unreferenced defs are never emitted, so no pruning pass exists or is needed"),codegen:ge("component backends consume the same demand-driven plan def channels"),dxf:Oe("DXF output has no defs graph from which orphans could need excluding."),mermaid:Oe("Mermaid output has no defs graph from which orphans could need excluding."),pdf:ge("the editor SVG consumed by svg2pdf passes through pruneOrphanedDefs"),"editor-dom":ge("static string exports are demand-driven via the core plan (no orphans emitted); the raster/selection clone sinks sweep accumulated live defs with SvgExportFinalizer.pruneOrphanedDefs")}),"font-embedding":_t({renderToSvg:ge("finalizeRenderPlan ships @font-face CSS from the injected resolveFontEmbedCss hook (core is platform-free; binary resolution is the caller environment responsibility)"),codegen:Oe("Generated components inherit the host page font pipeline; embedding binaries in component source is out of contract."),dxf:Oe("DXF text styling is font-name based; the format has no font binary embedding."),mermaid:Oe("Mermaid delegates font resolution entirely to the rendering host page."),pdf:ge("svg2pdf consumes the editor SVG after the async export inlined @font-face CSS"),"editor-dom":ge("every sink that leaves the live document embeds: static and animated string exports resolve plan-collected FACES (family + weight + style) through fontManager into the core resolveFontEmbedCss hook, and the embedded-SVG subtree and selection exports run SvgExportFinalizer.embedFontsInOutput over the projected tree. Raster sinks embed too, subset to the characters they render - an SVG handed to an <img> is processed in secure static/animated mode (SVG 2 2.2.4/2.2.6), so it resolves no external references and inherits none of the session live font faces. Only the internal clipboard payload skips embedding, because the session that wrote it is the session that reads it")}),"initial-value-elision":_t({renderToSvg:ge("finalizeRenderPlan drops redundant spec initials and product defaults under an initial-valued cascade (elideInitialValuesInPlan)"),codegen:Oe("Codegen backends consume the un-finalized plan; explicit values in component source are a readability choice, not an export-boundary concern."),dxf:Oe("DXF entities carry explicit CAD attributes with no SVG initial-value cascade."),mermaid:Oe("Mermaid emits graph syntax; SVG presentation initial values never appear in its output."),pdf:ge("PDF viewbox pages consume the plan-assembled string (core elision); selection pages pass through SvgExportFinalizer.stripDefaultPaintAttributes"),"editor-dom":ge("static string exports elide through core finalizeRenderPlan (plan-assembled); the selection/subtree markup clone sinks run SvgExportFinalizer.stripDefaultPaintAttributes and the output-artifact rules; the raster clone sink keeps default attributes by design (elision is spelling-only)")}),"namespace-declaration-completion":_t({renderToSvg:ge("finalizeRenderPlan declares used prefixes on the root via a well-known URI table (declareUsedNamespacePrefixes); unresolvable prefixes warn undeclarable-namespace-prefix"),codegen:Oe("Generated components render into a host document whose framework owns namespace handling; JSX/Vue templates have no xmlns declaration surface to complete."),dxf:Oe("DXF is not XML and has no namespace prefixes to declare or complete."),mermaid:Oe("Mermaid graph syntax is not XML; no namespace declarations exist."),pdf:ge("svg2pdf consumes the editor SVG string whose serializer declared every namespace it uses"),"editor-dom":ge("static string exports complete declarations through core declareUsedNamespacePrefixes; the raster/selection clone sinks rely on XMLSerializer plus hoistForeignNamespaceDecls")})};function Yo(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}async function Jb(e,t,n,r){let i=e[t];typeof i=="string"&&(e[t]=await r(i,n))}async function Qb(e,t){Yo(e)&&await Jb(e,"svgContent","svgMarkup",t)}async function rm(e,t){if(!Yo(e))return;await Jb(e,"href","href",t),await Qb(e.fillGradient,t),await Qb(e.strokeGradient,t);let n=e.children;if(Array.isArray(n))for(let r of n)Yo(r)&&await rm(r.state,t)}async function BT(e,t){if(!Yo(e))return;let n=e.shapes;if(Array.isArray(n))for(let o of n)Yo(o)&&await rm(o.state,t);let r=e.library;if(Array.isArray(r))for(let o of r)Yo(o)&&o.kind==="pattern"&&await Qb(o.pattern,t);let i=e.customPatterns;if(Array.isArray(i))for(let o of i)Yo(o)&&await Jb(o,"svgContent","svgMarkup",t)}function Gl(e,t,n={}){let r=to(e),i=r.errors.filter(o=>!n.ignoreError?.(o));if(i.length>0){let o=i.map(s=>` ${s.path}: ${s.message}`).join(`
|
|
41
|
+
${n}`:n}var W1=new Set(["animate","animatemotion","animatetransform","desc","metadata","mpath","set","title"]);function X1(e){switch(e.kind){case"text":return xb(e.value);case"comment":return`<!--${e.value}-->`;case"cdata":return`<![CDATA[${e.value.replaceAll("]]>","]]]]><![CDATA[>")}]]>`;case"processing-instruction":return`<?${e.value}?>`;case"doctype":return`<!DOCTYPE ${e.value}>`}}function GP(e,t,n){let r=e.sourceNodeId===t,i=new Map(e.attributes.map(u=>[u.name,u.value])),o=e.attributes.map(u=>u.name),s=(u,f)=>{if(f===null){i.delete(u);return}i.has(u)||o.push(u),i.set(u,f)};r&&Object.prototype.hasOwnProperty.call(n,"clipPathUnits")&&s("clipPathUnits",n.clipPathUnits??null),n.clipRule!==void 0&&(r||!W1.has(e.localName.toLowerCase()))&&s("clip-rule",n.clipRule);let a=o.filter((u,f)=>o.indexOf(u)===f&&i.has(u)).map(u=>`${u}="${_P(i.get(u))}"`),c=`<${e.name}${a.length>0?` ${a.join(" ")}`:""}`,l=e.children.map(u=>u.kind==="element"?GP(u,t,n):X1(u)).join(""),d=/\/\s*>\s*$/u.test(e.rawXml??"");return l.length===0&&d?`${c}/>`:`${c}>${l}</${e.name}>`}function jP(e,t){let n=Rn(`<svg xmlns="${te}">${e}</svg>`,{source:"native-document",entrypoint:"full-snapshot-restore"});if(!n.value)return null;let r=n.value.index.children(n.value.root.sourceNodeId)[0];if(!r)return null;let i=r.localName.toLowerCase();return i!=="clippath"&&i!=="mask"?null:GP(r,r.sourceNodeId,t)}function Vp(e){let t=/^(https?):\/\/([^/?#\s\\]+)([^\s\\]*)$/iu.exec(e);if(!t)return null;let n=t[1].toLowerCase(),r=t[2],i=r.lastIndexOf("@"),o=i>=0?r.slice(0,i+1):"",s=r.slice(i+1);if(!s)return null;let a=s.startsWith("[")?s.slice(0,Math.max(0,s.indexOf("]")+1)).toLowerCase():s.split(":")[0].toLowerCase();if(!a)return null;let c=t[3]||"/",l=c.indexOf("?"),d=c.indexOf("#",Math.max(0,l)),u=l<0?"":c.slice(l+1,d<0?void 0:d);return Object.freeze({href:`${n}://${o}${s.toLowerCase()}${c}`,hostname:a,query:u})}function LP(e){try{return decodeURIComponent(e.replace(/\+/gu," "))}catch{return e.replace(/\+/gu," ")}}function Ib(e){let t=[],n=0,r=null,i=!1,o=0;for(let s=0;s<e.length;s++){let a=e[s];if(r){i?i=!1:a==="\\"?i=!0:a===r&&(r=null);continue}if(a==="/"&&e[s+1]==="*"){s=Math.max(s,Fp(e,s)-1);continue}a==='"'||a==="'"?r=a:a==="("||a==="["?o++:a===")"||a==="]"?o=Math.max(0,o-1):a===","&&o===0&&(t.push(e.slice(n,s).trim()),n=s+1)}return t.push(e.slice(n).trim()),Object.freeze(t.filter(Boolean))}function UP(e){let t=[],n=0;for(;n<e.length;){for(;n<e.length&&(FP(e[n])||e[n]===",");)n++;if(n>=e.length)break;let r=n;for(;n<e.length&&!FP(e[n]);)n++;let i=e.slice(r,n);if(i.endsWith(",")){i=i.replace(/,+$/u,""),i&&t.push(i);continue}i&&t.push(i);let o=0;for(;n<e.length;){let s=e[n++];if(s==="(")o++;else if(s===")")o=Math.max(0,o-1);else if(s===","&&o===0)break}}return Object.freeze(t)}function wb(e){if(typeof e!="string")return null;let t=_p(Ib(e)[0]??"").trim();return!t||ca(t)?null:t}function Y1(e){let t=[];for(let n of Hr(e,";")){let r=e.slice(n.start,n.end),i=Hr(r,":",!0)[0]?.end??r.length;if(i>=r.length)continue;let o=r.slice(0,i).trim().toLowerCase(),s=r.slice(i+1).trim();o&&t.push(Object.freeze({property:o,value:s}))}return Object.freeze(t)}function q1(e){let t=Ir(e).find(n=>n.name==="format");return t&&_p(e.slice(t.argumentsStart,t.argumentsEnd))||null}var Z1=Object.freeze({"font-style":"style","font-weight":"weight","font-stretch":"stretch","font-display":"display","unicode-range":"unicodeRange","font-feature-settings":"featureSettings","font-variation-settings":"variationSettings","ascent-override":"ascentOverride","descent-override":"descentOverride","line-gap-override":"lineGapOverride","size-adjust":"sizeAdjust"});function Q1(e){let t={};for(let n of e){let r=Z1[n.property];r&&n.value&&(t[r]=n.value)}return Object.keys(t).length>0?Object.freeze(t):void 0}function kb(e){let t=[];for(let n of Lp(e)){if(n.name!=="font-face"||n.blockStart===null||n.blockEnd===null)continue;let r=Y1(e.slice(n.blockStart,n.blockEnd)),i=wb(r.find(a=>a.property==="font-family")?.value),o=r.find(a=>a.property==="src")?.value;if(!i||!o)continue;let s=Q1(r);for(let a of Ib(o)){let c=Bp(a);if(c===null)continue;let l=eo(c);l.status!=="external"||!l.requestUrl||t.push(Object.freeze({family:i,url:l.requestUrl,format:q1(a),...s?{descriptors:s}:{}}))}}return Object.freeze(t)}function HP(e){let t=[];for(let n of Lp(e)){if(n.name!=="import")continue;let r=Bp(e.slice(n.preludeStart,n.preludeEnd));if(r===null)continue;let i=eo(r);if(i.status!=="external"||!i.requestUrl)continue;let o=Vp(i.requestUrl);if(!o||o.hostname!=="fonts.googleapis.com")continue;let s=o.query.split("&").map(a=>a.split("=",2)).filter(([a])=>LP(a).toLowerCase()==="family").map(([,a])=>LP(a??""));for(let a of s)for(let c of a.split("|")){let l=c.split(":")[0].trim();l&&!ca(l)&&t.push(l)}}return Object.freeze(t)}function J1(e){return Hr(e,";").map(t=>{let n=e.slice(t.start,t.end),r=Hr(n,":",!0)[0]?.end??n.length;if(r>=n.length||n.slice(0,r).trim().toLowerCase()!=="src")return n;let o=n.slice(0,r+1),s=Ib(n.slice(r+1)).filter(a=>{let c=Bp(a);return c===null||eo(c).status==="data"});return`${o} ${s.length>0?s.join(", "):'local("__svgsketch_quarantined_font__")'}`}).join(";")}function Tl(e){let t=[];for(let i of Lp(e)){if(i.name==="import"){t.push({start:i.start,end:i.end,value:"/* external stylesheet import quarantined */"});continue}i.name!=="font-face"||i.blockStart===null||i.blockEnd===null||t.push({start:i.blockStart,end:i.blockEnd,value:J1(e.slice(i.blockStart,i.blockEnd))})}let n=e;for(let i of t.sort((o,s)=>s.start-o.start))n=`${n.slice(0,i.start)}${i.value}${n.slice(i.end)}`;let r=bb(n).filter(i=>{let o=i.rawUrl.trim();return!o||o.startsWith("#")?!1:eo(o).status!=="data"}).sort((i,o)=>o.tokenStart-i.tokenStart);for(let i of r)n=`${n.slice(0,i.tokenStart)}url("data:application/octet-stream;base64,")${n.slice(i.tokenEnd)}`;return n}function eB(e,t,n){let r=[];for(let i of t.stylesheets)if(i.applicable){for(let o of HP(i.authoredText))r.push(Object.freeze({sourceNodeId:i.sourceNodeId,occurrenceId:null,origin:"google-font-import",family:o}));for(let o of kb(i.authoredText))r.push(Object.freeze({sourceNodeId:i.sourceNodeId,occurrenceId:null,origin:"external-font-face",family:o.family,url:o.url,format:o.format,...o.descriptors?{descriptors:o.descriptors}:{}}))}for(let i of e.index.elements)for(let o of i.attributes)if(!(o.namespaceUri!==G1||o.localName!=="fonts"))for(let s of o.value.split(",")){let a=s.replace(/\+/gu," ").trim();!a||a.includes("/")||ca(a)||r.push(Object.freeze({sourceNodeId:i.sourceNodeId,occurrenceId:null,origin:"boxy-fonts",family:a}))}for(let i of n.candidates){if(i.canonicalType!=="text"||i.status!=="materialized")continue;let o=a=>{let c=wb(a);c&&r.push(Object.freeze({sourceNodeId:i.sourceNodeId,occurrenceId:i.occurrenceId,origin:"text-font-family",family:c}))};o(i.state.fontFamily);let s=Si(i.state);if(s){o(s.baseStyle.fontFamily);for(let a of s.runs)o(a.style.fontFamily)}}return Object.freeze(r)}function Wn(e,t){return e.attributes.find(n=>n.namespaceUri===null&&n.localName.toLowerCase()===t.toLowerCase())?.value??null}function yb(e){return e.children.map(t=>t.kind==="text"||t.kind==="cdata"?t.value:"").join("")}function Pb(e,t){let n=[],r=[...e.index.children(t)].reverse();for(;r.length>0;){let i=r.pop();n.push(i),r.push(...[...e.index.children(i.sourceNodeId)].reverse())}return Object.freeze(n)}function Xn(e,t){let n=eo(t.href);e.push(Object.freeze({...t,...n}))}function Ji(e,t,n,r=new Set(["css-import","css-url"]),i=()=>!0){for(let o of U1(t))!r.has(o.channel)||!i(o)||o.url.trim().startsWith("#")||Xn(e,{...n,occurrenceId:`${n.occurrenceId}:css:${o.tokenIndex}`,channel:o.channel,href:o.url,hrefNamespace:null})}function KP(e,t,n,r){for(let i of Pb(t,n.sourceNodeId)){let o=i.localName.toLowerCase(),s=Wn(i,"id"),a={sourceNodeId:i.sourceNodeId,occurrenceId:`${r}:foreign:${i.sourceNodeId}`,sourceId:s,elementName:i.localName},c=[{attributeName:"src",channel:"html-src",applies:["img","video","audio","source","track","iframe","embed"].includes(o)||o==="input"&&Wn(i,"type")?.toLowerCase()==="image"},{attributeName:"poster",channel:"html-poster",applies:o==="video"},{attributeName:"data",channel:"html-data",applies:o==="object"},{attributeName:"href",channel:"html-src",applies:o==="link"&&(Wn(i,"rel")??"").split(/\s+/u).some(u=>u.toLowerCase()==="stylesheet")}];for(let u of c){if(!u.applies)continue;let f=Wn(i,u.attributeName);f!==null&&Xn(e,{...a,occurrenceId:`${a.occurrenceId}:${u.attributeName}`,attributeName:u.attributeName,channel:u.channel,href:f,hrefNamespace:null})}let l=Wn(i,"srcset");if(l!==null&&(o==="img"||o==="source"))for(let[u,f]of UP(l).entries())Xn(e,{...a,occurrenceId:`${a.occurrenceId}:srcset:${u}`,attributeName:"srcset",channel:"html-srcset",href:f,hrefNamespace:null});let d=Wn(i,"style");d!==null&&Ji(e,d,{...a,attributeName:"style"}),o==="style"&&Ji(e,yb(i),{...a,attributeName:"textContent"})}}function tB(e,t,n,r){let i=Wn(n,"data-shape-type")?.toLowerCase();if(i==="video"||i==="audio"){let o=Pb(t,n.sourceNodeId).find(s=>s.localName.toLowerCase()===i);if(o){let s=Wn(o,"src")??"";if(Xn(e,{sourceNodeId:o.sourceNodeId,occurrenceId:`${r}:media:src`,sourceId:Wn(o,"id"),elementName:i,attributeName:"src",channel:"html-src",href:s,hrefNamespace:null}),i==="video"){let a=Wn(n,"data-poster")??Wn(o,"poster");a!==null&&Xn(e,{sourceNodeId:n.sourceNodeId,occurrenceId:`${r}:media:poster`,sourceId:Wn(n,"id"),elementName:"video",attributeName:"poster",channel:"html-poster",href:a,hrefNamespace:null})}}return}KP(e,t,n,r)}function nB(e,t,n){let r=[];for(let i of t.occurrences){let o=e.index.element(i.correspondingSourceNodeId);if(!o||o.namespaceUri!==te)continue;let s=o.localName.toLowerCase();if(s==="image"||s==="feimage"){let a=et(o)??{value:"",namespace:"svg2"};Xn(r,{sourceNodeId:o.sourceNodeId,occurrenceId:i.occurrenceId,sourceId:E(o,"id"),elementName:s==="feimage"?"feImage":"image",attributeName:"href",channel:"svg-href",href:a.value,hrefNamespace:a.namespace})}else s==="foreignobject"&&tB(r,e,o,i.occurrenceId)}for(let i of n.stylesheets)i.applicable&&Ji(r,i.authoredText,{sourceNodeId:i.sourceNodeId,occurrenceId:`style:${i.sourceNodeId}`,sourceId:i.id,elementName:"style",attributeName:"textContent"},new Set(["css-import"]),o=>Vp(o.url)?.hostname!=="fonts.googleapis.com");for(let i of n.elements){let o=e.index.element(i.correspondingSourceNodeId);if(!(!o||o.namespaceUri!==te))for(let s of Object.values(i.cascadedValues))Ji(r,s.value,{sourceNodeId:s.sourceNodeId,occurrenceId:`style:${i.occurrenceId}:${s.propertyName}`,sourceId:null,elementName:"style-declaration",attributeName:s.propertyName})}return Object.freeze(r)}function WP(e,t,n){let r=[...new Set(e.filter(d=>d.origin==="google-font-import"||d.origin==="boxy-fonts").map(d=>d.family))].sort(),i=[],o=new Set;for(let d of e){if(d.origin!=="external-font-face"||!d.url)continue;let u=`${d.family}\0${d.url}\0${d.format??""}\0${JSON.stringify(d.descriptors??{})}`;o.has(u)||(o.add(u),i.push(Object.freeze({family:d.family,url:d.url,format:d.format??null,...d.descriptors?{descriptors:d.descriptors}:{}})))}i.sort((d,u)=>d.family.localeCompare(u.family)||d.url.localeCompare(u.url)||(d.format??"").localeCompare(u.format??""));let s=[...new Set([...r,...i.map(d=>d.family)])].sort(),a=[...new Set(t.filter(d=>d.status==="external"&&d.requestUrl).map(d=>d.requestUrl))].sort(),c=[];s.length>0&&c.push(Object.freeze({kind:"font-consent",families:s,googleFamilies:r,...i.length>0?{externalSources:i}:{}})),a.length>0&&c.push(Object.freeze({kind:"external-asset-resolution",urls:a})),Object.freeze(s),Object.freeze(r),Object.freeze(i),Object.freeze(a),Object.freeze(c);let l=Object.freeze({fontCandidates:e,assetCandidates:t,effects:c});return Object.freeze({value:l,diagnostics:n})}function Gp(e,t,n,r,i){return WP(eB(e,n,r),nB(e,t,n),Object.freeze([]))}function rB(e){let t=e.state,n=t.extra;return typeof n=="object"&&n!==null&&!Array.isArray(n)?{...n,...t}:t}function Tb(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Rb(e,t,n){for(let r of HP(t))e.push(Object.freeze({sourceNodeId:n,occurrenceId:null,origin:"google-font-import",family:r}));for(let r of kb(t))e.push(Object.freeze({sourceNodeId:n,occurrenceId:null,origin:"external-font-face",family:r.family,url:r.url,format:r.format,...r.descriptors?{descriptors:r.descriptors}:{}}))}function XP(e,t,n,r){Rb(e,n,r),Ji(t,n,{sourceNodeId:r,occurrenceId:r,sourceId:null,elementName:"style",attributeName:"textContent"},void 0,o=>Vp(o.url)?.hostname!=="fonts.googleapis.com");let i=new Set(kb(n).map(o=>o.url));for(let o=t.length-1;o>=0;o--){let s=t[o];s.sourceNodeId===r&&i.has(s.requestUrl??"")&&t.splice(o,1)}}function iB(e,t,n,r){let i=[],o=c=>{c.kind==="element"&&(i.push(c),c.children.forEach(o))};n.forEach(o);let s=(c,l)=>c.attributes.find(d=>d.namespaceUri===null&&d.localName.toLowerCase()===l)?.value??null,a=c=>c.children.flatMap(l=>l.kind==="text"||l.kind==="cdata"?[l.value]:[]).join("");for(let[c,l]of i.entries()){let d=l.localName.toLowerCase(),u=s(l,"id"),f={sourceNodeId:`${r}:foreign:${c}`,occurrenceId:`${r}:foreign:${c}`,sourceId:u,elementName:l.localName},p=[{attributeName:"src",channel:"html-src",applies:["img","video","audio","source","track","iframe","embed"].includes(d)||d==="input"&&s(l,"type")?.toLowerCase()==="image"},{attributeName:"poster",channel:"html-poster",applies:d==="video"},{attributeName:"data",channel:"html-data",applies:d==="object"},{attributeName:"href",channel:"html-src",applies:d==="link"&&(s(l,"rel")??"").split(/\s+/u).some(h=>h.toLowerCase()==="stylesheet")}];for(let h of p){if(!h.applies)continue;let y=s(l,h.attributeName);y!==null&&Xn(t,{...f,occurrenceId:`${f.occurrenceId}:${h.attributeName}`,attributeName:h.attributeName,channel:h.channel,href:y,hrefNamespace:null})}let m=s(l,"srcset");if(m!==null&&(d==="img"||d==="source"))for(let[h,y]of UP(m).entries())Xn(t,{...f,occurrenceId:`${f.occurrenceId}:srcset:${h}`,attributeName:"srcset",channel:"html-srcset",href:y,hrefNamespace:null});let g=s(l,"style");if(g!==null&&Ji(t,g,{...f,attributeName:"style"}),d==="style"){let h=a(l);Rb(e,h,f.sourceNodeId),Ji(t,h,{...f,attributeName:"textContent"})}}}function Cb(e,t,n,r){Ji(e,t,{sourceNodeId:n,occurrenceId:`${n}:${r}`,sourceId:null,elementName:"canonical-state",attributeName:r})}function Pl(e,t,n){if(Tb(t))for(let[r,i]of Object.entries(t))typeof i=="string"&&Cb(e,i,n,r)}function Ab(e,t,n,r,i,o){if(Array.isArray(n))for(let[s,a]of n.entries()){if(!Tb(a))continue;let c=`${r}:filter:${s}`;a.type==="feImage"&&Xn(t,{sourceNodeId:r,occurrenceId:c,sourceId:null,elementName:"feImage",attributeName:"href",channel:"canonical-state",href:typeof a.href=="string"?a.href:typeof a.xlinkHref=="string"?a.xlinkHref:"",hrefNamespace:typeof a.href=="string"?"svg2":"xlink"}),a.type==="raw-svg"&&typeof a.svgContent=="string"&&Rl(e,t,a.svgContent,`${c}:raw`,i,o),Ab(e,t,a.primitives,`${c}:primitives`,i,o)}}function Sb(e,t,n,r,i,o){!Tb(n)||typeof n.svgContent!="string"||Rl(e,t,n.svgContent,r,i,o)}function oB(e,t,n,r,i,o){let s=rB(n),a=`snapshot:${r}:${n.id}`;if(n.type==="text"){let c=d=>{let u=wb(d);u&&e.push(Object.freeze({sourceNodeId:a,occurrenceId:a,origin:"text-font-family",family:u}))};c(s.fontFamily);let l=Si(s);if(l){c(l.baseStyle.fontFamily);for(let d of l.runs)c(d.style.fontFamily)}}n.type==="image"?Xn(t,{sourceNodeId:a,occurrenceId:a,sourceId:n.id,elementName:"image",attributeName:"href",channel:"canonical-state",href:typeof s.href=="string"?s.href:"",hrefNamespace:null}):n.type==="video"||n.type==="audio"?(Xn(t,{sourceNodeId:a,occurrenceId:`${a}:src`,sourceId:n.id,elementName:n.type,attributeName:"href",channel:"canonical-state",href:typeof s.href=="string"?s.href:"",hrefNamespace:null}),n.type==="video"&&typeof s.posterHref=="string"&&Xn(t,{sourceNodeId:a,occurrenceId:`${a}:poster`,sourceId:n.id,elementName:"video",attributeName:"posterHref",channel:"canonical-state",href:s.posterHref,hrefNamespace:null})):n.type==="foreign-object"&&Array.isArray(s.foreignContent)&&iB(e,t,s.foreignContent,a),Sb(e,t,s.fillGradient,`${a}:fillGradient`,i,o),Sb(e,t,s.strokeGradient,`${a}:strokeGradient`,i,o),Ab(e,t,s.filters,a,i,o),Pl(t,s.authoredAttributes,`${a}:authored`),Pl(t,s.containerPresentation,`${a}:container-presentation`),Pl(t,s.instancePresentation,`${a}:instance-presentation`),Pl(t,s.cssMaskProperties,`${a}:mask`),typeof s.cssClipPath=="string"&&Cb(t,s.cssClipPath,a,"clip-path")}function Rl(e,t,n,r,i,o){let s=Rn(`<svg xmlns="${te}">${n}</svg>`,i);if(!s.value){o.push(...s.diagnostics.map(c=>Object.freeze({...c,severity:"warning",message:`Canonical raw definition could not be inspected for external requests: ${c.message}`,documentPath:r})));return}let a=new Set;for(let c of s.value.index.elements){if(c.localName.toLowerCase()!=="foreignobject")continue;let l=`${r}:${c.sourceNodeId}`;KP(t,s.value,c,l);for(let d of Pb(s.value,c.sourceNodeId))a.add(d.sourceNodeId),d.localName.toLowerCase()==="style"&&Rb(e,yb(d),`${r}:${d.sourceNodeId}`)}for(let c of s.value.index.elements){if(a.has(c.sourceNodeId))continue;let l=c.localName.toLowerCase();if(c.namespaceUri===te&&(l==="image"||l==="feimage")){let d=et(c)??{value:"",namespace:"svg2"};Xn(t,{sourceNodeId:`${r}:${c.sourceNodeId}`,occurrenceId:`${r}:${c.sourceNodeId}`,sourceId:Wn(c,"id"),elementName:l==="feimage"?"feImage":"image",attributeName:"href",channel:"canonical-state",href:d.value,hrefNamespace:d.namespace})}l==="style"&&XP(e,t,yb(c),`${r}:${c.sourceNodeId}:style`);for(let d of c.attributes)d.localName.toLowerCase()==="href"||d.localName.toLowerCase()==="src"||Cb(t,d.value,`${r}:${c.sourceNodeId}`,d.name)}}function YP(e,t){let n=[],r=[],i=[];for(let[s,a]of(e.documentStyles??[]).entries())XP(n,r,a.css,`snapshot:documentStyles[${s}]`);mt(e,{onShape:(s,a)=>oB(n,r,s,a,t,i)});for(let[s,a]of(e.library??[]).entries()){let c=`snapshot:library[${s}]`;a.kind==="pattern"?Sb(n,r,a.pattern,`${c}:pattern`,t,i):a.kind==="filter"?Ab(n,r,a.filters,`${c}:filters`,t,i):(a.kind==="symbol"||a.kind==="marker")&&Pl(r,a.rootAttributes,`${c}:root`)}let o=e.documentMetadata?.rawHtmlMetadata;typeof o=="string"&&Rl(n,r,o,"snapshot:documentMetadata.rawHtmlMetadata",t,i);for(let[s,a]of(e.paintServerDefs??[]).entries())Rl(n,r,a.markup,`snapshot:paintServerDefs[${s}]`,t,i);for(let[s,a]of(e.clipMaskGroups??[]).entries())a.rawDefinition&&Rl(n,r,a.rawDefinition,`snapshot:clipMaskGroups[${s}].rawDefinition`,t,i);return WP(Object.freeze(n),Object.freeze(r),Object.freeze(i))}function sB(e,t,n){let r=new Set,i=o=>{let s=o;for(;s;){let a=s.localName.toLowerCase();if(a==="clippath"||a==="mask")return!0;s=e.index.parent(s.sourceNodeId)}return!1};for(let o of n.css){let s=t.occurrence(o.occurrenceId);if(!s)continue;let a=e.index.element(s.correspondingSourceNodeId);a&&i(a)&&r.add(a.sourceNodeId)}return e.index.elements.filter(o=>r.has(o.sourceNodeId)).map(o=>o.sourceNodeId)}var Nb=Object.freeze({matchesMedia(e){let t=e.trim().toLowerCase();return t===""||t==="all"||t==="screen"},supportsCondition(){return!1}}),aB=new Map([["clippath","clip-path"],["marker","marker"],["mask","mask"],["pattern","pattern"]]);function cB(e){return Object.freeze(e.index.elements.flatMap(t=>{let n=aB.get(t.localName.toLowerCase());return n?[Object.freeze({sourceNodeId:t.sourceNodeId,capability:n})]:[]}))}function lB(e,t,n){let r=new Map(e.occurrences.map(i=>[i.occurrenceId,i]));return Object.freeze([...t.candidates.filter(i=>i.status==="materialized").map(i=>i.occurrenceId),...n.uses.filter(i=>["symbol-instance","linked-reference"].includes(i.status)).map(i=>i.useOccurrenceId)].filter(i=>r.get(i)?.role!=="definition"))}function Cl(e,t={}){let n={source:t.source??"svg",entrypoint:t.entrypoint??"svg-document-import"},r=Rn(e,n,t.xmlHost);if(!r.value)return Object.freeze({value:null,diagnostics:r.diagnostics});let i=r.value,o=mf(i.root,n),s=Object.freeze({width:o.value.viewBoxWidth??300,height:o.value.viewBoxHeight??150}),a=t.rootFontSize??16,c=Object.freeze({viewport:Object.freeze({x:o.value.viewBoxX??0,y:o.value.viewBoxY??0,...s}),rootFontSize:a}),l=wf(i,n),d=l.value.condition(i.root.sourceNodeId),u=lp(i,n),f=Ep(i,n),p=Tf(i,{...n,resourceRoots:cB(i),...t.maxUseDepth!==void 0?{maxDepth:t.maxUseDepth}:{},...t.maxUseOccurrences!==void 0?{maxOccurrences:t.maxUseOccurrences}:{}}),m=$f(i,p,{...n,environment:t.styleEnvironment??Nb}),g=Zs(i,p,m.value,{viewport:s,rootFontSize:a}),h=Yf(i,p,m.value,{...n,viewport:s,rootFontSize:a,viewportPlan:g,...t.textMetricsHost?{textMetricsHost:t.textMetricsHost}:{}}),y=zf(i,p,m.value,{...n,leafGeometry:h.value}),S=kf(i,{...t.claimedIds?{claimedIds:t.claimedIds}:{},cssAnimationTargetSourceNodeIds:sB(i,p,y.value)}),b=S.liveIdForSourceNodeId(i.root.sourceNodeId),I=Object.freeze({...o.value,...b?{svgId:b}:{},...d?.systemLanguage!==null&&d?.systemLanguage!==void 0?{systemLanguage:d.systemLanguage}:{},...d?.requiredExtensions!==null&&d?.requiredExtensions!==void 0?{requiredExtensions:d.requiredExtensions}:{}}),v=Op(i,S),w=Of(i,{...n,appliedDeclarations:m.value.appliedResourceDeclarations}),k=Qf(i,p,m.value,w,h.value,{...n,viewport:s,rootFontSize:a}),C=new Set;for(let H of k.value.definitions)if(H.representation==="decomposed")for(let ie of H.geometrySourceNodeIds)C.add(ie);for(let H of y.value.smil)H.motionPathSourceNodeId&&C.add(H.motionPathSourceNodeId);let P=Nf(i,p,m.value,{...n,nativeDefinitionSourceNodeIds:C,privateGeometrySourceNodeIds:new Set(h.value.privateTextPathGeometry.map(H=>H.pathSourceNodeId))}),R=ap(i,p,m.value,w,{...n,viewport:s,rootFontSize:a}),N=Jf(i,p,m.value,w,{...n,viewport:s,rootFontSize:a}),M=ep(i,p,m.value,w,{...n,viewport:s,rootFontSize:a}),A=tp(i,p,m.value,w,{...n,viewport:s,rootFontSize:a}),$=rp(i,S,n),_=hf(i,n),z=Sf(i,p,g,n),j=Df(i),G=Gp(i,p,m.value,h.value,n),W=bf(i,p,{...n,materializedOccurrenceIds:lB(p,h.value,P)}),V=[...r.diagnostics,...o.diagnostics,...l.diagnostics,...u.diagnostics,...f.diagnostics,...p.diagnostics,...m.diagnostics,...y.diagnostics,...P.diagnostics,...h.diagnostics,...w.diagnostics,...k.diagnostics,...R.diagnostics,...N.diagnostics,...M.diagnostics,...A.diagnostics,...$.diagnostics,..._.diagnostics,...z.diagnostics,...G.diagnostics,...W.diagnostics],X=Object.freeze({projectionContext:c,sourceDocument:i,rootFrame:I,identifiers:S,conditionalProcessing:l.value,scripts:u.value,metadata:f.value,documentExtensions:v,useOccurrences:p,styles:m.value,viewportContexts:g,animations:y.value,symbolUses:P,leafGeometry:h.value,resourceDependencies:w,clipMasks:k.value,filters:R.value,markers:N.value,gradients:M.value,patterns:A.value,paintServerDefinitions:$.value,views:_.value,embeddedFrames:z.value,authoredAttributes:j,externalEffects:G.value,hierarchy:W.value});return Object.freeze({value:X,diagnostics:Object.freeze(V)})}function me(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`id-${crypto.randomUUID()}`:`id-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}function la(e={}){let t={schemaVersion:Pn,shapes:e.shapes?e.shapes.map(n=>({...n})):[],viewboxes:e.viewboxes?e.viewboxes.map(n=>({...n})):[]};return e.metadata&&(t.documentMetadata={title:"",description:"",author:"",keywords:[],license:"",licenseUrl:"",language:"en",customMetadata:{},...e.metadata}),t}function qP(e){let{type:t,id:n,...r}=e,i={};for(let[o,s]of Object.entries(r))s!==void 0&&(i[o]=s);return{id:n??me(),type:t,state:i}}function Ho(e,t,n,r,i){return{id:i??me(),x:e,y:t,width:n,height:r}}var Al=class{schemas=new Map;register(t,n){this.schemas.set(t,n)}get(t){return this.schemas.get(t)}typeIds(){return[...this.schemas.keys()]}getDefaults(t){let n=this.schemas.get(t);if(!n)return{};let r={};for(let i of Object.keys(n))r[i]=n[i].default;return r}validate(t,n,r){let i=this.schemas.get(t);if(!i)return r;let o=i[n];return o?.validate?o.validate(r):r}},Ee=e=>Math.max(0,e),da=e=>Math.max(0,Math.min(1,e)),Ft=e=>Math.max(0,Math.min(100,e)),dB=e=>Math.max(1,e),uB=e=>Math.max(3,Math.min(100,Math.floor(e))),fB=e=>Math.max(3,Math.min(50,Math.floor(e))),pB=e=>Math.max(3,Math.min(30,Math.floor(e))),mB=e=>Math.max(1,Math.min(10,e)),gB=e=>!e||typeof e!="object"||Array.isArray(e)||e.kind!=="shape"&&e.kind!=="definition"||typeof e.targetId!="string"||e.targetId.length===0||e.element!=="href"&&e.element!=="mpath"?null:{kind:e.kind,targetId:e.targetId,element:e.element};function hB(e){return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,{default:n}]))}var yB=hB(Yh),bt={layerName:{default:null},fillColor:{default:"#ffffff"},borderColor:{default:"#000000"},borderWidth:{default:1},opacity:{default:1,validate:da},fillOpacity:{default:1,validate:da},strokeOpacity:{default:1,validate:da},...yB,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:dB},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}},fr={...bt,cx:{default:0},cy:{default:0},radius:{default:50,validate:Ee},cornerRadius:{default:0,validate:Ee},shiftAngle:{default:0}},ua={...bt,x:{default:0},y:{default:0},width:{default:100,validate:Ee},height:{default:60,validate:Ee}},ZP={...bt,x:{default:0},y:{default:0},width:{default:0,validate:Ee},height:{default:0,validate:Ee},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:da},muted:{default:!1},loop:{default:!1},playbackRate:{default:1},mediaOpacity:{default:1,validate:da},fadeInDuration:{default:0,validate:Ee},fadeOutDuration:{default:0,validate:Ee},posterHref:{default:""},sourceRect:{default:null}},Pe=new Al;Pe.register("rectangle",{...bt,x:{default:0},y:{default:0},width:{default:100,validate:Ee},height:{default:100,validate:Ee},rx:{default:0,validate:Ee},ry:{default:0,validate:Ee},cornerRadius:{default:0,validate:Ee},cornerShape:{default:"round"},cornerMode:{default:"uniform"},cornerRadiusTL:{default:0,validate:Ee},cornerRadiusTR:{default:0,validate:Ee},cornerRadiusBL:{default:0,validate:Ee},cornerRadiusBR:{default:0,validate:Ee},cornerShapeTL:{default:"round"},cornerShapeTR:{default:"round"},cornerShapeBL:{default:"round"},cornerShapeBR:{default:"round"}});Pe.register("square",{...bt,x:{default:0},y:{default:0},size:{default:100,validate:Ee},width:{default:100,validate:Ee},height:{default:100,validate:Ee},rx:{default:0,validate:Ee},ry:{default:0,validate:Ee},cornerRadius:{default:0,validate:Ee},cornerShape:{default:"round"},cornerMode:{default:"uniform"},cornerRadiusTL:{default:0,validate:Ee},cornerRadiusTR:{default:0,validate:Ee},cornerRadiusBL:{default:0,validate:Ee},cornerRadiusBR:{default:0,validate:Ee},cornerShapeTL:{default:"round"},cornerShapeTR:{default:"round"},cornerShapeBL:{default:"round"},cornerShapeBR:{default:"round"}});Pe.register("circle",{...bt,x:{default:0},y:{default:0},radius:{default:50,validate:Ee}});Pe.register("ellipse",{...bt,x:{default:0},y:{default:0},rx:{default:50,validate:Ee},ry:{default:30,validate:Ee}});Pe.register("line",{...bt,fillType:{default:"none"},x1:{default:0},y1:{default:0},x2:{default:100},y2:{default:0},startEndpoint:{default:"none"},endEndpoint:{default:"none"}});Pe.register("text",{...bt,x:{default:0},y:{default:0},width:{default:0,validate:Ee},height:{default:0,validate:Ee},textX:{default:0},textY:{default:0},fontSize:{default:24},text:{default:""},fontFamily:{default:"Arial"},fontWeight:{default:"normal"},fontStyle:{default:"normal"},fontStretch:{default:"normal"},fontSizeAdjust:{default:"none"},fontVariant:{default:""},fontVariantLigatures:{default:""},fontVariantPosition:{default:""},fontVariantCaps:{default:""},fontVariantNumeric:{default:""},fontVariantEastAsian:{default:""},textDecoration:{default:{}},textTransform:{default:"none"},baselineShift:{default:"baseline"},dominantBaseline:{default:"auto"},alignmentBaseline:{default:"auto"},writingMode:{default:"horizontal-tb"},textAnchor:{default:"start"},letterSpacing:{default:0},wordSpacing:{default:0},lineHeight:{default:1.2},inlineSize:{default:0},overflowWrap:{default:"normal"},whiteSpace:{default:"pre-wrap"},textDirection:{default:"ltr"},unicodeBidi:{default:"normal"},scaleX:{default:1},scaleY:{default:1},scaleAnchor:{default:null},useRichText:{default:!1},richTextRuns:{default:null},charOffsets:{default:null},fontVariationSettings:{default:{}},isTextPath:{default:!1},textPathPoints:{default:null},textPathStartOffset:{default:0},textPathSide:{default:"left"},textPathReference:{default:null,validate:gB},shapeInsideRef:{default:null},shapePadding:{default:0}});Pe.register("image",{...bt,x:{default:0},y:{default:0},width:{default:100,validate:Ee},height:{default:100,validate:Ee},href:{default:""},originalWidth:{default:0},originalHeight:{default:0},preserveAspectRatio:{default:!0},imageOpacity:{default:1,validate:da}});Pe.register("path",{...bt,x:{default:0},y:{default:0},width:{default:0,validate:Ee},height:{default:0,validate:Ee},pathPoints:{default:[]},pathArcParams:{default:[]},pathControlBounds:{default:null},startEndpoint:{default:"none"},endEndpoint:{default:"none"}});Pe.register("polyline",{...bt,x:{default:0},y:{default:0},width:{default:0,validate:Ee},height:{default:0,validate:Ee},polylinePoints:{default:[]},polylineClosed:{default:!1}});Pe.register("triangle",{...fr,sides:{default:3}});Pe.register("ngon",{...fr,sides:{default:6,validate:uB}});Pe.register("star",{...fr,arms:{default:5,validate:fB},innerRadiusPercent:{default:40,validate:Ft}});Pe.register("cross",{...fr,armWidthPercent:{default:30,validate:Ft}});Pe.register("ring",{...fr,innerRadiusPercent:{default:50,validate:Ft}});Pe.register("spiral",{...fr,turns:{default:3,validate:mB},thicknessPercent:{default:15,validate:Ft},spiralDirection:{default:1}});Pe.register("gear",{...fr,teeth:{default:8,validate:pB},toothDepthPercent:{default:25,validate:Ft},holeRadiusPercent:{default:20,validate:Ft}});Pe.register("arrow",{...fr,headWidthPercent:{default:100,validate:Ft},headLengthPercent:{default:40,validate:Ft},shaftWidthPercent:{default:40,validate:Ft}});Pe.register("symbol-instance",{...bt,x:{default:0},y:{default:0},width:{default:100,validate:Ee},height:{default:100,validate:Ee},symbolId:{default:""}});Pe.register("group",{...bt});Pe.register("container",{...bt});Pe.register("cloud",{...fr,cloudBumps:{default:5},cloudPuffinessPercent:{default:60,validate:Ft}});Pe.register("heart",{...fr,lobeRadiusPercent:{default:50,validate:Ft},cleftDepthPercent:{default:25,validate:Ft}});Pe.register("lightning",{...fr,boltSegments:{default:3},boltWidthPercent:{default:30,validate:Ft},boltJaggednessPercent:{default:40,validate:Ft}});Pe.register("speechBubble",{...fr,tailAngleDeg:{default:45},tailLengthPercent:{default:40,validate:Ft},tailWidthPercent:{default:25,validate:Ft}});Pe.register("diamond",{...ua});Pe.register("parallelogram",{...ua,slantPercent:{default:20,validate:Ft}});Pe.register("trapezoid",{...ua,topWidthPercent:{default:70,validate:Ft}});Pe.register("terminator",{...ua});Pe.register("cylinder",{...ua,capHeightPercent:{default:15,validate:Ft}});Pe.register("document-shape",{...ua,waveAmplitudePercent:{default:15,validate:Ft}});Pe.register("hyperlink",{...bt,href:{default:""},hrefXlink:{default:""},linkTarget:{default:""},linkPing:{default:""},linkRel:{default:""},linkHreflang:{default:""},linkType:{default:""},linkReferrerPolicy:{default:""}});Pe.register("switch",{...bt,switchSystemLanguage:{default:null},switchRequiredExtensions:{default:null}});Pe.register("svg",{...bt});Pe.register("view",{...bt,viewBoxX:{default:0},viewBoxY:{default:0},viewBoxWidth:{default:0,validate:Ee},viewBoxHeight:{default:0,validate:Ee},viewName:{default:""},viewPreserveAspectRatio:{default:""},viewTarget:{default:""}});Pe.register("shape-reference",{...bt,targetShapeId:{default:""},offsetX:{default:0},offsetY:{default:0},targetWidth:{default:0,validate:Ee},targetHeight:{default:0,validate:Ee},broken:{default:!1}});Pe.register("foreign-object",{...bt,x:{default:0},y:{default:0},width:{default:0,validate:Ee},height:{default:0,validate:Ee},foreignContent:{default:[]}});Pe.register("video",{...ZP,mediaKind:{default:"video"}});Pe.register("audio",{...ZP,mediaKind:{default:"audio"}});Pe.register("document",{});function Eb(e){let t=new Set;for(let n of e??[])bn(n,{onShape:r=>{r.id&&t.add(r.id)}});return t}function pr(e){let t=Eb(e.shapes),n=new Map;for(let i of e.library??[]){let o=new Set([i.id]);if(i.kind==="symbol"||i.kind==="marker")for(let s of Eb(i.shapes))o.add(s);if(i.kind==="symbol")for(let s of Object.values(i.variants??{}))for(let a of Eb(s))o.add(a);for(let s of o){let a=n.get(s)??new Set;a.add(i.id),n.set(s,a)}}let r=new Map;for(let[i,o]of n)r.set(i,Object.freeze([...o].sort()));return{documentParentIds:t,definitionIdsByParentId:r,resolve(i){if(i.parentDefinitionId!==void 0)return(r.get(i.parentId)??[]).includes(i.parentDefinitionId)?{kind:"library",definitionId:i.parentDefinitionId}:{kind:"missing"};if(t.has(i.parentId))return{kind:"document"};let o=r.get(i.parentId)??[];return o.length===1?{kind:"library",definitionId:o[0]}:o.length>1?{kind:"ambiguous",definitionIds:o}:{kind:"missing"}}}}var SB;function bB(){return SB??=new Set([...Pe.typeIds().filter(e=>e!=="document"),"spline"])}function to(e){let t=[],n=[];if(e==null||typeof e!="object")return t.push({path:"",message:"Snapshot must be a non-null object",severity:"error"}),{valid:!1,errors:t,warnings:n};let r=e;for(let o of Object.keys(r))o in an||n.push({path:o,message:`Unknown top-level field "${o}" (likely written by a newer version); it is preserved in the unknownFields quarantine on save`,severity:"warning"});let i={doc:r,errors:t,warnings:n};for(let o of Object.keys(an)){let s=r[o];s===void 0&&!an[o].required||NB[o](s,i)}return IB(r,t),{valid:t.length===0,errors:t,warnings:n}}function de(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function vB(e){let t=new Map,n=r=>{if(Array.isArray(r)){for(let i of r)if(!(!de(i)||!de(i.state))){if(typeof i.id=="string"&&i.type==="text"){let o=new Map,s=i.state.textSpanTree,a=c=>{if(Array.isArray(c))for(let l of c)de(l)&&(typeof l.spanId=="string"&&l.spanId.length>0&&o.set(l.spanId,{start:l.start,end:l.end}),a(l.children))};de(s)&&a(s.spans),t.set(i.id,o)}n(i.state.children)}}};return n(e),t}function Ut(e,t,n){return Array.isArray(e)?!0:(n.push({path:t,message:`${t} must be an array`,severity:"error"}),!1)}function fa(e,t,n){e!==void 0&&(typeof e!="number"||!Number.isInteger(e)||e<0)&&n.push({path:t,message:"Definition order must be a non-negative integer",severity:"error"})}function pa(e,t,n){e!==void 0&&(typeof e!="string"||e.length===0)&&n.push({path:t,message:"Definition container id must be a non-empty string",severity:"error"})}function xB(e,t,n,r){if(e===void 0||!Ut(e,t,r))return;let i=new Set;e.forEach((o,s)=>{let a=`${t}[${s}]`;if(!de(o)){r.push({path:a,message:"Animation track must be an object",severity:"error"});return}if(typeof o.id!="string"||o.id.length===0?r.push({path:`${a}.id`,message:"Animation track id must be a non-empty string",severity:"error"}):i.has(o.id)?r.push({path:`${a}.id`,message:`Duplicate animation track id: "${o.id}"`,severity:"error"}):i.add(o.id),(typeof o.shapeId!="string"||!n.has(o.shapeId))&&r.push({path:`${a}.shapeId`,message:"Definition animation must target a shape owned by the definition",severity:"error"}),!Array.isArray(o.keyframes)){r.push({path:`${a}.keyframes`,message:"Animation track keyframes must be an array",severity:"error"});return}let c=new Set;o.keyframes.forEach((l,d)=>{let u=`${a}.keyframes[${d}].id`;!de(l)||typeof l.id!="string"||!l.id?r.push({path:u,message:"Animation keyframe id must be a non-empty string",severity:"error"}):c.has(l.id)?r.push({path:u,message:`Duplicate animation keyframe id: "${l.id}"`,severity:"error"}):c.add(l.id)})})}function IB(e,t){let n=new Set(Array.isArray(e.definitionContainers)?e.definitionContainers.flatMap(s=>de(s)&&typeof s.id=="string"?[s.id]:[]):[]),r=(s,a)=>{!de(s)||s.definitionContainerId===void 0||typeof s.definitionContainerId!="string"||s.definitionContainerId.length===0||n.has(s.definitionContainerId)||t.push({path:`${a}.definitionContainerId`,message:`Definition container "${s.definitionContainerId}" does not exist`,severity:"error"})};for(let[s,a]of[["documentExtensions",e.documentExtensions],["documentStyles",e.documentStyles],["library",e.library],["paintServerDefs",e.paintServerDefs],["clipMaskGroups",e.clipMaskGroups]])Array.isArray(a)&&a.forEach((c,l)=>r(c,`${s}[${l}]`));de(e.animationTimeline)&&Array.isArray(e.animationTimeline.tracks)&&e.animationTimeline.tracks.forEach((s,a)=>{if(!de(s)||s.sourceSmilDefinitionContainerId===void 0)return;let c=s.sourceSmilDefinitionContainerId;typeof c!="string"||c.length===0||n.has(c)||t.push({path:`animationTimeline.tracks[${a}].sourceSmilDefinitionContainerId`,message:`Definition container "${c}" does not exist`,severity:"error"})});let i=new Set(Array.isArray(e.library)?e.library.flatMap(s=>de(s)&&typeof s.id=="string"?[s.id]:[]):[]);Array.isArray(e.documentStyles)&&e.documentStyles.forEach((s,a)=>{!de(s)||s.scopeDefinitionId===void 0||typeof s.scopeDefinitionId!="string"||s.scopeDefinitionId.length===0||i.has(s.scopeDefinitionId)||t.push({path:`documentStyles[${a}].scopeDefinitionId`,message:`Scoped definition "${s.scopeDefinitionId}" does not exist`,severity:"error"})});let o=(s,a)=>{Array.isArray(s)&&s.forEach((c,l)=>{let d=`${a}[${l}]`;!de(c)||!de(c.state)||(r(c.state,`${d}.state`),o(c.state.children,`${d}.state.children`))})};o(e.shapes,"shapes"),Array.isArray(e.library)&&e.library.forEach((s,a)=>{de(s)&&o(s.shapes,`library[${a}].shapes`)})}var wB=new Set(["text","comment","cdata","processing-instruction"]);function eT(e,t,n){if(!de(e)){n.push({path:t,message:"Document extension attribute must be a plain object",severity:"error"});return}for(let r of["name","localName","value"])typeof e[r]!="string"&&n.push({path:`${t}.${r}`,message:`${r} must be a string`,severity:"error"});for(let r of["prefix","namespaceUri"])e[r]!==null&&typeof e[r]!="string"&&n.push({path:`${t}.${r}`,message:`${r} must be a string or null`,severity:"error"})}function tT(e,t,n){let r=[{node:e,path:t,depth:0}];for(;r.length>0;){let i=r.pop();if(i.depth>64){n.push({path:i.path,message:"Document extension nesting exceeds 64 levels",severity:"error"});continue}if(!de(i.node)){n.push({path:i.path,message:"Document extension node must be a plain object",severity:"error"});continue}let o=i.node;if(o.kind==="element"){for(let s of["name","localName"])(typeof o[s]!="string"||o[s].length===0)&&n.push({path:`${i.path}.${s}`,message:`${s} must be a non-empty string`,severity:"error"});for(let s of["prefix","namespaceUri"])o[s]!==null&&typeof o[s]!="string"&&n.push({path:`${i.path}.${s}`,message:`${s} must be a string or null`,severity:"error"});Ut(o.attributes,`${i.path}.attributes`,n)&&o.attributes.forEach((s,a)=>eT(s,`${i.path}.attributes[${a}]`,n)),Ut(o.children,`${i.path}.children`,n)&&o.children.forEach((s,a)=>r.push({node:s,path:`${i.path}.children[${a}]`,depth:i.depth+1}));continue}wB.has(String(o.kind))||n.push({path:`${i.path}.kind`,message:"Unsupported document extension node kind",severity:"error"}),typeof o.value!="string"&&n.push({path:`${i.path}.value`,message:"Document extension character value must be a string",severity:"error"})}}function kB(e,t,n,r){if(!de(e)){n.push({path:t,message:"Document extension must be a plain object",severity:"error"});return}typeof e.id!="string"||e.id.length===0?n.push({path:`${t}.id`,message:"Document extension id must be a non-empty string",severity:"error"}):r.has(e.id)?n.push({path:`${t}.id`,message:`Duplicate document extension id: "${e.id}"`,severity:"error"}):r.add(e.id),e.placement!=="root"&&e.placement!=="defs"&&n.push({path:`${t}.placement`,message:"Document extension placement must be root or defs",severity:"error"}),(typeof e.order!="number"||!Number.isInteger(e.order)||e.order<0)&&n.push({path:`${t}.order`,message:"Document extension order must be a non-negative integer",severity:"error"}),fa(e.definitionOrder,`${t}.definitionOrder`,n),pa(e.definitionContainerId,`${t}.definitionContainerId`,n),tT(e.element,`${t}.element`,n)}var PB=new Set(["x1","y1","x2","y2","gradientTransform"]),TB=new Set(["cx","cy","fx","fy","r","fr","gradientTransform"]),RB=new Set(["x","y","width","height"]);function Cn(e,t,n){e.push({path:t,message:n,severity:"error"})}function CB(e,t,n,r){if(!de(e)){Cn(r,t,"Gradient must be a plain object");return}if(e.templateId!==void 0&&typeof e.templateId!="string"&&Cn(r,`${t}.templateId`,"templateId must be a string"),e.rootAttributes!==void 0)if(!de(e.rootAttributes))Cn(r,`${t}.rootAttributes`,"Gradient rootAttributes must be a plain object");else for(let[o,s]of Object.entries(e.rootAttributes))vi(o)||Cn(r,`${t}.rootAttributes.${o}`,"Gradient root attributes must be safe non-typed attributes"),typeof s!="string"&&Cn(r,`${t}.rootAttributes.${o}`,"Gradient root attribute values must be strings");let i=n==="linear-gradient"?["x1","y1","x2","y2","opacity"]:["cx","cy","fx","fy","r","ry","rotation","opacity"];for(let o of i)e[o]!==void 0&&(typeof e[o]!="number"||!Number.isFinite(e[o]))&&Cn(r,`${t}.${o}`,`${o} must be a finite number`);if(e.fr!==void 0&&(typeof e.fr!="number"||!Number.isFinite(e.fr))&&Cn(r,`${t}.fr`,"fr must be a finite number"),e.authoredGeometry!==void 0)if(!de(e.authoredGeometry))Cn(r,`${t}.authoredGeometry`,"Gradient authoredGeometry must be a plain object");else{let o=n==="linear-gradient"?PB:TB;for(let[s,a]of Object.entries(e.authoredGeometry))o.has(s)?typeof a!="string"&&Cn(r,`${t}.authoredGeometry.${s}`,"Authored gradient geometry declarations must be strings"):Cn(r,`${t}.authoredGeometry.${s}`,"is not a supported authored gradient geometry field")}e.gradientTransform!==void 0&&(!Array.isArray(e.gradientTransform)||e.gradientTransform.length!==6||!e.gradientTransform.every(o=>typeof o=="number"&&Number.isFinite(o)))&&Cn(r,`${t}.gradientTransform`,"gradientTransform must be a 6-element finite affine matrix"),Array.isArray(e.stops)?e.stops.forEach((o,s)=>{if(!de(o)){Cn(r,`${t}.stops[${s}]`,"Gradient stop must be an object");return}o.id!==void 0&&(typeof o.id!="string"||o.id.length===0)&&Cn(r,`${t}.stops[${s}].id`,"id must be a nonempty string");for(let a of["offset","opacity"])o[a]!==void 0&&(typeof o[a]!="number"||!Number.isFinite(o[a]))&&Cn(r,`${t}.stops[${s}].${a}`,`${a} must be a finite number`)}):Cn(r,`${t}.stops`,"Gradient stops must be an array")}function AB(e,t,n){if(!de(e)){n.push({path:t,message:"Pattern must be a plain object",severity:"error"});return}if(e.templateId!==void 0&&typeof e.templateId!="string"&&n.push({path:`${t}.templateId`,message:"templateId must be a string",severity:"error"}),e.rootAttributes!==void 0)if(!de(e.rootAttributes))n.push({path:`${t}.rootAttributes`,message:"Pattern rootAttributes must be a plain object",severity:"error"});else for(let[r,i]of Object.entries(e.rootAttributes))xi(r)||n.push({path:`${t}.rootAttributes.${r}`,message:"Pattern root attributes must be safe non-typed attributes",severity:"error"}),typeof i!="string"&&n.push({path:`${t}.rootAttributes.${r}`,message:"Pattern root attribute values must be strings",severity:"error"});for(let r of["x","y","width","height","scale","rotation","opacity"])e[r]!==void 0&&(typeof e[r]!="number"||!Number.isFinite(e[r]))&&n.push({path:`${t}.${r}`,message:`${r} must be a finite number`,severity:"error"});e.patternUnits!==void 0&&e.patternUnits!=="userSpaceOnUse"&&e.patternUnits!=="objectBoundingBox"&&n.push({path:`${t}.patternUnits`,message:"patternUnits must be userSpaceOnUse or objectBoundingBox",severity:"error"}),e.patternContentUnits!==void 0&&e.patternContentUnits!=="userSpaceOnUse"&&e.patternContentUnits!=="objectBoundingBox"&&n.push({path:`${t}.patternContentUnits`,message:"patternContentUnits must be userSpaceOnUse or objectBoundingBox",severity:"error"});for(let r of["svgContent","patternTransform","viewBox","preserveAspectRatio"])e[r]!==void 0&&typeof e[r]!="string"&&n.push({path:`${t}.${r}`,message:`${r} must be a string`,severity:"error"});if(e.authoredGeometry!==void 0)if(!de(e.authoredGeometry))n.push({path:`${t}.authoredGeometry`,message:"Pattern authoredGeometry must be a plain object",severity:"error"});else for(let[r,i]of Object.entries(e.authoredGeometry))RB.has(r)?typeof i!="string"&&n.push({path:`${t}.authoredGeometry.${r}`,message:"Authored pattern geometry declarations must be strings",severity:"error"}):n.push({path:`${t}.authoredGeometry.${r}`,message:"is not a supported authored pattern geometry field",severity:"error"})}var NB={schemaVersion:(e,{errors:t,warnings:n})=>{typeof e!="number"||!Number.isInteger(e)?t.push({path:"schemaVersion",message:"schemaVersion must be an integer",severity:"error"}):e>Pn&&n.push({path:"schemaVersion",message:`schemaVersion ${e} is newer than supported (${Pn})`,severity:"warning"})},shapes:(e,{errors:t,warnings:n})=>{if(!Ut(e,"shapes",t))return;let r=new Set;e.forEach((i,o)=>{Db(i,`shapes[${o}]`,t,n,r)})},viewboxes:(e,{errors:t})=>{if(!Ut(e,"viewboxes",t))return;let n=new Set;e.forEach((r,i)=>{LB(r,`viewboxes[${i}]`,t,n)})},guides:(e,{errors:t})=>{Ut(e,"guides",t)&&e.forEach((n,r)=>{_B(n,`guides[${r}]`,t)})},measurements:(e,{errors:t})=>{Ut(e,"measurements",t)&&e.forEach((n,r)=>{let i=`measurements[${r}]`;if(!de(n)){t.push({path:i,message:"Measurement must be a non-null object",severity:"error"});return}(typeof n.id!="string"||n.id.length===0)&&t.push({path:`${i}.id`,message:"Measurement id must be a non-empty string",severity:"error"})})},sceneTree:(e,{doc:t,errors:n,warnings:r})=>{if(!Ut(e,"sceneTree",n))return;let i=Ob(t.shapes),o=new Set;e.forEach((s,a)=>{EB(s,`sceneTree[${a}]`,n,r,i,o)})},clipMaskGroups:(e,{doc:t,errors:n,warnings:r})=>{if(!Ut(e,"clipMaskGroups",n))return;let i=Ob(t.shapes),o=pr(t);e.forEach((s,a)=>{BB(s,`clipMaskGroups[${a}]`,n,r,i,o)})},documentMetadata:(e,{errors:t})=>{de(e)||t.push({path:"documentMetadata",message:"documentMetadata must be a plain object",severity:"error"})},documentExtensions:(e,{errors:t})=>{if(!Ut(e,"documentExtensions",t))return;let n=new Set;e.forEach((r,i)=>kB(r,`documentExtensions[${i}]`,t,n))},definitionContainers:(e,{doc:t,errors:n})=>{if(!Ut(e,"definitionContainers",n))return;let r=new Set,i=new Set,o=pr(t);e.forEach((s,a)=>{let c=`definitionContainers[${a}]`;if(!de(s)){n.push({path:c,message:"Definition container must be a plain object",severity:"error"});return}typeof s.id!="string"||s.id.length===0?n.push({path:`${c}.id`,message:"Definition container id must be a non-empty string",severity:"error"}):r.has(s.id)?n.push({path:`${c}.id`,message:`Duplicate definition container id: "${s.id}"`,severity:"error"}):r.add(s.id),s.svgId!==void 0&&(typeof s.svgId!="string"||s.svgId.length===0)&&n.push({path:`${c}.svgId`,message:"Definition container svgId must be a non-empty string",severity:"error"}),typeof s.order!="number"||!Number.isInteger(s.order)||s.order<0?n.push({path:`${c}.order`,message:"Definition container order must be a non-negative integer",severity:"error"}):i.has(s.order)?n.push({path:`${c}.order`,message:`Duplicate definition container order: ${s.order}`,severity:"error"}):i.add(s.order),Nl(s.authoredPlacement,`${c}.authoredPlacement`,n,o,"Definition container"),s.attributes!==void 0&&Ut(s.attributes,`${c}.attributes`,n)&&s.attributes.forEach((l,d)=>{let u=`${c}.attributes[${d}]`;eT(l,u,n),de(l)&&l.localName==="id"&&l.namespaceUri===null&&n.push({path:u,message:"Definition container attributes must not duplicate svgId authority",severity:"error"})})})},documentScripts:(e,{errors:t})=>{Ut(e,"documentScripts",t)&&e.forEach((n,r)=>{let i=`documentScripts[${r}]`;if(!de(n)){t.push({path:i,message:"Document script must be a non-null object",severity:"error"});return}(typeof n.id!="string"||n.id.length===0)&&t.push({path:`${i}.id`,message:"Document script id must be a non-empty string",severity:"error"})})},documentStyles:(e,{doc:t,errors:n})=>{if(!Ut(e,"documentStyles",n))return;let r=pr(t);e.forEach((i,o)=>{let s=`documentStyles[${o}]`;if(!de(i)){n.push({path:s,message:"Document style must be a non-null object",severity:"error"});return}(typeof i.id!="string"||i.id.length===0)&&n.push({path:`${s}.id`,message:"Document style id must be a non-empty string",severity:"error"}),typeof i.css!="string"&&n.push({path:`${s}.css`,message:"Document style css must be a string",severity:"error"}),i.placement!=="root"&&i.placement!=="defs"&&n.push({path:`${s}.placement`,message:'Document style placement must be "root" or "defs"',severity:"error"}),fa(i.definitionOrder,`${s}.definitionOrder`,n),pa(i.definitionContainerId,`${s}.definitionContainerId`,n),Nl(i.authoredPlacement,`${s}.authoredPlacement`,n,r,"Document style"),i.scopeDefinitionId!==void 0&&(typeof i.scopeDefinitionId!="string"||i.scopeDefinitionId.length===0)&&n.push({path:`${s}.scopeDefinitionId`,message:"Document style scopeDefinitionId must be a non-empty string",severity:"error"}),i.scopeDefinitionId!==void 0&&i.placement!=="defs"&&n.push({path:`${s}.scopeDefinitionId`,message:"A definition-scoped document style must use defs placement",severity:"error"})})},templateVariables:(e,{errors:t})=>{Ut(e,"templateVariables",t)&&e.forEach((n,r)=>{let i=`templateVariables[${r}]`;if(!de(n)){t.push({path:i,message:"Template variable must be a non-null object",severity:"error"});return}(typeof n.name!="string"||n.name.length===0)&&t.push({path:`${i}.name`,message:"Template variable name must be a non-empty string",severity:"error"})})},animationTimeline:(e,{doc:t,errors:n})=>{if(!de(e)){n.push({path:"animationTimeline",message:"animationTimeline must be a plain object",severity:"error"});return}if(e.tracks!==void 0&&!Array.isArray(e.tracks)){n.push({path:"animationTimeline.tracks",message:"animationTimeline.tracks must be an array",severity:"error"});return}if(e.cssAnimationDocumentStylesFingerprint!==void 0&&(typeof e.cssAnimationDocumentStylesFingerprint!="string"||e.cssAnimationDocumentStylesFingerprint.length===0)&&n.push({path:"animationTimeline.cssAnimationDocumentStylesFingerprint",message:"CSS animation document-style fingerprint must be a non-empty string",severity:"error"}),e.cssAnimationInlineStylesFingerprint!==void 0&&(typeof e.cssAnimationInlineStylesFingerprint!="string"||e.cssAnimationInlineStylesFingerprint.length===0)&&n.push({path:"animationTimeline.cssAnimationInlineStylesFingerprint",message:"CSS animation inline-style fingerprint must be a non-empty string",severity:"error"}),e.cssAnimationSources!==void 0)if(!Array.isArray(e.cssAnimationSources))n.push({path:"animationTimeline.cssAnimationSources",message:"CSS animation sources must be an array",severity:"error"});else{let r=new Set,i=new Set;e.cssAnimationSources.forEach((o,s)=>{let a=`animationTimeline.cssAnimationSources[${s}]`;if(!de(o)){n.push({path:a,message:"CSS animation source must be an object",severity:"error"});return}if(typeof o.id!="string"||o.id.length===0?n.push({path:`${a}.id`,message:"CSS animation source id must be a non-empty string",severity:"error"}):r.has(o.id)?n.push({path:`${a}.id`,message:`Duplicate CSS animation source id: "${o.id}"`,severity:"error"}):r.add(o.id),!Array.isArray(o.trackIds)||!Array.isArray(o.trackFingerprints)){n.push({path:a,message:"CSS animation source track ids and fingerprints must be arrays",severity:"error"});return}o.trackIds.length!==o.trackFingerprints.length&&n.push({path:a,message:"CSS animation source track ids and fingerprints must have equal lengths",severity:"error"}),o.trackIds.forEach((c,l)=>{typeof c!="string"||c.length===0?n.push({path:`${a}.trackIds[${l}]`,message:"CSS animation source track id must be a non-empty string",severity:"error"}):i.has(c)?n.push({path:`${a}.trackIds[${l}]`,message:`Duplicate CSS animation source track id: "${c}"`,severity:"error"}):i.add(c)}),o.trackFingerprints.forEach((c,l)=>{(typeof c!="string"||c.length===0)&&n.push({path:`${a}.trackFingerprints[${l}]`,message:"CSS animation track fingerprint must be a non-empty string",severity:"error"})})})}if(Array.isArray(e.tracks)&&Number(t.schemaVersion)>=11){let r=vB(t.shapes);e.tracks.forEach((i,o)=>{if(!de(i)||!Array.isArray(i.keyframes))return;if(i.sourceCssAnimationId!==void 0&&(typeof i.sourceCssAnimationId!="string"||!i.sourceCssAnimationId)&&n.push({path:`animationTimeline.tracks[${o}].sourceCssAnimationId`,message:"CSS animation source id must be a non-empty string",severity:"error"}),i.definitionTarget!==void 0){let a=`animationTimeline.tracks[${o}].definitionTarget`;if(!de(i.definitionTarget))n.push({path:a,message:"must be an object",severity:"error"});else{let c=i.definitionTarget.definitionId,l=i.definitionTarget.nodeId;if((typeof c!="string"||c.length===0)&&n.push({path:`${a}.definitionId`,message:"must be a non-empty string",severity:"error"}),l!==void 0&&(typeof l!="string"||l.length===0)&&n.push({path:`${a}.nodeId`,message:"must be a non-empty string when present",severity:"error"}),typeof c=="string"&&c.length>0){let d=`definition:${c}${typeof l=="string"&&l.length>0?`/${l}`:""}`;i.shapeId!==d&&n.push({path:`animationTimeline.tracks[${o}].shapeId`,message:`definition target tracks must use ${d}`,severity:"error"})}}}if(i.simpleDuration!==void 0&&i.simpleDuration!=="indefinite"&&n.push({path:`animationTimeline.tracks[${o}].simpleDuration`,message:'SMIL simple duration must be "indefinite" when present',severity:"error"}),i.simpleDuration==="indefinite"&&i.cycleDuration!==void 0&&n.push({path:`animationTimeline.tracks[${o}].cycleDuration`,message:"Finite and indefinite SMIL simple durations are mutually exclusive",severity:"error"}),i.sourceSmilPlacement!==void 0&&i.sourceSmilPlacement!=="document"&&i.sourceSmilPlacement!=="defs"&&n.push({path:`animationTimeline.tracks[${o}].sourceSmilPlacement`,message:'SMIL source placement must be "document" or "defs" when present',severity:"error"}),i.sourceSmilParentTarget!==void 0&&i.sourceSmilParentTarget!==!0&&n.push({path:`animationTimeline.tracks[${o}].sourceSmilParentTarget`,message:"SMIL implicit parent target must be true when present",severity:"error"}),i.sourceSmilParentTarget===!0&&i.sourceSmilPlacement!=="document"&&n.push({path:`animationTimeline.tracks[${o}].sourceSmilPlacement`,message:"SMIL implicit parent target requires document placement",severity:"error"}),i.sourceSmilOrder!==void 0&&(!Number.isInteger(i.sourceSmilOrder)||Number(i.sourceSmilOrder)<0)&&n.push({path:`animationTimeline.tracks[${o}].sourceSmilOrder`,message:"SMIL source order must be a non-negative integer when present",severity:"error"}),i.sourceSmilDefinitionOrder!==void 0&&(!Number.isInteger(i.sourceSmilDefinitionOrder)||Number(i.sourceSmilDefinitionOrder)<0)&&n.push({path:`animationTimeline.tracks[${o}].sourceSmilDefinitionOrder`,message:"SMIL definition order must be a non-negative integer when present",severity:"error"}),i.sourceSmilDefinitionContainerId!==void 0&&(typeof i.sourceSmilDefinitionContainerId!="string"||i.sourceSmilDefinitionContainerId.length===0)&&n.push({path:`animationTimeline.tracks[${o}].sourceSmilDefinitionContainerId`,message:"SMIL definition container id must be a non-empty string when present",severity:"error"}),(i.sourceSmilDefinitionOrder!==void 0||i.sourceSmilDefinitionContainerId!==void 0)&&i.sourceSmilPlacement!=="defs"&&n.push({path:`animationTimeline.tracks[${o}].sourceSmilPlacement`,message:'SMIL definition placement fields require sourceSmilPlacement "defs"',severity:"error"}),i.textPathStartOffsetUnit!==void 0&&i.textPathStartOffsetUnit!=="%"&&i.textPathStartOffsetUnit!=="user"&&n.push({path:`animationTimeline.tracks[${o}].textPathStartOffsetUnit`,message:'Text path start-offset unit must be "%" or "user" when present',severity:"error"}),i.textSpanTarget!==void 0){let a=`animationTimeline.tracks[${o}].textSpanTarget`;if(!de(i.textSpanTarget))n.push({path:a,message:"Text span target must be a plain object",severity:"error"});else{let c=i.textSpanTarget;if((typeof c.attributeName!="string"||c.attributeName.length===0)&&n.push({path:`${a}.attributeName`,message:"Text span target attribute name must be a non-empty string",severity:"error"}),!Array.isArray(c.spanIds)||c.spanIds.length===0||c.spanIds.some(l=>typeof l!="string"||l.length===0)||new Set(c.spanIds).size!==c.spanIds.length)n.push({path:`${a}.spanIds`,message:"Text span target ids must be unique non-empty strings",severity:"error"});else{let l=typeof i.shapeId=="string"?r.get(i.shapeId):void 0;if(!l)n.push({path:a,message:"Text span animation must target a canonical text shape",severity:"error"});else{c.spanIds.forEach((u,f)=>{l.has(u)||n.push({path:`${a}.spanIds[${f}]`,message:`Text span animation target "${u}" does not exist on shape "${i.shapeId}"`,severity:"error"})});let d=c.spanIds.map(u=>l.get(u));if(d.every(u=>u&&typeof u.start=="number"&&Number.isInteger(u.start)&&typeof u.end=="number"&&Number.isInteger(u.end))){let u=d[0].end;d.slice(1).every(p=>{let m=p;return m.start!==u?!1:(u=m.end,!0)})||n.push({path:`${a}.spanIds`,message:"Text span animation target ids must describe one ordered contiguous range",severity:"error"})}}}}}let s=new Set;i.keyframes.forEach((a,c)=>{let l=`animationTimeline.tracks[${o}].keyframes[${c}].id`;if(!de(a)||typeof a.id!="string"||!a.id){n.push({path:l,message:"Animation keyframe id must be a non-empty string",severity:"error"});return}if(s.has(a.id)){n.push({path:l,message:`Duplicate animation keyframe id: "${a.id}"`,severity:"error"});return}s.add(a.id)})})}},library:(e,{doc:t,errors:n,warnings:r})=>{if(!Ut(e,"library",n))return;let i=new Set,o=pr(t);e.forEach((c,l)=>{let d=`library[${l}]`;if(!de(c)){n.push({path:d,message:"Library def must be a non-null object",severity:"error"});return}if(typeof c.id!="string"||c.id.length===0?n.push({path:`${d}.id`,message:"Library def id must be a non-empty string",severity:"error"}):i.has(c.id)?n.push({path:`${d}.id`,message:`Duplicate library def id: "${c.id}"`,severity:"error"}):i.add(c.id),(typeof c.kind!="string"||c.kind.length===0)&&n.push({path:`${d}.kind`,message:"Library def kind must be a non-empty string",severity:"error"}),c.definitionPlacement!==void 0&&!["defs","document"].includes(String(c.definitionPlacement))&&n.push({path:`${d}.definitionPlacement`,message:"Library definitionPlacement must be defs or document",severity:"error"}),fa(c.definitionOrder,`${d}.definitionOrder`,n),pa(c.definitionContainerId,`${d}.definitionContainerId`,n),Nl(c.authoredPlacement,`${d}.authoredPlacement`,n,o,"Library"),c.kind==="symbol"||c.kind==="marker"){let u=Ob(c.shapes);if(typeof c.id=="string"&&c.id.length>0&&u.add(c.id),xB(c.animations,`${d}.animations`,u,n),c.kind==="symbol"){let f=typeof t.schemaVersion=="number"&&t.schemaVersion>=8;if(c.defKind!==void 0&&!["symbol","group","shape"].includes(String(c.defKind))&&n.push({path:`${d}.defKind`,message:"Symbol defKind must be symbol, group, or shape",severity:"error"}),c.definitionPlacement==="document"&&(c.defKind??"symbol")!=="symbol"&&n.push({path:`${d}.definitionPlacement`,message:"Only symbol roots may use document definition placement",severity:"error"}),c.defKind==="shape"&&(!Array.isArray(c.shapes)||c.shapes.length!==1)&&n.push({path:`${d}.shapes`,message:"Native shape definitions must contain exactly one root shape",severity:"error"}),f)for(let p of["wrapperAttrs","groups","overflow"])c[p]!==void 0&&n.push({path:`${d}.${p}`,message:`Symbol ${p} is schema-v7 migration input only`,severity:"error"});for(let p of["viewBox","preserveAspectRatio","x","y","width","height","refX","refY"])c[p]!==void 0&&typeof c[p]!="string"&&n.push({path:`${d}.${p}`,message:`Symbol ${p} must be a string when present`,severity:"error"});if(c.rootAttributes!==void 0)if(!de(c.rootAttributes))n.push({path:`${d}.rootAttributes`,message:"Symbol rootAttributes must be a plain object",severity:"error"});else for(let[p,m]of Object.entries(c.rootAttributes))f&&["viewBox","preserveAspectRatio","x","y","width","height","refX","refY"].includes(p)&&n.push({path:`${d}.rootAttributes.${p}`,message:`Symbol ${p} must use its typed root field`,severity:"error"}),typeof m!="string"&&n.push({path:`${d}.rootAttributes.${p}`,message:"Symbol root attribute values must be strings",severity:"error"});if(c.definitionContentOrder!==void 0)if(!Array.isArray(c.definitionContentOrder))n.push({path:`${d}.definitionContentOrder`,message:"Symbol definitionContentOrder must be an array",severity:"error"});else{let p=new Set(Array.isArray(c.shapes)?c.shapes.filter(g=>de(g)).map(g=>g.id).filter(g=>typeof g=="string"&&g.length>0):[]),m=new Set;c.definitionContentOrder.forEach((g,h)=>{let y=`${d}.definitionContentOrder[${h}]`;if(!de(g)){n.push({path:y,message:"Definition content entry must be a plain object",severity:"error"});return}if(g.kind!=="shape"&&g.kind!=="definition"&&n.push({path:`${y}.kind`,message:"Definition content kind must be shape or definition",severity:"error"}),typeof g.id!="string"||g.id.length===0){n.push({path:`${y}.id`,message:"Definition content id must be a non-empty string",severity:"error"});return}let S=`${String(g.kind)}\0${g.id}`;m.has(S)&&n.push({path:y,message:`Duplicate definition content entry: ${String(g.kind)} "${g.id}"`,severity:"error"}),m.add(S),g.kind==="shape"&&!p.has(g.id)&&n.push({path:`${y}.id`,message:`Definition content shape "${g.id}" is not a root shape of this definition`,severity:"error"})})}}if(c.kind==="marker"){for(let f of["viewBox","preserveAspectRatio"])c[f]!==void 0&&typeof c[f]!="string"&&n.push({path:`${d}.${f}`,message:`Marker ${f} must be a string when present`,severity:"error"});if(c.authoredGeometry!==void 0)if(!de(c.authoredGeometry))n.push({path:`${d}.authoredGeometry`,message:"Marker authoredGeometry must be a plain object",severity:"error"});else for(let[f,p]of Object.entries(c.authoredGeometry))typeof p!="string"&&n.push({path:`${d}.authoredGeometry.${f}`,message:"Marker authored geometry declarations must be strings",severity:"error"});if(c.rootAttributes!==void 0)if(!de(c.rootAttributes))n.push({path:`${d}.rootAttributes`,message:"Marker rootAttributes must be a plain object",severity:"error"});else for(let[f,p]of Object.entries(c.rootAttributes))["id","viewBox","preserveAspectRatio","refX","refY","markerWidth","markerHeight","markerUnits","orient"].includes(f)&&n.push({path:`${d}.rootAttributes.${f}`,message:`Marker ${f} must use its typed root field`,severity:"error"}),typeof p!="string"&&n.push({path:`${d}.rootAttributes.${f}`,message:"Marker root attribute values must be strings",severity:"error"})}if(Array.isArray(c.shapes)){let f=new Set;c.shapes.forEach((p,m)=>{Db(p,`${d}.shapes[${m}]`,n,r,f)})}if(c.kind==="symbol"&&de(c.variants))for(let[f,p]of Object.entries(c.variants)){if(!Array.isArray(p))continue;let m=new Set;p.forEach((g,h)=>{Db(g,`${d}.variants[${f}][${h}]`,n,r,m)})}}(c.kind==="linear-gradient"||c.kind==="radial-gradient")&&CB(c.gradient,`${d}.gradient`,c.kind,n),c.kind==="pattern"&&AB(c.pattern,`${d}.pattern`,n),c.kind==="appearance-style"&&DB(c.layers,`${d}.layers`,n)});let s=new Map;e.forEach((c,l)=>{de(c)&&c.kind==="symbol"&&typeof c.id=="string"&&c.id.length>0&&s.set(c.id,{def:c,index:l})});let a=new Map;for(let[c,{def:l,index:d}]of s)Array.isArray(l.definitionContentOrder)&&l.definitionContentOrder.forEach((u,f)=>{if(!de(u)||u.kind!=="definition"||typeof u.id!="string")return;let p=`library[${d}].definitionContentOrder[${f}].id`;if(u.id===c){n.push({path:p,message:`Symbol definition "${c}" cannot contain itself`,severity:"error"});return}if(!s.has(u.id)){n.push({path:p,message:`Nested symbol definition "${u.id}" does not exist`,severity:"error"});return}let m=a.get(u.id);if(m&&m!==c){n.push({path:p,message:`Nested symbol definition "${u.id}" already belongs to "${m}"`,severity:"error"});return}a.set(u.id,c)});for(let c of s.keys()){let l=new Set,d=c;for(;d!==void 0;){if(l.has(d)){let u=s.get(c);n.push({path:`library[${u?.index??0}].definitionContentOrder`,message:`Symbol definition forest contains a cycle through "${d}"`,severity:"error"});break}l.add(d),d=a.get(d)}}},paintServerDefs:(e,{doc:t,errors:n})=>{if(!Ut(e,"paintServerDefs",n))return;let r=new Set,i=pr(t);e.forEach((o,s)=>{$B(o,`paintServerDefs[${s}]`,n,r,i)})},colorGlyphLibrary:(e,{errors:t})=>{if(!de(e)){t.push({path:"colorGlyphLibrary",message:"colorGlyphLibrary must be a plain object",severity:"error"});return}e.version!==void 0&&!Number.isInteger(e.version)&&t.push({path:"colorGlyphLibrary.version",message:"colorGlyphLibrary.version must be an integer",severity:"error"}),e.entries!==void 0&&!Array.isArray(e.entries)&&t.push({path:"colorGlyphLibrary.entries",message:"colorGlyphLibrary.entries must be an array",severity:"error"})},exportItems:(e,{errors:t})=>{Ut(e,"exportItems",t)&&e.forEach((n,r)=>{let i=`exportItems[${r}]`;if(!de(n)){t.push({path:i,message:"Export item must be a non-null object",severity:"error"});return}(typeof n.id!="string"||n.id.length===0)&&t.push({path:`${i}.id`,message:"Export item id must be a non-empty string",severity:"error"}),typeof n.filename!="string"&&t.push({path:`${i}.filename`,message:"Export item filename must be a string",severity:"error"}),typeof n.format!="string"&&t.push({path:`${i}.format`,message:"Export item format must be a string",severity:"error"})})},unknownFields:(e,{errors:t})=>{de(e)||t.push({path:"unknownFields",message:"unknownFields must be a plain object (forward-compat quarantine bag)",severity:"error"})}};function Ob(e){let t=new Set;if(!Array.isArray(e))return t;for(let n of e)bn(n,{onShape:r=>{typeof r.id=="string"&&r.id.length>0&&t.add(r.id)}});return t}function QP(e){return e.startsWith("structural:")}function EB(e,t,n,r,i,o){if(e===null||typeof e!="object"){n.push({path:t,message:"Scene tree entry must be a non-null object",severity:"error"});return}let s=e;typeof s.id!="string"||s.id.length===0?n.push({path:`${t}.id`,message:"Scene tree id must be a non-empty string",severity:"error"}):(o.has(s.id)&&n.push({path:`${t}.id`,message:`Duplicate scene tree id: "${s.id}"`,severity:"error"}),o.add(s.id),!i.has(s.id)&&!QP(s.id)&&r.push({path:`${t}.id`,message:`Scene tree id "${s.id}" is not present in shapes`,severity:"warning"})),s.parentId!==null&&typeof s.parentId!="string"?n.push({path:`${t}.parentId`,message:"Scene tree parentId must be a string or null",severity:"error"}):typeof s.parentId=="string"&&!i.has(s.parentId)&&!QP(s.parentId)&&r.push({path:`${t}.parentId`,message:`Scene tree parentId "${s.parentId}" is not present in shapes`,severity:"warning"}),(typeof s.index!="number"||!Number.isInteger(s.index)||s.index<0)&&n.push({path:`${t}.index`,message:"Scene tree index must be a non-negative integer",severity:"error"}),s.updatedAt!==void 0&&(typeof s.updatedAt!="number"||!Number.isFinite(s.updatedAt)||s.updatedAt<0)&&n.push({path:`${t}.updatedAt`,message:"Scene tree updatedAt must be a non-negative finite number",severity:"error"}),s.clientId!==void 0&&typeof s.clientId!="string"&&n.push({path:`${t}.clientId`,message:"Scene tree clientId must be a string",severity:"error"})}var OB=new Set(["mask","clipPath","filter","linearGradient","radialGradient","pattern","symbol"]);function Nl(e,t,n,r,i){if(e===void 0)return;if(!de(e)){n.push({path:t,message:`${i} authoredPlacement must be an object`,severity:"error"});return}let o=e.parentId,s=e.parentDefinitionId,a=e.siblingIndex,c=!0;if((typeof o!="string"||o.length===0)&&(n.push({path:`${t}.parentId`,message:"Definition placement parentId must be a non-empty string",severity:"error"}),c=!1),s!==void 0&&(typeof s!="string"||s.length===0)&&(n.push({path:`${t}.parentDefinitionId`,message:"Definition placement parentDefinitionId must be a non-empty string when present",severity:"error"}),c=!1),c){let l=r.resolve(e);l.kind==="missing"?n.push({path:s===void 0?`${t}.parentId`:`${t}.parentDefinitionId`,message:s===void 0?`Definition placement parentId "${String(o)}" does not exist`:`Definition placement parent "${String(o)}" does not exist in library definition "${String(s)}"`,severity:"error"}):l.kind==="ambiguous"&&n.push({path:`${t}.parentId`,message:`Definition placement parentId "${String(o)}" is ambiguous across library definitions: ${l.definitionIds.join(", ")}`,severity:"error"})}(typeof a!="number"||!Number.isInteger(a)||a<0)&&n.push({path:`${t}.siblingIndex`,message:"Definition placement siblingIndex must be a non-negative integer",severity:"error"})}function DB(e,t,n){if(!Array.isArray(e)){n.push({path:t,message:"Appearance style layers must be an array",severity:"error"});return}let r=new Set;e.forEach((i,o)=>{let s=`${t}[${o}]`;if(!de(i)){n.push({path:s,message:"Appearance style layer must be an object",severity:"error"});return}if(i.kind!=="fill"&&i.kind!=="stroke"&&n.push({path:`${s}.kind`,message:"Appearance style layer kind must be fill or stroke",severity:"error"}),typeof i.id!="string"||i.id.length===0){n.push({path:`${s}.id`,message:"Appearance style layer id must be a non-empty string",severity:"error"});return}r.has(i.id)?n.push({path:`${s}.id`,message:`Duplicate appearance style layer id: "${i.id}"`,severity:"error"}):r.add(i.id)})}function $B(e,t,n,r,i){if(e===null||typeof e!="object"){n.push({path:t,message:"Paint server def must be a non-null object",severity:"error"});return}let o=e;typeof o.id!="string"||o.id.length===0?n.push({path:`${t}.id`,message:"Paint server def id must be a non-empty string",severity:"error"}):r.has(o.id)?n.push({path:`${t}.id`,message:`Duplicate paint server def id: "${o.id}"`,severity:"error"}):r.add(o.id),o.sourceId!==void 0&&(typeof o.sourceId!="string"||o.sourceId.length===0)&&n.push({path:`${t}.sourceId`,message:"Paint server def sourceId must be a non-empty string when present",severity:"error"});let s=o.role===void 0?"resource":o.role;s!=="resource"&&s!=="referenced-fragment"&&n.push({path:`${t}.role`,message:"Paint server def role must be resource or referenced-fragment",severity:"error"}),typeof o.type=="string"&&(s==="resource"&&OB.has(o.type)||s==="referenced-fragment"&&/^[A-Za-z][\w.-]*$/u.test(o.type))||n.push({path:`${t}.type`,message:"Paint server def type must be a supported SVG defs element type",severity:"error"}),(typeof o.markup!="string"||o.markup.length===0)&&n.push({path:`${t}.markup`,message:"Paint server def markup must be a non-empty string",severity:"error"}),o.passthrough!==void 0&&typeof o.passthrough!="boolean"&&n.push({path:`${t}.passthrough`,message:"Paint server def passthrough must be a boolean when present",severity:"error"});for(let c of["definitionChildIds","sourceDefinitionChildIds"]){let l=o[c];l!==void 0&&(!Array.isArray(l)||l.some(d=>typeof d!="string"||d.length===0))&&n.push({path:`${t}.${c}`,message:"Definition child ids must be non-empty strings",severity:"error"})}Array.isArray(o.definitionChildIds)&&Array.isArray(o.sourceDefinitionChildIds)&&o.definitionChildIds.length!==o.sourceDefinitionChildIds.length&&n.push({path:t,message:"Definition child id arrays must have equal lengths",severity:"error"}),Nl(o.authoredPlacement,`${t}.authoredPlacement`,n,i,"Paint server def"),fa(o.definitionOrder,`${t}.definitionOrder`,n),pa(o.definitionContainerId,`${t}.definitionContainerId`,n)}function Db(e,t,n,r,i){if(e===null||typeof e!="object"||Array.isArray(e)){n.push({path:t,message:"Shape must be a non-null object",severity:"error"});return}bn(e,{onShape:(o,s)=>{MB(o,`${t}${s}`,n,r,i)}})}function MB(e,t,n,r,i){if(typeof e.id!="string"||e.id.length===0?n.push({path:`${t}.id`,message:"Shape id must be a non-empty string",severity:"error"}):i.has(e.id)?n.push({path:`${t}.id`,message:`Duplicate shape id: "${e.id}"`,severity:"error"}):i.add(e.id),typeof e.type!="string"?n.push({path:`${t}.type`,message:"Shape type must be a string",severity:"error"}):bB().has(e.type)||r.push({path:`${t}.type`,message:`Unknown shape type: "${e.type}"`,severity:"warning"}),e.state===void 0||e.state===null||typeof e.state!="object")n.push({path:`${t}.state`,message:"Shape state must be a non-null object",severity:"error"});else{let o=e.state;FB(o,`${t}.state`,n,r),e.type==="foreign-object"&&(Object.hasOwn(o,"rawContent")&&n.push({path:`${t}.state.rawContent`,message:"rawContent is noncanonical; use structured foreignContent nodes",severity:"error"}),o.foreignContent!==void 0&&Ut(o.foreignContent,`${t}.state.foreignContent`,n)&&o.foreignContent.forEach((s,a)=>tT(s,`${t}.state.foreignContent[${a}]`,n))),o.children!==void 0&&!Array.isArray(o.children)?n.push({path:`${t}.state.children`,message:"children must be an array",severity:"error"}):Array.isArray(o.children)&&o.children.forEach((s,a)=>{(s===null||typeof s!="object"||Array.isArray(s))&&n.push({path:`${t}.state.children[${a}]`,message:"Shape must be a non-null object",severity:"error"})})}}var zB=/^\s*\{\{\s*[\w.\-]+\s*\}\}\s*$/;function JP(e){return typeof e=="number"?isFinite(e):typeof e=="string"?zB.test(e):!1}function FB(e,t,n,r){if(fa(e.definitionOrder,`${t}.definitionOrder`,n),pa(e.definitionContainerId,`${t}.definitionContainerId`,n),de(e.metadata))for(let s of["linkUrl","linkTarget"])Object.hasOwn(e.metadata,s)&&n.push({path:`${t}.metadata.${s}`,message:`${s} is noncanonical; use a Hyperlink container shape`,severity:"error"});if((e.fillType==="linear-gradient"||e.fillType==="radial-gradient"||e.fillType==="pattern")&&e.fillColor==="none"&&e.fillOpacity===0&&n.push({path:`${t}.fillOpacity`,message:"Painted shapes cannot carry the noncanonical no-fill opacity encoding",severity:"error"}),e.charOffsets!==void 0&&e.charOffsets!==null&&(Array.isArray(e.charOffsets)?e.charOffsets.forEach((s,a)=>{let c=`${t}.charOffsets[${a}]`;if(!de(s)){n.push({path:c,message:"Each charOffsets entry must be a plain object",severity:"error"});return}for(let l of["x","y"]){let d=s[l];d!==null&&(typeof d!="number"||!Number.isFinite(d))&&n.push({path:`${c}.${l}`,message:`${l} must be null or a finite number`,severity:"error"})}for(let l of["dx","dy","rotate"]){let d=s[l];(typeof d!="number"||!Number.isFinite(d))&&n.push({path:`${c}.${l}`,message:`${l} must be a finite number`,severity:"error"})}if(s.raw!==void 0)if(!de(s.raw))n.push({path:`${c}.raw`,message:"raw must be a plain object",severity:"error"});else for(let[l,d]of Object.entries(s.raw))(!["x","y","dx","dy"].includes(l)||typeof d!="string")&&n.push({path:`${c}.raw.${l}`,message:"raw accepts only string x/y/dx/dy members",severity:"error"})}):n.push({path:`${t}.charOffsets`,message:"charOffsets must be an array",severity:"error"})),e.textPathReference!==void 0&&e.textPathReference!==null){let s=e.textPathReference;(!de(s)||s.kind!=="shape"&&s.kind!=="definition"||typeof s.targetId!="string"||s.targetId.length===0||s.element!=="href"&&s.element!=="mpath"||Object.keys(s).some(a=>!["kind","targetId","element"].includes(a)))&&n.push({path:`${t}.textPathReference`,message:"textPathReference requires an exact shape/definition target and href/mpath element",severity:"error"})}for(let s of["textPathRefShapeId","textPathImportRefId"])e[s]!==void 0&&n.push({path:`${t}.${s}`,message:`${s} is noncanonical; use textPathReference`,severity:"error"});if(e.authoredTextPosition!==void 0)if(!de(e.authoredTextPosition))n.push({path:`${t}.authoredTextPosition`,message:"authoredTextPosition must be a plain object",severity:"error"});else for(let[s,a]of Object.entries(e.authoredTextPosition)){let c=`${t}.authoredTextPosition.${s}`;if(!["x","y"].includes(s)||!de(a)){n.push({path:c,message:"Authored text position accepts only x/y coordinate objects",severity:"error"});continue}(typeof a.raw!="string"||a.raw.length===0||typeof a.resolved!="number"||!Number.isFinite(a.resolved))&&n.push({path:c,message:"Authored text coordinates require non-empty raw and finite resolved values",severity:"error"});for(let l of Object.keys(a))["raw","resolved"].includes(l)||n.push({path:`${c}.${l}`,message:"Authored text coordinates accept only raw/resolved members",severity:"error"})}if(e.textSpanTree!==void 0){let s=`${t}.textSpanTree`;if(!de(e.textSpanTree))n.push({path:s,message:"textSpanTree must be a plain object",severity:"error"});else{let a=e.textSpanTree,c=a.text,l=a.spans;if(typeof c!="string"||!Array.isArray(l))n.push({path:s,message:"Text span trees require text and spans",severity:"error"});else{let d=new Set,u=(f,p,m,g)=>{let h=p;f.forEach((y,S)=>{let b=`${g}[${S}]`,I=de(y)?y.start:void 0,v=de(y)?y.end:void 0,w=de(y)?y.children:void 0,k=de(y)?y.spanId:void 0,C=de(y)?y.id:void 0,P=de(y)?y.lineIndex:void 0,R=de(y)?y.rotate:void 0;!de(y)||typeof I!="number"||typeof v!="number"||!Number.isInteger(I)||!Number.isInteger(v)||I<h||v<I||I<p||v>m||!Array.isArray(w)||typeof k!="string"||k.length===0||d.has(k)||C!==void 0&&(typeof C!="string"||C.length===0)||P!==void 0&&(typeof P!="number"||!Number.isInteger(P)||P<0)||R!==void 0&&(!Array.isArray(R)||R.length===0||R.some(N=>typeof N!="number"||!Number.isFinite(N)))||Object.keys(y).some(N=>!["spanId","start","end","id","lineIndex","rotate","children"].includes(N))?n.push({path:b,message:"Text span nodes require nested ordered ranges, child arrays, and valid optional identity/line fields",severity:"error"}):(d.add(k),u(w,I,v,`${b}.children`),h=v)})};u(l,0,c.length,`${s}.spans`),a.rotate!==void 0&&(!Array.isArray(a.rotate)||a.rotate.length===0||a.rotate.some(f=>typeof f!="number"||!Number.isFinite(f)))&&n.push({path:`${s}.rotate`,message:"Text span root rotate must be a non-empty finite number list",severity:"error"});for(let f of Object.keys(a))["text","rotate","spans"].includes(f)||n.push({path:`${s}.${f}`,message:"Text span trees accept only text/spans members",severity:"error"})}}}if(e.authoredUseGeometry!==void 0)if(!de(e.authoredUseGeometry))n.push({path:`${t}.authoredUseGeometry`,message:"authoredUseGeometry must be a plain object",severity:"error"});else for(let[s,a]of Object.entries(e.authoredUseGeometry))(!["x","y","width","height"].includes(s)||typeof a!="string")&&n.push({path:`${t}.authoredUseGeometry.${s}`,message:"Authored use geometry accepts only string x/y/width/height members",severity:"error"});let i=["x","y","width","height","radius","rx","ry","fontSize"];for(let s of i)e[s]!==void 0&&!JP(e[s])&&n.push({path:`${t}.${s}`,message:`${s} must be a finite number or a {{variable}} reference`,severity:"error"});for(let s of oc){let a=e[s];if(a!=null){if(s==="transformMatrix"){(!Array.isArray(a)||a.length<6||!a.slice(0,6).every(c=>typeof c=="number"&&Number.isFinite(c)))&&n.push({path:`${t}.${s}`,message:`${s} must be a 6-element finite affine matrix`,severity:"error"});continue}JP(a)||n.push({path:`${t}.${s}`,message:`${s} must be a finite number or a {{variable}} reference`,severity:"error"})}}let o=["width","height","radius","fontSize"];for(let s of o){let a=e[s];typeof a=="number"&&a<=0&&r.push({path:`${t}.${s}`,message:`${s} should be positive (got ${a})`,severity:"warning"})}}function LB(e,t,n,r){if(e===null||typeof e!="object"){n.push({path:t,message:"Viewbox must be a non-null object",severity:"error"});return}let i=e;typeof i.id!="string"||i.id.length===0?n.push({path:`${t}.id`,message:"Viewbox id must be a non-empty string",severity:"error"}):r.has(i.id)?n.push({path:`${t}.id`,message:`Duplicate viewbox id: "${i.id}"`,severity:"error"}):r.add(i.id);for(let o of["x","y","width","height"])(typeof i[o]!="number"||!isFinite(i[o]))&&n.push({path:`${t}.${o}`,message:`${o} must be a finite number`,severity:"error"});typeof i.width=="number"&&i.width<=0&&n.push({path:`${t}.width`,message:"Viewbox width must be positive",severity:"error"}),typeof i.height=="number"&&i.height<=0&&n.push({path:`${t}.height`,message:"Viewbox height must be positive",severity:"error"})}function _B(e,t,n){if(e===null||typeof e!="object"){n.push({path:t,message:"Guide must be a non-null object",severity:"error"});return}let r=e;(typeof r.id!="string"||r.id.length===0)&&n.push({path:`${t}.id`,message:"Guide id must be a non-empty string",severity:"error"}),r.orientation!=="horizontal"&&r.orientation!=="vertical"&&n.push({path:`${t}.orientation`,message:'Guide orientation must be "horizontal" or "vertical"',severity:"error"}),(typeof r.position!="number"||!isFinite(r.position))&&n.push({path:`${t}.position`,message:"Guide position must be a finite number",severity:"error"})}function BB(e,t,n,r,i,o){if(e===null||typeof e!="object"){n.push({path:t,message:"ClipMaskGroup must be a non-null object",severity:"error"});return}let s=e;(typeof s.id!="string"||s.id.length===0)&&n.push({path:`${t}.id`,message:"ClipMaskGroup id must be a non-empty string",severity:"error"}),s.type!=="clip"&&s.type!=="mask"&&n.push({path:`${t}.type`,message:'ClipMaskGroup type must be "clip" or "mask"',severity:"error"}),s.definitionPlacement!==void 0&&s.definitionPlacement!=="defs"&&s.definitionPlacement!=="document"&&n.push({path:`${t}.definitionPlacement`,message:'definitionPlacement must be "defs" or "document"',severity:"error"}),s.referenceChannel!==void 0&&s.referenceChannel!=="attribute"&&s.referenceChannel!=="style"&&s.referenceChannel!=="stylesheet"&&n.push({path:`${t}.referenceChannel`,message:'referenceChannel must be "attribute", "style", or "stylesheet"',severity:"error"}),s.referenceStyleOrder!==void 0&&(typeof s.referenceStyleOrder!="number"||!Number.isInteger(s.referenceStyleOrder)||s.referenceStyleOrder<0)&&n.push({path:`${t}.referenceStyleOrder`,message:"referenceStyleOrder must be a non-negative integer",severity:"error"}),fa(s.definitionOrder,`${t}.definitionOrder`,n),pa(s.definitionContainerId,`${t}.definitionContainerId`,n),Nl(s.authoredPlacement,`${t}.authoredPlacement`,n,o,"Clip/mask");let a=s.clipShapeIds,c=typeof s.rawDefinition=="string"&&s.rawDefinition.length>0;a!==void 0&&!Array.isArray(a)?n.push({path:`${t}.clipShapeIds`,message:"clipShapeIds must be an array",severity:"error"}):a===void 0?n.push({path:`${t}.clipShapeIds`,message:"ClipMaskGroup must carry clipShapeIds",severity:"error"}):Array.isArray(a)&&a.length===0&&!c&&r.push({path:`${t}.clipShapeIds`,message:"ClipMaskGroup has no clip shapes and no rawDefinition; it will clip nothing",severity:"warning"}),Array.isArray(s.contentShapeIds)||n.push({path:`${t}.contentShapeIds`,message:"contentShapeIds must be an array",severity:"error"})}function Qt(e){let t=[...e].sort((i,o)=>i.index-o.index);if(!t.some(i=>i.orderKey))return t;let n=iu(t.length),r=new Map;return t.forEach((i,o)=>{r.set(i.id,i.orderKey??n[o])}),t.sort((i,o)=>{let s=lc(r.get(i.id)??"",r.get(o.id)??"");return s!==0?s:i.id<o.id?-1:i.id>o.id?1:0})}function Lt(e){return e.definitionId??`${e.type}-${e.id}`}function jp(e){return e.rawDefinition!==void 0?!0:e.clipShapeIds.length===0}function Up(e){let t=jp(e);return e.type==="clip"?{type:"clip",...e.definitionPlacement!==void 0?{definitionPlacement:e.definitionPlacement}:{},...e.definitionOrder!==void 0?{definitionOrder:e.definitionOrder}:{},...e.definitionContainerId!==void 0?{definitionContainerId:e.definitionContainerId}:{},...e.authoredPlacement!==void 0?{authoredPlacement:structuredClone(e.authoredPlacement)}:{},...e.clipPathUnits!==void 0?{clipPathUnits:e.clipPathUnits}:{},...!t&&e.clipRule!==void 0?{clipRule:e.clipRule}:{},...t&&e.rawDefinition!==void 0?{rawDefinition:e.rawDefinition}:{}}:{type:"mask",...e.definitionPlacement!==void 0?{definitionPlacement:e.definitionPlacement}:{},...e.definitionOrder!==void 0?{definitionOrder:e.definitionOrder}:{},...e.definitionContainerId!==void 0?{definitionContainerId:e.definitionContainerId}:{},...e.authoredPlacement!==void 0?{authoredPlacement:structuredClone(e.authoredPlacement)}:{},...e.maskUnits!==void 0?{maskUnits:e.maskUnits}:{},...e.maskContentUnits!==void 0?{maskContentUnits:e.maskContentUnits}:{},...e.maskType!==void 0?{maskType:e.maskType}:{},...e.maskBounds!==void 0?{maskBounds:structuredClone(e.maskBounds)}:{},...t&&e.rawDefinition!==void 0?{rawDefinition:e.rawDefinition}:{}}}function Ko(e,t,n){let{clipPathUnits:r,clipRule:i,maskUnits:o,maskContentUnits:s,maskType:a,maskBounds:c,definitionPlacement:l,definitionOrder:d,definitionContainerId:u,authoredPlacement:f,rawDefinition:p,...m}=structuredClone(e),g=t.rawDefinition!==void 0||jp(e);return e.type==="clip"?{...m,type:"clip",...t.definitionPlacement!==void 0?{definitionPlacement:t.definitionPlacement}:{},...t.definitionOrder!==void 0?{definitionOrder:t.definitionOrder}:{},...t.definitionContainerId!==void 0?{definitionContainerId:t.definitionContainerId}:{},...t.authoredPlacement!==void 0?{authoredPlacement:structuredClone(t.authoredPlacement)}:{},...t.clipPathUnits!==void 0?{clipPathUnits:t.clipPathUnits}:{},...!g&&t.clipRule!==void 0?{clipRule:t.clipRule}:{},...g&&n&&t.rawDefinition!==void 0?{rawDefinition:t.rawDefinition}:{}}:{...m,type:"mask",...t.definitionPlacement!==void 0?{definitionPlacement:t.definitionPlacement}:{},...t.definitionOrder!==void 0?{definitionOrder:t.definitionOrder}:{},...t.definitionContainerId!==void 0?{definitionContainerId:t.definitionContainerId}:{},...t.authoredPlacement!==void 0?{authoredPlacement:structuredClone(t.authoredPlacement)}:{},...t.maskUnits!==void 0?{maskUnits:t.maskUnits}:{},...t.maskContentUnits!==void 0?{maskContentUnits:t.maskContentUnits}:{},...t.maskType!==void 0?{maskType:t.maskType}:{},...t.maskBounds!==void 0?{maskBounds:structuredClone(t.maskBounds)}:{},...g&&n&&t.rawDefinition!==void 0?{rawDefinition:t.rawDefinition}:{}}}function ei(e){let t=new Map;for(let n of e??[]){let r=Lt(n),i=Up(n),o=t.get(r);t.set(r,o?.type===i.type?{...o,...i}:i)}return t}function Yn(e){let t=structuredClone(e??[]),n=ei(t),r=new Set;return t.map(i=>{let o=Lt(i),s=n.get(o)??Up(i),a=s.rawDefinition!==void 0&&!r.has(o);return a&&r.add(o),Ko(i,s,a)})}function wi(e,t){let n=structuredClone(e??[]);if(t.type==="clipMask:remove"){let c=n.find(p=>p.id===t.id);if(!c)return Yn(n);let l=Lt(c),d=ei(n).get(l),u=n.filter(p=>p.id!==t.id),f=u.findIndex(p=>Lt(p)===l);return d&&f>=0&&(u[f]=Ko(u[f],d,!0)),Yn(u)}let r=n.findIndex(c=>c.id===t.clipMaskGroup.id),i=r>=0?n[r]:void 0,o=i?ei(n).get(Lt(i)):void 0;r>=0&&n.splice(r,1);let s=Math.min(Math.max(0,t.index??n.length),n.length),a=structuredClone(t.clipMaskGroup);return o?.rawDefinition!==void 0&&a.rawDefinition===void 0&&Lt(i)===Lt(a)&&(a=Ko(a,o,!0)),n.splice(s,0,a),Yn(n)}function Hp(e,t,n,r){if(!e.some(o=>o.id===t))throw new Error(`Unknown clip/mask group: ${t}`);let i=e.map(o=>o.id===t?Ko({...o,definitionId:n},r,r.rawDefinition!==void 0):Lt(o)!==n?structuredClone(o):Ko(o,r,!1));return Yn(i)}var VB=/^structural:(clip|mask):(.+):(group|path|content)$/;function nT(e,t){let n=`structural:${e}:${t}`;return{group:`${n}:group`,path:`${n}:path`,content:`${n}:content`}}function rT(e,t){for(let n of e){t.add(n.id);let r=n.state.children;Array.isArray(r)&&rT(r,t)}}function iT(e,t=null){let n=[];return e.forEach((r,i)=>{n.push({id:r.id,parentId:t,index:i});let o=r.state.children;Array.isArray(o)&&n.push(...iT(o,r.id))}),n}function Nr(e){let t=e.sceneTree&&e.sceneTree.length>0?e.sceneTree:iT(e.shapes),n=new Map(t.map(v=>[v.id,v])),r=new Map;for(let v of t){let w=r.get(v.parentId)??[];w.push(v),r.set(v.parentId,w)}for(let[v,w]of r)r.set(v,Qt(w));let i=v=>VB.test(v),o=new Set(t.filter(v=>!i(v.id)).map(v=>v.id)),s=new Set;rT(e.shapes,s);let a=new Map,c=new Set,l=(v,w)=>{let k=[];for(let C of r.get(v)??[]){if(!i(C.id)){c.has(C.id)||(c.add(C.id),k.push(C.id));continue}if(w.has(C.id))continue;let P=new Set(w);P.add(C.id),k.push(...l(C.id,P))}return k},d=[null,...o];for(let v of d){let w=l(v,new Set);w.length>0&&a.set(v,w)}for(let v of o){if(c.has(v))continue;let w=n.get(v)?.parentId??null,k=w!==null&&o.has(w)?w:null,C=a.get(k)??[];C.push(v),a.set(k,C),c.add(v)}let u=v=>{for(let[w,k]of a){let C=k.indexOf(v);if(C>=0)return{parentId:w,index:C}}return null},f=v=>{for(let w of a.values()){let k=w.indexOf(v);k>=0&&w.splice(k,1)}},p=e.clipMaskGroups??[],m=ei(p),g=new Set(p.filter(v=>v.clipShapeIds.some(w=>s.has(w))).map(v=>`${v.type}\0${Lt(v)}`)),h=new Map(p.map(v=>[nT(v.type,v.id).content,v])),y=(v,w=new Set)=>{if(w.has(v.id))return Number.MAX_SAFE_INTEGER;let k=v.parentId?h.get(v.parentId):void 0;if(!k)return 0;let C=new Set(w);return C.add(v.id),1+y(k,C)},S=[...p].sort((v,w)=>y(v)-y(w)||(v.siblingIndex??0)-(w.siblingIndex??0)),b=new Map;for(let v of S){let w=v.clipShapeIds.filter(W=>s.has(W)),k=v.contentShapeIds.filter(W=>s.has(W)),C=Lt(v),R=m.get(C)?.rawDefinition!==void 0||g.has(`${v.type}\0${C}`);if(k.length===0||!R)continue;let N=[...k,...w].map(u).filter(W=>W!==null),M=N[0]?.parentId??null,A=N.length>0?Math.min(...N.map(W=>W.index)):void 0,$=v.parentId===null||o.has(v.parentId)||h.has(v.parentId)?v.parentId:M;for(let W of[...w,...k])f(W);let _=nT(v.type,v.id),z=a.get($)??[],j=v.siblingIndex??A??z.length,G=Math.min(Math.max(0,j),z.length);z.splice(G,0,_.group),a.set($,z),a.set(_.group,[_.path,_.content]),a.set(_.path,[...w]),a.set(_.content,[...k]),b.set(_.group,{id:_.group,parentId:$,index:0}),b.set(_.path,{id:_.path,parentId:_.group,index:0}),b.set(_.content,{id:_.content,parentId:_.group,index:1})}let I=[];for(let[v,w]of a)w.forEach((k,C)=>{let P=b.get(k);if(P){I.push({...P,parentId:v,index:C});return}let R=n.get(k);R&&R.parentId===v?I.push({...R,index:C}):I.push({id:k,parentId:v,index:C})});e.sceneTree=I}function mr(e){let t=[],n=new Map,r=new Set,i=new WeakSet,o=[...e].reverse();for(;o.length>0;){let a=o.pop();if(!a||typeof a!="object"||i.has(a))continue;i.add(a),t.push(a);let c=n.get(a.id);c&&c!==a?r.add(a.id):c||n.set(a.id,a);let l=a.state.children;if(Array.isArray(l))for(let d=l.length-1;d>=0;d--){let u=l[d];u&&typeof u=="object"&&typeof u.id=="string"&&o.push(u)}}let s=new Map(n);for(let a of r)s.delete(a);return{ordered:t,uniqueById:s,duplicateIds:r}}function ki(e){let t=[...e??[]],n=new Map;for(let o of t)n.set(o.id,(n.get(o.id)??0)+1);let r=new Set([...n].filter(([,o])=>o>1).map(([o])=>o)),i=new Map;for(let o of t)r.has(o.id)||i.set(o.id,o);return{ordered:t,uniqueById:i,duplicateIds:r,definition:o=>i.get(o),symbol:o=>{let s=i.get(o);return s?.kind==="symbol"?s:void 0}}}function GB(e){let t=e.groupData;if(!t||typeof t!="object"||Array.isArray(t))return null;let n=t.transform;return typeof n=="string"&&n.trim()?n:null}function ma(e,t){let n=sn(e,t);if(n)return{matrix:ir(e,t),attribute:n,owner:"canonical"};let r=GB(e);if(r){let i=Tn(r),o=e.customPivot;return{matrix:o?Ic(o,i):i,attribute:r,owner:"group-data"}}return{matrix:He,attribute:null,owner:"none"}}function An(e){let t=e.transformMatrix;return mi(t)&&!on(t)||e.customPivot||typeof e.rawTransform=="string"&&e.rawTransform?!1:(e.rotation??0)!==0||(e.skewX??0)!==0||(e.skewY??0)!==0||(e.scaleX??1)!==1||(e.scaleY??1)!==1}function El(e,t){let n=t?{x:(t.minX+t.maxX)/2,y:(t.minY+t.maxY)/2}:void 0;return ma(e,n)}var jB=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/,UB=/^([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?)px$/i,HB=/^([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?)%$/;function Ol(e,t,n,r){let i=e.trim();if(jB.test(i))return Number(i);let o=UB.exec(i);if(o)return Number(o[1]);let s=HB.exec(i);if(s)return t.percentBasis===void 0?(r.push({code:"unresolved-symbol-viewport",message:`Symbol ${t.axis} percentage ${e} needs a containing viewport basis.`}),null):Number(s[1])/100*t.percentBasis;let a=n.resolveLength?.(e,t)??null;return a!==null&&Number.isFinite(a)?a:(r.push({code:"invalid-symbol-length",message:`Symbol ${t.axis} length ${e} is invalid or requires an unavailable length host.`}),null)}function KB(e){let t=e.state.authoredUseGeometry;return t&&typeof t=="object"?t:{}}function Wo(e,t){let n=e[t];if(typeof n=="string")return n;if(["viewBox","preserveAspectRatio","x","y","width","height","refX","refY"].includes(t))return;let r=e.rootAttributes?.[t];return typeof r=="string"?r:void 0}function WB(e,t){if(e===void 0)return;let n=At(e);return n?n.width<0||n.height<0?(t.push({code:"invalid-symbol-viewbox",message:`Symbol viewBox ${e} has a non-finite or negative dimension and is ignored.`}),null):n:(t.push({code:"invalid-symbol-viewbox",message:`Symbol viewBox ${e} is not four finite SVG numbers and is ignored.`}),null)}function oT(e,t,n,r,i,o){return t===void 0?0:Ol(t,{axis:n,percentBasis:n==="x"?r?.width:r?.height},i,o)??0}function sT(e,t,n,r,i,o,s){let a=n==="width"?i?.width:i?.height,c=[r,Wo(t,n)];for(let l of c){if(l===void 0||l.trim().toLowerCase()==="auto")continue;let d=Ol(l,{axis:n,percentBasis:a},o,s);if(d!==null){if(d<0){s.push({code:"invalid-symbol-length",message:`Negative symbol ${n} ${l} is invalid and falls back to auto.`});continue}return d}}return a!==void 0?a:(s.push({code:"unresolved-symbol-viewport",message:`Symbol ${n} is auto and needs a containing viewport basis.`}),null)}function aT(e,t,n,r,i){if(e===void 0)return;let o=e.trim();if(t==="refX"){if(o==="left")return 0;if(o==="center")return(n?.width??0)/2;if(o==="right")return n?.width??0}else{if(o==="top")return 0;if(o==="center")return(n?.height??0)/2;if(o==="bottom")return n?.height??0}return Ol(e,{axis:t,percentBasis:t==="refX"?n?.width:n?.height},r,i)??void 0}function ga(e,t,n,r={}){let i=[],o=KB(e),s=oT(e,o.x,"x",n,r,i),a=oT(e,o.y,"y",n,r,i),c=lt(s,a),l=Wo(t,"transform"),d=l?Tn(l):He;if((t.defKind??"symbol")!=="symbol")return{kind:"group",renders:!0,useX:s,useY:a,useAttributes:o,contentMatrix:ve(c,d),childPercentBasis:n??null,viewport:null,diagnostics:i};let u=sT(e,t,"width",o.width,n,r,i),f=sT(e,t,"height",o.height,n,r,i),p=Wo(t,"x"),m=Wo(t,"y"),g=p!==void 0?Ol(p,{axis:"x",percentBasis:n?.width},r,i)??0:0,h=m!==void 0?Ol(m,{axis:"y",percentBasis:n?.height},r,i)??0:0,y=WB(t.viewBox,i),S=Do({width:u,height:f,...y?{viewBoxX:y.x,viewBoxY:y.y,viewBoxWidth:y.width,viewBoxHeight:y.height}:{},preserveAspectRatio:Wo(t,"preserveAspectRatio")},n);for(let C of S.diagnostics)i.push({code:C.code==="unresolved-viewport-size"?"unresolved-symbol-viewport":"invalid-symbol-viewbox",message:C.message.replace("Nested SVG","Symbol")});if(u===null||f===null||!S.renders||!S.contentMatrix)return{kind:"symbol",renders:!1,useX:s,useY:a,useAttributes:o,contentMatrix:ve(c,d),childPercentBasis:S.childPercentBasis,viewport:S,diagnostics:i};let b=aT(Wo(t,"refX"),"refX",S.childPercentBasis,r,i),I=aT(Wo(t,"refY"),"refY",S.childPercentBasis,r,i),v=Ye(S.contentMatrix,{x:b??0,y:I??0}),w=lt(g-(b===void 0?0:v.x),h-(I===void 0?0:v.y)),k=ve(ve(ve(c,d),w),S.contentMatrix);return{kind:"symbol",renders:!0,useX:s,useY:a,useAttributes:o,contentMatrix:k,childPercentBasis:S.childPercentBasis,viewport:S,diagnostics:i}}function Kp(){return{bounds:null,status:"empty",diagnostics:[]}}function ya(e,t,n){return n.resolveOwnTransform?.(e,t)??t}function Or(e,t){return{bounds:null,status:e,diagnostics:[t]}}function Dl(e,t){return e?t?{minX:Math.min(e.minX,t.minX),minY:Math.min(e.minY,t.minY),maxX:Math.max(e.maxX,t.maxX),maxY:Math.max(e.maxY,t.maxY)}:e:t}function Er(e,t,n="empty"){return e?{bounds:e,status:"resolved",diagnostics:t}:t.some(r=>r.code==="container-cycle"||r.code==="reference-cycle"||r.code==="symbol-cycle")?{bounds:null,status:"cycle",diagnostics:t}:t.some(r=>r.code==="unsupported-shape"||r.code==="deferred-tree-kind")?{bounds:null,status:"unsupported",diagnostics:t}:t.some(r=>r.code==="unresolved-shape"||r.code==="unresolved-reference-target"||r.code==="unresolved-reference-pivot"||r.code==="duplicate-shape-id"||r.code==="unresolved-svg-viewport"||r.code==="unresolved-symbol-definition"||r.code==="duplicate-library-id"||r.code==="unresolved-symbol-viewport"||r.code==="unresolved-symbol-pivot")?{bounds:null,status:"unresolved",diagnostics:t}:{bounds:null,status:n,diagnostics:t}}function zb(e){if(e.length===0)return null;let t=e[0].x,n=e[0].y,r=e[0].x,i=e[0].y;for(let o=1;o<e.length;o++){let s=e[o];t=Math.min(t,s.x),n=Math.min(n,s.y),r=Math.max(r,s.x),i=Math.max(i,s.y)}return{minX:t,minY:n,maxX:r,maxY:i}}function _b(e,t){return zb([Ye(t,{x:e.minX,y:e.minY}),Ye(t,{x:e.maxX,y:e.minY}),Ye(t,{x:e.maxX,y:e.maxY}),Ye(t,{x:e.minX,y:e.maxY})])}function cT(e,t,n,r,i){return n<0||r<0?null:_b({minX:e,minY:t,maxX:e+n,maxY:t+r},i)}function lT(e,t,n,r,i){if(n<0||r<0)return null;let o=Ye(i,{x:e,y:t}),s=Math.hypot(i[0]*n,i[2]*r),a=Math.hypot(i[1]*n,i[3]*r);return{minX:o.x-s,minY:o.y-a,maxX:o.x+s,maxY:o.y+a}}function XB(e,t){let n=Array.isArray(e)?e:[e],r=null;for(let i of n)r=Dl(r,_b(i,t));return r}function $b(e,t,n){return Or("unsupported",{code:t,shapeId:e.id,message:`Object bounds for ${n} require a document resolver policy.`,path:[e.id]})}function dT(e,t,n={}){return Fb(e,Vn(e),t,n)}function Fb(e,t,n,r){if(!t)return Or("unsupported",{code:"unsupported-shape",shapeId:e.id,message:`No geometry kernel is registered for shape type ${e.type}.`,path:[e.id]});let i;switch(t.kind){case"circle":i=lT(t.cx,t.cy,t.r,t.r,n);break;case"ellipse":i=lT(t.cx,t.cy,t.rx,t.ry,n);break;case"rectangle":if(t.width<0||t.height<0)i=null;else if(t.pathData)i=ar(t.pathData,n);else if(t.rx>0&&t.ry>0){let o=wS(t.x,t.y,t.width,t.height,t.rx,t.ry);i=o?ar(o,n):null}else i=cT(t.x,t.y,t.width,t.height,n);break;case"line":if(t.boundsPolicy==="linked-line")return $b(e,"deferred-tree-kind","linked line");i=zb([Ye(n,{x:t.x1,y:t.y1}),Ye(n,{x:t.x2,y:t.y2})]);break;case"text":{let o=r.measureText?.(e,t)??null;if(!o)return $b(e,"deferred-tree-kind","text");i=XB(o,n);break}case"path":{if(t.boundsPolicy==="empty")return Kp();let o=t.placement?ve(n,lt(t.placement.x,t.placement.y)):n;i=Fy(t,o);break}case"polyline":{let o=t.points.length>0?t.points:[{x:0,y:0}];i=zb(o.map(s=>Ye(n,s)));break}case"positioning-rect":i=cT(t.x,t.y,t.width,t.height,n);break;case"view":return Kp();case"container":case"embedded-svg":case"shape-reference":case"symbol-instance":return $b(e,"deferred-tree-kind",t.kind)}return i?{bounds:i,status:"resolved",diagnostics:[]}:{bounds:null,status:"empty",diagnostics:[]}}function Lb(e){let t=e.state.children;return Array.isArray(t)?t.filter(n=>!!n&&typeof n=="object"&&typeof n.id=="string"):[]}function Dr(e){let t=mr(e.shapes),n=ki(e.library),r=e.sceneTree??[];if(r.length===0)return{roots:()=>e.shapes,shape:l=>t.uniqueById.get(l),duplicateShapeIds:()=>t.duplicateIds,libraryDefinition:l=>n.definition(l),duplicateLibraryIds:()=>n.duplicateIds,children:Lb};let i=new Map,o=new Set;for(let l of r){let d=i.get(l.parentId)??[];i.set(l.parentId,[...d,l]),t.uniqueById.has(l.id)&&o.add(l.id)}let s=l=>{let d=[],u=new Set,f=p=>{for(let m of Qt([...i.get(p)??[]])){let g=t.uniqueById.get(m.id);if(g){d.push(g);continue}u.has(m.id)||(u.add(m.id),f(m.id),u.delete(m.id))}};return f(l),d};return{roots:()=>[...s(null),...e.shapes.filter(l=>!o.has(l.id))],shape:l=>t.uniqueById.get(l),duplicateShapeIds:()=>t.duplicateIds,libraryDefinition:l=>n.definition(l),duplicateLibraryIds:()=>n.duplicateIds,children:l=>[...s(l.id),...Lb(l).filter(d=>!o.has(d.id))]}}function uT(e,t){return`${t.identityPrefixes.at(-1)??"document"}\0${e.id}`}var YB=new Set(["block","contents","flex","flow","flow-root","grid","inherit","initial","inline","inline-block","inline-flex","inline-grid","inline-table","list-item","none","revert","revert-layer","ruby","ruby-base","ruby-base-container","ruby-text","ruby-text-container","run-in","table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row","table-row-group","unset"]),Mb=new Set(["block","inline","run-in"]),qB=new Set(["flow","flow-root","table","flex","grid","ruby"]);function ZB(e){let t=e.trim().toLowerCase();if(YB.has(t)||/^(?:var|env)\(/.test(t)&&t.endsWith(")"))return!0;let n=t.split(/\s+/);if(n.length<2||n.length>3||new Set(n).size!==n.length)return!1;if(n.includes("list-item")){let r=n.filter(i=>i!=="list-item");return r.filter(i=>Mb.has(i)).length<=1&&r.filter(i=>i==="flow"||i==="flow-root").length<=1&&r.every(i=>Mb.has(i)||i==="flow"||i==="flow-root")}return n.length===2&&n.some(r=>Mb.has(r))&&n.some(r=>qB.has(r))}function QB(e){if(!e)return null;let t=null;for(let n of xr(e,";")){let r=xr(n,":");if(r.length<2||r[0].trim().toLowerCase()!=="display")continue;let i=r.slice(1).join(":").trim(),o=/\s*!important\s*$/i.test(i),s=i.replace(/\s*!important\s*$/i,"").trim().toLowerCase();ZB(s)&&(!t||o||!t.important)&&(t={value:s,important:o})}return t}function fT(e,t){let n=QB(typeof t=="string"?t:void 0);return n?n.value!=="none":typeof e!="string"||e.trim().toLowerCase()!=="none"}function $l(e,t){if(e.state.visible===!1)return!1;let n=e.type==="symbol-instance"||e.type==="shape-reference"?e.state.instancePresentation:void 0,r=n?.display??e.state.display;return fT(r,n?.style)?t.participatesInRendering?.(e)??!0:!1}function pT(e,t,n){let r=e.rootAttributes;return fT(r?.display,r?.style)?n.participatesSymbolDefinition?.(e,t)??!0:!1}function JB(e,t={}){return{x:e.x,y:e.y,width:t.width!==void 0?t.width:e.width,height:t.height!==void 0?t.height:e.height,viewBoxX:e.viewBoxX,viewBoxY:e.viewBoxY,viewBoxWidth:e.viewBoxWidth,viewBoxHeight:e.viewBoxHeight,preserveAspectRatio:e.preserveAspectRatio}}function no(e,t,n={}){let r=Vn(e);if(!r||r.kind!=="embedded-svg")return{matrix:He,attribute:null,pivotRequired:!1,pivotResolved:!1,viewport:Do({})};let i=Do(JB(r,n),t),o=An(e.state),s=i.frame?{x:i.frame.x+i.frame.width/2,y:i.frame.y+i.frame.height/2}:void 0;return{matrix:ir(e.state,s),attribute:sn(e.state,s),pivotRequired:o,pivotResolved:!o||s!==void 0,viewport:i}}function mT(e,t,n){return t.diagnostics.map(r=>({code:r.code==="unresolved-viewport-size"?"unresolved-svg-viewport":"invalid-svg-viewport",shapeId:e.id,message:r.message,path:[...n,e.id]}))}function Wp(e,t,n,r){let i=null,o=[],s=n.forceInlineChildren>0?Lb(e):n.view.children(e);for(let a of s){if(!$l(a,n.host))continue;let c=Ml(a,t,n,r);i=Dl(i,c.bounds),o.push(...c.diagnostics)}return Er(i,o)}function gT(e,t){return{...e,diagnostics:e.diagnostics.map(n=>n.path.includes(t)?n:{...n,path:[t,...n.path]})}}function eV(e,t,n,r,i={}){let o=no(e,r,i),s=mT(e,o.viewport,n.path);if(o.pivotRequired&&!o.pivotResolved)return s.push({code:"unresolved-svg-viewport",shapeId:e.id,message:`Embedded SVG ${e.id} has decomposed rotation/scale/skew channels, but its auto viewport frame cannot be resolved without a parent viewport.`,path:[...n.path,e.id]}),Er(null,s,"unresolved");if(!o.viewport.renders)return Er(null,s,o.viewport.status==="zero-disabled"?"empty":"unresolved");let a=uT(e,n);n.active.add(a),n.path.push(e.id);let l=e.state.isRootSvg===!0?t:ve(ve(t,ya(e,o.matrix,n.host)),o.viewport.contentMatrix??He),d=Wp(e,l,n,o.viewport.childPercentBasis??r);return n.path.pop(),n.active.delete(a),Er(d.bounds,[...s,...d.diagnostics],d.status)}function hT(e,t,n={},r={}){let i=typeof t=="string"?e.shape(t):t;if(!i){let d=typeof t=="string"?t:t.id;return Or("unresolved",{code:"unresolved-shape",shapeId:d,message:`Shape ${d} is not present in the document bounds view.`,path:[d]})}let o=Vn(i);if(!o||o.kind!=="embedded-svg")return Or("unsupported",{code:"unsupported-shape",shapeId:i.id,message:`Shape ${i.id} is not an embedded SVG viewport.`,path:[i.id]});let s=no(i,n.parentViewport),a=mT(i,s.viewport,[]);if(!s.viewport.frame||s.pivotRequired&&!s.pivotResolved)return Er(null,a,"unresolved");let c=ve(n.toTarget??He,ya(i,s.matrix,r)),l=s.viewport.frame;return{bounds:_b({minX:l.x,minY:l.y,maxX:l.x+l.width,maxY:l.y+l.height},c),status:"resolved",diagnostics:a}}function yT(e,t,n){let r=n.view.duplicateShapeIds?.().has(t)??!1;return Or("unresolved",{code:r?"duplicate-shape-id":"unresolved-reference-target",shapeId:e.id,message:r?`Shape reference ${e.id} targets ambiguous duplicate id ${t}.`:t?`Shape reference ${e.id} targets ${t}, which is not present in the document.`:`Shape reference ${e.id} has no targetShapeId.`,path:t?[...n.path,t]:[...n.path]})}function tV(e,t){let n=[...t.path,e.id];return Or("cycle",{code:"reference-cycle",shapeId:e.id,message:`Shape reference cycle detected: ${n.join(" -> ")}.`,path:n})}function ST(e,t,n,r,i){if(!An(e.state))return{matrix:ir(e.state),attribute:sn(e.state),pivotRequired:!1,pivotResolved:!0,diagnostics:[],contentBounds:null};let s=lt(t.offsetX,t.offsetY),a={width:t.width,height:t.height},c=gT(Ml(n,s,r,i,a),e.id),l=c.diagnostics.some(u=>u.code==="unsupported-shape"||u.code==="deferred-tree-kind"||u.code==="unresolved-reference-pivot"),d=c.bounds&&!l?{x:(c.bounds.minX+c.bounds.maxX)/2,y:(c.bounds.minY+c.bounds.maxY)/2}:null;if(!d){let u=c.bounds===null&&(c.status==="empty"||c.status==="cycle"||c.status==="unresolved"),f={code:"unresolved-reference-pivot",shapeId:e.id,message:`Shape reference ${e.id} has decomposed rotation/scale/skew channels, but its translated target bounds require unavailable contextual geometry or measurement.`,path:[...r.path]};return{matrix:ir(e.state),attribute:sn(e.state),pivotRequired:!0,pivotResolved:u,diagnostics:u?c.diagnostics:[...c.diagnostics,f],contentBounds:c}}return{matrix:ir(e.state,d),attribute:sn(e.state,d),pivotRequired:!0,pivotResolved:!0,diagnostics:[],contentBounds:c}}function nV(e,t,n,r,i){if(r.activeReferences.has(e.id))return tV(e,r);r.activeReferences.add(e.id),r.path.push(e.id);let o=u=>(r.path.pop(),r.activeReferences.delete(e.id),u),s=t.targetShapeId?.trim()??"",a=s?r.view.shape(s):void 0;if(!a)return o(yT(e,s,r));if(!$l(a,r.host))return o(Kp());let c=ST(e,t,a,r,i);if(c.pivotRequired&&!c.pivotResolved)return o(Er(null,[...c.diagnostics],"unresolved"));if(c.contentBounds?.bounds===null&&c.pivotResolved)return o(c.contentBounds);let l=ve(ve(n,ya(e,c.matrix,r.host)),lt(t.offsetX,t.offsetY)),d=gT(Ml(a,l,r,i,{width:t.width,height:t.height}),e.id);return o({...d,diagnostics:[...c.diagnostics,...d.diagnostics]})}function ha(e,t){let n=e.state.instancePresentation?.transform,r=typeof n=="string"&&n.trim()?n.trim():null,i=ir(e.state,t),o=sn(e.state,t);return r?{matrix:ve(Tn(r),i),attribute:o?`${r} ${o}`:r}:{matrix:i,attribute:o}}function Xo(e,t,n,r){return{code:n,shapeId:e.id,message:r,path:[...t.path,e.id]}}function bT(e,t,n,r,i,o){let s=null,a=[];for(let c of n){if(!$l(c,i.host))continue;let l=Ml(c,r,i,o);s=Dl(s,l.bounds),a.push(...l.diagnostics)}for(let c of t.definitionContentOrder??[]){if(c.kind!=="definition")continue;let l=i.view.libraryDefinition?.(c.id);if(!l||l.kind!=="symbol"){a.push(Xo(e,i,"unresolved-symbol-definition",`Nested definition ${c.id} is missing from ${t.id}.`));continue}if((l.defKind??"symbol")==="symbol"||!pT(l,e,i.host))continue;let d=`definition-forest\0${l.id}`;if(i.activeSymbols.has(d)){a.push(Xo(e,i,"symbol-cycle",`Nested definition forest cycle detected through ${l.id}.`));continue}i.activeSymbols.add(d),i.path.push(l.id);let u=l.rootAttributes?.transform,f=u?ve(r,Tn(u)):r,p=bT(e,l,l.shapes,f,i,o);i.path.pop(),i.activeSymbols.delete(d),s=Dl(s,p.bounds),a.push(...p.diagnostics)}return Er(s,a)}function vT(e,t,n,r,i,o=!1){let s=Ro(t,e),a=ga(e,t,i,{resolveLength:r.host.resolveSymbolLength}),c=[...s.diagnostics.map(g=>Xo(e,r,g.code,g.message)),...a.diagnostics.map(g=>Xo(e,r,g.code==="invalid-symbol-length"||g.code==="invalid-symbol-viewbox"?"invalid-symbol-viewport":"unresolved-symbol-viewport",g.message))];if(!a.renders){let g=a.viewport?.status==="zero-disabled";return{...Er(null,c,g?"empty":"unresolved"),transform:{...ha(e),pivotRequired:An(e.state),pivotResolved:!0,diagnostics:c}}}if(!pT(t,e,r.host))return{...Kp(),transform:{...ha(e),pivotRequired:An(e.state),pivotResolved:!0,diagnostics:c}};if(r.activeSymbols.has(s.materializationKey)){let g=Xo(e,r,"symbol-cycle",`Symbol instance cycle detected through ${t.id}.`);return{...Or("cycle",g),transform:{...ha(e),pivotRequired:An(e.state),pivotResolved:!0,diagnostics:[g]}}}r.activeSymbols.add(s.materializationKey),r.identityPrefixes.push(s.materializationKey),r.forceInlineChildren++,r.path.push(e.id);let l=g=>bT(e,t,s.shapes,g,r,a.childPercentBasis??i),d=An(e.state),u=ha(e),f=!d,p=[];if(d){let g=l(a.contentMatrix),h=g.diagnostics.some(S=>S.code==="unsupported-shape"||S.code==="deferred-tree-kind"||S.code==="unresolved-symbol-viewport"),y=g.bounds&&!h?{x:(g.bounds.minX+g.bounds.maxX)/2,y:(g.bounds.minY+g.bounds.maxY)/2}:void 0;if(y)u=ha(e,y),f=!0;else{let S=g.bounds===null&&(g.status==="empty"||g.status==="cycle"||g.status==="unresolved");f=S,S||(p=[Xo(e,r,"unresolved-symbol-pivot",`Symbol instance ${e.id} needs unavailable contextual geometry or measurement for its decomposed transform pivot.`)]),S&&!o&&(p=[...g.diagnostics])}}let m;if(d&&!f)m=Er(null,[...c,...p],"unresolved");else{let g=ve(ve(n,ya(e,u.matrix,r.host)),a.contentMatrix),h=l(g);m=Er(h.bounds,[...c,...p,...h.diagnostics],h.status)}return r.path.pop(),r.forceInlineChildren--,r.identityPrefixes.pop(),r.activeSymbols.delete(s.materializationKey),{...m,transform:{...u,pivotRequired:d,pivotResolved:f,diagnostics:[...c,...p]}}}function rV(e,t,n,r){let i=String(e.state.symbolId??"").trim(),o=i?n.view.duplicateLibraryIds?.().has(i)??!1:!1,s=i?n.view.libraryDefinition?.(i):void 0;if(o||!s||s.kind!=="symbol")return Or("unresolved",Xo(e,n,o?"duplicate-library-id":"unresolved-symbol-definition",o?`Symbol instance ${e.id} targets duplicate library id ${i}.`:`Symbol instance ${e.id} targets missing symbol definition ${i||"(blank)"}.`));let a=vT(e,s,t,n,r),{transform:c,...l}=a;return l}function Ml(e,t,n,r,i={}){let o=uT(e,n);if(n.active.has(o)){if(!n.collectDiagnostics)return{bounds:null,status:"cycle",diagnostics:[]};let l=[...n.path,e.id];return Or("cycle",{code:"container-cycle",shapeId:e.id,message:`Container cycle detected: ${l.join(" -> ")}.`,path:l})}let s=Vn(e);if(!s)return Fb(e,s,t,n.host);if(s.kind==="shape-reference")return nV(e,s,t,n,r);if(s.kind==="embedded-svg")return eV(e,t,n,r,i);if(s.kind==="symbol-instance")return rV(e,t,n,r);if(s.kind!=="container"){let l=ir(e.state,s.defaultPivot??void 0);return Fb(e,s,ve(t,ya(e,l,n.host)),n.host)}n.active.add(o),n.path.push(e.id);let a=ma(e.state).matrix;if(An(e.state)){let l=n.collectDiagnostics;n.collectDiagnostics=!1;let d=Wp(e,He,n,r);n.collectDiagnostics=l;let u=d.diagnostics.some(f=>f.code==="unsupported-shape"||f.code==="deferred-tree-kind");a=El(e.state,u?null:d.bounds).matrix}let c=Wp(e,ve(t,ya(e,a,n.host)),n,r);return n.path.pop(),n.active.delete(o),c}function ti(e,t,n={},r={}){let i=typeof t=="string"?e.shape(t):t;if(!i){let o=typeof t=="string"?t:t.id;return Or("unresolved",{code:"unresolved-shape",shapeId:o,message:`Shape ${o} is not present in the document bounds view.`,path:[o]})}return Ml(i,n.toTarget??He,{view:e,host:r,active:new Set,activeReferences:new Set,activeSymbols:new Set,identityPrefixes:[],forceInlineChildren:0,path:[],collectDiagnostics:!0},n.parentViewport)}function Sa(e,t,n={},r={}){let i=typeof t=="string"?e.shape(t):t;if(!i){let s=typeof t=="string"?t:t.id;return Or("unresolved",{code:"unresolved-shape",shapeId:s,message:`Shape ${s} is not present in the document bounds view.`,path:[s]})}let o={...r,resolveOwnTransform:(s,a)=>s===i?He:r.resolveOwnTransform?.(s,a)??a};return ti(e,i,{parentViewport:n.parentViewport},o)}function Xp(e,t,n={},r){let i=Vn(t);if(!i||i.kind!=="shape-reference")return{matrix:He,attribute:null,pivotRequired:!1,pivotResolved:!1,diagnostics:[]};let o={view:e,host:n,active:new Set,activeReferences:new Set([t.id]),activeSymbols:new Set,identityPrefixes:[],forceInlineChildren:0,path:[t.id],collectDiagnostics:!0},s=i.targetShapeId?.trim()??"",a=s?e.shape(s):void 0;if(!a||!$l(a,n)){let l=An(t.state);return{matrix:ir(t.state),attribute:sn(t.state),pivotRequired:l,pivotResolved:!0,diagnostics:a?[]:yT(t,s,o).diagnostics}}let c=ST(t,i,a,o,r);return{matrix:c.matrix,attribute:c.attribute,pivotRequired:c.pivotRequired,pivotResolved:c.pivotResolved,diagnostics:c.diagnostics}}function Yp(e,t,n={},r){let i=An(t.state),o=String(t.state.symbolId??"").trim(),s=o?e.duplicateLibraryIds?.().has(o)??!1:!1,a=o?e.libraryDefinition?.(o):void 0;return s||!a||a.kind!=="symbol"?{...ha(t),pivotRequired:i,pivotResolved:!0,diagnostics:[]}:vT(t,a,He,{view:e,host:n,active:new Set,activeReferences:new Set,activeSymbols:new Set,identityPrefixes:[],forceInlineChildren:0,path:[],collectDiagnostics:!0},r,!0).transform}function xT(e,t={},n={}){let r=null,i=[];for(let o of e.roots()){if(!$l(o,n))continue;let s=ti(e,o,t,n);r=Dl(r,s.bounds),i.push(...s.diagnostics)}return Er(r,i)}function qp(e,t={}){if(!An(e.state))return{transform:ma(e.state),contentBounds:null,pivotRequired:!1,pivotResolved:!0};let i={view:Dr({shapes:[e],viewboxes:[]}),host:t,active:new Set([`document\0${e.id}`]),activeReferences:new Set,activeSymbols:new Set,identityPrefixes:[],forceInlineChildren:0,path:[e.id],collectDiagnostics:!0},o=Wp(e,He,i),a=o.diagnostics.some(c=>c.code==="unsupported-shape"||c.code==="deferred-tree-kind")?null:o.bounds;return{transform:El(e.state,a),contentBounds:o,pivotRequired:!0,pivotResolved:a!==null||o.status==="empty"}}function ba(e,t=e.id){return{kind:"pattern",id:t,name:e.name??t,pattern:{type:"pattern",svgContent:e.svgContent,width:e.width,height:e.height,patternType:"custom",color:"#000000",backgroundColor:"transparent",scale:1,rotation:0,opacity:1,patternUnits:"userSpaceOnUse"}}}function Zp(e){if(e.builtIn)return!1;let t=e.pattern;return!t||typeof t!="object"?!1:t.patternType==="custom"&&typeof t.svgContent=="string"}var iV=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?(?:px)?$/u;function IT(e,t){if(e.patternUnits!=="userSpaceOnUse")return;let n=e.authoredGeometry?.[t]?.trim();if(n===void 0||!iV.test(n))return;let r=Number.parseFloat(n);return Number.isFinite(r)&&r>0?r:void 0}function Qp(e){let t=(e.viewBox??"").trim().split(/[\s,]+/).filter(o=>o.length>0).map(Number),n=t.length===4&&t.every(o=>Number.isFinite(o)),r=n&&t[2]>0?t[2]:e.width??IT(e,"width")??10,i=n&&t[3]>0?t[3]:e.height??IT(e,"height")??10;return{width:r,height:i}}function Jp(e){if(!Zp(e))return null;let{width:t,height:n}=Qp(e.pattern);return{id:e.id,name:e.name,svgContent:e.pattern.svgContent??"",width:t,height:n}}function oV(e,t){let n=new Map(t.map(o=>[o.id,o])),r=typeof e=="string"?n.get(e):e,i=new Set;for(;r?.kind==="pattern";){if(i.has(r.id))return null;if(i.add(r.id),Zp(r))return r;let o=r.pattern?.templateId;if(!o)return null;r=n.get(o)}return null}function wT(e,t){let n=oV(e,t);if(!n)return null;let{width:r,height:i}=Qp(YS(n,t)??n.pattern);return{id:n.id,name:n.name,svgContent:n.pattern.svgContent??"",width:r,height:i}}function sV(){let e=new Set(Wh);for(let t of Xh)e.add(t);for(let t of Pe.typeIds())for(let n of Object.keys(Pe.getDefaults(t)))e.add(n);return e.delete("scaleAnchor"),e.delete("extra"),e}var Bb=sV(),kT=new Set(["scaleAnchor","displayAttr"]);function zl(e){let t=e.extra&&typeof e.extra=="object"&&!Array.isArray(e.extra)?e.extra:void 0;for(let n of Object.keys(e)){if(n==="extra"||Bb.has(n))continue;let r=e[n];delete e[n],r!==void 0&&((t??={})[n]=r)}return t&&Object.keys(t).length>0?e.extra=t:delete e.extra,e}function em(e){return bn(e,{onState:t=>{zl(t)}}),e}function tm(e){return bn(e,{onState:t=>{ro(t)}}),e}function ro(e){let t=e.extra;if(!t||typeof t!="object"||Array.isArray(t))return delete e.extra,e;for(let[n,r]of Object.entries(t))n!=="extra"&&(n in e||(e[n]=r));return delete e.extra,e}function Vb(e){return typeof e=="string"&&e.length>0?e:null}function aV(e){let t=Vb(e.groupId);if(t)return t;let n=e.extra;return!n||typeof n!="object"||Array.isArray(n)?null:Vb(n.groupId)}function PT(e){delete e.groupId;let t=e.extra;if(!t||typeof t!="object"||Array.isArray(t))return;let n=t;delete n.groupId,Object.keys(n).length===0&&delete e.extra}function cV(e){let t={};return e.transformOrigin&&(t.transformOrigin=e.transformOrigin),e.pluginId&&(t.pluginId=e.pluginId),e.pluginData&&(t.pluginData=e.pluginData),e.attributes&&Object.keys(e.attributes).length>0&&(t.attributes=e.attributes),e.fill&&(t.fill=e.fill),e.fillOpacity&&(t.fillOpacity=e.fillOpacity),e.strokeOpacity&&(t.strokeOpacity=e.strokeOpacity),e.opacity&&(t.opacity=e.opacity),e.filter&&(t.filter=e.filter),e.cssFilter&&(t.cssFilter=e.cssFilter),e.mixBlendMode&&(t.mixBlendMode=e.mixBlendMode),e.isolation&&(t.isolation=e.isolation),e.clipPath&&(t.clipPath=e.clipPath),e.mask&&(t.mask=e.mask),e.rawMetadata&&(t.rawMetadata=e.rawMetadata),e.transform&&(t.transform=e.transform),t}function lV(e){let t=cV(e),n={fillColor:null,borderColor:null,rotation:0,skewX:0,skewY:0,customPivot:null};return Object.keys(t).length>0&&(n.groupData=t),{id:e.id,type:"group",state:n}}function TT(e,t){let n=e.state.children;if(Array.isArray(n))for(let r of n)t.add(r.id),TT(r,t)}function RT(e,t=!1){let n=e.state,r=n.children;return t&&PT(n),Array.isArray(r)&&(n.children=r.map(i=>RT(i,!0))),e}function dV(e){if(e.length<2)return e.map(s=>s.shape);let t=e.filter(s=>s.shape.type==="group"&&s.siblingIndex!==void 0&&Number.isFinite(s.siblingIndex)).sort((s,a)=>(s.siblingIndex??0)-(a.siblingIndex??0));if(t.length===0)return[...e].sort((s,a)=>s.flatOrder-a.flatOrder).map(s=>s.shape);let n=Array(e.length).fill(null),r=new Set(t);for(let s of t){let a=Math.max(0,Math.min(e.length-1,s.siblingIndex??0));for(;a<n.length&&n[a]!==null;)a++;if(a>=n.length)for(a=n.length-1;a>=0&&n[a]!==null;)a--;a>=0&&(n[a]=s)}let i=e.filter(s=>!r.has(s)).sort((s,a)=>s.flatOrder-a.flatOrder),o=0;for(let s of i){for(;o<n.length&&n[o]!==null;)o++;o<n.length&&(n[o]=s)}return n.filter(s=>s!==null).map(s=>s.shape)}function Fl(e,t=[]){let n=structuredClone(e),r=structuredClone(t),i=new Map;for(let h of r)i.set(h.id,h);let o=n.map(h=>RT(h)),s=new Set;for(let h of o)TT(h,s);let a=new Map,c=new Map;o.forEach((h,y)=>{s.has(h.id)||c.has(h.id)||(a.set(h.id,y),c.set(h.id,h))});for(let h of r){if(s.has(h.id)||c.has(h.id))continue;let y=lV(h);a.set(y.id,Number.POSITIVE_INFINITY),c.set(y.id,y)}let l=new Map,d=new Map;for(let h of c.values()){let y=h.state,S=i.get(h.id),b=aV(y)??(h.type==="group"?Vb(S?.parentId):null),I=l.get(b)??[];d.set(h.id,b),I.push({shape:h,flatOrder:a.get(h.id)??Number.POSITIVE_INFINITY,siblingIndex:h.type==="group"?S?.siblingIndex:void 0}),l.set(b,I)}let u=new Set,f=h=>{if(u.has(h.id))return null;u.add(h.id);let y=h.state,S=Array.isArray(y.children)?y.children:[],b=p(h.id),I=new Set(S.map(w=>w.id)),v=[...S,...b.filter(w=>!I.has(w.id))];return v.length>0?y.children=v:delete y.children,PT(y),h},p=h=>{let y=[];for(let S of dV(l.get(h)??[])){let b=f(S);b&&y.push(b)}return y},m=p(null),g=h=>{if(!h)return;let y=f(h);y&&m.push(y)};for(let h of c.values()){let y=d.get(h.id);y&&!c.has(y)&&g(h)}for(let h of r)g(c.get(h.id));for(let h of c.values())g(h);return m}var Ll="data-svgsketch-passthrough",uV=new Set(["mask","clipPath","filter","linearGradient","radialGradient","pattern","symbol"]),fV=/^<([A-Za-z][\w:-]*)\b[^>]*>/;function CT(e){return fV.exec(e.trimStart())}function _l(e){let t=CT(e);if(!t)return null;let n=/\bid\s*=\s*(?:"([^"]*)"|'([^']*)')/.exec(t[0]);return n?n[1]??n[2]:null}function pV(e){let t=CT(e);if(!t)return null;let n=t[1],r=n.lastIndexOf(":");return r>=0?n.slice(r+1):n}var mV=new RegExp(`\\s+${Ll}\\s*=\\s*(?:"[^"]*"|'[^']*')`);function Bl(e){let t=e.markup.indexOf(">");if(t<0)return e;let n=e.markup.slice(0,t+1),r=mV.exec(n);if(!r)return e;let i=n.slice(0,r.index)+n.slice(r.index+r[0].length);return{...e,markup:i+e.markup.slice(t+1),passthrough:!0}}function AT(e){let t=[];for(let n of e){if(typeof n!="string")continue;let r=_l(n);if(!r)continue;let i=pV(n),o=i&&uV.has(i)?i:"mask";t.push(Bl({id:r,type:o,markup:n}))}return t}var gV=[["splinePoints","pathPoints"],["splineClosed","pathClosed"],["splineCurveType","pathCurveType"],["splineTension","pathTension"],["splineArcParams","pathArcParams"],["splineControlBounds","pathControlBounds"]];function hV(e){let t=!1;if(e.type==="spline"&&(e.type="path",t=!0),e.state&&typeof e.state=="object"){let n=e.state,r=n.extra&&typeof n.extra=="object"&&!Array.isArray(n.extra)?n.extra:null;for(let[i,o]of gV)Object.prototype.hasOwnProperty.call(n,i)&&(Object.prototype.hasOwnProperty.call(n,o)||(n[o]=n[i]),Reflect.deleteProperty(n,i),t=!0),r&&Object.prototype.hasOwnProperty.call(r,i)&&(Object.prototype.hasOwnProperty.call(n,o)||(n[o]=r[i]),delete r[i],t=!0);r&&Object.keys(r).length===0&&delete n.extra}return t}function NT(e){return mt(e,{onShape:t=>{hV(t)}}),e}function yV(e){if(e.type!=="connector")return;let t=e.state,n=Vl(t.sourcePoint),r=Vl(t.targetPoint);e.type="line",e.state={...e.state,x1:typeof t.x1=="number"?t.x1:n?.x??0,y1:typeof t.y1=="number"?t.y1:n?.y??0,x2:typeof t.x2=="number"?t.x2:r?.x??0,y2:typeof t.y2=="number"?t.y2:r?.y??0,routingMode:t.routingMode??"orthogonal"}}function $T(e){let t=e.customPivot;if(t)return t;let n=e.x,r=e.y,i=e.width,o=e.height;if(typeof n=="number"&&typeof r=="number"&&typeof i=="number"&&typeof o=="number")return{x:n+i/2,y:r+o/2};let s=e.radius;if(typeof n=="number"&&typeof r=="number"&&typeof s=="number")return{x:n,y:r};let a=e.cx,c=e.cy;if(typeof a=="number"&&typeof c=="number")return{x:a,y:c};let l=e.x1,d=e.y1,u=e.x2,f=e.y2;if(typeof l=="number"&&typeof d=="number"&&typeof u=="number"&&typeof f=="number")return{x:(l+u)/2,y:(d+f)/2};let p=e.pathPoints;if(p?.[0])return{x:p[0].x,y:p[0].y};let m=e.polylinePoints;if(m?.[0])return{x:m[0].x,y:m[0].y}}function SV(e){return mt(e,{onShape:t=>{let n=t.state;!n||typeof n!="object"||vy(n,$T(n))}}),e.schemaVersion=3,e}function Vl(e){let t=e;return t&&typeof t.x=="number"&&Number.isFinite(t.x)&&typeof t.y=="number"&&Number.isFinite(t.y)?{x:t.x,y:t.y}:null}function bV(e,t){let n=e.translateX??0,r=e.translateY??0,i=typeof e.rawTransform=="string"?e.rawTransform:"",o=lt(n,r);if(i)return Pt(ve(o,Tn(i)));let s=e.rotation??0,a=e.skewX??0,c=e.skewY??0;if(s!==0||a!==0||c!==0){let u=Vl(e.customPivot)??t??Vl(e.scaleAnchor);u&&(o=ve(o,lt(u.x,u.y)),s!==0&&(o=ve(o,Ts(s))),a!==0&&(o=ve(o,vc(a))),c!==0&&(o=ve(o,xc(c))),o=ve(o,lt(-u.x,-u.y)))}let l=e.scaleX??1,d=e.scaleY??1;if(l!==1||d!==1){let u=Vl(e.scaleAnchor)??t;u&&(o=ve(o,lt(u.x,u.y)),o=ve(o,wo(l,d)),o=ve(o,lt(-u.x,-u.y)))}return Pt(o)}function vV(e){return mt(e,{onShape:t=>{let n=t.state;!n||typeof n!="object"||!("scaleAnchor"in n)||(t.type==="text"&&!mi(n.transformMatrix)&&(n.transformMatrix=bV(n,$T(n))),delete n.scaleAnchor)}}),e.schemaVersion=4,e}function xV(e){let t=e,n=Array.isArray(e.library)?[...e.library]:[],r=new Set(n.map(l=>l.id));if(Array.isArray(t.symbols))for(let l of t.symbols)!l||r.has(l.id)||(n.push({...l,kind:"symbol"}),r.add(l.id));if(Array.isArray(t.markers))for(let l of t.markers)!l||r.has(l.id)||(n.push({...l,kind:"marker"}),r.add(l.id));let i=new Map,o=(l,d)=>{let{id:u,sourceId:f,...p}=l,m=JSON.stringify({kind:d,...p}),g=i.get(m);if(g)return g;let h=r.has(l.id)?`grd-${nm()}`:l.id;r.add(h),i.set(m,h);let y=d==="linear-gradient"?{kind:"linear-gradient",id:h,name:l.sourceId??h,sourceId:l.sourceId,gradient:ET(l)}:{kind:"radial-gradient",id:h,name:l.sourceId??h,sourceId:l.sourceId,gradient:ET(l)};return n.push(y),h},s=new Map;if(Array.isArray(t.customPatterns))for(let l of t.customPatterns){if(!l)continue;let d=r.has(l.id)?`pat-${nm()}`:l.id;r.add(d),s.set(l.id,d),n.push(ba(l,d))}let a=l=>{if(l.customPatternId){let S=s.get(l.customPatternId);if(S)return S}let{id:d,sourceId:u,customPatternId:f,...p}=l,m=JSON.stringify({kind:"pattern",...p}),g=i.get(m);if(g)return g;let h=r.has(l.id)?`pat-${nm()}`:l.id;r.add(h),i.set(m,h);let y={kind:"pattern",id:h,name:l.sourceId??h,sourceId:l.sourceId,pattern:p};return n.push(y),h};for(let l of e.shapes??[]){let d=l.state;if(!d)continue;let u=d.fillGradient;u&&(typeof d.fillType!="string"&&(d.fillType=u.type),u.type==="linear-gradient"||u.type==="radial-gradient"?d.fillLibraryId=o(u,u.type):u.type==="pattern"&&(d.fillLibraryId=a(u)));let f=d.strokeGradient;f&&(typeof d.strokeType!="string"&&(d.strokeType=f.type),f.type==="linear-gradient"||f.type==="radial-gradient"?d.strokeLibraryId=o(f,f.type):f.type==="pattern"&&(d.strokeLibraryId=a(f)));let p=d.filters;if(Array.isArray(p)&&p.length>0){let m=c(p,d,l.id);d.filterLibraryIds=[m]}}return e.library=n,mt(e,{onShape:yV}),delete t.customPatterns,delete t.symbols,delete t.markers,e;function c(l,d,u){let f={filters:l,colorInterpolation:d.filterColorInterpolation,filterUnits:d.filterUnits,primitiveUnits:d.primitiveUnits,x:d.filterX,y:d.filterY,width:d.filterWidth,height:d.filterHeight},p=JSON.stringify({kind:"filter",...f}),m=i.get(p);if(m)return m;let g=`filter-${u}`,h=r.has(g)?`flt-${nm()}`:g;r.add(h),i.set(p,h);let y={kind:"filter",id:h,name:h,filters:f.filters,...f.colorInterpolation?{colorInterpolation:f.colorInterpolation}:{},...f.filterUnits?{filterUnits:f.filterUnits}:{},...f.primitiveUnits?{primitiveUnits:f.primitiveUnits}:{},...f.x!==void 0?{x:f.x}:{},...f.y!==void 0?{y:f.y}:{},...f.width!==void 0?{width:f.width}:{},...f.height!==void 0?{height:f.height}:{}};return n.push(y),h}}function ET(e){let{id:t,sourceId:n,...r}=e;return r}var Gb=0;function nm(){return Gb=Gb+1&65535,`${Date.now().toString(36)}-${Gb.toString(36)}`}function IV(e){return mt(e,{onState:t=>{let n=t,r=Object.prototype.hasOwnProperty.call(n,"richTextData"),i=n.richTextData;if(zl(t),!r)return;n.richTextData=i;let o=t.extra;o&&(delete o.richTextData,Object.keys(o).length===0&&delete t.extra)}}),e.schemaVersion=5,e}function wV(e){if(!e||typeof e!="object"||Array.isArray(e))return;let t=e;if(t.richTextRuns!==void 0&&t.richTextRuns!==null)return;let n=t.richTextData;!n||typeof n!="object"||Array.isArray(n)||Array.isArray(n.lines)&&(t.richTextRuns=yi(n))}function kV(e){return mt(e,{onState:t=>wV(t)}),e.schemaVersion=6,e}function jb(e,t){if(!t.has(e))return e;let n=2;for(;t.has(`${e}-${n}`);)n++;return`${e}-${n}`}function va(e){let t=new Set,n=new Set,r=new Map;mt(e,{onShape:o=>{if(n.add(o.id),o.type!=="view")return;r.has(o.id)||r.set(o.id,o);let s=o.state.viewName;typeof s=="string"&&s&&t.add(s)}});let i=[];return(e.viewboxes??[]).filter(o=>{let s=r.get(o.id);return!(s&&s.state.viewBoxX===o.x&&s.state.viewBoxY===o.y&&s.state.viewBoxWidth===Math.max(1,o.width)&&s.state.viewBoxHeight===Math.max(1,o.height))}).forEach((o,s)=>{let a=jb(`view-${s+1}`,t);t.add(a);let c=jb(o.id||`legacy-view-${s+1}`,n);n.add(c),i.push({id:c,type:"view",state:{viewBoxX:o.x,viewBoxY:o.y,viewBoxWidth:Math.max(1,o.width),viewBoxHeight:Math.max(1,o.height),viewName:a}})}),i.length>0&&e.shapes.unshift(...i),e.viewboxes=[],e}var PV=["svgX","svgY","svgWidth","svgHeight","svgViewBoxX","svgViewBoxY","svgViewBoxWidth","svgViewBoxHeight","svgPreserveAspectRatio"];function TV(e){if(e.type!=="svg"||e.state.isRootSvg===!0)return;let t=e.state;if(![t.svgViewBoxX,t.svgViewBoxY,t.svgViewBoxWidth,t.svgViewBoxHeight].every(i=>i===0))return;if(t.svgX===0&&t.svgY===0&&t.svgWidth===0&&t.svgHeight===0&&t.svgPreserveAspectRatio===""){for(let i of PV)delete t[i];return}delete t.svgViewBoxX,delete t.svgViewBoxY,delete t.svgViewBoxWidth,delete t.svgViewBoxHeight}function Ub(e){return mt(e,{onShape:TV}),va(e),e.schemaVersion=7,e}var RV=["viewBox","preserveAspectRatio","x","y","width","height","refX","refY"];function CV(e,t){if(e.type!=="symbol-instance"||e.state.authoredUseGeometry!==void 0)return;let n={};for(let r of["x","y","width","height"]){if((r==="width"||r==="height")&&t.has(String(e.state.symbolId??"")))continue;let i=e.state[r];typeof i=="number"&&Number.isFinite(i)&&(n[r]=String(i))}Object.keys(n).length>0&&(e.state.authoredUseGeometry=n)}function AV(e){let t=new Set((e.library??[]).filter(n=>n.kind==="symbol"&&n.defKind==="group").map(n=>n.id));for(let n of e.library??[]){if(n.kind!=="symbol")continue;let r=n,i={...r.wrapperAttrs??{},...r.rootAttributes??{}};for(let s of RV){let a=i[s];r[s]===void 0&&a!==void 0&&(r[s]=a),delete i[s]}if(r.overflow!==void 0&&i.overflow===void 0&&(i.overflow=r.overflow),Object.keys(i).length>0?r.rootAttributes=i:delete r.rootAttributes,r.shapes=Fl(r.shapes,r.groups),r.variants)for(let[s,a]of Object.entries(r.variants))r.variants[s]=Fl(a,r.groups);let o=r;delete o.wrapperAttrs,delete o.groups,delete o.overflow}return mt(e,{onShape:n=>CV(n,t)}),e.schemaVersion=8,e}function NV(e){let t=e;Array.isArray(e.shapes)&&(e.shapes=Fl(e.shapes,t.groups)),delete t.groups,Array.isArray(t.rawPaintServerDefs)&&!Array.isArray(e.paintServerDefs)&&(e.paintServerDefs=AT(t.rawPaintServerDefs)),delete t.rawPaintServerDefs;for(let n of e.library??[]){if(n.kind!=="marker")continue;let r=n;r.shapes=Fl(r.shapes,r.groups),delete r.groups}return Array.isArray(t.clipMaskGroups)&&(e.clipMaskGroups=t.clipMaskGroups.map(n=>{let r=n,i=Array.isArray(r.clipShapeIds)?r.clipShapeIds:typeof r.clipShapeId=="string"&&r.clipShapeId.length>0?[r.clipShapeId]:[],o={...r,clipShapeIds:i};return delete o.clipShapeId,o})),e.schemaVersion=9,e}function EV(e){return mt(e,{onState:t=>{let n=t;n.richTextRuns===void 0&&n.richTextData!==null&&typeof n.richTextData=="object"&&Array.isArray(n.richTextData.lines)&&(n.richTextRuns=yi(n.richTextData)),delete n.richTextData}}),e.schemaVersion=10,e}function OV(e){let n=(Array.isArray(e)?e.slice(0,6).join(" "):String(e)).trim().toLowerCase();return n==="none"||n==="hidden"||n==="collapse"?"none":"inline"}function OT(e){let t=new Set(e.keyframes.flatMap(n=>n.id?[n.id]:[]));if(e.keyframes.forEach((n,r)=>{if(n.id)return;let i=`kf${r}`;for(;t.has(i);)i=`${i}x`;n.id=i,t.add(i)}),e.property==="visibility"&&e.sourceSmilAttribute==="display"){e.property="display";for(let n of e.keyframes)n.value=OV(n.value)}delete e.sourceSmilAttribute}function DV(e){if(!Array.isArray(e.shapes))return;let t=new Map,n=new Map,r=new Map,i=(s,a)=>{let c=a?n:t,l=c.get(s.id)??[];l.push(s),c.set(s.id,l),r.set(s.id,(r.get(s.id)??0)+1);let d=s.state.children;Array.isArray(d)&&d.forEach(u=>i(u,!0))};e.shapes.forEach(s=>i(s,!1));let o=new Set;for(let[s,a]of t)a.length!==1||r.get(s)!==2||(n.get(s)??[]).length===1&&o.add(s);e.shapes=e.shapes.filter(s=>!o.has(s.id))}function $V(e){if(!Array.isArray(e.shapes))return;mt(e,{onShape:a=>{if(a.type!=="view")return;let c=a.state;Reflect.deleteProperty(c,"viewLinkedSvgId"),typeof c.extra=="object"&&c.extra!==null&&!Array.isArray(c.extra)&&Reflect.deleteProperty(c.extra,"viewLinkedSvgId")}});let t=e.shapes.filter(a=>{if(a.type!=="view")return!1;let c=a.state;return c.isHomeView===!0||typeof c.extra=="object"&&c.extra!==null&&!Array.isArray(c.extra)&&c.extra.isHomeView===!0});if(t.length===0)return;let n=t[0].state,r=Number(n.viewBoxWidth??0),i=Number(n.viewBoxHeight??0),o=e.shapes.find(a=>a.type==="svg"&&a.state.isRootSvg===!0);if(o&&r>0&&i>0){let a=Number(o.state.svgViewBoxWidth??0),c=Number(o.state.svgViewBoxHeight??0);a>0&&c>0||(o.state.svgViewBoxX=Number(n.viewBoxX??0),o.state.svgViewBoxY=Number(n.viewBoxY??0),o.state.svgViewBoxWidth=r,o.state.svgViewBoxHeight=i,Number(o.state.svgWidth??0)>0||(o.state.svgWidth=r),Number(o.state.svgHeight??0)>0||(o.state.svgHeight=i))}let s=new Set(t.map(a=>a.id));e.shapes=e.shapes.filter(a=>!s.has(a.id)),e.sceneTree=e.sceneTree?.filter(a=>!s.has(a.id))}function MV(e){if(!Array.isArray(e.shapes))return;let t=new Set;mt(e,{onShape:i=>{typeof i.id=="string"&&t.add(i.id)}});let n=new Map,r=i=>i.map(o=>{let s=o.state.children;Array.isArray(s)&&(o.state.children=r(s));let a=o.state.metadata;if(!a||typeof a!="object"||Array.isArray(a))return o;let c=typeof a.linkUrl=="string"?a.linkUrl:"",l=typeof a.linkTarget=="string"?a.linkTarget:"";if(!Object.hasOwn(a,"linkUrl")&&!Object.hasOwn(a,"linkTarget"))return o;let{linkUrl:d,linkTarget:u,...f}=a;if(o.state.metadata=f,!c||o.type==="hyperlink")return o;let p=jb(`${o.id}-link`,t);return t.add(p),n.set(o.id,p),{id:p,type:"hyperlink",state:{href:c,...l?{linkTarget:l}:{},children:[o]}}});e.shapes=r(e.shapes);for(let i of e.library??[])if(!(i.kind!=="symbol"&&i.kind!=="marker")&&(i.shapes=r(i.shapes),i.kind==="symbol"&&i.variants))for(let[o,s]of Object.entries(i.variants))i.variants[o]=r(s);if(e.sceneTree&&n.size>0){let i=[];for(let o of e.sceneTree){let s=n.get(o.id);if(!s){i.push(o);continue}i.push({...o,id:s}),i.push({id:o.id,parentId:s,index:0})}e.sceneTree=i}}function zV(e){mt(e,{onState:t=>{(t.fillType==="linear-gradient"||t.fillType==="radial-gradient"||t.fillType==="pattern")&&t.fillColor==="none"&&t.fillOpacity===0&&(t.fillOpacity=1)}})}function FV(e){mt(e,{onState:t=>{Array.isArray(t.charOffsets)&&(t.charOffsets=t.charOffsets.map(n=>{if(!n||typeof n!="object"||"dx"in n||typeof n.x!="number")return n;let r=n;return{x:null,y:null,dx:r.x,dy:typeof r.y=="number"&&Number.isFinite(r.y)?r.y:0,rotate:typeof r.rotate=="number"&&Number.isFinite(r.rotate)?r.rotate:0}}))}})}function LV(e){mt(e,{onShape:t=>{if(t.type!=="group")return;let n=t.state,r=n.groupData;if(!r||typeof r!="object"||Array.isArray(r))return;let i=r,o=i.attributes;if(o&&typeof o=="object"&&!Array.isArray(o)){let s={...o};n.locked===void 0&&s["data-locked"]==="true"&&(n.locked=!0),n.visible===void 0&&s["data-hidden"]==="true"&&(n.visible=!1),delete s["data-locked"],delete s["data-hidden"],Object.keys(s).length>0?i.attributes=s:delete i.attributes}Array.isArray(i.classes)&&(i.classes=i.classes.map(s=>{let a=String(s);return a.startsWith("usr-")?a.slice(4):a}))}})}function _V(e){let t=NT(e);va(t),$V(t),DV(t),MV(t),zV(t),FV(t),LV(t);for(let n of t.animationTimeline?.tracks??[])OT(n);for(let n of t.library??[])if(!(n.kind!=="marker"&&n.kind!=="symbol"))for(let r of n.animations??[])OT(r);return t.schemaVersion=11,t}function Hb(e){return e.schemaVersion=12,e}function BV(e){return e.schemaVersion=13,e}function VV(e){return e.schemaVersion=14,e}function Kb(e){return mt(e,{onState:t=>{let n=t,r=n.authoredTextStructure;if(n.textSpanTree===void 0&&r&&typeof r.text=="string"&&Array.isArray(r.spans)){let i=r.spans.flatMap(o=>{if(!o||typeof o!="object"||Array.isArray(o))return[];let s=o;return typeof s.start=="number"&&typeof s.end=="number"&&typeof s.id=="string"?[{start:s.start,end:s.end,id:s.id,children:[]}]:[]});i.length===r.spans.length&&(n.textSpanTree={text:r.text,spans:i})}delete n.authoredTextStructure}}),e.schemaVersion=15,e}function Wb(e){return e.schemaVersion=16,e}function Xb(e){for(let t of e.documentStyles??[]){let n=t;n.placement??="root"}return e.schemaVersion=17,e}function Yb(e){return e.schemaVersion=18,e}function qb(e){return mt(e,{onState:t=>{let n=t;n.textPathReference===void 0&&typeof n.textPathRefShapeId=="string"&&n.textPathRefShapeId.length>0&&(n.textPathReference={kind:"shape",targetId:n.textPathRefShapeId,element:"href"}),delete n.textPathRefShapeId,delete n.textPathImportRefId}}),e.schemaVersion=19,e}function GV(e){return e.schemaVersion=20,e}function jV(e){return e.schemaVersion=21,e}function UV(e){let t=new Map,n=(r,i,o)=>{let s=r.textSpanTree;if(!s||typeof s!="object"||Array.isArray(s))return;let a=s.spans;if(!Array.isArray(a))return;let c=new Map,l=(d,u=[])=>{d.forEach((f,p)=>{if(!f||typeof f!="object"||Array.isArray(f))return;let m=f,g=[...u,p],h=typeof m.spanId=="string"&&m.spanId.length>0?m.spanId:`text-span:${i}:${g.join(".")}`;m.spanId=h,c.set(g.join("."),h),Array.isArray(m.children)&&l(m.children,g)})};l(a),o&&t.set(o,c)};return mt(e,{onShape:(r,i)=>n(r.state,r.id||i,r.id),onState:(r,i)=>n(r,i)}),e.animationTimeline&&(e.animationTimeline.tracks=e.animationTimeline.tracks.filter(r=>{let i=r.textSpanTarget;if(!i||Array.isArray(i.spanIds))return!0;let o=Array.isArray(i.path)?i.path:[],s=o.every(c=>Number.isInteger(c)&&Number(c)>=0)?o.join("."):"",a=s?t.get(r.shapeId)?.get(s):void 0;return a?(i.spanIds=[a],delete i.path,!0):!1})),e.schemaVersion=22,e}function HV(e){let t=pr(e),n=r=>{let i=r.authoredPlacement;if(!i||i.parentDefinitionId!==void 0)return;let o=t.resolve(i);o.kind==="library"&&(i.parentDefinitionId=o.definitionId)};for(let r of e.library??[])n(r);for(let r of e.paintServerDefs??[])n(r);for(let r of e.clipMaskGroups??[])n(r);return e.schemaVersion=23,e}function KV(e){return e.schemaVersion=24,e}function WV(e){return e.schemaVersion=25,e}function XV(e){return mt(e,{onShape(t){if(t.type!=="foreign-object")return;let n=t.state,r=n.rawContent;if(typeof r!="string")return;let i=Rn(`<svg xmlns="${te}"><foreignObject>${r}</foreignObject></svg>`,{source:"native-document",entrypoint:"full-snapshot-restore"}).value,o=i?.index.children(i.root.sourceNodeId).find(s=>s.localName.toLowerCase()==="foreignobject");n.foreignContent=o?structuredClone(aa(o.children)):r.length===0?[]:[{kind:"text",value:r}],delete n.rawContent}}),e.schemaVersion=26,e}function YV(e){let t=typeof e.shapeId=="string"?e.shapeId:"";if(t.startsWith("__dom__")&&t.length>7)return t.slice(7);let n=typeof e.domTargetSelector=="string"?e.domTargetSelector:"",r=/\[id\s*=\s*(["'])(.*?)\1\]/u.exec(n);return r?.[2]?r[2]:/^#([A-Za-z_][\w:.-]*)$/u.exec(n.trim())?.[1]??null}function DT(e,t){return e?Rn(`<svg xmlns="${te}">${e}</svg>`,{source:"native-document",entrypoint:"full-snapshot-restore"}).value?.nodes.some(r=>r.kind==="element"&&r.attributes.some(i=>i.namespaceUri===null&&i.localName==="id"&&i.value===t))??!1:!1}function qV(e,t){for(let n of e.clipMaskGroups??[]){let r=n.definitionId??`${n.type}-${n.id}`;if(r===t)return{definitionId:r};if(DT(n.rawDefinition,t))return{definitionId:r,nodeId:t}}for(let n of e.paintServerDefs??[]){if(n.id===t)return{definitionId:n.id};if(DT(n.markup,t))return{definitionId:n.id,nodeId:t}}for(let n of e.library??[]){if(n.id===t||n.sourceId===t)return{definitionId:n.id};if(n.kind==="filter")for(let r of n.filters){if(r.type!=="svg-primitive-chain")continue;let i=r.primitives.find(o=>o.id===t);if(i)return{definitionId:n.id,nodeId:i.id}}}return{definitionId:t}}function ZV(e){let t=typeof e.property=="string"?e.property:"";if(t==="domTransformStack")return"targetTransformStack";if(t==="domDisplay")return"targetDisplay";if(t==="domVisibility")return"targetVisibility";if(t!=="domAttribute")return t;let n=typeof e.domAttribute=="string"?e.domAttribute:"",r=n.toLowerCase();return new Map([["class","className"],["fill","fillColor"],["stroke","strokeColor"],["preserveaspectratio","svgPreserveAspectRatio"],["xlink:href","referenceTargetShapeId"],["href","referenceTargetShapeId"],["clippathunits","clipPathUnits"],["spreadmethod","spreadMethod"]]).get(r)??n}function QV(e){let t=e.animationTimeline;for(let n of t?.tracks??[]){let r=n,i=YV(r);if(!i)continue;let o=qV(e,i);r.definitionTarget=o,r.shapeId=vr(o),r.property=ZV(r),typeof r.domAttribute=="string"&&(r.targetAttribute=r.domAttribute),typeof r.domAttributeValueType=="string"&&(r.targetAttributeValueType=r.domAttributeValueType),delete r.domTargetSelector,delete r.domTargetIdGenerated,delete r.domAttribute,delete r.domAttributeValueType}return e.schemaVersion=27,e}function JV(e){return e.schemaVersion=28,e}function eG(e){let t=e.clipMaskGroups;if(!Array.isArray(t)||t.length===0)return e.schemaVersion=29,e;let n=new Set;for(let o of e.shapes)bn(o,{onShape:s=>n.add(s.id)});let r=new Set;for(let o of t){let s=typeof o.rawDefinition=="string"&&o.rawDefinition.length>0,a=o.clipShapeIds.some(c=>n.has(c));(s||a)&&r.add(`${o.type}\0${Lt(o)}`)}let i=t.filter(o=>r.has(`${o.type}\0${Lt(o)}`));return i.length!==t.length&&(e.clipMaskGroups=Yn(i),Nr(e)),e.schemaVersion=29,e}var Zb=Object.freeze({1:xV,2:SV,3:vV,4:IV,5:kV,6:Ub,7:AV,8:NV,9:EV,10:_V,11:Hb,12:BV,13:VV,14:Kb,15:Wb,16:Xb,17:Yb,18:qb,19:GV,20:jV,21:UV,22:HV,23:KV,24:WV,25:XV,26:QV,27:JV,28:eG});function tG(e){let t=e.schemaVersion;return typeof t!="number"||!Number.isFinite(t)||t<1?1:Math.floor(t)}function xa(e,t=Zb){let n=JSON.parse(JSON.stringify(e)),r=tG(n);if(r>Pn)return n;if(r===Pn)return n.schemaVersion=Pn,n;for(;r<Pn;){let i=t[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 ${Pn}.`);n=i(n),r+=1}return n.schemaVersion=Pn,n}var LT=["unknown-shape-diagnostic","symbol-variants-overrides","smil-timeline","motion-only-partition","paint-server-references","filter-references","document-definition-context","inline-child-containers","isolated-flowchart-nodes","text-path","common-presentation","gradient-definition-envelope","filter-definition-envelope","export-precision-rounding","defs-deduplication","source-id-restoration","orphan-def-exclusion","font-embedding","initial-value-elision","namespace-declaration-completion"],ge=e=>({mode:"supported",by:e}),io=e=>({mode:"diagnostic",signal:"warning",by:e}),Oe=e=>({mode:"outside-contract",reason:e}),_t=e=>e,MT=Oe("DXF is a static CAD geometry contract and has no representation for this SVG behavior."),zT=Oe("Mermaid is a static graph-structure contract and has no representation for this SVG behavior."),FT=Oe("PDF export produces a static page from the current editor SVG projection and does not promise animation playback."),_T={"unknown-shape-diagnostic":_t({renderToSvg:io("renderShape reports UNSUPPORTED_SHAPE_TYPE through renderToSvgWithDiagnostics"),codegen:io("buildRenderPlan carries UNSUPPORTED_SHAPE_TYPE into generateCodeWithDiagnostics"),dxf:io("DxfExportStats records unsupported types and the DXF export UI reports them"),mermaid:io("exportMermaidWithDiagnostics records unsupported nodes and both Mermaid UIs report them"),pdf:Oe("PDF conversion consumes an already-projected editor SVG; unknown model nodes never enter its input."),"editor-dom":Oe("Unknown nodes are preserved for round-trip but require a registered shape implementation for projection.")}),"symbol-variants-overrides":_t({renderToSvg:ge("buildRenderPlan materializes symbol variants and per-instance overrides before emission"),codegen:ge("every component backend consumes buildRenderPlan symbol materialization"),dxf:io("DXF unsupported-shape accounting reports symbol instances without a lowering"),mermaid:io("Mermaid node-skip diagnostics report symbol instances without a lowering"),pdf:ge("the editor projects SymbolInstance content into the SVG consumed by svg2pdf"),"editor-dom":ge("SymbolInstance projects resolved library variants and overrides")}),"smil-timeline":_t({renderToSvg:ge("buildRenderPlan injects renderAnimationElements output into target and document-root markup"),codegen:ge("component backends preserve SMIL elements in planned target and document-root markup"),dxf:MT,mermaid:zT,pdf:FT,"editor-dom":ge("AnimationManager and the shared SMIL kernel project live playback")}),"motion-only-partition":_t({renderToSvg:ge("buildRenderPlan diverts motionOnly templates into defs outside visible paint"),codegen:ge("component backends consume the render plan visible and motion-def partitions"),dxf:MT,mermaid:zT,pdf:FT,"editor-dom":Oe("The authoring DOM retains motion templates for editing instead of applying export partitioning.")}),"paint-server-references":_t({renderToSvg:ge("plan defs and shapes use one library-first paint-server reference resolver"),codegen:ge("buildShapeAttrs and plan defs use the library-first reference resolver"),dxf:Oe("DXF promises geometry and basic entity colors, not SVG paint-server definition graphs."),mermaid:Oe("Mermaid graph syntax has no SVG gradient or pattern paint-server model."),pdf:ge("the cloned SVG carries paint-server definitions and references into svg2pdf"),"editor-dom":ge("GradientManager maintains live defs matching shape paint references")}),"filter-references":_t({renderToSvg:ge("renderFilterDefs and filterReferenceValue emit matching identifiers"),codegen:ge("planned filter defs and buildShapeAttrs share filter reference resolution"),dxf:Oe("DXF entity geometry has no SVG filter graph or filter-reference representation."),mermaid:Oe("Mermaid graph syntax has no SVG filter graph or filter-reference representation."),pdf:ge("the cloned SVG carries filter definitions and references into svg2pdf"),"editor-dom":ge("FilterManager maintains live filter definitions and shape references")}),"document-definition-context":_t({renderToSvg:ge("buildRenderPlan consumes the full snapshot definition and style context"),codegen:ge("component codegen accepts snapshot context and clipboard supplies its definitions"),dxf:Oe("DXF consumes resolved shapes and does not serialize SVG document definition sections."),mermaid:Oe("Mermaid consumes graph nodes and does not serialize SVG definition sections."),pdf:ge("PDF receives a cloned SVG document with its referenced definition context"),"editor-dom":ge("the document aggregate and managers project referenced resources into defs")}),"inline-child-containers":_t({renderToSvg:ge("renderShape recursively renders INLINE_CHILD_CONTAINER_TYPES children"),codegen:ge("component backends preserve recursively rendered plan container markup"),dxf:ge("DXF walks INLINE_CHILD_CONTAINER_TYPES with transforms and cycle guards"),mermaid:io("unsupported container nodes are counted by exportMermaidWithDiagnostics"),pdf:ge("the cloned editor SVG preserves nested containers for svg2pdf"),"editor-dom":ge("registered containers project managed children into nested SVG elements")}),"isolated-flowchart-nodes":_t({renderToSvg:Oe("Isolated-node declarations are a Mermaid graph concern, not an SVG branch."),codegen:Oe("Isolated-node declarations are a Mermaid graph concern, not component SVG output."),dxf:Oe("DXF emits geometry independently and has no connector-enrollment requirement."),mermaid:ge("exportMermaid declares mapped nodes before emitting connector edges"),pdf:Oe("PDF paints SVG geometry independently and has no graph-node declaration requirement."),"editor-dom":Oe("The live SVG projects shapes independently and has no graph-node declaration requirement.")}),"text-path":_t({renderToSvg:ge("renderText emits textPath markup and its referenced or private path definition; the render plan routes textPathMorph SMIL into that private path or into textPath for the inline path form"),codegen:ge("component backends preserve planned textPath markup, path definitions and their textPathMorph SMIL children"),dxf:Oe("DXF text entities do not reproduce SVG textPath layout along arbitrary paths."),mermaid:Oe("Mermaid labels do not reproduce SVG textPath layout along arbitrary paths."),pdf:io("ExportPanel.generatePdfBlob detects textPath content and shows its localized warning"),"editor-dom":ge("Text projects textPath attributes and maintains its referenced path")}),"common-presentation":_t({renderToSvg:ge("commonAttrs projects the ordered PRESENTATION_SEMANTICS vocabulary"),codegen:ge("buildShapeAttrs projects the ordered PRESENTATION_SEMANTICS vocabulary"),dxf:Oe("DXF is not an SVG presentation-attribute serialization contract."),mermaid:Oe("Mermaid is not an SVG presentation-attribute serialization contract."),pdf:ge("svg2pdf consumes common presentation attributes from the cloned SVG"),"editor-dom":ge("COMMON_PROP_RENDERERS derives its dispatch from PRESENTATION_SEMANTICS")}),"gradient-definition-envelope":_t({renderToSvg:ge("gradient renderers serialize the shared typed definition envelopes"),codegen:ge("render plan defs contain gradients serialized from shared typed envelopes"),dxf:Oe("DXF has no SVG linearGradient or radialGradient definition envelope."),mermaid:Oe("Mermaid has no SVG linearGradient or radialGradient definition envelope."),pdf:ge("the cloned SVG supplies shared-envelope gradient definitions to svg2pdf"),"editor-dom":ge("GradientManager projects shared gradient envelopes into live defs")}),"filter-definition-envelope":_t({renderToSvg:ge("renderFilterElement serializes filterDefinitionEnvelope for each wrapper kind"),codegen:ge("render plan defs contain filters serialized from shared typed envelopes"),dxf:Oe("DXF has no SVG filter element or primitive graph envelope representation."),mermaid:Oe("Mermaid has no SVG filter element or primitive graph envelope representation."),pdf:ge("the cloned SVG supplies shared-envelope filter definitions to svg2pdf"),"editor-dom":ge("FilterManager projects filterDefinitionEnvelope before primitive emission")}),"export-precision-rounding":_t({renderToSvg:ge("finalizeRenderPlan rounds markup coordinates at the effective documentMetadata.coordinatePrecision"),codegen:Oe("Codegen backends consume the un-finalized render plan; component output precision is a code-style concern, not an export boundary."),dxf:Oe("DXF numeric precision is owned by the DXF writer, not the SVG export boundary."),mermaid:Oe("Mermaid emits graph syntax rather than SVG coordinate attribute streams."),pdf:ge("PDF viewbox pages consume the plan-assembled string (core rounding); selection pages pass through SvgExportFinalizer.roundSvgAttributes"),"editor-dom":ge("static string exports round through core finalizeRenderPlan (plan-assembled); the selection/subtree markup clone sinks round through SvgExportFinalizer.roundSvgAttributes; the raster clone sink skips rounding by design (spelling-only, pixel-irrelevant)")}),"defs-deduplication":_t({renderToSvg:ge("finalizeRenderPlan collapses content-identical gradient/pattern/marker defs and rewrites references"),codegen:Oe("Codegen backends consume the un-finalized render plan; def duplication in generated components is a code-size concern outside the export contract."),dxf:Oe("DXF output has no shared-definition graph in which duplicates could exist."),mermaid:Oe("Mermaid output has no shared-definition graph in which duplicates could exist."),pdf:ge("PDF viewbox pages consume the plan-assembled string (core dedup); selection pages pass through SvgExportFinalizer.deduplicateDefsForExport"),"editor-dom":ge("static string exports dedup through core finalizeRenderPlan (plan-assembled); the selection/subtree markup clone sinks run SvgExportFinalizer.deduplicateDefsForExport; the raster clone sink skips dedup by design (spelling-only, pixel-irrelevant)")}),"source-id-restoration":_t({renderToSvg:ge("finalizeRenderPlan restores uncontested library sourceIds and rewrites references"),codegen:Oe("Generated components keep collision-safe runtime ids; source ids are a document round-trip concern."),dxf:Oe("DXF entities carry no SVG id namespace for source ids to be restored into."),mermaid:Oe("Mermaid nodes carry no SVG id namespace for source ids to be restored into."),pdf:Oe("PDF output has no id namespace to restore; the intermediate SVG string restores ids for fidelity but the PDF consumer never observes them."),"editor-dom":ge("static string exports restore source ids through core finalizeRenderPlan (plan-assembled); the selection/subtree markup clone sinks run SvgExportFinalizer.restoreSourceIds; the raster clone sink skips restoration by design (ids are spelling, not pixels)")}),"orphan-def-exclusion":_t({renderToSvg:ge("def emission is demand-driven (collectReferencedLibraryDefs, the referenced-marker gate, the paint-server reachability fixed point) \u2014 unreferenced defs are never emitted, so no pruning pass exists or is needed"),codegen:ge("component backends consume the same demand-driven plan def channels"),dxf:Oe("DXF output has no defs graph from which orphans could need excluding."),mermaid:Oe("Mermaid output has no defs graph from which orphans could need excluding."),pdf:ge("the editor SVG consumed by svg2pdf passes through pruneOrphanedDefs"),"editor-dom":ge("static string exports are demand-driven via the core plan (no orphans emitted); the raster/selection clone sinks sweep accumulated live defs with SvgExportFinalizer.pruneOrphanedDefs")}),"font-embedding":_t({renderToSvg:ge("finalizeRenderPlan ships @font-face CSS from the injected resolveFontEmbedCss hook (core is platform-free; binary resolution is the caller environment responsibility)"),codegen:Oe("Generated components inherit the host page font pipeline; embedding binaries in component source is out of contract."),dxf:Oe("DXF text styling is font-name based; the format has no font binary embedding."),mermaid:Oe("Mermaid delegates font resolution entirely to the rendering host page."),pdf:ge("svg2pdf consumes the editor SVG after the async export inlined @font-face CSS"),"editor-dom":ge("every sink that leaves the live document embeds: static and animated string exports resolve plan-collected FACES (family + weight + style) through fontManager into the core resolveFontEmbedCss hook, and the embedded-SVG subtree and selection exports run SvgExportFinalizer.embedFontsInOutput over the projected tree. Raster sinks embed too, subset to the characters they render - an SVG handed to an <img> is processed in secure static/animated mode (SVG 2 2.2.4/2.2.6), so it resolves no external references and inherits none of the session live font faces. Only the internal clipboard payload skips embedding, because the session that wrote it is the session that reads it")}),"initial-value-elision":_t({renderToSvg:ge("finalizeRenderPlan drops redundant spec initials and product defaults under an initial-valued cascade (elideInitialValuesInPlan)"),codegen:Oe("Codegen backends consume the un-finalized plan; explicit values in component source are a readability choice, not an export-boundary concern."),dxf:Oe("DXF entities carry explicit CAD attributes with no SVG initial-value cascade."),mermaid:Oe("Mermaid emits graph syntax; SVG presentation initial values never appear in its output."),pdf:ge("PDF viewbox pages consume the plan-assembled string (core elision); selection pages pass through SvgExportFinalizer.stripDefaultPaintAttributes"),"editor-dom":ge("static string exports elide through core finalizeRenderPlan (plan-assembled); the selection/subtree markup clone sinks run SvgExportFinalizer.stripDefaultPaintAttributes and the output-artifact rules; the raster clone sink keeps default attributes by design (elision is spelling-only)")}),"namespace-declaration-completion":_t({renderToSvg:ge("finalizeRenderPlan declares used prefixes on the root via a well-known URI table (declareUsedNamespacePrefixes); unresolvable prefixes warn undeclarable-namespace-prefix"),codegen:Oe("Generated components render into a host document whose framework owns namespace handling; JSX/Vue templates have no xmlns declaration surface to complete."),dxf:Oe("DXF is not XML and has no namespace prefixes to declare or complete."),mermaid:Oe("Mermaid graph syntax is not XML; no namespace declarations exist."),pdf:ge("svg2pdf consumes the editor SVG string whose serializer declared every namespace it uses"),"editor-dom":ge("static string exports complete declarations through core declareUsedNamespacePrefixes; the raster/selection clone sinks rely on XMLSerializer plus hoistForeignNamespaceDecls")})};function Yo(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}async function Jb(e,t,n,r){let i=e[t];typeof i=="string"&&(e[t]=await r(i,n))}async function Qb(e,t){Yo(e)&&await Jb(e,"svgContent","svgMarkup",t)}async function rm(e,t){if(!Yo(e))return;await Jb(e,"href","href",t),await Qb(e.fillGradient,t),await Qb(e.strokeGradient,t);let n=e.children;if(Array.isArray(n))for(let r of n)Yo(r)&&await rm(r.state,t)}async function BT(e,t){if(!Yo(e))return;let n=e.shapes;if(Array.isArray(n))for(let o of n)Yo(o)&&await rm(o.state,t);let r=e.library;if(Array.isArray(r))for(let o of r)Yo(o)&&o.kind==="pattern"&&await Qb(o.pattern,t);let i=e.customPatterns;if(Array.isArray(i))for(let o of i)Yo(o)&&await Jb(o,"svgContent","svgMarkup",t)}function Gl(e,t,n={}){let r=to(e),i=r.errors.filter(o=>!n.ignoreError?.(o));if(i.length>0){let o=i.map(s=>` ${s.path}: ${s.message}`).join(`
|
|
42
42
|
`);throw new Error(`Invalid .svgs document:
|
|
43
43
|
${o}`)}return n.includeWarnings===!1?[]:r.warnings.map(o=>({severity:"warning",code:/\.type$/.test(o.path)&&/Unknown shape type/.test(o.message)?"unavailable-shape-descriptor":"native-validation-warning",source:"native-document",entrypoint:t,message:o.message,documentPath:o.path}))}function im(e,t={}){let{indent:n=2,trailingNewline:r=!0,validate:i=!1}=t;if(i){let a=to(e);if(!a.valid){let c=a.errors.map(l=>` ${l.path}: ${l.message}`).join(`
|
|
44
44
|
`);throw new Error(`Invalid document:
|
|
@@ -95,4 +95,4 @@ ${t.join(`
|
|
|
95
95
|
${g.join(`
|
|
96
96
|
`)}
|
|
97
97
|
}`)}let l=[];for(let p of r.body){if(p.kind==="shape"){l.push(`${n}${qA(p.markup,o.get(p))}`);continue}l.push(`${n}${p.open}`);for(let m of p.members)l.push(`${n}${n}${qA(m.markup,o.get(m))}`);l.push(`${n}${p.close}`)}let d=$n(r.defs),u=r.documentCss,f=[];f.push("<style>");for(let p of c)f.push(p);u.length>0&&f.push(u),f.push("</style>"),f.push(""),f.push(`<svg xmlns="http://www.w3.org/2000/svg" width="${r.frame.width}" height="${r.frame.height}" viewBox="${r.frame.viewBox}">`),d.length>0&&f.push(`${n}<defs>${d}</defs>`);for(let p of l)f.push(p);return f.push("</svg>"),f.push(""),f.join(`
|
|
98
|
-
`)}function rh(e,t){return Lx(e,t).code}function Lx(e,t){let n=new ka;return{code:fm(n,()=>J2(e,t)),diagnostics:n.diagnostics}}function J2(e,t){let n=tH(e,t),r={...t};return Wv(eH(n,r))}function eH(e,t){switch(t.format){case"svg":return qg(e,t);case"react":return Qg(e,t);case"vue":return Jg(e,t);case"d3":return th(e,t);case"css":return nh(e,t);default:throw new Error(`Unsupported code format: ${t.format}`)}}function tH(e,t){if(Array.isArray(e)){let n=NR(e);return{shapes:e,viewboxes:[{id:"default",x:0,y:0,width:t.width??800,height:t.height??600}],...n.length>0?{library:n}:{}}}return e}var ih=class e{_snapshot;constructor(t={}){let{width:n=800,height:r=600,viewboxId:i}=t,o=Ho(0,0,n,r,i);this._snapshot=la({viewboxes:[o]})}static fromSnapshot(t){let n=new e;return n._snapshot=JSON.parse(JSON.stringify(t)),n}static fromJSON(t,n){let r=om(t,n),i=new e;return i._snapshot=r,i}static fromSVG(t,n){return e.fromSnapshot(mg(t,n))}add(t){let n="build"in t&&typeof t.build=="function"?t.build():t;return this._snapshot.shapes.push(n),this}addAll(...t){for(let n of t)this.add(n);return this}remove(t){let n=this._snapshot.shapes.length;return this._snapshot.shapes=this._snapshot.shapes.filter(r=>r.id!==t),this._snapshot.shapes.length<n}get shapes(){return this._snapshot.shapes}findShape(t){return this._snapshot.shapes.find(n=>n.id===t)}size(t,n){return this._snapshot.viewboxes.length>0?(this._snapshot.viewboxes[0].width=t,this._snapshot.viewboxes[0].height=n):this._snapshot.viewboxes=[Ho(0,0,t,n)],this}get width(){return this._snapshot.viewboxes[0]?.width??800}get height(){return this._snapshot.viewboxes[0]?.height??600}title(t){return this._ensureMetadata(),this._snapshot.documentMetadata.title=t,this}description(t){return this._ensureMetadata(),this._snapshot.documentMetadata.description=t,this}author(t){return this._ensureMetadata(),this._snapshot.documentMetadata.author=t,this}keywords(...t){return this._ensureMetadata(),this._snapshot.documentMetadata.keywords=t,this}license(t,n){return this._ensureMetadata(),this._snapshot.documentMetadata.license=t,n!==void 0&&(this._snapshot.documentMetadata.licenseUrl=n),this}language(t){return this._ensureMetadata(),this._snapshot.documentMetadata.language=t,this}customMetadata(t){return this._ensureMetadata(),this._snapshot.documentMetadata.customMetadata={...this._snapshot.documentMetadata.customMetadata,...t},this}get meta(){return this._snapshot.documentMetadata}defineSymbol(t,n,r){let i=me(),o=n.map(l=>"build"in l&&typeof l.build=="function"?l.build():l),s={kind:"symbol",id:i,name:t,shapes:o};r?.thumbnail&&(s.thumbnail=r.thumbnail),r?.defKind&&(s.defKind=r.defKind),r?.definitionPlacement&&(s.definitionPlacement=r.definitionPlacement);let a={...r?.rootAttributes??{}},c=a.viewBox;delete a.viewBox,r?.viewBox!==null&&(s.viewBox=r?.viewBox??c??"0 0 100 100");for(let l of["preserveAspectRatio","x","y","width","height","refX","refY"])r?.[l]!==void 0?s[l]=r[l]:s[l]===void 0&&a[l]!==void 0&&(s[l]=a[l]),delete a[l];return Object.keys(a).length>0&&(s.rootAttributes=a),r?.variantAxes&&(s.variantAxes=r.variantAxes),r?.variants&&(s.variants=Object.fromEntries(Object.entries(r.variants).map(([l,d])=>[l,d]))),r?.variantThumbnails&&(s.variantThumbnails=r.variantThumbnails),this._pushLibraryDef(s),i}placeSymbolInstance(t,n,r,i={}){let o=i.width,s=i.height,a={symbolId:t,x:n,y:r,width:o??100,height:s??100},c=i.authoredUseGeometry??{x:String(n),y:String(r),...o!==void 0?{width:String(o)}:{},...s!==void 0?{height:String(s)}:{}};Object.keys(c).length>0&&(a.authoredUseGeometry=c),i.variantKey&&(a.variantKey=i.variantKey),i.symbolOverrides&&(a.symbolOverrides=i.symbolOverrides),i.instancePresentation&&(a.instancePresentation=i.instancePresentation);let l={id:me(),type:"symbol-instance",state:a};return this._snapshot.shapes.push(l),this}removeSymbol(t){if(!this._snapshot.library)return!1;let n=this._snapshot.library.length;return this._snapshot.library=this._snapshot.library.filter(r=>!(r.kind==="symbol"&&r.id===t)),this._snapshot.library.length<n}get symbols(){return(this._snapshot.library??[]).filter(t=>t.kind==="symbol")}defineMarker(t,n,r){let i=me(),o=n.map(a=>"build"in a&&typeof a.build=="function"?a.build():a),s={kind:"marker",id:i,name:t,viewBox:r?.viewBox??"0 0 10 10",refX:r?.refX??5,refY:r?.refY??5,markerWidth:r?.markerWidth??10,markerHeight:r?.markerHeight??10,markerUnits:r?.markerUnits??"strokeWidth",orient:r?.orient??"auto",shapes:o};return r?.preserveAspectRatio!==void 0&&(s.preserveAspectRatio=r.preserveAspectRatio),r?.authoredGeometry&&(s.authoredGeometry={...r.authoredGeometry}),r?.rootAttributes&&(s.rootAttributes={...r.rootAttributes}),r?.thumbnail&&(s.thumbnail=r.thumbnail),this._pushLibraryDef(s),i}defineFilter(t,n,r){let i=me(),o={kind:"filter",id:i,name:t,filters:n};return r?.colorInterpolation&&(o.colorInterpolation=r.colorInterpolation),r?.filterUnits&&(o.filterUnits=r.filterUnits),r?.primitiveUnits&&(o.primitiveUnits=r.primitiveUnits),r?.x!==void 0&&(o.x=r.x),r?.y!==void 0&&(o.y=r.y),r?.width!==void 0&&(o.width=r.width),r?.height!==void 0&&(o.height=r.height),r?.thumbnail&&(o.thumbnail=r.thumbnail),this._pushLibraryDef(o),i}defineLinearGradientLibrary(t,n,r){let i=me(),o="build"in n?n.build():n,{id:s,sourceId:a,...c}=o,l={kind:"linear-gradient",id:i,name:t,gradient:c};return r?.thumbnail&&(l.thumbnail=r.thumbnail),this._pushLibraryDef(l),i}defineRadialGradientLibrary(t,n,r){let i=me(),o="build"in n?n.build():n,{id:s,sourceId:a,...c}=o,l={kind:"radial-gradient",id:i,name:t,gradient:c};return r?.thumbnail&&(l.thumbnail=r.thumbnail),this._pushLibraryDef(l),i}definePatternLibrary(t,n,r){let i=me(),o="build"in n?n.build():n,{id:s,sourceId:a,customPatternId:c,...l}=o,d={kind:"pattern",id:i,name:t,pattern:l};return r?.thumbnail&&(d.thumbnail=r.thumbnail),this._pushLibraryDef(d),i}removeLibraryDef(t){if(!this._snapshot.library)return!1;let n=this._snapshot.library.length;return this._snapshot.library=this._snapshot.library.filter(r=>r.id!==t),this._snapshot.library.length<n}get library(){return this._snapshot.library??[]}_pushLibraryDef(t){this._snapshot.library||(this._snapshot.library=[]);let n=this._snapshot.library.findIndex(r=>r.id===t.id);n>=0?this._snapshot.library[n]=t:this._snapshot.library.push(t)}addClipGroup(t,n,r){this._snapshot.clipMaskGroups||(this._snapshot.clipMaskGroups=[]);let i=me(),o={id:i,type:"clip",clipShapeIds:t,contentShapeIds:n,parentId:null};return r?.clipPathUnits&&(o.clipPathUnits=r.clipPathUnits),r?.definitionPlacement&&(o.definitionPlacement=r.definitionPlacement),r?.clipRule&&(o.clipRule=r.clipRule),r?.rawDefinition&&(o.rawDefinition=r.rawDefinition),this._snapshot.clipMaskGroups.push(o),i}addMaskGroup(t,n,r){this._snapshot.clipMaskGroups||(this._snapshot.clipMaskGroups=[]);let i=me(),o={id:i,type:"mask",clipShapeIds:t,contentShapeIds:n,parentId:null};return r?.maskUnits&&(o.maskUnits=r.maskUnits),r?.maskContentUnits&&(o.maskContentUnits=r.maskContentUnits),r?.maskBounds&&(o.maskBounds=r.maskBounds),r?.maskType&&(o.maskType=r.maskType),r?.definitionPlacement&&(o.definitionPlacement=r.definitionPlacement),r?.rawDefinition&&(o.rawDefinition=r.rawDefinition),this._snapshot.clipMaskGroups.push(o),i}removeClipMaskGroup(t){if(!this._snapshot.clipMaskGroups)return!1;let n=this._snapshot.clipMaskGroups.length;return this._snapshot.clipMaskGroups=this._snapshot.clipMaskGroups.filter(r=>r.id!==t),this._snapshot.clipMaskGroups.length<n}addGuide(t,n,r){this._snapshot.guides||(this._snapshot.guides=[]);let i=me(),o={id:i,orientation:t,position:n,controlPointOffset:0};return r?.color&&(o.color=r.color),r?.opacity!==void 0&&(o.opacity=r.opacity),this._snapshot.guides.push(o),i}removeGuide(t){if(!this._snapshot.guides)return!1;let n=this._snapshot.guides.length;return this._snapshot.guides=this._snapshot.guides.filter(r=>r.id!==t),this._snapshot.guides.length<n}clearGuides(){return this._snapshot.guides=[],this}get guides(){return this._snapshot.guides??[]}addMeasurement(t,n,r){this._snapshot.measurements||(this._snapshot.measurements=[]);let i=me(),o={id:i,type:t,points:n,visible:r?.visible??!0,snapDivisions:r?.snapDivisions??1};return r?.color&&(o.color=r.color),r?.opacity!==void 0&&(o.opacity=r.opacity),this._snapshot.measurements.push(o),i}removeMeasurement(t){if(!this._snapshot.measurements)return!1;let n=this._snapshot.measurements.length;return this._snapshot.measurements=this._snapshot.measurements.filter(r=>r.id!==t),this._snapshot.measurements.length<n}get measurements(){return this._snapshot.measurements??[]}addCustomPattern(t,n,r,i){let o=me();return this._pushLibraryDef(ba({id:o,name:t,svgContent:n,width:r,height:i})),o}removeCustomPattern(t){let n=this._snapshot.library;if(!n)return!1;let r=n.length;return this._snapshot.library=n.filter(i=>!(i.kind==="pattern"&&i.id===t)),this._snapshot.library.length<r}get customPatterns(){let t=[];for(let n of this._snapshot.library??[]){if(n.kind!=="pattern")continue;let r=Jp(n);r&&t.push(r)}return t}bringToFront(t){let n=this._snapshot.shapes.findIndex(r=>r.id===t);if(n>=0){let[r]=this._snapshot.shapes.splice(n,1);this._snapshot.shapes.push(r)}return this}sendToBack(t){let n=this._snapshot.shapes.findIndex(r=>r.id===t);if(n>=0){let[r]=this._snapshot.shapes.splice(n,1);this._snapshot.shapes.unshift(r)}return this}reorder(t,n){let r=this._snapshot.shapes.findIndex(i=>i.id===t);if(r>=0){let[i]=this._snapshot.shapes.splice(r,1),o=Math.max(0,Math.min(n,this._snapshot.shapes.length));this._snapshot.shapes.splice(o,0,i)}return this}defineVariable(t,n,r,i){this._snapshot.templateVariables||(this._snapshot.templateVariables=[]);let o=this._snapshot.templateVariables.find(s=>s.name===t);if(o)o.type=n,o.defaultValue=r,i?.label!==void 0&&(o.label=i.label),i?.description!==void 0&&(o.description=i.description);else{let s={name:t,type:n,defaultValue:r};i?.label!==void 0&&(s.label=i.label),i?.description!==void 0&&(s.description=i.description),this._snapshot.templateVariables.push(s)}return this}removeVariable(t){return this._snapshot.templateVariables&&(this._snapshot.templateVariables=this._snapshot.templateVariables.filter(n=>n.name!==t)),this}get variables(){return this._snapshot.templateVariables??[]}inspectVariables(){return am(this._snapshot)}setTimeline(t){return"build"in t&&typeof t.build=="function"?this._snapshot.animationTimeline=t.build():this._snapshot.animationTimeline=t,this}clearTimeline(){return delete this._snapshot.animationTimeline,this}get timeline(){return this._snapshot.animationTimeline}toSVG(t){let{variables:n,...r}=t??{},i=jl(this._snapshot,n);return Qa(i,r)}toSVGWithDiagnostics(t){let{variables:n,...r}=t??{},i=jl(this._snapshot,n);return Fd(i,r)}toJSON(t){return im(this._snapshot,t)}toSnapshot(){return JSON.parse(JSON.stringify(this._snapshot))}toCode(t,n){return rh(this._snapshot,{...n,format:t})}_ensureMetadata(){this._snapshot.documentMetadata||(this._snapshot.documentMetadata={title:"",description:"",author:"",keywords:[],license:"",licenseUrl:"",language:"en",customMetadata:{}})}};var oh=class{_track;constructor(t,n){this._track={id:me(),shapeId:t,property:n,keyframes:[],enabled:!0,locked:!1}}id(t){return this._track.id=t,this}keyframe(t,n,r="linear"){return this._track.keyframes.push({id:me(),time:t,value:n,easing:r}),this}keyframeBezier(t,n,r){return this._track.keyframes.push({id:me(),time:t,value:n,easing:"custom-bezier",customBezier:r}),this}keyframeLinear(t,n,r){return this._track.keyframes.push({id:me(),time:t,value:n,easing:"linear-function",linearPoints:r}),this}keyframes(...t){return this._track.keyframes.push(...t.map(n=>({...n,id:n.id??me()}))),this}disabled(){return this._track.enabled=!1,this}locked(){return this._track.locked=!0,this}motionPath(t){return this._track.motionPath=t,this}motionPathRef(t,n="trackShape"){return this._track.motionPathRef={shapeId:t,mode:n},this}beginTrigger(t,n){return this._track.beginTrigger={type:t,value:n},this}endTrigger(t,n){return this._track.endTrigger={type:t,value:n},this}cycleDuration(t){return this._track.cycleDuration=t,this}cycleRepeats(t){return this._track.cycleRepeats=t,this}infinite(){return this._track.cycleInfinite=!0,this}cycle(t){return this._track.cycleBehavior=t,this}transformOrigin(t,n){return this._track.transformOrigin={x:t,y:n},this._track.targetTransformOrigin=void 0,this}motionRotate(t){return this._track.motionRotate=t,this}additive(t){return this._track.additive=t,this}accumulate(t="sum"){return this._track.accumulate=t,this}fill(t){return this._track.fill=t,this}fillBackwards(t=!0){return this._track.fillBackwards=t,this}build(){let t=[...this._track.keyframes].sort((n,r)=>n.time-r.time);return{...this._track,keyframes:t}}},sh=class{_duration;_loop=!1;_playbackSpeed=1;_tracks=[];constructor(t){this._duration=t}loop(t=!0){return this._loop=t,this}speed(t){return this._playbackSpeed=t,this}duration(t){return this._duration=t,this}addTrack(t){return this._tracks.push(t),this}addTracks(...t){return this._tracks.push(...t),this}buildTimeline(){return{duration:this._duration,loop:this._loop,playbackSpeed:this._playbackSpeed,tracks:this._tracks.map(t=>t.build())}}build(){let t=this.buildTimeline();return{duration:t.duration,loop:t.loop,playbackSpeed:t.playbackSpeed,tracks:t.tracks.map(n=>({id:n.id,shapeId:n.shapeId,property:n.property,enabled:n.enabled,locked:n.locked||void 0,motionPath:n.motionPath,motionPathRef:n.motionPathRef,beginTrigger:n.beginTrigger,endTrigger:n.endTrigger,cycleDuration:n.cycleDuration,simpleDuration:n.simpleDuration,cycleRepeats:n.cycleRepeats,cycleInfinite:n.cycleInfinite,cycleBehavior:n.cycleBehavior,fillBackwards:n.fillBackwards,transformOrigin:n.transformOrigin,targetTransformOrigin:n.targetTransformOrigin,motionRotate:n.motionRotate,additive:n.additive,accumulate:n.accumulate,fill:n.fill,keyframes:n.keyframes.map(r=>({id:r.id,time:r.time,value:r.value,easing:r.easing,...r.customBezier?{customBezier:r.customBezier}:{},...r.linearPoints?{linearPoints:r.linearPoints}:{}}))}))}}};var tn=class{_id;_type;_state={};constructor(t,n){this._type=t,this._id=n??me()}id(t){return this._id=t,this}locked(t=!0){return this._state.locked=t,this}visible(t=!0){return this._state.visible=t,this}displayMode(t){return this._state.displayMode=t,this}motionOnly(){return this._state.displayMode="motionOnly",this}fill(t,n){return this._state.fillColor=t,this._state.fillType="solid",n!==void 0&&(this._state.fillOpacity=n),this}noFill(){return this._state.fillType="none",this}fillGradient(t){let n="build"in t?t.build():t;return this._state.fillType=n.type,this._state.fillGradient=n,this}fillPattern(t){let n="build"in t?t.build():t;return this._state.fillType="pattern",this._state.fillGradient=n,this}fillOpacity(t){return this._state.fillOpacity=t,this}fillRule(t){return this._state.fillRule=t,this}addFill(t,n){let r={id:`fill-${this.nextLayerOrdinal("fill")}`,kind:"fill",color:t,paintType:"solid"};return n!==void 0&&(r.opacity=n),this.pushAppearanceLayer(r),this}addStroke(t,n){let r={id:`stroke-${this.nextLayerOrdinal("stroke")}`,kind:"stroke",color:t,paintType:"solid"};return n!==void 0&&(r.width=n),this.pushAppearanceLayer(r),this}pushAppearanceLayer(t){let n=lu(this._state,t);Object.assign(this._state,n)}nextLayerOrdinal(t){let r=(this._state.appearance??[]).filter(i=>i.kind===t).length;return Math.max(r,1)}stroke(t,n){return this._state.borderColor=t,n!==void 0&&(this._state.borderWidth=n),this}noStroke(){return this._state.borderColor="none",this._state.borderWidth=0,this}strokeWidth(t){return this._state.borderWidth=t,this}strokeOpacity(t){return this._state.strokeOpacity=t,this}strokeGradient(t){let n="build"in t?t.build():t;return this._state.strokeType=n.type,this._state.strokeGradient=n,this}strokePattern(t){let n="build"in t?t.build():t;return this._state.strokeType="pattern",this._state.strokeGradient=n,this}strokeLinejoin(t){return this._state.strokeLinejoin=t,this}strokeLinecap(t){return this._state.strokeLinecap=t,this}strokeMiterlimit(t){return this._state.strokeMiterlimit=t,this}dashOffset(t){return this._state.dashOffset=t,this}strokeDasharray(t){return this._state.strokeDasharray=t,this}dash(t,n,r){return this._state.lineStyle=t,t==="custom"&&(n!==void 0&&(this._state.dashLength=n),r!==void 0&&(this._state.gapLength=r)),this}opacity(t){return this._state.opacity=t,this}rotate(t){return this._state.rotation=t,this.refreshTransformMatrix(),this}skew(t,n){return this._state.skewX=t,this._state.skewY=n,this.refreshTransformMatrix(),this}scale(t,n){return this._state.scaleX=t,this._state.scaleY=n??t,this.refreshTransformMatrix(),this}pivot(t,n){return this._state.customPivot={x:t,y:n},this.refreshTransformMatrix(),this}transformMatrix(t){if(t.length<6||!t.slice(0,6).every(Number.isFinite))throw new RangeError("transformMatrix must contain six finite numbers");return this._state.transformMatrix=t.slice(0,6),this}refreshTransformMatrix(){this._state.transformMatrix=Pt(kc(this._state,this.defaultTransformPivot()))}defaultTransformPivot(){let t=this._state.customPivot;if(t)return t;let n=this._state.x,r=this._state.y,i=this._state.width,o=this._state.height;if(n!==void 0&&r!==void 0&&i!==void 0&&o!==void 0)return{x:n+i/2,y:r+o/2};let s=this._state.radius;if(n!==void 0&&r!==void 0&&s!==void 0)return{x:n,y:r};let a=this._state.cx,c=this._state.cy;if(a!==void 0&&c!==void 0)return{x:a,y:c};let l=this._state.x1,d=this._state.y1,u=this._state.x2,f=this._state.y2;if(l!==void 0&&d!==void 0&&u!==void 0&&f!==void 0)return{x:(l+u)/2,y:(d+f)/2};let p=this._state.pathPoints;if(p?.[0])return{x:p[0].x,y:p[0].y};let m=this._state.polylinePoints;if(m?.[0])return m[0]}filter(...t){let n=this._state.filters??[];return this._state.filters=[...n,...t],this}dropShadow(t={}){let n={id:`drop-shadow-${me()}`,type:"drop-shadow",enabled:!0,offsetX:t.offsetX??4,offsetY:t.offsetY??4,blurRadius:t.blurRadius??8,spread:t.spread??0,color:t.color??"#000000",opacity:t.opacity??.3};return this.filter(n)}innerShadow(t={}){let n={id:`inner-shadow-${me()}`,type:"inner-shadow",enabled:!0,offsetX:t.offsetX??2,offsetY:t.offsetY??2,blurRadius:t.blurRadius??4,choke:t.choke??0,color:t.color??"#000000",opacity:t.opacity??.5};return this.filter(n)}blur(t,n,r){let i=t??4,o=n??i,s={id:`gaussian-blur-${me()}`,type:"gaussian-blur",enabled:!0,blurX:i,blurY:o,linked:i===o,quality:r?.quality??"normal"};return this.filter(s)}glow(t={}){let n={id:`glow-${me()}`,type:"glow",enabled:!0,color:t.color??"#ffffff",radius:t.radius??10,intensity:t.intensity??.8};return this.filter(n)}innerGlow(t={}){let n={id:`inner-glow-${me()}`,type:"inner-glow",enabled:!0,color:t.color??"#ffffff",radius:t.radius??10,intensity:t.intensity??.8};return this.filter(n)}grayscale(t=1){let n={id:`grayscale-${me()}`,type:"grayscale",enabled:!0,amount:t};return this.filter(n)}sepia(t=1){let n={id:`sepia-${me()}`,type:"sepia",enabled:!0,amount:t};return this.filter(n)}outline(t={}){return this.filter({id:`outline-${me()}`,type:"outline",enabled:!0,width:t.width??3,color:t.color??"#000000",opacity:t.opacity??1,position:t.position??"outside"})}motionBlur(t={}){let n={id:`motion-blur-${me()}`,type:"motion-blur",enabled:!0,distance:t.distance??10,angle:t.angle??0,quality:t.quality??"normal"};return this.filter(n)}pointLight(t={}){let n={id:`point-light-${me()}`,type:"point-light",enabled:!0,x:t.x??100,y:t.y??100,z:t.z??200,color:t.color??"#ffffff",surfaceScale:t.surfaceScale??5,diffuseConstant:t.diffuseConstant??1,specularConstant:t.specularConstant??1,specularExponent:t.specularExponent??20};return this.filter(n)}spotLight(t={}){let n={id:`spot-light-${me()}`,type:"spot-light",enabled:!0,x:t.x??100,y:t.y??0,z:t.z??200,pointsAtX:t.pointsAtX??100,pointsAtY:t.pointsAtY??100,pointsAtZ:t.pointsAtZ??0,coneAngle:t.coneAngle??30,color:t.color??"#ffffff",surfaceScale:t.surfaceScale??5,specularConstant:t.specularConstant??1,specularExponent:t.specularExponent??20};return this.filter(n)}sharpen(t=1){let n={id:`sharpen-${me()}`,type:"sharpen",enabled:!0,amount:t};return this.filter(n)}pixelate(t=8){let n={id:`pixelate-${me()}`,type:"pixelate",enabled:!0,blockSize:t};return this.filter(n)}warp(t={}){let n={id:`warp-${me()}`,type:"warp",enabled:!0,scale:t.scale??10,frequency:t.frequency??.02,octaves:t.octaves??1,warpType:t.warpType??"turbulence"};return this.filter(n)}morphology(t={}){let n=t.radiusX??2,r=t.radiusY??n,i={id:`morphology-${me()}`,type:"morphology",enabled:!0,operator:t.operator??"dilate",radiusX:n,radiusY:r,linked:t.linked??n===r};return this.filter(i)}contouring(t={}){if((t.mode??"discrete")==="table"){let i={id:`contouring-table-${me()}`,type:"contouring-table",enabled:!0,levels:t.levels??4,contrast:t.contrast??1};return this.filter(i)}let r={id:`contouring-discrete-${me()}`,type:"contouring-discrete",enabled:!0,levels:t.levels??4};return this.filter(r)}roundEdges(t=4){let n={id:`round-edges-${me()}`,type:"round-edges",enabled:!0,radius:t};return this.filter(n)}channelPainter(t={}){let n={id:`channel-painter-${me()}`,type:"channel-painter",enabled:!0,red:t.red??1,green:t.green??1,blue:t.blue??1};return this.filter(n)}brightness(t=1){let n={id:`brightness-${me()}`,type:"brightness",enabled:!0,amount:t};return this.filter(n)}contrast(t=1){let n={id:`contrast-${me()}`,type:"contrast",enabled:!0,amount:t};return this.filter(n)}filterOpacity(t=1){let n={id:`opacity-${me()}`,type:"opacity",enabled:!0,amount:t};return this.filter(n)}invert(t=1){let n={id:`invert-${me()}`,type:"invert",enabled:!0,amount:t};return this.filter(n)}hueRotate(t=0){let n={id:`hue-rotate-${me()}`,type:"hue-rotate",enabled:!0,angle:t};return this.filter(n)}saturate(t=1){let n={id:`saturate-${me()}`,type:"saturate",enabled:!0,amount:t};return this.filter(n)}blackAndWhite(t=.5){let n={id:`black-and-white-${me()}`,type:"black-and-white",enabled:!0,threshold:t};return this.filter(n)}duotone(t={}){let n={id:`duotone-${me()}`,type:"duotone",enabled:!0,shadowColor:t.shadowColor??"#000000",highlightColor:t.highlightColor??"#ffffff"};return this.filter(n)}xray(t=1){let n={id:`xray-${me()}`,type:"xray",enabled:!0,intensity:t};return this.filter(n)}noise(t={}){let n={id:`noise-${me()}`,type:"noise",enabled:!0,amount:t.amount??.3,scale:t.scale??1};return this.filter(n)}emboss(t={}){let n={id:`emboss-${me()}`,type:"emboss",enabled:!0,strength:t.strength??1,angle:t.angle??135};return this.filter(n)}filmGrain(t={}){let n={id:`film-grain-${me()}`,type:"film-grain",enabled:!0,amount:t.amount??.3,size:t.size??1};return this.filter(n)}watercolor(t={}){let n={id:`watercolor-${me()}`,type:"watercolor",enabled:!0,wetness:t.wetness??.5,turbulence:t.turbulence??.5};return this.filter(n)}gouache(t={}){let n={id:`gouache-${me()}`,type:"gouache",enabled:!0,thickness:t.thickness??.5,texture:t.texture??.5};return this.filter(n)}inkBlot(t={}){let n={id:`ink-blot-${me()}`,type:"ink-blot",enabled:!0,spread:t.spread??.5,edges:t.edges??.5};return this.filter(n)}crumpledPlastic(t={}){let n={id:`crumpled-plastic-${me()}`,type:"crumpled-plastic",enabled:!0,wrinkles:t.wrinkles??.5,shine:t.shine??.5};return this.filter(n)}riddled(t={}){let n={id:`riddled-${me()}`,type:"riddled",enabled:!0,density:t.density??.5,size:t.size??1};return this.filter(n)}cssClipPath(t){return this._state.cssClipPath=t,this}cssMaskProperties(t){return this._state.cssMaskProperties=t,this}vectorEffect(t){return this._state.vectorEffect=t,this}transformBox(t){return this._state.transformBox=t,this}paintOrder(t){return this._state.paintOrder=t,this}blendMode(t){return this._state.blendMode=t,this}visibility(t){return this._state.visibility=t,this}shapeRendering(t){return this._state.shapeRendering=t,this}filterColorInterpolation(t){return this._state.filterColorInterpolation=t,this}inheritFill(t=!0){return this._state.inheritFill=t,this}inheritStroke(t=!0){return this._state.inheritStroke=t,this}systemLanguage(t){return this._state.systemLanguage=t,this}requiredExtensions(t){return this._state.requiredExtensions=t,this}fillLibrary(t,n="linear-gradient"){return this._state.fillLibraryId=t,this._state.fillType=n,this}strokeLibrary(t,n="linear-gradient"){return this._state.strokeLibraryId=t,this._state.strokeType=n,this}filterLibrary(...t){let n=this._state.filterLibraryIds??[];return this._state.filterLibraryIds=[...n,...t],this}markerStartRef(t){return this._state.markerStart=t,this}markerMidRef(t){return this._state.markerMid=t,this}markerEndRef(t){return this._state.markerEnd=t,this}bind(t,n){let r=this._state.bindings??{};return this._state.bindings={...r,[t]:n},this}metadata(t){return this._state.metadata={...this._state.metadata,...t},this}build(){return{id:this._id,type:this._type,state:{...this._state}}}},ah=class extends tn{constructor(t,n,r){if(r<0)throw new RangeError("Circle radius must be non-negative");super("circle"),this._state.x=t,this._state.y=n,this._state.radius=r}position(t,n){return this._state.x=t,this._state.y=n,this}radius(t){return this._state.radius=t,this}},ch=class extends tn{constructor(t,n,r,i){if(r<0||i<0)throw new RangeError("Ellipse radii must be non-negative");super("ellipse"),this._state.cx=t,this._state.cy=n,this._state.rx=r,this._state.ry=i}position(t,n){return this._state.cx=t,this._state.cy=n,this}radii(t,n){return this._state.rx=t,this._state.ry=n,this}},lh=class extends tn{constructor(t,n,r,i){if(r<0||i<0)throw new RangeError("Rectangle dimensions must be non-negative");super("rectangle"),this._state.x=t,this._state.y=n,this._state.width=r,this._state.height=i}position(t,n){return this._state.x=t,this._state.y=n,this}size(t,n){return this._state.width=t,this._state.height=n,this}cornerRadius(t){return this._state.cornerRadius=t,this._state.rx=t,this._state.ry=t,this}radii(t,n){return this._state.rx=t,this._state.ry=n,t===n&&(this._state.cornerRadius=t),this}},dh=class extends tn{constructor(t,n,r){if(r<0)throw new RangeError("Square size must be non-negative");super("square"),this._state.x=t,this._state.y=n,this._state.width=r,this._state.height=r}position(t,n){return this._state.x=t,this._state.y=n,this}size(t){return this._state.width=t,this._state.height=t,this}cornerRadius(t){return this._state.cornerRadius=t,this._state.rx=t,this._state.ry=t,this}radii(t,n){return this._state.rx=t,this._state.ry=n,t===n&&(this._state.cornerRadius=t),this}},uh=class extends tn{constructor(t,n,r,i){super("line"),this._state.x1=t,this._state.y1=n,this._state.x2=r,this._state.y2=i}from(t,n){return this._state.x1=t,this._state.y1=n,this}to(t,n){return this._state.x2=t,this._state.y2=n,this}markerStart(t){return this._state.startEndpoint=t,this}markerEnd(t){return this._state.endEndpoint=t,this}markers(t,n){return this._state.startEndpoint=t,this._state.endEndpoint=n,this}},fh=class extends tn{constructor(t,n,r){super("text"),this._state.x=t,this._state.y=n,this._state.text=r}position(t,n){return this._state.x=t,this._state.y=n,this}content(t){return this._state.text=t,this}fontSize(t){return this._state.fontSize=t,this}fontFamily(t){return this._state.fontFamily=t,this}fontWeight(t){return this._state.fontWeight=t,this}fontStyle(t){return this._state.fontStyle=t,this}fontVariant(t){return this._state.fontVariant=t,this}fontVariantLigatures(t){return this._state.fontVariantLigatures=t,this}fontVariantPosition(t){return this._state.fontVariantPosition=t,this}fontVariantCaps(t){return this._state.fontVariantCaps=t,this}fontVariantNumeric(t){return this._state.fontVariantNumeric=t,this}fontVariantEastAsian(t){return this._state.fontVariantEastAsian=t,this}anchor(t){return this._state.textAnchor=t,this}letterSpacing(t){return this._state.letterSpacing=t,this}lineHeight(t){return this._state.lineHeight=t,this}decoration(t){return this._state.textDecoration=t,this}transform(t){return this._state.textTransform=t,this}textPath(t,n=0){return this._state.isTextPath=!0,this._state.textPathPoints=t,this._state.textPathStartOffset=n,this}textPathOffset(t){return this._state.textPathStartOffset=t,this}textPathSide(t){return this._state.textPathSide=t,this}direction(t){return this._state.textDirection=t,this}unicodeBidi(t){return this._state.unicodeBidi=t,this}dominantBaseline(t){return this._state.dominantBaseline=t,this}writingMode(t){return this._state.writingMode=t,this}wordSpacing(t){return this._state.wordSpacing=t,this}baselineShift(t){return this._state.baselineShift=t,this}inlineSize(t){return this._state.inlineSize=t,this}overflowWrap(t){return this._state.overflowWrap=t,this}whiteSpace(t){return this._state.whiteSpace=t,this}fontVariationSettings(t){return this._state.fontVariationSettings=t,this}charOffsets(t){return this._state.charOffsets=t,this}shapeInsideRef(t){return this._state.shapeInsideRef=t,this}shapePadding(t){return this._state.shapePadding=t,this}richTextSegments(t){return this._state.richTextRuns=yi(t),this}richTextRuns(t){let n=Fo(t);return this._state.richTextRuns=n,this}useRichText(t=!0){return this._state.useRichText=t,this}linePositions(t){return this._state.linePositions=t,this}textLength(t){return this._state.textLength=t,this}lengthAdjust(t){return this._state.lengthAdjust=t,this}},Mn=class extends tn{constructor(t,n,r,i){super(t),this._state.cx=n,this._state.cy=r,this._state.radius=i}position(t,n){return this._state.cx=t,this._state.cy=n,this}radius(t){return this._state.radius=t,this}shiftAngle(t){return this._state.shiftAngle=t,this}cornerRadius(t){return this._state.cornerRadius=t,this}},ph=class extends Mn{constructor(t,n,r){super("triangle",t,n,r)}},mh=class extends Mn{constructor(t,n,r,i=5){super("ngon",t,n,r),this._state.sides=i}sides(t){return this._state.sides=t,this}},gh=class extends Mn{constructor(t,n,r){super("star",t,n,r),this._state.arms=5,this._state.innerRadiusPercent=40}arms(t){return this._state.arms=t,this}innerRadius(t){return this._state.innerRadiusPercent=t,this}},hh=class extends Mn{constructor(t,n,r){super("cross",t,n,r),this._state.armWidthPercent=35}armWidth(t){return this._state.armWidthPercent=t,this}},yh=class extends Mn{constructor(t,n,r){super("ring",t,n,r),this._state.innerRadiusPercent=60}innerRadius(t){return this._state.innerRadiusPercent=t,this}},Sh=class extends Mn{constructor(t,n,r){super("spiral",t,n,r),this._state.turns=3,this._state.thicknessPercent=15,this._state.spiralDirection=1}turns(t){return this._state.turns=t,this}thickness(t){return this._state.thicknessPercent=t,this}direction(t){return this._state.spiralDirection=t,this}},bh=class extends Mn{constructor(t,n,r){super("gear",t,n,r),this._state.teeth=8,this._state.toothDepthPercent=25}teeth(t){return this._state.teeth=t,this}toothDepth(t){return this._state.toothDepthPercent=t,this}holeRadius(t){return this._state.holeRadiusPercent=t,this}},vh=class extends Mn{constructor(t,n,r){super("arrow",t,n,r),this._state.headWidthPercent=100,this._state.headLengthPercent=35,this._state.shaftWidthPercent=35}headWidth(t){return this._state.headWidthPercent=t,this}headLength(t){return this._state.headLengthPercent=t,this}shaftWidth(t){return this._state.shaftWidthPercent=t,this}},xh=class extends Mn{constructor(t,n,r){super("heart",t,n,r),this._state.lobeRadiusPercent=50,this._state.cleftDepthPercent=25}lobeRadius(t){return this._state.lobeRadiusPercent=t,this}cleftDepth(t){return this._state.cleftDepthPercent=t,this}},Ih=class extends Mn{constructor(t,n,r){super("lightning",t,n,r),this._state.boltSegments=3,this._state.boltJaggednessPercent=40,this._state.boltWidthPercent=30}segments(t){return this._state.boltSegments=t,this}jaggedness(t){return this._state.boltJaggednessPercent=t,this}thickness(t){return this._state.boltWidthPercent=t,this}},wh=class extends Mn{constructor(t,n,r){super("cloud",t,n,r),this._state.cloudBumps=5,this._state.cloudPuffinessPercent=60}bumps(t){return this._state.cloudBumps=t,this}puffiness(t){return this._state.cloudPuffinessPercent=t,this}},kh=class extends Mn{constructor(t,n,r){super("speechBubble",t,n,r),this._state.tailAngleDeg=45,this._state.tailLengthPercent=40,this._state.tailWidthPercent=25}tailAngle(t){return this._state.tailAngleDeg=t,this}tailLength(t){return this._state.tailLengthPercent=t,this}tailWidth(t){return this._state.tailWidthPercent=t,this}},lo=class extends tn{add(t){let n="build"in t&&typeof t.build=="function"?t.build():t,r=this._state.children??[];return this._state.children=[...r,n],this}addAll(...t){for(let n of t)this.add(n);return this}children(t){return this._state.children=t.map(n=>"build"in n&&typeof n.build=="function"?n.build():n),this}},Ph=class extends lo{constructor(t){super("hyperlink"),t!==void 0&&(this._state.href=t)}href(t){return this._state.href=t,this}hrefXlink(t){return this._state.hrefXlink=t,this}target(t){return this._state.linkTarget=t,this}download(t){return this._state.linkDownload=t,this}rel(t){return this._state.linkRel=t,this}ping(t){return this._state.linkPing=t,this}hreflang(t){return this._state.linkHreflang=t,this}type(t){return this._state.linkType=t,this}referrerPolicy(t){return this._state.linkReferrerPolicy=t,this}},Th=class extends lo{constructor(){super("switch")}},Rh=class extends lo{constructor(){super("container")}},Ch=class extends tn{constructor(t){super("view"),t&&(this._state.viewBoxX=t.x,this._state.viewBoxY=t.y,this._state.viewBoxWidth=t.width,this._state.viewBoxHeight=t.height)}viewBox(t,n,r,i){return this._state.viewBoxX=t,this._state.viewBoxY=n,this._state.viewBoxWidth=r,this._state.viewBoxHeight=i,this}name(t){return this._state.viewName=t,this}preserveAspectRatio(t){return this._state.viewPreserveAspectRatio=t,this}zoomAndPan(t){return this._state.viewZoomAndPan=t,this}viewTarget(t){return this._state.viewTarget=t,this}},Ah=class extends lo{constructor(t=0,n=0,r=100,i=100){super("svg"),this._state.svgX=t,this._state.svgY=n,this._state.svgWidth=r,this._state.svgHeight=i}position(t,n){return this._state.svgX=t,this._state.svgY=n,this}size(t,n){return this._state.svgWidth=t,this._state.svgHeight=n,this}viewBox(t,n,r,i){return this._state.svgViewBoxX=t,this._state.svgViewBoxY=n,this._state.svgViewBoxWidth=r,this._state.svgViewBoxHeight=i,this}preserveAspectRatio(t){return this._state.svgPreserveAspectRatio=t,this}asRoot(t=!0){return this._state.isRootSvg=t,this}},Nh=class extends tn{constructor(t){super("shape-reference"),t!==void 0&&(this._state.targetShapeId=t)}target(t){return this._state.targetShapeId=t,this}offset(t,n){return this._state.offsetX=t,this._state.offsetY=n,this}size(t,n){return this._state.width=t,this._state.height=n,this}},Eh=class extends tn{position(t,n){return this._state.x=t,this._state.y=n,this}size(t,n){return this._state.width=t,this._state.height=n,this}src(t){return this._state.href=t,this}mimeType(t){return this._state.mediaMimeType=t,this}naturalDuration(t){return this._state.naturalDuration=t,this}begin(t){return this._state.begin=t,this}trim(t,n){return this._state.trimStart=t,this._state.trimEnd=n,this}volume(t){return this._state.volume=t,this}muted(t=!0){return this._state.muted=t,this}loop(t=!0){return this._state.loop=t,this}playbackRate(t){return this._state.playbackRate=t,this}fade(t,n){return this._state.fadeInDuration=t,this._state.fadeOutDuration=n,this}language(t){return this._state.systemLanguage=t,this}},Oh=class extends Eh{constructor(t){super("video"),this._state.mediaKind="video",t!==void 0&&(this._state.href=t)}poster(t){return this._state.posterHref=t,this}sourceRect(t){return this._state.sourceRect=t,this}},Dh=class extends Eh{constructor(t){super("audio"),this._state.mediaKind="audio",t!==void 0&&(this._state.href=t)}},$h=class extends tn{constructor(t=[]){super("path"),this._state.pathPoints=[...t],this._state.pathCurveType="cubic",this._state.pathClosed=!1}points(t){return this._state.pathPoints=[...t],this}addPoint(t,n){let r=this._state.pathPoints??[];return r.push({x:t,y:n}),this._state.pathPoints=r,this}curveType(t){return this._state.pathCurveType=t,this}closed(t=!0){return this._state.pathClosed=t,this}tension(t){return this._state.pathTension=t,this}arcParams(t){return this._state.pathArcParams=t,this}markerStart(t){return this._state.startEndpoint=t,this}markerEnd(t){return this._state.endEndpoint=t,this}markers(t,n){return this._state.startEndpoint=t,this._state.endEndpoint=n,this}toD(){let t=this._state.pathPoints??[],n=this._state.pathCurveType??"CUBIC",r=this._state.pathClosed??!1,i=this._state.pathTension??.5,o=this._state.pathArcParams;return sr(t,n,r,i,o)}},Mh=class extends tn{constructor(t=[]){super("polyline"),this._state.polylinePoints=[...t],this._state.polylineClosed=!1}points(t){return this._state.polylinePoints=[...t],this}addPoint(t,n){let r=this._state.polylinePoints??[];return r.push({x:t,y:n}),this._state.polylinePoints=r,this}closed(t=!0){return this._state.polylineClosed=t,this}markerStart(t){return this._state.startEndpoint=t,this}markerEnd(t){return this._state.endEndpoint=t,this}markers(t,n){return this._state.startEndpoint=t,this._state.endEndpoint=n,this}},zh=class extends tn{constructor(t,n,r,i,o){super("image"),this._state.x=t,this._state.y=n,this._state.width=r,this._state.height=i,this._state.href=o}position(t,n){return this._state.x=t,this._state.y=n,this}size(t,n){return this._state.width=t,this._state.height=n,this}src(t){return this._state.href=t,this}preserveAspectRatio(t){return this._state.preserveAspectRatio=t,this}};var Ld=class{_x1;_y1;_x2;_y2;_stops=[];_spreadMethod="pad";_opacity=1;_id;constructor(t=0,n=0,r=1,i=0){this._x1=t,this._y1=n,this._x2=r,this._y2=i,this._id=me()}stop(t,n,r=1){return this._stops.push({offset:t,color:n,opacity:r}),this}direction(t,n,r,i){return this._x1=t,this._y1=n,this._x2=r,this._y2=i,this}spread(t){return this._spreadMethod=t,this}opacity(t){return this._opacity=t,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}}},_d=class{_cx=.5;_cy=.5;_fx=.5;_fy=.5;_r=.5;_ry=.5;_rotation=0;_stops=[];_spreadMethod="pad";_opacity=1;_id;constructor(){this._id=me()}center(t,n){return this._cx=t,this._cy=n,this}focus(t,n){return this._fx=t,this._fy=n,this}radius(t,n){return this._r=t,this._ry=n??t,this}rotation(t){return this._rotation=t,this}stop(t,n,r=1){return this._stops.push({offset:t,color:n,opacity:r}),this}spread(t){return this._spreadMethod=t,this}opacity(t){return this._opacity=t,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}}},Bd=class{_patternType;_color;_backgroundColor;_scale=1;_rotation=0;_opacity=1;_patternParams;_id;_svgContent;_width;_height;_patternUnits;_patternContentUnits;_patternTransform;_viewBox;_preserveAspectRatio;_x;_y;_customPatternId;constructor(t="stripes",n="#000000",r="#ffffff"){this._patternType=t,this._color=n,this._backgroundColor=r,this._id=me()}scale(t){return this._scale=t,this}rotation(t){return this._rotation=t,this}opacity(t){return this._opacity=t,this}params(t){return this._patternParams=t,this}svgContent(t){return this._svgContent=t,this}size(t,n){return this._width=t,this._height=n,this}patternUnits(t){return this._patternUnits=t,this}patternContentUnits(t){return this._patternContentUnits=t,this}patternTransform(t){return this._patternTransform=t,this}viewBox(t){return this._viewBox=t,this}preserveAspectRatio(t){return this._preserveAspectRatio=t,this}position(t,n){return this._x=t,this._y=n,this}customPatternId(t){return this._customPatternId=t,this}build(){let t,n,r;if(this._svgContent!==void 0)t=this._svgContent,n=this._width??10,r=this._height??10;else{let o=dp(this._patternType,this._scale,this._color,this._backgroundColor,this._patternParams);t=o.svgContent,n=this._width??o.width,r=this._height??o.height}let i={type:"pattern",id:this._id,patternType:this._svgContent!==void 0?"custom":this._patternType,color:this._color,backgroundColor:this._backgroundColor,scale:this._scale,rotation:this._rotation,opacity:this._opacity,svgContent:t,width:n,height:r,patternUnits:this._patternUnits??"userSpaceOnUse",patternParams:this._patternParams,patternTransform:this._patternTransform??(this._rotation?`rotate(${this._rotation})`:void 0)};return this._patternContentUnits&&(i.patternContentUnits=this._patternContentUnits),this._viewBox&&(i.viewBox=this._viewBox),this._preserveAspectRatio&&(i.preserveAspectRatio=this._preserveAspectRatio),this._x!==void 0&&(i.x=this._x),this._y!==void 0&&(i.y=this._y),this._customPatternId&&(i.customPatternId=this._customPatternId),i}};function ZA(e=0,t=0,n=1,r=0){return new Ld(e,t,n,r)}function QA(){return new _d}function JA(e="stripes",t="#000000",n="#ffffff"){return new Bd(e,t,n)}var _x={rows:4,cols:4,style:"classic",tabDepthPercent:20,tabPattern:"random",seed:1},nH=.04,rH=0;function iH(e){let t=e>>>0;return()=>{t=t+1831565813>>>0;let n=t;return n=Math.imul(n^n>>>15,n|1),n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}}function Ie(e){return Number(e.toFixed(3)).toString()}function oH(e,t,n,r,i,o,s,a,c,l,d,u){return[[0,0],[.2,a],[.5+c+d,-o+l],[.5-o+c,o+l],[.5-2*o+c-d,3*o+l],[.5+2*o+c-d,3*o+l],[.5+o+c,o+l],[.5+c+d,-o+l],[.8,u],[1,0]].map(([p,m])=>{let g=t+p*r,h=n+m*i*s;return e?{x:g,y:h}:{x:h,y:g}})}function eN(e,t,n,r,i,o,s,a,c,l,d){let u=[],f=(v,w)=>c==="alternating"?0:v+l()*(w-v),p=()=>l()<.5,m=f(-a,a),g=c==="alternating"?d%2===0:p(),h=null,y=m,S=f(-a,a),b=f(-a,a),I=f(-a,a);m=f(-a,a);for(let v=0;v<e;v++){v>0&&(h=g,g=c==="alternating"?(d+v)%2===0:p(),y=g===h?-m:m,S=f(-a,a),b=f(-a,a),I=f(-a,a),m=f(-a,a));let w=g?-1:1,k=n+v*i;u.push(oH(t,k,r,i,o,s,w,y,S,b,I,m))}return u}function tN(e,t,n,r,i,o,s){let a=2*o;return[[0,0],[.2,0],[.4,0],[.4,a],[.4,a],[.6,a],[.6,a],[.6,0],[.8,0],[1,0]].map(([l,d])=>{let u=t+l*r,f=n+d*i*s;return e?{x:u,y:f}:{x:f,y:u}})}function nN(e,t){return e+` C ${Ie(t[1].x)} ${Ie(t[1].y)} ${Ie(t[2].x)} ${Ie(t[2].y)} ${Ie(t[3].x)} ${Ie(t[3].y)} C ${Ie(t[4].x)} ${Ie(t[4].y)} ${Ie(t[5].x)} ${Ie(t[5].y)} ${Ie(t[6].x)} ${Ie(t[6].y)} C ${Ie(t[7].x)} ${Ie(t[7].y)} ${Ie(t[8].x)} ${Ie(t[8].y)} ${Ie(t[9].x)} ${Ie(t[9].y)}`}function rN(e,t){return e+` C ${Ie(t[8].x)} ${Ie(t[8].y)} ${Ie(t[7].x)} ${Ie(t[7].y)} ${Ie(t[6].x)} ${Ie(t[6].y)} C ${Ie(t[5].x)} ${Ie(t[5].y)} ${Ie(t[4].x)} ${Ie(t[4].y)} ${Ie(t[3].x)} ${Ie(t[3].y)} C ${Ie(t[2].x)} ${Ie(t[2].y)} ${Ie(t[1].x)} ${Ie(t[1].y)} ${Ie(t[0].x)} ${Ie(t[0].y)}`}function iN(e,t={}){let n={..._x,...t};if(n.rows<1||n.cols<1)throw new Error("generatePuzzlePieces: rows and cols must be >= 1");if(!Number.isFinite(e.width)||!Number.isFinite(e.height))throw new Error("generatePuzzlePieces: bounds must have finite width/height");if(e.width<=0||e.height<=0)throw new Error("generatePuzzlePieces: bounds must have positive width/height");let{rows:r,cols:i,style:o,tabDepthPercent:s,tabPattern:a,seed:c}=n,l=iH(c),d=e.width/i,u=e.height/r,f=Math.max(0,Math.min(.4,s/200)),p=(o==="classic"||o==="curved")&&f>0,m=o==="square-tabs"&&f>0,g=o==="classic"&&a==="random"?nH:rH,h=[];for(let b=0;b<r-1;b++){let I=e.y+(b+1)*u;if(p)h.push(eN(i,!0,e.x,I,d,u,f,g,a,l,b));else if(m){let v=[];for(let w=0;w<i;w++){let k=a==="alternating"?(b+w)%2===0?1:-1:l()<.5?1:-1;v.push(tN(!0,e.x+w*d,I,d,u,f,k))}h.push(v)}else h.push(new Array(i).fill(null))}let y=[];for(let b=0;b<i-1;b++){let I=e.x+(b+1)*d;if(p)y.push(eN(r,!1,e.y,I,u,d,f,g,a,l,b));else if(m){let v=[];for(let w=0;w<r;w++){let k=a==="alternating"?(w+b)%2===0?1:-1:l()<.5?1:-1;v.push(tN(!1,e.y+w*u,I,u,d,f,k))}y.push(v)}else y.push(new Array(r).fill(null))}let S=[];for(let b=0;b<r;b++)for(let I=0;I<i;I++){let v=e.x+I*d,w=e.y+b*u,k=v+d,C=w+u,P=`M ${Ie(v)} ${Ie(w)}`;if(b===0)P+=` L ${Ie(k)} ${Ie(w)}`;else{let R=h[b-1][I];R?P=nN(P,R):P+=` L ${Ie(k)} ${Ie(w)}`}if(I===i-1)P+=` L ${Ie(k)} ${Ie(C)}`;else{let R=y[I][b];R?P=nN(P,R):P+=` L ${Ie(k)} ${Ie(C)}`}if(b===r-1)P+=` L ${Ie(v)} ${Ie(C)}`;else{let R=h[b][I];R?P=rN(P,R):P+=` L ${Ie(v)} ${Ie(C)}`}if(I===0)P+=` L ${Ie(v)} ${Ie(w)}`;else{let R=y[I-1][b];R?P=rN(P,R):P+=` L ${Ie(v)} ${Ie(w)}`}P+=" Z",S.push({id:`puzzle-${c}-r${b}-c${I}`,row:b,col:I,d:P})}return S}var aN=[1,2,3,4,5,6,7,8,9],sH={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 Vd(e){return e.map(t=>[...t])}function aH(){return Array.from({length:9},()=>Array.from({length:9},()=>0))}function cN(e){let t=e>>>0;return()=>{t=t+1831565813>>>0;let n=t;return n=Math.imul(n^n>>>15,n|1),n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}}function lN(e,t){let n=[...e];for(let r=n.length-1;r>0;r--){let i=Math.floor(t()*(r+1));[n[r],n[i]]=[n[i],n[r]]}return n}function Ja(e){return 1<<e-1}function dN(e){let t=0,n=e;for(;n;)n&=n-1,t++;return t}function cH(e){for(let t=1;t<=9;t++)if(e===Ja(t))return t;return 0}function Vx(e,t){return Math.floor(e/3)*3+Math.floor(t/3)}function Bx(e){let t=0;for(let n of e)for(let r of n)r!==0&&t++;return t}function lH(e){if(!Number.isFinite(e))return 1;let t=Math.floor(e);return t===0?1:t}function uN(e,t){if(!Array.isArray(e)||e.length!==9)return t.push("Grid must contain 9 rows."),!1;let n=!0;for(let r=0;r<9;r++){if(!Array.isArray(e[r])||e[r].length!==9){t.push(`Row ${r+1} must contain 9 cells.`),n=!1;continue}for(let i=0;i<9;i++){let o=e[r][i];(!Number.isInteger(o)||o<0||o>9)&&(t.push(`Cell R${r+1}C${i+1} must be a digit from 0 to 9.`),n=!1)}}return n}function fN(e,t){let n=!0,r=(i,o)=>{let s=0;for(let a of o){if(a===0)continue;let c=Ja(a);if(s&c){t.push(`${i} contains duplicate ${a}.`),n=!1;return}s|=c}};for(let i=0;i<9;i++)r(`Row ${i+1}`,e[i]);for(let i=0;i<9;i++)r(`Column ${i+1}`,e.map(o=>o[i]));for(let i=0;i<9;i+=3)for(let o=0;o<9;o+=3){let s=[];for(let a=i;a<i+3;a++)for(let c=o;c<o+3;c++)s.push(e[a][c]);r(`Box ${Math.floor(i/3)*3+Math.floor(o/3)+1}`,s)}return n}function Gx(e){let t=Array.from({length:9},()=>0),n=Array.from({length:9},()=>0),r=Array.from({length:9},()=>0);for(let i=0;i<9;i++)for(let o=0;o<9;o++){let s=e[i][o];if(s===0)continue;let a=Ja(s),c=Vx(i,o);if(t[i]&a||n[o]&a||r[c]&a)return null;t[i]|=a,n[o]|=a,r[c]|=a}return{rows:t,cols:n,boxes:r}}function jx(e,t,n,r,i){return 511&~(n[e]|r[t]|i[Vx(e,t)])}function pN(e,t,n){let r=Gx(e);if(!r)return[];let i=Vd(e),o=[],{rows:s,cols:a,boxes:c}=r,l=()=>{if(o.length>=t)return;let d=-1,u=-1,f=0,p=10;for(let g=0;g<9;g++){for(let h=0;h<9;h++){if(i[g][h]!==0)continue;let y=jx(g,h,s,a,c),S=dN(y);if(S===0)return;if(S<p&&(d=g,u=h,f=y,p=S,S===1))break}if(p===1)break}if(d===-1){o.push(Vd(i));return}let m=aN.filter(g=>f&Ja(g));n&&(m=lN(m,n));for(let g of m){let h=Ja(g),y=Vx(d,u);if(i[d][u]=g,s[d]|=h,a[u]|=h,c[y]|=h,l(),c[y]&=~h,a[u]&=~h,s[d]&=~h,i[d][u]=0,o.length>=t)return}};return l(),o}function dH(e){let t=aH(),n=cN(e),[r]=pN(t,1,n);if(!r)throw new Error("generateSudokuPuzzle: failed to generate solved grid");return r}function uH(e){let t=Gx(e);if(!t)return null;for(let n=0;n<9;n++)for(let r=0;r<9;r++){if(e[n][r]!==0)continue;let i=jx(n,r,t.rows,t.cols,t.boxes);if(dN(i)===1)return{row:n,col:r,value:cH(i)}}return null}function fH(e){let t=Gx(e);if(!t)return null;let n=r=>{for(let i of aN){let o=Ja(i),s=null;for(let a of r)if(!(e[a.row][a.col]!==0||!(jx(a.row,a.col,t.rows,t.cols,t.boxes)&o))){if(s){s=null;break}s=a}if(s)return{...s,value:i}}return null};for(let r=0;r<9;r++){let i=n(Array.from({length:9},(o,s)=>({row:r,col:s})));if(i)return i}for(let r=0;r<9;r++){let i=n(Array.from({length:9},(o,s)=>({row:s,col:r})));if(i)return i}for(let r=0;r<9;r+=3)for(let i=0;i<9;i+=3){let o=[];for(let a=r;a<r+3;a++)for(let c=i;c<i+3;c++)o.push({row:a,col:c});let s=n(o);if(s)return s}return null}function oN(e){let t=Vd(e),n=!1;for(;Bx(t)<81;){let r=uH(t);if(r){t[r.row][r.col]=r.value;continue}let i=fH(t);if(i){n=!0,t[i.row][i.col]=i.value;continue}return"search"}return n?"hidden-singles":"singles"}function sN(e,t){let n={singles:0,"hidden-singles":1,search:2};return n[e]<=n[t]}function Gd(e,t={}){let n=[];return uN(e,n)?fN(e,n)?pN(e,Math.max(1,Math.floor(t.maxSolutions??2))):[]:[]}function mN(e){let t=[];if(!uN(e,t))return{valid:!1,unique:!1,solution:null,errors:t};if(fN(e,t),t.length>0)return{valid:!1,unique:!1,solution:null,errors:t};let r=Gd(e,{maxSolutions:2});return r.length===0?t.push("Puzzle has no solution."):r.length>1&&t.push("Puzzle has more than one solution."),{valid:t.length===0,unique:r.length===1,solution:r[0]?Vd(r[0]):null,errors:t}}function gN(e){let t=e.difficulty,n=sH[t];if(!n)throw new Error(`generateSudokuPuzzle: unsupported difficulty "${t}"`);let r=lH(e.seed);for(let i=0;i<30;i++){let o=r+i*104729>>>0,s=cN(o),a=dH(o),c=Vd(a),l=n.minGivens+Math.floor(s()*(n.maxGivens-n.minGivens+1)),d=lN(Array.from({length:81},(m,g)=>({row:Math.floor(g/9),col:g%9})),s);for(let m of d){if(Bx(c)<=l)break;let g=c[m.row][m.col];if(c[m.row][m.col]=0,Gd(c,{maxSolutions:2}).length!==1){c[m.row][m.col]=g;continue}let y=oN(c);sN(y,n.maxRating)||(c[m.row][m.col]=g)}let u=Bx(c),f=oN(c);if(Gd(c,{maxSolutions:2}).length===1&&u>=n.minGivens&&u<=n.maxGivens&&sN(f,n.maxRating))return{puzzle:c,solution:a,difficulty:t,seed:r,givens:u,rating:f}}throw new Error(`generateSudokuPuzzle: unable to generate a ${t} puzzle`)}var hN="ABCDEFGHIJKLMNOPQRSTUVWXYZ";var pH={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 SN(e){if(!Number.isFinite(e))return 1;let t=Math.floor(e);return t===0?1:t}function bN(e){let t=e>>>0;return()=>{t=t+1831565813>>>0;let n=t;return n=Math.imul(n^n>>>15,n|1),n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}}function ec(e){let t=globalThis.Intl.Segmenter;return t?Array.from(new t(void 0,{granularity:"grapheme"}).segment(e),n=>n.segment.normalize("NFC")):Array.from(e.normalize("NFC"))}function mH(e,t,n,r){return e>=0&&t>=0&&e<r&&t<n}function Ux(e,t){return Array.from({length:t},()=>Array.from({length:e},()=>!0))}function vN(e,t,n,r){if(!n)return Ux(e,t);if(!Array.isArray(n)||n.length!==t)return r.push(`Mask must contain exactly ${t} rows.`),Ux(e,t);let i=[];for(let o=0;o<t;o++){if(!Array.isArray(n[o])||n[o].length!==e)return r.push(`Mask row ${o+1} must contain exactly ${e} cells.`),Ux(e,t);i.push(n[o].map(Boolean))}return i}function gH(e){let t=0;for(let n of e)for(let r of n)r&&t++;return t}function hH(e){return e.trim().normalize("NFC")}function xN(e){return e.replace(/\r/g,"").split(/[,\n]+/).map(t=>t.trim()).filter(t=>t.length>0)}function Hx(e,t){let n=[];return e.across&&(n.push("E"),t&&n.push("W")),e.down&&(n.push("S"),t&&n.push("N")),e.diagonal&&(n.push("SE","NE"),t&&n.push("NW","SW")),n}function yH(e,t,n,r,i,o,s,a){let c=ec(e),l=[];for(let d=0;d<c.length;d++){let u=t+r.dr*d,f=n+r.dc*d;if(!mH(u,f,o,s)||!i[u][f])return null;l.push({row:u,col:f,grapheme:c[d]})}return{word:e,graphemes:c,row:t,col:n,direction:r.direction,dr:r.dr,dc:r.dc,cells:l,jitter:a}}function IN(e,t,n,r,i,o){let s=[];for(let a of t){let c=pH[a];for(let l=0;l<i;l++)for(let d=0;d<r;d++){let u=yH(e,l,d,c,n,r,i,o());u&&s.push(u)}}return s}function Kx(e){let t=[],n=[],r=[],i=Math.floor(e.width),o=Math.floor(e.height);(!Number.isInteger(i)||i<2||i>64)&&t.push("Width must be an integer from 2 to 64."),(!Number.isInteger(o)||o<2||o>64)&&t.push("Height must be an integer from 2 to 64.");let s=Hx(e.axes,e.allowBackwards);s.length===0&&t.push("At least one word direction must be enabled.");let a=vN(Math.max(1,i),Math.max(1,o),e.mask,t),c=gH(a);c===0&&t.push("Mask must contain at least one active cell.");let l=new Set,d=[];for(let p of e.words){let m=hH(p);if(m){if(/\s/u.test(m)){r.push({input:p,reason:"Words cannot contain whitespace."});continue}if(l.has(m)){r.push({input:p,reason:"Duplicate word."});continue}l.add(m),d.push(m)}}d.length===0&&t.push("Enter at least one word.");let u=bN(SN(e.seed));if(t.length===0)for(let p=d.length-1;p>=0;p--){let m=d[p];IN(m,s,a,i,o,u).length===0&&(r.push({input:m,reason:"No legal placement exists for the current size, mask, and directions."}),d.splice(p,1))}r.length>0&&t.push(`${r.length} word${r.length===1?"":"s"} rejected.`);let f=Math.max(0,c);return d.length>f&&n.push("The word count exceeds the active cell count; overlaps may be required for this puzzle."),{valid:t.length===0,acceptedWords:d,rejectedWords:r,errors:t,warnings:n,minWords:1,maxWords:f,activeCells:c,directions:s}}function SH(e,t){for(let n of t.cells){let r=e[n.row][n.col];if(r!==null&&r!==n.grapheme)return!0}return!1}function bH(e,t){let n=[];for(let r of t.cells)e[r.row][r.col]===null&&(n.push({row:r.row,col:r.col}),e[r.row][r.col]=r.grapheme);return n}function vH(e,t){for(let n of t)e[n.row][n.col]=null}function yN(e,t){let n=0;for(let r of t.cells)e[r.row][r.col]===r.grapheme&&n++;return n}function xH(e){return{word:e.word,row:e.row,col:e.col,direction:e.direction,path:e.cells.map(t=>({...t}))}}function IH(e){let t=e.fillerAlphabet??hN,n=typeof t=="string"?ec(t):t.flatMap(i=>ec(i)),r=n.filter((i,o)=>i.trim()&&n.indexOf(i)===o);return r.length>0?r:ec(hN)}function wN(e){let t=Math.floor(e.width),n=Math.floor(e.height),r=SN(e.seed),i=Kx({...e,width:t,height:n,seed:r});if(!i.valid)throw new Error(`generateWordSearch: ${i.errors[0]??"invalid options"}`);let o=vN(t,n,e.mask,[]),s=Math.max(1,Math.floor(e.maxBacktrackNodes??15e4));for(let a=0;a<24;a++){let c=bN(r+a*104729>>>0),l=i.directions,d=new Map;for(let S of i.acceptedWords)d.set(S,IN(S,l,o,t,n,c));let u=[...i.acceptedWords].sort((S,b)=>{let I=d.get(S)?.length??0,v=d.get(b)?.length??0;return I!==v?I-v:ec(b).length-ec(S).length}),f=Array.from({length:n},(S,b)=>Array.from({length:t},(I,v)=>o[b][v]?null:"")),p=[],m=new Map,g=0,h=S=>{if(++g>s)return!1;if(S>=u.length)return!0;let b=u[S],I=[...d.get(b)??[]].filter(v=>!SH(f,v)).sort((v,w)=>{let k=yN(f,w)-yN(f,v);if(k!==0)return k;let C=(m.get(v.direction)??0)-(m.get(w.direction)??0);return C!==0?C:v.jitter-w.jitter});for(let v of I){let w=bH(f,v);if(p.push(xH(v)),m.set(v.direction,(m.get(v.direction)??0)+1),h(S+1))return!0;m.set(v.direction,(m.get(v.direction)??1)-1),p.pop(),vH(f,w)}return!1};if(!h(0))continue;let y=IH(e);for(let S=0;S<n;S++)for(let b=0;b<t;b++)o[S][b]?f[S][b]===null&&(f[S][b]=y[Math.floor(c()*y.length)]):f[S][b]="";return{width:t,height:n,grid:f,mask:o.map(S=>[...S]),normalizedWords:[...i.acceptedWords],placements:[...p],seed:r,title:e.title,creator:e.creator,lint:i}}throw new Error("generateWordSearch: unable to place all words with the current settings")}function wH(e,t,n){let r=!1;for(let i=0,o=n.length-1;i<n.length;o=i++){let s=n[i],a=n[o];s.y>t!=a.y>t&&e<(a.x-s.x)*(t-s.y)/(a.y-s.y)+s.x&&(r=!r)}return r}function kH(){let e=[];for(let t=0;t<10;t++){let n=t%2===0?.5:.23,r=-Math.PI/2+t*Math.PI/5;e.push({x:.5+Math.cos(r)*n,y:.5+Math.sin(r)*n})}return e}function kN(e,t,n){let r=Math.max(1,Math.floor(e)),i=Math.max(1,Math.floor(t)),o=kH();return Array.from({length:i},(s,a)=>Array.from({length:r},(c,l)=>{let d=(l+.5)/r,u=(a+.5)/i,f=d*2-1,p=u*2-1;switch(n){case"rectangle":return!0;case"circle":return f*f+p*p<=1;case"triangle":return u>=.08&&u<=.95&&Math.abs(f)<=u;case"diamond":return Math.abs(f)+Math.abs(p)<=1;case"star":return wH(d,u,o);case"heart":{let m=f*1.25,g=-p*1.25;return Math.pow(m*m+g*g-1,3)-m*m*g*g*g<=0}case"cross":return Math.abs(f)<=.32||Math.abs(p)<=.32;default:return!0}}))}function jd(e,t){let{width:n,height:r,data:i}=e;if(!Number.isInteger(n)||!Number.isInteger(r)||n<0||r<0)throw new Error(`${t}: image dimensions must be non-negative integers, got ${n}x${r}`);if(i.length!==n*r*4)throw new Error(`${t}: data length ${i.length} does not match ${n}x${r} RGBA (${n*r*4})`)}function Fh(e,t,n){return .2126*e+.7152*t+.0722*n}function Wx(e){let t=e/255;return t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}var PH=.95047,TH=1,RH=1.08883,CH=Math.pow(6/29,3),AH=1/(3*Math.pow(6/29,2));function Xx(e){return e>CH?Math.cbrt(e):e*AH+4/29}function Ud(e,t,n,r){let i=Wx(e),o=Wx(t),s=Wx(n),a=.4124564*i+.3575761*o+.1804375*s,c=.2126729*i+.7151522*o+.072175*s,l=.0193339*i+.119192*o+.9503041*s,d=Xx(a/PH),u=Xx(c/TH),f=Xx(l/RH);r[0]=116*u-16,r[1]=500*(d-u),r[2]=200*(u-f)}var uo=Math.PI/180,PN=Math.pow(25,7);function Lh(e,t,n,r,i,o){let s=Math.hypot(t,n),a=Math.hypot(i,o),c=(s+a)/2,l=Math.pow(c,7),d=.5*(1-Math.sqrt(l/(l+PN))),u=(1+d)*t,f=(1+d)*i,p=Math.hypot(u,n),m=Math.hypot(f,o),g=p===0?0:(Math.atan2(n,u)/uo+360)%360,h=m===0?0:(Math.atan2(o,f)/uo+360)%360,y=r-e,S=m-p,b=0;p*m!==0&&(b=h-g,b>180?b-=360:b<-180&&(b+=360));let I=2*Math.sqrt(p*m)*Math.sin(b/2*uo),v=(e+r)/2,w=(p+m)/2,k;if(p*m===0)k=g+h;else{let V=g+h;Math.abs(g-h)<=180?k=V/2:V<360?k=(V+360)/2:k=(V-360)/2}let C=1-.17*Math.cos((k-30)*uo)+.24*Math.cos(2*k*uo)+.32*Math.cos((3*k+6)*uo)-.2*Math.cos((4*k-63)*uo),P=30*Math.exp(-Math.pow((k-275)/25,2)),R=Math.pow(w,7),N=2*Math.sqrt(R/(R+PN)),M=Math.pow(v-50,2),A=1+.015*M/Math.sqrt(20+M),$=1+.045*w,_=1+.015*w*C,z=-Math.sin(2*P*uo)*N,j=y/A,G=S/$,W=I/_;return Math.sqrt(j*j+G*G+W*W+z*G*W)}function _h(e,t){return e.width===t.width&&e.height===t.height}function Hd(e){let t=e.data,n=new Uint8ClampedArray(t.length);for(let r=0;r<t.length;r+=4){let i=t[r+3];if(n[r+3]=i,i===255)n[r]=t[r],n[r+1]=t[r+1],n[r+2]=t[r+2];else if(i!==0){let o=i/255;n[r]=Math.round(t[r]*o),n[r+1]=Math.round(t[r+1]*o),n[r+2]=Math.round(t[r+2]*o)}}return n}function Kd(e,t){let n=e.data,r=e.width*e.height,i=new Uint8ClampedArray(r*3);for(let o=0;o<r;o++){let s=o*4,a=o*3,c=n[s+3]/255;if(c===1)i[a]=n[s],i[a+1]=n[s+1],i[a+2]=n[s+2];else if(c===0)i[a]=t.r,i[a+1]=t.g,i[a+2]=t.b;else{let l=1-c;i[a]=Math.round(n[s]*c+t.r*l),i[a+1]=Math.round(n[s+1]*c+t.g*l),i[a+2]=Math.round(n[s+2]*c+t.b*l)}}return i}var TN=6.502500000000001,RN=(.03*255)**2;function NH(e,t){let n=new Float64Array(e*2+1),r=0;for(let i=-e;i<=e;i++){let o=Math.exp(-(i*i)/(2*t*t));n[i+e]=o,r+=o}for(let i=0;i<n.length;i++)n[i]/=r;return n}function Wd(e,t,n,r,i,o,s){for(let a=0;a<n;a++){let c=a*t;for(let l=0;l<t;l++){let d=0;for(let u=-i;u<=i;u++){let f=l+u;f<0?f=0:f>=t&&(f=t-1),d+=e[c+f]*r[u+i]}o[c+l]=d}}for(let a=0;a<n;a++)for(let c=0;c<t;c++){let l=0;for(let d=-i;d<=i;d++){let u=a+d;u<0?u=0:u>=n&&(u=n-1),l+=o[u*t+c]*r[d+i]}s[a*t+c]=l}}function Xd(e,t,n,r){if(e.length!==n*r||t.length!==n*r)throw new Error(`ssimPlane: plane length ${e.length}/${t.length} does not match ${n}x${r}`);let i=Math.min(n,r);if(i<3){for(let I=0;I<e.length;I++)if(e[I]!==t[I])return 0;return 1}let o=11;i<o&&(o=i%2===0?i-1:i);let s=(o-1)/2,a=NH(s,1.5),c=n*r,l=new Float64Array(c),d=new Float64Array(c),u=new Float64Array(c);for(let I=0;I<c;I++)l[I]=e[I]*e[I],d[I]=t[I]*t[I],u[I]=e[I]*t[I];let f=new Float64Array(c),p=new Float64Array(c),m=new Float64Array(c),g=new Float64Array(c),h=new Float64Array(c),y=new Float64Array(c);Wd(e,n,r,a,s,f,p),Wd(t,n,r,a,s,f,m),Wd(l,n,r,a,s,f,g),Wd(d,n,r,a,s,f,h),Wd(u,n,r,a,s,f,y);let S=0,b=0;for(let I=s;I<r-s;I++)for(let v=s;v<n-s;v++){let w=I*n+v,k=p[w],C=m[w],P=k*k,R=C*C,N=g[w]-P,M=h[w]-R,A=y[w]-k*C,$=(2*k*C+TN)*(2*A+RN),_=(P+R+TN)*(N+M+RN);S+=$/_,b++}return b>0?S/b:1}function Bh(e,t,n,r={}){let i=t*n;if(e.length!==i)throw new Error(`severity: field length ${e.length} does not match ${t}x${n}`);let o=r.threshold??2,s=r.minNeighbours??4,a=new Uint8Array(i),c=0;for(let h=0;h<i;h++)e[h]>o&&(a[h]=1,c++);if(c===0)return{differing:0,coherent:0,clusters:0,largestCluster:0,mass:0,score:1};let l=new Uint8Array(i),d=0;for(let h=0;h<n;h++){let y=h*t;for(let S=0;S<t;S++){if(!a[y+S])continue;let b=0;for(let I=-1;I<=1;I++){let v=h+I;if(v<0||v>=n)continue;let w=v*t;for(let k=-1;k<=1;k++){if(k===0&&I===0)continue;let C=S+k;C<0||C>=t||(b+=a[w+C])}}b>=s&&(l[y+S]=1,d++)}}let u=0,f=0,p=0,m=[];for(let h=0;h<i;h++){if(!l[h])continue;u++;let y=0;for(l[h]=0,m.push(h);m.length>0;){let S=m.pop();y++;let b=S%t;b>0&&l[S-1]&&(l[S-1]=0,m.push(S-1)),b+1<t&&l[S+1]&&(l[S+1]=0,m.push(S+1)),S>=t&&l[S-t]&&(l[S-t]=0,m.push(S-t)),S+t<i&&l[S+t]&&(l[S+t]=0,m.push(S+t))}y>f&&(f=y),p+=y*y}let g=i===0?0:Math.min(1,Math.sqrt(p)/i);return{differing:c,coherent:d,clusters:u,largestCluster:f,mass:g,score:1-g}}var EH={r:255,g:255,b:255,a:255};function AN(e,t,n={}){if(jd(e,"compareImages(reference)"),jd(t,"compareImages(candidate)"),!_h(e,t))throw new Error(`compareImages: cannot compare ${e.width}x${e.height} against ${t.width}x${t.height}`);let r=n.alphaMode??"premultiplied",i=n.deltaEBackground??EH,o=r==="premultiplied"?Hd(e):e.data,s=r==="premultiplied"?Hd(t):t.data,a=e.width,c=e.height,l=a*c,d=0,u=0,f=0;for(let v=0;v<l;v++){let w=v*4,k=o[w]-s[w],C=o[w+1]-s[w+1],P=o[w+2]-s[w+2],R=o[w+3]-s[w+3];if(d+=k*k+C*C+P*P+R*R,k===0&&C===0&&P===0&&R===0)u++;else{let N=Math.max(Math.abs(k),Math.abs(C),Math.abs(P),Math.abs(R));N>f&&(f=N)}}let p=l===0?0:d/(l*4),m=p===0?1/0:10*Math.log10(65025/p),g=u===l,h=1,y=1;if(!g&&!n.skipSsim){let v=CN(o,l),w=CN(s,l),k=0;for(let C=0;C<3;C++)k+=Xd(v.rgb[C],w.rgb[C],a,c);h=k/3,y=Xd(v.luma,w.luma,a,c)}let S={mean:0,p95:0,max:0},b=n.severity&&!g?new Float64Array(l):void 0;!g&&!n.skipDeltaE&&(S=OH(e,t,i,b));let I;return n.severity&&(I=g?{differing:0,coherent:0,clusters:0,largestCluster:0,mass:0,score:1}:Bh(b??new Float64Array(l),a,c)),{width:a,height:c,pixels:l,exactPixels:u,exactRatio:l===0?1:u/l,maxChannelDiff:f,mse:p,rmse:Math.sqrt(p),psnr:m,ssim:h,ssimLuma:y,deltaE:S,deltaEBackground:i,alphaMode:r,lossless:g,severity:I}}function CN(e,t){let n=new Float64Array(t),r=new Float64Array(t),i=new Float64Array(t),o=new Float64Array(t);for(let s=0;s<t;s++){let a=s*4;n[s]=e[a],r[s]=e[a+1],i[s]=e[a+2],o[s]=Fh(e[a],e[a+1],e[a+2])}return{rgb:[n,r,i],luma:o}}function OH(e,t,n,r){let i=Kd(e,n),o=Kd(t,n),s=e.width*e.height,a=10001,c=new Uint32Array(a),l=new Float64Array(3),d=new Float64Array(3),u=0,f=0;for(let h=0;h<s;h++){let y=h*3,S=i[y],b=i[y+1],I=i[y+2],v=o[y],w=o[y+1],k=o[y+2];if(S===v&&b===w&&I===k){c[0]++;continue}Ud(S,b,I,l),Ud(v,w,k,d);let C=Lh(l[0],l[1],l[2],d[0],d[1],d[2]);r&&(r[h]=C),u+=C,C>f&&(f=C),c[Math.min(a-1,Math.round(C*100))]++}let p=Math.ceil(s*.95),m=0,g=0;for(let h=0;h<a;h++)if(m+=c[h],m>=p){g=h/100;break}return{mean:s===0?0:u/s,p95:g,max:f}}0&&(module.exports={ANIMATION_MANAGER_INTERPOLATION_POLICY,Arrow,Audio,BASE_FILL_LAYER_ID,BASE_STROKE_LAYER_ID,BROWSER_SVG_EXTENSION_URIS,BUILTIN_MARKER_ID_MAP,CANONICAL_NORMALIZATION_FAULT_POINTS,CC_NS,COLLAB_PROTOCOL_VERSION,COMMON_PROP_DEFAULTS,COMMON_TRANSFORM_NODE_DEFAULTS,CONNECTOR_LABEL_BASELINE_LIFT,CONNECTOR_LABEL_FONT_FAMILY,CONNECTOR_LABEL_FONT_SIZE,CSS_GENERIC_FAMILY_NAMES,CURRENT_SCHEMA_VERSION,CanonicalDocument,Circle,Cloud,Container,ContainerShapeBuilder,Cross,DC_NS,DEFAULT_CONNECTOR_CORNER_RADIUS,DEFAULT_CONNECTOR_LABEL_OFFSET,DEFAULT_CONNECTOR_LABEL_POSITION,DEFAULT_COORDINATE_PRECISION,DEFAULT_FONT_WEIGHT,DEFAULT_RICH_TEXT_STYLE,DOCUMENT_BYTE_KINDS,DOCUMENT_FIELDS,DOCUMENT_FIELD_LIVE_AUTHORITY,DOCUMENT_IMPORT_INTENTS,DOCUMENT_IMPORT_KINDS,DOCUMENT_INGEST_POLICIES,DOCUMENT_SECTION_ORDER,DocumentBuilder,DocumentModel,DocumentSession,EASING_CURVES,EasingType,Ellipse,FLOWCHART_GEOMETRY_DEFAULTS,GEOMETRY_TRACK_PROPERTIES,Gear,HEADLESS_SVG_STYLE_ENVIRONMENT,Heart,Hyperlink,IDENTITY_AFFINE,INGEST_APPLY_STAGES,INGEST_DIAGNOSTIC_CODES,INGEST_DOCUMENT_ROOT_IDENTITY,INGEST_FEATURES,INGEST_FEATURE_CAPABILITIES,INGEST_PLAN_VERSION,INGRESS_INTENTS,INITIAL_ROOT_FONT_SIZE,INLINE_CHILD_CONTAINER_TYPES,ImageShape,IngestApplicationError,KNOWN_METADATA_PREFIXES,KNOWN_STATE_KEYS,LAYER_PRESENTATION_IDS,LIBRARY_ASSEMBLY_KIND_ORDER,LIBRARY_EMIT_ORDER,LIBRARY_KINDS,Lightning,Line,LinearGradientBuilder,MARKER_HEIGHT,MARKER_VIEWBOX,MARKER_WIDTH,MATHML_EXTENSION_URI,MAX_COORDINATE_PRECISION,MIGRATIONS,NAMESPACE_VOCABULARIES,NGon,NON_RENDERING_LIBRARY_KINDS,NON_WIRE_PROP_KEYS,NUMERIC_SHAPE_TRANSFORM_STATE_KEYS,NestedSvg,NodeSchemaRegistry,PAINT_SERVER_PASSTHROUGH_ATTR,PATH_DATA_TRACK_PROPERTIES,POLYGON_GEOMETRY_DEFAULTS,PRESENTATION_SEMANTICS,PUZZLE_DEFAULTS,Path,PathCurveType,PathPointType,PatternBuilder,Polyline,RDF_NS,RENDER_DIAGNOSTIC_CODES,RENDER_FEATURES,RENDER_FEATURE_CAPABILITIES,RENDER_TARGETS,RICH_TEXT_STYLE_KEYS,RadialGradientBuilder,Rectangle,Ring,SAXES_SVG_XML_PARSER_HOST,SCRIPT_ANIMATION_GENERATORS,SERIALIZED_SHAPE_STATE_KEYS,SHAPE_ENVELOPE_KEYS,SHAPE_GEOMETRY_DEFAULTS,SHAPE_TRANSFORM_STATE_KEYS,SVGSKETCH_NS,SVGSKETCH_PATH_EXTENSIONS,SVG_CONDITIONAL_PROCESSING_ATTRIBUTES,SVG_IMPORT_CAPABILITY_OWNERS,SVG_NAMESPACE,SVG_NS,SVG_PRESENTATION_PROPERTIES,SVG_WELL_KNOWN_NAMESPACE_URIS,SceneGraph,SceneNode,ShapeBuilder,ShapeReference,SpeechBubble,Spiral,Square,Star,SvgImportError,SvgSourceDecodingError,SvgXmlParserHostError,Switch,TEXT_PATH_GENERATED_ID_PREFIX,TYPED_FIELD_PREDICATES,Text,TextLayoutEngine,Timeline,Track,Triangle,VARIANT_INTERPOLATION_POLICY,Video,View,WRAPPER_PRESENTATION_IDS,XHTML_EXTENSION_URI,accumulateAnimationValue,addAnimationValues,addSmilPointsValues,affine,affineFromArray,affineToArray,almostEqualAffine,animationBackwardsFillTrack,animationCycleDuration,animationDefinitionTargetShapeId,animationTrackActiveEnd,animationTrackDocumentBegin,appearanceLayers,appendAppearanceLayer,applyAffineToPoint,applyAffineToVector,applyAppearanceStyle,applyClipMaskGroupDelta,applyClipMaskPlanToShapes,applyCssAnimationLonghandOverrides,applyGuideDeltaOp,applyIngestPlan,applyMeasurementDeltaOp,applyMetadataDeltaOp,applyOpToSnapshot,applyOpsInPlace,applyOpsToSnapshot,applyOpsToSnapshotWithAccepted,applyPathNodeValue,applyRichTextFormat,applyTextSplice,applyTextTransform,applyTimingFunctionToKeyframe,arcEndpointToCenter,areTracksTimingEquivalent,around,assembleLibraryDefs,assembleSvgFromPlan,assertIngestFeatureRegistry,assertIngestPolicyRegistry,assertNamespaceVocabularyRegistry,assertRasterImage,assertSvgImportCapabilityOwners,authoredPaintDeclarations,baseFillLayer,baseStrokeLayer,buildCompoundTransformValues,buildDefinitionPlacementIndex,buildForeignImportReport,buildFreshMetadataBlock,buildGuideDeltaOps,buildManagedChildren,buildManagedDescription,buildMeasurementDeltaOps,buildMetadataDeltaOps,buildRenderPlan,buildSmilKeyframeData,buildSmilKeyframes,buildSvgDestinationIdentityIndex,buildSvgIngestPlan,buildSymbolMaterializationPlan,buildViewBoxSmilKeyframeData,canonicalPolygonTransformString,canonicalTransformMatrix,canonicalTransformString,chainHasTargetedEffects,claimElementThroughVocabulary,classifyIngestDiagnostic,classifySvgExternalAssetUrl,clipMaskDefinitionFromGroup,clipMaskDefinitionsFromGroups,clipMaskGroupDefId,clipMaskGroupDefinitionId,clipMaskGroupIsRawBacked,clipMaskGroupWithDefinition,clipMaskOwnedDefIds,cloneTextSpanTree,collaborationResourceKey,collectDocumentEnvelopeLibraryReferenceIds,collectFontFacesFromPlan,collectFontFamiliesFromPlan,collectMarkerReferences,collectReferencedLibraryDefs,collectReferencedMarkerIds,collectSvgFragmentLibraryReferenceIds,collectUnknownDocumentFields,compareImages,compareOrderKeys,composeDecomposedTransformMatrix,compositeOver,computeArrowVertices,computeCatmullRomSegments,computeCloudPath,computeCrossVertices,computeDashArray,computeFlowchartBoxPath,computeGearPath,computeGearVertices,computeHeartPath,computeLightningVertices,computePolygonVertices,computeRectanglePath,computeRingPath,computeSpeechBubbleVertices,computeSpiralPath,computeSplinePath,computeStarVertices,connectorLabelAnchor,containerTransformNeedsContentPivot,convertGradientUnits,createDocument,createSceneNode,createShape,createSvgDestinationIdAllocator,createSvgPathMetrics,createTextLayoutKey,createTextLayoutProduct,createViewbox,createWordSearchPrimitiveMask,cssAnimationFillField,cssNamedColorToRgb,cubicBezierExtent1D,cubicBezierToEasingFields,customPatternDefToLibraryDef,declaredRichTextDeltaKeys,decodeCssEscapes,decodeSvgSourceBytes,decomposeAffine2D,decoratePlanNodes,decorateSnapshotShapes,dedupeFontFaces,defaultVariableMode,deltaE2000,deriveRichTextFormatRanges,deriveSegments,deriveTextSplice,derivedConnectionPoints,detachAppearanceStyle,documentObjectBounds,ellipticalArcBounds,emptyDocumentMetadata,ensureTextSpanRange,escXml,evaluateEasing,evaluateFontCoverage,evaluateKeyframeEasing,evaluateLinearEasing,evaluateParsedTimingFunction,evaluateSteps,evaluateSvgConditionalProcessing,expandAppearanceStack,extractVariables,filterAttr,filterChainExtendsBounds,filterChainGroupId,filterChainGroups,filterDefinitionEnvelope,filterReferenceValue,finalizeRenderPlan,findShapeById,fingerprintCssAnimationDocumentStyles,fingerprintCssAnimationInlineStyles,fingerprintCssAnimationTrack,fingerprintIngestSource,flattenShapeStateTree,flattenStateExtra,flattenUnknownDocumentFields,foldSchemaV2AncestorTransformIntoMatrix,fontFaceKey,forEachAppearanceLayerRef,forEachAppearanceStyleRef,forEachLibraryRefInState,forEachMarkerRefInState,forEachReachableShape,forEachShapeInLibraryDefs,formatCssFontFamilyList,formatOperationValidationIssues,formatSmilKeySpline,formatSmilKeyTime,freezeIngestPlan,freezeSiblingOrderKeys,generateCode,generateCodeWithDiagnostics,generateCssCode,generateD3Code,generateId,generatePatternSvgContent,generatePuzzlePieces,generateReactCode,generateSudokuPuzzle,generateSvgCode,generateVueCode,generateWordSearch,geometryDefinitionId,geometryState,getBuiltInMarkerDefs,getEasingCubicBezier,getEffectivePrecision,getIngestFeatureCapability,getIngestFieldPolicy,getKeyframeCubicBezier,getLicenseLabel,getLicenseUrl,getMarkerDescriptors,getPatternElements,getShapeGeometryKernel,getSmilAccumulate,getSmilAdditive,getSmilBeginValue,getSmilFillMode,getSmilMotionKeyPoints,getSmilRepeatCount,getSmilSetBeginValue,getSmilTrackDuration,getSvgCoordinateAttributePrecision,getSvgPropertySemantics,getSvgSourceAttribute,getSvgSourceHref,getWordSearchDirections,gradientStopPoint,gradientTransformAttribute,hasAnyTypedMetadataField,hasEmittableSmilSimpleDuration,hasOpaqueSvgAncestor,hasSvgSourceAttribute,importSvg,importSvgWithDiagnostics,indexLibraryDefinitions,inferSvgCoordinatePrecision,initialOrderKeys,injectClipMaskReference,inspectCssTransformValue,interpolateAngle,interpolateCharOffsetArray,interpolateColor,interpolateDasharrayLists,interpolateGradient,interpolateNumericArray,interpolatePathData,interpolatePlainObject,interpolatePointArray,interpolatePolylinePoints,interpolateShapeTrees,interpolateSplinePointArray,invertAffine,isColorValue,isConnectorLineState,isCssAnimationDeclarationName,isCssGenericFamilyName,isCssNamedColor,isDefaultKeyPoints,isDefaultKeyTimes,isDocumentImportIntent,isEntirelyUnembeddableFamilyList,isFiniteAffineArray,isGeometryTrackProperty,isGradientLike,isIdentityAffine,isIdentityLinearSplines,isIndefiniteSetTrack,isIndefiniteSmilSimpleDuration,isNumericArray,isPathDataTrackProperty,isPathNodeTrack,isReusablePatternTile,isSafeGradientRootAttributeName,isSafePatternRootAttributeName,isSetSequenceTrack,isSvgPresentationProperty,isTextPathGeneratedId,isUnembeddableFamilyName,isValidOrderKey,keyBetween,keysBetween,layerFilterTargets,layerPaints,layerState,layoutText,legacyEndpointMarkerId,lerpNumber,linearGradient,linearGradientEnvelope,lintWordSearchOptions,lowerPathNodeTracks,luma709,mapAnimationTrackTime,matchCubicBezierToPreset,materializeSceneTreeOrderKeys,matrixTransformPart,maxCollaborationTimestamp,mergeRichTextStyle,migrateSnapshot,migrateV11toV12,migrateV14toV15,migrateV15toV16,migrateV16toV17,migrateV17toV18,migrateV18toV19,migrateV6toV7,migrateViewboxSidecarToViews,motionPathD,moveResourceById,multiplyAffine,mutateSvgClipMaskDefinitionMarkup,namespaceVocabularies,namespaceVocabulary,needsAppearanceStack,nodeSchemas,normalizeClipMaskGroups,normalizePaintServerDef,normalizeRichTextRuns,normalizeRichTextStyle,normalizeRichTextStyleDelta,normalizeSmilPointsValue,normalizeSnapshotStructure,normalizeSnapshotToCanonicalDocument,orderSiblings,paintingLayers,parseColor,parseCssAnimationShorthand,parseCssTimingFunction,parseCssTransformOrigin,parseDocument,parseDocumentWithDiagnostics,parseFontFamilyList,parseInterpolationNumbers,parsePathNodeProperty,parsePreserveAspectRatio,parseSmilAdditive,parseSmilClockValue,parseSmilDuration,parseSmilFillField,parseSmilKeySplines,parseSmilKeyTimes,parseSmilRepeatSettings,parseSmilValues,parseSvgAbsoluteLength,parseSvgLength,parseSvgLengthList,parseSvgLengthToken,parseSvgPathData,parseSvgRootFrame,parseSvgSourceDocument,parseSvgStyleAttribute,parseSvgTransformList,parseSvgViewBox,parseSvgatorPayload,parseVariableArgs,parseWordSearchWords,partitionShapeStateTree,partitionStateExtra,partitionUnknownDocumentFields,pathCommandStructuresMatch,pathDataBounds,pathNodeTracksAreSuperseded,pattern,patternDefinitionEnvelope,patternLibraryDefToCustomPatternDef,patternTileSize,pickCssAnimationListItem,plainTextOf,plainTextStyle,planClipMaskGroups,planSnapshotExternalEffects,planSvgAnimations,planSvgAuthoredAttributes,planSvgClipMasks,planSvgConditionalProcessing,planSvgContainerHierarchy,planSvgDocumentExtensions,planSvgEmbeddedFrames,planSvgExternalEffects,planSvgFilters,planSvgGradients,planSvgImport,planSvgLeafGeometry,planSvgMarkers,planSvgMetadata,planSvgOccurrenceViewports,planSvgPaintServerDefinitions,planSvgPatterns,planSvgResourceDependencies,planSvgScripts,planSvgSourceIdentifiers,planSvgStyleCascade,planSvgSymbolUses,planSvgUseOccurrences,planSvgViews,planTransformFusion,planVariantTransitions,planVariantTransitionsCss,planVariantTransitionsSmil,planVariantTransitionsWaapi,planViewBoxFusion,preferredSubsetsForText,premultiply,prepareSvgAuthorCssForLiveProjection,prepareSvgExternalAssetUrlForLiveProjection,prepareSvgMarkupForLiveProjection,prepareSvgXmlSource,preserveAspectRatioAlignFactor,projectClipMaskDefinitionAnimations,projectCssTransformStops,projectDefinitionAnimations,projectPresentation,projectPresentationEntry,projectSceneTreeOntoClipMaskGroups,projectSceneTreeOntoShapes,projectSvgAnimationPlan,projectSvgAnimationTimeline,projectSvgImportToIngestPlan,projectSvgImportToSnapshot,projectSvgSourceNodes,projectSvgatorAnimation,projectTextLinePosition,projectTextSpanRotations,promoteManagedDescription,promoteRebasedShapeUpdateClock,pruneAndWrapSubtree,quadraticBezierExtent1D,radialGradient,radialGradientEnvelope,rebaseRichTextFormatRanges,rebaseRichTextRuns,recognizeScriptAnimation,reflectCubicBezier,registerNamespaceVocabulary,registeredExtensionUris,registeredShapeGeometryTypes,removeResourceById,removeResourceByKey,removeResourceByName,removeTrackKeyframe,renderAnimationElements,renderBuiltinMarkerDefs,renderCircle,renderClipMaskDefinitionAnimationElements,renderClipMaskDefinitionShape,renderDefinitionAnimationElements,renderDescriptiveElements,renderDocumentAnimationElements,renderDocumentExtensionAttributes,renderDocumentExtensionNodes,renderDocumentExtensions,renderDocumentScripts,renderDocumentStyles,renderEllipse,renderFilterDefs,renderFilterElement,renderFilterLibraryDef,renderFilterPrimitive,renderFilterPrimitivesForType,renderFlowchartBox,renderForeignObject,renderGradientDefs,renderGradientStopAnimationElement,renderImage,renderLibraryDef,renderLibraryDefs,renderLine,renderLinearGradient,renderLinearGradientLibraryDef,renderMarkerLibraryDef,renderPaintServerDefs,renderPatternLibraryDef,renderPlanDefsBody,renderPolygonShape,renderPolyline,renderRadialGradient,renderRadialGradientLibraryDef,renderRectangle,renderReferencedLibraryDefs,renderResolvedSymbolDefinitionForest,renderResolvedSymbolDefinitionSubtree,renderResolvedSymbolLibraryDef,renderShape,renderShapeContextForLibrary,renderSpline,renderSvgPrimitiveChainFilter,renderSymbolInstance,renderSymbolLibraryDef,renderTemplateVariablesStyle,renderText,renderTextSpanAnimationElements,renderToSvg,renderToSvgWithDiagnostics,renderVariantTransitionScript,renderVariantTransitionStylesheet,replaceClipMaskDefinition,replaceClipMaskGroupsInSceneTree,replaySceneTreePlacements,requiredDecimalPrecision,requiredSubsetsForText,resolveAppearanceStyle,resolveConnectorAnchorFromDocument,resolveConnectorEndpoints,resolveContainerTransform,resolveContainerTransformFromContentBounds,resolveCssAnimationEasingType,resolveEmbeddedSvgTransform,resolveEmbeddedSvgViewportFrameBounds,resolveFontStyle,resolveFontWeight,resolveGradientGeometry,resolveGradientLibraryDef,resolveInlineContainerTransform,resolveMetadataQName,resolvePasteWrapperViewportSize,resolvePathDAtTime,resolvePatternLibraryDef,resolvePatternTile,resolveRichTextStyleAt,resolveRootViewportFraming,resolveShapeGeometry,resolveShapeLocalObjectBounds,resolveShapeObjectBounds,resolveShapeReferenceTransform,resolveStyledTextLines,resolveSvgGradientGeometry,resolveSvgLengthToken,resolveSvgPatternTile,resolveSvgQName,resolveSvgRectRadii,resolveSvgTextSpanTarget,resolveSvgViewport,resolveSymbolDefinitionForestRootIds,resolveSymbolInstanceContent,resolveSymbolInstanceShapes,resolveSymbolInstanceTransform,resolveSymbolViewport,resolveTextSpanProjection,rewriteDocumentEmbeddedPayloads,rewriteIdReferencesInMarkup,rewriteShapeStateEmbeddedPayloads,rewriteSvgResourceReferenceValue,richTextFontVariantCss,richTextLineSpans,richTextRunsFromState,richTextStyleDelta,richTextStyleDeltasEqual,richTextStylesEqual,richTextTspanAttributes,rootMetadataAttrs,rootPaintServerDefId,rotateAffine,roundCoord,roundMarkupCoordinates,roundNumberString,roundSerializedShape,roundSnapshot,routeConnector,runsFromSegments,sameSize,sampleAnimationTrackTime,sampleTextForSubsets,sanitizeRichTextFormatRanges,sanitizeXmlId,scaleAffine,scanCssFunctionTokens,scanCssLocalUrlTokens,senderCorrectionsForOp,serializeSvgPathData,serializedPathNodeGeometry,serializedPresentationReader,severity,shapeAppearanceLayers,shapeAppearanceStyle,shapeLocalObjectBounds,shapeLocalObjectCenter,shapeNeedsAppearanceExpansion,shapeObjectBoundsInSpace,shapeOutlineCapability,shouldRoundSvgCoordinateAttribute,skewXAffine,skewYAffine,smilKeyframeAttributes,snapshotBoundsView,sniffDocumentBytes,solveCubicBezier,solveSudoku,spliceTextSpanTree,splinePathBounds,splitAppearanceForStyle,splitCssAnimationList,splitCssTopLevel,splitCssTopLevelRanges,splitTopLevelElements,srgbToLab,ssimPlane,stringifyDocument,stripAnimationDeclarations,stripCssAnimationInlineStyle,subsetsForCodePoint,substituteString,substituteVariables,symbolDefinitionSemanticHash,symbolInstanceTargetId,synthesizeCssAnimationShorthand,templateVariablesCss,textPathGeneratedId,textSpanEffectiveRotations,textSpanIds,textSpanNodeById,textSpanRangeByIds,transformSplice,transformSvgPathData,translateAffine,translateSvgPathData,tryParseSvgTransformList,unmatchedDecorationDiagnostics,updateGradientLibraryDef,upsertResourceById,upsertResourceByKey,upsertResourceByName,upsertTrackKeyframe,validateDocumentOperations,validateOperation,validatePresenceOperation,validateSnapshot,validateSudokuPuzzle,verticesToPath,visitShapeTree,visitSnapshotShapeTrees,writeAppearanceLayers});
|
|
98
|
+
`)}function rh(e,t){return Lx(e,t).code}function Lx(e,t){let n=new ka;return{code:fm(n,()=>J2(e,t)),diagnostics:n.diagnostics}}function J2(e,t){let n=tH(e,t),r={...t};return Wv(eH(n,r))}function eH(e,t){switch(t.format){case"svg":return qg(e,t);case"react":return Qg(e,t);case"vue":return Jg(e,t);case"d3":return th(e,t);case"css":return nh(e,t);default:throw new Error(`Unsupported code format: ${t.format}`)}}function tH(e,t){if(Array.isArray(e)){let n=NR(e);return{shapes:e,viewboxes:[{id:"default",x:0,y:0,width:t.width??800,height:t.height??600}],...n.length>0?{library:n}:{}}}return e}var ih=class e{_snapshot;constructor(t={}){let{width:n=800,height:r=600,viewboxId:i}=t,o=Ho(0,0,n,r,i);this._snapshot=la({viewboxes:[o]})}static fromSnapshot(t){let n=new e;return n._snapshot=JSON.parse(JSON.stringify(t)),n}static fromJSON(t,n){let r=om(t,n),i=new e;return i._snapshot=r,i}static fromSVG(t,n){return e.fromSnapshot(mg(t,n))}add(t){let n="build"in t&&typeof t.build=="function"?t.build():t;return this._snapshot.shapes.push(n),this}addAll(...t){for(let n of t)this.add(n);return this}remove(t){let n=this._snapshot.shapes.length;return this._snapshot.shapes=this._snapshot.shapes.filter(r=>r.id!==t),this._snapshot.shapes.length<n}get shapes(){return this._snapshot.shapes}findShape(t){return this._snapshot.shapes.find(n=>n.id===t)}size(t,n){return this._snapshot.viewboxes.length>0?(this._snapshot.viewboxes[0].width=t,this._snapshot.viewboxes[0].height=n):this._snapshot.viewboxes=[Ho(0,0,t,n)],this}get width(){return this._snapshot.viewboxes[0]?.width??800}get height(){return this._snapshot.viewboxes[0]?.height??600}title(t){return this._ensureMetadata(),this._snapshot.documentMetadata.title=t,this}description(t){return this._ensureMetadata(),this._snapshot.documentMetadata.description=t,this}author(t){return this._ensureMetadata(),this._snapshot.documentMetadata.author=t,this}keywords(...t){return this._ensureMetadata(),this._snapshot.documentMetadata.keywords=t,this}license(t,n){return this._ensureMetadata(),this._snapshot.documentMetadata.license=t,n!==void 0&&(this._snapshot.documentMetadata.licenseUrl=n),this}language(t){return this._ensureMetadata(),this._snapshot.documentMetadata.language=t,this}customMetadata(t){return this._ensureMetadata(),this._snapshot.documentMetadata.customMetadata={...this._snapshot.documentMetadata.customMetadata,...t},this}get meta(){return this._snapshot.documentMetadata}defineSymbol(t,n,r){let i=me(),o=n.map(l=>"build"in l&&typeof l.build=="function"?l.build():l),s={kind:"symbol",id:i,name:t,shapes:o};r?.thumbnail&&(s.thumbnail=r.thumbnail),r?.defKind&&(s.defKind=r.defKind),r?.definitionPlacement&&(s.definitionPlacement=r.definitionPlacement);let a={...r?.rootAttributes??{}},c=a.viewBox;delete a.viewBox,r?.viewBox!==null&&(s.viewBox=r?.viewBox??c??"0 0 100 100");for(let l of["preserveAspectRatio","x","y","width","height","refX","refY"])r?.[l]!==void 0?s[l]=r[l]:s[l]===void 0&&a[l]!==void 0&&(s[l]=a[l]),delete a[l];return Object.keys(a).length>0&&(s.rootAttributes=a),r?.variantAxes&&(s.variantAxes=r.variantAxes),r?.variants&&(s.variants=Object.fromEntries(Object.entries(r.variants).map(([l,d])=>[l,d]))),r?.variantThumbnails&&(s.variantThumbnails=r.variantThumbnails),this._pushLibraryDef(s),i}placeSymbolInstance(t,n,r,i={}){let o=i.width,s=i.height,a={symbolId:t,x:n,y:r,width:o??100,height:s??100},c=i.authoredUseGeometry??{x:String(n),y:String(r),...o!==void 0?{width:String(o)}:{},...s!==void 0?{height:String(s)}:{}};Object.keys(c).length>0&&(a.authoredUseGeometry=c),i.variantKey&&(a.variantKey=i.variantKey),i.symbolOverrides&&(a.symbolOverrides=i.symbolOverrides),i.instancePresentation&&(a.instancePresentation=i.instancePresentation);let l={id:me(),type:"symbol-instance",state:a};return this._snapshot.shapes.push(l),this}removeSymbol(t){if(!this._snapshot.library)return!1;let n=this._snapshot.library.length;return this._snapshot.library=this._snapshot.library.filter(r=>!(r.kind==="symbol"&&r.id===t)),this._snapshot.library.length<n}get symbols(){return(this._snapshot.library??[]).filter(t=>t.kind==="symbol")}defineMarker(t,n,r){let i=me(),o=n.map(a=>"build"in a&&typeof a.build=="function"?a.build():a),s={kind:"marker",id:i,name:t,viewBox:r?.viewBox??"0 0 10 10",refX:r?.refX??5,refY:r?.refY??5,markerWidth:r?.markerWidth??10,markerHeight:r?.markerHeight??10,markerUnits:r?.markerUnits??"strokeWidth",orient:r?.orient??"auto",shapes:o};return r?.preserveAspectRatio!==void 0&&(s.preserveAspectRatio=r.preserveAspectRatio),r?.authoredGeometry&&(s.authoredGeometry={...r.authoredGeometry}),r?.rootAttributes&&(s.rootAttributes={...r.rootAttributes}),r?.thumbnail&&(s.thumbnail=r.thumbnail),this._pushLibraryDef(s),i}defineFilter(t,n,r){let i=me(),o={kind:"filter",id:i,name:t,filters:n};return r?.colorInterpolation&&(o.colorInterpolation=r.colorInterpolation),r?.filterUnits&&(o.filterUnits=r.filterUnits),r?.primitiveUnits&&(o.primitiveUnits=r.primitiveUnits),r?.x!==void 0&&(o.x=r.x),r?.y!==void 0&&(o.y=r.y),r?.width!==void 0&&(o.width=r.width),r?.height!==void 0&&(o.height=r.height),r?.thumbnail&&(o.thumbnail=r.thumbnail),this._pushLibraryDef(o),i}defineLinearGradientLibrary(t,n,r){let i=me(),o="build"in n?n.build():n,{id:s,sourceId:a,...c}=o,l={kind:"linear-gradient",id:i,name:t,gradient:c};return r?.thumbnail&&(l.thumbnail=r.thumbnail),this._pushLibraryDef(l),i}defineRadialGradientLibrary(t,n,r){let i=me(),o="build"in n?n.build():n,{id:s,sourceId:a,...c}=o,l={kind:"radial-gradient",id:i,name:t,gradient:c};return r?.thumbnail&&(l.thumbnail=r.thumbnail),this._pushLibraryDef(l),i}definePatternLibrary(t,n,r){let i=me(),o="build"in n?n.build():n,{id:s,sourceId:a,customPatternId:c,...l}=o,d={kind:"pattern",id:i,name:t,pattern:l};return r?.thumbnail&&(d.thumbnail=r.thumbnail),this._pushLibraryDef(d),i}removeLibraryDef(t){if(!this._snapshot.library)return!1;let n=this._snapshot.library.length;return this._snapshot.library=this._snapshot.library.filter(r=>r.id!==t),this._snapshot.library.length<n}get library(){return this._snapshot.library??[]}_pushLibraryDef(t){this._snapshot.library||(this._snapshot.library=[]);let n=this._snapshot.library.findIndex(r=>r.id===t.id);n>=0?this._snapshot.library[n]=t:this._snapshot.library.push(t)}addClipGroup(t,n,r){this._snapshot.clipMaskGroups||(this._snapshot.clipMaskGroups=[]);let i=me(),o={id:i,type:"clip",clipShapeIds:t,contentShapeIds:n,parentId:null};return r?.clipPathUnits&&(o.clipPathUnits=r.clipPathUnits),r?.definitionPlacement&&(o.definitionPlacement=r.definitionPlacement),r?.clipRule&&(o.clipRule=r.clipRule),r?.rawDefinition&&(o.rawDefinition=r.rawDefinition),this._snapshot.clipMaskGroups.push(o),i}addMaskGroup(t,n,r){this._snapshot.clipMaskGroups||(this._snapshot.clipMaskGroups=[]);let i=me(),o={id:i,type:"mask",clipShapeIds:t,contentShapeIds:n,parentId:null};return r?.maskUnits&&(o.maskUnits=r.maskUnits),r?.maskContentUnits&&(o.maskContentUnits=r.maskContentUnits),r?.maskBounds&&(o.maskBounds=r.maskBounds),r?.maskType&&(o.maskType=r.maskType),r?.definitionPlacement&&(o.definitionPlacement=r.definitionPlacement),r?.rawDefinition&&(o.rawDefinition=r.rawDefinition),this._snapshot.clipMaskGroups.push(o),i}removeClipMaskGroup(t){if(!this._snapshot.clipMaskGroups)return!1;let n=this._snapshot.clipMaskGroups.length;return this._snapshot.clipMaskGroups=this._snapshot.clipMaskGroups.filter(r=>r.id!==t),this._snapshot.clipMaskGroups.length<n}addGuide(t,n,r){this._snapshot.guides||(this._snapshot.guides=[]);let i=me(),o={id:i,orientation:t,position:n,controlPointOffset:0};return r?.color&&(o.color=r.color),r?.opacity!==void 0&&(o.opacity=r.opacity),this._snapshot.guides.push(o),i}removeGuide(t){if(!this._snapshot.guides)return!1;let n=this._snapshot.guides.length;return this._snapshot.guides=this._snapshot.guides.filter(r=>r.id!==t),this._snapshot.guides.length<n}clearGuides(){return this._snapshot.guides=[],this}get guides(){return this._snapshot.guides??[]}addMeasurement(t,n,r){this._snapshot.measurements||(this._snapshot.measurements=[]);let i=me(),o={id:i,type:t,points:n,visible:r?.visible??!0,snapDivisions:r?.snapDivisions??1};return r?.color&&(o.color=r.color),r?.opacity!==void 0&&(o.opacity=r.opacity),this._snapshot.measurements.push(o),i}removeMeasurement(t){if(!this._snapshot.measurements)return!1;let n=this._snapshot.measurements.length;return this._snapshot.measurements=this._snapshot.measurements.filter(r=>r.id!==t),this._snapshot.measurements.length<n}get measurements(){return this._snapshot.measurements??[]}addCustomPattern(t,n,r,i){let o=me();return this._pushLibraryDef(ba({id:o,name:t,svgContent:n,width:r,height:i})),o}removeCustomPattern(t){let n=this._snapshot.library;if(!n)return!1;let r=n.length;return this._snapshot.library=n.filter(i=>!(i.kind==="pattern"&&i.id===t)),this._snapshot.library.length<r}get customPatterns(){let t=[];for(let n of this._snapshot.library??[]){if(n.kind!=="pattern")continue;let r=Jp(n);r&&t.push(r)}return t}bringToFront(t){let n=this._snapshot.shapes.findIndex(r=>r.id===t);if(n>=0){let[r]=this._snapshot.shapes.splice(n,1);this._snapshot.shapes.push(r)}return this}sendToBack(t){let n=this._snapshot.shapes.findIndex(r=>r.id===t);if(n>=0){let[r]=this._snapshot.shapes.splice(n,1);this._snapshot.shapes.unshift(r)}return this}reorder(t,n){let r=this._snapshot.shapes.findIndex(i=>i.id===t);if(r>=0){let[i]=this._snapshot.shapes.splice(r,1),o=Math.max(0,Math.min(n,this._snapshot.shapes.length));this._snapshot.shapes.splice(o,0,i)}return this}defineVariable(t,n,r,i){this._snapshot.templateVariables||(this._snapshot.templateVariables=[]);let o=this._snapshot.templateVariables.find(s=>s.name===t);if(o)o.type=n,o.defaultValue=r,i?.label!==void 0&&(o.label=i.label),i?.description!==void 0&&(o.description=i.description);else{let s={name:t,type:n,defaultValue:r};i?.label!==void 0&&(s.label=i.label),i?.description!==void 0&&(s.description=i.description),this._snapshot.templateVariables.push(s)}return this}removeVariable(t){return this._snapshot.templateVariables&&(this._snapshot.templateVariables=this._snapshot.templateVariables.filter(n=>n.name!==t)),this}get variables(){return this._snapshot.templateVariables??[]}inspectVariables(){return am(this._snapshot)}setTimeline(t){return"build"in t&&typeof t.build=="function"?this._snapshot.animationTimeline=t.build():this._snapshot.animationTimeline=t,this}clearTimeline(){return delete this._snapshot.animationTimeline,this}get timeline(){return this._snapshot.animationTimeline}toSVG(t){let{variables:n,...r}=t??{},i=jl(this._snapshot,n);return Qa(i,r)}toSVGWithDiagnostics(t){let{variables:n,...r}=t??{},i=jl(this._snapshot,n);return Fd(i,r)}toJSON(t){return im(this._snapshot,t)}toSnapshot(){return JSON.parse(JSON.stringify(this._snapshot))}toCode(t,n){return rh(this._snapshot,{...n,format:t})}_ensureMetadata(){this._snapshot.documentMetadata||(this._snapshot.documentMetadata={title:"",description:"",author:"",keywords:[],license:"",licenseUrl:"",language:"en",customMetadata:{}})}};var oh=class{_track;constructor(t,n){this._track={id:me(),shapeId:t,property:n,keyframes:[],enabled:!0,locked:!1}}id(t){return this._track.id=t,this}keyframe(t,n,r="linear"){return this._track.keyframes.push({id:me(),time:t,value:n,easing:r}),this}keyframeBezier(t,n,r){return this._track.keyframes.push({id:me(),time:t,value:n,easing:"custom-bezier",customBezier:r}),this}keyframeLinear(t,n,r){return this._track.keyframes.push({id:me(),time:t,value:n,easing:"linear-function",linearPoints:r}),this}keyframes(...t){return this._track.keyframes.push(...t.map(n=>({...n,id:n.id??me()}))),this}disabled(){return this._track.enabled=!1,this}locked(){return this._track.locked=!0,this}motionPath(t){return this._track.motionPath=t,this}motionPathRef(t,n="trackShape"){return this._track.motionPathRef={shapeId:t,mode:n},this}beginTrigger(t,n){return this._track.beginTrigger={type:t,value:n},this}endTrigger(t,n){return this._track.endTrigger={type:t,value:n},this}cycleDuration(t){return this._track.cycleDuration=t,this}cycleRepeats(t){return this._track.cycleRepeats=t,this}infinite(){return this._track.cycleInfinite=!0,this}cycle(t){return this._track.cycleBehavior=t,this}transformOrigin(t,n){return this._track.transformOrigin={x:t,y:n},this._track.targetTransformOrigin=void 0,this}motionRotate(t){return this._track.motionRotate=t,this}additive(t){return this._track.additive=t,this}accumulate(t="sum"){return this._track.accumulate=t,this}fill(t){return this._track.fill=t,this}fillBackwards(t=!0){return this._track.fillBackwards=t,this}build(){let t=[...this._track.keyframes].sort((n,r)=>n.time-r.time);return{...this._track,keyframes:t}}},sh=class{_duration;_loop=!1;_playbackSpeed=1;_tracks=[];constructor(t){this._duration=t}loop(t=!0){return this._loop=t,this}speed(t){return this._playbackSpeed=t,this}duration(t){return this._duration=t,this}addTrack(t){return this._tracks.push(t),this}addTracks(...t){return this._tracks.push(...t),this}buildTimeline(){return{duration:this._duration,loop:this._loop,playbackSpeed:this._playbackSpeed,tracks:this._tracks.map(t=>t.build())}}build(){let t=this.buildTimeline();return{duration:t.duration,loop:t.loop,playbackSpeed:t.playbackSpeed,tracks:t.tracks.map(n=>({id:n.id,shapeId:n.shapeId,property:n.property,enabled:n.enabled,locked:n.locked||void 0,motionPath:n.motionPath,motionPathRef:n.motionPathRef,beginTrigger:n.beginTrigger,endTrigger:n.endTrigger,cycleDuration:n.cycleDuration,simpleDuration:n.simpleDuration,cycleRepeats:n.cycleRepeats,cycleInfinite:n.cycleInfinite,cycleBehavior:n.cycleBehavior,fillBackwards:n.fillBackwards,transformOrigin:n.transformOrigin,targetTransformOrigin:n.targetTransformOrigin,motionRotate:n.motionRotate,additive:n.additive,accumulate:n.accumulate,fill:n.fill,keyframes:n.keyframes.map(r=>({id:r.id,time:r.time,value:r.value,easing:r.easing,...r.customBezier?{customBezier:r.customBezier}:{},...r.linearPoints?{linearPoints:r.linearPoints}:{}}))}))}}};var tn=class{_id;_type;_state={};constructor(t,n){this._type=t,this._id=n??me()}id(t){return this._id=t,this}locked(t=!0){return this._state.locked=t,this}visible(t=!0){return this._state.visible=t,this}displayMode(t){return this._state.displayMode=t,this}motionOnly(){return this._state.displayMode="motionOnly",this}fill(t,n){return this._state.fillColor=t,this._state.fillType="solid",n!==void 0&&(this._state.fillOpacity=n),this}noFill(){return this._state.fillType="none",this}fillGradient(t){let n="build"in t?t.build():t;return this._state.fillType=n.type,this._state.fillGradient=n,this}fillPattern(t){let n="build"in t?t.build():t;return this._state.fillType="pattern",this._state.fillGradient=n,this}fillOpacity(t){return this._state.fillOpacity=t,this}fillRule(t){return this._state.fillRule=t,this}addFill(t,n){let r={id:`fill-${this.nextLayerOrdinal("fill")}`,kind:"fill",color:t,paintType:"solid"};return n!==void 0&&(r.opacity=n),this.pushAppearanceLayer(r),this}addStroke(t,n){let r={id:`stroke-${this.nextLayerOrdinal("stroke")}`,kind:"stroke",color:t,paintType:"solid"};return n!==void 0&&(r.width=n),this.pushAppearanceLayer(r),this}pushAppearanceLayer(t){let n=lu(this._state,t);Object.assign(this._state,n)}nextLayerOrdinal(t){let r=(this._state.appearance??[]).filter(i=>i.kind===t).length;return Math.max(r,1)}stroke(t,n){return this._state.borderColor=t,n!==void 0&&(this._state.borderWidth=n),this}noStroke(){return this._state.borderColor="none",this._state.borderWidth=0,this}strokeWidth(t){return this._state.borderWidth=t,this}strokeOpacity(t){return this._state.strokeOpacity=t,this}strokeGradient(t){let n="build"in t?t.build():t;return this._state.strokeType=n.type,this._state.strokeGradient=n,this}strokePattern(t){let n="build"in t?t.build():t;return this._state.strokeType="pattern",this._state.strokeGradient=n,this}strokeLinejoin(t){return this._state.strokeLinejoin=t,this}strokeLinecap(t){return this._state.strokeLinecap=t,this}strokeMiterlimit(t){return this._state.strokeMiterlimit=t,this}dashOffset(t){return this._state.dashOffset=t,this}strokeDasharray(t){return this._state.strokeDasharray=t,this}dash(t,n,r){return this._state.lineStyle=t,t==="custom"&&(n!==void 0&&(this._state.dashLength=n),r!==void 0&&(this._state.gapLength=r)),this}opacity(t){return this._state.opacity=t,this}rotate(t){return this._state.rotation=t,this.refreshTransformMatrix(),this}skew(t,n){return this._state.skewX=t,this._state.skewY=n,this.refreshTransformMatrix(),this}scale(t,n){return this._state.scaleX=t,this._state.scaleY=n??t,this.refreshTransformMatrix(),this}pivot(t,n){return this._state.customPivot={x:t,y:n},this.refreshTransformMatrix(),this}transformMatrix(t){if(t.length<6||!t.slice(0,6).every(Number.isFinite))throw new RangeError("transformMatrix must contain six finite numbers");return this._state.transformMatrix=t.slice(0,6),this}refreshTransformMatrix(){this._state.transformMatrix=Pt(kc(this._state,this.defaultTransformPivot()))}defaultTransformPivot(){let t=this._state.customPivot;if(t)return t;let n=this._state.x,r=this._state.y,i=this._state.width,o=this._state.height;if(n!==void 0&&r!==void 0&&i!==void 0&&o!==void 0)return{x:n+i/2,y:r+o/2};let s=this._state.radius;if(n!==void 0&&r!==void 0&&s!==void 0)return{x:n,y:r};let a=this._state.cx,c=this._state.cy;if(a!==void 0&&c!==void 0)return{x:a,y:c};let l=this._state.x1,d=this._state.y1,u=this._state.x2,f=this._state.y2;if(l!==void 0&&d!==void 0&&u!==void 0&&f!==void 0)return{x:(l+u)/2,y:(d+f)/2};let p=this._state.pathPoints;if(p?.[0])return{x:p[0].x,y:p[0].y};let m=this._state.polylinePoints;if(m?.[0])return m[0]}filter(...t){let n=this._state.filters??[];return this._state.filters=[...n,...t],this}dropShadow(t={}){let n={id:`drop-shadow-${me()}`,type:"drop-shadow",enabled:!0,offsetX:t.offsetX??4,offsetY:t.offsetY??4,blurRadius:t.blurRadius??8,spread:t.spread??0,color:t.color??"#000000",opacity:t.opacity??.3};return this.filter(n)}innerShadow(t={}){let n={id:`inner-shadow-${me()}`,type:"inner-shadow",enabled:!0,offsetX:t.offsetX??2,offsetY:t.offsetY??2,blurRadius:t.blurRadius??4,choke:t.choke??0,color:t.color??"#000000",opacity:t.opacity??.5};return this.filter(n)}blur(t,n,r){let i=t??4,o=n??i,s={id:`gaussian-blur-${me()}`,type:"gaussian-blur",enabled:!0,blurX:i,blurY:o,linked:i===o,quality:r?.quality??"normal"};return this.filter(s)}glow(t={}){let n={id:`glow-${me()}`,type:"glow",enabled:!0,color:t.color??"#ffffff",radius:t.radius??10,intensity:t.intensity??.8};return this.filter(n)}innerGlow(t={}){let n={id:`inner-glow-${me()}`,type:"inner-glow",enabled:!0,color:t.color??"#ffffff",radius:t.radius??10,intensity:t.intensity??.8};return this.filter(n)}grayscale(t=1){let n={id:`grayscale-${me()}`,type:"grayscale",enabled:!0,amount:t};return this.filter(n)}sepia(t=1){let n={id:`sepia-${me()}`,type:"sepia",enabled:!0,amount:t};return this.filter(n)}outline(t={}){return this.filter({id:`outline-${me()}`,type:"outline",enabled:!0,width:t.width??3,color:t.color??"#000000",opacity:t.opacity??1,position:t.position??"outside"})}motionBlur(t={}){let n={id:`motion-blur-${me()}`,type:"motion-blur",enabled:!0,distance:t.distance??10,angle:t.angle??0,quality:t.quality??"normal"};return this.filter(n)}pointLight(t={}){let n={id:`point-light-${me()}`,type:"point-light",enabled:!0,x:t.x??100,y:t.y??100,z:t.z??200,color:t.color??"#ffffff",surfaceScale:t.surfaceScale??5,diffuseConstant:t.diffuseConstant??1,specularConstant:t.specularConstant??1,specularExponent:t.specularExponent??20};return this.filter(n)}spotLight(t={}){let n={id:`spot-light-${me()}`,type:"spot-light",enabled:!0,x:t.x??100,y:t.y??0,z:t.z??200,pointsAtX:t.pointsAtX??100,pointsAtY:t.pointsAtY??100,pointsAtZ:t.pointsAtZ??0,coneAngle:t.coneAngle??30,color:t.color??"#ffffff",surfaceScale:t.surfaceScale??5,specularConstant:t.specularConstant??1,specularExponent:t.specularExponent??20};return this.filter(n)}sharpen(t=1){let n={id:`sharpen-${me()}`,type:"sharpen",enabled:!0,amount:t};return this.filter(n)}pixelate(t=8){let n={id:`pixelate-${me()}`,type:"pixelate",enabled:!0,blockSize:t};return this.filter(n)}warp(t={}){let n={id:`warp-${me()}`,type:"warp",enabled:!0,scale:t.scale??10,frequency:t.frequency??.02,octaves:t.octaves??1,warpType:t.warpType??"turbulence"};return this.filter(n)}morphology(t={}){let n=t.radiusX??2,r=t.radiusY??n,i={id:`morphology-${me()}`,type:"morphology",enabled:!0,operator:t.operator??"dilate",radiusX:n,radiusY:r,linked:t.linked??n===r};return this.filter(i)}contouring(t={}){if((t.mode??"discrete")==="table"){let i={id:`contouring-table-${me()}`,type:"contouring-table",enabled:!0,levels:t.levels??4,contrast:t.contrast??1};return this.filter(i)}let r={id:`contouring-discrete-${me()}`,type:"contouring-discrete",enabled:!0,levels:t.levels??4};return this.filter(r)}roundEdges(t=4){let n={id:`round-edges-${me()}`,type:"round-edges",enabled:!0,radius:t};return this.filter(n)}channelPainter(t={}){let n={id:`channel-painter-${me()}`,type:"channel-painter",enabled:!0,red:t.red??1,green:t.green??1,blue:t.blue??1};return this.filter(n)}brightness(t=1){let n={id:`brightness-${me()}`,type:"brightness",enabled:!0,amount:t};return this.filter(n)}contrast(t=1){let n={id:`contrast-${me()}`,type:"contrast",enabled:!0,amount:t};return this.filter(n)}filterOpacity(t=1){let n={id:`opacity-${me()}`,type:"opacity",enabled:!0,amount:t};return this.filter(n)}invert(t=1){let n={id:`invert-${me()}`,type:"invert",enabled:!0,amount:t};return this.filter(n)}hueRotate(t=0){let n={id:`hue-rotate-${me()}`,type:"hue-rotate",enabled:!0,angle:t};return this.filter(n)}saturate(t=1){let n={id:`saturate-${me()}`,type:"saturate",enabled:!0,amount:t};return this.filter(n)}blackAndWhite(t=.5){let n={id:`black-and-white-${me()}`,type:"black-and-white",enabled:!0,threshold:t};return this.filter(n)}duotone(t={}){let n={id:`duotone-${me()}`,type:"duotone",enabled:!0,shadowColor:t.shadowColor??"#000000",highlightColor:t.highlightColor??"#ffffff"};return this.filter(n)}xray(t=1){let n={id:`xray-${me()}`,type:"xray",enabled:!0,intensity:t};return this.filter(n)}noise(t={}){let n={id:`noise-${me()}`,type:"noise",enabled:!0,amount:t.amount??.3,scale:t.scale??1};return this.filter(n)}emboss(t={}){let n={id:`emboss-${me()}`,type:"emboss",enabled:!0,strength:t.strength??1,angle:t.angle??135};return this.filter(n)}filmGrain(t={}){let n={id:`film-grain-${me()}`,type:"film-grain",enabled:!0,amount:t.amount??.3,size:t.size??1};return this.filter(n)}watercolor(t={}){let n={id:`watercolor-${me()}`,type:"watercolor",enabled:!0,wetness:t.wetness??.5,turbulence:t.turbulence??.5};return this.filter(n)}gouache(t={}){let n={id:`gouache-${me()}`,type:"gouache",enabled:!0,thickness:t.thickness??.5,texture:t.texture??.5};return this.filter(n)}inkBlot(t={}){let n={id:`ink-blot-${me()}`,type:"ink-blot",enabled:!0,spread:t.spread??.5,edges:t.edges??.5};return this.filter(n)}crumpledPlastic(t={}){let n={id:`crumpled-plastic-${me()}`,type:"crumpled-plastic",enabled:!0,wrinkles:t.wrinkles??.5,shine:t.shine??.5};return this.filter(n)}riddled(t={}){let n={id:`riddled-${me()}`,type:"riddled",enabled:!0,density:t.density??.5,size:t.size??1};return this.filter(n)}cssClipPath(t){return this._state.cssClipPath=t,this}cssMaskProperties(t){return this._state.cssMaskProperties=t,this}vectorEffect(t){return this._state.vectorEffect=t,this}transformBox(t){return this._state.transformBox=t,this}paintOrder(t){return this._state.paintOrder=t,this}blendMode(t){return this._state.blendMode=t,this}visibility(t){return this._state.visibility=t,this}shapeRendering(t){return this._state.shapeRendering=t,this}filterColorInterpolation(t){return this._state.filterColorInterpolation=t,this}inheritFill(t=!0){return this._state.inheritFill=t,this}inheritStroke(t=!0){return this._state.inheritStroke=t,this}systemLanguage(t){return this._state.systemLanguage=t,this}requiredExtensions(t){return this._state.requiredExtensions=t,this}fillLibrary(t,n="linear-gradient"){return this._state.fillLibraryId=t,this._state.fillType=n,this}strokeLibrary(t,n="linear-gradient"){return this._state.strokeLibraryId=t,this._state.strokeType=n,this}filterLibrary(...t){let n=this._state.filterLibraryIds??[];return this._state.filterLibraryIds=[...n,...t],this}markerStartRef(t){return this._state.markerStart=t,this}markerMidRef(t){return this._state.markerMid=t,this}markerEndRef(t){return this._state.markerEnd=t,this}bind(t,n){let r=this._state.bindings??{};return this._state.bindings={...r,[t]:n},this}metadata(t){return this._state.metadata={...this._state.metadata,...t},this}build(){return{id:this._id,type:this._type,state:{...this._state}}}},ah=class extends tn{constructor(t,n,r){if(r<0)throw new RangeError("Circle radius must be non-negative");super("circle"),this._state.x=t,this._state.y=n,this._state.radius=r}position(t,n){return this._state.x=t,this._state.y=n,this}radius(t){return this._state.radius=t,this}},ch=class extends tn{constructor(t,n,r,i){if(r<0||i<0)throw new RangeError("Ellipse radii must be non-negative");super("ellipse"),this._state.cx=t,this._state.cy=n,this._state.rx=r,this._state.ry=i}position(t,n){return this._state.cx=t,this._state.cy=n,this}radii(t,n){return this._state.rx=t,this._state.ry=n,this}},lh=class extends tn{constructor(t,n,r,i){if(r<0||i<0)throw new RangeError("Rectangle dimensions must be non-negative");super("rectangle"),this._state.x=t,this._state.y=n,this._state.width=r,this._state.height=i}position(t,n){return this._state.x=t,this._state.y=n,this}size(t,n){return this._state.width=t,this._state.height=n,this}cornerRadius(t){return this._state.cornerRadius=t,this._state.rx=t,this._state.ry=t,this}radii(t,n){return this._state.rx=t,this._state.ry=n,t===n&&(this._state.cornerRadius=t),this}},dh=class extends tn{constructor(t,n,r){if(r<0)throw new RangeError("Square size must be non-negative");super("square"),this._state.x=t,this._state.y=n,this._state.width=r,this._state.height=r}position(t,n){return this._state.x=t,this._state.y=n,this}size(t){return this._state.width=t,this._state.height=t,this}cornerRadius(t){return this._state.cornerRadius=t,this._state.rx=t,this._state.ry=t,this}radii(t,n){return this._state.rx=t,this._state.ry=n,t===n&&(this._state.cornerRadius=t),this}},uh=class extends tn{constructor(t,n,r,i){super("line"),this._state.x1=t,this._state.y1=n,this._state.x2=r,this._state.y2=i}from(t,n){return this._state.x1=t,this._state.y1=n,this}to(t,n){return this._state.x2=t,this._state.y2=n,this}markerStart(t){return this._state.startEndpoint=t,this}markerEnd(t){return this._state.endEndpoint=t,this}markers(t,n){return this._state.startEndpoint=t,this._state.endEndpoint=n,this}},fh=class extends tn{constructor(t,n,r){super("text"),this._state.x=t,this._state.y=n,this._state.text=r}position(t,n){return this._state.x=t,this._state.y=n,this}content(t){return this._state.text=t,this}fontSize(t){return this._state.fontSize=t,this}fontFamily(t){return this._state.fontFamily=t,this}fontWeight(t){return this._state.fontWeight=t,this}fontStyle(t){return this._state.fontStyle=t,this}fontVariant(t){return this._state.fontVariant=t,this}fontVariantLigatures(t){return this._state.fontVariantLigatures=t,this}fontVariantPosition(t){return this._state.fontVariantPosition=t,this}fontVariantCaps(t){return this._state.fontVariantCaps=t,this}fontVariantNumeric(t){return this._state.fontVariantNumeric=t,this}fontVariantEastAsian(t){return this._state.fontVariantEastAsian=t,this}anchor(t){return this._state.textAnchor=t,this}letterSpacing(t){return this._state.letterSpacing=t,this}lineHeight(t){return this._state.lineHeight=t,this}decoration(t){return this._state.textDecoration=t,this}transform(t){return this._state.textTransform=t,this}textPath(t,n=0){return this._state.isTextPath=!0,this._state.textPathPoints=t,this._state.textPathStartOffset=n,this}textPathOffset(t){return this._state.textPathStartOffset=t,this}textPathSide(t){return this._state.textPathSide=t,this}direction(t){return this._state.textDirection=t,this}unicodeBidi(t){return this._state.unicodeBidi=t,this}dominantBaseline(t){return this._state.dominantBaseline=t,this}writingMode(t){return this._state.writingMode=t,this}wordSpacing(t){return this._state.wordSpacing=t,this}baselineShift(t){return this._state.baselineShift=t,this}inlineSize(t){return this._state.inlineSize=t,this}overflowWrap(t){return this._state.overflowWrap=t,this}whiteSpace(t){return this._state.whiteSpace=t,this}fontVariationSettings(t){return this._state.fontVariationSettings=t,this}charOffsets(t){return this._state.charOffsets=t,this}shapeInsideRef(t){return this._state.shapeInsideRef=t,this}shapePadding(t){return this._state.shapePadding=t,this}richTextSegments(t){return this._state.richTextRuns=yi(t),this}richTextRuns(t){let n=Fo(t);return this._state.richTextRuns=n,this}useRichText(t=!0){return this._state.useRichText=t,this}linePositions(t){return this._state.linePositions=t,this}textLength(t){return this._state.textLength=t,this}lengthAdjust(t){return this._state.lengthAdjust=t,this}},Mn=class extends tn{constructor(t,n,r,i){super(t),this._state.cx=n,this._state.cy=r,this._state.radius=i}position(t,n){return this._state.cx=t,this._state.cy=n,this}radius(t){return this._state.radius=t,this}shiftAngle(t){return this._state.shiftAngle=t,this}cornerRadius(t){return this._state.cornerRadius=t,this}},ph=class extends Mn{constructor(t,n,r){super("triangle",t,n,r)}},mh=class extends Mn{constructor(t,n,r,i=5){super("ngon",t,n,r),this._state.sides=i}sides(t){return this._state.sides=t,this}},gh=class extends Mn{constructor(t,n,r){super("star",t,n,r),this._state.arms=5,this._state.innerRadiusPercent=40}arms(t){return this._state.arms=t,this}innerRadius(t){return this._state.innerRadiusPercent=t,this}},hh=class extends Mn{constructor(t,n,r){super("cross",t,n,r),this._state.armWidthPercent=35}armWidth(t){return this._state.armWidthPercent=t,this}},yh=class extends Mn{constructor(t,n,r){super("ring",t,n,r),this._state.innerRadiusPercent=60}innerRadius(t){return this._state.innerRadiusPercent=t,this}},Sh=class extends Mn{constructor(t,n,r){super("spiral",t,n,r),this._state.turns=3,this._state.thicknessPercent=15,this._state.spiralDirection=1}turns(t){return this._state.turns=t,this}thickness(t){return this._state.thicknessPercent=t,this}direction(t){return this._state.spiralDirection=t,this}},bh=class extends Mn{constructor(t,n,r){super("gear",t,n,r),this._state.teeth=8,this._state.toothDepthPercent=25}teeth(t){return this._state.teeth=t,this}toothDepth(t){return this._state.toothDepthPercent=t,this}holeRadius(t){return this._state.holeRadiusPercent=t,this}},vh=class extends Mn{constructor(t,n,r){super("arrow",t,n,r),this._state.headWidthPercent=100,this._state.headLengthPercent=35,this._state.shaftWidthPercent=35}headWidth(t){return this._state.headWidthPercent=t,this}headLength(t){return this._state.headLengthPercent=t,this}shaftWidth(t){return this._state.shaftWidthPercent=t,this}},xh=class extends Mn{constructor(t,n,r){super("heart",t,n,r),this._state.lobeRadiusPercent=50,this._state.cleftDepthPercent=25}lobeRadius(t){return this._state.lobeRadiusPercent=t,this}cleftDepth(t){return this._state.cleftDepthPercent=t,this}},Ih=class extends Mn{constructor(t,n,r){super("lightning",t,n,r),this._state.boltSegments=3,this._state.boltJaggednessPercent=40,this._state.boltWidthPercent=30}segments(t){return this._state.boltSegments=t,this}jaggedness(t){return this._state.boltJaggednessPercent=t,this}thickness(t){return this._state.boltWidthPercent=t,this}},wh=class extends Mn{constructor(t,n,r){super("cloud",t,n,r),this._state.cloudBumps=5,this._state.cloudPuffinessPercent=60}bumps(t){return this._state.cloudBumps=t,this}puffiness(t){return this._state.cloudPuffinessPercent=t,this}},kh=class extends Mn{constructor(t,n,r){super("speechBubble",t,n,r),this._state.tailAngleDeg=45,this._state.tailLengthPercent=40,this._state.tailWidthPercent=25}tailAngle(t){return this._state.tailAngleDeg=t,this}tailLength(t){return this._state.tailLengthPercent=t,this}tailWidth(t){return this._state.tailWidthPercent=t,this}},lo=class extends tn{add(t){let n="build"in t&&typeof t.build=="function"?t.build():t,r=this._state.children??[];return this._state.children=[...r,n],this}addAll(...t){for(let n of t)this.add(n);return this}children(t){return this._state.children=t.map(n=>"build"in n&&typeof n.build=="function"?n.build():n),this}},Ph=class extends lo{constructor(t){super("hyperlink"),t!==void 0&&(this._state.href=t)}href(t){return this._state.href=t,this}hrefXlink(t){return this._state.hrefXlink=t,this}target(t){return this._state.linkTarget=t,this}download(t){return this._state.linkDownload=t,this}rel(t){return this._state.linkRel=t,this}ping(t){return this._state.linkPing=t,this}hreflang(t){return this._state.linkHreflang=t,this}type(t){return this._state.linkType=t,this}referrerPolicy(t){return this._state.linkReferrerPolicy=t,this}},Th=class extends lo{constructor(){super("switch")}},Rh=class extends lo{constructor(){super("container")}},Ch=class extends tn{constructor(t){super("view"),t&&(this._state.viewBoxX=t.x,this._state.viewBoxY=t.y,this._state.viewBoxWidth=t.width,this._state.viewBoxHeight=t.height)}viewBox(t,n,r,i){return this._state.viewBoxX=t,this._state.viewBoxY=n,this._state.viewBoxWidth=r,this._state.viewBoxHeight=i,this}name(t){return this._state.viewName=t,this}preserveAspectRatio(t){return this._state.viewPreserveAspectRatio=t,this}zoomAndPan(t){return this._state.viewZoomAndPan=t,this}viewTarget(t){return this._state.viewTarget=t,this}},Ah=class extends lo{constructor(t=0,n=0,r=100,i=100){super("svg"),this._state.svgX=t,this._state.svgY=n,this._state.svgWidth=r,this._state.svgHeight=i}position(t,n){return this._state.svgX=t,this._state.svgY=n,this}size(t,n){return this._state.svgWidth=t,this._state.svgHeight=n,this}viewBox(t,n,r,i){return this._state.svgViewBoxX=t,this._state.svgViewBoxY=n,this._state.svgViewBoxWidth=r,this._state.svgViewBoxHeight=i,this}preserveAspectRatio(t){return this._state.svgPreserveAspectRatio=t,this}asRoot(t=!0){return this._state.isRootSvg=t,this}},Nh=class extends tn{constructor(t){super("shape-reference"),t!==void 0&&(this._state.targetShapeId=t)}target(t){return this._state.targetShapeId=t,this}offset(t,n){return this._state.offsetX=t,this._state.offsetY=n,this}size(t,n){return this._state.width=t,this._state.height=n,this}},Eh=class extends tn{position(t,n){return this._state.x=t,this._state.y=n,this}size(t,n){return this._state.width=t,this._state.height=n,this}src(t){return this._state.href=t,this}mimeType(t){return this._state.mediaMimeType=t,this}naturalDuration(t){return this._state.naturalDuration=t,this}begin(t){return this._state.begin=t,this}trim(t,n){return this._state.trimStart=t,this._state.trimEnd=n,this}volume(t){return this._state.volume=t,this}muted(t=!0){return this._state.muted=t,this}loop(t=!0){return this._state.loop=t,this}playbackRate(t){return this._state.playbackRate=t,this}fade(t,n){return this._state.fadeInDuration=t,this._state.fadeOutDuration=n,this}language(t){return this._state.systemLanguage=t,this}},Oh=class extends Eh{constructor(t){super("video"),this._state.mediaKind="video",t!==void 0&&(this._state.href=t)}poster(t){return this._state.posterHref=t,this}sourceRect(t){return this._state.sourceRect=t,this}},Dh=class extends Eh{constructor(t){super("audio"),this._state.mediaKind="audio",t!==void 0&&(this._state.href=t)}},$h=class extends tn{constructor(t=[]){super("path"),this._state.pathPoints=[...t],this._state.pathCurveType="cubic",this._state.pathClosed=!1}points(t){return this._state.pathPoints=[...t],this}addPoint(t,n){let r=this._state.pathPoints??[];return r.push({x:t,y:n}),this._state.pathPoints=r,this}curveType(t){return this._state.pathCurveType=t,this}closed(t=!0){return this._state.pathClosed=t,this}tension(t){return this._state.pathTension=t,this}arcParams(t){return this._state.pathArcParams=t,this}markerStart(t){return this._state.startEndpoint=t,this}markerEnd(t){return this._state.endEndpoint=t,this}markers(t,n){return this._state.startEndpoint=t,this._state.endEndpoint=n,this}toD(){let t=this._state.pathPoints??[],n=this._state.pathCurveType??"CUBIC",r=this._state.pathClosed??!1,i=this._state.pathTension??.5,o=this._state.pathArcParams;return sr(t,n,r,i,o)}},Mh=class extends tn{constructor(t=[]){super("polyline"),this._state.polylinePoints=[...t],this._state.polylineClosed=!1}points(t){return this._state.polylinePoints=[...t],this}addPoint(t,n){let r=this._state.polylinePoints??[];return r.push({x:t,y:n}),this._state.polylinePoints=r,this}closed(t=!0){return this._state.polylineClosed=t,this}markerStart(t){return this._state.startEndpoint=t,this}markerEnd(t){return this._state.endEndpoint=t,this}markers(t,n){return this._state.startEndpoint=t,this._state.endEndpoint=n,this}},zh=class extends tn{constructor(t,n,r,i,o){super("image"),this._state.x=t,this._state.y=n,this._state.width=r,this._state.height=i,this._state.href=o}position(t,n){return this._state.x=t,this._state.y=n,this}size(t,n){return this._state.width=t,this._state.height=n,this}src(t){return this._state.href=t,this}preserveAspectRatio(t){return this._state.preserveAspectRatio=t,this}};var Ld=class{_x1;_y1;_x2;_y2;_stops=[];_spreadMethod="pad";_opacity=1;_id;constructor(t=0,n=0,r=1,i=0){this._x1=t,this._y1=n,this._x2=r,this._y2=i,this._id=me()}stop(t,n,r=1){return this._stops.push({offset:t,color:n,opacity:r}),this}direction(t,n,r,i){return this._x1=t,this._y1=n,this._x2=r,this._y2=i,this}spread(t){return this._spreadMethod=t,this}opacity(t){return this._opacity=t,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}}},_d=class{_cx=.5;_cy=.5;_fx=.5;_fy=.5;_r=.5;_ry=.5;_rotation=0;_stops=[];_spreadMethod="pad";_opacity=1;_id;constructor(){this._id=me()}center(t,n){return this._cx=t,this._cy=n,this}focus(t,n){return this._fx=t,this._fy=n,this}radius(t,n){return this._r=t,this._ry=n??t,this}rotation(t){return this._rotation=t,this}stop(t,n,r=1){return this._stops.push({offset:t,color:n,opacity:r}),this}spread(t){return this._spreadMethod=t,this}opacity(t){return this._opacity=t,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}}},Bd=class{_patternType;_color;_backgroundColor;_scale=1;_rotation=0;_opacity=1;_patternParams;_id;_svgContent;_width;_height;_patternUnits;_patternContentUnits;_patternTransform;_viewBox;_preserveAspectRatio;_x;_y;_customPatternId;constructor(t="stripes",n="#000000",r="#ffffff"){this._patternType=t,this._color=n,this._backgroundColor=r,this._id=me()}scale(t){return this._scale=t,this}rotation(t){return this._rotation=t,this}opacity(t){return this._opacity=t,this}params(t){return this._patternParams=t,this}svgContent(t){return this._svgContent=t,this}size(t,n){return this._width=t,this._height=n,this}patternUnits(t){return this._patternUnits=t,this}patternContentUnits(t){return this._patternContentUnits=t,this}patternTransform(t){return this._patternTransform=t,this}viewBox(t){return this._viewBox=t,this}preserveAspectRatio(t){return this._preserveAspectRatio=t,this}position(t,n){return this._x=t,this._y=n,this}customPatternId(t){return this._customPatternId=t,this}build(){let t,n,r;if(this._svgContent!==void 0)t=this._svgContent,n=this._width??10,r=this._height??10;else{let o=dp(this._patternType,this._scale,this._color,this._backgroundColor,this._patternParams);t=o.svgContent,n=this._width??o.width,r=this._height??o.height}let i={type:"pattern",id:this._id,patternType:this._svgContent!==void 0?"custom":this._patternType,color:this._color,backgroundColor:this._backgroundColor,scale:this._scale,rotation:this._rotation,opacity:this._opacity,svgContent:t,width:n,height:r,patternUnits:this._patternUnits??"userSpaceOnUse",patternParams:this._patternParams,patternTransform:this._patternTransform??(this._rotation?`rotate(${this._rotation})`:void 0)};return this._patternContentUnits&&(i.patternContentUnits=this._patternContentUnits),this._viewBox&&(i.viewBox=this._viewBox),this._preserveAspectRatio&&(i.preserveAspectRatio=this._preserveAspectRatio),this._x!==void 0&&(i.x=this._x),this._y!==void 0&&(i.y=this._y),this._customPatternId&&(i.customPatternId=this._customPatternId),i}};function ZA(e=0,t=0,n=1,r=0){return new Ld(e,t,n,r)}function QA(){return new _d}function JA(e="stripes",t="#000000",n="#ffffff"){return new Bd(e,t,n)}var _x={rows:4,cols:4,style:"classic",tabDepthPercent:20,tabPattern:"random",seed:1},nH=.04,rH=0;function iH(e){let t=e>>>0;return()=>{t=t+1831565813>>>0;let n=t;return n=Math.imul(n^n>>>15,n|1),n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}}function Ie(e){return Number(e.toFixed(3)).toString()}function oH(e,t,n,r,i,o,s,a,c,l,d,u){return[[0,0],[.2,a],[.5+c+d,-o+l],[.5-o+c,o+l],[.5-2*o+c-d,3*o+l],[.5+2*o+c-d,3*o+l],[.5+o+c,o+l],[.5+c+d,-o+l],[.8,u],[1,0]].map(([p,m])=>{let g=t+p*r,h=n+m*i*s;return e?{x:g,y:h}:{x:h,y:g}})}function eN(e,t,n,r,i,o,s,a,c,l,d){let u=[],f=(v,w)=>c==="alternating"?0:v+l()*(w-v),p=()=>l()<.5,m=f(-a,a),g=c==="alternating"?d%2===0:p(),h=null,y=m,S=f(-a,a),b=f(-a,a),I=f(-a,a);m=f(-a,a);for(let v=0;v<e;v++){v>0&&(h=g,g=c==="alternating"?(d+v)%2===0:p(),y=g===h?-m:m,S=f(-a,a),b=f(-a,a),I=f(-a,a),m=f(-a,a));let w=g?-1:1,k=n+v*i;u.push(oH(t,k,r,i,o,s,w,y,S,b,I,m))}return u}function tN(e,t,n,r,i,o,s){let a=2*o;return[[0,0],[.2,0],[.4,0],[.4,a],[.4,a],[.6,a],[.6,a],[.6,0],[.8,0],[1,0]].map(([l,d])=>{let u=t+l*r,f=n+d*i*s;return e?{x:u,y:f}:{x:f,y:u}})}function nN(e,t){return e+` C ${Ie(t[1].x)} ${Ie(t[1].y)} ${Ie(t[2].x)} ${Ie(t[2].y)} ${Ie(t[3].x)} ${Ie(t[3].y)} C ${Ie(t[4].x)} ${Ie(t[4].y)} ${Ie(t[5].x)} ${Ie(t[5].y)} ${Ie(t[6].x)} ${Ie(t[6].y)} C ${Ie(t[7].x)} ${Ie(t[7].y)} ${Ie(t[8].x)} ${Ie(t[8].y)} ${Ie(t[9].x)} ${Ie(t[9].y)}`}function rN(e,t){return e+` C ${Ie(t[8].x)} ${Ie(t[8].y)} ${Ie(t[7].x)} ${Ie(t[7].y)} ${Ie(t[6].x)} ${Ie(t[6].y)} C ${Ie(t[5].x)} ${Ie(t[5].y)} ${Ie(t[4].x)} ${Ie(t[4].y)} ${Ie(t[3].x)} ${Ie(t[3].y)} C ${Ie(t[2].x)} ${Ie(t[2].y)} ${Ie(t[1].x)} ${Ie(t[1].y)} ${Ie(t[0].x)} ${Ie(t[0].y)}`}function iN(e,t={}){let n={..._x,...t};if(n.rows<1||n.cols<1)throw new Error("generatePuzzlePieces: rows and cols must be >= 1");if(!Number.isFinite(e.width)||!Number.isFinite(e.height))throw new Error("generatePuzzlePieces: bounds must have finite width/height");if(e.width<=0||e.height<=0)throw new Error("generatePuzzlePieces: bounds must have positive width/height");let{rows:r,cols:i,style:o,tabDepthPercent:s,tabPattern:a,seed:c}=n,l=iH(c),d=e.width/i,u=e.height/r,f=Math.max(0,Math.min(.4,s/200)),p=(o==="classic"||o==="curved")&&f>0,m=o==="square-tabs"&&f>0,g=o==="classic"&&a==="random"?nH:rH,h=[];for(let b=0;b<r-1;b++){let I=e.y+(b+1)*u;if(p)h.push(eN(i,!0,e.x,I,d,u,f,g,a,l,b));else if(m){let v=[];for(let w=0;w<i;w++){let k=a==="alternating"?(b+w)%2===0?1:-1:l()<.5?1:-1;v.push(tN(!0,e.x+w*d,I,d,u,f,k))}h.push(v)}else h.push(new Array(i).fill(null))}let y=[];for(let b=0;b<i-1;b++){let I=e.x+(b+1)*d;if(p)y.push(eN(r,!1,e.y,I,u,d,f,g,a,l,b));else if(m){let v=[];for(let w=0;w<r;w++){let k=a==="alternating"?(w+b)%2===0?1:-1:l()<.5?1:-1;v.push(tN(!1,e.y+w*u,I,u,d,f,k))}y.push(v)}else y.push(new Array(r).fill(null))}let S=[];for(let b=0;b<r;b++)for(let I=0;I<i;I++){let v=e.x+I*d,w=e.y+b*u,k=v+d,C=w+u,P=`M ${Ie(v)} ${Ie(w)}`;if(b===0)P+=` L ${Ie(k)} ${Ie(w)}`;else{let R=h[b-1][I];R?P=nN(P,R):P+=` L ${Ie(k)} ${Ie(w)}`}if(I===i-1)P+=` L ${Ie(k)} ${Ie(C)}`;else{let R=y[I][b];R?P=nN(P,R):P+=` L ${Ie(k)} ${Ie(C)}`}if(b===r-1)P+=` L ${Ie(v)} ${Ie(C)}`;else{let R=h[b][I];R?P=rN(P,R):P+=` L ${Ie(v)} ${Ie(C)}`}if(I===0)P+=` L ${Ie(v)} ${Ie(w)}`;else{let R=y[I-1][b];R?P=rN(P,R):P+=` L ${Ie(v)} ${Ie(w)}`}P+=" Z",S.push({id:`puzzle-${c}-r${b}-c${I}`,row:b,col:I,d:P})}return S}var aN=[1,2,3,4,5,6,7,8,9],sH={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 Vd(e){return e.map(t=>[...t])}function aH(){return Array.from({length:9},()=>Array.from({length:9},()=>0))}function cN(e){let t=e>>>0;return()=>{t=t+1831565813>>>0;let n=t;return n=Math.imul(n^n>>>15,n|1),n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}}function lN(e,t){let n=[...e];for(let r=n.length-1;r>0;r--){let i=Math.floor(t()*(r+1));[n[r],n[i]]=[n[i],n[r]]}return n}function Ja(e){return 1<<e-1}function dN(e){let t=0,n=e;for(;n;)n&=n-1,t++;return t}function cH(e){for(let t=1;t<=9;t++)if(e===Ja(t))return t;return 0}function Vx(e,t){return Math.floor(e/3)*3+Math.floor(t/3)}function Bx(e){let t=0;for(let n of e)for(let r of n)r!==0&&t++;return t}function lH(e){if(!Number.isFinite(e))return 1;let t=Math.floor(e);return t===0?1:t}function uN(e,t){if(!Array.isArray(e)||e.length!==9)return t.push("Grid must contain 9 rows."),!1;let n=!0;for(let r=0;r<9;r++){if(!Array.isArray(e[r])||e[r].length!==9){t.push(`Row ${r+1} must contain 9 cells.`),n=!1;continue}for(let i=0;i<9;i++){let o=e[r][i];(!Number.isInteger(o)||o<0||o>9)&&(t.push(`Cell R${r+1}C${i+1} must be a digit from 0 to 9.`),n=!1)}}return n}function fN(e,t){let n=!0,r=(i,o)=>{let s=0;for(let a of o){if(a===0)continue;let c=Ja(a);if(s&c){t.push(`${i} contains duplicate ${a}.`),n=!1;return}s|=c}};for(let i=0;i<9;i++)r(`Row ${i+1}`,e[i]);for(let i=0;i<9;i++)r(`Column ${i+1}`,e.map(o=>o[i]));for(let i=0;i<9;i+=3)for(let o=0;o<9;o+=3){let s=[];for(let a=i;a<i+3;a++)for(let c=o;c<o+3;c++)s.push(e[a][c]);r(`Box ${Math.floor(i/3)*3+Math.floor(o/3)+1}`,s)}return n}function Gx(e){let t=Array.from({length:9},()=>0),n=Array.from({length:9},()=>0),r=Array.from({length:9},()=>0);for(let i=0;i<9;i++)for(let o=0;o<9;o++){let s=e[i][o];if(s===0)continue;let a=Ja(s),c=Vx(i,o);if(t[i]&a||n[o]&a||r[c]&a)return null;t[i]|=a,n[o]|=a,r[c]|=a}return{rows:t,cols:n,boxes:r}}function jx(e,t,n,r,i){return 511&~(n[e]|r[t]|i[Vx(e,t)])}function pN(e,t,n){let r=Gx(e);if(!r)return[];let i=Vd(e),o=[],{rows:s,cols:a,boxes:c}=r,l=()=>{if(o.length>=t)return;let d=-1,u=-1,f=0,p=10;for(let g=0;g<9;g++){for(let h=0;h<9;h++){if(i[g][h]!==0)continue;let y=jx(g,h,s,a,c),S=dN(y);if(S===0)return;if(S<p&&(d=g,u=h,f=y,p=S,S===1))break}if(p===1)break}if(d===-1){o.push(Vd(i));return}let m=aN.filter(g=>f&Ja(g));n&&(m=lN(m,n));for(let g of m){let h=Ja(g),y=Vx(d,u);if(i[d][u]=g,s[d]|=h,a[u]|=h,c[y]|=h,l(),c[y]&=~h,a[u]&=~h,s[d]&=~h,i[d][u]=0,o.length>=t)return}};return l(),o}function dH(e){let t=aH(),n=cN(e),[r]=pN(t,1,n);if(!r)throw new Error("generateSudokuPuzzle: failed to generate solved grid");return r}function uH(e){let t=Gx(e);if(!t)return null;for(let n=0;n<9;n++)for(let r=0;r<9;r++){if(e[n][r]!==0)continue;let i=jx(n,r,t.rows,t.cols,t.boxes);if(dN(i)===1)return{row:n,col:r,value:cH(i)}}return null}function fH(e){let t=Gx(e);if(!t)return null;let n=r=>{for(let i of aN){let o=Ja(i),s=null;for(let a of r)if(!(e[a.row][a.col]!==0||!(jx(a.row,a.col,t.rows,t.cols,t.boxes)&o))){if(s){s=null;break}s=a}if(s)return{...s,value:i}}return null};for(let r=0;r<9;r++){let i=n(Array.from({length:9},(o,s)=>({row:r,col:s})));if(i)return i}for(let r=0;r<9;r++){let i=n(Array.from({length:9},(o,s)=>({row:s,col:r})));if(i)return i}for(let r=0;r<9;r+=3)for(let i=0;i<9;i+=3){let o=[];for(let a=r;a<r+3;a++)for(let c=i;c<i+3;c++)o.push({row:a,col:c});let s=n(o);if(s)return s}return null}function oN(e){let t=Vd(e),n=!1;for(;Bx(t)<81;){let r=uH(t);if(r){t[r.row][r.col]=r.value;continue}let i=fH(t);if(i){n=!0,t[i.row][i.col]=i.value;continue}return"search"}return n?"hidden-singles":"singles"}function sN(e,t){let n={singles:0,"hidden-singles":1,search:2};return n[e]<=n[t]}function Gd(e,t={}){let n=[];return uN(e,n)?fN(e,n)?pN(e,Math.max(1,Math.floor(t.maxSolutions??2))):[]:[]}function mN(e){let t=[];if(!uN(e,t))return{valid:!1,unique:!1,solution:null,errors:t};if(fN(e,t),t.length>0)return{valid:!1,unique:!1,solution:null,errors:t};let r=Gd(e,{maxSolutions:2});return r.length===0?t.push("Puzzle has no solution."):r.length>1&&t.push("Puzzle has more than one solution."),{valid:t.length===0,unique:r.length===1,solution:r[0]?Vd(r[0]):null,errors:t}}function gN(e){let t=e.difficulty,n=sH[t];if(!n)throw new Error(`generateSudokuPuzzle: unsupported difficulty "${t}"`);let r=lH(e.seed);for(let i=0;i<30;i++){let o=r+i*104729>>>0,s=cN(o),a=dH(o),c=Vd(a),l=n.minGivens+Math.floor(s()*(n.maxGivens-n.minGivens+1)),d=lN(Array.from({length:81},(m,g)=>({row:Math.floor(g/9),col:g%9})),s);for(let m of d){if(Bx(c)<=l)break;let g=c[m.row][m.col];if(c[m.row][m.col]=0,Gd(c,{maxSolutions:2}).length!==1){c[m.row][m.col]=g;continue}let y=oN(c);sN(y,n.maxRating)||(c[m.row][m.col]=g)}let u=Bx(c),f=oN(c);if(Gd(c,{maxSolutions:2}).length===1&&u>=n.minGivens&&u<=n.maxGivens&&sN(f,n.maxRating))return{puzzle:c,solution:a,difficulty:t,seed:r,givens:u,rating:f}}throw new Error(`generateSudokuPuzzle: unable to generate a ${t} puzzle`)}var hN="ABCDEFGHIJKLMNOPQRSTUVWXYZ";var pH={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 SN(e){if(!Number.isFinite(e))return 1;let t=Math.floor(e);return t===0?1:t}function bN(e){let t=e>>>0;return()=>{t=t+1831565813>>>0;let n=t;return n=Math.imul(n^n>>>15,n|1),n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}}function ec(e){let t=globalThis.Intl.Segmenter;return t?Array.from(new t(void 0,{granularity:"grapheme"}).segment(e),n=>n.segment.normalize("NFC")):Array.from(e.normalize("NFC"))}function mH(e,t,n,r){return e>=0&&t>=0&&e<r&&t<n}function Ux(e,t){return Array.from({length:t},()=>Array.from({length:e},()=>!0))}function vN(e,t,n,r){if(!n)return Ux(e,t);if(!Array.isArray(n)||n.length!==t)return r.push(`Mask must contain exactly ${t} rows.`),Ux(e,t);let i=[];for(let o=0;o<t;o++){if(!Array.isArray(n[o])||n[o].length!==e)return r.push(`Mask row ${o+1} must contain exactly ${e} cells.`),Ux(e,t);i.push(n[o].map(Boolean))}return i}function gH(e){let t=0;for(let n of e)for(let r of n)r&&t++;return t}function hH(e){return e.trim().normalize("NFC")}function xN(e){return e.replace(/\r/g,"").split(/[,\n]+/).map(t=>t.trim()).filter(t=>t.length>0)}function Hx(e,t){let n=[];return e.across&&(n.push("E"),t&&n.push("W")),e.down&&(n.push("S"),t&&n.push("N")),e.diagonal&&(n.push("SE","NE"),t&&n.push("NW","SW")),n}function yH(e,t,n,r,i,o,s,a){let c=ec(e),l=[];for(let d=0;d<c.length;d++){let u=t+r.dr*d,f=n+r.dc*d;if(!mH(u,f,o,s)||!i[u][f])return null;l.push({row:u,col:f,grapheme:c[d]})}return{word:e,graphemes:c,row:t,col:n,direction:r.direction,dr:r.dr,dc:r.dc,cells:l,jitter:a}}function IN(e,t,n,r,i,o){let s=[];for(let a of t){let c=pH[a];for(let l=0;l<i;l++)for(let d=0;d<r;d++){let u=yH(e,l,d,c,n,r,i,o());u&&s.push(u)}}return s}function Kx(e){let t=[],n=[],r=[],i=Math.floor(e.width),o=Math.floor(e.height);(!Number.isInteger(i)||i<2||i>64)&&t.push("Width must be an integer from 2 to 64."),(!Number.isInteger(o)||o<2||o>64)&&t.push("Height must be an integer from 2 to 64.");let s=Hx(e.axes,e.allowBackwards);s.length===0&&t.push("At least one word direction must be enabled.");let a=vN(Math.max(1,i),Math.max(1,o),e.mask,t),c=gH(a);c===0&&t.push("Mask must contain at least one active cell.");let l=new Set,d=[];for(let p of e.words){let m=hH(p);if(m){if(/\s/u.test(m)){r.push({input:p,reason:"Words cannot contain whitespace."});continue}if(l.has(m)){r.push({input:p,reason:"Duplicate word."});continue}l.add(m),d.push(m)}}d.length===0&&t.push("Enter at least one word.");let u=bN(SN(e.seed));if(t.length===0)for(let p=d.length-1;p>=0;p--){let m=d[p];IN(m,s,a,i,o,u).length===0&&(r.push({input:m,reason:"No legal placement exists for the current size, mask, and directions."}),d.splice(p,1))}r.length>0&&t.push(`${r.length} word${r.length===1?"":"s"} rejected.`);let f=Math.max(0,c);return d.length>f&&n.push("The word count exceeds the active cell count; overlaps may be required for this puzzle."),{valid:t.length===0,acceptedWords:d,rejectedWords:r,errors:t,warnings:n,minWords:1,maxWords:f,activeCells:c,directions:s}}function SH(e,t){for(let n of t.cells){let r=e[n.row][n.col];if(r!==null&&r!==n.grapheme)return!0}return!1}function bH(e,t){let n=[];for(let r of t.cells)e[r.row][r.col]===null&&(n.push({row:r.row,col:r.col}),e[r.row][r.col]=r.grapheme);return n}function vH(e,t){for(let n of t)e[n.row][n.col]=null}function yN(e,t){let n=0;for(let r of t.cells)e[r.row][r.col]===r.grapheme&&n++;return n}function xH(e){return{word:e.word,row:e.row,col:e.col,direction:e.direction,path:e.cells.map(t=>({...t}))}}function IH(e){let t=e.fillerAlphabet??hN,n=typeof t=="string"?ec(t):t.flatMap(i=>ec(i)),r=n.filter((i,o)=>i.trim()&&n.indexOf(i)===o);return r.length>0?r:ec(hN)}function wN(e){let t=Math.floor(e.width),n=Math.floor(e.height),r=SN(e.seed),i=Kx({...e,width:t,height:n,seed:r});if(!i.valid)throw new Error(`generateWordSearch: ${i.errors[0]??"invalid options"}`);let o=vN(t,n,e.mask,[]),s=Math.max(1,Math.floor(e.maxBacktrackNodes??15e4));for(let a=0;a<24;a++){let c=bN(r+a*104729>>>0),l=i.directions,d=new Map;for(let S of i.acceptedWords)d.set(S,IN(S,l,o,t,n,c));let u=[...i.acceptedWords].sort((S,b)=>{let I=d.get(S)?.length??0,v=d.get(b)?.length??0;return I!==v?I-v:ec(b).length-ec(S).length}),f=Array.from({length:n},(S,b)=>Array.from({length:t},(I,v)=>o[b][v]?null:"")),p=[],m=new Map,g=0,h=S=>{if(++g>s)return!1;if(S>=u.length)return!0;let b=u[S],I=[...d.get(b)??[]].filter(v=>!SH(f,v)).sort((v,w)=>{let k=yN(f,w)-yN(f,v);if(k!==0)return k;let C=(m.get(v.direction)??0)-(m.get(w.direction)??0);return C!==0?C:v.jitter-w.jitter});for(let v of I){let w=bH(f,v);if(p.push(xH(v)),m.set(v.direction,(m.get(v.direction)??0)+1),h(S+1))return!0;m.set(v.direction,(m.get(v.direction)??1)-1),p.pop(),vH(f,w)}return!1};if(!h(0))continue;let y=IH(e);for(let S=0;S<n;S++)for(let b=0;b<t;b++)o[S][b]?f[S][b]===null&&(f[S][b]=y[Math.floor(c()*y.length)]):f[S][b]="";return{width:t,height:n,grid:f,mask:o.map(S=>[...S]),normalizedWords:[...i.acceptedWords],placements:[...p],seed:r,title:e.title,creator:e.creator,lint:i}}throw new Error("generateWordSearch: unable to place all words with the current settings")}function wH(e,t,n){let r=!1;for(let i=0,o=n.length-1;i<n.length;o=i++){let s=n[i],a=n[o];s.y>t!=a.y>t&&e<(a.x-s.x)*(t-s.y)/(a.y-s.y)+s.x&&(r=!r)}return r}function kH(){let e=[];for(let t=0;t<10;t++){let n=t%2===0?.5:.23,r=-Math.PI/2+t*Math.PI/5;e.push({x:.5+Math.cos(r)*n,y:.5+Math.sin(r)*n})}return e}function kN(e,t,n){let r=Math.max(1,Math.floor(e)),i=Math.max(1,Math.floor(t)),o=kH();return Array.from({length:i},(s,a)=>Array.from({length:r},(c,l)=>{let d=(l+.5)/r,u=(a+.5)/i,f=d*2-1,p=u*2-1;switch(n){case"rectangle":return!0;case"circle":return f*f+p*p<=1;case"triangle":return u>=.08&&u<=.95&&Math.abs(f)<=u;case"diamond":return Math.abs(f)+Math.abs(p)<=1;case"star":return wH(d,u,o);case"heart":{let m=f*1.25,g=-p*1.25;return Math.pow(m*m+g*g-1,3)-m*m*g*g*g<=0}case"cross":return Math.abs(f)<=.32||Math.abs(p)<=.32;default:return!0}}))}function jd(e,t){let{width:n,height:r,data:i}=e;if(!Number.isInteger(n)||!Number.isInteger(r)||n<0||r<0)throw new Error(`${t}: image dimensions must be non-negative integers, got ${n}x${r}`);if(i.length!==n*r*4)throw new Error(`${t}: data length ${i.length} does not match ${n}x${r} RGBA (${n*r*4})`)}function Fh(e,t,n){return .2126*e+.7152*t+.0722*n}function Wx(e){let t=e/255;return t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}var PH=.95047,TH=1,RH=1.08883,CH=Math.pow(6/29,3),AH=1/(3*Math.pow(6/29,2));function Xx(e){return e>CH?Math.cbrt(e):e*AH+4/29}function Ud(e,t,n,r){let i=Wx(e),o=Wx(t),s=Wx(n),a=.4124564*i+.3575761*o+.1804375*s,c=.2126729*i+.7151522*o+.072175*s,l=.0193339*i+.119192*o+.9503041*s,d=Xx(a/PH),u=Xx(c/TH),f=Xx(l/RH);r[0]=116*u-16,r[1]=500*(d-u),r[2]=200*(u-f)}var uo=Math.PI/180,PN=Math.pow(25,7);function Lh(e,t,n,r,i,o){let s=Math.hypot(t,n),a=Math.hypot(i,o),c=(s+a)/2,l=Math.pow(c,7),d=.5*(1-Math.sqrt(l/(l+PN))),u=(1+d)*t,f=(1+d)*i,p=Math.hypot(u,n),m=Math.hypot(f,o),g=p===0?0:(Math.atan2(n,u)/uo+360)%360,h=m===0?0:(Math.atan2(o,f)/uo+360)%360,y=r-e,S=m-p,b=0;p*m!==0&&(b=h-g,b>180?b-=360:b<-180&&(b+=360));let I=2*Math.sqrt(p*m)*Math.sin(b/2*uo),v=(e+r)/2,w=(p+m)/2,k;if(p*m===0)k=g+h;else{let V=g+h;Math.abs(g-h)<=180?k=V/2:V<360?k=(V+360)/2:k=(V-360)/2}let C=1-.17*Math.cos((k-30)*uo)+.24*Math.cos(2*k*uo)+.32*Math.cos((3*k+6)*uo)-.2*Math.cos((4*k-63)*uo),P=30*Math.exp(-Math.pow((k-275)/25,2)),R=Math.pow(w,7),N=2*Math.sqrt(R/(R+PN)),M=Math.pow(v-50,2),A=1+.015*M/Math.sqrt(20+M),$=1+.045*w,_=1+.015*w*C,z=-Math.sin(2*P*uo)*N,j=y/A,G=S/$,W=I/_;return Math.sqrt(j*j+G*G+W*W+z*G*W)}function _h(e,t){return e.width===t.width&&e.height===t.height}function Hd(e){let t=e.data,n=new Uint8ClampedArray(t.length);for(let r=0;r<t.length;r+=4){let i=t[r+3];if(n[r+3]=i,i===255)n[r]=t[r],n[r+1]=t[r+1],n[r+2]=t[r+2];else if(i!==0){let o=i/255;n[r]=Math.round(t[r]*o),n[r+1]=Math.round(t[r+1]*o),n[r+2]=Math.round(t[r+2]*o)}}return n}function Kd(e,t){let n=e.data,r=e.width*e.height,i=new Uint8ClampedArray(r*3);for(let o=0;o<r;o++){let s=o*4,a=o*3,c=n[s+3]/255;if(c===1)i[a]=n[s],i[a+1]=n[s+1],i[a+2]=n[s+2];else if(c===0)i[a]=t.r,i[a+1]=t.g,i[a+2]=t.b;else{let l=1-c;i[a]=Math.round(n[s]*c+t.r*l),i[a+1]=Math.round(n[s+1]*c+t.g*l),i[a+2]=Math.round(n[s+2]*c+t.b*l)}}return i}var TN=6.502500000000001,RN=(.03*255)**2;function NH(e,t){let n=new Float64Array(e*2+1),r=0;for(let i=-e;i<=e;i++){let o=Math.exp(-(i*i)/(2*t*t));n[i+e]=o,r+=o}for(let i=0;i<n.length;i++)n[i]/=r;return n}function Wd(e,t,n,r,i,o,s){for(let a=0;a<n;a++){let c=a*t;for(let l=0;l<t;l++){let d=0;for(let u=-i;u<=i;u++){let f=l+u;f<0?f=0:f>=t&&(f=t-1),d+=e[c+f]*r[u+i]}o[c+l]=d}}for(let a=0;a<n;a++)for(let c=0;c<t;c++){let l=0;for(let d=-i;d<=i;d++){let u=a+d;u<0?u=0:u>=n&&(u=n-1),l+=o[u*t+c]*r[d+i]}s[a*t+c]=l}}function Xd(e,t,n,r){if(e.length!==n*r||t.length!==n*r)throw new Error(`ssimPlane: plane length ${e.length}/${t.length} does not match ${n}x${r}`);let i=Math.min(n,r);if(i<3){for(let I=0;I<e.length;I++)if(e[I]!==t[I])return 0;return 1}let o=11;i<o&&(o=i%2===0?i-1:i);let s=(o-1)/2,a=NH(s,1.5),c=n*r,l=new Float64Array(c),d=new Float64Array(c),u=new Float64Array(c);for(let I=0;I<c;I++)l[I]=e[I]*e[I],d[I]=t[I]*t[I],u[I]=e[I]*t[I];let f=new Float64Array(c),p=new Float64Array(c),m=new Float64Array(c),g=new Float64Array(c),h=new Float64Array(c),y=new Float64Array(c);Wd(e,n,r,a,s,f,p),Wd(t,n,r,a,s,f,m),Wd(l,n,r,a,s,f,g),Wd(d,n,r,a,s,f,h),Wd(u,n,r,a,s,f,y);let S=0,b=0;for(let I=s;I<r-s;I++)for(let v=s;v<n-s;v++){let w=I*n+v,k=p[w],C=m[w],P=k*k,R=C*C,N=g[w]-P,M=h[w]-R,A=y[w]-k*C,$=(2*k*C+TN)*(2*A+RN),_=(P+R+TN)*(N+M+RN);S+=$/_,b++}return b>0?S/b:1}function Bh(e,t,n,r={}){let i=t*n;if(e.length!==i)throw new Error(`severity: field length ${e.length} does not match ${t}x${n}`);let o=r.threshold??2,s=r.minNeighbors??r.minNeighbours??4,a=new Uint8Array(i),c=0;for(let h=0;h<i;h++)e[h]>o&&(a[h]=1,c++);if(c===0)return{differing:0,coherent:0,clusters:0,largestCluster:0,mass:0,score:1};let l=new Uint8Array(i),d=0;for(let h=0;h<n;h++){let y=h*t;for(let S=0;S<t;S++){if(!a[y+S])continue;let b=0;for(let I=-1;I<=1;I++){let v=h+I;if(v<0||v>=n)continue;let w=v*t;for(let k=-1;k<=1;k++){if(k===0&&I===0)continue;let C=S+k;C<0||C>=t||(b+=a[w+C])}}b>=s&&(l[y+S]=1,d++)}}let u=0,f=0,p=0,m=[];for(let h=0;h<i;h++){if(!l[h])continue;u++;let y=0;for(l[h]=0,m.push(h);m.length>0;){let S=m.pop();y++;let b=S%t;b>0&&l[S-1]&&(l[S-1]=0,m.push(S-1)),b+1<t&&l[S+1]&&(l[S+1]=0,m.push(S+1)),S>=t&&l[S-t]&&(l[S-t]=0,m.push(S-t)),S+t<i&&l[S+t]&&(l[S+t]=0,m.push(S+t))}y>f&&(f=y),p+=y*y}let g=i===0?0:Math.min(1,Math.sqrt(p)/i);return{differing:c,coherent:d,clusters:u,largestCluster:f,mass:g,score:1-g}}var EH={r:255,g:255,b:255,a:255};function AN(e,t,n={}){if(jd(e,"compareImages(reference)"),jd(t,"compareImages(candidate)"),!_h(e,t))throw new Error(`compareImages: cannot compare ${e.width}x${e.height} against ${t.width}x${t.height}`);let r=n.alphaMode??"premultiplied",i=n.deltaEBackground??EH,o=r==="premultiplied"?Hd(e):e.data,s=r==="premultiplied"?Hd(t):t.data,a=e.width,c=e.height,l=a*c,d=0,u=0,f=0;for(let v=0;v<l;v++){let w=v*4,k=o[w]-s[w],C=o[w+1]-s[w+1],P=o[w+2]-s[w+2],R=o[w+3]-s[w+3];if(d+=k*k+C*C+P*P+R*R,k===0&&C===0&&P===0&&R===0)u++;else{let N=Math.max(Math.abs(k),Math.abs(C),Math.abs(P),Math.abs(R));N>f&&(f=N)}}let p=l===0?0:d/(l*4),m=p===0?1/0:10*Math.log10(65025/p),g=u===l,h=1,y=1;if(!g&&!n.skipSsim){let v=CN(o,l),w=CN(s,l),k=0;for(let C=0;C<3;C++)k+=Xd(v.rgb[C],w.rgb[C],a,c);h=k/3,y=Xd(v.luma,w.luma,a,c)}let S={mean:0,p95:0,max:0},b=n.severity&&!g?new Float64Array(l):void 0;!g&&!n.skipDeltaE&&(S=OH(e,t,i,b));let I;return n.severity&&(I=g?{differing:0,coherent:0,clusters:0,largestCluster:0,mass:0,score:1}:Bh(b??new Float64Array(l),a,c)),{width:a,height:c,pixels:l,exactPixels:u,exactRatio:l===0?1:u/l,maxChannelDiff:f,mse:p,rmse:Math.sqrt(p),psnr:m,ssim:h,ssimLuma:y,deltaE:S,deltaEBackground:i,alphaMode:r,lossless:g,severity:I}}function CN(e,t){let n=new Float64Array(t),r=new Float64Array(t),i=new Float64Array(t),o=new Float64Array(t);for(let s=0;s<t;s++){let a=s*4;n[s]=e[a],r[s]=e[a+1],i[s]=e[a+2],o[s]=Fh(e[a],e[a+1],e[a+2])}return{rgb:[n,r,i],luma:o}}function OH(e,t,n,r){let i=Kd(e,n),o=Kd(t,n),s=e.width*e.height,a=10001,c=new Uint32Array(a),l=new Float64Array(3),d=new Float64Array(3),u=0,f=0;for(let h=0;h<s;h++){let y=h*3,S=i[y],b=i[y+1],I=i[y+2],v=o[y],w=o[y+1],k=o[y+2];if(S===v&&b===w&&I===k){c[0]++;continue}Ud(S,b,I,l),Ud(v,w,k,d);let C=Lh(l[0],l[1],l[2],d[0],d[1],d[2]);r&&(r[h]=C),u+=C,C>f&&(f=C),c[Math.min(a-1,Math.round(C*100))]++}let p=Math.ceil(s*.95),m=0,g=0;for(let h=0;h<a;h++)if(m+=c[h],m>=p){g=h/100;break}return{mean:s===0?0:u/s,p95:g,max:f}}0&&(module.exports={ANIMATION_MANAGER_INTERPOLATION_POLICY,Arrow,Audio,BASE_FILL_LAYER_ID,BASE_STROKE_LAYER_ID,BROWSER_SVG_EXTENSION_URIS,BUILTIN_MARKER_ID_MAP,CANONICAL_NORMALIZATION_FAULT_POINTS,CC_NS,COLLAB_PROTOCOL_VERSION,COMMON_PROP_DEFAULTS,COMMON_TRANSFORM_NODE_DEFAULTS,CONNECTOR_LABEL_BASELINE_LIFT,CONNECTOR_LABEL_FONT_FAMILY,CONNECTOR_LABEL_FONT_SIZE,CSS_GENERIC_FAMILY_NAMES,CURRENT_SCHEMA_VERSION,CanonicalDocument,Circle,Cloud,Container,ContainerShapeBuilder,Cross,DC_NS,DEFAULT_CONNECTOR_CORNER_RADIUS,DEFAULT_CONNECTOR_LABEL_OFFSET,DEFAULT_CONNECTOR_LABEL_POSITION,DEFAULT_COORDINATE_PRECISION,DEFAULT_FONT_WEIGHT,DEFAULT_RICH_TEXT_STYLE,DOCUMENT_BYTE_KINDS,DOCUMENT_FIELDS,DOCUMENT_FIELD_LIVE_AUTHORITY,DOCUMENT_IMPORT_INTENTS,DOCUMENT_IMPORT_KINDS,DOCUMENT_INGEST_POLICIES,DOCUMENT_SECTION_ORDER,DocumentBuilder,DocumentModel,DocumentSession,EASING_CURVES,EasingType,Ellipse,FLOWCHART_GEOMETRY_DEFAULTS,GEOMETRY_TRACK_PROPERTIES,Gear,HEADLESS_SVG_STYLE_ENVIRONMENT,Heart,Hyperlink,IDENTITY_AFFINE,INGEST_APPLY_STAGES,INGEST_DIAGNOSTIC_CODES,INGEST_DOCUMENT_ROOT_IDENTITY,INGEST_FEATURES,INGEST_FEATURE_CAPABILITIES,INGEST_PLAN_VERSION,INGRESS_INTENTS,INITIAL_ROOT_FONT_SIZE,INLINE_CHILD_CONTAINER_TYPES,ImageShape,IngestApplicationError,KNOWN_METADATA_PREFIXES,KNOWN_STATE_KEYS,LAYER_PRESENTATION_IDS,LIBRARY_ASSEMBLY_KIND_ORDER,LIBRARY_EMIT_ORDER,LIBRARY_KINDS,Lightning,Line,LinearGradientBuilder,MARKER_HEIGHT,MARKER_VIEWBOX,MARKER_WIDTH,MATHML_EXTENSION_URI,MAX_COORDINATE_PRECISION,MIGRATIONS,NAMESPACE_VOCABULARIES,NGon,NON_RENDERING_LIBRARY_KINDS,NON_WIRE_PROP_KEYS,NUMERIC_SHAPE_TRANSFORM_STATE_KEYS,NestedSvg,NodeSchemaRegistry,PAINT_SERVER_PASSTHROUGH_ATTR,PATH_DATA_TRACK_PROPERTIES,POLYGON_GEOMETRY_DEFAULTS,PRESENTATION_SEMANTICS,PUZZLE_DEFAULTS,Path,PathCurveType,PathPointType,PatternBuilder,Polyline,RDF_NS,RENDER_DIAGNOSTIC_CODES,RENDER_FEATURES,RENDER_FEATURE_CAPABILITIES,RENDER_TARGETS,RICH_TEXT_STYLE_KEYS,RadialGradientBuilder,Rectangle,Ring,SAXES_SVG_XML_PARSER_HOST,SCRIPT_ANIMATION_GENERATORS,SERIALIZED_SHAPE_STATE_KEYS,SHAPE_ENVELOPE_KEYS,SHAPE_GEOMETRY_DEFAULTS,SHAPE_TRANSFORM_STATE_KEYS,SVGSKETCH_NS,SVGSKETCH_PATH_EXTENSIONS,SVG_CONDITIONAL_PROCESSING_ATTRIBUTES,SVG_IMPORT_CAPABILITY_OWNERS,SVG_NAMESPACE,SVG_NS,SVG_PRESENTATION_PROPERTIES,SVG_WELL_KNOWN_NAMESPACE_URIS,SceneGraph,SceneNode,ShapeBuilder,ShapeReference,SpeechBubble,Spiral,Square,Star,SvgImportError,SvgSourceDecodingError,SvgXmlParserHostError,Switch,TEXT_PATH_GENERATED_ID_PREFIX,TYPED_FIELD_PREDICATES,Text,TextLayoutEngine,Timeline,Track,Triangle,VARIANT_INTERPOLATION_POLICY,Video,View,WRAPPER_PRESENTATION_IDS,XHTML_EXTENSION_URI,accumulateAnimationValue,addAnimationValues,addSmilPointsValues,affine,affineFromArray,affineToArray,almostEqualAffine,animationBackwardsFillTrack,animationCycleDuration,animationDefinitionTargetShapeId,animationTrackActiveEnd,animationTrackDocumentBegin,appearanceLayers,appendAppearanceLayer,applyAffineToPoint,applyAffineToVector,applyAppearanceStyle,applyClipMaskGroupDelta,applyClipMaskPlanToShapes,applyCssAnimationLonghandOverrides,applyGuideDeltaOp,applyIngestPlan,applyMeasurementDeltaOp,applyMetadataDeltaOp,applyOpToSnapshot,applyOpsInPlace,applyOpsToSnapshot,applyOpsToSnapshotWithAccepted,applyPathNodeValue,applyRichTextFormat,applyTextSplice,applyTextTransform,applyTimingFunctionToKeyframe,arcEndpointToCenter,areTracksTimingEquivalent,around,assembleLibraryDefs,assembleSvgFromPlan,assertIngestFeatureRegistry,assertIngestPolicyRegistry,assertNamespaceVocabularyRegistry,assertRasterImage,assertSvgImportCapabilityOwners,authoredPaintDeclarations,baseFillLayer,baseStrokeLayer,buildCompoundTransformValues,buildDefinitionPlacementIndex,buildForeignImportReport,buildFreshMetadataBlock,buildGuideDeltaOps,buildManagedChildren,buildManagedDescription,buildMeasurementDeltaOps,buildMetadataDeltaOps,buildRenderPlan,buildSmilKeyframeData,buildSmilKeyframes,buildSvgDestinationIdentityIndex,buildSvgIngestPlan,buildSymbolMaterializationPlan,buildViewBoxSmilKeyframeData,canonicalPolygonTransformString,canonicalTransformMatrix,canonicalTransformString,chainHasTargetedEffects,claimElementThroughVocabulary,classifyIngestDiagnostic,classifySvgExternalAssetUrl,clipMaskDefinitionFromGroup,clipMaskDefinitionsFromGroups,clipMaskGroupDefId,clipMaskGroupDefinitionId,clipMaskGroupIsRawBacked,clipMaskGroupWithDefinition,clipMaskOwnedDefIds,cloneTextSpanTree,collaborationResourceKey,collectDocumentEnvelopeLibraryReferenceIds,collectFontFacesFromPlan,collectFontFamiliesFromPlan,collectMarkerReferences,collectReferencedLibraryDefs,collectReferencedMarkerIds,collectSvgFragmentLibraryReferenceIds,collectUnknownDocumentFields,compareImages,compareOrderKeys,composeDecomposedTransformMatrix,compositeOver,computeArrowVertices,computeCatmullRomSegments,computeCloudPath,computeCrossVertices,computeDashArray,computeFlowchartBoxPath,computeGearPath,computeGearVertices,computeHeartPath,computeLightningVertices,computePolygonVertices,computeRectanglePath,computeRingPath,computeSpeechBubbleVertices,computeSpiralPath,computeSplinePath,computeStarVertices,connectorLabelAnchor,containerTransformNeedsContentPivot,convertGradientUnits,createDocument,createSceneNode,createShape,createSvgDestinationIdAllocator,createSvgPathMetrics,createTextLayoutKey,createTextLayoutProduct,createViewbox,createWordSearchPrimitiveMask,cssAnimationFillField,cssNamedColorToRgb,cubicBezierExtent1D,cubicBezierToEasingFields,customPatternDefToLibraryDef,declaredRichTextDeltaKeys,decodeCssEscapes,decodeSvgSourceBytes,decomposeAffine2D,decoratePlanNodes,decorateSnapshotShapes,dedupeFontFaces,defaultVariableMode,deltaE2000,deriveRichTextFormatRanges,deriveSegments,deriveTextSplice,derivedConnectionPoints,detachAppearanceStyle,documentObjectBounds,ellipticalArcBounds,emptyDocumentMetadata,ensureTextSpanRange,escXml,evaluateEasing,evaluateFontCoverage,evaluateKeyframeEasing,evaluateLinearEasing,evaluateParsedTimingFunction,evaluateSteps,evaluateSvgConditionalProcessing,expandAppearanceStack,extractVariables,filterAttr,filterChainExtendsBounds,filterChainGroupId,filterChainGroups,filterDefinitionEnvelope,filterReferenceValue,finalizeRenderPlan,findShapeById,fingerprintCssAnimationDocumentStyles,fingerprintCssAnimationInlineStyles,fingerprintCssAnimationTrack,fingerprintIngestSource,flattenShapeStateTree,flattenStateExtra,flattenUnknownDocumentFields,foldSchemaV2AncestorTransformIntoMatrix,fontFaceKey,forEachAppearanceLayerRef,forEachAppearanceStyleRef,forEachLibraryRefInState,forEachMarkerRefInState,forEachReachableShape,forEachShapeInLibraryDefs,formatCssFontFamilyList,formatOperationValidationIssues,formatSmilKeySpline,formatSmilKeyTime,freezeIngestPlan,freezeSiblingOrderKeys,generateCode,generateCodeWithDiagnostics,generateCssCode,generateD3Code,generateId,generatePatternSvgContent,generatePuzzlePieces,generateReactCode,generateSudokuPuzzle,generateSvgCode,generateVueCode,generateWordSearch,geometryDefinitionId,geometryState,getBuiltInMarkerDefs,getEasingCubicBezier,getEffectivePrecision,getIngestFeatureCapability,getIngestFieldPolicy,getKeyframeCubicBezier,getLicenseLabel,getLicenseUrl,getMarkerDescriptors,getPatternElements,getShapeGeometryKernel,getSmilAccumulate,getSmilAdditive,getSmilBeginValue,getSmilFillMode,getSmilMotionKeyPoints,getSmilRepeatCount,getSmilSetBeginValue,getSmilTrackDuration,getSvgCoordinateAttributePrecision,getSvgPropertySemantics,getSvgSourceAttribute,getSvgSourceHref,getWordSearchDirections,gradientStopPoint,gradientTransformAttribute,hasAnyTypedMetadataField,hasEmittableSmilSimpleDuration,hasOpaqueSvgAncestor,hasSvgSourceAttribute,importSvg,importSvgWithDiagnostics,indexLibraryDefinitions,inferSvgCoordinatePrecision,initialOrderKeys,injectClipMaskReference,inspectCssTransformValue,interpolateAngle,interpolateCharOffsetArray,interpolateColor,interpolateDasharrayLists,interpolateGradient,interpolateNumericArray,interpolatePathData,interpolatePlainObject,interpolatePointArray,interpolatePolylinePoints,interpolateShapeTrees,interpolateSplinePointArray,invertAffine,isColorValue,isConnectorLineState,isCssAnimationDeclarationName,isCssGenericFamilyName,isCssNamedColor,isDefaultKeyPoints,isDefaultKeyTimes,isDocumentImportIntent,isEntirelyUnembeddableFamilyList,isFiniteAffineArray,isGeometryTrackProperty,isGradientLike,isIdentityAffine,isIdentityLinearSplines,isIndefiniteSetTrack,isIndefiniteSmilSimpleDuration,isNumericArray,isPathDataTrackProperty,isPathNodeTrack,isReusablePatternTile,isSafeGradientRootAttributeName,isSafePatternRootAttributeName,isSetSequenceTrack,isSvgPresentationProperty,isTextPathGeneratedId,isUnembeddableFamilyName,isValidOrderKey,keyBetween,keysBetween,layerFilterTargets,layerPaints,layerState,layoutText,legacyEndpointMarkerId,lerpNumber,linearGradient,linearGradientEnvelope,lintWordSearchOptions,lowerPathNodeTracks,luma709,mapAnimationTrackTime,matchCubicBezierToPreset,materializeSceneTreeOrderKeys,matrixTransformPart,maxCollaborationTimestamp,mergeRichTextStyle,migrateSnapshot,migrateV11toV12,migrateV14toV15,migrateV15toV16,migrateV16toV17,migrateV17toV18,migrateV18toV19,migrateV6toV7,migrateViewboxSidecarToViews,motionPathD,moveResourceById,multiplyAffine,mutateSvgClipMaskDefinitionMarkup,namespaceVocabularies,namespaceVocabulary,needsAppearanceStack,nodeSchemas,normalizeClipMaskGroups,normalizePaintServerDef,normalizeRichTextRuns,normalizeRichTextStyle,normalizeRichTextStyleDelta,normalizeSmilPointsValue,normalizeSnapshotStructure,normalizeSnapshotToCanonicalDocument,orderSiblings,paintingLayers,parseColor,parseCssAnimationShorthand,parseCssTimingFunction,parseCssTransformOrigin,parseDocument,parseDocumentWithDiagnostics,parseFontFamilyList,parseInterpolationNumbers,parsePathNodeProperty,parsePreserveAspectRatio,parseSmilAdditive,parseSmilClockValue,parseSmilDuration,parseSmilFillField,parseSmilKeySplines,parseSmilKeyTimes,parseSmilRepeatSettings,parseSmilValues,parseSvgAbsoluteLength,parseSvgLength,parseSvgLengthList,parseSvgLengthToken,parseSvgPathData,parseSvgRootFrame,parseSvgSourceDocument,parseSvgStyleAttribute,parseSvgTransformList,parseSvgViewBox,parseSvgatorPayload,parseVariableArgs,parseWordSearchWords,partitionShapeStateTree,partitionStateExtra,partitionUnknownDocumentFields,pathCommandStructuresMatch,pathDataBounds,pathNodeTracksAreSuperseded,pattern,patternDefinitionEnvelope,patternLibraryDefToCustomPatternDef,patternTileSize,pickCssAnimationListItem,plainTextOf,plainTextStyle,planClipMaskGroups,planSnapshotExternalEffects,planSvgAnimations,planSvgAuthoredAttributes,planSvgClipMasks,planSvgConditionalProcessing,planSvgContainerHierarchy,planSvgDocumentExtensions,planSvgEmbeddedFrames,planSvgExternalEffects,planSvgFilters,planSvgGradients,planSvgImport,planSvgLeafGeometry,planSvgMarkers,planSvgMetadata,planSvgOccurrenceViewports,planSvgPaintServerDefinitions,planSvgPatterns,planSvgResourceDependencies,planSvgScripts,planSvgSourceIdentifiers,planSvgStyleCascade,planSvgSymbolUses,planSvgUseOccurrences,planSvgViews,planTransformFusion,planVariantTransitions,planVariantTransitionsCss,planVariantTransitionsSmil,planVariantTransitionsWaapi,planViewBoxFusion,preferredSubsetsForText,premultiply,prepareSvgAuthorCssForLiveProjection,prepareSvgExternalAssetUrlForLiveProjection,prepareSvgMarkupForLiveProjection,prepareSvgXmlSource,preserveAspectRatioAlignFactor,projectClipMaskDefinitionAnimations,projectCssTransformStops,projectDefinitionAnimations,projectPresentation,projectPresentationEntry,projectSceneTreeOntoClipMaskGroups,projectSceneTreeOntoShapes,projectSvgAnimationPlan,projectSvgAnimationTimeline,projectSvgImportToIngestPlan,projectSvgImportToSnapshot,projectSvgSourceNodes,projectSvgatorAnimation,projectTextLinePosition,projectTextSpanRotations,promoteManagedDescription,promoteRebasedShapeUpdateClock,pruneAndWrapSubtree,quadraticBezierExtent1D,radialGradient,radialGradientEnvelope,rebaseRichTextFormatRanges,rebaseRichTextRuns,recognizeScriptAnimation,reflectCubicBezier,registerNamespaceVocabulary,registeredExtensionUris,registeredShapeGeometryTypes,removeResourceById,removeResourceByKey,removeResourceByName,removeTrackKeyframe,renderAnimationElements,renderBuiltinMarkerDefs,renderCircle,renderClipMaskDefinitionAnimationElements,renderClipMaskDefinitionShape,renderDefinitionAnimationElements,renderDescriptiveElements,renderDocumentAnimationElements,renderDocumentExtensionAttributes,renderDocumentExtensionNodes,renderDocumentExtensions,renderDocumentScripts,renderDocumentStyles,renderEllipse,renderFilterDefs,renderFilterElement,renderFilterLibraryDef,renderFilterPrimitive,renderFilterPrimitivesForType,renderFlowchartBox,renderForeignObject,renderGradientDefs,renderGradientStopAnimationElement,renderImage,renderLibraryDef,renderLibraryDefs,renderLine,renderLinearGradient,renderLinearGradientLibraryDef,renderMarkerLibraryDef,renderPaintServerDefs,renderPatternLibraryDef,renderPlanDefsBody,renderPolygonShape,renderPolyline,renderRadialGradient,renderRadialGradientLibraryDef,renderRectangle,renderReferencedLibraryDefs,renderResolvedSymbolDefinitionForest,renderResolvedSymbolDefinitionSubtree,renderResolvedSymbolLibraryDef,renderShape,renderShapeContextForLibrary,renderSpline,renderSvgPrimitiveChainFilter,renderSymbolInstance,renderSymbolLibraryDef,renderTemplateVariablesStyle,renderText,renderTextSpanAnimationElements,renderToSvg,renderToSvgWithDiagnostics,renderVariantTransitionScript,renderVariantTransitionStylesheet,replaceClipMaskDefinition,replaceClipMaskGroupsInSceneTree,replaySceneTreePlacements,requiredDecimalPrecision,requiredSubsetsForText,resolveAppearanceStyle,resolveConnectorAnchorFromDocument,resolveConnectorEndpoints,resolveContainerTransform,resolveContainerTransformFromContentBounds,resolveCssAnimationEasingType,resolveEmbeddedSvgTransform,resolveEmbeddedSvgViewportFrameBounds,resolveFontStyle,resolveFontWeight,resolveGradientGeometry,resolveGradientLibraryDef,resolveInlineContainerTransform,resolveMetadataQName,resolvePasteWrapperViewportSize,resolvePathDAtTime,resolvePatternLibraryDef,resolvePatternTile,resolveRichTextStyleAt,resolveRootViewportFraming,resolveShapeGeometry,resolveShapeLocalObjectBounds,resolveShapeObjectBounds,resolveShapeReferenceTransform,resolveStyledTextLines,resolveSvgGradientGeometry,resolveSvgLengthToken,resolveSvgPatternTile,resolveSvgQName,resolveSvgRectRadii,resolveSvgTextSpanTarget,resolveSvgViewport,resolveSymbolDefinitionForestRootIds,resolveSymbolInstanceContent,resolveSymbolInstanceShapes,resolveSymbolInstanceTransform,resolveSymbolViewport,resolveTextSpanProjection,rewriteDocumentEmbeddedPayloads,rewriteIdReferencesInMarkup,rewriteShapeStateEmbeddedPayloads,rewriteSvgResourceReferenceValue,richTextFontVariantCss,richTextLineSpans,richTextRunsFromState,richTextStyleDelta,richTextStyleDeltasEqual,richTextStylesEqual,richTextTspanAttributes,rootMetadataAttrs,rootPaintServerDefId,rotateAffine,roundCoord,roundMarkupCoordinates,roundNumberString,roundSerializedShape,roundSnapshot,routeConnector,runsFromSegments,sameSize,sampleAnimationTrackTime,sampleTextForSubsets,sanitizeRichTextFormatRanges,sanitizeXmlId,scaleAffine,scanCssFunctionTokens,scanCssLocalUrlTokens,senderCorrectionsForOp,serializeSvgPathData,serializedPathNodeGeometry,serializedPresentationReader,severity,shapeAppearanceLayers,shapeAppearanceStyle,shapeLocalObjectBounds,shapeLocalObjectCenter,shapeNeedsAppearanceExpansion,shapeObjectBoundsInSpace,shapeOutlineCapability,shouldRoundSvgCoordinateAttribute,skewXAffine,skewYAffine,smilKeyframeAttributes,snapshotBoundsView,sniffDocumentBytes,solveCubicBezier,solveSudoku,spliceTextSpanTree,splinePathBounds,splitAppearanceForStyle,splitCssAnimationList,splitCssTopLevel,splitCssTopLevelRanges,splitTopLevelElements,srgbToLab,ssimPlane,stringifyDocument,stripAnimationDeclarations,stripCssAnimationInlineStyle,subsetsForCodePoint,substituteString,substituteVariables,symbolDefinitionSemanticHash,symbolInstanceTargetId,synthesizeCssAnimationShorthand,templateVariablesCss,textPathGeneratedId,textSpanEffectiveRotations,textSpanIds,textSpanNodeById,textSpanRangeByIds,transformSplice,transformSvgPathData,translateAffine,translateSvgPathData,tryParseSvgTransformList,unmatchedDecorationDiagnostics,updateGradientLibraryDef,upsertResourceById,upsertResourceByKey,upsertResourceByName,upsertTrackKeyframe,validateDocumentOperations,validateOperation,validatePresenceOperation,validateSnapshot,validateSudokuPuzzle,verticesToPath,visitShapeTree,visitSnapshotShapeTrees,writeAppearanceLayers});
|