@getv.design/embed 0.5.5 → 0.6.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/README.md CHANGED
@@ -36,7 +36,7 @@ rebundling), so the editor and the font code still load only when needed:
36
36
  ```html
37
37
  <div id="design"></div>
38
38
  <script type="module">
39
- import { view } from 'https://cdn.jsdelivr.net/npm/@getv.design/embed@0.5.5/dist/view.js';
39
+ import { view } from 'https://cdn.jsdelivr.net/npm/@getv.design/embed@0.6.0/dist/view.js';
40
40
 
41
41
  const text = await (await fetch('/designs/home.vd')).text();
42
42
  await view(document.querySelector('#design'), text);
@@ -230,7 +230,7 @@ has no `problems` or `fonts` event yet to say so.
230
230
  ### Where the faces come from
231
231
 
232
232
  The faces come from `fontBase`, by default this package's `fonts/` folder on
233
- jsDelivr (`https://cdn.jsdelivr.net/npm/@getv.design/embed@0.5.5/fonts/`). That means
233
+ jsDelivr (`https://cdn.jsdelivr.net/npm/@getv.design/embed@0.6.0/fonts/`). That means
234
234
  your readers' browsers request the faces from jsDelivr, and a content security
235
235
  policy needs it in `connect-src`. To keep those requests on your own origin,
236
236
  copy `node_modules/@getv.design/embed/fonts/` to your site and point `fontBase` at it:
@@ -259,7 +259,7 @@ The embed's styles reach the page by one of two routes.
259
259
  ```
260
260
 
261
261
  Link them before the embed runs, from your own origin or from the CDN
262
- (`https://cdn.jsdelivr.net/npm/@getv.design/embed@0.5.5/view.css`). The id is what
262
+ (`https://cdn.jsdelivr.net/npm/@getv.design/embed@0.6.0/view.css`). The id is what
263
263
  the embed looks for: linked without it, the stylesheet still works, but
264
264
  the embed inserts its `<style>` as well.
265
265
 
@@ -1,4 +1,4 @@
1
- @getv.design/embed v0.5.5
1
+ @getv.design/embed v0.6.0
2
2
 
3
3
  Third-party notices.
4
4
 
@@ -7,7 +7,7 @@ files are included, the fonts listed below. Each is distributed under its own
7
7
  licence, reproduced here in full; those licences, not the licence of this
8
8
  package, govern them.
9
9
 
10
- Software (13):
10
+ Software (14):
11
11
 
12
12
  ========================================================================
13
13
  @swc/helpers 0.5.23 (Apache-2.0)
@@ -652,6 +652,45 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
652
652
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
653
653
  SOFTWARE.
654
654
 
655
+ ========================================================================
656
+ path-bool 1.0.4 (MIT)
657
+ https://r-flash.github.io/PathBool.js/
658
+ ------------------------------------------------------------------------
659
+
660
+ MIT License
661
+
662
+ Copyright (c) 2024 Adam Platkevič
663
+
664
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
665
+
666
+ The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.
667
+
668
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
669
+
670
+ ------------------------------------------------------------------------
671
+
672
+ Includes gl-matrix 3.4.4 (MIT), copied into its own files (path-bool's dist/path-bool.js carries gl-matrix's vec2 and mat2 code without its notice; the text is gl-matrix 3.4.4's LICENSE.md):
673
+
674
+ Copyright (c) 2015-2025, Brandon Jones, Colin MacKenzie IV.
675
+
676
+ Permission is hereby granted, free of charge, to any person obtaining a copy
677
+ of this software and associated documentation files (the "Software"), to deal
678
+ in the Software without restriction, including without limitation the rights
679
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
680
+ copies of the Software, and to permit persons to whom the Software is
681
+ furnished to do so, subject to the following conditions:
682
+
683
+ The above copyright notice and this permission notice shall be included in
684
+ all copies or substantial portions of the Software.
685
+
686
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
687
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
688
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
689
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
690
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
691
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
692
+ THE SOFTWARE.
693
+
655
694
  ========================================================================
656
695
  restructure 3.0.2 (MIT)
657
696
  https://github.com/devongovett/restructure
package/dist/auto.js CHANGED
@@ -1,2 +1,2 @@
1
- /*! @getv.design/embed v0.5.5. Free to use under the vDesign Embed Licence. © 2026 vDesign. https://getv.design/docs/licence/ */
2
- import"./chunks/chunk-565P424V.js";var f="data-vd-live";async function L(n=document,s={}){let e=[...n.querySelectorAll('figure.vd-figure[data-vd-mode="view"]')].filter(t=>!t.hasAttribute(f)&&t.dataset.vdSource);if(e.length===0)return[];for(let t of e)t.setAttribute(f,"opening");let{view:r}=await import("./view.js");return(await Promise.all(e.map(t=>w(t,r,s)))).filter(t=>t!==void 0)}async function w(n,s,e){let r;try{let d=atob(n.dataset.vdSource??"");r=new TextDecoder().decode(Uint8Array.from(d,u=>u.charCodeAt(0)))}catch{n.removeAttribute(f);return}let i=n.querySelector(".vd-figure-art"),t=n.ownerDocument.createElement("div");t.className="vd-figure-live",t.style.height=`${x(n,i)}px`,i?.after(t);let o=n.dataset.vdPage;try{let d=await s(t,r,{fit:"page",...o===void 0?{}:{page:/^\d+$/.test(o)?Number(o):o},...e.fonts?{fonts:e.fonts}:{},...e.fontBase?{fontBase:e.fontBase}:{},...e.surface?{surface:e.surface}:{},...e.onLink?{onLink:e.onLink}:{}});return i?.setAttribute("hidden",""),n.setAttribute(f,"true"),d.pages().length>1&&H(n,t,d,o),d}catch{t.remove(),n.removeAttribute(f);return}}function H(n,s,e,r){let i=(a,v,y)=>{let b=n.ownerDocument.createElement(a);return b.className=v,b.textContent=y,b},t=i("div","vd-figure-pager",""),o=i("button","vd-figure-pager__button","\u2039"),d=i("span","vd-figure-pager__label",""),u=i("button","vd-figure-pager__button","\u203A"),m=i("button","vd-figure-pager__button","Present");o.setAttribute("aria-label","Previous page"),u.setAttribute("aria-label","Next page"),d.setAttribute("aria-live","polite");for(let a of[o,u,m])a.setAttribute("type","button");t.append(o,d,u,m),s.after(t);let c=e.pages(),g=r===void 0?-1:/^\d+$/.test(r)?Number(r):c.findIndex(a=>a.id===r),l=g>=0&&g<c.length?g:0,p=()=>{let a=c[l];d.textContent=`${a?.name??a?.id??""} \xB7 ${l+1} of ${c.length}`},h=a=>{l=Math.min(c.length-1,Math.max(0,l+a)),e.goTo(l),p()};e.on("page",a=>{l=Math.max(0,c.findIndex(v=>v.id===a.id)),p()}),o.addEventListener("click",()=>h(-1)),u.addEventListener("click",()=>h(1)),m.addEventListener("click",()=>{e.play()}),p()}function x(n,s){let e=Number(n.dataset.vdHeight);if(Number.isFinite(e)&&e>0)return e;let r=s?.getBoundingClientRect().height??0;return r>0?Math.max(240,Math.round(r)):420}export{L as hydrate};
1
+ /*! @getv.design/embed v0.6.0. Free to use under the vDesign Embed Licence. © 2026 vDesign. https://getv.design/docs/licence/ */
2
+ import"./chunks/chunk-UN7F6SH4.js";var f="data-vd-live";async function L(n=document,s={}){let e=[...n.querySelectorAll('figure.vd-figure[data-vd-mode="view"]')].filter(t=>!t.hasAttribute(f)&&t.dataset.vdSource);if(e.length===0)return[];for(let t of e)t.setAttribute(f,"opening");let{view:r}=await import("./view.js");return(await Promise.all(e.map(t=>w(t,r,s)))).filter(t=>t!==void 0)}async function w(n,s,e){let r;try{let d=atob(n.dataset.vdSource??"");r=new TextDecoder().decode(Uint8Array.from(d,u=>u.charCodeAt(0)))}catch{n.removeAttribute(f);return}let i=n.querySelector(".vd-figure-art"),t=n.ownerDocument.createElement("div");t.className="vd-figure-live",t.style.height=`${x(n,i)}px`,i?.after(t);let o=n.dataset.vdPage;try{let d=await s(t,r,{fit:"page",...o===void 0?{}:{page:/^\d+$/.test(o)?Number(o):o},...e.fonts?{fonts:e.fonts}:{},...e.fontBase?{fontBase:e.fontBase}:{},...e.surface?{surface:e.surface}:{},...e.onLink?{onLink:e.onLink}:{}});return i?.setAttribute("hidden",""),n.setAttribute(f,"true"),d.pages().length>1&&H(n,t,d,o),d}catch{t.remove(),n.removeAttribute(f);return}}function H(n,s,e,r){let i=(a,v,y)=>{let b=n.ownerDocument.createElement(a);return b.className=v,b.textContent=y,b},t=i("div","vd-figure-pager",""),o=i("button","vd-figure-pager__button","\u2039"),d=i("span","vd-figure-pager__label",""),u=i("button","vd-figure-pager__button","\u203A"),m=i("button","vd-figure-pager__button","Present");o.setAttribute("aria-label","Previous page"),u.setAttribute("aria-label","Next page"),d.setAttribute("aria-live","polite");for(let a of[o,u,m])a.setAttribute("type","button");t.append(o,d,u,m),s.after(t);let c=e.pages(),g=r===void 0?-1:/^\d+$/.test(r)?Number(r):c.findIndex(a=>a.id===r),l=g>=0&&g<c.length?g:0,p=()=>{let a=c[l];d.textContent=`${a?.name??a?.id??""} \xB7 ${l+1} of ${c.length}`},h=a=>{l=Math.min(c.length-1,Math.max(0,l+a)),e.goTo(l),p()};e.on("page",a=>{l=Math.max(0,c.findIndex(v=>v.id===a.id)),p()}),o.addEventListener("click",()=>h(-1)),u.addEventListener("click",()=>h(1)),m.addEventListener("click",()=>{e.play()}),p()}function x(n,s){let e=Number(n.dataset.vdHeight);if(Number.isFinite(e)&&e>0)return e;let r=s?.getBoundingClientRect().height??0;return r>0?Math.max(240,Math.round(r)):420}export{L as hydrate};
@@ -1,3 +1,3 @@
1
- /*! @getv.design/embed v0.5.5. Free to use under the vDesign Embed Licence. © 2026 vDesign. https://getv.design/docs/licence/ */
2
- import{a as m,b as w,d as g,e as O,f as P,g as S,h as y,i as p}from"./chunk-NMTM7OEB.js";import{L as R,n as v}from"./chunk-5XTOQNJT.js";import{b as h}from"./chunk-OJEQYRTB.js";function E(e){return m(e)}async function L(e,n={}){let t=n.fonts??"approximate";if(!x.includes(t))throw new TypeError(`renderSvg: fonts must be one of ${x.join(", ")}; got ${String(t)}.`);let o=t==="exact"?y(n.fontBase,F()):void 0,{document:i,blocks:a,problems:s}=await O(e),r=n.page===void 0?i:D(i,n.page),u=B(a),f=n.idPrefix,d=[...s],c;if(t==="exact")if(o===void 0)d.push(p([],"no fontBase was given and this build has no default"));else{let{exactSvg:l}=await import("./fonts.js"),b=await l(r,{base:o,resolveAsset:u,...f?{idPrefix:f}:{}});"svg"in b?c=b.svg:d.push(p(b.failures))}return c??=R(r,{ids:!1,resolveAsset:u,...f?{idPrefix:f}:{}}),n.onProblems?.(d),c}function M(e){return typeof e=="string"?w(e).vd:void 0}function C(e){let{document:n,problems:t}=m(e),{document:o}=g(n),{vd:i,offset:a}=typeof e=="string"?w(e):{vd:void 0,offset:0},s=new Map;if(i!==void 0){let r=/^frame\s+(\S+)/;i.split(`
1
+ /*! @getv.design/embed v0.6.0. Free to use under the vDesign Embed Licence. © 2026 vDesign. https://getv.design/docs/licence/ */
2
+ import{a as m,b as w,d as g,e as O,f as P,g as S,h as y,i as p}from"./chunk-RSOCS6S4.js";import{da as R,o as v}from"./chunk-P42KFNKD.js";import{b as h}from"./chunk-VTEBIFPH.js";function E(e){return m(e)}async function L(e,n={}){let t=n.fonts??"approximate";if(!x.includes(t))throw new TypeError(`renderSvg: fonts must be one of ${x.join(", ")}; got ${String(t)}.`);let o=t==="exact"?y(n.fontBase,F()):void 0,{document:i,blocks:a,problems:s}=await O(e),r=n.page===void 0?i:D(i,n.page),u=B(a),f=n.idPrefix,d=[...s],c;if(t==="exact")if(o===void 0)d.push(p([],"no fontBase was given and this build has no default"));else{let{exactSvg:l}=await import("./fonts.js"),b=await l(r,{base:o,resolveAsset:u,...f?{idPrefix:f}:{}});"svg"in b?c=b.svg:d.push(p(b.failures))}return c??=R(r,{ids:!1,resolveAsset:u,...f?{idPrefix:f}:{}}),n.onProblems?.(d),c}function M(e){return typeof e=="string"?w(e).vd:void 0}function C(e){let{document:n,problems:t}=m(e),{document:o}=g(n),{vd:i,offset:a}=typeof e=="string"?w(e):{vd:void 0,offset:0},s=new Map;if(i!==void 0){let r=/^frame\s+(\S+)/;i.split(`
3
3
  `).some((u,f)=>{if(u.startsWith("--- payload"))return!0;let d=r.exec(u)?.[1];return d!==void 0&&!s.has(d)&&s.set(d,f+1+a),!1})}return{...o.title===void 0?{}:{title:o.title},pages:P(o).map(r=>({id:r.id,...r.name===void 0?{}:{name:r.name},...s.has(r.id)?{line:s.get(r.id)}:{}})),problems:t}}async function W(e={}){let n=e.fonts??"approximate";if(!x.includes(n))throw new TypeError(`createRenderer: fonts must be one of ${x.join(", ")}; got ${String(n)}.`);let t,o="approximate",i,a;if(n==="exact")if(t=y(e.fontBase,F()),t===void 0)a=p([],"no fontBase was given and this build has no default");else{let s=await import("./fonts.js"),r=await s.exactFontsAt(t).ensureAll();i=s.exactSvgNow,o=r.length<s.BUNDLED_FACE_COUNT?"exact":"approximate",r.length>0&&(a=p(r))}return N({fonts:o,base:t,exactNow:i,failed:a})}function _(){return N({fonts:"approximate",base:void 0,exactNow:void 0,failed:void 0})}function N(e){let{fonts:n,base:t,exactNow:o,failed:i}=e;return{fonts:n,renderSvg(a,s={}){let r=typeof a=="string"?g(m(a).document):g(a),u=s.page===void 0?r.document:D(r.document,s.page),f=B(r.blocks),d=s.idPrefix,c=[...r.problems],l;return n==="exact"&&t!==void 0&&o!==void 0?(l=o(u,{base:t,resolveAsset:f,...d?{idPrefix:d}:{}}),l===void 0&&i&&c.push(i)):i&&c.push(i),l??=R(u,{ids:!1,resolveAsset:f,...d?{idPrefix:d}:{}}),s.onProblems?.(c),l}}}function B(e){return n=>{let t=e.get(n.hash);return t===void 0?void 0:v(n.type,t)}}var x=["approximate","exact"];function F(){let e=import.meta.url;if(typeof e!="string")return h;let t=typeof globalThis.process?.getBuiltinModule=="function",o=/\/dist\/chunks\/[^/]*$/.test(e)?"../../fonts/":"../fonts/";return e.startsWith("file:")&&t?new URL(o,e).href:h}function D(e,n){let t=S(e,n);return{...e,root:{...e.root,children:e.root.children.map(o=>o===t?o:{...o,hidden:!0})}}}export{E as a,L as b,M as c,C as d,W as e,_ as f};
@@ -1,4 +1,4 @@
1
- /*! @getv.design/embed v0.5.5. Free to use under the vDesign Embed Licence. © 2026 vDesign. https://getv.design/docs/licence/ */
2
- import{f as O}from"./chunk-2ZC4KNI4.js";import{a as k,d as P,f as S}from"./chunk-NMTM7OEB.js";import{a as x,o as F}from"./chunk-5XTOQNJT.js";function _(r="vd"){let e=0;return()=>`${r}${++e}-`}var A={bytes:1e6,nodes:5e3};function Z(r){let e=/^\s*([^\s{]+)/.exec(r??"")?.[1]?.toLowerCase();return e==="vd"||e==="vdesign"}function E(r){let e={},s=(r??"").trim().replace(/^\S+/,""),t=/([A-Za-z][\w-]*)(?:=(?:"((?:[^"\\]|\\.)*)"|'([^']*)'|(\S+)))?/g;for(let a of s.matchAll(t)){let i=a[1]?.toLowerCase(),o=a[2]?.replace(/\\(.)/g,"$1")??a[3]??a[4];switch(i){case"page":o!==void 0&&o!==""&&(e.page=/^\d+$/.test(o)?Number(o):o);break;case"src":o&&(e.src=o);break;case"height":{let d=Number(o);Number.isFinite(d)&&d>0&&d<=1e4&&(e.height=d);break}case"mode":(o==="static"||o==="view")&&(e.mode=o);break;case"source":e.source=o===void 0||o==="true";break;case"alt":o!==void 0&&(e.alt=o);break;default:break}}return e}function G(r,e,s={}){let t=typeof e=="string"?E(e):e,a={...A,...s.limits},i=typeof r=="string"?r:"";if(t.src!==void 0){let n;try{n=s.resolveSrc?.(t.src)}catch{n=void 0}if(n===void 0)return l(i,[g("src-unresolved",`Could not read ${t.src}.`)]);i=n}if(i.length>a.bytes)return l(t.src===void 0?i:"",[g("too-large",`This design is over ${a.bytes} characters, the most a fence draws.`)]);let{document:o,problems:d}=k(i),h=P(o).document;if(B(h)>a.nodes)return l(t.src===void 0?i:"",[g("too-large",`This design has over ${a.nodes} shapes, the most a fence draws.`)]);if(S(h).length===0){let n=d.filter(m=>m.severity==="error");return l(t.src===void 0?i:"",[...n,...n.length===0?[g("no-pages","This design has no page to draw.")]:[]])}let R=s.renderer??O(),j=s.idPrefix??z,f,v=[];try{f=R.renderSvg(o,{...t.page===void 0?{}:{page:t.page},idPrefix:j(),onProblems:n=>v.push(...n)})}catch(n){return l(t.src===void 0?i:"",[g("no-such-page",n instanceof Error?n.message:String(n))])}let b=t.mode??s.mode??"static",$=t.alt??h.title??"Design",L=s.output==="img"||s.inlineStyles===!1&&/ style="/.test(f)?`<img class="vd-figure-art" alt="${c($)}" src="data:image/svg+xml;base64,${T(f)}">`:`<div class="vd-figure-art" role="img" aria-label="${c($)}">${N(f).trimEnd()}</div>`,y=["vd-figure"],u=[];for(let[n,m]of s.attributes??[])!/^[a-z][a-z0-9-]*$/i.test(n)||/^on/i.test(n)||n==="style"||(n==="class"?y.push(...m.split(/\s+/).filter(Boolean)):u.push(`${n}="${c(m)}"`));u.unshift(`class="${c(y.join(" "))}"`,`data-vd-mode="${b}"`),t.page!==void 0&&u.push(`data-vd-page="${c(String(t.page))}"`),t.height!==void 0&&u.push(`data-vd-height="${t.height}"`),b==="view"&&u.push(`data-vd-source="${T(i)}"`);let p=[`<figure ${u.join(" ")}>`,L],w=C([...d,...v]);return w.length>0&&p.push(I(w)),t.source&&p.push(`<details class="vd-figure-source"><summary>Source</summary><pre><code class="language-vd">${c(i)}</code></pre></details>`),p.push("</figure>"),`${p.join("")}
1
+ /*! @getv.design/embed v0.6.0. Free to use under the vDesign Embed Licence. © 2026 vDesign. https://getv.design/docs/licence/ */
2
+ import{f as O}from"./chunk-7P37TP37.js";import{a as k,d as P,f as S}from"./chunk-RSOCS6S4.js";import{b as x,p as F}from"./chunk-P42KFNKD.js";function _(r="vd"){let e=0;return()=>`${r}${++e}-`}var A={bytes:1e6,nodes:5e3};function Z(r){let e=/^\s*([^\s{]+)/.exec(r??"")?.[1]?.toLowerCase();return e==="vd"||e==="vdesign"}function E(r){let e={},s=(r??"").trim().replace(/^\S+/,""),t=/([A-Za-z][\w-]*)(?:=(?:"((?:[^"\\]|\\.)*)"|'([^']*)'|(\S+)))?/g;for(let a of s.matchAll(t)){let i=a[1]?.toLowerCase(),o=a[2]?.replace(/\\(.)/g,"$1")??a[3]??a[4];switch(i){case"page":o!==void 0&&o!==""&&(e.page=/^\d+$/.test(o)?Number(o):o);break;case"src":o&&(e.src=o);break;case"height":{let d=Number(o);Number.isFinite(d)&&d>0&&d<=1e4&&(e.height=d);break}case"mode":(o==="static"||o==="view")&&(e.mode=o);break;case"source":e.source=o===void 0||o==="true";break;case"alt":o!==void 0&&(e.alt=o);break;default:break}}return e}function G(r,e,s={}){let t=typeof e=="string"?E(e):e,a={...A,...s.limits},i=typeof r=="string"?r:"";if(t.src!==void 0){let n;try{n=s.resolveSrc?.(t.src)}catch{n=void 0}if(n===void 0)return l(i,[g("src-unresolved",`Could not read ${t.src}.`)]);i=n}if(i.length>a.bytes)return l(t.src===void 0?i:"",[g("too-large",`This design is over ${a.bytes} characters, the most a fence draws.`)]);let{document:o,problems:d}=k(i),h=P(o).document;if(B(h)>a.nodes)return l(t.src===void 0?i:"",[g("too-large",`This design has over ${a.nodes} shapes, the most a fence draws.`)]);if(S(h).length===0){let n=d.filter(m=>m.severity==="error");return l(t.src===void 0?i:"",[...n,...n.length===0?[g("no-pages","This design has no page to draw.")]:[]])}let R=s.renderer??O(),j=s.idPrefix??z,f,v=[];try{f=R.renderSvg(o,{...t.page===void 0?{}:{page:t.page},idPrefix:j(),onProblems:n=>v.push(...n)})}catch(n){return l(t.src===void 0?i:"",[g("no-such-page",n instanceof Error?n.message:String(n))])}let b=t.mode??s.mode??"static",$=t.alt??h.title??"Design",L=s.output==="img"||s.inlineStyles===!1&&/ style="/.test(f)?`<img class="vd-figure-art" alt="${c($)}" src="data:image/svg+xml;base64,${T(f)}">`:`<div class="vd-figure-art" role="img" aria-label="${c($)}">${N(f).trimEnd()}</div>`,y=["vd-figure"],u=[];for(let[n,m]of s.attributes??[])!/^[a-z][a-z0-9-]*$/i.test(n)||/^on/i.test(n)||n==="style"||(n==="class"?y.push(...m.split(/\s+/).filter(Boolean)):u.push(`${n}="${c(m)}"`));u.unshift(`class="${c(y.join(" "))}"`,`data-vd-mode="${b}"`),t.page!==void 0&&u.push(`data-vd-page="${c(String(t.page))}"`),t.height!==void 0&&u.push(`data-vd-height="${t.height}"`),b==="view"&&u.push(`data-vd-source="${T(i)}"`);let p=[`<figure ${u.join(" ")}>`,L],w=C([...d,...v]);return w.length>0&&p.push(I(w)),t.source&&p.push(`<details class="vd-figure-source"><summary>Source</summary><pre><code class="language-vd">${c(i)}</code></pre></details>`),p.push("</figure>"),`${p.join("")}
3
3
  `}function N(r){return r.replace(/<a href="#[^"]*">(<tspan[^>]*>[^<]*<\/tspan>)<\/a>/g,"$1")}function T(r){return F(new TextEncoder().encode(r))}var z=_();function B(r){let e=0;return x(r.root,()=>{e+=1}),e}function l(r,e){let s=e.length>0?I(e):"";return`<pre><code class="language-vd">${c(r)}</code></pre>${s}
4
4
  `}function I(r){return`<ul class="vd-problems">${r.map(s=>`<li data-severity="${s.severity}">${c(s.message)}</li>`).join("")}</ul>`}function C(r){let e=new Set;return r.filter(s=>{let t=`${s.code}\0${s.message}`;return e.has(t)?!1:(e.add(t),!0)})}function g(r,e){return{code:r,message:e,severity:"error"}}function c(r){return r.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}export{_ as a,Z as b,E as c,G as d};
@@ -0,0 +1,10 @@
1
+ /*! @getv.design/embed v0.6.0. Free to use under the vDesign Embed Licence. © 2026 vDesign. https://getv.design/docs/licence/ */
2
+ var bn=["radiusTL","radiusTR","radiusBR","radiusBL"],re=["radius",...bn];function $n(e){let n=e.radius??0,t=r=>Math.max(0,e[r]??n);return{tl:t("radiusTL"),tr:t("radiusTR"),br:t("radiusBR"),bl:t("radiusBL")}}function wn(e,n,t){let r=Math.max(0,n),o=Math.max(0,t),i=1,s=(u,a)=>{a>0&&(i=Math.min(i,u/a))};return s(r,e.tl+e.tr),s(r,e.bl+e.br),s(o,e.tl+e.bl),s(o,e.tr+e.br),i>=1?e:{tl:e.tl*i,tr:e.tr*i,br:e.br*i,bl:e.bl*i}}function Te(e,n,t){return wn($n(e),n,t)}function oe(e){return e.tl<=0&&e.tr<=0&&e.br<=0&&e.bl<=0}function Pt(e){return e.tl===e.tr&&e.tr===e.br&&e.br===e.bl}var Hi=/^(?:\d+(?:\.\d*)?|\.\d+)$/;function Ct(e){if(!e.startsWith('"'))return;let n;try{let u=JSON.parse(e);if(typeof u!="string")return;n=u}catch{return}let t=n.trim().split(/\s+/).filter(u=>u!=="");if(t.length<2)return;if(t.length>4)return{error:`the shorthand takes one to four corners, got ${t.length}: "${n}"`};for(let u of t){if(/^[$@(]/.test(u))return{error:`the shorthand takes numbers \u2014 bind one corner with its own cell, e.g. radiusTL=${u}`};if(!Hi.test(u))return/^(-?\d+(?:\.\d+)?)px$/.exec(u)&&!u.startsWith("-")?{error:`drop the unit: radius="${t.map(c=>c.replace(/px$/,"")).join(" ")}"`}:{error:/^-\d/.test(u)?`a radius cannot be negative, got ${u}`:`the shorthand takes plain numbers, got "${u}"`}}let[r,o=r,i=r,s=o]=t;return{corners:[["radiusTL",r],["radiusTR",o],["radiusBR",i],["radiusBL",s]]}}var kn=["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"];var He=["left","center","right","justify"],Ye=["top","middle","bottom"],fe=["cover","contain","fill"],vn=["nonzero","evenodd"],Sn=["butt","round","square"],En=["miter","round","bevel"],ro=["canvas","frame","group","instance"];function On(e){return ro.includes(e)}function D(e){return On(e.type)}function Ae(e){return e.type==="group"}function z(e){return D(e)?e.children:[]}var oo={canvas:["w","h"],connector:["x1","y1","x2","y2","strokeWidth","opacity","blur"],ellipse:["x","y","w","h","rotation","strokeWidth","opacity","blur","backdrop"],frame:["x","y","w","h","strokeWidth",...re,"blur","backdrop"],group:[],instance:["x","y","w","h"],image:["x","y","w","h","rotation","strokeWidth",...re,"opacity","blur"],rect:["x","y","w","h","rotation","strokeWidth",...re,"opacity","blur","backdrop"],text:["x","y","w","h","rotation","size","weight","lineHeight","letterSpacing","strokeWidth","opacity","blur"],video:["x","y","w","h","rotation","strokeWidth",...re,"opacity","blur"],vector:["x","y","w","h","rotation","strokeWidth","opacity","blur","backdrop"]};function Mn(e){return oo[e.type]}function C(e,n,t){if(n(e,t)!==!1&&D(e))for(let r of e.children)C(r,n,e)}function X(e,n){let t;return C(e,r=>{if(t)return!1;r.id===n&&(t=r)}),t}function le(e){let n=e.trim();if(n.startsWith("#")){let r=n.slice(1);return r===""?void 0:{kind:"frame",id:r}}let t;try{t=new URL(n)}catch{return}if(!(t.protocol!=="https:"&&t.protocol!=="mailto:"))return{kind:"url",url:n}}var Ne="--- payload base64 ---",Yi="sha256-";function io(e){let n=ns(e);return n===-1?{head:e,payload:""}:{head:e.slice(0,n),payload:e.slice(n+Ne.length)}}function qi(e){let{head:n,payload:t}=io(e);return{head:n,blocks:so(t)}}function so(e){let n=new Map;for(let t of e.split(`
3
+ `)){let r=t.indexOf(" ");if(r===-1)continue;let o=t.slice(0,r);o.startsWith(Yi)&&n.set(o,t.slice(r+1).trim())}return n}function Zi(e,n){return`data:${e};base64,${n}`}function Qi(e){let n=e.toBase64;if(typeof n=="function")return n.call(e);let t="";for(let r=0;r<e.length;r+=32768)t+=String.fromCharCode(...e.subarray(r,r+32768));return btoa(t)}function es(e){let n=Uint8Array.fromBase64;if(typeof n=="function")return n(e);let t=atob(e),r=new Uint8Array(t.length);for(let o=0;o<t.length;o+=1)r[o]=t.charCodeAt(o);return r}function ns(e){if(e.startsWith(Ne))return 0;let n=e.indexOf(`
4
+ ${Ne}`);return n===-1?-1:n+1}function pe(e){return{expr:e}}function F(e){return typeof e=="object"&&e!==null&&typeof e.expr=="string"}var Dt=["light","dark"],Vt=["must","should"],Tn=["no-gradient","contrast","font-only","logo-min"];var uo=["role","logo","rule","guide","review"];function An(e){return uo.includes(e)}function Nn(e="",n=1){return{slug:e,version:n,changes:[],sources:[],roles:{},logos:{},rules:{},guides:{},review:[]}}function Lt(e){let n=/^([a-z0-9][a-z0-9-]*)(?:@(\d+))?$/.exec(e);if(!n)return;let t=n[2]===void 0?1:Number(n[2]);if(!(!Number.isSafeInteger(t)||t<1))return{slug:n[1],version:t}}var ts=8,rs=new Set(["type","id","children","component","overrides"]);function _e(e){return!rs.has(e)}function Ie(e,n){return`${e}.${n}`}function Re(e){let n=new Map,t=r=>{if(r.type!=="instance"){r.type==="frame"&&r.component===!0&&n.set(r.id,r);for(let o of z(r))t(o)}};return t(e),n}function _n(e,n){let t=[],r=o=>{if(o.type==="instance"){(n===void 0||o.component===n)&&t.push(o);return}for(let i of z(o))r(i)};return r(e),t}function he(e){let n=e;for(let t=0;t<ts;t+=1){let r=Re(n),o=ao(n,r);if(o===n)return n;n=o}return n}var jt=new WeakMap;function ao(e,n){if(e.type==="instance"){let o=n.get(e.component)??null;if(jt.has(e)&&jt.get(e)===o)return e;let i=co(e,n,new Set),s=Ut(i,e.children)?e:{...e,children:i};return jt.set(s,o),s}if(!D(e))return e;let t=!1,r=e.children.map(o=>{let i=ao(o,n);return i!==o&&(t=!0),i});return t?{...e,children:r}:e}function co(e,n,t){let r=n.get(e.component);if(!r||t.has(r.id))return[];let o=new Set(t).add(r.id),i=r.children.map(s=>Bt(s,e.id,n,o));return os(i,e.id,e.overrides)}function Bt(e,n,t,r){let o=Ie(n,e.id);if(e.type==="instance"){let i={...e,id:o};return{...i,children:co(i,t,r)}}if(e.type==="frame"){let i={...e};return delete i.component,{...i,id:o,children:e.children.map(s=>Bt(s,n,t,r))}}return D(e)?{...e,id:o,children:e.children.map(i=>Bt(i,n,t,r))}:{...e,id:o}}function os(e,n,t){if(t===void 0)return[...e];let r=new Map;for(let[i,s]of Object.entries(t))r.set(Ie(n,i),s);let o=i=>{let s=r.get(i.id),u=i;if(s){let a={...i};for(let[c,d]of Object.entries(s))_e(c)&&(a[c]=d);u=a}return D(u)?{...u,children:u.children.map(o)}:u};return e.map(o)}function Wt(e){let n=[],t=Re(e);for(let i of _n(e)){let s=t.get(i.component);if(!s){n.push({severity:"error",code:"missing-component",message:`${i.id} places ${i.component}, which is not a component \u2014 mark a frame with component, or point component= at one`,nodeId:i.id});continue}if(Ft(s,s.id,t,new Set)){n.push({severity:"error",code:"component-cycle",message:`${s.id} holds an instance of itself, so ${i.id} cannot be drawn`,nodeId:i.id});continue}for(let u of Object.keys(i.overrides??{}))X(i,Ie(i.id,u))||n.push({severity:"warning",code:"orphaned-override",message:`${i.id} overrides ${u}, which ${s.id} no longer has`,nodeId:i.id})}for(let[i]of t)e.type==="canvas"&&e.children.some(s=>s.id===i)||n.push({severity:"warning",code:"component-not-top-level",message:`${i} is a component inside another frame \u2014 keep components in the row below the pages, at the top level`,nodeId:i});let r=new Map,o=i=>{r.set(i.id,(r.get(i.id)??0)+1);for(let s of z(i))o(s)};o(e);for(let i of _n(e))for(let s of i.children){let u=a=>{(r.get(a.id)??0)>1&&n.push({severity:"error",code:"duplicate-id",message:`${a.id} is both a node and a part of ${i.id} \u2014 rename one`,nodeId:a.id});for(let c of z(a))u(c)};u(s)}return n}function Ft(e,n,t,r){return z(e).some(o=>{if(o.type==="instance"){if(o.component===n)return!0;if(r.has(o.component))return!1;r.add(o.component);let i=t.get(o.component);return i!==void 0&&Ft(i,n,t,r)}return Ft(o,n,t,r)})}function In(e){return Re(e).size>0||_n(e).length>0}function Ut(e,n){if(e===n)return!0;if(typeof e!="object"||typeof n!="object"||e===null||n===null)return!1;if(Array.isArray(e)||Array.isArray(n))return Array.isArray(e)&&Array.isArray(n)&&e.length===n.length&&e.every((i,s)=>Ut(i,n[s]));let t=e,r=n,o=new Set([...Object.keys(t),...Object.keys(r)]);for(let i of o)if(!Ut(t[i],r[i]))return!1;return!0}var qe=["design","brand"],Pe="design",fo=new WeakMap;function U(e){let n=e.brand?.theme==="dark"?e.themes?.dark:void 0;if(n===void 0)return e.tokens;let t=fo.get(e);if(t!==void 0)return t;let r={...e.tokens,...n};return fo.set(e,r),r}var lo=4,po=5,ho=6,mo=7,zt=8,Rn=[1,2,3,4,5,6,7,8],Pn=zt;function ie(e){return e.root!==void 0&&go(e.root)?zt:e.root!==void 0&&yo(e.root)?mo:e.root!==void 0&&In(e.root)?ho:e.kind==="brand"||e.brand!==void 0||e.themes!==void 0||is(e.fonts)?po:lo}function go(e){let n=!1;return C(e,t=>(t.type==="video"&&(n=!0),n?!1:void 0)),n}function yo(e){let n=!1;return C(e,t=>(t.type==="connector"&&(n=!0),n?!1:void 0)),n}function is(e){return Object.values(e??{}).some(n=>(n.faces??[]).some(t=>t.asset!==void 0))}var me="doc";function Ze(e){return{type:"canvas",...e}}function Cn(e={}){let n=e.kind??Pe,t=Ce(e.themes),r=he(e.root??Ze({id:me,children:[]}));return{version:ie({kind:n,root:r,...e.fonts===void 0?{}:{fonts:e.fonts},...e.brand===void 0?{}:{brand:e.brand},...t===void 0?{}:{themes:t}}),kind:n,...e.title===void 0?{}:{title:e.title},tokens:e.tokens??{},fonts:e.fonts??{},assets:e.assets??{},...e.motion===void 0||Object.keys(e.motion).length===0?{}:{motion:e.motion},...e.brand===void 0?{}:{brand:e.brand},...t===void 0?{}:{themes:t},root:r}}function Ce(e){let n=e?.dark;return n===void 0||Object.keys(n).length===0?void 0:{dark:n}}var Dn=["beat","bar"];var ss=/^(\d+(?:\.\d+)?)(beats?|bars?)$/;function De(e){let n=ss.exec(e);if(!n)return;let t=Number(n[1]);if(Number.isFinite(t))return{count:t,unit:n[2].startsWith("bar")?"bar":"beat"}}function Ve(e,n){return`${String(Math.round(e*1e6)/1e6)}${n}${e===1?"":"s"}`}function Le(e){return typeof e=="string"&&De(e)!==void 0}function ge(e){let n=e?.bpm;if(n===void 0)return;let t=e?.meter??4,r=6e4/n;return{bpm:n,meter:t,beat:r,bar:r*t}}function Qe(e,n,t){if(e===void 0)return t;if(typeof e=="number")return e;let r=De(e);return!r||!n?t:r.count*(r.unit==="bar"?n.bar:n.beat)}var en=36e5;var Vn=["cut","fade","push","slide"],Ln=["cut","fade","rise","drop","pop","wipe","grow","count","draw"],je=["cut","fade","rise","drop","pop"],jn=["pulse"],Bn=["out","in","inout","linear","spring"],Fn=["word","letter"],ye=["left","right","top","bottom"],xo=400,nn=1e4,Un=18e4,xe=7680;function Be(e){let n=e.trim();return n==="back"?{kind:"back"}:n==="next"?{kind:"next"}:le(n)}function tn(e){return e===void 0||e.enter===void 0&&e.duration===void 0&&e.scroll!==!0&&e.length===void 0&&e.w===void 0&&e.h===void 0&&e.bpm===void 0&&e.meter===void 0&&e.music===void 0&&e.lines.length===0}function Wn(e){return e.camera===!0||e.enter!==void 0||e.exit!==void 0||e.emphasis!==void 0||e.go!==void 0}var as=["camera","emphasis","from","by","stagger","hold","at","after","with","on","ease","pad"];function bo(e){return e===void 0?!1:e.length!==void 0||e.w!==void 0||e.h!==void 0||e.bpm!==void 0||e.meter!==void 0||e.music!==void 0?!0:e.lines.some(n=>as.some(t=>n[t]!==void 0)||n.enter!==void 0&&!je.includes(n.enter)||n.exit!==void 0&&!je.includes(n.exit))}function zn(e){let n=e.motion;if(!n)return[];let t=e.root.children.map(o=>o.id).filter(o=>o in n),r=Object.keys(n).filter(o=>!t.includes(o)).sort();return[...t,...r]}function Gn(e){return new Set(e.root.children.filter(n=>n.type==="frame"&&n.component!==!0).map(n=>n.id))}function Xn(e){let n=new Map;for(let t of e.root.children)t.type!=="frame"||t.component===!0||C(t,r=>{n.set(r.id,t.id)});return n}function cs(e){let n=new Set;return C(e,t=>{n.add(t.id)}),n}function rn(e,n){let t=e.motion;if(!t)return[];let r=[],o=Gn(e),i=Xn(e),s=cs(e.root),u=(a,c)=>{let d=n?.(a,c);return d===void 0?"":`Line ${d}: `};for(let a of zn(e)){let c=t[a];if(!c)continue;if(!o.has(a)){r.push({severity:"warning",code:"motion-not-a-page",message:`${u(a)}motion ${a}: ${a} is not a page (a top-level frame), so none of it plays`,nodeId:a});continue}let d=new Set;for(let f of c.lines){let l=u(a,f.id);for(let b of["after","with"]){let $=f[b];$!==void 0&&!d.has($)&&r.push({severity:"warning",code:"motion-anchor-missing",message:`${l}motion ${a}: ${b}=${$} names no line above, so it starts after the line above instead`,nodeId:f.id})}f.camera!==!0&&d.add(f.id);let p=s.has(f.id)?X(e.root,f.id):void 0;p&&r.push(...ds(f,p,l,a)),s.has(f.id)?i.get(f.id)!==a&&r.push({severity:"warning",code:"motion-wrong-page",message:`${l}motion ${a}: ${f.id} is not on ${a}, so Play skips it`,nodeId:f.id}):r.push({severity:"warning",code:"unknown-reference",message:`${l}motion ${a}: no node ${f.id}`,nodeId:f.id});let h=f.go===void 0?void 0:Be(f.go);h?.kind==="frame"&&!ps(e,h.id)&&r.push({severity:"warning",code:"unknown-reference",message:`${l}motion ${a}: go=#${h.id} names no frame`,nodeId:f.id})}}return r}function ds(e,n,t,r){let o=[],i=(u,a)=>{o.push({severity:"warning",code:u,message:`${t}motion ${r}: ${a}`,nodeId:n.id})};if(e.camera===!0)return o;let s=e.enter??e.exit;return s==="count"&&(n.type!=="text"||!/\d/.test(Jn(n.content)))&&i("count-no-number",`${n.id} has no number to count, so it fades in instead`),s==="draw"&&!ls(n)&&i("draw-no-stroke",`${n.id} has no stroked vector to draw, so it fades in instead`),e.by!==void 0&&n.type!=="text"?i("by-not-text",`by=${e.by} splits text, and ${n.id} is a ${n.type}`):e.by!==void 0&&n.type==="text"&&fs(n)&&i("by-rotated",`${n.id} is rotated, so by=${e.by} enters it whole`),e.stagger!==void 0&&e.by===void 0&&z(n).length===0&&i("stagger-no-children",`${n.id} has no children to stagger: split a text with by=word`),o}function fs(e){let n=e.rotation;return n!==void 0&&n!==0}function ls(e){let n=!1;return C(e,t=>((t.type==="vector"&&t.stroke!==void 0||t.type==="connector")&&(n=!0),n?!1:void 0)),n}function Jn(e){return typeof e=="string"?e:e.map(n=>typeof n=="string"?n:n.text).join("")}function ps(e,n){let t=!1;return C(e.root,r=>{if(t)return!1;r.id===n&&(t=r.type==="frame")}),t}function y(e){if(!Number.isFinite(e))return"0";let n=Math.round(e*1e4)/1e4,t=Object.is(n,-0)?0:n;return Math.abs(t)>=1e21?t.toFixed(0):String(t)}var hs={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0};function on(e){let n=[],t,r=0,o=0,i=0,s=0,u,a,c=ms(e),d=()=>(t||(t={anchors:[{x:r,y:o}],closed:!1},n.push(t)),t.anchors[t.anchors.length-1]),f=(b,$)=>{d(),t?.anchors.push({x:b,y:$}),r=b,o=$},l=(b,$,S,N)=>{d().out=b,t?.anchors.push({x:S,y:N,in:$}),r=S,o=N},p="",h=!0;for(;c.more();){let b=c.command();if(b!==void 0)p=b,h=!0;else if(p===""||p.toUpperCase()==="Z")return{contours:Kn(n),error:`Expected a command at ${c.at()}`};let $=p.toUpperCase(),S=p!==$,N=hs[$];if(N===void 0)return{contours:Kn(n),error:`Unknown command ${p}`};if($==="Z"){t&&(t.closed=!0),t=void 0,r=i,o=s,u=void 0,a=void 0,p="";continue}let T=$==="A"?c.arc():c.numbers(N);if(T===void 0)return{contours:Kn(n),error:`${p} expects ${N} numbers at ${c.at()}`};let A=S?r:0,_=S?o:0,O=g=>T[g];switch($){case"M":h&&(t={anchors:[{x:A+O(0),y:_+O(1)}],closed:!1},n.push(t),r=i=A+O(0),o=s=_+O(1),p=S?"l":"L"),u=a=void 0;break;case"L":f(A+O(0),_+O(1)),u=a=void 0;break;case"H":f(A+O(0),o),u=a=void 0;break;case"V":f(r,_+O(0)),u=a=void 0;break;case"C":{let g={x:A+O(2),y:_+O(3)};l({x:A+O(0),y:_+O(1)},g,A+O(4),_+O(5)),u=g,a=void 0;break}case"S":{let g=u?{x:2*r-u.x,y:2*o-u.y}:{x:r,y:o},m={x:A+O(0),y:_+O(1)};l(g,m,A+O(2),_+O(3)),u=m,a=void 0;break}case"Q":case"T":{let g=$==="Q"?{x:A+O(0),y:_+O(1)}:a?{x:2*r-a.x,y:2*o-a.y}:{x:r,y:o},m=$==="Q"?A+O(2):A+O(0),w=$==="Q"?_+O(3):_+O(1),x={x:r+2/3*(g.x-r),y:o+2/3*(g.y-o)},E={x:m+2/3*(g.x-m),y:w+2/3*(g.y-w)};l(x,E,m,w),a=g,u=void 0;break}case"A":{let g=A+O(5),m=_+O(6);for(let[w,x,E]of gs(r,o,O(0),O(1),O(2),O(3)!==0,O(4)!==0,g,m))l(w,x,E.x,E.y);(r!==g||o!==m)&&f(g,m),u=a=void 0;break}}h=!1}return{contours:Kn(n)}}function Kn(e){return e.map(n=>{let t=[...n.anchors];if(n.closed&&t.length>1){let r=t[0],o=t[t.length-1];be(r,o)&&(t.pop(),t[0]={...r,...o.in?{in:o.in}:{}})}return{anchors:t.map(ko),closed:n.closed}})}function Gt(e,n,t){return ko({x:e.x,y:e.y,...n?{in:n}:{},...t?{out:t}:{}})}function ko(e){let n={x:e.x,y:e.y};return e.in&&!be(e.in,e)&&(n.in=e.in),e.out&&!be(e.out,e)&&(n.out=e.out),n}function be(e,n,t=1e-6){return Math.abs(e.x-n.x)<t&&Math.abs(e.y-n.y)<t}function ms(e){let n=0,t=()=>{for(;n<e.length&&/[\s,]/.test(e[n]);)n+=1},r=()=>{t();let i=/^[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/.exec(e.slice(n));if(i)return n+=i[0].length,Number(i[0])},o=()=>{t();let i=e[n];if(!(i!=="0"&&i!=="1"))return n+=1,Number(i)};return{more(){return t(),n<e.length},command(){t();let i=e[n];if(/[a-zA-Z]/.test(i))return n+=1,i},numbers(i){let s=[];for(let u=0;u<i;u+=1){let a=r();if(a===void 0)return;s.push(a)}return s},arc(){let i=this.numbers(3),s=o(),u=o(),a=this.numbers(2);if(!(!i||s===void 0||u===void 0||!a))return[...i,s,u,...a]},at(){return n}}}function gs(e,n,t,r,o,i,s,u,a){let c=Math.abs(t),d=Math.abs(r);if(c===0||d===0||e===u&&n===a)return[];let f=o*Math.PI/180,l=Math.cos(f),p=Math.sin(f),h=(e-u)/2,b=(n-a)/2,$=l*h+p*b,S=-p*h+l*b,N=$*$/(c*c)+S*S/(d*d);N>1&&(c*=Math.sqrt(N),d*=Math.sqrt(N));let T=c*c*d*d-c*c*S*S-d*d*$*$,A=c*c*S*S+d*d*$*$,_=(i===s?-1:1)*Math.sqrt(Math.max(0,T/A)),O=_*c*S/d,g=-_*d*$/c,m=l*O-p*g+(e+u)/2,w=p*O+l*g+(n+a)/2,x=(P,Z,Oe,Me)=>{let Je=P*Oe+Z*Me,xn=Math.hypot(P,Z)*Math.hypot(Oe,Me),Ke=Math.acos(Math.min(1,Math.max(-1,Je/xn)));return P*Me-Z*Oe<0?-Ke:Ke},E=x(1,0,($-O)/c,(S-g)/d),k=x(($-O)/c,(S-g)/d,(-$-O)/c,(-S-g)/d);!s&&k>0&&(k-=2*Math.PI),s&&k<0&&(k+=2*Math.PI);let M=Math.max(1,Math.ceil(Math.abs(k)/(Math.PI/2)-1e-9)),R=k/M,V=4/3*Math.tan(R/4),I=P=>({x:m+c*Math.cos(P)*l-d*Math.sin(P)*p,y:w+c*Math.cos(P)*p+d*Math.sin(P)*l}),W=P=>({x:-c*Math.sin(P)*l-d*Math.cos(P)*p,y:-c*Math.sin(P)*p+d*Math.cos(P)*l}),de=[];for(let P=0;P<M;P+=1){let Z=E+P*R,Oe=Z+R,Me=I(Z),Je=P===M-1?{x:u,y:a}:I(Oe),xn=W(Z),Ke=W(Oe);de.push([{x:Me.x+V*xn.x,y:Me.y+V*xn.y},{x:Je.x-V*Ke.x,y:Je.y-V*Ke.y},Je])}return de}function q(e){let n=[],t=r=>`${y(r.x)} ${y(r.y)}`;for(let r of e){let{anchors:o}=r,i=o[0];if(!i)continue;n.push(`M${t(i)}`);let s=$e(r);for(let u=0;u<s;u+=1){let a=o[u],c=o[(u+1)%o.length],d=r.closed&&u===o.length-1;!a.out&&!c.in?d||n.push(`L${t(c)}`):n.push(`C${t(a.out??a)} ${t(c.in??c)} ${t(c)}`)}r.closed&&n.push("Z")}return n.join(" ")}function $e(e){let n=e.anchors.length;return n<2?0:e.closed?n:n-1}function Ue(e,n){let t=e.anchors[n],r=e.anchors[(n+1)%e.anchors.length];return[{x:t.x,y:t.y},t.out??{x:t.x,y:t.y},r.in??{x:r.x,y:r.y},{x:r.x,y:r.y}]}function Xt(e,n){let[t,r,o,i]=e,s=1-n,u=s*s*s,a=3*s*s*n,c=3*s*n*n,d=n*n*n;return{x:u*t.x+a*r.x+c*o.x+d*i.x,y:u*t.y+a*r.y+c*o.y+d*i.y}}function J(e,n){return e.map(t=>({closed:t.closed,anchors:t.anchors.map(r=>{let o=n(r);return{x:o.x,y:o.y,...r.in?{in:n(r.in)}:{},...r.out?{out:n(r.out)}:{}}})}))}function We(e){let n=1/0,t=1/0,r=-1/0,o=-1/0,i=s=>{n=Math.min(n,s.x),t=Math.min(t,s.y),r=Math.max(r,s.x),o=Math.max(o,s.y)};for(let s of e){for(let a of s.anchors)i(a);let u=$e(s);for(let a=0;a<u;a+=1){let c=Ue(s,a);for(let d of ys(c))i(Xt(c,d))}}if(n!==1/0)return{x:n,y:t,w:r-n,h:o-t}}function ys(e){let[n,t,r,o]=e,i=[];for(let s of["x","y"]){let u=-n[s]+3*t[s]-3*r[s]+o[s],a=2*(n[s]-2*t[s]+r[s]),c=t[s]-n[s];if(Math.abs(u)<1e-12){Math.abs(a)>1e-12&&i.push(-c/a);continue}let d=a*a-4*u*c;if(d<0)continue;let f=Math.sqrt(d);i.push((-a+f)/(2*u),(-a-f)/(2*u))}return i.filter(s=>s>0&&s<1)}function Hn(e){if(e===void 0)return;let n=e.trim().split(/[\s,]+/).map(Number);if(n.length!==4||n.some(s=>!Number.isFinite(s)))return;let[t,r,o,i]=n;return{x:t,y:r,w:o,h:i}}function sn(e,n,t){return Hn(e)??{x:0,y:0,w:n,h:t}}function un(e,n){let t=e.w===0?1:n.w/e.w,r=e.h===0?1:n.h/e.h;return o=>({x:n.x+(o.x-e.x)*t,y:n.y+(o.y-e.y)*r})}function an(e,n=.5){let[t,r,o,i]=e;if(be(t,r)&&be(o,i))return[t,i];let u=Math.hypot(r.x-t.x,r.y-t.y)+Math.hypot(o.x-r.x,o.y-r.y)+Math.hypot(i.x-o.x,i.y-o.y),a=Math.min(256,Math.max(4,Math.ceil(Math.sqrt(u/n)))),c=[];for(let d=0;d<=a;d+=1)c.push(Xt(e,d/a));return c}function Jt(e){let n=0;for(let t of e)for(let r=0;r<$e(t);r+=1){let o=an(Ue(t,r),.25);for(let i=1;i<o.length;i+=1){let s=o[i-1],u=o[i];n+=Math.hypot(u.x-s.x,u.y-s.y)}}return n}function xs(e,n,t){let r=0,o=0;for(let i of e){let s=bs(i);if(s.length!==0){if(t.reach>0){let u=i.closed?s.length:s.length-1;for(let a=0;a<u;a+=1){let c=s[a],d=s[(a+1)%s.length];if($s(n,c,d)<=t.reach)return!0}if(s.length===1&&Math.hypot(n.x-s[0].x,n.y-s[0].y)<=t.reach)return!0}if(t.fill)for(let u=0;u<s.length;u+=1){let a=s[u],c=s[(u+1)%s.length];a.y<=n.y!=c.y<=n.y&&a.x+(n.y-a.y)/(c.y-a.y)*(c.x-a.x)>n.x&&(o+=1,r+=c.y>a.y?1:-1)}}}return t.fill?t.rule==="evenodd"?o%2===1:r!==0:!1}function bs(e){let n=e.anchors[0];if(!n)return[];let t=[{x:n.x,y:n.y}],r=$e(e);for(let o=0;o<r;o+=1)t.push(...an(Ue(e,o)).slice(1));return e.closed&&t.length>1&&t.pop(),t}function $s(e,n,t){let r=t.x-n.x,o=t.y-n.y,i=r*r+o*o,s=i===0?0:Math.max(0,Math.min(1,((e.x-n.x)*r+(e.y-n.y)*o)/i));return Math.hypot(e.x-(n.x+s*r),e.y-(n.y+s*o))}var Fe=.5522847498;function we(e,n,t=0){let r=wn(typeof t=="number"?{tl:Math.max(0,t),tr:Math.max(0,t),br:Math.max(0,t),bl:Math.max(0,t)}:t,e,n),o=[],i=(u,a,c,d)=>{if(u<=0){o.push({x:a.x,y:a.y});return}let f=Fe*u,l={x:a.x+c.x*u,y:a.y+c.y*u},p={x:a.x+d.x*u,y:a.y+d.y*u};o.push({x:l.x,y:l.y,out:{x:l.x-c.x*f,y:l.y-c.y*f}}),o.push({x:p.x,y:p.y,in:{x:p.x-d.x*f,y:p.y-d.y*f}})};i(r.tl,{x:0,y:0},{x:0,y:1},{x:1,y:0}),i(r.tr,{x:e,y:0},{x:-1,y:0},{x:0,y:1}),i(r.br,{x:e,y:n},{x:0,y:-1},{x:-1,y:0}),i(r.bl,{x:0,y:n},{x:1,y:0},{x:0,y:-1});let s=r.tl>0?o.slice(1).concat(o.slice(0,1)):o;return[{closed:!0,anchors:ws(s)}]}function cn(e,n){let t=e/2,r=n/2,o=Fe*t,i=Fe*r;return[{closed:!0,anchors:[{x:t,y:0,in:{x:t-o,y:0},out:{x:t+o,y:0}},{x:e,y:r,in:{x:e,y:r-i},out:{x:e,y:r+i}},{x:t,y:n,in:{x:t+o,y:n},out:{x:t-o,y:n}},{x:0,y:r,in:{x:0,y:r+i},out:{x:0,y:r-i}}]}]}function ws(e){let n=[];for(let o of e){let i=n[n.length-1];if(i&&be(i,o)&&!i.out&&!o.in){n[n.length-1]=Gt(i,i.in,o.out);continue}n.push(o)}let t=n[0],r=n[n.length-1];return n.length>1&&t&&r&&be(t,r)&&!r.out&&!t.in&&(n[0]=Gt(t,r.in,t.out),n.pop()),n}var Yn=["straight","elbow","curve"],qn=["none","arrow","triangle","dot","bar"];var Ht="#1F2937",Yt=2;function qt(e){return{x:Math.min(e.x1,e.x2),y:Math.min(e.y1,e.y2),w:Math.abs(e.x2-e.x1),h:Math.abs(e.y2-e.y1)}}function vo(e){return Math.abs(e.x2-e.x1)>=Math.abs(e.y2-e.y1)?"x":"y"}function So(e,n){let t=vo(e);return{start:n.start??t,end:n.end??t}}function Eo(e,n,t={}){let{x1:r,y1:o,x2:i,y2:s}=e,u=(r+i)/2,a=(o+s)/2,c=So(e,t);switch(n){case"straight":return{closed:!1,anchors:[{x:r,y:o},{x:i,y:s}]};case"elbow":{let d=c.start==="x"?c.end==="x"?[{x:u,y:o},{x:u,y:s}]:[{x:i,y:o}]:c.end==="y"?[{x:r,y:a},{x:i,y:a}]:[{x:r,y:s}];return{closed:!1,anchors:[{x:r,y:o},...d,{x:i,y:s}]}}case"curve":{let d=c.start!==c.end,f=c.start==="x"?{x:d?i:u,y:o}:{x:r,y:d?s:a},l=c.end==="x"?{x:d?r:u,y:s}:{x:i,y:d?o:a};return{closed:!1,anchors:[{x:r,y:o,out:f},{x:i,y:s,in:l}]}}}}function Oo(e,n,t={}){let r=e.x2-e.x1,o=e.y2-e.y1;if(r===0&&o===0)return;if(n==="straight"||r===0||o===0){let a=Math.hypot(r,o),c={x:r/a,y:o/a};return{start:{x:-c.x,y:-c.y},end:c}}let i=So(e,t),s=a=>a==="x"?{x:Math.sign(r),y:0}:{x:0,y:Math.sign(o)},u=s(i.start);return{start:{x:-u.x,y:-u.y},end:s(i.end)}}function Zn(e){return 3*Math.max(0,e)+4}function Kt(e,n,t,r){let o=Zn(r),i=o/2,s={x:-t.x,y:-t.y},u={x:-t.y,y:t.x},a=(c,d)=>({x:n.x+s.x*c+u.x*d,y:n.y+s.y*c+u.y*d});switch(e){case"none":return;case"triangle":return{filled:!0,inset:i,contours:[{closed:!0,anchors:[a(0,0),a(o,i),a(o,-i)]}]};case"arrow":return{filled:!1,inset:r/2,contours:[{closed:!1,anchors:[a(o,i),a(0,0),a(o,-i)]}]};case"bar":return{filled:!1,inset:0,contours:[{closed:!1,anchors:[a(0,i),a(0,-i)]}]};case"dot":return{filled:!0,inset:0,contours:[ks(n,o*.4)]}}}function ks(e,n){let t=n*Fe,{x:r,y:o}=e;return{closed:!0,anchors:[{x:r+n,y:o,in:{x:r+n,y:o-t},out:{x:r+n,y:o+t}},{x:r,y:o+n,in:{x:r+t,y:o+n},out:{x:r-t,y:o+n}},{x:r-n,y:o,in:{x:r-n,y:o+t},out:{x:r-n,y:o-t}},{x:r,y:o-n,in:{x:r-t,y:o-n},out:{x:r+t,y:o-n}}]}}function Zt(e,n,t,r,o,i={}){let s=Eo(e,n,i),u=Oo(e,n,i);if(!u)return{route:s,filled:[],lined:[]};let a=[Kt(t,{x:e.x1,y:e.y1},u.start,o),Kt(r,{x:e.x2,y:e.y2},u.end,o)],c=vs(s,u,a[0]?.inset??0,a[1]?.inset??0),d=[],f=[];for(let l of a)l&&(l.filled?d:f).push(...l.contours);return{route:c,filled:d,lined:f}}function vs(e,n,t,r){if(t===0&&r===0)return e;let o=[...e.anchors],i=(s,u,a,c)=>{let d=o[s],f=o[u];if(!d||!f||a<=0)return;let l=Math.hypot(f.x-d.x,f.y-d.y),p=o.length===2?Math.min(a,l/2):Math.min(a,l),h=-c.x*p,b=-c.y*p,$=A=>A===void 0?void 0:{x:A.x+h,y:A.y+b},S={x:d.x+h,y:d.y+b},N=$(d.in),T=$(d.out);o[s]={...S,...N===void 0?{}:{in:N},...T===void 0?{}:{out:T}}};return i(0,1,t,n.start),i(o.length-1,o.length-2,r,n.end),{...e,anchors:o}}var Qn=["center","inside","outside"];function dn(e){let n=e.trim();if(n===""||n==="none"||n==="solid")return{error:"a solid line has no dash \u2014 unset dash rather than writing one"};let t=n.split(/[\s,]+/),r=[];for(let o of t){if(!/^\d*\.?\d+$/.test(o)){let i=/^(\d*\.?\d+)[a-z%]+$/i.exec(o);return i?{error:`lengths have no unit \u2014 write ${i[1]} for ${o}`}:/^-/.test(o)?{error:`a dash length cannot be negative, got ${o}`}:{error:`expected lengths like "6 4", got ${JSON.stringify(e)}`}}r.push(Number(y(Number(o))))}return r.some(o=>o>0)?{dash:r}:{error:"a dash needs one length above zero \u2014 unset dash for a solid line"}}function et(e){return e.map(n=>y(n)).join(" ")}function Qt(e){if(e===void 0)return[];let n=dn(e);return"error"in n?[]:n.dash.length%2===1?[...n.dash,...n.dash]:n.dash}var nt={canvas:[["name","string"],["w","numberValue"],["h","numberValue"],["background","stringValue"]],frame:[["name","string"],["x","numberValue"],["y","numberValue"],["w","numberValue"],["h","numberValue"],["background","stringValue"],["stroke","stringValue"],["strokeWidth","numberValue"],["dash","dash"],["strokeAlign","strokeAlign"],["cap","lineCap"],["radius","numberValue"],["radiusTL","numberValue"],["radiusTR","numberValue"],["radiusBR","numberValue"],["radiusBL","numberValue"],["clip","boolean"],["skip","boolean"],["component","boolean"],["blend","blendMode"],["shadow","stringValue"],["blur","numberValue"],["backdrop","numberValue"],["hidden","boolean"],["locked","boolean"]],connector:[["name","string"],["x1","numberValue"],["y1","numberValue"],["x2","numberValue"],["y2","numberValue"],["route","route"],["start","connectorEnd"],["end","connectorEnd"],["stroke","stringValue"],["strokeWidth","numberValue"],["dash","dash"],["cap","lineCap"],["opacity","numberValue"],["blend","blendMode"],["shadow","stringValue"],["blur","numberValue"],["hidden","boolean"],["locked","boolean"]],group:[["name","string"],["hidden","boolean"],["locked","boolean"]],instance:[["name","string"],["component","string"],["x","numberValue"],["y","numberValue"],["w","numberValue"],["h","numberValue"],["hidden","boolean"],["locked","boolean"]],ellipse:[["name","string"],["x","numberValue"],["y","numberValue"],["w","numberValue"],["h","numberValue"],["rotation","numberValue"],["fill","stringValue"],["stroke","stringValue"],["strokeWidth","numberValue"],["dash","dash"],["strokeAlign","strokeAlign"],["cap","lineCap"],["opacity","numberValue"],["blend","blendMode"],["shadow","stringValue"],["blur","numberValue"],["backdrop","numberValue"],["hidden","boolean"],["locked","boolean"]],vector:[["name","string"],["x","numberValue"],["y","numberValue"],["w","numberValue"],["h","numberValue"],["rotation","numberValue"],["view","string"],["d","string"],["fill","stringValue"],["stroke","stringValue"],["strokeWidth","numberValue"],["dash","dash"],["strokeAlign","strokeAlign"],["opacity","numberValue"],["rule","fillRule"],["cap","lineCap"],["join","lineJoin"],["blend","blendMode"],["shadow","stringValue"],["blur","numberValue"],["backdrop","numberValue"],["hidden","boolean"],["locked","boolean"]],video:[["name","string"],["x","numberValue"],["y","numberValue"],["w","numberValue"],["h","numberValue"],["rotation","numberValue"],["src","stringValue"],["fit","imageFit"],["start","number"],["end","number"],["poster","number"],["muted","boolean"],["loop","boolean"],["mask","string"],["stroke","stringValue"],["strokeWidth","numberValue"],["dash","dash"],["strokeAlign","strokeAlign"],["cap","lineCap"],["radius","numberValue"],["radiusTL","numberValue"],["radiusTR","numberValue"],["radiusBR","numberValue"],["radiusBL","numberValue"],["opacity","numberValue"],["blend","blendMode"],["shadow","stringValue"],["blur","numberValue"],["hidden","boolean"],["locked","boolean"]],rect:[["name","string"],["x","numberValue"],["y","numberValue"],["w","numberValue"],["h","numberValue"],["rotation","numberValue"],["fill","stringValue"],["stroke","stringValue"],["strokeWidth","numberValue"],["dash","dash"],["strokeAlign","strokeAlign"],["cap","lineCap"],["radius","numberValue"],["radiusTL","numberValue"],["radiusTR","numberValue"],["radiusBR","numberValue"],["radiusBL","numberValue"],["opacity","numberValue"],["blend","blendMode"],["shadow","stringValue"],["blur","numberValue"],["backdrop","numberValue"],["hidden","boolean"],["locked","boolean"]],image:[["name","string"],["x","numberValue"],["y","numberValue"],["w","numberValue"],["h","numberValue"],["rotation","numberValue"],["src","stringValue"],["fit","imageFit"],["mask","string"],["stroke","stringValue"],["strokeWidth","numberValue"],["dash","dash"],["strokeAlign","strokeAlign"],["cap","lineCap"],["radius","numberValue"],["radiusTL","numberValue"],["radiusTR","numberValue"],["radiusBR","numberValue"],["radiusBL","numberValue"],["opacity","numberValue"],["blend","blendMode"],["shadow","stringValue"],["blur","numberValue"],["hidden","boolean"],["locked","boolean"]],text:[["name","string"],["x","numberValue"],["y","numberValue"],["w","numberValue"],["h","numberValue"],["rotation","numberValue"],["font","stringValue"],["size","numberValue"],["weight","numberValue"],["lineHeight","numberValue"],["letterSpacing","numberValue"],["align","align"],["valign","valign"],["italic","boolean"],["fill","stringValue"],["stroke","stringValue"],["strokeWidth","numberValue"],["dash","dash"],["opacity","numberValue"],["blend","blendMode"],["shadow","stringValue"],["blur","numberValue"],["hidden","boolean"],["locked","boolean"]]},tt=[["font","string"],["size","number"],["weight","number"],["italic","boolean"],["underline","boolean"],["strike","boolean"],["fill","string"],["letterSpacing","number"],["link","string"]];var rt=[["enter","pageEffect"],["duration","number"],["scroll","boolean"],["length","time"],["w","number"],["h","number"],["bpm","number"],["meter","number"]],fn=[["enter","nodeEffect"],["exit","nodeEffect"],["emphasis","emphasisEffect"],["from","from"],["by","piece"],["stagger","time"],["duration","time"],["hold","time"],["delay","time"],["at","time"],["after","string"],["with","string"],["step","boolean"],["together","boolean"],["on","on"],["ease","ease"],["pad","number"],["go","string"]],ot=[["from","number"],["volume","number"],["fadein","time"],["fadeout","time"],["loop","boolean"]],er=Object.keys(nt);function it(e){return er.includes(e)}function ln(e,n){return nt[e].find(([t])=>t===n)?.[1]}function nr(e){for(let n of er){if(n==="canvas"||n==="instance")continue;let t=ln(n,e);if(t!==void 0)return t}}var tr="override";function L(e,n){if(n==="boolean")return e===""||e==="true"?{value:!0}:e==="false"?{value:!1}:{error:`Expected true or false, got ${e}`};if(e.startsWith('"')){let r=Q(e);return r===void 0?{error:`Malformed quoted string ${e}`}:Mo(r,n,e)}if(Ps(e)){if(!_s(n))return{error:Is(e,n)};let r=_o(e).trim();return r===""?{error:"Empty expression"}:{value:pe(r)}}return n==="numberValue"&&Ao.test(e)?{value:pe(e)}:Mo(e,n,e)}var Ao=/^-?\d+(?:\.\d+)?%$/;function _s(e){return e==="numberValue"||e==="stringValue"}function Is(e,n){return n==="number"?`Expected a plain number, not an expression, got ${e}`:n==="string"&&/^\$\w+$/.test(e)?`Expected a literal, got ${e} \u2014 name a token without the $: ${e.slice(1)}`:`Expected a literal, not an expression, got ${e} \u2014 quote it if you meant the text`}function No(e,n){let t=/^(-?\d+(?:\.\d+)?)([A-Za-z]+)$/.exec(e);return t?/^(?:beats?|bars?)$/.test(t[2])?" \u2014 beats and bars count motion times on a page with bpm=; this is milliseconds":t[2]==="s"&&n==="number"?` \u2014 durations are milliseconds: ${Number(t[1])*1e3}`:/^(?:px|pt|deg|ms)$/.test(t[2])?` \u2014 drop the unit: ${t[1]}`:" \u2014 units are not supported: use a number, a percentage like (100%), or an expression":n==="number"?Ao.test(e)?" \u2014 a percentage is not allowed here":"":/^-[$@(]/.test(e)?` \u2014 wrap an expression in parentheses: (${e})`:/^-?[A-Za-z_]\w*(?:\.\w+)+$/.test(e)?` \u2014 wrap an expression in parentheses: (${e})`:""}function Mo(e,n,t){switch(n){case"numberValue":case"number":{let r=Number(e);return Number.isFinite(r)&&e.trim()!==""?{value:r}:{error:`Expected a number, got ${t}${No(e,n)}`}}case"align":return He.includes(e)?{value:e}:{error:`Expected one of ${He.join(", ")}, got ${t}`};case"valign":return Ye.includes(e)?{value:e}:{error:`Expected one of ${Ye.join(", ")}, got ${t}`};case"fontStyle":return e==="normal"||e==="italic"?{value:e}:{error:`Expected normal or italic, got ${t}`};case"imageFit":return fe.includes(e)?{value:e}:{error:`Expected one of ${fe.join(", ")}, got ${t}`};case"fillRule":return K(vn,e,t);case"lineCap":return K(Sn,e,t);case"lineJoin":return K(En,e,t);case"dash":{let r=dn(e);return"error"in r?{error:r.error}:{value:et(r.dash)}}case"strokeAlign":return K(Qn,e,t);case"blendMode":return K(kn,e,t);case"route":return K(Yn,e,t);case"connectorEnd":return K(qn,e,t);case"pageEffect":return K(Vn,e,t);case"nodeEffect":return K(Ln,e,t);case"emphasisEffect":return K(jn,e,t);case"ease":return K(Bn,e,t);case"piece":return K(Fn,e,t);case"time":{let r=De(e);if(r)return{value:Ve(r.count,r.unit)};let o=Number(e);return Number.isFinite(o)&&e.trim()!==""?{value:o}:{error:`Expected milliseconds or beats, got ${t}${Rs(e)}`}}case"on":return Dn.includes(e)?{value:e}:e==="downbeat"?{error:`Expected beat or bar, got ${t} \u2014 write on=bar: a bar starts on its downbeat`}:e==="beats"||e==="bars"?{error:`Expected beat or bar, got ${t} \u2014 write on=${e.slice(0,-1)}`}:{error:`Expected beat or bar, got ${t}`};case"from":{if(ye.includes(e))return{value:e};let r=Number(e);return Number.isFinite(r)&&e.trim()!==""?{value:r}:{error:`Expected a number or one of ${ye.join(", ")}, got ${t}`}}default:return{value:e}}}function Rs(e){let n=/^(beat|bar|b)[:\s#]?(\d+(?:\.\d+)?)$/.exec(e);if(n){let r=n[1]==="bar"?"bar":"beat",o=Number(n[2]);return` \u2014 write ${Ve(Math.max(0,o-1),r)} (counted from the start: ${r} ${o}'s ${r==="bar"?"downbeat":"start"})`}let t=/^(\d+(?:\.\d+)?)\s*(b|bt|beat|bars?|beats?)$/.exec(e);if(t){let r=t[2]?.startsWith("bar")?"bar":"beat";return` \u2014 write ${Ve(Number(t[1]),r)} (counted from the start)`}return No(e,"number")}function K(e,n,t){return e.includes(n)?{value:n}:{error:`Expected one of ${e.join(", ")}, got ${t}`}}function Ps(e){return/^[$@(]/.test(e)}function st(e,n){if(e!=="radius")return;let t=Ct(n);if(t===void 0)return;if("error"in t)return t;let r=[];for(let[o,i]of t.corners){let s=L(i,"numberValue");if("error"in s)return s;r.push([o,s.value])}return{cells:r}}function Q(e){try{let n=JSON.parse(e);return typeof n=="string"?n:void 0}catch{return}}function _o(e){if(!e.startsWith("("))return e;let n=0;for(let t=0;t<e.length;t+=1){let r=e[t];if(r==="(")n+=1;else if(r===")"&&(n-=1,n===0))return t===e.length-1?e.slice(1,-1):e}return e}function Io(e){let n=[],t="",r=0,o=!1;for(let i=0;i<e.length;i+=1){let s=e[i];if(o){t+=s,s==="\\"?(t+=e[i+1]??"",i+=1):s==='"'&&(o=!1);continue}if(s==='"'){o=!0,t+=s;continue}if(s==="("?r+=1:s===")"&&(r=Math.max(0,r-1)),r===0&&/\s/.test(s)){t!==""&&n.push(t),t="";continue}t+=s}return t!==""&&n.push(t),n}function ut(e,n,t){let r=t===void 0?void 0:j(t);if(r?.value===void 0||!To(e[n]??""))return;let o=n;for(;o<e.length&&To(e[o]??"");)o+=1;let i=[_o(r.value),...e.slice(n,o)].join(" ");return r.key==="dash"&&i.split(" ").every(s=>/^\d*\.?\d+$/.test(s))?{end:o,message:`dash: quote a pattern of several lengths \u2014 write dash="${i}"`}:r.key==="radius"&&i.split(" ").every(s=>/^-?\d+(?:\.\d+)?$/.test(s))?{end:o,message:`radius: quote the four-corner shorthand \u2014 write radius="${i}"`}:{end:o,message:`${r.key}: an expression with spaces needs parentheses \u2014 write ${r.key}=(${i})`}}function To(e){return!e.includes("=")&&/^(?:[-+*/]|-?\d+(?:\.\d+)?%?|[$@][\w.]*|[A-Za-z_]\w*(?:\.\w+)+|\(.*|.*\))$/.test(e)}function j(e){let n=e.indexOf("=");return n===-1?{key:e,value:void 0}:{key:e.slice(0,n),value:e.slice(n+1)}}function rr(e,n){let t,r=0,o,i=[],s=[],u={},a={},c={},d={},f=[],l=!1,p=!1,h,b=(m,w,x)=>{n.push({severity:"warning",code:w,message:`Line ${m}: ${x}`})},$=(m,w,x)=>{e(m.number,"invalid-brand",`${w} ${x} is written twice \u2014 keep one`)},S=m=>{if(t){e(m.number,"invalid-brand",`A document has one brand line; the first is on line ${r}`);return}let w=m.words[1]===void 0?void 0:Lt(m.words[1]);if(!w){e(m.number,"invalid-brand","Expected brand <slug>@<version>, e.g. brand ember@3 \u2014 a slug is lower case, digits and dashes");return}let x=m.words.slice(2).includes("strict"),E=ne({...m,words:m.words.filter((M,R)=>R<2||M!=="strict")},2,["id","theme"],e),k=E.theme;k!==void 0&&!Dt.includes(k)&&e(m.number,"invalid-brand",`theme= is light or dark, got ${k}`),t={...w,...E.id===void 0?{}:{id:E.id},...k==="dark"||k==="light"?{theme:k}:{},...x?{strict:!0}:{}},r=m.number,h={kind:"brand"}},N=m=>{let w=m.words[0];if(w==="summary"){let x=at(m,1);x===void 0?e(m.number,"invalid-brand",'Expected summary "\u2026"'):o=x;return}if(w==="change"){let x=Number(m.words[1]),E=m.words[2]===void 0?void 0:Do(m.words[2]);if(!Number.isSafeInteger(x)||x<1||E===void 0){e(m.number,"invalid-brand",'Expected change <version> "<what changed>" at=<date>');return}let k=ne(m,3,["at"],e);i.push({version:x,note:E,...k.at===void 0?{}:{at:k.at}});return}if(w==="source"){let x=m.words[1];if(x===void 0||x.includes("=")){e(m.number,"invalid-brand","Expected source <kind> key=value\u2026, e.g. source site url=\u2026");return}s.push({kind:x,props:ne(m,2,void 0,e)});return}if(w==="rule"){_(m);return}if(w==="banned"){let x=at(m,1);if(x===void 0){e(m.number,"invalid-brand",'Expected banned "\u2026"');return}(d.voice??={entries:[]}).entries.push({kind:"banned",text:x});return}e(m.number,"invalid-brand",`"${w}" is not a line of the brand block \u2014 it holds summary, change and source, and in a design rule and banned`)},T=m=>{let w=m.words[1];if(w===void 0||w.includes("=")){e(m.number,"invalid-role","Expected role <name> light=<token or colour> dark=\u2026");return}let x=ne(m,2,["light","dark"],e),E=x.light;if(E===void 0){e(m.number,"invalid-role",`role ${w} needs light=`);return}if(Object.prototype.hasOwnProperty.call(u,w))return $(m,"role",w);let k=x.dark;u[w]={light:Ro(E),...k===void 0?{}:{dark:Ro(k)}}},A=m=>{let w=m.words[1];if(w===void 0||w.includes("=")){e(m.number,"invalid-logo","Expected logo <id> asset=<name> min=<px> clear=<fraction>");return}let x=ne(m,2,["asset","min","clear"],e),E=x.asset;if(E===void 0){e(m.number,"invalid-logo",`logo ${w} needs asset=`);return}let k={asset:E};for(let M of["min","clear"]){let R=x[M];if(R===void 0)continue;let V=Number(R);if(!Number.isFinite(V)||V<0){e(m.number,"invalid-logo",`logo ${w}: ${M} must be a number, got ${R}`);continue}k[M]=V}if(Object.prototype.hasOwnProperty.call(a,w))return $(m,"logo",w);a[w]=k},_=m=>{let w=m.words[1],x=m.words[2],E=m.words[3],k=E?.startsWith('"')===!0?Q(E):void 0;if(w===void 0||w.includes("=")){e(m.number,"invalid-rule",'Expected rule <id> must|should "<what it asks>" check=\u2026');return}if(x===void 0||!Vt.includes(x)){e(m.number,"invalid-rule",`rule ${w}: the second word is must or should`);return}if(k===void 0){e(m.number,"invalid-rule",`rule ${w} needs its words, quoted: rule ${w} ${x} "\u2026"`);return}let{check:M,...R}=ne(m,4,void 0,e);if(M!==void 0&&!Tn.includes(M)&&b(m.number,"unknown-check",`rule ${w}: this build has no check "${M}", so it is kept as words only \u2014 the checks are ${Tn.join(", ")}`),Object.prototype.hasOwnProperty.call(c,w))return $(m,"rule",w);c[w]={level:x,text:k,...M===void 0?{}:{check:M},...Object.keys(R).length===0?{}:{params:R}}},O=(m,w)=>{let x=m.words[0];if(x.startsWith('"')){let E=at(m,0);E===void 0?e(m.number,"invalid-guide",`Could not read ${m.text}`):w.push({kind:"line",text:E});return}if(x==="banned"||x==="avoid"){let E=at(m,1);E===void 0?e(m.number,"invalid-guide",`Expected ${x} "\u2026"`):w.push({kind:x,text:E});return}if(x==="rewrite"){let E=ne(m,1,["from","to"],e),k=E.from,M=E.to;if(k===void 0||M===void 0){e(m.number,"invalid-guide",'Expected rewrite from="\u2026" to="\u2026"');return}w.push({kind:"rewrite",from:k,to:M});return}if(x==="ref"||x==="approved"||x==="rejected"){let E=ne(m,1,["asset","note"],e),k=E.asset;if(k===void 0){e(m.number,"invalid-guide",`Expected ${x} asset=<name> note="\u2026"`);return}let M=E.note;w.push({kind:x,asset:k,...M===void 0?{}:{note:M}});return}e(m.number,"invalid-guide",`"${x}" is not a guide line \u2014 a guide holds quoted lines, banned, avoid, rewrite, ref, approved and rejected`)},g=m=>{let w=m.words[0];if(w.includes("=")||w.startsWith('"')){e(m.number,"invalid-review",'Expected <what>.<id> from=\u2026 note="\u2026", e.g. role.muted from=site');return}let x=ne(m,1,["from","note"],e);f.push({target:w,...x.from===void 0?{}:{from:x.from},...x.note===void 0?{}:{note:x.note}})};return{take(m){if(m.indent>0)return h?(h.kind==="brand"?N(m):h.kind==="guide"?O(m,h.entries):g(m),!0):!1;h=void 0;let w=m.words[0];if(w!=="brand"&&!An(w))return!1;switch(p=!0,w){case"brand":S(m);break;case"role":T(m);break;case"logo":A(m);break;case"rule":_(m);break;case"guide":{let x=m.words[1];if(x===void 0||x.includes("=")||m.words.length>2){e(m.number,"invalid-guide","Expected guide <id> on its own line, e.g. guide voice"),h={kind:"guide",id:"",entries:[]};break}if(Object.prototype.hasOwnProperty.call(d,x)){$(m,"guide",x),h={kind:"guide",id:"",entries:[]};break}let E=[];d[x]={entries:E},h={kind:"guide",id:x,entries:E};break}case"review":m.words.length>1&&e(m.number,"invalid-review","review is a block: its items go on the lines under it"),l=!0,h={kind:"review"};break}return!0},finish(){if(!p)return{header:!1,review:!1};let m=t??Nn();return{brand:{slug:m.slug,version:m.version,...t?.id===void 0?{}:{id:t.id},...t?.theme===void 0?{}:{theme:t.theme},...t?.strict===!0?{strict:!0}:{},...o===void 0?{}:{summary:o},changes:i,sources:s,roles:u,logos:a,rules:c,guides:d,review:f},header:t!==void 0,review:l}}}}function ne(e,n,t,r){let o={};for(let i of e.words.slice(n)){let{key:s,value:u}=j(i);if(u===void 0){r(e.number,"invalid-brand",`A stray word "${i}" \u2014 expected key=value`);continue}if(t!==void 0&&!t.includes(s)){r(e.number,"invalid-brand",`"${s}" is not allowed here; this line takes ${t.join(", ")}`);continue}o[s]=Do(u)}return o}function at(e,n){if(e.words.length!==n+1)return;let t=e.words[n];return t.startsWith('"')?Q(t):void 0}function Do(e){return e.startsWith('"')?Q(e)??e:e}function Ro(e){return e.startsWith("$")?e.slice(1):e}var Ds=new Set(["exit","delay","step","together","go","at","after","with"]),Lo=["at","after","with","together","step"],Vs=new Set(["pad","duration","delay","ease","on",...Lo]);function or(e){if(e==="at"||e==="length")return Un;if(e==="w"||e==="h")return xe;if(e==="duration"||e==="delay"||e==="stagger"||e==="hold")return nn;if(e==="pad")return xe}function ir(e,n){let t=e.words[1];if(t===void 0||t.includes("=")){n(e.number,"invalid-motion","Expected motion <page>, e.g. motion intro enter=fade");return}let r={};for(let i of e.words.slice(2)){let{key:s,value:u}=j(i),a=rt.find(([d])=>d===s)?.[1];if(a===void 0){let d=Ds.has(s)?` \u2014 ${s} goes on a node's line, under the header`:"";n(e.number,"invalid-motion",`motion ${t} has no "${s}"${d}`,t);continue}let c=L(u??"",a);"error"in c?n(e.number,"invalid-motion",`${s}: ${zs(s,u)??c.error}`,t):s==="bpm"&&!Us(c.value)?n(e.number,"invalid-motion",`bpm: expected ${20} to ${300} beats a minute, got ${u??""}`,t):s==="meter"&&!Ws(c.value)?n(e.number,"invalid-motion",`meter: expected a whole number of beats in a bar, 1 to ${16}, got ${u??""}`,t):c.value!==!1&&(r[s]=c.value)}let o=ge({...r,lines:[]});for(let[i]of rt){let s=r[i];if(s===void 0||or(i)===void 0)continue;let u=ar(i,s,o,t);u!==void 0&&(n(e.number,"invalid-motion",u,t),delete r[i])}return{page:t,number:e.number,head:r,lines:[],where:new Map,taken:new Map,numbers:[]}}function sr(e,n,t){if(n.words[0]==="music"&&!(n.words[1]??"").includes("=")){js(e,n,t);return}let r=n.words[0]==="camera"&&n.words[1]!==void 0&&!n.words[1].includes("="),o=r?n.words.slice(1):n.words,i=o[0];if(n.indent!==1){t(n.number,"invalid-motion","A motion line sits one level under its page");return}if(i.includes("=")){t(n.number,"invalid-motion",`Expected a node id first, got ${i}`);return}if(i===e.page&&!r){t(n.number,"invalid-motion",`${i} is the page: its transition goes on the header (motion ${i} enter=fade)`,i);return}let s=r?{id:i,camera:!0}:{id:i},u=!0;for(let d of o.slice(1)){let{key:f,value:l}=j(d),p=fn.find(([$])=>$===f)?.[1];if(p===void 0){t(n.number,"invalid-motion",`A motion line has no "${f}"${Gs(f)}`,i),u=!1;continue}if(r&&!Vs.has(f)){t(n.number,"invalid-motion",`A camera line moves the shot and says only pad=, duration=, delay=, ease= and when: not ${f}=`,i),u=!1;continue}let h=L(l??"",p),b="error"in h||or(f)===void 0?void 0:ar(f,h.value,ge(jo(e)),e.page);"error"in h?(t(n.number,"invalid-motion",`${f}: ${h.error}`,i),u=!1):b!==void 0?(t(n.number,"invalid-motion",`${i}: ${b}`,i),u=!1):f==="on"&&e.head.bpm===void 0?(t(n.number,"invalid-motion",`${i}: on=${String(h.value)} needs a tempo \u2014 motion ${e.page} bpm=120`,i),u=!1):f==="go"&&Be(h.value)===void 0?(t(n.number,"invalid-motion",`go: expected #<page>, back, next, or an https: or mailto: link, got ${l??""}`,i),u=!1):h.value!==!1&&(s[f]=h.value)}s.enter!==void 0&&s.exit!==void 0&&(t(n.number,"invalid-motion",`${i} either enters or exits on one line \u2014 write a second line for the other`,i),u=!1),s.emphasis!==void 0&&(s.enter!==void 0||s.exit!==void 0)&&(t(n.number,"invalid-motion",`${i} either ${s.enter!==void 0?"enters":"exits"} or is stressed on one line \u2014 write a second line for emphasis=`,i),u=!1);let a=Lo.filter(d=>s[d]!==void 0);if(s.step===!0&&s.together===!0?(t(n.number,"invalid-motion",`${i} waits for a step or starts together with the line above, not both`,i),u=!1):a.length>1?(t(n.number,"invalid-motion",`${i} says when it starts twice (${a.join(", ")}): keep one`,i),u=!1):s.on!==void 0&&(s.with!==void 0||s.together===!0)&&(t(n.number,"invalid-motion",`${i} starts with another line (${s.with===void 0?"together":"with="}), so on= could only pull it apart: keep one`,i),u=!1),u){let d=Xs(s);d!==void 0&&(t(n.number,"invalid-motion",`${i}: ${d}`,i),u=!1)}if(!u)return;let c=Fs(s);if(!Wn(c)){t(n.number,"invalid-motion",`${i} says nothing: give it enter=, exit=, emphasis= or go=`,i);return}if(r){e.where.has(i)||e.where.set(i,n.number),e.lines.push(c),e.numbers.push(n.number);return}for(let d of["enter","exit","emphasis","go"]){if(c[d]===void 0)continue;let f=e.taken.get(`${i} ${d}`);if(f!==void 0){let l=d==="go"?"has a go=":d==="enter"?"enters":d==="exit"?"exits":"has an emphasis=";t(n.number,"invalid-motion",`${i} already ${l} on line ${f}`,i);return}}for(let d of["enter","exit","emphasis","go"])c[d]!==void 0&&e.taken.set(`${i} ${d}`,n.number);e.where.has(i)||e.where.set(i,n.number),e.lines.push(c),e.numbers.push(n.number)}function ur(e){let n={...e.head.enter===void 0?{}:{enter:e.head.enter},...e.head.duration===void 0?{}:{duration:e.head.duration},...e.head.scroll===!0?{scroll:!0}:{},...e.head.length===void 0?{}:{length:e.head.length},...e.head.w===void 0?{}:{w:e.head.w},...e.head.h===void 0?{}:{h:e.head.h},...e.head.bpm===void 0?{}:{bpm:e.head.bpm},...e.head.meter===void 0?{}:{meter:e.head.meter},...e.music===void 0?{}:{music:e.music},lines:e.lines};return tn(n)?void 0:n}var Ls=new Set(["loop","step","together"]);function js(e,n,t){let r=n.words[1];if(n.indent!==1){t(n.number,"invalid-motion","A motion line sits one level under its page");return}if(r===void 0){t(n.number,"invalid-motion","Expected music <asset>, e.g. music bed fadeout=1500");return}if(Ls.has(r)){t(n.number,"invalid-motion",`music names its track first: music <asset> ${r}`);return}if(e.musicLine!==void 0){t(n.number,"invalid-motion",`motion ${e.page} already has music on line ${e.musicLine}: a page has one track`);return}let o={asset:r},i=ge(jo(e)),s=!0,u=c=>{t(n.number,"invalid-motion",`music ${r}: ${c}`),s=!1};for(let c of n.words.slice(2)){let{key:d,value:f}=j(c),l=ot.find(([h])=>h===d)?.[1];if(l===void 0){u(`the music line has no "${d}"${Bs(d)}`);continue}if(d==="from"&&f!==void 0&&/\d(?:beats?|bars?)$/.test(f)){u(`from= is where in the track to begin, in milliseconds, not ${f}`);continue}let p=L(f??"",l);if("error"in p){u(`${d}: ${p.error}`);continue}if(d==="from"&&!Vo(p.value,0,en)){u(`from: expected 0 to ${en} milliseconds, got ${f??""}`);continue}if(d==="volume"&&!Vo(p.value,0,1)){u(`volume: expected 0 to 1, got ${f??""}`);continue}if(d==="fadein"||d==="fadeout"){let h=ar(d,p.value,i,e.page);if(h!==void 0){u(h);continue}}p.value!==!1&&(o[d]=p.value)}if(!s)return;let a={asset:r};for(let[c]of ot)o[c]!==void 0&&(a[c]=o[c]);e.music=a,e.musicLine=n.number}function Vo(e,n,t){return typeof e=="number"&&e>=n&&e<=t}function Bs(e){return e==="fade"?" \u2014 write fadein= and fadeout=":e==="fade-in"||e==="fadeIn"||e==="fade_in"?" \u2014 write fadein=":e==="fade-out"||e==="fadeOut"||e==="fade_out"?" \u2014 write fadeout=":e==="start"||e==="offset"||e==="seek"?" \u2014 write from= (where in the track to begin, in milliseconds)":e==="gain"||e==="level"?" \u2014 write volume= (0 to 1)":e==="at"||e==="delay"||e==="after"||e==="with"?": the music starts with the video; from= picks where in the track":": it takes from=, volume=, fadein=, fadeout= and loop"}function Fs(e){let n=e.camera===!0?{id:e.id,camera:!0}:{id:e.id};for(let[t]of fn)e[t]!==void 0&&(n[t]=e[t]);return n}function jo(e){let{bpm:n,meter:t}=e.head;return{...n===void 0?{}:{bpm:n},...t===void 0?{}:{meter:t},lines:[]}}function ar(e,n,t,r){if(Le(n)&&!t)return`${n} needs a tempo \u2014 motion ${r} bpm=120`;let o=typeof n=="number"||Le(n)?Qe(n,t):void 0,i=or(e)??nn;if(o!==void 0&&o>=(e==="w"||e==="h"?16:0)&&o<=i)return;let u=String(n),a=Le(n)&&o!==void 0?` (${Math.round(o)} ms)`:"";return e==="w"||e==="h"?`${e}: expected 16 to ${xe} pixels, got ${u}`:e==="pad"?`pad: expected 0 to ${xe}, got ${u}`:`${e}: expected 0 to ${i} milliseconds, got ${u}${a}`}function Us(e){return typeof e=="number"&&e>=20&&e<=300}function Ws(e){return typeof e=="number"&&Number.isInteger(e)&&e>=1&&e<=16}function zs(e,n){if(e==="meter"&&n!==void 0&&/^\d+\/\d+$/.test(n))return`Expected beats in a bar, got ${n} \u2014 meter is beats per bar: meter=${n.split("/")[0]??""}`;if(e==="duration"&&n!==void 0&&/\d(?:beats?|bars?)$/.test(n))return`Expected milliseconds, got ${n} \u2014 the page transition is milliseconds; beats are for the lines`}function Gs(e){return e==="emphasise"||e==="emphasize"?" \u2014 write emphasis=pulse":e==="easing"?" \u2014 write ease=":e==="split"?" \u2014 write by=word or by=letter":e==="start"?" \u2014 write at= (milliseconds), after= or with=":""}function Xs(e){let n=e.enter,t=e.exit,r=n??t,o=e.from;if(t==="count")return"count only enters: it runs a number up to its written value";if(o!==void 0)if(r==="count"){if(typeof o!="number")return"from= on count is the number it starts at, e.g. from=0"}else if(r==="wipe"||r==="grow"){if(typeof o=="number")return`from= on ${r} is a side: ${ye.join(", ")}`}else return"from= goes with count (a number), or wipe and grow (a side)";if(e.by!==void 0&&r!==void 0&&!je.includes(r))return`by= splits a text for ${je.join(", ")}, not ${r}`;if(e.by!==void 0&&r===void 0)return"by= goes with enter= or exit=";if(e.stagger!==void 0&&r===void 0)return"stagger= goes with enter= or exit=";if(e.hold!==void 0&&n===void 0)return"hold= goes with enter=: how long to stay before leaving the way it came"}function cr(e){return(n,t,r,o)=>{e.push({severity:"error",code:t,message:`Line ${n}: ${r}`,...o===void 0?{}:{nodeId:o}})}}function dr(e){let n=[],t=e.split(`
5
+ `);for(let r=0;r<t.length;r+=1){let o=t[r],i=o.trim();if(i===Ne)break;if(i===""||i.startsWith("```"))continue;let s=o.length-o.trimStart().length;n.push({number:r+1,indent:Math.floor(s/2),text:i,words:Io(i)})}return n}function fr(e){let n=[],t=[],r,o=()=>{r&&r.runs.length>0&&(r.props.content=Fo(r.runs)),r=void 0},i=s=>{for(o();n.length>0&&n[n.length-1].indent>=s;)qs(n.pop())};return{push(s){let u=s.words[0];if(u.startsWith('"')&&r&&s.indent>r.indent){let f=Bo(s,e);return f!==void 0&&r.runs.push(f),!0}if(u===tr){i(s.indent);let f=n[n.length-1];return!f||f.type!=="instance"?(e(s.number,"invalid-override","An override line must sit inside an instance"),!0):(r=Ys(f,s,e),!0)}if(u.startsWith('"')){let f=n[n.length-1];if(!f||f.type!=="text")return e(s.number,"invalid-content","A quoted line must sit inside a text node"),!0;let l=Bo(s,e);return l!==void 0&&f.runs.push(l),!0}if(!it(u))return!1;i(s.indent);let a=s.words[1];if(a===void 0||a.includes("="))return e(s.number,"missing-id",`A ${u} needs an id`),!0;let c=Hs(u,a,s.words.slice(2),s,e),d=n[n.length-1];return d?.type==="instance"?e(s.number,"invalid-override",`${d.record.id} takes its contents from its component \u2014 change the component, or write an override line`,a):d?d.children.push(c.record):t.push(c.record),n.push(c),!0},finish(){return i(0),t}}}function Hs(e,n,t,r,o){let i={type:e,id:n},s=[];for(let u=0;u<t.length;u+=1){let{key:a,value:c}=j(t[u]),d=ln(e,a);if(d===void 0){let p=ut(t,u,t[u-1]);p?(o(r.number,"invalid-value",p.message,n),u=p.end-1):o(r.number,"invalid-value",`${e} has no property "${a}"`,n);continue}let f=st(a,c??"");if(f!==void 0){if("error"in f)o(r.number,"invalid-value",`${a}: ${f.error}`,n);else for(let[p,h]of f.cells)i[p]=h;continue}let l=L(c??"",d);"error"in l?o(r.number,"invalid-value",`${a}: ${l.error}`,n):i[a]=l.value}return On(e)&&(i.children=s),e==="text"&&(i.content=""),{indent:r.indent,type:e,record:i,children:s,runs:[]}}function Ys(e,n,t){let r=e.record.id,o=n.words[1];if(o===void 0||o.includes("=")){t(n.number,"invalid-override","An override names the part it changes, e.g. override item.title fill=accent",r);return}let i=e.record.overrides??={},s=i[o]??={},u=n.words.slice(2);for(let a=0;a<u.length;a+=1){let{key:c,value:d}=j(u[a]),f=_e(c)?nr(c):void 0;if(f===void 0){let h=ut(u,a,u[a-1]);h?(t(n.number,"invalid-value",h.message,r),a=h.end-1):c==="content"?t(n.number,"invalid-value","Write the text as quoted lines under the override",r):t(n.number,"invalid-value",`An override cannot set "${c}"`,r);continue}let l=st(c,d??"");if(l!==void 0){if("error"in l)t(n.number,"invalid-value",`${c}: ${l.error}`,r);else for(let[h,b]of l.cells)s[h]=b;continue}let p=L(d??"",f);"error"in p?t(n.number,"invalid-value",`${c}: ${p.error}`,r):s[c]=p.value}return{indent:n.indent,props:s,runs:[]}}function qs(e){if(e.type==="text"&&(e.record.content=Fo(e.runs)),e.type==="instance"){let n=e.record.overrides;for(let[t,r]of Object.entries(n??{}))Object.keys(r).length===0&&delete n?.[t];n&&Object.keys(n).length===0&&delete e.record.overrides}}function Fo(e){if(e.length===0)return"";let n=e[0];return e.length===1&&typeof n=="string"?n:[...e]}function Bo(e,n){let t=Q(e.words[0]);if(t===void 0){n(e.number,"invalid-run","Malformed quoted string");return}if(e.words.length===1)return t;let r={text:t};for(let o of e.words.slice(1)){let{key:i,value:s}=j(o),u=tt.find(([c])=>c===i);if(!u){n(e.number,"invalid-run",`A run has no mark "${i}"`);continue}let a=L(s??"",u[1]);"error"in a?n(e.number,"invalid-run",`${i}: ${a.error}`):r[i]=a.value}return r}function Zs(e){let n=[],t=cr(n),r=Pe,o,i=!1,s={},u={},a={},c=fr(t),d=rr(t,n),f,l={},p=!1,h=!1,b={},$=new Map,S,N=!1,T=()=>{if(!S)return;let k=S;S=void 0;let M=$.get(k.page);if(M!==void 0){t(k.number,"invalid-motion",`motion ${k.page} is written twice \u2014 put its lines in the block on line ${M}`,k.page);return}$.set(k.page,k.number);for(let[V,I]of k.where)$.set(`${k.page} ${V}`,I);let R=ur(k);R&&(b[k.page]=R)};for(let k of dr(e)){let M=k.words[0];if(S&&k.indent>0){sr(S,k,t);continue}if(!(N&&k.indent>0)){if(N=!1,T(),M==="motion"&&k.indent===0){f=void 0,S=ir(k,t),N=S===void 0;continue}if(d.take(k)){f=void 0;continue}if(M==="version"){i=!0,nu(k,n);continue}if(M==="kind"&&k.indent===0){r=tu(k,n);continue}if(M==="title"&&k.indent===0){o=Uo(k,t);continue}if(M==="theme"&&k.indent===0){f=void 0,p=!0,h&&t(k.number,"invalid-theme","theme dark is written twice \u2014 keep one block"),h=!0,(k.words[1]!=="dark"||k.words.length>2)&&t(k.number,"invalid-theme","Expected theme dark on its own line, with the tokens that differ indented under it");continue}if(M.startsWith("$")){if(f=void 0,p&&k.indent>0){lr(k,l,t);continue}p=!1,lr(k,s,t);continue}if(k.indent===0)p=!1;else if(p){t(k.number,"invalid-theme","A theme block holds only $name = value lines");continue}if(M==="asset"&&k.indent===0){f=void 0,ru(k,a,t);continue}if(M==="font"&&k.indent===0){f=iu(k,u,t);continue}if((M==="fallback"||M==="face")&&f){uu(M,k,f,t);continue}f=void 0,!c.push(k)&&t(k.number,"unknown-node-type",`Unknown statement "${M}"`)}}T();let A=eu(d.finish(),r,n),_=Ce({dark:l}),O={...A===void 0?{}:{brand:A},..._===void 0?{}:{themes:_}},g=Qs(c.finish(),n),m=Object.keys(b).length===0?{}:{motion:b},w=(k,M)=>$.get(M===void 0?k:`${k} ${M}`);if(!g){i||n.push({severity:"error",code:"invalid-document",message:"No nodes found"});let k=Ze({id:me,children:[]}),M=Cn({kind:r,...o===void 0?{}:{title:o},tokens:s,fonts:u,assets:a,...m,...O,root:k});return n.push(...rn(M,w)),{document:M,problems:n}}let x=he(g),E={version:ie({kind:r,fonts:u,...O,root:x}),kind:r,...o===void 0?{}:{title:o},tokens:s,fonts:u,assets:a,...m,...O,root:x};return n.push(...rn(E,w)),{document:E,problems:n}}function Qs(e,n){let t=e[0];if(t!==void 0){if(e.length===1&&t.type==="canvas")return t;for(let r of e){if(r.type!=="canvas")continue;let o=r.id;n.push({severity:"error",code:"invalid-document",message:"A canvas must be the only top-level node",...typeof o=="string"?{nodeId:o}:{}})}return{type:"canvas",id:me,children:[...e]}}}function eu(e,n,t){let r=e.brand;if(!r)return;e.header||t.push({severity:"error",code:"invalid-brand",message:"A brand needs its brand line first, e.g. brand ember@1"});let o=Object.entries(r.guides).filter(([s,u])=>s!=="voice"||u.entries.some(a=>a.kind!=="banned")),i=Object.keys(r.roles).length+Object.keys(r.logos).length+o.length+r.review.length;return n!=="brand"&&i>0&&t.push({severity:"warning",code:"brand-only",message:"Roles, logos, guides and review define a brand, and are read in a kind brand document"}),r}function nu(e,n){Rn.includes(Number(e.words[1]))||n.push({severity:"warning",code:"version-mismatch",message:`Line ${e.number}: expected version ${Pn} or older, got ${e.words[1]??"nothing"}`})}function tu(e,n){let t=e.words[1];return t!==void 0&&qe.includes(t)?t:(n.push({severity:"error",code:"unknown-kind",message:`Line ${e.number}: unknown kind "${t??"nothing"}" \u2014 this build reads ${qe.join(", ")}`}),Pe)}function Uo(e,n){let t=e.words.slice(1).join(" ").trim();if(t===""){n(e.number,"invalid-value",'title needs a name, e.g. title "Pitch deck"');return}let r=t.startsWith('"')?Q(t):t;if(r===void 0){n(e.number,"invalid-value",`Could not read the title ${t}`);return}return r.trim()===""?void 0:r}function lr(e,n,t){let{name:r,value:o}=pr(e.words);if(r===void 0||o===void 0){t(e.number,"invalid-token","Expected $name = value");return}if(!o.startsWith('"')&&/\s/.test(o)){t(e.number,"invalid-token",`$${r}: expected one value, got "${o}". Quote it if the value has spaces; there are no comments.`);return}let i=L(o,"stringValue");if("error"in i){t(e.number,"invalid-token",`$${r}: ${i.error}`);return}if(typeof i.value!="string"){t(e.number,"invalid-token",`$${r} may not be an expression`);return}n[r]=Wo(i.value,o)}function Wo(e,n){let t=Number(e);return n.startsWith('"')||!Number.isFinite(t)||e.trim()===""?e:t}function pr(e){let n=e[0],t=i=>i.startsWith("$")?i.slice(1):i;if(e[1]==="=")return{name:t(n),value:e.slice(2).join(" ")||void 0};let{key:r,value:o}=j(n);return o!==void 0?{name:t(r),value:o}:{name:t(n)}}function ru(e,n,t){let r=e.words.slice(1),o=r[0],i=r[1]==="=",s=o===void 0?void 0:j(o),u=s?.key,a=i?r[2]:s?.value,c=r.slice(i?3:1);if(u===void 0||u===""||a===void 0){t(e.number,"invalid-asset","Expected asset <name> = <type> hash=\u2026 bytes=\u2026");return}let d={};for(let h of c){let{key:b,value:$}=j(h);if($===void 0){t(e.number,"invalid-asset",`Asset "${u}" has a stray word "${h}"`);continue}d[b]=ou($)}let f=d.hash,l=Number(d.bytes);if(f===void 0||!Number.isFinite(l)){t(e.number,"invalid-asset",`Asset "${u}" needs a hash and a bytes count`);return}let p=d.ms===void 0?void 0:Number(d.ms);if(p!==void 0&&!(Number.isFinite(p)&&p>=0)){t(e.number,"invalid-asset",`Asset "${u}": ms is the track's length, in milliseconds`);return}n[u]={type:a,hash:f,bytes:l,...p===void 0?{}:{ms:p},...d.credit===void 0?{}:{credit:d.credit},...d.source===void 0?{}:{source:d.source},...d.license===void 0?{}:{license:d.license}}}function ou(e){return e.startsWith('"')?Q(e)??e:e}function iu(e,n,t){let{name:r,value:o}=pr(e.words.slice(1));if(r===void 0||o===void 0){t(e.number,"invalid-font","Expected font <name> = <family>");return}let i=L(o,"string"),s={family:"error"in i?o:i.value};return n[r]=s,{family:s,faces:[]}}var su=/^[A-Za-z_][\w-]*$/;function uu(e,n,t,r){if(e==="fallback"){let u=L(n.words.slice(1).join(" "),"string");"error"in u?r(n.number,"invalid-font",`fallback: ${u.error}`):t.family.fallback=u.value;return}let o=n.words[1];if(o===void 0){r(n.number,"invalid-font-face","A face needs a src, or asset=");return}let i=o.startsWith("asset=")?o.slice(6):void 0,s={};if(i!==void 0){if(!su.test(i)){r(n.number,"invalid-font-face",`asset=${i}: not an asset name`);return}s.asset=i}else{let u=L(o,"string");s.src="error"in u?o:u.value}for(let u of n.words.slice(2)){let{key:a,value:c}=j(u);if(a!=="weight"&&a!=="style"){r(n.number,"invalid-font-face",`A face has no property "${a}"`);continue}let d=L(c??"",a==="weight"?"number":"fontStyle");"error"in d?r(n.number,"invalid-font-face",`${a}: ${d.error}`):s[a]=d.value}t.faces.push(s),t.family.faces=t.faces}function se(e){return{x:e.x+e.w/2,y:e.y+e.h/2}}function lt(e,n,t){if(t===0)return e;let r=t*Math.PI/180,o=Math.cos(r),i=Math.sin(r),s=e.x-n.x,u=e.y-n.y;return{x:n.x+s*o-u*i,y:n.y+s*i+u*o}}function ze(e,n,t=se(e)){if(n%360===0)return e;let r=[{x:e.x,y:e.y},{x:e.x+e.w,y:e.y},{x:e.x+e.w,y:e.y+e.h},{x:e.x,y:e.y+e.h}].map(a=>lt(a,t,n)),o=r.map(a=>a.x),i=r.map(a=>a.y),s=Math.min(...o),u=Math.min(...i);return{x:s,y:u,w:Math.max(...o)-s,h:Math.max(...i)-u}}var zo=["image","video"],Go=["rect","ellipse","vector"];function pt(e){return zo.includes(e.type)}function Xo(e){return Go.includes(e.type)}function ht(e){let n=new Map,t=[],r=(s,u,a)=>{let c={node:s,page:u,instance:a};n.has(s.id)||n.set(s.id,c),pt(s)&&s.mask!==void 0&&t.push(c);let d=s.type==="instance"?s.id:a;for(let f of z(s)){let l=s===e&&f.type==="frame"?f.id:u;r(f,l,d)}};r(e,e.id,void 0);let o=new Map,i=[];for(let s of t){let u=s.node,a=u.mask,c=s.instance===void 0?void 0:Ie(s.instance,a),d=(c===void 0?void 0:n.get(c))??n.get(a);if(!d){i.push({severity:"error",code:"unknown-reference",message:`${u.id}: mask=${a} names nothing in the document, so it is drawn unmasked \u2014 point mask= at a rect, ellipse or vector on its page`,nodeId:u.id,prop:"mask"});continue}if(!Xo(d.node)){i.push({severity:"error",code:"mask-not-a-shape",message:d.node.id===u.id?`${u.id} cannot be its own mask, so it is drawn unmasked \u2014 point mask= at a rect, ellipse or vector`:`${u.id}: mask=${a} is ${au(d.node.type)} ${d.node.type}, so it is drawn unmasked \u2014 a mask is a rect, ellipse or vector`,nodeId:u.id,prop:"mask"});continue}if(d.page!==s.page){i.push({severity:"error",code:"mask-wrong-page",message:`${u.id}: mask=${a} is on ${d.page}, not ${s.page}, so it is drawn unmasked \u2014 move the shape onto the image's page`,nodeId:u.id,prop:"mask"});continue}o.set(u.id,d.node.id)}return{links:o,shapes:new Set(o.values()),problems:i}}function hr(e){return[...ht(e).problems]}function au(e){return/^[aeiou]/.test(e)?"an":"a"}function mr(e,n,t){let r={x:n.x,y:n.y,w:Math.max(0,n.w),h:Math.max(0,n.h)},o=a=>({x:a.x+r.x,y:a.y+r.y}),i,s="nonzero";switch(e.type){case"rect":i=J(we(r.w,r.h,$n(t)),o);break;case"ellipse":i=J(cn(r.w,r.h),o);break;case"vector":i=J(on(e.d).contours,un(sn(e.view,r.w,r.h),r)),s=e.rule??"nonzero";break;case"canvas":case"connector":case"frame":case"group":case"image":case"instance":case"text":case"video":return}let u=t.rotation??0;if(u%360!==0){let a=se(r);i=J(i,c=>lt(c,a,u))}return{contours:i,rule:s}}var cu=/^[A-Za-z_][\w-]*$/;function pn(e){return xr(e).map(n=>n.trim())}function mt(e){return/^\s*image\s*\(/i.test(e)}function gr(e){let n=e.trim();if(n==="")return{error:"A paint list has an empty layer"};if(!mt(n))return yt(n);let t=/^image\s*\(([\s\S]*)\)$/i.exec(n);if(!t)return{error:'An image paint needs its closing ")"'};let r=xr(t[1]).map(s=>s.trim()),o=r[0]??"";if(!cu.test(o))return{error:`image() names an asset, like image(photo, cover), not ${JSON.stringify(o)}`};if(r.length>2)return{error:"image() takes an asset and a fit: image(photo, cover)"};let i=(r[1]??"cover").toLowerCase();return fe.includes(i)?{kind:"image",asset:o,fit:i}:{error:`An image paint's fit is cover, contain or fill, not ${JSON.stringify(i)}`}}function gt(e){return/^\s*(linear|radial|conic|repeating-[a-z]+)-gradient\s*\(/i.test(e)}function yt(e){let n=e.trim(),t=/^([a-z-]+)-gradient\s*\(([\s\S]*)\)$/i.exec(n);if(!t)return gt(n)?{error:'A gradient needs its closing ")"'}:{kind:"solid",colour:n};let r=t[1].toLowerCase(),o=xr(t[2]).map(i=>i.trim());if(o.some(i=>i===""))return{error:"A gradient has an empty argument"};if(r==="linear"){let i=fu(o[0]),s=Ko(i===void 0?o:o.slice(1));return"error"in s?s:{kind:"linear",angle:i??180,stops:s.stops}}if(r==="radial"){let i=pu(o[0]);if(i&&"error"in i)return i;let s=Ko(i?o.slice(1):o);return"error"in s?s:{kind:"radial",shape:i?.shape??"ellipse",cx:i?.cx??.5,cy:i?.cy??.5,stops:s.stops}}return{error:`${r}-gradient is not supported; use linear-gradient or radial-gradient`}}function yr(e){let n=e.map(r=>r.at);n[0]===void 0&&(n[0]=0),n[n.length-1]===void 0&&(n[n.length-1]=1);let t=0;for(let r=0;r<n.length;r+=1){let o=n[r];o!==void 0&&(t=Math.max(t,o),n[r]=t)}for(let r=1;r<n.length;r+=1){if(n[r]!==void 0)continue;let o=r-1,i=r;for(;n[i]===void 0;)i+=1;let s=n[o],u=n[i];for(let a=r;a<i;a+=1)n[a]=s+(u-s)*(a-o)/(i-o);r=i}return e.map((r,o)=>({colour:r.colour,at:n[o]}))}function xr(e){let n=[],t=0,r=0;for(let o=0;o<e.length;o+=1){let i=e[o];i==="("?t+=1:i===")"?t=Math.max(0,t-1):i===","&&t===0&&(n.push(e.slice(r,o)),r=o+1)}return n.push(e.slice(r)),n}var du={top:[0,-1],bottom:[0,1],left:[-1,0],right:[1,0]};function fu(e){let n=/^(-?\d*\.?\d+)(deg|turn|rad)$/i.exec(e);if(n){let i=Number(n[1]),s=n[2].toLowerCase();return s==="turn"?i*360:s==="rad"?i*180/Math.PI:i}let t=/^to\s+([a-z]+)(?:\s+([a-z]+))?$/i.exec(e);if(!t)return;let r=0,o=0;for(let i of[t[1],t[2]]){if(i===void 0)continue;let s=du[i.toLowerCase()];if(!s)return;r+=s[0],o+=s[1]}return(Math.atan2(r,-o)*180/Math.PI+360)%360}var lu={left:0,top:0,center:.5,right:1,bottom:1};function pu(e){let n=/^(circle|ellipse)?\s*(?:at\s+(\S+)(?:\s+(\S+))?)?$/i.exec(e);if(!n||n[1]===void 0&&n[2]===void 0)return;let t=n[1]?.toLowerCase();if(n[2]===void 0)return t?{shape:t}:void 0;let r=Jo(n[2]),o=n[3]===void 0?.5:Jo(n[3]);return r===void 0||o===void 0?{error:`A radial centre is two percentages or keywords, not "${e}"`}:{...t?{shape:t}:{},cx:r,cy:o}}function Jo(e){let n=lu[e.toLowerCase()];if(n!==void 0)return n;let t=/^(-?\d*\.?\d+)%$/.exec(e);return t?Number(t[1])/100:void 0}function Ko(e){if(e.length<2)return{error:"A gradient needs at least two colours"};let n=[];for(let t of e){let r=/^([\s\S]*?\S)\s+(-?\d*\.?\d+)%$/.exec(t);if(r&&hu(r[1]))n.push({colour:r[1],at:Number(r[2])/100});else{if(/\s/.test(t.replace(/\([^)]*\)/g,"")))return{error:`"${t}" is not a colour with an optional percentage`};n.push({colour:t})}}return{stops:n}}function hu(e){let n=0;for(let t of e)if(t==="("&&(n+=1),t===")"&&(n-=1),n<0)return!1;return n===0}var Yo="https://getv.design/ns/vd",wf=`<metadata><vd:document xmlns:vd="${Yo}" version="1"><![CDATA[
6
+ `;var Eu=/<vd:document\b[^>]*>([\s\S]*?)<\/vd:document\s*>/;function Ou(e){let n=Eu.exec(e);if(!n)return;let t=n[1]??"",r="",o=t;for(;;){let i=o.indexOf("<![CDATA[");if(i===-1){r+=Ho(o);break}r+=Ho(o.slice(0,i));let s=o.indexOf("]]>",i);if(s===-1){r+=o.slice(i+9);break}r+=o.slice(i+9,s),o=o.slice(s+3)}return`${r.replace(/^\n/,"").replace(/\n$/,"")}
7
+ `}function Mu(e){return/^\uFEFF?\s*</.test(e)}function Ho(e){return e.replace(/&(lt|gt|quot|apos|amp|#\d+|#x[0-9a-fA-F]+);/g,(n,t)=>{switch(t){case"lt":return"<";case"gt":return">";case"quot":return'"';case"apos":return"'";case"amp":return"&";default:{let r=t.startsWith("#x")?parseInt(t.slice(2),16):parseInt(t.slice(1),10);return Number.isFinite(r)&&r<=1114111?String.fromCodePoint(r):n}}})}var qo=.04,Zo=.85;var Du=[.2,0,0,1],Vu=[.4,0,1,1],Lu=[.4,0,.2,1];function br(e){let n=e.trim();if(n===""||n==="none")return{shadows:[]};let t=[];for(let r of ju(n)){let o=Bu(r.trim()),i=o.filter(h=>h.toLowerCase()==="inset").length;if(i>1)return{error:`"${r.trim()}" says inset more than once`};let s=o[0]?.toLowerCase()==="inset",u=o[o.length-1]?.toLowerCase()==="inset";if(i===1&&!s&&!u)return{error:`"${r.trim()}" needs inset first or last, as CSS writes it`};i===1&&(o=s?o.slice(1):o.slice(0,-1));let a=[],c=[];for(let h of o){let b=/^(-?\d*\.?\d+)(px)?$/.exec(h);b&&c.length===0?a.push(Number(b[1])):c.push(h)}if(a.length<2||a.length>4)return{error:`"${r.trim()}" needs x, y, then optional blur and spread`};if(c.length!==1)return{error:`"${r.trim()}" needs one colour after its numbers`};let[d=0,f=0,l=0,p=0]=a;if(l<0)return{error:"A shadow cannot have a negative blur"};t.push({x:d,y:f,blur:l,spread:p,colour:c[0],...i?{inset:!0}:{}})}return{shadows:t}}function ju(e){let n=[],t=0,r=0;for(let o=0;o<e.length;o+=1){let i=e[o];i==="("?t+=1:i===")"?t=Math.max(0,t-1):i===","&&t===0&&(n.push(e.slice(r,o)),r=o+1)}return n.push(e.slice(r)),n}function Bu(e){let n=[],t=0,r="";for(let o of e){if(o==="("&&(t+=1),o===")"&&(t=Math.max(0,t-1)),/\s/.test(o)&&t===0){r!==""&&n.push(r),r="";continue}r+=o}return r!==""&&n.push(r),n}var xt=["video/mp4","video/webm"];function $r(e){return xt.includes(e.type)}function Qo(e,n){return e.end===void 0?n:n===void 0?e.end:Math.min(e.end,n)}function wr(e,n){let t=e.start??0,r=Qo(e,n),o=e.poster??t;return r===void 0?Math.max(o,t):Uu(o,t,Fu(t,r))}function Fu(e,n){return Math.max(e,n-1)}function Uu(e,n,t){return Math.min(Math.max(e,n),t)}var ti="system-ui, -apple-system, Segoe UI, Roboto, sans-serif",ri=16,oi=400,ii=1.2,bt="#0F172A";function $t(){return{advance(e,n){return e.length*(n.size*.5+n.letterSpacing)},metrics(e){return{ascent:e.size*.8,descent:e.size*.2,lineGap:0}}}}function kr(e,n){if(e===void 0)return ti;let t=n[e];return t?t.fallback?`${ni(t.family)}, ${t.fallback}`:ni(t.family):e}function ni(e){return/^[A-Za-z][A-Za-z0-9 -]*$/.test(e)?e:JSON.stringify(e)}function vr(e,n,t,r){let o={family:kr(n.font,t),size:n.size,weight:n.weight,italic:n.italic,underline:!1,strike:!1,fill:r(n.fill),letterSpacing:n.letterSpacing},i=typeof e=="string"?[e]:e,s=[];for(let u of i){if(typeof u=="string"){u.length>0&&s.push({text:u,style:o});continue}let a=u;a.text.length!==0&&s.push({text:a.text,style:{family:a.font===void 0?o.family:kr(a.font,t),size:a.size??o.size,weight:a.weight??o.weight,italic:a.italic??o.italic,underline:a.underline??!1,strike:a.strike??!1,fill:a.fill===void 0?o.fill:r(a.fill),letterSpacing:a.letterSpacing??o.letterSpacing,...a.link!==void 0&&le(a.link)?{link:a.link}:{}}})}return s}function Ku(e,n){let t=[];for(let r of e)for(let o of r.text.split(/(\n)/))if(o!==""){if(o===`
8
+ `){let i=t[t.length-1];i&&!i.hardBreak?t[t.length-1]={...i,hardBreak:!0}:t.push({text:"",style:r.style,w:0,hardBreak:!0,glued:!1});continue}for(let i of o.match(/\S+\s*|\s+/g)??[]){let s=t[t.length-1];t.push({text:i,style:r.style,w:n.advance(i,r.style),hardBreak:!1,glued:s!==void 0&&!s.hardBreak&&/\S$/.test(s.text)&&/^\S/.test(i)})}}return t}function Hu(e,n,t){let r=[...e.text],o=[],i="";for(let s of r){let u=i+s;if(i!==""&&t.advance(u,e.style)>n){o.push({text:i,style:e.style,w:t.advance(i,e.style),hardBreak:!1,glued:o.length===0&&e.glued}),i=s;continue}i=u}return i!==""&&o.push({text:i,style:e.style,w:t.advance(i,e.style),hardBreak:e.hardBreak,glued:o.length===0&&e.glued}),o.length>0?o:[e]}function si(e,n){let{width:t,measure:r}=n,o=Ku(r.itemize?e.flatMap(c=>r.itemize?.(c)??[c]):e,r);if(o.length===0){let c=e[0]?.style,d=c?n.lineHeight*c.size:0;return{lines:c?[qu(c,n.lineHeight)]:[],width:0,height:d}}let i=[],s=[],u=0,a=()=>{i.push(s),s=[],u=0};for(let c=0;c<o.length;){let d=c+1;for(;o[d]?.glued;)d+=1;let f=o.slice(c,d);c=d,f.length>1&&s.length>0&&u+Yu(f,r)>t&&a();for(let l of f){let p=s.length===0&&l.w>t&&t>0?Hu(l,t,r):[l];for(let h of p){let b=h.text.trimEnd(),$=b===h.text?h.w:r.advance(b,h.style);s.length>0&&u+$>t&&a(),s.push(h),u+=h.w,h.hardBreak&&a()}}}return s.length>0&&i.push(s),Zu(i,n)}function Yu(e,n){let t=e[e.length-1],r=t.text.trimEnd(),o=r===t.text?t.w:n.advance(r,t.style);return e.slice(0,-1).reduce((i,s)=>i+s.w,0)+o}function qu(e,n){let t=n*e.size;return{y:0,h:t,baseline:t*.8,w:0,spans:[],style:e}}function Zu(e,n){let t=[],r=0,o=0;return e.forEach((i,s)=>{let u=i.map(m=>m.style.size),a=Math.max(...u,0),c=n.lineHeight*a,d=i.map(m=>n.measure.metrics(m.style)),f=Math.max(...d.map(m=>m.ascent),0),l=Math.max(...d.map(m=>m.descent),0),p=r+(c-(f+l))/2+f,h=Qu(i,n.measure),b=h.reduce((m,w)=>m+w.w,0);o=Math.max(o,b);let $=s===e.length-1||(i[i.length-1]?.hardBreak??!1),S=h.filter((m,w)=>w>0&&!m.glued).length,N=n.align==="justify"&&!$&&S>0,T=Math.max(0,n.width-b),A=n.align==="center"?T/2:n.align==="right"?T:0,_=N?T/S:0,O=[],g=A;h.forEach((m,w)=>{O.push({text:m.text,style:m.style,x:g,w:m.w});let x=h[w+1];g+=m.w+(x&&!x.glued?_:0)}),t.push({y:r,h:c,baseline:p,w:b,spans:ea(O,N)}),r+=c}),{lines:t,width:o,height:r}}function Qu(e,n){let t=[...e];for(;t.length>0;){let r=t[t.length-1],o=r.text.trimEnd();if(o===r.text)break;if(o===""){t.pop();continue}t[t.length-1]={...r,text:o,w:n.advance(o,r.style)};break}return t}function ea(e,n){if(n)return[...e];let t=[];for(let r of e){let o=t[t.length-1];if(o&&ui(o.style,r.style)&&Math.abs(o.x+o.w-r.x)<.01){t[t.length-1]={...o,text:o.text+r.text,w:o.w+r.w};continue}t.push(r)}return t}function ui(e,n){return e.family===n.family&&e.size===n.size&&e.weight===n.weight&&e.italic===n.italic&&e.underline===n.underline&&e.strike===n.strike&&e.fill===n.fill&&e.letterSpacing===n.letterSpacing&&e.link===n.link}function Sr(e,n,t,r,o,i){let s={size:n.size??ri,weight:n.weight??oi,lineHeight:n.lineHeight??ii,letterSpacing:n.letterSpacing??0,italic:e.italic??!1,font:typeof e.font=="string"?e.font:void 0,fill:typeof e.fill=="string"?e.fill:bt},u=vr(e.content,s,r,o),a=vr(" ",s,r,o).map(c=>({...c,text:""}));return si(u.length>0?u:a,{width:t,align:e.align??"left",lineHeight:s.lineHeight,measure:i})}function Er(e,n,t){let r=n-t;return e.valign==="middle"?r/2:e.valign==="bottom"?r:0}var ai=["x","y","w","h","left","right","top","bottom","cx","cy"];function ke(e){return ai.includes(e)}var ci=["parent","prev","next","self","root"];function Or(e){return ci.includes(e)}var B=class extends Error{position;constructor(n,t){super(n),this.position=t,this.name="ExprSyntaxError"}},di=/[A-Za-z_]/,Mr=/[A-Za-z0-9_]/;function Tr(e){let n=[],t=0,r=()=>{if(!di.test(e[t]??""))throw new B(`Expected a name at position ${t}`,t);let s=t;for(;t<e.length&&Mr.test(e[t]??"");)t++;return e.slice(s,t)},o=()=>{if(!Mr.test(e[t]??""))throw new B(`Expected a name at position ${t}`,t);let s=t;for(;t<e.length&&Mr.test(e[t]??"");)t++;return e.slice(s,t)},i=()=>{let s=[r()];for(;e[t]===".";)t++,s.push(o());return s};for(;t<e.length;){let s=e[t]??"";if(/\s/.test(s)){t++;continue}if(/[0-9]/.test(s)){let u=t;for(;t<e.length&&/[0-9]/.test(e[t]??"");)t++;if(e[t]==="."&&/[0-9]/.test(e[t+1]??""))for(t++;t<e.length&&/[0-9]/.test(e[t]??"");)t++;let a=e.slice(u,t),c=Number(a);if(!Number.isFinite(c))throw new B(`Bad number "${a}"`,u);e[t]==="%"?(t++,n.push({type:"percent",value:c})):n.push({type:"number",value:c});continue}if(s==="$"){t++,n.push({type:"token",name:r()});continue}if(s==="@"){t++,n.push({type:"ref",path:i()});continue}if(di.test(s)){n.push({type:"word",path:i()});continue}if("+-*/()".includes(s)){t++,n.push({type:"op",value:s});continue}throw new B(`Unexpected character "${s}" at position ${t}`,t)}return n.push({type:"eof"}),n}var na={"+":1,"-":1,"*":2,"/":2};function ve(e){try{let n=Tr(e),t=new Ar(n),r=t.parseBinary(0);return t.expectEof(),{ok:!0,ast:r}}catch(n){if(n instanceof B)return{ok:!1,message:n.message};throw n}}var Ar=class{tokens;index=0;constructor(n){this.tokens=n}peek(){return this.tokens[this.index]??{type:"eof"}}next(){let n=this.peek();return this.index++,n}expectEof(){if(this.peek().type!=="eof")throw new B("Unexpected trailing input",this.index)}parseBinary(n){let t=this.parseUnary();for(;;){let r=this.peek();if(r.type!=="op"||!ta(r.value))break;let o=na[r.value];if(o<n)break;this.next();let i=this.parseBinary(o+1);t={kind:"binary",op:r.value,left:t,right:i}}return t}parseUnary(){let n=this.peek();return n.type==="op"&&(n.value==="-"||n.value==="+")?(this.next(),{kind:"unary",op:n.value,operand:this.parseUnary()}):this.parsePrimary()}parsePrimary(){let n=this.next();switch(n.type){case"number":return{kind:"number",value:n.value};case"percent":return{kind:"percent",value:n.value};case"token":return{kind:"token",name:n.name};case"ref":{if(n.path.length<2)throw new B(`@${n.path.join(".")} needs an edge, for example @${n.path.join(".")}.right`,this.index);return{kind:"nodeRef",path:n.path}}case"word":{let[t,r,...o]=n.path;if(t===void 0||!Or(t))throw new B(`Unknown name "${n.path.join(".")}". Use $token for a token or @id.edge for a node.`,this.index);if(r===void 0||!ke(r)||o.length>0)throw new B(`${t} needs an edge, for example ${t}.w`,this.index);return{kind:"relRef",word:t,edge:r}}case"op":{if(n.value==="("){let t=this.parseBinary(0),r=this.next();if(r.type!=="op"||r.value!==")")throw new B("Missing closing parenthesis",this.index);return t}throw new B(`Unexpected "${n.value}"`,this.index)}case"eof":throw new B("Unexpected end of expression",this.index)}}};function ta(e){return e==="+"||e==="-"||e==="*"||e==="/"}function G(e,n){return`${e} ${n}`}function Nr(e){switch(e){case"x":case"left":return["x"];case"y":case"top":return["y"];case"w":return["w"];case"h":return["h"];case"right":case"cx":return["x","w"];case"bottom":case"cy":return["y","h"]}}function _r(e,n,t,r,o){switch(e){case"x":case"left":return n;case"y":case"top":return t;case"w":return r;case"h":return o;case"right":return n+r;case"bottom":return t+o;case"cx":return n+r/2;case"cy":return t+o/2}}function Ir(e){switch(e){case"x":case"left":case"right":case"cx":return"x";case"y":case"top":case"bottom":case"cy":return"y";case"w":case"h":return}}function Rr(e,n,t){let r=f=>{let l=[];for(let p=t.parentOf.get(f);p!==void 0;p=t.parentOf.get(p))l.push(p);return l},o=r(e),i=r(n),s=new Set(i),u=o.find(f=>s.has(f)),a=f=>u===void 0?f:f.slice(0,f.indexOf(u)),c=new Map([[e,1]]),d=(f,l)=>{let p=(c.get(f)??0)+l;p===0?c.delete(f):c.set(f,p)};for(let f of a(o))d(f,1);for(let f of a(i))d(f,-1);return c}function Pr(e){switch(e){case"right":case"bottom":return 1;case"cx":case"cy":return .5;default:return 0}}function wt(e){if(e==="x"||e==="w"||e==="x1"||e==="x2")return"w";if(e==="y"||e==="h"||e==="y1"||e==="y2")return"h"}function hn(e){let n=new Map,t=new Map,r=new Map,o=new Map,i=new Map,s=[];C(e.root,(f,l)=>{if(n.has(f.id)||n.set(f.id,f),s.push(f),l){t.set(f.id,l.id);let p=i.get(l.id)??[],h=l.type==="instance"?[l.id,...p]:p;h.length>0&&i.set(f.id,h)}D(f)&&f.children.forEach((p,h)=>{let b=f.children[h-1],$=f.children[h+1];b&&r.set(p.id,b.id),$&&o.set(p.id,$.id)})});let u=new Map;for(let f of s){let l=t.get(f.id);for(;l!==void 0;){let p=n.get(l);if(!p||!Ae(p))break;l=t.get(l)}l!==void 0&&u.set(f.id,l)}let a=new Map,c=new Map,d=f=>{if(D(f)){if(!Ae(f)){let l=fi(f);l.forEach((p,h)=>{let b=l[h-1],$=l[h+1];b&&a.set(p.id,b.id),$&&c.set(p.id,$.id)})}for(let l of f.children)d(l)}};return d(e.root),{rootId:e.root.id,byId:n,parentOf:t,prevOf:r,nextOf:o,layoutParentOf:u,layoutPrevOf:a,layoutNextOf:c,scopeOf:i,order:s}}function fi(e){let n=[];for(let t of e.children)D(t)&&Ae(t)?n.push(...fi(t)):n.push(t);return n}function Ge(e,n,t){if(e.kind==="relRef"){let i=ra(e.word,n,t);return i===void 0?{ok:!1,message:`${n} has no ${e.word}`}:{ok:!0,nodeId:i,edge:e.edge}}let r=e.path[e.path.length-1]??"",o=e.path.slice(0,-1).join(".");if(!ke(r))return{ok:!1,message:`"${r}" is not an edge of @${o}`};for(let i of t.scopeOf.get(n)??[]){let s=`${i}.${o}`;if(t.byId.has(s))return{ok:!0,nodeId:s,edge:r};let u=t.byId.get(i);if(u?.type==="instance"&&u.component===o)return{ok:!0,nodeId:i,edge:r}}return t.byId.has(o)?{ok:!0,nodeId:o,edge:r}:{ok:!1,message:`No node @${o}`}}function ra(e,n,t){switch(e){case"self":return n;case"root":return t.rootId;case"parent":return t.layoutParentOf.get(n);case"prev":return t.layoutPrevOf.get(n);case"next":return t.layoutNextOf.get(n)}}var hi=[["start","x1","y1"],["end","x2","y2"]];function Dr(e){return oa(hn(e))}function oa(e){let n=new Map;for(let t of e.order){if(t.type!=="connector")continue;let r={},o={},i={};for(let[s,u,a]of hi){let c=Cr(t[u],t.id,e),d=Cr(t[a],t.id,e),f=new Set([...c,...d]),[l]=f;if(f.size===1&&c.length>0&&d.length>0&&l!==void 0){r[s]=l;let p=li(t[u]),h=li(t[a]),b=ia(p,h);b!==void 0&&(o[s]=b);let $=b==="x"?p:b==="y"?h:void 0;($==="left"||$==="right"||$==="top"||$==="bottom")&&(i[s]=$)}}(r.start!==void 0||r.end!==void 0)&&n.set(t.id,{...r,sides:o,named:i})}return n}function mi(e){let n=[];for(let t of e.order){if(t.type!=="connector")continue;let r=pi(t.id,e),o=new Set;for(let[,i,s]of hi)for(let u of[i,s])for(let a of Cr(t[u],t.id,e)){if(a===t.id||o.has(a))continue;let c=e.byId.get(a)?.type;if(c==="group"||c==="canvas"){o.add(a),n.push({severity:"warning",code:"connector-no-box",message:`${t.id} follows @${a}, a ${c} with no box of its own, which reads as 0 \u2014 attach to a shape inside it`,nodeId:t.id,prop:u});continue}pi(a,e)!==r&&(o.add(a),n.push({severity:"warning",code:"connector-other-page",message:`${t.id} follows @${a}, which is on another page, so the line leaves its own \u2014 attach to a node on the same page`,nodeId:t.id,prop:u}))}}return n}function li(e){if(!F(e))return;let n=ve(e.expr);if(!n.ok)return;let t=r=>{switch(r.kind){case"nodeRef":{let o=r.path[r.path.length-1];return o!==void 0&&ke(o)?o:void 0}case"relRef":return r.edge;case"unary":return t(r.operand);case"binary":return t(r.left)??t(r.right);case"number":case"token":case"percent":return}};return t(n.ast)}function ia(e,n){let t=e==="left"||e==="right",r=n==="top"||n==="bottom";if(t&&!r)return"x";if(r&&!t)return"y"}function Cr(e,n,t){if(!F(e))return[];let r=ve(e.expr);if(!r.ok)return[];let o=[],i=s=>{switch(s.kind){case"nodeRef":case"relRef":{if(s.kind==="relRef"&&(s.word==="self"||s.word==="parent"))return;let u=Ge(s,n,t);u.ok&&!o.includes(u.nodeId)&&o.push(u.nodeId);return}case"unary":i(s.operand);return;case"binary":i(s.left),i(s.right);return;case"number":case"token":case"percent":return}};return i(r.ast),o}function pi(e,n){let t=e;for(;t!==void 0;){let r=n.parentOf.get(t);if(r===n.rootId)return n.byId.get(t)?.type==="frame"?t:void 0;t=r}}function Vr(e){let n=[...Wt(e.root),...hr(e.root)],t=hn(e),r=sa(t),o=new Set;ca(r,n),da(r,e,t,o,n),n.push(...mi(t));let i=fa(r);la(r,i,n);let s=pa(r,i,e,t,o,n);return{nodes:ma(e.root,s,r,n),problems:n}}function sa(e){let n=new Map;for(let t of e.order){t.type==="connector"&&ua(t.id,n);let r=t;for(let o of Mn(t)){let i=r[o]??aa(t,o,e);i!==void 0&&n.set(G(t.id,o),{nodeId:t.id,prop:o,value:i,deps:[]})}}return n}function ua(e,n){let t={x:["x1","x2",Math.min],y:["y1","y2",Math.min],w:["x1","x2",(r,o)=>Math.abs(o-r)],h:["y1","y2",(r,o)=>Math.abs(o-r)]};for(let[r,[o,i,s]]of Object.entries(t))n.set(G(e,r),{nodeId:e,prop:r,value:0,deps:[G(e,o),G(e,i)],derive:u=>s(u(o),u(i))})}function aa(e,n,t){if(!(e.type!=="instance"||n!=="w"&&n!=="h")&&t.byId.get(e.component)?.type==="frame")return pe(`@${e.component}.${n}`)}function ca(e,n){for(let t of e.values()){if(!F(t.value))continue;let r=ve(t.value.expr);if(r.ok){t.ast=r.ast;continue}n.push({severity:"error",code:"expression-syntax",message:r.message,nodeId:t.nodeId,prop:t.prop})}}function da(e,n,t,r,o){for(let i of e.values()){if(!i.ast||i.derive)continue;let s=new Set,u=a=>{switch(a.kind){case"number":return;case"token":{let c=U(n)[a.name];typeof c!="number"&&o.push({severity:"error",code:c===void 0?"unknown-token":"token-not-a-number",message:c===void 0?`Unknown token $${a.name}`:`Token $${a.name} is not a number`,nodeId:i.nodeId,prop:i.prop});return}case"percent":{let c=wt(i.prop);if(!c)return;let d=t.layoutParentOf.get(i.nodeId),f=d===void 0?void 0:G(d,c);if(f===void 0||!e.has(f)){o.push({severity:"error",code:"percent-without-parent",message:`${i.nodeId}.${i.prop} uses a percentage but has no parent to measure against`,nodeId:i.nodeId,prop:i.prop});return}s.add(f);return}case"nodeRef":case"relRef":{let c=Ge(a,i.nodeId,t);if(!c.ok){r.add(a),o.push({severity:"error",code:"unknown-reference",message:c.message,nodeId:i.nodeId,prop:i.prop});return}let d=l=>{e.has(l)&&s.add(l)},f=Ir(c.edge);if(!f){for(let l of Nr(c.edge))d(G(c.nodeId,l));return}for(let l of Rr(c.nodeId,i.nodeId,t).keys())d(G(l,f));Pr(c.edge)!==0&&d(G(c.nodeId,f==="x"?"w":"h"));return}case"unary":u(a.operand);return;case"binary":u(a.left),u(a.right);return}};u(i.ast),i.deps=[...s]}}function fa(e){let n=new Map,t=new Map;for(let[i,s]of e){n.set(i,s.deps.length);for(let u of s.deps){let a=t.get(u);a?a.push(i):t.set(u,[i])}}let r=[];for(let[i,s]of n)s===0&&r.push(i);let o=[];for(let i=0;i<r.length;i++){let s=r[i];o.push(s);for(let u of t.get(s)??[]){let a=(n.get(u)??0)-1;n.set(u,a),a===0&&r.push(u)}}return o}function la(e,n,t){if(n.length===e.size)return;let r=new Set(n);for(let[o,i]of e)r.has(o)||t.push({severity:"error",code:"cycle",message:`${i.nodeId}.${i.prop} is part of a dependency cycle`,nodeId:i.nodeId,prop:i.prop})}function pa(e,n,t,r,o,i){let s=new Map,u=(a,c)=>s.get(G(a,c))??0;for(let a of n){let c=e.get(a);if(c){if(c.derive){s.set(a,c.derive(d=>u(c.nodeId,d)));continue}if(!F(c.value)){s.set(a,c.value);continue}if(!c.ast){s.set(a,0);continue}s.set(a,gi(c.ast,c,t,r,o,i,u))}}return s}function gi(e,n,t,r,o,i,s){let u=a=>gi(a,n,t,r,o,i,s);switch(e.kind){case"number":return e.value;case"token":{let a=U(t)[e.name];return typeof a=="number"?a:0}case"percent":{let a=wt(n.prop);if(!a)return e.value/100;let c=r.layoutParentOf.get(n.nodeId);return c===void 0?0:e.value/100*s(c,a)}case"nodeRef":case"relRef":{if(o.has(e))return 0;let a=Ge(e,n.nodeId,r);if(!a.ok)return 0;let c=Ir(a.edge);if(!c)return _r(a.edge,s(a.nodeId,"x"),s(a.nodeId,"y"),s(a.nodeId,"w"),s(a.nodeId,"h"));let d=Pr(a.edge)*s(a.nodeId,c==="x"?"w":"h");for(let[f,l]of Rr(a.nodeId,n.nodeId,r))d+=l*s(f,c);return d}case"unary":{let a=u(e.operand);return e.op==="-"?-a:a}case"binary":{let a=u(e.left),c=u(e.right);if(e.op==="/"&&c===0)return i.push({severity:"error",code:"divide-by-zero",message:`${n.nodeId}.${n.prop} divides by zero`,nodeId:n.nodeId,prop:n.prop}),0;let d=ha(e.op,a,c);return Number.isFinite(d)?d:(i.push({severity:"error",code:"not-a-number",message:`${n.nodeId}.${n.prop} did not produce a finite number`,nodeId:n.nodeId,prop:n.prop}),0)}}}function ha(e,n,t){switch(e){case"+":return n+t;case"-":return n-t;case"*":return n*t;case"/":return n/t}}function ma(e,n,t,r){let o=new Map,i=(u,a)=>n.get(G(u,a))??0,s=(u,a,c)=>{let d=i(u.id,"x"),f=i(u.id,"y"),l=i(u.id,"w"),p=i(u.id,"h"),h={};for(let S of Mn(u)){let N=G(u.id,S);t.has(N)&&(h[S]=n.get(N)??0)}(l<0||p<0)&&r.push({severity:"warning",code:"negative-size",message:`${u.id} resolved to a negative size`,nodeId:u.id});let b=a+d,$=c+f;if(o.set(u.id,{id:u.id,type:u.type,x:d,y:f,w:l,h:p,left:d,top:f,right:d+l,bottom:f+p,cx:d+l/2,cy:f+p/2,absX:b,absY:$,values:h}),D(u))for(let S of u.children)s(S,b,$)};return s(e,0,0),o}var yi="round";function ee(e){if(e.kind==="frame")return;let n=e.stroke,t=e.strokeWidth??0;if(n===void 0||!(t>0))return;let r=e.dash??[];return e.kind==="text"?{paint:n,width:t,dash:r,align:"center",cap:"butt",join:yi}:{paint:n,width:t,dash:r,align:e.kind==="connector"?"center":e.strokeAlign??"center",cap:e.cap??"butt",join:e.kind==="vector"?e.join:"miter"}}function Lr(e){if(e.mask!==void 0)return{contours:e.mask.contours,rule:e.mask.rule};let n=t=>J(t,r=>({x:e.x+r.x,y:e.y+r.y}));switch(e.kind){case"text":case"connector":return;case"vector":return{contours:e.contours,rule:e.rule};case"ellipse":return e.w>0&&e.h>0?{contours:n(cn(e.w,e.h)),rule:"nonzero"}:void 0;case"rect":case"image":case"border":case"frame":return e.w>0&&e.h>0?{contours:n(we(e.w,e.h,e.radii)),rule:"nonzero"}:void 0}}function vt(e,n){if(n.align==="center"||e.mask!==void 0||e.kind!=="rect"&&e.kind!=="ellipse"&&e.kind!=="image"&&e.kind!=="border")return;let t=(n.align==="inside"?-n.width:n.width)/2,r=e.w+t*2,o=e.h+t*2;if(!(r>0&&o>0))return;let i=e.kind==="ellipse"?{tl:0,tr:0,br:0,bl:0}:{tl:kt(e.radii.tl,t),tr:kt(e.radii.tr,t),br:kt(e.radii.br,t),bl:kt(e.radii.bl,t)};return{x:e.x-t,y:e.y-t,w:r,h:o,radii:i}}function kt(e,n){return e<=0?0:Math.max(0,e+n)}function jr(e,n){return n.align!=="center"&&n.dash.length>0&&vt(e,n)===void 0}function Br(e){let n=[];for(let t of e)for(let r=0;r<$e(t);r+=1){let o=an(Ue(t,r),1);for(let i=1;i<o.length;i+=1)if(n.push([o[i-1],o[i]]),n.length>ga)return!1}for(let t=0;t<n.length;t+=1)for(let r=t+1;r<n.length;r+=1)if(ya(n[t],n[r]))return!0;return!1}var ga=600;function ya(e,n){let t=(a,c,d)=>(c.x-a.x)*(d.y-a.y)-(c.y-a.y)*(d.x-a.x),r=t(n[0],n[1],e[0]),o=t(n[0],n[1],e[1]),i=t(e[0],e[1],n[0]),s=t(e[0],e[1],n[1]),u=1e-9;return(r>u&&o<-u||r<-u&&o>u)&&(i>u&&s<-u||i<-u&&s>u)}function Fr(e){return e.width*2*4+1}function Ur(e,n,t){let r=n+1,o=e.reduce((a,c)=>a+c,0);if(e.length===0||!(o>0)||n*t/o>xa)return{array:[r,r],offset:r*(1-t)};let i=n*t,s=[],u=0;for(let a=0;u<i;a+=1){let c=e[a%e.length],d=Math.min(c,i-u);s.push(d),u+=d}return s.length%2===1?s.push(r):s.length>0?s[s.length-1]=s[s.length-1]+r:s.push(0,r),{array:s,offset:0}}var xa=2e3;function zr(e){let n=ze({x:e.x,y:e.y,w:e.w,h:e.h},e.rotation),t=We(e.mask.contours);if(!t)return n;let r=Wr(n,t),o={...r,w:Math.max(0,r.w),h:Math.max(0,r.h)},i=Ot(e);if(!(i>0))return o;let s=Math.min(o.w>0?o.x:1/0,t.x-i),u=Math.min(o.h>0?o.y:1/0,t.y-i),a=Math.max(o.x+o.w,t.x+t.w+i),c=Math.max(o.y+o.h,t.y+t.h+i);return{x:s,y:u,w:a-s,h:c-u}}var gn=250;function Xe(e){return e!==void 0&&e>0?Math.ceil(e*1.5):0}function Gr(e,n){let t=e.indexOf(n);if(t<=0||n.backdrop===void 0)return[];let r=n.backdrop.page,o=0;if(r!==void 0)for(let i=t-1;i>=0;i-=1){let s=e[i];if(s.id===r&&s.kind==="frame"){o=i;break}}return e.slice(o,t).map(i=>{if(i.backdrop===void 0)return i;let{backdrop:s,...u}=i;return u})}function Xr(e){return e.lines.filter(n=>n.spans.length>0)}function yn(e){switch(e.kind){case"text":{let n=Xr(e),t=Math.max(e.w,...n.map(i=>i.w)),r=Math.max(e.y+e.h,...n.map(i=>i.y+i.h)),o=Ot(e);return{x:e.x-o,y:e.y-o,w:t+o*2,h:r-e.y+o*2}}case"connector":{let n=Zn(e.strokeWidth)/2+e.strokeWidth;return{x:e.x-n,y:e.y-n,w:e.w+n*2,h:e.h+n*2}}case"vector":{let n=We(e.contours)??{x:e.x,y:e.y,w:e.w,h:e.h},t=e.stroke!==void 0?e.strokeWidth*2:0;return{x:n.x-t,y:n.y-t,w:n.w+t*2,h:n.h+t*2}}case"rect":case"ellipse":case"image":case"border":{let n=Ot(e);return{x:e.x-n,y:e.y-n,w:e.w+n*2,h:e.h+n*2}}case"frame":return{x:e.x,y:e.y,w:e.w,h:e.h}}}function Ot(e){if(e.kind==="frame"||e.stroke===void 0)return 0;let n=e.strokeWidth??0;if(!(n>0))return 0;let t=e.kind==="text"||e.kind==="connector"?void 0:e.strokeAlign;return t==="inside"?0:t==="outside"?n:n/2}function Tt(e,n,t){let r=e.x,o=e.y,i=e.x+e.w,s=e.y+e.h;for(let a of n){if(a.inset)continue;let c=a.spread+a.blur;r=Math.min(r,e.x+a.x-c),o=Math.min(o,e.y+a.y-c),i=Math.max(i,e.x+e.w+a.x+c),s=Math.max(s,e.y+e.h+a.y+c)}let u=Xe(t);return{x:r-u,y:o-u,w:i-r+u*2,h:s-o+u*2}}var wi="vd-paint-";var Mt="#CBD5E1",ki="#FFFFFF";function vi(e,n,t={}){let r=[...n.problems],o=[],i=[],s=t.measure??$t(),u=Ra(U(e),r,e,t.resolveAsset),a=u.paint,c=new Map,d=Re(e.root),f=ht(e.root),l=g=>{if(!pt(g))return{};let m=f.links.get(g.id);if(m===void 0)return{};let w=va(e,n,m);return w?{mask:w}:(r.push({severity:"warning",code:"mask-empty",message:`${g.id}: its mask ${m} has no area, so it is drawn unmasked \u2014 give the shape a size`,nodeId:g.id,prop:"mask"}),{})},p,h=new Map,b=new Map,$=new Map,S=new Map;C(e.root,(g,m)=>{if(m&&b.set(g.id,m.id),"hidden"in g&&g.hidden===!0)return!1;let w=m?c.get(m.id):void 0,x=n.nodes.get(g.id);if(!x||f.shapes.has(g.id)){c.set(g.id,w);return}let E=g.type==="frame"?g:g.type==="instance"?d.get(g.component):void 0;if(g.type==="instance"&&!E){c.set(g.id,w);return}let k=E&&g.type==="instance"?n.nodes.get(E.id):x,M=bi(k?.values.blur,g.id,"blur",r);M>0&&$.set(g.id,M);let R=bi(k?.values.backdrop,g.id,"backdrop",r);if(R>0&&S.set(g.id,R),E){g.type==="frame"&&g.skip===!0&&m!==e.root&&r.push({severity:"warning",code:"skip-not-a-page",message:`${g.id}: skip only applies to a page, a frame at the top level`,nodeId:g.id,prop:"skip"});let I={x:x.absX,y:x.absY,w:Math.max(0,x.w),h:Math.max(0,x.h)},W=g.type==="frame"?x:n.nodes.get(E.id),de=Te(W?.values??{},I.w,I.h);c.set(g.id,E.clip===!0?g.id:w),E.clip===!0&&i.push({id:g.id,...I,...oe(de)?{}:{radii:de},parent:w}),o.push({kind:"frame",id:g.id,...I,background:a(E.background,g.id,"background",I,I),radii:de,clip:w,blend:E.blend??"normal",shadows:ue(E.shadow,g.id,U(e),r),rotation:0});let P=a(E.stroke,g.id,"stroke",I),Z=W?.values.strokeWidth??0;P!==void 0&&Z>0&&h.set(g.id,{kind:"border",id:g.id,...I,radii:de,stroke:P,strokeWidth:Z,...Ee(E,g.id,r,!0),...E.cap===void 0?{}:{cap:E.cap},clip:w,blend:"normal",shadows:[],rotation:0});return}if(c.set(g.id,w),g.type==="text"){o.push(Ea(g,x,e,s,r,w,a));return}if(g.type==="video"){let I=St(x),W=Da(g,e,t,r);o.push({kind:"image",id:g.id,...I,href:W.href,fit:g.fit??"fill",radii:Te(x.values,I.w,I.h),opacity:Se(x.values.opacity??1),...xi(g,x.values,I,a,r),clip:w,blend:g.blend??"normal",shadows:ue(g.shadow,g.id,U(e),r),rotation:x.values.rotation??0,...W.video===void 0?{}:{video:W.video},...W.href===void 0&&W.video?.clip===void 0?{}:l(g)});return}if(g.type==="image"){let I=St(x),W=Va(g,e,t.resolveAsset,r);o.push({kind:"image",id:g.id,...I,href:W,fit:g.fit??"fill",radii:Te(x.values,I.w,I.h),opacity:Se(x.values.opacity??1),...xi(g,x.values,I,a,r),clip:w,blend:g.blend??"normal",shadows:ue(g.shadow,g.id,U(e),r),rotation:x.values.rotation??0,...W===void 0?{}:l(g)});return}if(g.type==="ellipse"){let I=St(x);o.push({kind:"ellipse",id:g.id,...I,fill:a(g.fill,g.id,"fill",I,I)??Mt,stroke:a(g.stroke,g.id,"stroke",I),strokeWidth:x.values.strokeWidth??0,...Ee(g,g.id,r,!0),...g.cap===void 0?{}:{cap:g.cap},opacity:Se(x.values.opacity??1),clip:w,blend:g.blend??"normal",shadows:ue(g.shadow,g.id,U(e),r),rotation:x.values.rotation??0});return}if(g.type==="connector"){p??=Dr(e),o.push(_a(g,x,p.get(g.id)?.sides??{},r,w,a,ue(g.shadow,g.id,U(e),r)));return}if(g.type==="vector"){o.push(Na(g,x,r,w,a,ue(g.shadow,g.id,U(e),r)));return}if(g.type!=="rect")return;let V=St(x);o.push({kind:"rect",id:g.id,...V,fill:a(g.fill,g.id,"fill",V,V)??Mt,stroke:a(g.stroke,g.id,"stroke",V),strokeWidth:x.values.strokeWidth??0,...Ee(g,g.id,r,!0),...g.cap===void 0?{}:{cap:g.cap},radii:Te(x.values,V.w,V.h),opacity:Se(x.values.opacity??1),clip:w,blend:g.blend??"normal",shadows:ue(g.shadow,g.id,U(e),r),rotation:x.values.rotation??0})}),h.size>0&&wa(o,h,b),($.size>0||S.size>0)&&ka(o,{blurs:$,backdrops:S,parents:b,root:e.root.id}),$a(o,g=>b.get(g)===e.root.id,r);let N=n.nodes.get(e.root.id),T=e.root.w!==void 0&&e.root.h!==void 0,A=T?{x:0,y:0,width:Math.max(0,N?.w??0),height:Math.max(0,N?.h??0)}:Sa(o,i),_={x:A.x,y:A.y,w:A.width,h:A.height},O=a(e.root.background,e.root.id,"background",_,_);return{...A,background:T?O??ki:O,items:o,clips:i,gradients:u.gradients,problems:r}}function Ee(e,n,t,r){let o=Qt(e.dash);e.dash!==void 0&&o.length===0&&t.push({severity:"error",code:"invalid-dash",message:`${n}: dash ${JSON.stringify(e.dash)} is not a dash array like "6 4", so the stroke is solid`,nodeId:n,prop:"dash"});let i=e.strokeAlign,s;return(i==="inside"||i==="outside")&&(r?s=i:e.stroke!==void 0&&t.push({severity:"warning",code:"stroke-align-open",message:`${n}: an ${i} stroke needs a closed path, so it is drawn centred \u2014 close every contour with Z, or set strokeAlign=center`,nodeId:n,prop:"strokeAlign"})),{...o.length===0?{}:{dash:o},...s===void 0?{}:{strokeAlign:s}}}function xi(e,n,t,r,o){let i=r(e.stroke,e.id,"stroke",t),s=n.strokeWidth??0;return i===void 0||!(s>0)?{}:{stroke:i,strokeWidth:s,...Ee(e,e.id,o,!0),...e.cap===void 0?{}:{cap:e.cap}}}function ba(e,n,t,r,o){let i=r(e.stroke,e.id,"stroke",t),s=n.strokeWidth??0;if(i===void 0||!(s>0))return{};let{dash:u}=Ee(e,e.id,o,!1);return{stroke:i,strokeWidth:s,...u===void 0?{}:{dash:u}}}function $a(e,n,t){let r=(o,i,s)=>{t.push({severity:"warning",code:i,message:`${o}: ${s}`,nodeId:o,prop:"strokeAlign"})};for(let o of e){let i=ee(o);if(!i||(o.kind==="border"&&i.align!=="inside"&&n(o.id)&&r(o.id,"stroke-page-edge",`the page's own edge cuts off its ${i.align==="outside"?"outside":"centred"} border in every export \u2014 use strokeAlign=inside`),i.align==="center"))continue;jr(o,i)&&r(o.id,"stroke-align-dash",`a dashed ${i.align} stroke on a path or a mask is cut along the outline, so its dashes' ends are not exact \u2014 use strokeAlign=center for exact dashes`);let s=o.mask?.contours??(o.kind==="vector"?o.contours:void 0);s&&Br(s)&&r(o.id,"stroke-align-overlap",`its outline crosses itself, so an ${i.align} stroke draws across the fill \u2014 make a clean outline with merge union first, or use strokeAlign=center`)}}function wa(e,n,t){let r=new Map;e.forEach((s,u)=>{for(let a=s.id;a!==void 0;a=t.get(a))n.has(a)&&r.set(a,u)});let o=s=>{let u=0;for(let a=t.get(s);a!==void 0;a=t.get(a))u+=1;return u},i=[...n.values()].map(s=>({border:s,after:r.get(s.id)??-1,depth:o(s.id)})).filter(s=>s.after>=0).sort((s,u)=>u.after-s.after||s.depth-u.depth);for(let{border:s,after:u}of i)e.splice(u+1,0,s)}function bi(e,n,t,r){return e===void 0||e===0?0:e>0?e>gn?(r.push({severity:"warning",code:"invalid-blur",message:`${n}: ${t} ${String(e)} is more than ${gn}, so it is drawn at ${gn}`,nodeId:n,prop:t}),gn):e:(r.push({severity:"warning",code:"invalid-blur",message:`${n}: ${t} ${String(e)} is not a blur, so it is drawn unblurred \u2014 write 0 or more`,nodeId:n,prop:t}),0)}function $i(e){return Math.sqrt(e.reduce((n,t)=>n+t*t,0))}function ka(e,n){let{blurs:t,backdrops:r,parents:o,root:i}=n,s=new Map;for(let u of e)u.kind==="frame"&&s.set(u.id,u);e.forEach((u,a)=>{let c=u.kind==="frame"||u.kind==="border",d=c?0:t.get(u.id)??0,f=[];for(let T=c?u.id:o.get(u.id);T!==void 0;T=o.get(T)){let A=s.get(T);A&&(t.get(T)??0)>0&&f.push(A)}let l=f.every(T=>T.clip===u.clip),p=$i(l?[d,...f.map(T=>t.get(T.id)??0)]:[d]),h=f[f.length-1],b=l||h===void 0?void 0:{id:h.id,blur:$i(f.map(T=>t.get(T.id)??0)),clip:h.clip,x:h.x,y:h.y,w:h.w,h:h.h},$=r.get(u.id)??0,S=$>0&&(u.kind==="rect"||u.kind==="ellipse"||u.kind==="vector"||u.kind==="frame");if(!(p>0)&&!b&&!S)return;let N;for(let T=u.id;T!==void 0;T=o.get(T))o.get(T)===i&&s.has(T)&&(N=T);e[a]={...u,...p>0?{blur:p}:{},...b?{veil:b}:{},...S?{backdrop:{blur:$,page:N}}:{}}})}function va(e,n,t){let r=X(e.root,t),o=n.nodes.get(t);if(!r||!o)return;let i=mr(r,{x:o.absX,y:o.absY,w:o.w,h:o.h},o.values),s=i?We(i.contours):void 0;if(!(!i||!s||!(s.w>0)||!(s.h>0)))return{id:t,d:q(i.contours),contours:i.contours,rule:i.rule}}function Sa(e,n){let t=new Map;for(let u of n){let a=u.parent===void 0?void 0:t.get(u.parent);t.set(u.id,a?Wr(u,a):u)}let r=1/0,o=1/0,i=-1/0,s=-1/0;for(let u of e){let a=u.kind==="text"&&Xr(u).length>0?Math.max(u.h,u.height):u.h,c=u.clip===void 0?void 0:t.get(u.clip),d=u.kind==="connector"?yn(u):{x:u.x,y:u.y,w:u.w,h:a},f=ze(Tt(d,u.shadows,u.blur),u.rotation,se(u)),l=c?Wr(f,c):f;l.w<=0||l.h<=0||(r=Math.min(r,l.x),o=Math.min(o,l.y),i=Math.max(i,l.x+l.w),s=Math.max(s,l.y+l.h))}return Number.isFinite(r)?{x:r,y:o,width:i-r,height:s-o}:{x:0,y:0,width:0,height:0}}function Wr(e,n){let t=Math.max(e.x,n.x),r=Math.max(e.y,n.y);return{x:t,y:r,w:Math.min(e.x+e.w,n.x+n.w)-t,h:Math.min(e.y+e.h,n.y+n.h)-r}}function Jr(e,n={}){return vi(e,Vr(e),n)}function Ea(e,n,t,r,o,i,s){let u=Math.max(0,n.w),a=Math.max(0,n.h),c={x:n.absX,y:n.absY,w:u,h:a},d=Sr(e,n.values,u,t.fonts,p=>s(p,e.id,"fill",c)??bt,r);!d.lines.every(p=>p.spans.length===0)&&d.height>a+.5&&o.push({severity:"warning",code:"text-overflow",message:`${e.id} needs ${Math.ceil(d.height)}px but its height is ${Math.round(a)}px`,nodeId:e.id,prop:"h"}),Oa(e,t,o);let l=n.absY+Er(e,a,d.height);return{kind:"text",id:e.id,x:n.absX,y:n.absY,w:u,h:a,clip:i,blend:e.blend??"normal",shadows:ue(e.shadow,e.id,U(t),o),rotation:n.values.rotation??0,opacity:Se(n.values.opacity??1),...ba(e,n.values,c,s,o),height:d.height,lines:d.lines.map(p=>({y:l+p.y,h:p.h,baseline:l+p.baseline,w:p.w,spans:p.spans.map(h=>({text:h.text,x:n.absX+h.x,y:l+p.baseline,w:h.w,style:h.style})),...p.style?{style:p.style}:{}}))}}function Oa(e,n,t){if(typeof e.content!="string")for(let r of e.content){if(typeof r=="string"||r.link===void 0)continue;let o=le(r.link);if(!o){t.push({severity:"warning",code:"invalid-link",message:`${e.id}: links go to https:, mailto: or #<frame>, not ${JSON.stringify(r.link)}`,nodeId:e.id,prop:"content"});continue}o.kind==="frame"&&!Ma(n,o.id)&&t.push({severity:"warning",code:"link-target-missing",message:`${e.id}: links to #${o.id}, which is not a frame`,nodeId:e.id,prop:"content"})}}function Ma(e,n){let t=!1;return C(e.root,r=>{if(t)return!1;r.id===n&&r.type==="frame"&&(t=!0)}),t}var mn=new Map,Ta=512;function Aa(e){let n=mn.get(e);if(n)return n;let t=on(e);return mn.size>=Ta&&mn.delete(mn.keys().next().value),mn.set(e,t),t}function Na(e,n,t,r,o,i){let s=Math.max(0,n.w),u=Math.max(0,n.h),a={x:n.absX,y:n.absY,w:s,h:u},{contours:c,error:d}=Aa(e.d);d!==void 0&&t.push({severity:"error",code:"bad-path",message:`${e.id}: ${d}`,nodeId:e.id,prop:"d"}),e.view!==void 0&&Hn(e.view)===void 0&&t.push({severity:"warning",code:"bad-view",message:`${e.id}: view must be four numbers, like "0 0 24 24"`,nodeId:e.id,prop:"view"});let f=J(c,un(sn(e.view,s,u),a));return{kind:"vector",id:e.id,...a,d:q(f),contours:f,fill:o(e.fill,e.id,"fill",a,Ia(a,We(f)))??Mt,stroke:o(e.stroke,e.id,"stroke",a),strokeWidth:n.values.strokeWidth??0,...Ee(e,e.id,t,c.length>0&&c.every(l=>l.closed)),opacity:Se(n.values.opacity??1),rule:e.rule??"nonzero",cap:e.cap??"butt",join:e.join??"miter",clip:r,blend:e.blend??"normal",shadows:i,rotation:n.values.rotation??0}}function _a(e,n,t,r,o,i,s){let u=n.absX-n.x,a=n.absY-n.y,c={x1:u+(n.values.x1??0),y1:a+(n.values.y1??0),x2:u+(n.values.x2??0),y2:a+(n.values.y2??0)},d=qt(c),f=Math.max(0,n.values.strokeWidth??Yt),l=e.route??"straight",p=e.start??"none",h=e.end??"none",b=Zt(c,l,p,h,f,t),$=[b.route],{dash:S}=Ee(e,e.id,r,!1);return{kind:"connector",id:e.id,...d,...c,route:l,sides:t,start:p,end:h,d:q($),contours:$,filled:{d:q(b.filled),contours:b.filled},lined:{d:q(b.lined),contours:b.lined},stroke:i(e.stroke,e.id,"stroke",d)??Ht,strokeWidth:f,...S===void 0?{}:{dash:S},opacity:Se(n.values.opacity??1),cap:e.cap??"butt",clip:o,blend:e.blend??"normal",shadows:s,rotation:0}}function Si(e,n,t,r,o){if(e===void 0)return;if(F(e)){o.push({severity:"warning",code:"expression-not-supported",message:`Expressions are not supported for ${r} yet; grammar v0 is numeric only`,nodeId:t,prop:r});return}let i=n[e];if(i===void 0)return e;if(typeof i=="string")return i;o.push({severity:"error",code:"token-not-a-colour",message:`Token $${e} is a number, not a colour`,nodeId:t,prop:r})}function Ia(e,n){if(!n)return e;let t=Math.min(e.x,n.x),r=Math.min(e.y,n.y);return{x:t,y:r,w:Math.max(e.x+e.w,n.x+n.w)-t,h:Math.max(e.y+e.h,n.y+n.h)-r}}function St(e){return{x:e.absX,y:e.absY,w:Math.max(0,e.w),h:Math.max(0,e.h)}}function Ra(e,n,t,r){let o=[],i=[],s=new Map,u=(l,p,h)=>{let b=[...s.keys()].filter(S=>S.startsWith(`${p}\0${h}\0`)).length,$=`${wi}${p}-${h}${b===0?"":`-${b+1}`}`;return s.set(l,$),$},a=(l,p,h)=>{n.some($=>$.code==="invalid-paint"&&$.nodeId===l&&$.message===h)||n.push({severity:"error",code:"invalid-paint",message:h,nodeId:l,prop:p})},c=(l,p,h,b)=>{let $=yt(l);if("error"in $)return a(p,h,`${p}: ${$.error}`);if($.kind==="solid")return l;let S=`${p}\0${h}\0${l}`,N=s.get(S);if(N!==void 0)return`url(#${N})`;let T=u(S,p,h),A=yr($.stops).map(_=>({offset:_.at,colour:Ei(_.colour,e,p,h,n)}));return o.push(Ca($,T,b,Pa(A))),`url(#${T})`},d=(l,p,h,b)=>{let $=t.assets[l.asset];if(!$){n.push({severity:"warning",code:"fill-asset-missing",message:`${p}: ${h} names image ${JSON.stringify(l.asset)}, which is not one of the document's assets, so that layer is not drawn \u2014 add the picture with vd_add_asset, or take the layer out`,nodeId:p,prop:h});return}let S=r?.($,l.asset);if(S===void 0){n.push({severity:"warning",code:"unresolved-asset",message:`The bytes for asset "${l.asset}" are not available here`,nodeId:p,prop:h});return}return{kind:"image",href:S,fit:l.fit,...b}};return{paint:(l,p,h,b,$)=>{let S=Si(l,e,p,h,n);if(S===void 0)return;if(/url\(/i.test(S))return a(p,h,`${p}: a paint is a colour or a gradient, not ${JSON.stringify(S)}`);let N=pn(S);if(N.length===1&&!mt(S))return c(S,p,h,b);if($===void 0)return a(p,h,`${p}: ${h} takes one colour or gradient, not ${N.length>1?"a list of paints":"a picture"}; only a shape's fill and a frame's background take layers`);let T=[];for(let m of N){let w=e[m],x=typeof w=="string"?w:m;if(/url\(/i.test(x)){a(p,h,`${p}: a paint is a colour or a gradient, not ${JSON.stringify(x)}`);continue}for(let E of pn(x)){let k=gr(E);if("error"in k){a(p,h,`${p}: ${k.error}`);continue}let M=k.kind==="image"?d(k,p,h,b):(R=>R===void 0?void 0:{kind:"paint",paint:R})(c(E,p,h,b));M&&T.push(M)}}if(T.length===0)return;let A=T[0];if(T.length===1&&A.kind==="paint")return A.paint;let _=`${p}\0${h}\0${S}\0layers`,O=s.get(_);if(O!==void 0)return`url(#${O})`;let g=u(_,p,h);return i.push({id:g,kind:"layers",...$,layers:[...T].reverse()}),`url(#${g})`},get gradients(){return[...o,...i]}}}function ue(e,n,t,r){let o=Si(e,t,n,"shadow",r);if(o===void 0)return[];let i=br(o);return"error"in i?(r.push({severity:"error",code:"invalid-shadow",message:`${n}: ${i.error}`,nodeId:n,prop:"shadow"}),[]):i.shadows.map(s=>({...s,colour:Ei(s.colour,t,n,"shadow",r)}))}function Pa(e){return e.map((n,t)=>{if(n.colour.trim().toLowerCase()!=="transparent")return n;let r=[e[t-1],e[t+1]].find(o=>o!==void 0&&o.colour.trim().toLowerCase()!=="transparent");return r===void 0?n:{offset:n.offset,colour:r.colour,opacity:0}})}function Ei(e,n,t,r,o){let i=n[e];return i===void 0?e:typeof i=="string"&&!gt(i)?i:(o.push({severity:"error",code:"invalid-paint",message:`${t}: a gradient stop names $${e}, which is not a colour`,nodeId:t,prop:r}),"transparent")}function Ca(e,n,t,r){if(e.kind==="linear"){let c=e.angle*Math.PI/180,d=Math.sin(c),f=-Math.cos(c),l=(Math.abs(t.w*d)+Math.abs(t.h*f))/2,p=t.x+t.w/2,h=t.y+t.h/2;return{id:n,kind:"linear",x1:Et(p-d*l),y1:Et(h-f*l),x2:Et(p+d*l),y2:Et(h+f*l),stops:r}}let o=t.x+t.w*e.cx,i=t.y+t.h*e.cy,s={x:Math.max(o-t.x,t.x+t.w-o),y:Math.max(i-t.y,t.y+t.h-i)};if(e.shape==="circle"||s.x===0||s.y===0){let c=Math.hypot(s.x,s.y);return{id:n,kind:"radial",cx:o,cy:i,rx:c,ry:c,stops:r}}let u=s.x/s.y,a=Math.hypot(s.x/u,s.y);return{id:n,kind:"radial",cx:o,cy:i,rx:a*u,ry:a,stops:r}}function Et(e){return Math.round(e*1e6)/1e6}function Se(e){return Math.min(Math.max(e,0),1)}function Da(e,n,t,r){let o=F(e.src)?void 0:e.src,i=o===void 0?void 0:n.assets[o];if(!i||o===void 0)return r.push({severity:"warning",code:"missing-asset",message:`No clip for ${JSON.stringify(o??e.src)} yet: a video slot waiting for one`,nodeId:e.id,prop:"src"}),{href:void 0};if(!$r(i))return r.push({severity:"error",code:"not-a-video",message:`${e.id}: src=${o} is ${i.type}, not a clip \u2014 a video plays ${xt.join(" or ")}; use an image for a picture`,nodeId:e.id,prop:"src"}),{href:void 0};i.bytes>26214400&&r.push({severity:"warning",code:"large-video",message:`${e.id}: clip ${o} is ${Math.round(i.bytes/1048576)} MB, and every save and every read of this document carries it \u2014 trim it, or keep it under 25 MB`,nodeId:e.id,prop:"src"});let s={...e.start===void 0?{}:{start:e.start},...e.end===void 0?{}:{end:e.end},...e.poster===void 0?{}:{poster:e.poster},...e.loop===void 0?{}:{loop:e.loop}},u=wr(s,i.ms),a=t.resolveAsset?.(i,o),c=t.resolveFrame?.(i,o,u);return a===void 0&&c===void 0&&r.push({severity:"warning",code:"unresolved-clip",message:`The frames of clip "${o}" are not available here, so it draws as a placeholder`,nodeId:e.id,prop:"src"}),{href:c,video:{asset:o,clip:a,at:u,...e.start===void 0?{}:{start:e.start},...e.end===void 0?{}:{end:e.end},loop:e.loop===!0,muted:e.muted===!0,...i.ms===void 0?{}:{ms:i.ms}}}}function Va(e,n,t,r){let o=F(e.src)?void 0:e.src,i=o===void 0?void 0:n.assets[o];if(!i){r.push({severity:"warning",code:"missing-asset",message:`No picture for ${JSON.stringify(o??e.src)} yet: an image slot waiting for one`,nodeId:e.id,prop:"src"});return}let s=t?.(i,o);return s===void 0&&r.push({severity:"warning",code:"unresolved-asset",message:`The bytes for asset "${o}" are not available here`,nodeId:e.id,prop:"src"}),s}var ce="vd-clip-";function Kr(e,n={}){let t=n.indent??" ",r={ids:n.ids??!0,prefix:n.idPrefix??""},o=y(e.width),i=y(e.height),s=`${y(e.x)} ${y(e.y)} ${o} ${i}`,u=[`<svg xmlns="http://www.w3.org/2000/svg" width="${o}" height="${i}" viewBox="${s}">`],a=n.shadowsOnly?"drops":n.insetsOnly?"insets":"all",c=e.items.filter(It),d=e.items.filter(l=>l.mask!==void 0),f=Ii(e.items);if(e.clips.length>0||e.gradients.length>0||c.length>0||d.length>0||f.length>0){u.push(`${t}<defs>`);for(let l of e.clips)u.push(t+t+Oi(l,r.prefix));for(let l of d)u.push(t+t+Bi(l,r.prefix));for(let l of e.gradients)u.push(t+t+Ai(l,r.prefix));for(let l of c)u.push(t+t+_i(l,a,r.prefix));for(let l of f)u.push(t+t+Ri(l,r.prefix));u.push(`${t}</defs>`)}e.background!==void 0&&!n.backdropsOnly&&u.push(`${t}<rect x="${y(e.x)}" y="${y(e.y)}" width="${o}" height="${i}" fill="${v(Y(e.background,r))}"/>`);for(let l of e.items){if(l.backdrop!==void 0){let h=Ci(e,l,r);h!==""&&u.push(t+h)}if(n.backdropsOnly)continue;let p=qr(l,r);p!==""&&u.push(t+p)}return u.push("</svg>"),`${u.join(`
9
+ `)}
10
+ `}function La(e){return Oi(e,"")}function Oi(e,n){let t=e.parent===void 0?"":` clip-path="url(#${v(n+ce+e.parent)})"`;return`<clipPath id="${v(n+ce+e.id)}"${t}>${H(e,e.radii)}</clipPath>`}function H(e,n,t=[],r=[]){let o=r.map(s=>`${s} `).join(""),i=t.length===0?"":` ${t.join(" ")}`;if(n===void 0||!Ti(n)){let s=n!==void 0&&!oe(n)?` rx="${y(n.tl)}"`:"";return`<rect ${o}x="${y(e.x)}" y="${y(e.y)}" width="${y(e.w)}" height="${y(e.h)}"${s}${i}/>`}return`<path ${o}d="${Mi(e,n)}"${i}/>`}function Mi(e,n){return q(J(we(e.w,e.h,n),t=>({x:e.x+t.x,y:e.y+t.y})))}function Ti(e){return!oe(e)&&!Pt(e)}function ja(e){return Ai(e,"")}function Ai(e,n){if(e.kind==="layers")return Ba(e,n);let t=e.stops.map(o=>`<stop offset="${y(o.offset)}" stop-color="${v(o.colour)}"${o.opacity===void 0?"":` stop-opacity="${y(o.opacity)}"`}/>`).join(""),r=v(n+e.id);return e.kind==="linear"?`<linearGradient id="${r}" gradientUnits="userSpaceOnUse" x1="${y(e.x1)}" y1="${y(e.y1)}" x2="${y(e.x2)}" y2="${y(e.y2)}">${t}</linearGradient>`:`<radialGradient id="${r}" gradientUnits="userSpaceOnUse" cx="0" cy="0" r="1" gradientTransform="matrix(${y(e.rx)} 0 0 ${y(e.ry)} ${y(e.cx)} ${y(e.cy)})">${t}</radialGradient>`}function Ba(e,n){let t=`x="${y(e.x)}" y="${y(e.y)}" width="${y(e.w)}" height="${y(e.h)}"`,r=e.layers.map(o=>{if(o.kind==="paint"){let i=Y(o.paint,{ids:!1,prefix:n});return`<rect ${t} fill="${v(i)}"/>`}return`<image href="${v(o.href)}" x="${y(o.x)}" y="${y(o.y)}" width="${y(o.w)}" height="${y(o.h)}" preserveAspectRatio="${Ni[o.fit]}"/>`}).join("");return`<pattern id="${v(n+e.id)}" patternUnits="userSpaceOnUse" ${t} viewBox="${y(e.x)} ${y(e.y)} ${y(e.w)} ${y(e.h)}">${r}</pattern>`}var Ni={cover:"xMidYMid slice",contain:"xMidYMid meet",fill:"none"},Fa="#94A3B8";function te(e,n){let t=e.clip===void 0?[]:[`clip-path="url(#${v(n+ce+e.clip)})"`];return e.rotation!==0&&t.push(`transform="${Yr(e)}"`),It(e)&&t.push(`filter="url(#${v(n+_t+e.id)})"`),e.blend!=="normal"&&t.push(`style="mix-blend-mode:${e.blend}"`),t}var _t="vd-shadow-";function It(e){return e.shadows.length>0||(e.blur??0)>0}function Ua(e,n="all"){return _i(e,n,"")}var Wa=20;function _i(e,n,t){let r=e.mask===void 0?yn(e):zr({...e,mask:e.mask}),o=n==="insets"?[]:e.shadows.filter(l=>!l.inset),i=n==="drops"?[]:e.shadows.filter(l=>l.inset),s=n==="all"?e.blur??0:0,u=Tt(r,o,s);for(let l of i){let p=Math.abs(l.x)+Math.abs(l.y)+Xe(l.blur)+Math.abs(l.spread);u=za(u,{x:r.x-p,y:r.y-p,w:r.w+p*2,h:r.h+p*2})}let a=2,c=[];o.forEach((l,p)=>{let h=`s${p}`,b="SourceAlpha";l.spread!==0&&(c.push(`<feMorphology in="${b}" operator="${l.spread>0?"dilate":"erode"}" radius="${y(Math.abs(l.spread))}" result="${h}m"/>`),b=`${h}m`),l.blur>0&&(c.push(`<feGaussianBlur in="${b}" stdDeviation="${y(l.blur/2)}" result="${h}b"/>`),b=`${h}b`),c.push(`<feOffset in="${b}" dx="${y(l.x)}" dy="${y(l.y)}" result="${h}o"/>`,`<feFlood flood-color="${v(l.colour)}" result="${h}c"/>`,`<feComposite in="${h}c" in2="${h}o" operator="in" result="${h}"/>`)}),i.length>0&&c.push(`<feComponentTransfer in="SourceAlpha" result="solid"><feFuncA type="linear" slope="${Wa}"/></feComponentTransfer>`),i.forEach((l,p)=>{let h=`i${p}`,b="solid";l.spread!==0&&(c.push(`<feMorphology in="${b}" operator="${l.spread>0?"erode":"dilate"}" radius="${y(Math.abs(l.spread))}" result="${h}m"/>`),b=`${h}m`),c.push(`<feComponentTransfer in="${b}" result="${h}n"><feFuncA type="table" tableValues="1 0"/></feComponentTransfer>`),b=`${h}n`,l.blur>0&&(c.push(`<feGaussianBlur in="${b}" stdDeviation="${y(l.blur/2)}" result="${h}b"/>`),b=`${h}b`),c.push(`<feOffset in="${b}" dx="${y(l.x)}" dy="${y(l.y)}" result="${h}o"/>`,`<feFlood flood-color="${v(l.colour)}" result="${h}c"/>`,`<feComposite in="${h}c" in2="${h}o" operator="in" result="${h}k"/>`,`<feComposite in="${h}k" in2="solid" operator="in" result="${h}"/>`)});let d=[...o.map((l,p)=>`<feMergeNode in="s${o.length-1-p}"/>`),...n==="all"?['<feMergeNode in="SourceGraphic"/>']:[],...i.map((l,p)=>`<feMergeNode in="i${i.length-1-p}"/>`)].join(""),f=s>0?`<feMerge result="layer">${d}</feMerge><feGaussianBlur in="layer" stdDeviation="${y(s/2)}"/>`:`<feMerge>${d}</feMerge>`;return`<filter id="${v(t+_t+e.id)}" filterUnits="userSpaceOnUse" x="${y(u.x-a)}" y="${y(u.y-a)}" width="${y(u.w+a*2)}" height="${y(u.h+a*2)}" color-interpolation-filters="sRGB">`+c.join("")+f+"</filter>"}function za(e,n){let t=Math.min(e.x,n.x),r=Math.min(e.y,n.y);return{x:t,y:r,w:Math.max(e.x+e.w,n.x+n.w)-t,h:Math.max(e.y+e.h,n.y+n.h)-r}}var Hr="vd-veil-";function Ii(e){let n=new Map;for(let t of e)t.veil&&n.set(t.veil.id,t.veil);return[...n.values()]}function Ga(e){return Ri(e,"")}function Ri(e,n){let t=Xe(e.blur)+2;return`<filter id="${v(n+Hr+e.id)}" filterUnits="userSpaceOnUse" x="${y(e.x-t)}" y="${y(e.y-t)}" width="${y(e.w+t*2)}" height="${y(e.h+t*2)}" color-interpolation-filters="sRGB"><feGaussianBlur stdDeviation="${y(e.blur/2)}"/></filter>`}var Pi="vd-backdrop-";function Xa(e,n){return Ci(e,n,{ids:!1,prefix:""})}function Ci(e,n,t){let r=n.backdrop;if(r===void 0)return"";let o={ids:!1,prefix:t.prefix},i=Gr(e.items,n).map(b=>qr(b,o)).filter(b=>b!=="");if(r.page===void 0&&e.background!==void 0&&i.unshift(`<rect x="${y(e.x)}" y="${y(e.y)}" width="${y(e.width)}" height="${y(e.height)}" fill="${v(Y(e.background,t))}"/>`),i.length===0)return"";let s=Ja(n);if(s==="")return"";let u=v(t.prefix+Pi+n.id),a=n.pose,c=ze({x:n.x,y:n.y,w:n.w,h:n.h},n.rotation,se({x:n.x,y:n.y,w:n.w,h:n.h})),d=a?{x:a.sx*c.x+a.tx,y:a.sy*c.y+a.ty,w:a.sx*c.w,h:a.sy*c.h}:c,f=Xe(r.blur)+2,l=`<filter id="${u}-blur" filterUnits="userSpaceOnUse" x="${y(d.x-f)}" y="${y(d.y-f)}" width="${y(d.w+f*2)}" height="${y(d.h+f*2)}" color-interpolation-filters="sRGB"><feGaussianBlur stdDeviation="${y(r.blur/2)}"/></filter>`,p=[];n.clip!==void 0&&p.push(`clip-path="url(#${v(t.prefix+ce+n.clip)})"`);let h=("opacity"in n?n.opacity:1)*(a?.opacity??1);return h<1&&p.push(`opacity="${y(h)}"`),`<g${p.length===0?"":` ${p.join(" ")}`}><defs><clipPath id="${u}">${s}</clipPath>${l}</defs><g clip-path="url(#${u})" filter="url(#${u}-blur)">${i.join("")}</g></g>`}function Ja(e){let n=e.rotation===0?"":Yr(e),r=[e.pose?Zr(e.pose):"",n].filter(i=>i!=="").join(" "),o=r===""?[]:[`transform="${r}"`];switch(e.kind){case"rect":case"frame":return H(e,e.radii,o);case"ellipse":return At(e,o);case"vector":return e.d===""?"":`<path d="${v(e.d)}"${e.rule==="evenodd"?' clip-rule="evenodd"':""}${o.length===0?"":` ${o.join(" ")}`}/>`;case"image":case"text":case"border":case"connector":return""}}function Yr(e){return`rotate(${y(e.rotation)} ${y(e.x+e.w/2)} ${y(e.y+e.h/2)})`}function Di(e){return e.rotation!==0&&e.clip!==void 0&&e.mask===void 0}function qr(e,n){if(e.veil!==void 0){let{veil:t,...r}=e,o=qr(r,n);if(o==="")return"";let i=[`filter="url(#${v(n.prefix+Hr+t.id)})"`];return t.clip!==void 0&&i.push(`clip-path="url(#${v(n.prefix+ce+t.clip)})"`),`<g ${i.join(" ")}>${o}</g>`}if(e.pose!==void 0)return Ka(e,e.pose,n);if(e.mask!==void 0)return Vi(e,n);if(Di(e)){let t=[`clip-path="url(#${v(n.prefix+ce+e.clip)})"`];e.blend!=="normal"&&t.push(`style="mix-blend-mode:${e.blend}"`);let r=Nt({...e,clip:void 0,blend:"normal"},n);return r===""?"":`<g ${t.join(" ")}>${r}</g>`}return Nt(e,n)}function Ka(e,n,t){let r=Nt({...e,clip:void 0,blend:"normal",shadows:e.shadows},t);if(r==="")return"";let o=[];e.clip!==void 0&&o.push(`clip-path="url(#${v(t.prefix+ce+e.clip)})"`),n.opacity<1&&o.push(`opacity="${y(n.opacity)}"`),e.blend!=="normal"&&o.push(`style="mix-blend-mode:${e.blend}"`);let i=n.sx===1&&n.sy===1&&n.tx===0&&n.ty===0?r:`<g transform="${Zr(n)}">${r}</g>`;return o.length===0?i:`<g ${o.join(" ")}>${i}</g>`}function Zr(e){return`matrix(${y(e.sx)} 0 0 ${y(e.sy)} ${y(e.tx)} ${y(e.ty)})`}var Rt="vd-mask-";function Vi(e,n){let t=Nt(Li(e),{...n,ids:!1});if(t==="")return"";let r=[];n.ids&&r.push(`id="${v(e.id)}"`),e.clip!==void 0&&r.push(`clip-path="url(#${v(n.prefix+ce+e.clip)})"`),It(e)&&r.push(`filter="url(#${v(n.prefix+_t+e.id)})"`),"opacity"in e&&e.opacity<1&&r.push(`opacity="${y(e.opacity)}"`),e.blend!=="normal"&&r.push(`style="mix-blend-mode:${e.blend}"`);let o=r.length===0?"<g>":`<g ${r.join(" ")}>`,i=ji(e,n.prefix);return`${o}<g clip-path="url(#${v(n.prefix+Rt+e.id)})">${t}</g>${i===""?"":`<g>${i}</g>`}</g>`}function Li(e){let n=Fi(e),t={..."opacity"in n?{...n,opacity:1}:n,clip:void 0,blend:"normal",shadows:[]};if(t.kind!=="image")return t;let{stroke:r,strokeWidth:o,...i}=t;return r===void 0&&o===void 0?t:i}function Ha(e){return ji(e,"")}function ji(e,n){let t=ee(e),r=e.mask;if(!t||r===void 0)return"";let o=v(r.d);if(t.align==="center")return`<path d="${o}" fill="none" ${ae(e,t,n,!1).join(" ")}/>`;let i=ae(e,t,n,!0).join(" ");if(t.align==="inside")return`<path d="${o}" fill="none" ${i} clip-path="url(#${v(n+Rt+e.id)})"/>`;let s=v(n+to+e.id);return`<clipPath id="${s}">${Ki(r.contours,t)}</clipPath><path d="${o}" fill="none" ${i} clip-path="url(#${s})"/>`}function Ya(e){return Bi(e,"")}function Bi(e,n){let t=e.mask;if(t===void 0)return"";let r=t.rule==="evenodd"?' clip-rule="evenodd"':"";return`<clipPath id="${v(n+Rt+e.id)}"><path d="${v(t.d)}"${r}/></clipPath>`}function Fi(e){let{mask:n,...t}=e;return n===void 0?e:t}function Nt(e,n){if(e.mask!==void 0)return Vi(e,n);if(Xi(e))return ic(e,n);switch(e.kind){case"border":return ec(e,n);case"connector":return rc(e,n);case"ellipse":return nc(e,n);case"frame":return qa(e,n);case"image":return Ui(e,n);case"rect":return Qa(e,n);case"text":return ac(e,n);case"vector":return tc(e,n)}}function Y(e,n){return/url\(/i.test(e)&&!e.startsWith("url(#")?"none":n.prefix!==""&&e.startsWith("url(#")?`url(#${n.prefix}${e.slice(5)}`:e}function qa(e,n){return H(e,e.radii,[`fill="${e.background===void 0?"none":v(Y(e.background,n))}"`,...te(e,n.prefix)],n.ids?[`id="${v(e.id)}"`]:[])}function Ui(e,n,t=!1){let r=n.ids?[`id="${v(e.id)}"`]:[],o=t?[]:te(e,n.prefix);if(e.href===void 0&&e.video?.clip!==void 0){let a=e.opacity<1?[`opacity="${y(e.opacity)}"`]:[],c=[...r,...a,...o];return`<g${c.length===0?"":` ${c.join(" ")}`}>${Wi(e,n.prefix)}</g>`}if(e.href===void 0)return H(e,e.radii,['fill="none"',`stroke="${v(Fa)}"`,'stroke-width="1"','stroke-dasharray="4 4"',...o],r);let i=[`x="${y(e.x)}"`,`y="${y(e.y)}"`,`width="${y(e.w)}"`,`height="${y(e.h)}"`,`href="${v(e.href)}"`,`preserveAspectRatio="${Ni[e.fit]}"`],s=e.opacity<1?[`opacity="${y(e.opacity)}"`]:[];if(oe(e.radii))return`<image ${[...r,...i,...s,...o].join(" ")}/>`;let u=v(n.prefix+Qr+e.id);return`${t?"<g>":`<g ${[...r,...s,...o].join(" ")}>`}<clipPath id="${u}">${H(e,e.radii)}</clipPath><image ${[...i,`clip-path="url(#${u})"`].join(" ")}/></g>`}function Wi(e,n=""){let t=[`x="${y(e.x)}"`,`y="${y(e.y)}"`,`width="${y(e.w)}"`,`height="${y(e.h)}"`],r=v(n+Qr+e.id),o=oe(e.radii),i=`width:100%;height:100%;display:block;object-fit:${Za[e.fit]}`;return(o?"":`<clipPath id="${r}">${H(e,e.radii)}</clipPath>`)+`<foreignObject ${[...t,...o?[]:[`clip-path="url(#${r})"`]].join(" ")}><video xmlns="http://www.w3.org/1999/xhtml" data-vd-video="${v(e.id)}" src="${v(e.video?.clip??"")}" muted="" playsinline="" preload="auto" style="${i}"></video></foreignObject>`}var Za={cover:"cover",contain:"contain",fill:"fill"},Qr="vd-round-";function Qa(e,n){return H(e,e.radii,[...eo(e,n),...zi(e,n),...te(e,n.prefix)],n.ids?[`id="${v(e.id)}"`]:[])}function ec(e,n){let t=ee(e);return t?H(e,e.radii,['fill="none"',...ae(e,t,n.prefix,!1),...te(e,n.prefix)]):""}function zi(e,n){let t=ee(e);return t?ae(e,t,n.prefix,!1).slice(2):[]}function eo(e,n){let t=[`fill="${v(Y(e.fill,n))}"`];return e.stroke!==void 0&&e.strokeWidth>0&&t.push(`stroke="${v(Y(e.stroke,n))}"`,`stroke-width="${y(e.strokeWidth)}"`),e.opacity<1&&t.push(`opacity="${y(e.opacity)}"`),t}function nc(e,n){let t=[];return n.ids&&t.push(`id="${v(e.id)}"`),t.push(`cx="${y(e.x+e.w/2)}"`,`cy="${y(e.y+e.h/2)}"`,`rx="${y(e.w/2)}"`,`ry="${y(e.h/2)}"`,...eo(e,n),...zi(e,n),...te(e,n.prefix)),`<ellipse ${t.join(" ")}/>`}function tc(e,n){if(e.d==="")return"";let t=[];n.ids&&t.push(`id="${v(e.id)}"`),t.push(`d="${v(e.d)}"`,...eo(e,n)),t.push(...no(e,e.dash??[]));let r=e.pose?.fillOpacity;return r!==void 0&&r<1&&t.push(`fill-opacity="${y(r)}"`),e.rule!=="nonzero"&&t.push(`fill-rule="${e.rule}"`),e.cap!=="butt"&&t.push(`stroke-linecap="${e.cap}"`),e.join!=="miter"&&t.push(`stroke-linejoin="${e.join}"`),e.paintOrder!==void 0&&t.push(`paint-order="${e.paintOrder}"`),t.push(...te(e,n.prefix)),`<path ${t.join(" ")}/>`}function rc(e,n){let t=Gi(e,n.prefix);if(t==="")return"";let r=[];return n.ids&&r.push(`id="${v(e.id)}"`),e.opacity<1&&r.push(`opacity="${y(e.opacity)}"`),r.push(...te(e,n.prefix)),`<g ${r.join(" ")}>${t}</g>`}function oc(e){return Gi(e,"")}function Gi(e,n){if(!(e.strokeWidth>0))return"";let t=v(Y(e.stroke,{ids:!1,prefix:n})),r=y(e.strokeWidth),o=e.pose?.trace,i=[`d="${v(e.d)}"`,'fill="none"',`stroke="${t}"`,`stroke-width="${r}"`,...no(e,e.dash??[])];e.cap!=="butt"&&i.push(`stroke-linecap="${e.cap}"`);let s=[`<path ${i.join(" ")}/>`];return(a=>{a&&(e.filled.d!==""&&s.push(`<path d="${v(e.filled.d)}" fill="${t}"/>`),e.lined.d!==""&&s.push(`<path d="${v(e.lined.d)}" fill="none" stroke="${t}" stroke-width="${r}"/>`))})(o===void 0||o>=1),s.join("")}function no(e,n){let t=e.kind==="vector"||e.kind==="connector",r=t?e.pose?.trace:void 0;if(r!==void 0&&t&&e.stroke!==void 0){let o=Ur(n,Jt(e.contours),r),i=[`stroke-dasharray="${o.array.map(y).join(" ")}"`];return(o.offset!==0||n.length===0)&&i.push(`stroke-dashoffset="${y(o.offset)}"`),i}return n.length===0?[]:[`stroke-dasharray="${n.map(y).join(" ")}"`]}function ae(e,n,t,r){let o=[`stroke="${v(Y(n.paint,{ids:!1,prefix:t}))}"`,`stroke-width="${y(n.width*(r?2:1))}"`,...no(e,n.dash)];return n.cap!=="butt"&&o.push(`stroke-linecap="${n.cap}"`),n.join!=="miter"&&o.push(`stroke-linejoin="${n.join}"`),o}var to="vd-stroke-";function Xi(e){if(e.mask!==void 0)return!1;let n=ee(e);return!n||e.kind==="text"?!1:e.kind==="image"||n.align!=="center"}function ic(e,n){let t=[];return n.ids&&e.kind!=="border"&&t.push(`id="${v(e.id)}"`),"opacity"in e&&e.opacity<1&&t.push(`opacity="${y(e.opacity)}"`),t.push(...te(e,n.prefix)),`${t.length===0?"<g>":`<g ${t.join(" ")}>`}${Ji(e,n.prefix)}</g>`}function sc(e){return Ji(e,"")}function Ji(e,n){let t=ee(e),r={ids:!1,prefix:n},o="",i="",s=f=>{switch(e.kind){case"ellipse":i=At(e,f);return;case"vector":i=e.d===""?"":`<path d="${v(e.d)}" ${f.join(" ")}/>`;return;case"rect":case"image":case"border":i=H(e,e.radii,f);return;case"frame":case"text":return}};switch(e.kind){case"rect":o=H(e,e.radii,[`fill="${v(Y(e.fill,r))}"`]);break;case"ellipse":o=At(e,[`fill="${v(Y(e.fill,r))}"`]);break;case"vector":{let f=[`fill="${v(Y(e.fill,r))}"`],l=e.pose?.fillOpacity;l!==void 0&&l<1&&f.push(`fill-opacity="${y(l)}"`),e.rule!=="nonzero"&&f.push(`fill-rule="${e.rule}"`),o=e.d===""?"":`<path d="${v(e.d)}" ${f.join(" ")}/>`;break}case"image":o=Ui({...e,opacity:1,clip:void 0,rotation:0,shadows:[],blend:"normal"},r,!0);break;case"border":case"frame":case"text":break}if(!t)return o;if(t.align==="center")return s(['fill="none"',...ae(e,t,n,!1)]),o+i;let u=vt(e,t);if(u){let f=['fill="none"',...ae(e,t,n,!1)],l=e.kind==="ellipse"?At(u,f):H(u,u.radii,f);return o+l}let a=Lr(e);if(!a)return o;let c=v(n+to+e.id);s(['fill="none"',...ae(e,t,n,!0),`clip-path="url(#${c})"`]);let d=t.align==="inside"?`<path d="${v(q(a.contours))}"${a.rule==="evenodd"?' clip-rule="evenodd"':""}/>`:Ki(a.contours,t);return`${o}<clipPath id="${c}">${d}</clipPath>${i}`}function Ki(e,n){let t=uc(e),r=Fr(n),o=t.x-r,i=t.y-r,s=t.x+t.w+r,u=t.y+t.h+r,a=`M${y(o)} ${y(i)}H${y(s)}V${y(u)}H${y(o)}Z`;return`<path d="${v(a+q(e))}" clip-rule="evenodd"/>`}function uc(e){let n=1/0,t=1/0,r=-1/0,o=-1/0;for(let i of e)for(let s of i.anchors)for(let u of[s,s.in,s.out])u&&(n=Math.min(n,u.x),t=Math.min(t,u.y),r=Math.max(r,u.x),o=Math.max(o,u.y));return Number.isFinite(n)?{x:n,y:t,w:r-n,h:o-t}:{x:0,y:0,w:0,h:0}}function At(e,n){return`<ellipse cx="${y(e.x+e.w/2)}" cy="${y(e.y+e.h/2)}" rx="${y(e.w/2)}" ry="${y(e.h/2)}" ${n.join(" ")}/>`}function ac(e,n){if(e.lines.every(i=>i.spans.length===0))return"";let t=[];n.ids&&t.push(`id="${v(e.id)}"`),t.push('xml:space="preserve"'),e.opacity<1&&t.push(`opacity="${y(e.opacity)}"`);let r=ee(e);r&&t.push(...ae(e,r,n.prefix,!1),'paint-order="stroke"'),t.push(...te(e,n.prefix));let o=[];for(let i of e.lines)for(let s of i.spans)s.text!==""&&o.push(cc(s,n));return`<text ${t.join(" ")}>${o.join("")}</text>`}function cc(e,n){let r=`<tspan ${[`x="${y(e.x)}"`,`y="${y(e.y)}"`,...dc(e.style,n)].join(" ")}>${fc(e.text)}</tspan>`;return e.style.link===void 0?r:`<a href="${v(e.style.link)}">${r}</a>`}function dc(e,n){let t=[`font-family="${v(e.family)}"`,`font-size="${y(e.size)}"`,`fill="${v(Y(e.fill,n))}"`];e.weight!==400&&t.push(`font-weight="${y(e.weight)}"`),e.italic&&t.push('font-style="italic"'),e.letterSpacing!==0&&t.push(`letter-spacing="${y(e.letterSpacing)}"`);let r=[e.underline?"underline":"",e.strike?"line-through":""].filter(Boolean).join(" ");return r&&t.push(`text-decoration="${r}"`),t}function fc(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function v(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Dm(e,n={}){let{resolveAsset:t,measure:r,...o}=n;return Kr(Jr(e,{...t?{resolveAsset:t}:{},...r?{measure:r}:{}}),o)}export{oe as a,C as b,X as c,le as d,ge as e,Qe as f,xo as g,Be as h,bo as i,Gn as j,Xn as k,Jt as l,xs as m,qi as n,Zi as o,Qi as p,es as q,Zs as r,lt as s,Ou as t,Mu as u,qo as v,Zo as w,Du as x,Vu as y,Lu as z,Vr as A,ee as B,Ur as C,$t as D,Ot as E,vi as F,Jr as G,Kr as H,La as I,Mi as J,Ti as K,ja as L,_t as M,It as N,Ua as O,Hr as P,Ii as Q,Ga as R,Xa as S,Yr as T,Di as U,Zr as V,Rt as W,Li as X,Ha as Y,Ya as Z,Wi as _,Qr as $,oc as aa,Xi as ba,sc as ca,Dm as da};
@@ -1,5 +1,5 @@
1
- /*! @getv.design/embed v0.5.5. Free to use under the vDesign Embed Licence. © 2026 vDesign. https://getv.design/docs/licence/ */
2
- import{m as l,q as d,r as p,s as g}from"./chunk-5XTOQNJT.js";import{a as m}from"./chunk-OJEQYRTB.js";var h=Symbol.for(`vdesign.embed.documents@${m}`),y=globalThis[h]??=new WeakMap,v=/^Line (\d+): /;function w(e){let n=v.exec(e.message);return{...n?{line:Number(n[1])}:{},code:e.code,message:e.message,severity:e.severity}}function f(e){if(typeof e!="string")return c(d("").document,new Map,[{code:"not-text",message:`parse() takes .vd text, not ${e===null?"null":typeof e}.`,severity:"error"}]);let n=D(e);if(n.vd===void 0)return c(d("").document,new Map,[{code:"not-vd",message:"This SVG carries no vDesign document: only a .vd.svg exported from vDesign does.",severity:"error"}]);let{head:t,blocks:o}=l(n.vd),r=d(t),s=r.problems.map(w).map(i=>i.line===void 0?i:{...i,line:i.line+n.offset});return c(r.document,o,s)}function D(e){if(!g(e))return{vd:e,offset:0};let n=p(e);if(n===void 0)return{vd:void 0,offset:0};let t=e.indexOf("<vd:document"),o=e.indexOf("</vd:document",t),r=e.indexOf("<![CDATA[",t);if(r===-1||o!==-1&&r>o){let u=e.indexOf(">",t)+1,b=e.slice(0,u).split(`
1
+ /*! @getv.design/embed v0.6.0. Free to use under the vDesign Embed Licence. © 2026 vDesign. https://getv.design/docs/licence/ */
2
+ import{n as l,r as d,t as p,u as g}from"./chunk-P42KFNKD.js";import{a as m}from"./chunk-VTEBIFPH.js";var h=Symbol.for(`vdesign.embed.documents@${m}`),y=globalThis[h]??=new WeakMap,v=/^Line (\d+): /;function w(e){let n=v.exec(e.message);return{...n?{line:Number(n[1])}:{},code:e.code,message:e.message,severity:e.severity}}function f(e){if(typeof e!="string")return c(d("").document,new Map,[{code:"not-text",message:`parse() takes .vd text, not ${e===null?"null":typeof e}.`,severity:"error"}]);let n=D(e);if(n.vd===void 0)return c(d("").document,new Map,[{code:"not-vd",message:"This SVG carries no vDesign document: only a .vd.svg exported from vDesign does.",severity:"error"}]);let{head:t,blocks:o}=l(n.vd),r=d(t),s=r.problems.map(w).map(i=>i.line===void 0?i:{...i,line:i.line+n.offset});return c(r.document,o,s)}function D(e){if(!g(e))return{vd:e,offset:0};let n=p(e);if(n===void 0)return{vd:void 0,offset:0};let t=e.indexOf("<vd:document"),o=e.indexOf("</vd:document",t),r=e.indexOf("<![CDATA[",t);if(r===-1||o!==-1&&r>o){let u=e.indexOf(">",t)+1,b=e.slice(0,u).split(`
3
3
  `).length-1;return{vd:n,offset:b+(e[u]===`
4
4
  `?1:0)}}let s=r+9,i=e.slice(0,s).split(`
5
5
  `).length-1;return{vd:n,offset:i+(e[s]===`
@@ -1,2 +1,2 @@
1
- /*! @getv.design/embed v0.5.5. Free to use under the vDesign Embed Licence. © 2026 vDesign. https://getv.design/docs/licence/ */
1
+ /*! @getv.design/embed v0.6.0. Free to use under the vDesign Embed Licence. © 2026 vDesign. https://getv.design/docs/licence/ */
2
2
  var g=Object.create;var f=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var m=(b,a)=>()=>{try{return a||b((a={exports:{}}).exports,a),a.exports}catch(c){throw a=0,c}};var l=(b,a,c,e)=>{if(a&&typeof a=="object"||typeof a=="function")for(let d of i(a))!k.call(b,d)&&d!==c&&f(b,d,{get:()=>a[d],enumerable:!(e=h(a,d))||e.enumerable});return b};var n=(b,a,c)=>(c=b!=null?g(j(b)):{},l(a||!b||!b.__esModule?f(c,"default",{value:b,enumerable:!0}):c,b));export{m as a,n as b};
@@ -0,0 +1,2 @@
1
+ /*! @getv.design/embed v0.6.0. Free to use under the vDesign Embed Licence. © 2026 vDesign. https://getv.design/docs/licence/ */
2
+ var _="0.6.0",e="https://cdn.jsdelivr.net/npm/@getv.design/embed@0.6.0/fonts/";export{_ as a,e as b};