@getv.design/embed 0.4.0 → 0.5.1
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 +3 -3
- package/THIRD_PARTY_NOTICES.txt +1 -1
- package/dist/auto.js +2 -2
- package/dist/chunks/{chunk-ACYFDE3D.js → chunk-7K6NORUY.js} +1 -1
- package/dist/chunks/{chunk-RYQFBGKS.js → chunk-EFCLQF2H.js} +3 -3
- package/dist/chunks/chunk-OK6J2L2H.js +2 -0
- package/dist/chunks/chunk-OMFQR6TE.js +10 -0
- package/dist/chunks/{chunk-WZMAP7VR.js → chunk-OQXGXTNC.js} +2 -2
- package/dist/chunks/{chunk-TQVHSS5W.js → chunk-VL77CJOG.js} +2 -2
- package/dist/chunks/fonts.js +2 -2
- package/dist/cli.js +17 -17
- package/dist/edit.js +131 -32
- package/dist/index.js +2 -2
- package/dist/markdown-it.js +2 -2
- package/dist/markdown.js +2 -2
- package/dist/marked.js +2 -2
- package/dist/rehype.js +2 -2
- package/dist/static.js +2 -2
- package/dist/view.js +3 -3
- package/edit.css +93 -0
- package/package.json +1 -1
- package/dist/chunks/chunk-JWSC2HIX.js +0 -10
- package/dist/chunks/chunk-Z7CAMO33.js +0 -2
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/*! @getv.design/embed v0.4.0. Free to use under the vDesign Embed Licence. © 2026 vDesign. https://getv.design/docs/licence/ */
|
|
2
|
-
var Ce=["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ge=["left","center","right","justify"],ye=["top","middle","bottom"],xe=["cover","contain","fill"],Fe=["nonzero","evenodd"],je=["butt","round","square"],Ve=["miter","round","bevel"],Tn=["canvas","frame","group"];function Be(e){return Tn.includes(e)}function F(e){return Be(e.type)}function be(e){return e.type==="group"}function oe(e){return F(e)?e.children:[]}var Nn={canvas:["w","h"],ellipse:["x","y","w","h","rotation","strokeWidth","opacity"],frame:["x","y","w","h"],group:[],image:["x","y","w","h","rotation","radius","opacity"],rect:["x","y","w","h","rotation","strokeWidth","radius","opacity"],text:["x","y","w","h","rotation","size","weight","lineHeight","letterSpacing","opacity"],vector:["x","y","w","h","rotation","strokeWidth","opacity"]};function Ue(e){return Nn[e.type]}function I(e,t,n){if(t(e,n)!==!1&&F(e))for(let r of e.children)I(r,t,e)}function G(e,t){let n;return I(e,r=>{if(n)return!1;r.id===t&&(n=r)}),n}function Y(e){let t=e.trim();if(t.startsWith("#")){let r=t.slice(1);return r===""?void 0:{kind:"frame",id:r}}let n;try{n=new URL(t)}catch{return}if(!(n.protocol!=="https:"&&n.protocol!=="mailto:"))return{kind:"url",url:t}}var ie="--- payload base64 ---",Pr="sha256-";function _n(e){let t=Fr(e);return t===-1?{head:e,payload:""}:{head:e.slice(0,t),payload:e.slice(t+ie.length)}}function Rr(e){let{head:t,payload:n}=_n(e);return{head:t,blocks:An(n)}}function An(e){let t=new Map;for(let n of e.split(`
|
|
3
|
-
`)){let r=n.indexOf(" ");if(r===-1)continue;let o=n.slice(0,r);o.startsWith(Pr)&&t.set(o,n.slice(r+1).trim())}return t}function Dr(e,t){return`data:${e};base64,${t}`}function Lr(e){let t=e.toBase64;if(typeof t=="function")return t.call(e);let n="";for(let r=0;r<e.length;r+=32768)n+=String.fromCharCode(...e.subarray(r,r+32768));return btoa(n)}function Cr(e){let t=Uint8Array.fromBase64;if(typeof t=="function")return t(e);let n=atob(e),r=new Uint8Array(n.length);for(let o=0;o<n.length;o+=1)r[o]=n.charCodeAt(o);return r}function Fr(e){if(e.startsWith(ie))return 0;let t=e.indexOf(`
|
|
4
|
-
${ie}`);return t===-1?-1:t+1}function we(e){return{expr:e}}function V(e){return typeof e=="object"&&e!==null&&typeof e.expr=="string"}var _t=["light","dark"],At=["must","should"],We=["no-gradient","contrast","font-only","logo-min"];var In=["role","logo","rule","guide","review"];function ze(e){return In.includes(e)}function Xe(e="",t=1){return{slug:e,version:t,changes:[],sources:[],roles:{},logos:{},rules:{},guides:{},review:[]}}function It(e){let t=/^([a-z0-9][a-z0-9-]*)(?:@(\d+))?$/.exec(e);if(!t)return;let n=t[2]===void 0?1:Number(t[2]);if(!(!Number.isSafeInteger(n)||n<1))return{slug:t[1],version:n}}var $e=["design","brand"],se="design",Pn=new WeakMap;function j(e){let t=e.brand?.theme==="dark"?e.themes?.dark:void 0;if(t===void 0)return e.tokens;let n=Pn.get(e);if(n!==void 0)return n;let r={...e.tokens,...t};return Pn.set(e,r),r}var Rn=4,ke=5,Ge=[1,2,3,4,5];function H(e){return e.kind==="brand"||e.brand!==void 0||e.themes!==void 0||jr(e.fonts)?ke:Rn}function jr(e){return Object.values(e??{}).some(t=>(t.faces??[]).some(n=>n.asset!==void 0))}var K="doc";function ve(e){return{type:"canvas",...e}}function He(e={}){let t=e.kind??se,n=ue(e.themes);return{version:H({kind:t,...e.fonts===void 0?{}:{fonts:e.fonts},...e.brand===void 0?{}:{brand:e.brand},...n===void 0?{}:{themes:n}}),kind:t,...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},...n===void 0?{}:{themes:n},root:e.root??ve({id:K,children:[]})}}function ue(e){let t=e?.dark;return t===void 0||Object.keys(t).length===0?void 0:{dark:t}}var Je=["beat","bar"];var Vr=/^(\d+(?:\.\d+)?)(beats?|bars?)$/;function ae(e){let t=Vr.exec(e);if(!t)return;let n=Number(t[1]);if(Number.isFinite(n))return{count:n,unit:t[2].startsWith("bar")?"bar":"beat"}}function ce(e,t){return`${String(Math.round(e*1e6)/1e6)}${t}${e===1?"":"s"}`}function de(e){return typeof e=="string"&&ae(e)!==void 0}function q(e){let t=e?.bpm;if(t===void 0)return;let n=e?.meter??4,r=6e4/t;return{bpm:t,meter:n,beat:r,bar:r*n}}function Ee(e,t,n){if(e===void 0)return n;if(typeof e=="number")return e;let r=ae(e);return!r||!t?n:r.count*(r.unit==="bar"?t.bar:t.beat)}var Se=36e5;var Ye=["cut","fade","push","slide"],Ke=["cut","fade","rise","drop","pop","wipe","grow","count","draw"],fe=["cut","fade","rise","drop","pop"],qe=["pulse"],Ze=["out","in","inout","linear","spring"],Qe=["word","letter"],Z=["left","right","top","bottom"],Dn=400,Me=1e4,et=18e4,Q=7680;function le(e){let t=e.trim();return t==="back"?{kind:"back"}:t==="next"?{kind:"next"}:Y(t)}function Oe(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 tt(e){return e.camera===!0||e.enter!==void 0||e.exit!==void 0||e.emphasis!==void 0||e.go!==void 0}var Ur=["camera","emphasis","from","by","stagger","hold","at","after","with","on","ease","pad"];function Ln(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(t=>Ur.some(n=>t[n]!==void 0)||t.enter!==void 0&&!fe.includes(t.enter)||t.exit!==void 0&&!fe.includes(t.exit))}function nt(e){let t=e.motion;if(!t)return[];let n=e.root.children.map(o=>o.id).filter(o=>o in t),r=Object.keys(t).filter(o=>!n.includes(o)).sort();return[...n,...r]}function rt(e){return new Set(e.root.children.filter(t=>t.type==="frame").map(t=>t.id))}function ot(e){let t=new Map;for(let n of e.root.children)n.type==="frame"&&I(n,r=>{t.set(r.id,n.id)});return t}function Wr(e){let t=new Set;return I(e,n=>{t.add(n.id)}),t}function Te(e,t){let n=e.motion;if(!n)return[];let r=[],o=rt(e),i=ot(e),s=Wr(e.root),u=(a,c)=>{let d=t?.(a,c);return d===void 0?"":`Line ${d}: `};for(let a of nt(e)){let c=n[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 p=u(a,f.id);for(let m of["after","with"]){let $=f[m];$!==void 0&&!d.has($)&&r.push({severity:"warning",code:"motion-anchor-missing",message:`${p}motion ${a}: ${m}=${$} names no line above, so it starts after the line above instead`,nodeId:f.id})}f.camera!==!0&&d.add(f.id);let h=s.has(f.id)?G(e.root,f.id):void 0;h&&r.push(...zr(f,h,p,a)),s.has(f.id)?i.get(f.id)!==a&&r.push({severity:"warning",code:"motion-wrong-page",message:`${p}motion ${a}: ${f.id} is not on ${a}, so Play skips it`,nodeId:f.id}):r.push({severity:"warning",code:"unknown-reference",message:`${p}motion ${a}: no node ${f.id}`,nodeId:f.id});let x=f.go===void 0?void 0:le(f.go);x?.kind==="frame"&&!Hr(e,x.id)&&r.push({severity:"warning",code:"unknown-reference",message:`${p}motion ${a}: go=#${x.id} names no frame`,nodeId:f.id})}}return r}function zr(e,t,n,r){let o=[],i=(u,a)=>{o.push({severity:"warning",code:u,message:`${n}motion ${r}: ${a}`,nodeId:t.id})};if(e.camera===!0)return o;let s=e.enter??e.exit;return s==="count"&&(t.type!=="text"||!/\d/.test(it(t.content)))&&i("count-no-number",`${t.id} has no number to count, so it fades in instead`),s==="draw"&&!Gr(t)&&i("draw-no-stroke",`${t.id} has no stroked vector to draw, so it fades in instead`),e.by!==void 0&&t.type!=="text"?i("by-not-text",`by=${e.by} splits text, and ${t.id} is a ${t.type}`):e.by!==void 0&&t.type==="text"&&Xr(t)&&i("by-rotated",`${t.id} is rotated, so by=${e.by} enters it whole`),e.stagger!==void 0&&e.by===void 0&&oe(t).length===0&&i("stagger-no-children",`${t.id} has no children to stagger: split a text with by=word`),o}function Xr(e){let t=e.rotation;return t!==void 0&&t!==0}function Gr(e){let t=!1;return I(e,n=>(n.type==="vector"&&n.stroke!==void 0&&(t=!0),t?!1:void 0)),t}function it(e){return typeof e=="string"?e:e.map(t=>typeof t=="string"?t:t.text).join("")}function Hr(e,t){let n=!1;return I(e.root,r=>{if(n)return!1;r.id===t&&(n=r.type==="frame")}),n}function y(e){if(!Number.isFinite(e))return"0";let t=Math.round(e*1e4)/1e4,n=Object.is(t,-0)?0:t;return Math.abs(n)>=1e21?n.toFixed(0):String(n)}var Jr={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0};function Pt(e){let t=[],n,r=0,o=0,i=0,s=0,u,a,c=Kr(e),d=()=>(n||(n={anchors:[{x:r,y:o}],closed:!1},t.push(n)),n.anchors[n.anchors.length-1]),f=(m,$)=>{d(),n?.anchors.push({x:m,y:$}),r=m,o=$},p=(m,$,E,v)=>{d().out=m,n?.anchors.push({x:E,y:v,in:$}),r=E,o=v},h="",x=!0;for(;c.more();){let m=c.command();if(m!==void 0)h=m,x=!0;else if(h===""||h.toUpperCase()==="Z")return{contours:st(t),error:`Expected a command at ${c.at()}`};let $=h.toUpperCase(),E=h!==$,v=Jr[$];if(v===void 0)return{contours:st(t),error:`Unknown command ${h}`};if($==="Z"){n&&(n.closed=!0),n=void 0,r=i,o=s,u=void 0,a=void 0,h="";continue}let D=$==="A"?c.arc():c.numbers(v);if(D===void 0)return{contours:st(t),error:`${h} expects ${v} numbers at ${c.at()}`};let O=E?r:0,N=E?o:0,S=M=>D[M];switch($){case"M":x&&(n={anchors:[{x:O+S(0),y:N+S(1)}],closed:!1},t.push(n),r=i=O+S(0),o=s=N+S(1),h=E?"l":"L"),u=a=void 0;break;case"L":f(O+S(0),N+S(1)),u=a=void 0;break;case"H":f(O+S(0),o),u=a=void 0;break;case"V":f(r,N+S(0)),u=a=void 0;break;case"C":{let M={x:O+S(2),y:N+S(3)};p({x:O+S(0),y:N+S(1)},M,O+S(4),N+S(5)),u=M,a=void 0;break}case"S":{let M=u?{x:2*r-u.x,y:2*o-u.y}:{x:r,y:o},l={x:O+S(0),y:N+S(1)};p(M,l,O+S(2),N+S(3)),u=l,a=void 0;break}case"Q":case"T":{let M=$==="Q"?{x:O+S(0),y:N+S(1)}:a?{x:2*r-a.x,y:2*o-a.y}:{x:r,y:o},l=$==="Q"?O+S(2):O+S(0),w=$==="Q"?N+S(3):N+S(1),b={x:r+2/3*(M.x-r),y:o+2/3*(M.y-o)},g={x:l+2/3*(M.x-l),y:w+2/3*(M.y-w)};p(b,g,l,w),a=M,u=void 0;break}case"A":{let M=O+S(5),l=N+S(6);for(let[w,b,g]of qr(r,o,S(0),S(1),S(2),S(3)!==0,S(4)!==0,M,l))p(w,b,g.x,g.y);(r!==M||o!==l)&&f(M,l),u=a=void 0;break}}x=!1}return{contours:st(t)}}function st(e){return e.map(t=>{let n=[...t.anchors];if(t.closed&&n.length>1){let r=n[0],o=n[n.length-1];Ne(r,o)&&(n.pop(),n[0]={...r,...o.in?{in:o.in}:{}})}return{anchors:n.map(Yr),closed:t.closed}})}function Yr(e){let t={x:e.x,y:e.y};return e.in&&!Ne(e.in,e)&&(t.in=e.in),e.out&&!Ne(e.out,e)&&(t.out=e.out),t}function Ne(e,t,n=1e-6){return Math.abs(e.x-t.x)<n&&Math.abs(e.y-t.y)<n}function Kr(e){let t=0,n=()=>{for(;t<e.length&&/[\s,]/.test(e[t]);)t+=1},r=()=>{n();let i=/^[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/.exec(e.slice(t));if(i)return t+=i[0].length,Number(i[0])},o=()=>{n();let i=e[t];if(!(i!=="0"&&i!=="1"))return t+=1,Number(i)};return{more(){return n(),t<e.length},command(){n();let i=e[t];if(/[a-zA-Z]/.test(i))return t+=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 t}}}function qr(e,t,n,r,o,i,s,u,a){let c=Math.abs(n),d=Math.abs(r);if(c===0||d===0||e===u&&t===a)return[];let f=o*Math.PI/180,p=Math.cos(f),h=Math.sin(f),x=(e-u)/2,m=(t-a)/2,$=p*x+h*m,E=-h*x+p*m,v=$*$/(c*c)+E*E/(d*d);v>1&&(c*=Math.sqrt(v),d*=Math.sqrt(v));let D=c*c*d*d-c*c*E*E-d*d*$*$,O=c*c*E*E+d*d*$*$,N=(i===s?-1:1)*Math.sqrt(Math.max(0,D/O)),S=N*c*E/d,M=-N*d*$/c,l=p*S-h*M+(e+u)/2,w=h*S+p*M+(t+a)/2,b=(A,J,ne,re)=>{let he=A*ne+J*re,Le=Math.hypot(A,J)*Math.hypot(ne,re),me=Math.acos(Math.min(1,Math.max(-1,he/Le)));return A*re-J*ne<0?-me:me},g=b(1,0,($-S)/c,(E-M)/d),k=b(($-S)/c,(E-M)/d,(-$-S)/c,(-E-M)/d);!s&&k>0&&(k-=2*Math.PI),s&&k<0&&(k+=2*Math.PI);let _=Math.max(1,Math.ceil(Math.abs(k)/(Math.PI/2)-1e-9)),L=k/_,B=4/3*Math.tan(L/4),Sn=A=>({x:l+c*Math.cos(A)*p-d*Math.sin(A)*h,y:w+c*Math.cos(A)*h+d*Math.sin(A)*p}),Mn=A=>({x:-c*Math.sin(A)*p-d*Math.cos(A)*h,y:-c*Math.sin(A)*h+d*Math.cos(A)*p}),On=[];for(let A=0;A<_;A+=1){let J=g+A*L,ne=J+L,re=Sn(J),he=A===_-1?{x:u,y:a}:Sn(ne),Le=Mn(J),me=Mn(ne);On.push([{x:re.x+B*Le.x,y:re.y+B*Le.y},{x:he.x-B*me.x,y:he.y-B*me.y},he])}return On}function Rt(e){let t=[],n=r=>`${y(r.x)} ${y(r.y)}`;for(let r of e){let{anchors:o}=r,i=o[0];if(!i)continue;t.push(`M${n(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||t.push(`L${n(c)}`):t.push(`C${n(a.out??a)} ${n(c.in??c)} ${n(c)}`)}r.closed&&t.push("Z")}return t.join(" ")}function _e(e){let t=e.anchors.length;return t<2?0:e.closed?t:t-1}function ut(e,t){let n=e.anchors[t],r=e.anchors[(t+1)%e.anchors.length];return[{x:n.x,y:n.y},n.out??{x:n.x,y:n.y},r.in??{x:r.x,y:r.y},{x:r.x,y:r.y}]}function Dt(e,t){let[n,r,o,i]=e,s=1-t,u=s*s*s,a=3*s*s*t,c=3*s*t*t,d=t*t*t;return{x:u*n.x+a*r.x+c*o.x+d*i.x,y:u*n.y+a*r.y+c*o.y+d*i.y}}function Lt(e,t){return e.map(n=>({closed:n.closed,anchors:n.anchors.map(r=>{let o=t(r);return{x:o.x,y:o.y,...r.in?{in:t(r.in)}:{},...r.out?{out:t(r.out)}:{}}})}))}function Ct(e){let t=1/0,n=1/0,r=-1/0,o=-1/0,i=s=>{t=Math.min(t,s.x),n=Math.min(n,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=ut(s,a);for(let d of Zr(c))i(Dt(c,d))}}if(t!==1/0)return{x:t,y:n,w:r-t,h:o-n}}function Zr(e){let[t,n,r,o]=e,i=[];for(let s of["x","y"]){let u=-t[s]+3*n[s]-3*r[s]+o[s],a=2*(t[s]-2*n[s]+r[s]),c=n[s]-t[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 at(e){if(e===void 0)return;let t=e.trim().split(/[\s,]+/).map(Number);if(t.length!==4||t.some(s=>!Number.isFinite(s)))return;let[n,r,o,i]=t;return{x:n,y:r,w:o,h:i}}function Ft(e,t,n){return at(e)??{x:0,y:0,w:t,h:n}}function jt(e,t){let n=e.w===0?1:t.w/e.w,r=e.h===0?1:t.h/e.h;return o=>({x:t.x+(o.x-e.x)*n,y:t.y+(o.y-e.y)*r})}function Vt(e,t=.5){let[n,r,o,i]=e;if(Ne(n,r)&&Ne(o,i))return[n,i];let u=Math.hypot(r.x-n.x,r.y-n.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/t)))),c=[];for(let d=0;d<=a;d+=1)c.push(Dt(e,d/a));return c}function ct(e){let t=0;for(let n of e)for(let r=0;r<_e(n);r+=1){let o=Vt(ut(n,r),.25);for(let i=1;i<o.length;i+=1){let s=o[i-1],u=o[i];t+=Math.hypot(u.x-s.x,u.y-s.y)}}return t}function Qr(e,t,n){let r=0,o=0;for(let i of e){let s=eo(i);if(s.length!==0){if(n.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(to(t,c,d)<=n.reach)return!0}if(s.length===1&&Math.hypot(t.x-s[0].x,t.y-s[0].y)<=n.reach)return!0}if(n.fill)for(let u=0;u<s.length;u+=1){let a=s[u],c=s[(u+1)%s.length];a.y<=t.y!=c.y<=t.y&&a.x+(t.y-a.y)/(c.y-a.y)*(c.x-a.x)>t.x&&(o+=1,r+=c.y>a.y?1:-1)}}}return n.fill?n.rule==="evenodd"?o%2===1:r!==0:!1}function eo(e){let t=e.anchors[0];if(!t)return[];let n=[{x:t.x,y:t.y}],r=_e(e);for(let o=0;o<r;o+=1)n.push(...Vt(ut(e,o)).slice(1));return e.closed&&n.length>1&&n.pop(),n}function to(e,t,n){let r=n.x-t.x,o=n.y-t.y,i=r*r+o*o,s=i===0?0:Math.max(0,Math.min(1,((e.x-t.x)*r+(e.y-t.y)*o)/i));return Math.hypot(e.x-(t.x+s*r),e.y-(t.y+s*o))}var dt={canvas:[["name","string"],["w","numberValue"],["h","numberValue"],["background","stringValue"]],frame:[["name","string"],["x","numberValue"],["y","numberValue"],["w","numberValue"],["h","numberValue"],["background","stringValue"],["clip","boolean"],["skip","boolean"],["blend","blendMode"],["shadow","stringValue"],["hidden","boolean"],["locked","boolean"]],group:[["name","string"],["hidden","boolean"],["locked","boolean"]],ellipse:[["name","string"],["x","numberValue"],["y","numberValue"],["w","numberValue"],["h","numberValue"],["rotation","numberValue"],["fill","stringValue"],["stroke","stringValue"],["strokeWidth","numberValue"],["opacity","numberValue"],["blend","blendMode"],["shadow","stringValue"],["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"],["opacity","numberValue"],["rule","fillRule"],["cap","lineCap"],["join","lineJoin"],["blend","blendMode"],["shadow","stringValue"],["hidden","boolean"],["locked","boolean"]],rect:[["name","string"],["x","numberValue"],["y","numberValue"],["w","numberValue"],["h","numberValue"],["rotation","numberValue"],["fill","stringValue"],["stroke","stringValue"],["strokeWidth","numberValue"],["radius","numberValue"],["opacity","numberValue"],["blend","blendMode"],["shadow","stringValue"],["hidden","boolean"],["locked","boolean"]],image:[["name","string"],["x","numberValue"],["y","numberValue"],["w","numberValue"],["h","numberValue"],["rotation","numberValue"],["src","stringValue"],["fit","imageFit"],["radius","numberValue"],["opacity","numberValue"],["blend","blendMode"],["shadow","stringValue"],["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"],["opacity","numberValue"],["blend","blendMode"],["shadow","stringValue"],["hidden","boolean"],["locked","boolean"]]},ft=[["font","string"],["size","number"],["weight","number"],["italic","boolean"],["underline","boolean"],["strike","boolean"],["fill","string"],["letterSpacing","number"],["link","string"]];var lt=[["enter","pageEffect"],["duration","number"],["scroll","boolean"],["length","time"],["w","number"],["h","number"],["bpm","number"],["meter","number"]],Ae=[["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"]],pt=[["from","number"],["volume","number"],["fadein","time"],["fadeout","time"],["loop","boolean"]],Vn=Object.keys(dt);function ht(e){return Vn.includes(e)}function Bt(e,t){return dt[e].find(([n])=>n===t)?.[1]}function C(e,t){if(t==="boolean")return e===""||e==="true"?{value:!0}:e==="false"?{value:!1}:{error:`Expected true or false, got ${e}`};if(e.startsWith('"')){let r=U(e);return r===void 0?{error:`Malformed quoted string ${e}`}:Fn(r,t,e)}if(co(e)){if(!so(t))return{error:uo(e,t)};let r=Wn(e).trim();return r===""?{error:"Empty expression"}:{value:we(r)}}return t==="numberValue"&&Bn.test(e)?{value:we(e)}:Fn(e,t,e)}var Bn=/^-?\d+(?:\.\d+)?%$/;function so(e){return e==="numberValue"||e==="stringValue"}function uo(e,t){return t==="number"?`Expected a plain number, not an expression, got ${e}`:t==="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 Un(e,t){let n=/^(-?\d+(?:\.\d+)?)([A-Za-z]+)$/.exec(e);return n?/^(?:beats?|bars?)$/.test(n[2])?" \u2014 beats and bars count motion times on a page with bpm=; this is milliseconds":n[2]==="s"&&t==="number"?` \u2014 durations are milliseconds: ${Number(n[1])*1e3}`:/^(?:px|pt|deg|ms)$/.test(n[2])?` \u2014 drop the unit: ${n[1]}`:" \u2014 units are not supported: use a number, a percentage like (100%), or an expression":t==="number"?Bn.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 Fn(e,t,n){switch(t){case"numberValue":case"number":{let r=Number(e);return Number.isFinite(r)&&e.trim()!==""?{value:r}:{error:`Expected a number, got ${n}${Un(e,t)}`}}case"align":return ge.includes(e)?{value:e}:{error:`Expected one of ${ge.join(", ")}, got ${n}`};case"valign":return ye.includes(e)?{value:e}:{error:`Expected one of ${ye.join(", ")}, got ${n}`};case"fontStyle":return e==="normal"||e==="italic"?{value:e}:{error:`Expected normal or italic, got ${n}`};case"imageFit":return xe.includes(e)?{value:e}:{error:`Expected one of ${xe.join(", ")}, got ${n}`};case"fillRule":return z(Fe,e,n);case"lineCap":return z(je,e,n);case"lineJoin":return z(Ve,e,n);case"blendMode":return z(Ce,e,n);case"pageEffect":return z(Ye,e,n);case"nodeEffect":return z(Ke,e,n);case"emphasisEffect":return z(qe,e,n);case"ease":return z(Ze,e,n);case"piece":return z(Qe,e,n);case"time":{let r=ae(e);if(r)return{value:ce(r.count,r.unit)};let o=Number(e);return Number.isFinite(o)&&e.trim()!==""?{value:o}:{error:`Expected milliseconds or beats, got ${n}${ao(e)}`}}case"on":return Je.includes(e)?{value:e}:e==="downbeat"?{error:`Expected beat or bar, got ${n} \u2014 write on=bar: a bar starts on its downbeat`}:e==="beats"||e==="bars"?{error:`Expected beat or bar, got ${n} \u2014 write on=${e.slice(0,-1)}`}:{error:`Expected beat or bar, got ${n}`};case"from":{if(Z.includes(e))return{value:e};let r=Number(e);return Number.isFinite(r)&&e.trim()!==""?{value:r}:{error:`Expected a number or one of ${Z.join(", ")}, got ${n}`}}default:return{value:e}}}function ao(e){let t=/^(beat|bar|b)[:\s#]?(\d+(?:\.\d+)?)$/.exec(e);if(t){let r=t[1]==="bar"?"bar":"beat",o=Number(t[2]);return` \u2014 write ${ce(Math.max(0,o-1),r)} (counted from the start: ${r} ${o}'s ${r==="bar"?"downbeat":"start"})`}let n=/^(\d+(?:\.\d+)?)\s*(b|bt|beat|bars?|beats?)$/.exec(e);if(n){let r=n[2]?.startsWith("bar")?"bar":"beat";return` \u2014 write ${ce(Number(n[1]),r)} (counted from the start)`}return Un(e,"number")}function z(e,t,n){return e.includes(t)?{value:t}:{error:`Expected one of ${e.join(", ")}, got ${n}`}}function co(e){return/^[$@(]/.test(e)}function U(e){try{let t=JSON.parse(e);return typeof t=="string"?t:void 0}catch{return}}function Wn(e){if(!e.startsWith("("))return e;let t=0;for(let n=0;n<e.length;n+=1){let r=e[n];if(r==="(")t+=1;else if(r===")"&&(t-=1,t===0))return n===e.length-1?e.slice(1,-1):e}return e}function zn(e){let t=[],n="",r=0,o=!1;for(let i=0;i<e.length;i+=1){let s=e[i];if(o){n+=s,s==="\\"?(n+=e[i+1]??"",i+=1):s==='"'&&(o=!1);continue}if(s==='"'){o=!0,n+=s;continue}if(s==="("?r+=1:s===")"&&(r=Math.max(0,r-1)),r===0&&/\s/.test(s)){n!==""&&t.push(n),n="";continue}n+=s}return n!==""&&t.push(n),t}function Ut(e,t,n){let r=n===void 0?void 0:P(n);if(r?.value===void 0||!jn(e[t]??""))return;let o=t;for(;o<e.length&&jn(e[o]??"");)o+=1;let i=[Wn(r.value),...e.slice(t,o)].join(" ");return{end:o,message:`${r.key}: an expression with spaces needs parentheses \u2014 write ${r.key}=(${i})`}}function jn(e){return!e.includes("=")&&/^(?:[-+*/]|-?\d+(?:\.\d+)?%?|[$@][\w.]*|[A-Za-z_]\w*(?:\.\w+)+|\(.*|.*\))$/.test(e)}function P(e){let t=e.indexOf("=");return t===-1?{key:e,value:void 0}:{key:e.slice(0,t),value:e.slice(t+1)}}function Wt(e,t){let n,r=0,o,i=[],s=[],u={},a={},c={},d={},f=[],p=!1,h=!1,x,m=(l,w,b)=>{t.push({severity:"warning",code:w,message:`Line ${l}: ${b}`})},$=(l,w,b)=>{e(l.number,"invalid-brand",`${w} ${b} is written twice \u2014 keep one`)},E=l=>{if(n){e(l.number,"invalid-brand",`A document has one brand line; the first is on line ${r}`);return}let w=l.words[1]===void 0?void 0:It(l.words[1]);if(!w){e(l.number,"invalid-brand","Expected brand <slug>@<version>, e.g. brand ember@3 \u2014 a slug is lower case, digits and dashes");return}let b=l.words.slice(2).includes("strict"),g=X({...l,words:l.words.filter((_,L)=>L<2||_!=="strict")},2,["id","theme"],e),k=g.theme;k!==void 0&&!_t.includes(k)&&e(l.number,"invalid-brand",`theme= is light or dark, got ${k}`),n={...w,...g.id===void 0?{}:{id:g.id},...k==="dark"||k==="light"?{theme:k}:{},...b?{strict:!0}:{}},r=l.number,x={kind:"brand"}},v=l=>{let w=l.words[0];if(w==="summary"){let b=mt(l,1);b===void 0?e(l.number,"invalid-brand",'Expected summary "\u2026"'):o=b;return}if(w==="change"){let b=Number(l.words[1]),g=l.words[2]===void 0?void 0:Jn(l.words[2]);if(!Number.isSafeInteger(b)||b<1||g===void 0){e(l.number,"invalid-brand",'Expected change <version> "<what changed>" at=<date>');return}let k=X(l,3,["at"],e);i.push({version:b,note:g,...k.at===void 0?{}:{at:k.at}});return}if(w==="source"){let b=l.words[1];if(b===void 0||b.includes("=")){e(l.number,"invalid-brand","Expected source <kind> key=value\u2026, e.g. source site url=\u2026");return}s.push({kind:b,props:X(l,2,void 0,e)});return}if(w==="rule"){N(l);return}if(w==="banned"){let b=mt(l,1);if(b===void 0){e(l.number,"invalid-brand",'Expected banned "\u2026"');return}(d.voice??={entries:[]}).entries.push({kind:"banned",text:b});return}e(l.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`)},D=l=>{let w=l.words[1];if(w===void 0||w.includes("=")){e(l.number,"invalid-role","Expected role <name> light=<token or colour> dark=\u2026");return}let b=X(l,2,["light","dark"],e),g=b.light;if(g===void 0){e(l.number,"invalid-role",`role ${w} needs light=`);return}if(Object.prototype.hasOwnProperty.call(u,w))return $(l,"role",w);let k=b.dark;u[w]={light:Xn(g),...k===void 0?{}:{dark:Xn(k)}}},O=l=>{let w=l.words[1];if(w===void 0||w.includes("=")){e(l.number,"invalid-logo","Expected logo <id> asset=<name> min=<px> clear=<fraction>");return}let b=X(l,2,["asset","min","clear"],e),g=b.asset;if(g===void 0){e(l.number,"invalid-logo",`logo ${w} needs asset=`);return}let k={asset:g};for(let _ of["min","clear"]){let L=b[_];if(L===void 0)continue;let B=Number(L);if(!Number.isFinite(B)||B<0){e(l.number,"invalid-logo",`logo ${w}: ${_} must be a number, got ${L}`);continue}k[_]=B}if(Object.prototype.hasOwnProperty.call(a,w))return $(l,"logo",w);a[w]=k},N=l=>{let w=l.words[1],b=l.words[2],g=l.words[3],k=g?.startsWith('"')===!0?U(g):void 0;if(w===void 0||w.includes("=")){e(l.number,"invalid-rule",'Expected rule <id> must|should "<what it asks>" check=\u2026');return}if(b===void 0||!At.includes(b)){e(l.number,"invalid-rule",`rule ${w}: the second word is must or should`);return}if(k===void 0){e(l.number,"invalid-rule",`rule ${w} needs its words, quoted: rule ${w} ${b} "\u2026"`);return}let{check:_,...L}=X(l,4,void 0,e);if(_!==void 0&&!We.includes(_)&&m(l.number,"unknown-check",`rule ${w}: this build has no check "${_}", so it is kept as words only \u2014 the checks are ${We.join(", ")}`),Object.prototype.hasOwnProperty.call(c,w))return $(l,"rule",w);c[w]={level:b,text:k,..._===void 0?{}:{check:_},...Object.keys(L).length===0?{}:{params:L}}},S=(l,w)=>{let b=l.words[0];if(b.startsWith('"')){let g=mt(l,0);g===void 0?e(l.number,"invalid-guide",`Could not read ${l.text}`):w.push({kind:"line",text:g});return}if(b==="banned"||b==="avoid"){let g=mt(l,1);g===void 0?e(l.number,"invalid-guide",`Expected ${b} "\u2026"`):w.push({kind:b,text:g});return}if(b==="rewrite"){let g=X(l,1,["from","to"],e),k=g.from,_=g.to;if(k===void 0||_===void 0){e(l.number,"invalid-guide",'Expected rewrite from="\u2026" to="\u2026"');return}w.push({kind:"rewrite",from:k,to:_});return}if(b==="ref"||b==="approved"||b==="rejected"){let g=X(l,1,["asset","note"],e),k=g.asset;if(k===void 0){e(l.number,"invalid-guide",`Expected ${b} asset=<name> note="\u2026"`);return}let _=g.note;w.push({kind:b,asset:k,..._===void 0?{}:{note:_}});return}e(l.number,"invalid-guide",`"${b}" is not a guide line \u2014 a guide holds quoted lines, banned, avoid, rewrite, ref, approved and rejected`)},M=l=>{let w=l.words[0];if(w.includes("=")||w.startsWith('"')){e(l.number,"invalid-review",'Expected <what>.<id> from=\u2026 note="\u2026", e.g. role.muted from=site');return}let b=X(l,1,["from","note"],e);f.push({target:w,...b.from===void 0?{}:{from:b.from},...b.note===void 0?{}:{note:b.note}})};return{take(l){if(l.indent>0)return x?(x.kind==="brand"?v(l):x.kind==="guide"?S(l,x.entries):M(l),!0):!1;x=void 0;let w=l.words[0];if(w!=="brand"&&!ze(w))return!1;switch(h=!0,w){case"brand":E(l);break;case"role":D(l);break;case"logo":O(l);break;case"rule":N(l);break;case"guide":{let b=l.words[1];if(b===void 0||b.includes("=")||l.words.length>2){e(l.number,"invalid-guide","Expected guide <id> on its own line, e.g. guide voice"),x={kind:"guide",id:"",entries:[]};break}if(Object.prototype.hasOwnProperty.call(d,b)){$(l,"guide",b),x={kind:"guide",id:"",entries:[]};break}let g=[];d[b]={entries:g},x={kind:"guide",id:b,entries:g};break}case"review":l.words.length>1&&e(l.number,"invalid-review","review is a block: its items go on the lines under it"),p=!0,x={kind:"review"};break}return!0},finish(){if(!h)return{header:!1,review:!1};let l=n??Xe();return{brand:{slug:l.slug,version:l.version,...n?.id===void 0?{}:{id:n.id},...n?.theme===void 0?{}:{theme:n.theme},...n?.strict===!0?{strict:!0}:{},...o===void 0?{}:{summary:o},changes:i,sources:s,roles:u,logos:a,rules:c,guides:d,review:f},header:n!==void 0,review:p}}}}function X(e,t,n,r){let o={};for(let i of e.words.slice(t)){let{key:s,value:u}=P(i);if(u===void 0){r(e.number,"invalid-brand",`A stray word "${i}" \u2014 expected key=value`);continue}if(n!==void 0&&!n.includes(s)){r(e.number,"invalid-brand",`"${s}" is not allowed here; this line takes ${n.join(", ")}`);continue}o[s]=Jn(u)}return o}function mt(e,t){if(e.words.length!==t+1)return;let n=e.words[t];return n.startsWith('"')?U(n):void 0}function Jn(e){return e.startsWith('"')?U(e)??e:e}function Xn(e){return e.startsWith("$")?e.slice(1):e}var lo=new Set(["exit","delay","step","together","go","at","after","with"]),Kn=["at","after","with","together","step"],po=new Set(["pad","duration","delay","ease","on",...Kn]);function zt(e){if(e==="at"||e==="length")return et;if(e==="w"||e==="h")return Q;if(e==="duration"||e==="delay"||e==="stagger"||e==="hold")return Me;if(e==="pad")return Q}function Xt(e,t){let n=e.words[1];if(n===void 0||n.includes("=")){t(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}=P(i),a=lt.find(([d])=>d===s)?.[1];if(a===void 0){let d=lo.has(s)?` \u2014 ${s} goes on a node's line, under the header`:"";t(e.number,"invalid-motion",`motion ${n} has no "${s}"${d}`,n);continue}let c=C(u??"",a);"error"in c?t(e.number,"invalid-motion",`${s}: ${wo(s,u)??c.error}`,n):s==="bpm"&&!xo(c.value)?t(e.number,"invalid-motion",`bpm: expected ${20} to ${300} beats a minute, got ${u??""}`,n):s==="meter"&&!bo(c.value)?t(e.number,"invalid-motion",`meter: expected a whole number of beats in a bar, 1 to ${16}, got ${u??""}`,n):c.value!==!1&&(r[s]=c.value)}let o=q({...r,lines:[]});for(let[i]of lt){let s=r[i];if(s===void 0||zt(i)===void 0)continue;let u=Jt(i,s,o,n);u!==void 0&&(t(e.number,"invalid-motion",u,n),delete r[i])}return{page:n,number:e.number,head:r,lines:[],where:new Map,taken:new Map,numbers:[]}}function Gt(e,t,n){if(t.words[0]==="music"&&!(t.words[1]??"").includes("=")){mo(e,t,n);return}let r=t.words[0]==="camera"&&t.words[1]!==void 0&&!t.words[1].includes("="),o=r?t.words.slice(1):t.words,i=o[0];if(t.indent!==1){n(t.number,"invalid-motion","A motion line sits one level under its page");return}if(i.includes("=")){n(t.number,"invalid-motion",`Expected a node id first, got ${i}`);return}if(i===e.page&&!r){n(t.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:p}=P(d),h=Ae.find(([$])=>$===f)?.[1];if(h===void 0){n(t.number,"invalid-motion",`A motion line has no "${f}"${$o(f)}`,i),u=!1;continue}if(r&&!po.has(f)){n(t.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 x=C(p??"",h),m="error"in x||zt(f)===void 0?void 0:Jt(f,x.value,q(qn(e)),e.page);"error"in x?(n(t.number,"invalid-motion",`${f}: ${x.error}`,i),u=!1):m!==void 0?(n(t.number,"invalid-motion",`${i}: ${m}`,i),u=!1):f==="on"&&e.head.bpm===void 0?(n(t.number,"invalid-motion",`${i}: on=${String(x.value)} needs a tempo \u2014 motion ${e.page} bpm=120`,i),u=!1):f==="go"&&le(x.value)===void 0?(n(t.number,"invalid-motion",`go: expected #<page>, back, next, or an https: or mailto: link, got ${p??""}`,i),u=!1):x.value!==!1&&(s[f]=x.value)}s.enter!==void 0&&s.exit!==void 0&&(n(t.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)&&(n(t.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=Kn.filter(d=>s[d]!==void 0);if(s.step===!0&&s.together===!0?(n(t.number,"invalid-motion",`${i} waits for a step or starts together with the line above, not both`,i),u=!1):a.length>1?(n(t.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)&&(n(t.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=ko(s);d!==void 0&&(n(t.number,"invalid-motion",`${i}: ${d}`,i),u=!1)}if(!u)return;let c=yo(s);if(!tt(c)){n(t.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,t.number),e.lines.push(c),e.numbers.push(t.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 p=d==="go"?"has a go=":d==="enter"?"enters":d==="exit"?"exits":"has an emphasis=";n(t.number,"invalid-motion",`${i} already ${p} on line ${f}`,i);return}}for(let d of["enter","exit","emphasis","go"])c[d]!==void 0&&e.taken.set(`${i} ${d}`,t.number);e.where.has(i)||e.where.set(i,t.number),e.lines.push(c),e.numbers.push(t.number)}function Ht(e){let t={...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 Oe(t)?void 0:t}var ho=new Set(["loop","step","together"]);function mo(e,t,n){let r=t.words[1];if(t.indent!==1){n(t.number,"invalid-motion","A motion line sits one level under its page");return}if(r===void 0){n(t.number,"invalid-motion","Expected music <asset>, e.g. music bed fadeout=1500");return}if(ho.has(r)){n(t.number,"invalid-motion",`music names its track first: music <asset> ${r}`);return}if(e.musicLine!==void 0){n(t.number,"invalid-motion",`motion ${e.page} already has music on line ${e.musicLine}: a page has one track`);return}let o={asset:r},i=q(qn(e)),s=!0,u=c=>{n(t.number,"invalid-motion",`music ${r}: ${c}`),s=!1};for(let c of t.words.slice(2)){let{key:d,value:f}=P(c),p=pt.find(([x])=>x===d)?.[1];if(p===void 0){u(`the music line has no "${d}"${go(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 h=C(f??"",p);if("error"in h){u(`${d}: ${h.error}`);continue}if(d==="from"&&!Yn(h.value,0,Se)){u(`from: expected 0 to ${Se} milliseconds, got ${f??""}`);continue}if(d==="volume"&&!Yn(h.value,0,1)){u(`volume: expected 0 to 1, got ${f??""}`);continue}if(d==="fadein"||d==="fadeout"){let x=Jt(d,h.value,i,e.page);if(x!==void 0){u(x);continue}}h.value!==!1&&(o[d]=h.value)}if(!s)return;let a={asset:r};for(let[c]of pt)o[c]!==void 0&&(a[c]=o[c]);e.music=a,e.musicLine=t.number}function Yn(e,t,n){return typeof e=="number"&&e>=t&&e<=n}function go(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 yo(e){let t=e.camera===!0?{id:e.id,camera:!0}:{id:e.id};for(let[n]of Ae)e[n]!==void 0&&(t[n]=e[n]);return t}function qn(e){let{bpm:t,meter:n}=e.head;return{...t===void 0?{}:{bpm:t},...n===void 0?{}:{meter:n},lines:[]}}function Jt(e,t,n,r){if(de(t)&&!n)return`${t} needs a tempo \u2014 motion ${r} bpm=120`;let o=typeof t=="number"||de(t)?Ee(t,n):void 0,i=zt(e)??Me;if(o!==void 0&&o>=(e==="w"||e==="h"?16:0)&&o<=i)return;let u=String(t),a=de(t)&&o!==void 0?` (${Math.round(o)} ms)`:"";return e==="w"||e==="h"?`${e}: expected 16 to ${Q} pixels, got ${u}`:e==="pad"?`pad: expected 0 to ${Q}, got ${u}`:`${e}: expected 0 to ${i} milliseconds, got ${u}${a}`}function xo(e){return typeof e=="number"&&e>=20&&e<=300}function bo(e){return typeof e=="number"&&Number.isInteger(e)&&e>=1&&e<=16}function wo(e,t){if(e==="meter"&&t!==void 0&&/^\d+\/\d+$/.test(t))return`Expected beats in a bar, got ${t} \u2014 meter is beats per bar: meter=${t.split("/")[0]??""}`;if(e==="duration"&&t!==void 0&&/\d(?:beats?|bars?)$/.test(t))return`Expected milliseconds, got ${t} \u2014 the page transition is milliseconds; beats are for the lines`}function $o(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 ko(e){let t=e.enter,n=e.exit,r=t??n,o=e.from;if(n==="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: ${Z.join(", ")}`}else return"from= goes with count (a number), or wipe and grow (a side)";if(e.by!==void 0&&r!==void 0&&!fe.includes(r))return`by= splits a text for ${fe.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&&t===void 0)return"hold= goes with enter=: how long to stay before leaving the way it came"}function Yt(e){return(t,n,r,o)=>{e.push({severity:"error",code:n,message:`Line ${t}: ${r}`,...o===void 0?{}:{nodeId:o}})}}function Kt(e){let t=[],n=e.split(`
|
|
5
|
-
`);for(let r=0;r<n.length;r+=1){let o=n[r],i=o.trim();if(i===ie)break;if(i===""||i.startsWith("```"))continue;let s=o.length-o.trimStart().length;t.push({number:r+1,indent:Math.floor(s/2),text:i,words:zn(i)})}return t}function qt(e){let t=[],n=[],r=o=>{for(;t.length>0&&t[t.length-1].indent>=o;)So(t.pop())};return{push(o){let i=o.words[0];if(i.startsWith('"')){let c=t[t.length-1];if(!c||c.type!=="text")return e(o.number,"invalid-content","A quoted line must sit inside a text node"),!0;let d=Oo(o,e);return d!==void 0&&c.runs.push(d),!0}if(!ht(i))return!1;r(o.indent);let s=o.words[1];if(s===void 0||s.includes("="))return e(o.number,"missing-id",`A ${i} needs an id`),!0;let u=Eo(i,s,o.words.slice(2),o,e),a=t[t.length-1];return a?a.children.push(u.record):n.push(u.record),t.push(u),!0},finish(){return r(0),n}}}function Eo(e,t,n,r,o){let i={type:e,id:t},s=[];for(let u=0;u<n.length;u+=1){let{key:a,value:c}=P(n[u]),d=Bt(e,a);if(d===void 0){let p=Ut(n,u,n[u-1]);p?(o(r.number,"invalid-value",p.message,t),u=p.end-1):o(r.number,"invalid-value",`${e} has no property "${a}"`,t);continue}let f=C(c??"",d);"error"in f?o(r.number,"invalid-value",`${a}: ${f.error}`,t):i[a]=f.value}return Be(e)&&(i.children=s),e==="text"&&(i.content=""),{indent:r.indent,type:e,record:i,children:s,runs:[]}}function So(e){e.type==="text"&&(e.record.content=Mo(e.runs))}function Mo(e){if(e.length===0)return"";let t=e[0];return e.length===1&&typeof t=="string"?t:[...e]}function Oo(e,t){let n=U(e.words[0]);if(n===void 0){t(e.number,"invalid-run","Malformed quoted string");return}if(e.words.length===1)return n;let r={text:n};for(let o of e.words.slice(1)){let{key:i,value:s}=P(o),u=ft.find(([c])=>c===i);if(!u){t(e.number,"invalid-run",`A run has no mark "${i}"`);continue}let a=C(s??"",u[1]);"error"in a?t(e.number,"invalid-run",`${i}: ${a.error}`):r[i]=a.value}return r}function To(e){let t=[],n=Yt(t),r=se,o,i=!1,s={},u={},a={},c=qt(n),d=Wt(n,t),f,p={},h=!1,x=!1,m={},$=new Map,E,v=!1,D=()=>{if(!E)return;let g=E;E=void 0;let k=$.get(g.page);if(k!==void 0){n(g.number,"invalid-motion",`motion ${g.page} is written twice \u2014 put its lines in the block on line ${k}`,g.page);return}$.set(g.page,g.number);for(let[L,B]of g.where)$.set(`${g.page} ${L}`,B);let _=Ht(g);_&&(m[g.page]=_)};for(let g of Kt(e)){let k=g.words[0];if(E&&g.indent>0){Gt(E,g,n);continue}if(!(v&&g.indent>0)){if(v=!1,D(),k==="motion"&&g.indent===0){f=void 0,E=Xt(g,n),v=E===void 0;continue}if(d.take(g)){f=void 0;continue}if(k==="version"){i=!0,Ao(g,t);continue}if(k==="kind"&&g.indent===0){r=Io(g,t);continue}if(k==="title"&&g.indent===0){o=Zn(g,n);continue}if(k==="theme"&&g.indent===0){f=void 0,h=!0,x&&n(g.number,"invalid-theme","theme dark is written twice \u2014 keep one block"),x=!0,(g.words[1]!=="dark"||g.words.length>2)&&n(g.number,"invalid-theme","Expected theme dark on its own line, with the tokens that differ indented under it");continue}if(k.startsWith("$")){if(f=void 0,h&&g.indent>0){Zt(g,p,n);continue}h=!1,Zt(g,s,n);continue}if(g.indent===0)h=!1;else if(h){n(g.number,"invalid-theme","A theme block holds only $name = value lines");continue}if(k==="asset"&&g.indent===0){f=void 0,Po(g,a,n);continue}if(k==="font"&&g.indent===0){f=Do(g,u,n);continue}if((k==="fallback"||k==="face")&&f){Co(k,g,f,n);continue}f=void 0,!c.push(g)&&n(g.number,"unknown-node-type",`Unknown statement "${k}"`)}}D();let O=_o(d.finish(),r,t),N=ue({dark:p}),S={...O===void 0?{}:{brand:O},...N===void 0?{}:{themes:N}},M=No(c.finish(),t),l=Object.keys(m).length===0?{}:{motion:m},w=(g,k)=>$.get(k===void 0?g:`${g} ${k}`);if(!M){i||t.push({severity:"error",code:"invalid-document",message:"No nodes found"});let g=ve({id:K,children:[]}),k=He({kind:r,...o===void 0?{}:{title:o},tokens:s,fonts:u,assets:a,...l,...S,root:g});return t.push(...Te(k,w)),{document:k,problems:t}}let b={version:H({kind:r,fonts:u,...S}),kind:r,...o===void 0?{}:{title:o},tokens:s,fonts:u,assets:a,...l,...S,root:M};return t.push(...Te(b,w)),{document:b,problems:t}}function No(e,t){let n=e[0];if(n!==void 0){if(e.length===1&&n.type==="canvas")return n;for(let r of e){if(r.type!=="canvas")continue;let o=r.id;t.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:K,children:[...e]}}}function _o(e,t,n){let r=e.brand;if(!r)return;e.header||n.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 t!=="brand"&&i>0&&n.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 Ao(e,t){Ge.includes(Number(e.words[1]))||t.push({severity:"warning",code:"version-mismatch",message:`Line ${e.number}: expected version ${ke} or older, got ${e.words[1]??"nothing"}`})}function Io(e,t){let n=e.words[1];return n!==void 0&&$e.includes(n)?n:(t.push({severity:"error",code:"unknown-kind",message:`Line ${e.number}: unknown kind "${n??"nothing"}" \u2014 this build reads ${$e.join(", ")}`}),se)}function Zn(e,t){let n=e.words.slice(1).join(" ").trim();if(n===""){t(e.number,"invalid-value",'title needs a name, e.g. title "Pitch deck"');return}let r=n.startsWith('"')?U(n):n;if(r===void 0){t(e.number,"invalid-value",`Could not read the title ${n}`);return}return r.trim()===""?void 0:r}function Zt(e,t,n){let{name:r,value:o}=Qt(e.words);if(r===void 0||o===void 0){n(e.number,"invalid-token","Expected $name = value");return}if(!o.startsWith('"')&&/\s/.test(o)){n(e.number,"invalid-token",`$${r}: expected one value, got "${o}". Quote it if the value has spaces; there are no comments.`);return}let i=C(o,"stringValue");if("error"in i){n(e.number,"invalid-token",`$${r}: ${i.error}`);return}if(typeof i.value!="string"){n(e.number,"invalid-token",`$${r} may not be an expression`);return}t[r]=Qn(i.value,o)}function Qn(e,t){let n=Number(e);return t.startsWith('"')||!Number.isFinite(n)||e.trim()===""?e:n}function Qt(e){let t=e[0],n=i=>i.startsWith("$")?i.slice(1):i;if(e[1]==="=")return{name:n(t),value:e.slice(2).join(" ")||void 0};let{key:r,value:o}=P(t);return o!==void 0?{name:n(r),value:o}:{name:n(t)}}function Po(e,t,n){let r=e.words.slice(1),o=r[0],i=r[1]==="=",s=o===void 0?void 0:P(o),u=s?.key,a=i?r[2]:s?.value,c=r.slice(i?3:1);if(u===void 0||u===""||a===void 0){n(e.number,"invalid-asset","Expected asset <name> = <type> hash=\u2026 bytes=\u2026");return}let d={};for(let x of c){let{key:m,value:$}=P(x);if($===void 0){n(e.number,"invalid-asset",`Asset "${u}" has a stray word "${x}"`);continue}d[m]=Ro($)}let f=d.hash,p=Number(d.bytes);if(f===void 0||!Number.isFinite(p)){n(e.number,"invalid-asset",`Asset "${u}" needs a hash and a bytes count`);return}let h=d.ms===void 0?void 0:Number(d.ms);if(h!==void 0&&!(Number.isFinite(h)&&h>=0)){n(e.number,"invalid-asset",`Asset "${u}": ms is the track's length, in milliseconds`);return}t[u]={type:a,hash:f,bytes:p,...h===void 0?{}:{ms:h},...d.credit===void 0?{}:{credit:d.credit},...d.source===void 0?{}:{source:d.source},...d.license===void 0?{}:{license:d.license}}}function Ro(e){return e.startsWith('"')?U(e)??e:e}function Do(e,t,n){let{name:r,value:o}=Qt(e.words.slice(1));if(r===void 0||o===void 0){n(e.number,"invalid-font","Expected font <name> = <family>");return}let i=C(o,"string"),s={family:"error"in i?o:i.value};return t[r]=s,{family:s,faces:[]}}var Lo=/^[A-Za-z_][\w-]*$/;function Co(e,t,n,r){if(e==="fallback"){let u=C(t.words.slice(1).join(" "),"string");"error"in u?r(t.number,"invalid-font",`fallback: ${u.error}`):n.family.fallback=u.value;return}let o=t.words[1];if(o===void 0){r(t.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(!Lo.test(i)){r(t.number,"invalid-font-face",`asset=${i}: not an asset name`);return}s.asset=i}else{let u=C(o,"string");s.src="error"in u?o:u.value}for(let u of t.words.slice(2)){let{key:a,value:c}=P(u);if(a!=="weight"&&a!=="style"){r(t.number,"invalid-font-face",`A face has no property "${a}"`);continue}let d=C(c??"",a==="weight"?"number":"fontStyle");"error"in d?r(t.number,"invalid-font-face",`${a}: ${d.error}`):s[a]=d.value}n.faces.push(s),n.family.faces=n.faces}var tr="https://getv.design/ns/vd",Tu=`<metadata><vd:document xmlns:vd="${tr}" version="1"><![CDATA[
|
|
6
|
-
`;var Uo=/<vd:document\b[^>]*>([\s\S]*?)<\/vd:document\s*>/;function Wo(e){let t=Uo.exec(e);if(!t)return;let n=t[1]??"",r="",o=n;for(;;){let i=o.indexOf("<![CDATA[");if(i===-1){r+=er(o);break}r+=er(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 zo(e){return/^\uFEFF?\s*</.test(e)}function er(e){return e.replace(/&(lt|gt|quot|apos|amp|#\d+|#x[0-9a-fA-F]+);/g,(t,n)=>{switch(n){case"lt":return"<";case"gt":return">";case"quot":return'"';case"apos":return"'";case"amp":return"&";default:{let r=n.startsWith("#x")?parseInt(n.slice(2),16):parseInt(n.slice(1),10);return Number.isFinite(r)&&r<=1114111?String.fromCodePoint(r):t}}})}var nr=.04,rr=.85;var Zo=[.2,0,0,1],Qo=[.4,0,1,1],ei=[.4,0,.2,1];function bt(e){return/^\s*(linear|radial|conic|repeating-[a-z]+)-gradient\s*\(/i.test(e)}function en(e){let t=e.trim(),n=/^([a-z-]+)-gradient\s*\(([\s\S]*)\)$/i.exec(t);if(!n)return bt(t)?{error:'A gradient needs its closing ")"'}:{kind:"solid",colour:t};let r=n[1].toLowerCase(),o=ti(n[2]).map(i=>i.trim());if(o.some(i=>i===""))return{error:"A gradient has an empty argument"};if(r==="linear"){let i=ri(o[0]),s=ir(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=ii(o[0]);if(i&&"error"in i)return i;let s=ir(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 tn(e){let t=e.map(r=>r.at);t[0]===void 0&&(t[0]=0),t[t.length-1]===void 0&&(t[t.length-1]=1);let n=0;for(let r=0;r<t.length;r+=1){let o=t[r];o!==void 0&&(n=Math.max(n,o),t[r]=n)}for(let r=1;r<t.length;r+=1){if(t[r]!==void 0)continue;let o=r-1,i=r;for(;t[i]===void 0;)i+=1;let s=t[o],u=t[i];for(let a=r;a<i;a+=1)t[a]=s+(u-s)*(a-o)/(i-o);r=i}return e.map((r,o)=>({colour:r.colour,at:t[o]}))}function ti(e){let t=[],n=0,r=0;for(let o=0;o<e.length;o+=1){let i=e[o];i==="("?n+=1:i===")"?n=Math.max(0,n-1):i===","&&n===0&&(t.push(e.slice(r,o)),r=o+1)}return t.push(e.slice(r)),t}var ni={top:[0,-1],bottom:[0,1],left:[-1,0],right:[1,0]};function ri(e){let t=/^(-?\d*\.?\d+)(deg|turn|rad)$/i.exec(e);if(t){let i=Number(t[1]),s=t[2].toLowerCase();return s==="turn"?i*360:s==="rad"?i*180/Math.PI:i}let n=/^to\s+([a-z]+)(?:\s+([a-z]+))?$/i.exec(e);if(!n)return;let r=0,o=0;for(let i of[n[1],n[2]]){if(i===void 0)continue;let s=ni[i.toLowerCase()];if(!s)return;r+=s[0],o+=s[1]}return(Math.atan2(r,-o)*180/Math.PI+360)%360}var oi={left:0,top:0,center:.5,right:1,bottom:1};function ii(e){let t=/^(circle|ellipse)?\s*(?:at\s+(\S+)(?:\s+(\S+))?)?$/i.exec(e);if(!t||t[1]===void 0&&t[2]===void 0)return;let n=t[1]?.toLowerCase();if(t[2]===void 0)return n?{shape:n}:void 0;let r=or(t[2]),o=t[3]===void 0?.5:or(t[3]);return r===void 0||o===void 0?{error:`A radial centre is two percentages or keywords, not "${e}"`}:{...n?{shape:n}:{},cx:r,cy:o}}function or(e){let t=oi[e.toLowerCase()];if(t!==void 0)return t;let n=/^(-?\d*\.?\d+)%$/.exec(e);return n?Number(n[1])/100:void 0}function ir(e){if(e.length<2)return{error:"A gradient needs at least two colours"};let t=[];for(let n of e){let r=/^([\s\S]*?\S)\s+(-?\d*\.?\d+)%$/.exec(n);if(r&&si(r[1]))t.push({colour:r[1],at:Number(r[2])/100});else{if(/\s/.test(n.replace(/\([^)]*\)/g,"")))return{error:`"${n}" is not a colour with an optional percentage`};t.push({colour:n})}}return{stops:t}}function si(e){let t=0;for(let n of e)if(n==="("&&(t+=1),n===")"&&(t-=1),t<0)return!1;return t===0}function nn(e){let t=e.trim();if(t===""||t==="none")return{shadows:[]};let n=[];for(let r of ui(t)){let o=ai(r.trim());if(o.includes("inset"))return{error:"Inner shadows (inset) are not supported yet"};let i=[],s=[];for(let f of o){let p=/^(-?\d*\.?\d+)(px)?$/.exec(f);p&&s.length===0?i.push(Number(p[1])):s.push(f)}if(i.length<2||i.length>4)return{error:`"${r.trim()}" needs x, y, then optional blur and spread`};if(s.length!==1)return{error:`"${r.trim()}" needs one colour after its numbers`};let[u=0,a=0,c=0,d=0]=i;if(c<0)return{error:"A shadow cannot have a negative blur"};n.push({x:u,y:a,blur:c,spread:d,colour:s[0]})}return{shadows:n}}function ui(e){let t=[],n=0,r=0;for(let o=0;o<e.length;o+=1){let i=e[o];i==="("?n+=1:i===")"?n=Math.max(0,n-1):i===","&&n===0&&(t.push(e.slice(r,o)),r=o+1)}return t.push(e.slice(r)),t}function ai(e){let t=[],n=0,r="";for(let o of e){if(o==="("&&(n+=1),o===")"&&(n=Math.max(0,n-1)),/\s/.test(o)&&n===0){r!==""&&t.push(r),r="";continue}r+=o}return r!==""&&t.push(r),t}function wt(e){return{x:e.x+e.w/2,y:e.y+e.h/2}}function sr(e,t,n){if(n===0)return e;let r=n*Math.PI/180,o=Math.cos(r),i=Math.sin(r),s=e.x-t.x,u=e.y-t.y;return{x:t.x+s*o-u*i,y:t.y+s*i+u*o}}function rn(e,t,n=wt(e)){if(t%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=>sr(a,n,t)),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 ar="system-ui, -apple-system, Segoe UI, Roboto, sans-serif",cr=16,dr=400,fr=1.2,$t="#0F172A";function kt(){return{advance(e,t){return e.length*(t.size*.5+t.letterSpacing)},metrics(e){return{ascent:e.size*.8,descent:e.size*.2,lineGap:0}}}}function on(e,t){if(e===void 0)return ar;let n=t[e];return n?n.fallback?`${ur(n.family)}, ${n.fallback}`:ur(n.family):e}function ur(e){return/^[A-Za-z][A-Za-z0-9 -]*$/.test(e)?e:JSON.stringify(e)}function sn(e,t,n,r){let o={family:on(t.font,n),size:t.size,weight:t.weight,italic:t.italic,underline:!1,strike:!1,fill:r(t.fill),letterSpacing:t.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:on(a.font,n),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&&Y(a.link)?{link:a.link}:{}}})}return s}function pi(e,t){let n=[];for(let r of e)for(let o of r.text.split(/(\n)/))if(o!==""){if(o===`
|
|
8
|
-
`){let i=n[n.length-1];i&&!i.hardBreak?n[n.length-1]={...i,hardBreak:!0}:n.push({text:"",style:r.style,w:0,hardBreak:!0});continue}for(let i of o.match(/\S+\s*|\s+/g)??[])n.push({text:i,style:r.style,w:t.advance(i,r.style),hardBreak:!1})}return n}function hi(e,t,n){let r=[...e.text],o=[],i="";for(let s of r){let u=i+s;if(i!==""&&n.advance(u,e.style)>t){o.push({text:i,style:e.style,w:n.advance(i,e.style),hardBreak:!1}),i=s;continue}i=u}return i!==""&&o.push({text:i,style:e.style,w:n.advance(i,e.style),hardBreak:e.hardBreak}),o.length>0?o:[e]}function lr(e,t){let{width:n,measure:r}=t,o=pi(r.itemize?e.flatMap(c=>r.itemize?.(c)??[c]):e,r);if(o.length===0){let c=e[0]?.style,d=c?t.lineHeight*c.size:0;return{lines:c?[mi(c,t.lineHeight)]:[],width:0,height:d}}let i=[],s=[],u=0,a=()=>{i.push(s),s=[],u=0};for(let c of o){let d=s.length===0&&c.w>n&&n>0?hi(c,n,r):[c];for(let f of d){let p=f.text.trimEnd(),h=p===f.text?f.w:r.advance(p,f.style);s.length>0&&u+h>n&&a(),s.push(f),u+=f.w,f.hardBreak&&a()}}return s.length>0&&i.push(s),gi(i,t)}function mi(e,t){let n=t*e.size;return{y:0,h:n,baseline:n*.8,w:0,spans:[],style:e}}function gi(e,t){let n=[],r=0,o=0;return e.forEach((i,s)=>{let u=i.map(M=>M.style.size),a=Math.max(...u,0),c=t.lineHeight*a,d=i.map(M=>t.measure.metrics(M.style)),f=Math.max(...d.map(M=>M.ascent),0),p=Math.max(...d.map(M=>M.descent),0),h=r+(c-(f+p))/2+f,x=yi(i,t.measure),m=x.reduce((M,l)=>M+l.w,0);o=Math.max(o,m);let $=s===e.length-1||(i[i.length-1]?.hardBreak??!1),E=t.align==="justify"&&!$&&x.length>1,v=Math.max(0,t.width-m),D=t.align==="center"?v/2:t.align==="right"?v:0,O=E?v/(x.length-1):0,N=[],S=D;x.forEach((M,l)=>{N.push({text:M.text,style:M.style,x:S,w:M.w}),S+=M.w+(l<x.length-1?O:0)}),n.push({y:r,h:c,baseline:h,w:m,spans:xi(N,E)}),r+=c}),{lines:n,width:o,height:r}}function yi(e,t){let n=[...e];for(;n.length>0;){let r=n[n.length-1],o=r.text.trimEnd();if(o===r.text)break;if(o===""){n.pop();continue}n[n.length-1]={...r,text:o,w:t.advance(o,r.style)};break}return n}function xi(e,t){if(t)return[...e];let n=[];for(let r of e){let o=n[n.length-1];if(o&&pr(o.style,r.style)&&Math.abs(o.x+o.w-r.x)<.01){n[n.length-1]={...o,text:o.text+r.text,w:o.w+r.w};continue}n.push(r)}return n}function pr(e,t){return e.family===t.family&&e.size===t.size&&e.weight===t.weight&&e.italic===t.italic&&e.underline===t.underline&&e.strike===t.strike&&e.fill===t.fill&&e.letterSpacing===t.letterSpacing&&e.link===t.link}function un(e,t,n,r,o,i){let s={size:t.size??cr,weight:t.weight??dr,lineHeight:t.lineHeight??fr,letterSpacing:t.letterSpacing??0,italic:e.italic??!1,font:typeof e.font=="string"?e.font:void 0,fill:typeof e.fill=="string"?e.fill:$t},u=sn(e.content,s,r,o),a=sn(" ",s,r,o).map(c=>({...c,text:""}));return lr(u.length>0?u:a,{width:n,align:e.align??"left",lineHeight:s.lineHeight,measure:i})}function an(e,t,n){let r=t-n;return e.valign==="middle"?r/2:e.valign==="bottom"?r:0}var hr=["x","y","w","h","left","right","top","bottom","cx","cy"];function Ie(e){return hr.includes(e)}var mr=["parent","prev","next","self","root"];function cn(e){return mr.includes(e)}var R=class extends Error{position;constructor(t,n){super(t),this.position=n,this.name="ExprSyntaxError"}},gr=/[A-Za-z_]/,dn=/[A-Za-z0-9_]/;function fn(e){let t=[],n=0,r=()=>{if(!gr.test(e[n]??""))throw new R(`Expected a name at position ${n}`,n);let s=n;for(;n<e.length&&dn.test(e[n]??"");)n++;return e.slice(s,n)},o=()=>{if(!dn.test(e[n]??""))throw new R(`Expected a name at position ${n}`,n);let s=n;for(;n<e.length&&dn.test(e[n]??"");)n++;return e.slice(s,n)},i=()=>{let s=[r()];for(;e[n]===".";)n++,s.push(o());return s};for(;n<e.length;){let s=e[n]??"";if(/\s/.test(s)){n++;continue}if(/[0-9]/.test(s)){let u=n;for(;n<e.length&&/[0-9]/.test(e[n]??"");)n++;if(e[n]==="."&&/[0-9]/.test(e[n+1]??""))for(n++;n<e.length&&/[0-9]/.test(e[n]??"");)n++;let a=e.slice(u,n),c=Number(a);if(!Number.isFinite(c))throw new R(`Bad number "${a}"`,u);e[n]==="%"?(n++,t.push({type:"percent",value:c})):t.push({type:"number",value:c});continue}if(s==="$"){n++,t.push({type:"token",name:r()});continue}if(s==="@"){n++,t.push({type:"ref",path:i()});continue}if(gr.test(s)){t.push({type:"word",path:i()});continue}if("+-*/()".includes(s)){n++,t.push({type:"op",value:s});continue}throw new R(`Unexpected character "${s}" at position ${n}`,n)}return t.push({type:"eof"}),t}var bi={"+":1,"-":1,"*":2,"/":2};function vt(e){try{let t=fn(e),n=new ln(t),r=n.parseBinary(0);return n.expectEof(),{ok:!0,ast:r}}catch(t){if(t instanceof R)return{ok:!1,message:t.message};throw t}}var ln=class{tokens;index=0;constructor(t){this.tokens=t}peek(){return this.tokens[this.index]??{type:"eof"}}next(){let t=this.peek();return this.index++,t}expectEof(){if(this.peek().type!=="eof")throw new R("Unexpected trailing input",this.index)}parseBinary(t){let n=this.parseUnary();for(;;){let r=this.peek();if(r.type!=="op"||!wi(r.value))break;let o=bi[r.value];if(o<t)break;this.next();let i=this.parseBinary(o+1);n={kind:"binary",op:r.value,left:n,right:i}}return n}parseUnary(){let t=this.peek();return t.type==="op"&&(t.value==="-"||t.value==="+")?(this.next(),{kind:"unary",op:t.value,operand:this.parseUnary()}):this.parsePrimary()}parsePrimary(){let t=this.next();switch(t.type){case"number":return{kind:"number",value:t.value};case"percent":return{kind:"percent",value:t.value};case"token":return{kind:"token",name:t.name};case"ref":{if(t.path.length<2)throw new R(`@${t.path.join(".")} needs an edge, for example @${t.path.join(".")}.right`,this.index);return{kind:"nodeRef",path:t.path}}case"word":{let[n,r,...o]=t.path;if(n===void 0||!cn(n))throw new R(`Unknown name "${t.path.join(".")}". Use $token for a token or @id.edge for a node.`,this.index);if(r===void 0||!Ie(r)||o.length>0)throw new R(`${n} needs an edge, for example ${n}.w`,this.index);return{kind:"relRef",word:n,edge:r}}case"op":{if(t.value==="("){let n=this.parseBinary(0),r=this.next();if(r.type!=="op"||r.value!==")")throw new R("Missing closing parenthesis",this.index);return n}throw new R(`Unexpected "${t.value}"`,this.index)}case"eof":throw new R("Unexpected end of expression",this.index)}}};function wi(e){return e==="+"||e==="-"||e==="*"||e==="/"}function W(e,t){return`${e} ${t}`}function pn(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 hn(e,t,n,r,o){switch(e){case"x":case"left":return t;case"y":case"top":return n;case"w":return r;case"h":return o;case"right":return t+r;case"bottom":return n+o;case"cx":return t+r/2;case"cy":return n+o/2}}function mn(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 gn(e,t,n){let r=f=>{let p=[];for(let h=n.parentOf.get(f);h!==void 0;h=n.parentOf.get(h))p.push(h);return p},o=r(e),i=r(t),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,p)=>{let h=(c.get(f)??0)+p;h===0?c.delete(f):c.set(f,h)};for(let f of a(o))d(f,1);for(let f of a(i))d(f,-1);return c}function yn(e){switch(e){case"right":case"bottom":return 1;case"cx":case"cy":return .5;default:return 0}}function Et(e){if(e==="x"||e==="w")return"w";if(e==="y"||e==="h")return"h"}function xn(e){let t=new Map,n=new Map,r=new Map,o=new Map,i=[];I(e.root,(d,f)=>{t.has(d.id)||t.set(d.id,d),i.push(d),f&&n.set(d.id,f.id),F(d)&&d.children.forEach((p,h)=>{let x=d.children[h-1],m=d.children[h+1];x&&r.set(p.id,x.id),m&&o.set(p.id,m.id)})});let s=new Map;for(let d of i){let f=n.get(d.id);for(;f!==void 0;){let p=t.get(f);if(!p||!be(p))break;f=n.get(f)}f!==void 0&&s.set(d.id,f)}let u=new Map,a=new Map,c=d=>{if(F(d)){if(!be(d)){let f=yr(d);f.forEach((p,h)=>{let x=f[h-1],m=f[h+1];x&&u.set(p.id,x.id),m&&a.set(p.id,m.id)})}for(let f of d.children)c(f)}};return c(e.root),{rootId:e.root.id,byId:t,parentOf:n,prevOf:r,nextOf:o,layoutParentOf:s,layoutPrevOf:u,layoutNextOf:a,order:i}}function yr(e){let t=[];for(let n of e.children)F(n)&&be(n)?t.push(...yr(n)):t.push(n);return t}function St(e,t,n){if(e.kind==="relRef"){let i=$i(e.word,t,n);return i===void 0?{ok:!1,message:`${t} 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(".");return Ie(r)?n.byId.has(o)?{ok:!0,nodeId:o,edge:r}:{ok:!1,message:`No node @${o}`}:{ok:!1,message:`"${r}" is not an edge of @${o}`}}function $i(e,t,n){switch(e){case"self":return t;case"root":return n.rootId;case"parent":return n.layoutParentOf.get(t);case"prev":return n.layoutPrevOf.get(t);case"next":return n.layoutNextOf.get(t)}}function bn(e){let t=[],n=xn(e),r=ki(n),o=new Set;vi(r,t),Ei(r,e,n,o,t);let i=Si(r);Mi(r,i,t);let s=Oi(r,i,e,n,o,t);return{nodes:Ni(e.root,s,r,t),problems:t}}function ki(e){let t=new Map;for(let n of e.order){let r=n;for(let o of Ue(n)){let i=r[o];i!==void 0&&t.set(W(n.id,o),{nodeId:n.id,prop:o,value:i,deps:[]})}}return t}function vi(e,t){for(let n of e.values()){if(!V(n.value))continue;let r=vt(n.value.expr);if(r.ok){n.ast=r.ast;continue}t.push({severity:"error",code:"expression-syntax",message:r.message,nodeId:n.nodeId,prop:n.prop})}}function Ei(e,t,n,r,o){for(let i of e.values()){if(!i.ast)continue;let s=new Set,u=a=>{switch(a.kind){case"number":return;case"token":{let c=j(t)[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=Et(i.prop);if(!c)return;let d=n.layoutParentOf.get(i.nodeId),f=d===void 0?void 0:W(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=St(a,i.nodeId,n);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=p=>{e.has(p)&&s.add(p)},f=mn(c.edge);if(!f){for(let p of pn(c.edge))d(W(c.nodeId,p));return}for(let p of gn(c.nodeId,i.nodeId,n).keys())d(W(p,f));yn(c.edge)!==0&&d(W(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 Si(e){let t=new Map,n=new Map;for(let[i,s]of e){t.set(i,s.deps.length);for(let u of s.deps){let a=n.get(u);a?a.push(i):n.set(u,[i])}}let r=[];for(let[i,s]of t)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 n.get(s)??[]){let a=(t.get(u)??0)-1;t.set(u,a),a===0&&r.push(u)}}return o}function Mi(e,t,n){if(t.length===e.size)return;let r=new Set(t);for(let[o,i]of e)r.has(o)||n.push({severity:"error",code:"cycle",message:`${i.nodeId}.${i.prop} is part of a dependency cycle`,nodeId:i.nodeId,prop:i.prop})}function Oi(e,t,n,r,o,i){let s=new Map,u=(a,c)=>s.get(W(a,c))??0;for(let a of t){let c=e.get(a);if(c){if(!V(c.value)){s.set(a,c.value);continue}if(!c.ast){s.set(a,0);continue}s.set(a,xr(c.ast,c,n,r,o,i,u))}}return s}function xr(e,t,n,r,o,i,s){let u=a=>xr(a,t,n,r,o,i,s);switch(e.kind){case"number":return e.value;case"token":{let a=j(n)[e.name];return typeof a=="number"?a:0}case"percent":{let a=Et(t.prop);if(!a)return e.value/100;let c=r.layoutParentOf.get(t.nodeId);return c===void 0?0:e.value/100*s(c,a)}case"nodeRef":case"relRef":{if(o.has(e))return 0;let a=St(e,t.nodeId,r);if(!a.ok)return 0;let c=mn(a.edge);if(!c)return hn(a.edge,s(a.nodeId,"x"),s(a.nodeId,"y"),s(a.nodeId,"w"),s(a.nodeId,"h"));let d=yn(a.edge)*s(a.nodeId,c==="x"?"w":"h");for(let[f,p]of gn(a.nodeId,t.nodeId,r))d+=p*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:`${t.nodeId}.${t.prop} divides by zero`,nodeId:t.nodeId,prop:t.prop}),0;let d=Ti(e.op,a,c);return Number.isFinite(d)?d:(i.push({severity:"error",code:"not-a-number",message:`${t.nodeId}.${t.prop} did not produce a finite number`,nodeId:t.nodeId,prop:t.prop}),0)}}}function Ti(e,t,n){switch(e){case"+":return t+n;case"-":return t-n;case"*":return t*n;case"/":return t/n}}function Ni(e,t,n,r){let o=new Map,i=(u,a)=>t.get(W(u,a))??0,s=(u,a,c)=>{let d=i(u.id,"x"),f=i(u.id,"y"),p=i(u.id,"w"),h=i(u.id,"h"),x={};for(let E of Ue(u)){let v=W(u.id,E);n.has(v)&&(x[E]=t.get(v)??0)}(p<0||h<0)&&r.push({severity:"warning",code:"negative-size",message:`${u.id} resolved to a negative size`,nodeId:u.id});let m=a+d,$=c+f;if(o.set(u.id,{id:u.id,type:u.type,x:d,y:f,w:p,h,left:d,top:f,right:d+p,bottom:f+h,cx:d+p/2,cy:f+h/2,absX:m,absY:$,values:x}),F(u))for(let E of u.children)s(E,m,$)};return s(e,0,0),o}function wn(e){return e.lines.filter(t=>t.spans.length>0)}function Tt(e){switch(e.kind){case"text":{let t=wn(e),n=Math.max(e.w,...t.map(o=>o.w)),r=Math.max(e.y+e.h,...t.map(o=>o.y+o.h));return{x:e.x,y:e.y,w:n,h:r-e.y}}case"vector":{let t=Ct(e.contours)??{x:e.x,y:e.y,w:e.w,h:e.h},n=e.stroke!==void 0?e.strokeWidth*2:0;return{x:t.x-n,y:t.y-n,w:t.w+n*2,h:t.h+n*2}}case"rect":case"ellipse":{let t=e.stroke!==void 0?e.strokeWidth/2:0;return{x:e.x-t,y:e.y-t,w:e.w+t*2,h:e.h+t*2}}case"frame":case"image":return{x:e.x,y:e.y,w:e.w,h:e.h}}}function Nt(e,t){let n=e.x,r=e.y,o=e.x+e.w,i=e.y+e.h;for(let s of t){let u=s.spread+s.blur;n=Math.min(n,e.x+s.x-u),r=Math.min(r,e.y+s.y-u),o=Math.max(o,e.x+e.w+s.x+u),i=Math.max(i,e.y+e.h+s.y+u)}return{x:n,y:r,w:o-n,h:i-r}}var $r="vd-paint-";var Ot="#CBD5E1",kr="#FFFFFF";function vr(e,t,n={}){let r=[...t.problems],o=[],i=[],s=n.measure??kt(),u=Ci(j(e),r),a=u.paint,c=new Map;I(e.root,(m,$)=>{if("hidden"in m&&m.hidden===!0)return!1;let E=$?c.get($.id):void 0,v=t.nodes.get(m.id);if(!v){c.set(m.id,E);return}if(m.type==="frame"){m.skip===!0&&$!==e.root&&r.push({severity:"warning",code:"skip-not-a-page",message:`${m.id}: skip only applies to a page, a frame at the top level`,nodeId:m.id,prop:"skip"});let O={x:v.absX,y:v.absY,w:Math.max(0,v.w),h:Math.max(0,v.h)};c.set(m.id,m.clip===!0?m.id:E),m.clip===!0&&i.push({id:m.id,...O,parent:E}),o.push({kind:"frame",id:m.id,...O,background:a(m.background,m.id,"background",O),clip:E,blend:m.blend??"normal",shadows:pe(m.shadow,m.id,j(e),r),rotation:0});return}if(c.set(m.id,E),m.type==="text"){o.push(Ai(m,v,e,s,r,E,a));return}if(m.type==="image"){o.push({kind:"image",id:m.id,x:v.absX,y:v.absY,w:Math.max(0,v.w),h:Math.max(0,v.h),href:Vi(m,e,n.resolveAsset,r),fit:m.fit??"fill",radius:Math.max(0,v.values.radius??0),opacity:Re(v.values.opacity??1),clip:E,blend:m.blend??"normal",shadows:pe(m.shadow,m.id,j(e),r),rotation:v.values.rotation??0});return}if(m.type==="ellipse"){let O=wr(v);o.push({kind:"ellipse",id:m.id,...O,fill:a(m.fill,m.id,"fill",O)??Ot,stroke:a(m.stroke,m.id,"stroke",O),strokeWidth:v.values.strokeWidth??0,opacity:Re(v.values.opacity??1),clip:E,blend:m.blend??"normal",shadows:pe(m.shadow,m.id,j(e),r),rotation:v.values.rotation??0});return}if(m.type==="vector"){o.push(Li(m,v,r,E,a,pe(m.shadow,m.id,j(e),r)));return}if(m.type!=="rect")return;let D=wr(v);o.push({kind:"rect",id:m.id,...D,fill:a(m.fill,m.id,"fill",D)??Ot,stroke:a(m.stroke,m.id,"stroke",D),strokeWidth:v.values.strokeWidth??0,radius:Math.max(0,v.values.radius??0),opacity:Re(v.values.opacity??1),clip:E,blend:m.blend??"normal",shadows:pe(m.shadow,m.id,j(e),r),rotation:v.values.rotation??0})});let d=t.nodes.get(e.root.id),f=e.root.w!==void 0&&e.root.h!==void 0,p=f?{x:0,y:0,width:Math.max(0,d?.w??0),height:Math.max(0,d?.h??0)}:_i(o,i),h={x:p.x,y:p.y,w:p.width,h:p.height},x=a(e.root.background,e.root.id,"background",h);return{...p,background:f?x??kr:x,items:o,clips:i,gradients:u.gradients,problems:r}}function _i(e,t){let n=new Map;for(let u of t){let a=u.parent===void 0?void 0:n.get(u.parent);n.set(u.id,a?br(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"&&wn(u).length>0?Math.max(u.h,u.height):u.h,c=u.clip===void 0?void 0:n.get(u.clip),d=rn(Nt({x:u.x,y:u.y,w:u.w,h:a},u.shadows),u.rotation,wt(u)),f=c?br(d,c):d;f.w<=0||f.h<=0||(r=Math.min(r,f.x),o=Math.min(o,f.y),i=Math.max(i,f.x+f.w),s=Math.max(s,f.y+f.h))}return Number.isFinite(r)?{x:r,y:o,width:i-r,height:s-o}:{x:0,y:0,width:0,height:0}}function br(e,t){let n=Math.max(e.x,t.x),r=Math.max(e.y,t.y);return{x:n,y:r,w:Math.min(e.x+e.w,t.x+t.w)-n,h:Math.min(e.y+e.h,t.y+t.h)-r}}function $n(e,t={}){return vr(e,bn(e),t)}function Ai(e,t,n,r,o,i,s){let u=Math.max(0,t.w),a=Math.max(0,t.h),c={x:t.absX,y:t.absY,w:u,h:a},d=un(e,t.values,u,n.fonts,h=>s(h,e.id,"fill",c)??$t,r);!d.lines.every(h=>h.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"}),Ii(e,n,o);let p=t.absY+an(e,a,d.height);return{kind:"text",id:e.id,x:t.absX,y:t.absY,w:u,h:a,clip:i,blend:e.blend??"normal",shadows:pe(e.shadow,e.id,j(n),o),rotation:t.values.rotation??0,opacity:Re(t.values.opacity??1),height:d.height,lines:d.lines.map(h=>({y:p+h.y,h:h.h,baseline:p+h.baseline,w:h.w,spans:h.spans.map(x=>({text:x.text,x:t.absX+x.x,y:p+h.baseline,w:x.w,style:x.style})),...h.style?{style:h.style}:{}}))}}function Ii(e,t,n){if(typeof e.content!="string")for(let r of e.content){if(typeof r=="string"||r.link===void 0)continue;let o=Y(r.link);if(!o){n.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"&&!Pi(t,o.id)&&n.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 Pi(e,t){let n=!1;return I(e.root,r=>{if(n)return!1;r.id===t&&r.type==="frame"&&(n=!0)}),n}var Pe=new Map,Ri=512;function Di(e){let t=Pe.get(e);if(t)return t;let n=Pt(e);return Pe.size>=Ri&&Pe.delete(Pe.keys().next().value),Pe.set(e,n),n}function Li(e,t,n,r,o,i){let s=Math.max(0,t.w),u=Math.max(0,t.h),a={x:t.absX,y:t.absY,w:s,h:u},{contours:c,error:d}=Di(e.d);d!==void 0&&n.push({severity:"error",code:"bad-path",message:`${e.id}: ${d}`,nodeId:e.id,prop:"d"}),e.view!==void 0&&at(e.view)===void 0&&n.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=Lt(c,jt(Ft(e.view,s,u),a));return{kind:"vector",id:e.id,...a,d:Rt(f),contours:f,fill:o(e.fill,e.id,"fill",a)??Ot,stroke:o(e.stroke,e.id,"stroke",a),strokeWidth:t.values.strokeWidth??0,opacity:Re(t.values.opacity??1),rule:e.rule??"nonzero",cap:e.cap??"butt",join:e.join??"miter",clip:r,blend:e.blend??"normal",shadows:i,rotation:t.values.rotation??0}}function Er(e,t,n,r,o){if(e===void 0)return;if(V(e)){o.push({severity:"warning",code:"expression-not-supported",message:`Expressions are not supported for ${r} yet; grammar v0 is numeric only`,nodeId:n,prop:r});return}let i=t[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:n,prop:r})}function wr(e){return{x:e.absX,y:e.absY,w:Math.max(0,e.w),h:Math.max(0,e.h)}}function Ci(e,t){let n=[],r=new Map;return{paint:(i,s,u,a)=>{let c=Er(i,e,s,u,t);if(c===void 0)return;if(/url\(/i.test(c)){t.push({severity:"error",code:"invalid-paint",message:`${s}: a paint is a colour or a gradient, not ${JSON.stringify(c)}`,nodeId:s,prop:u});return}let d=en(c);if("error"in d){t.push({severity:"error",code:"invalid-paint",message:`${s}: ${d.error}`,nodeId:s,prop:u});return}if(d.kind==="solid")return c;let f=`${s}\0${u}\0${c}`,p=r.get(f);if(p!==void 0)return`url(#${p})`;let h=[...r.keys()].filter($=>$.startsWith(`${s}\0${u}\0`)).length,x=`${$r}${s}-${u}${h===0?"":`-${h+1}`}`;r.set(f,x);let m=tn(d.stops).map($=>({offset:$.at,colour:Sr($.colour,e,s,u,t)}));return n.push(ji(d,x,a,Fi(m))),`url(#${x})`},gradients:n}}function pe(e,t,n,r){let o=Er(e,n,t,"shadow",r);if(o===void 0)return[];let i=nn(o);return"error"in i?(r.push({severity:"error",code:"invalid-shadow",message:`${t}: ${i.error}`,nodeId:t,prop:"shadow"}),[]):i.shadows.map(s=>({...s,colour:Sr(s.colour,n,t,"shadow",r)}))}function Fi(e){return e.map((t,n)=>{if(t.colour.trim().toLowerCase()!=="transparent")return t;let r=[e[n-1],e[n+1]].find(o=>o!==void 0&&o.colour.trim().toLowerCase()!=="transparent");return r===void 0?t:{offset:t.offset,colour:r.colour,opacity:0}})}function Sr(e,t,n,r,o){let i=t[e];return i===void 0?e:typeof i=="string"&&!bt(i)?i:(o.push({severity:"error",code:"invalid-paint",message:`${n}: a gradient stop names $${e}, which is not a colour`,nodeId:n,prop:r}),"transparent")}function ji(e,t,n,r){if(e.kind==="linear"){let c=e.angle*Math.PI/180,d=Math.sin(c),f=-Math.cos(c),p=(Math.abs(n.w*d)+Math.abs(n.h*f))/2,h=n.x+n.w/2,x=n.y+n.h/2;return{id:t,kind:"linear",x1:Mt(h-d*p),y1:Mt(x-f*p),x2:Mt(h+d*p),y2:Mt(x+f*p),stops:r}}let o=n.x+n.w*e.cx,i=n.y+n.h*e.cy,s={x:Math.max(o-n.x,n.x+n.w-o),y:Math.max(i-n.y,n.y+n.h-i)};if(e.shape==="circle"||s.x===0||s.y===0){let c=Math.hypot(s.x,s.y);return{id:t,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:t,kind:"radial",cx:o,cy:i,rx:a*u,ry:a,stops:r}}function Mt(e){return Math.round(e*1e6)/1e6}function Re(e){return Math.min(Math.max(e,0),1)}function Vi(e,t,n,r){let o=V(e.src)?void 0:e.src,i=o===void 0?void 0:t.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=n?.(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 De="vd-clip-";function vn(e,t={}){let n=t.indent??" ",r={ids:t.ids??!0,prefix:t.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=e.items.filter(c=>c.shadows.length>0);if(e.clips.length>0||e.gradients.length>0||a.length>0){u.push(`${n}<defs>`);for(let c of e.clips)u.push(n+n+Mr(c,r.prefix));for(let c of e.gradients)u.push(n+n+Or(c,r.prefix));for(let c of a)u.push(n+n+Tr(c,t.shadowsOnly,r.prefix));u.push(`${n}</defs>`)}e.background!==void 0&&u.push(`${n}<rect x="${y(e.x)}" y="${y(e.y)}" width="${o}" height="${i}" fill="${T(te(e.background,r))}"/>`);for(let c of e.items){let d=Gi(c,r);d!==""&&u.push(n+d)}return u.push("</svg>"),`${u.join(`
|
|
9
|
-
`)}
|
|
10
|
-
`}function Bi(e){return Mr(e,"")}function Mr(e,t){let n=e.parent===void 0?"":` clip-path="url(#${T(t+De+e.parent)})"`;return`<clipPath id="${T(t+De+e.id)}"${n}><rect x="${y(e.x)}" y="${y(e.y)}" width="${y(e.w)}" height="${y(e.h)}"/></clipPath>`}function Ui(e){return Or(e,"")}function Or(e,t){let n=e.stops.map(o=>`<stop offset="${y(o.offset)}" stop-color="${T(o.colour)}"${o.opacity===void 0?"":` stop-opacity="${y(o.opacity)}"`}/>`).join(""),r=T(t+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)}">${n}</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)})">${n}</radialGradient>`}var Wi={cover:"xMidYMid slice",contain:"xMidYMid meet",fill:"none"},zi="#94A3B8";function ee(e,t){let n=e.clip===void 0?[]:[`clip-path="url(#${T(t+De+e.clip)})"`];return e.rotation!==0&&n.push(`transform="${Nr(e)}"`),e.shadows.length>0&&n.push(`filter="url(#${T(t+En+e.id)})"`),e.blend!=="normal"&&n.push(`style="mix-blend-mode:${e.blend}"`),n}var En="vd-shadow-";function Xi(e,t=!1){return Tr(e,t,"")}function Tr(e,t,n){let r=Nt(Tt(e),e.shadows),o=2,i=[];e.shadows.forEach((u,a)=>{let c=`s${a}`,d="SourceAlpha";u.spread!==0&&(i.push(`<feMorphology in="${d}" operator="${u.spread>0?"dilate":"erode"}" radius="${y(Math.abs(u.spread))}" result="${c}m"/>`),d=`${c}m`),u.blur>0&&(i.push(`<feGaussianBlur in="${d}" stdDeviation="${y(u.blur/2)}" result="${c}b"/>`),d=`${c}b`),i.push(`<feOffset in="${d}" dx="${y(u.x)}" dy="${y(u.y)}" result="${c}o"/>`,`<feFlood flood-color="${T(u.colour)}" result="${c}c"/>`,`<feComposite in="${c}c" in2="${c}o" operator="in" result="${c}"/>`)});let s=e.shadows.map((u,a)=>`<feMergeNode in="s${e.shadows.length-1-a}"/>`).join("");return`<filter id="${T(n+En+e.id)}" filterUnits="userSpaceOnUse" x="${y(r.x-o)}" y="${y(r.y-o)}" width="${y(r.w+o*2)}" height="${y(r.h+o*2)}" color-interpolation-filters="sRGB">`+i.join("")+`<feMerge>${s}${t?"":'<feMergeNode in="SourceGraphic"/>'}</feMerge></filter>`}function Nr(e){return`rotate(${y(e.rotation)} ${y(e.x+e.w/2)} ${y(e.y+e.h/2)})`}function _r(e){return e.rotation!==0&&e.clip!==void 0}function Gi(e,t){if(e.pose!==void 0)return Hi(e,e.pose,t);if(_r(e)){let n=[`clip-path="url(#${T(t.prefix+De+e.clip)})"`];e.blend!=="normal"&&n.push(`style="mix-blend-mode:${e.blend}"`);let r=kn({...e,clip:void 0,blend:"normal"},t);return r===""?"":`<g ${n.join(" ")}>${r}</g>`}return kn(e,t)}function Hi(e,t,n){let r=kn({...e,clip:void 0,blend:"normal",shadows:e.shadows},n);if(r==="")return"";let o=[];e.clip!==void 0&&o.push(`clip-path="url(#${T(n.prefix+De+e.clip)})"`),t.opacity<1&&o.push(`opacity="${y(t.opacity)}"`),e.blend!=="normal"&&o.push(`style="mix-blend-mode:${e.blend}"`);let i=t.sx===1&&t.sy===1&&t.tx===0&&t.ty===0?r:`<g transform="${Ar(t)}">${r}</g>`;return o.length===0?i:`<g ${o.join(" ")}>${i}</g>`}function Ar(e){return`matrix(${y(e.sx)} 0 0 ${y(e.sy)} ${y(e.tx)} ${y(e.ty)})`}function kn(e,t){switch(e.kind){case"ellipse":return qi(e,t);case"frame":return Ji(e,t);case"image":return Yi(e,t);case"rect":return Ki(e,t);case"text":return Qi(e,t);case"vector":return Zi(e,t)}}function te(e,t){return/url\(/i.test(e)&&!e.startsWith("url(#")?"none":t.prefix!==""&&e.startsWith("url(#")?`url(#${t.prefix}${e.slice(5)}`:e}function Ji(e,t){let n=[];return t.ids&&n.push(`id="${T(e.id)}"`),n.push(`x="${y(e.x)}"`,`y="${y(e.y)}"`,`width="${y(e.w)}"`,`height="${y(e.h)}"`,`fill="${e.background===void 0?"none":T(te(e.background,t))}"`,...ee(e,t.prefix)),`<rect ${n.join(" ")}/>`}function Yi(e,t){let n=[];return t.ids&&n.push(`id="${T(e.id)}"`),n.push(`x="${y(e.x)}"`,`y="${y(e.y)}"`,`width="${y(e.w)}"`,`height="${y(e.h)}"`),e.href===void 0?(e.radius>0&&n.push(`rx="${y(e.radius)}"`),n.push('fill="none"',`stroke="${T(zi)}"`,'stroke-width="1"','stroke-dasharray="4 4"',...ee(e,t.prefix)),`<rect ${n.join(" ")}/>`):(n.push(`href="${T(e.href)}"`,`preserveAspectRatio="${Wi[e.fit]}"`),e.opacity<1&&n.push(`opacity="${y(e.opacity)}"`),n.push(...ee(e,t.prefix)),`<image ${n.join(" ")}/>`)}function Ki(e,t){let n=[];return t.ids&&n.push(`id="${T(e.id)}"`),n.push(`x="${y(e.x)}"`,`y="${y(e.y)}"`,`width="${y(e.w)}"`,`height="${y(e.h)}"`),e.radius>0&&n.push(`rx="${y(e.radius)}"`),n.push(`fill="${T(te(e.fill,t))}"`),e.stroke!==void 0&&e.strokeWidth>0&&n.push(`stroke="${T(te(e.stroke,t))}"`,`stroke-width="${y(e.strokeWidth)}"`),e.opacity<1&&n.push(`opacity="${y(e.opacity)}"`),n.push(...ee(e,t.prefix)),`<rect ${n.join(" ")}/>`}function Ir(e,t){let n=[`fill="${T(te(e.fill,t))}"`];return e.stroke!==void 0&&e.strokeWidth>0&&n.push(`stroke="${T(te(e.stroke,t))}"`,`stroke-width="${y(e.strokeWidth)}"`),e.opacity<1&&n.push(`opacity="${y(e.opacity)}"`),n}function qi(e,t){let n=[];return t.ids&&n.push(`id="${T(e.id)}"`),n.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)}"`,...Ir(e,t),...ee(e,t.prefix)),`<ellipse ${n.join(" ")}/>`}function Zi(e,t){if(e.d==="")return"";let n=[];t.ids&&n.push(`id="${T(e.id)}"`),n.push(`d="${T(e.d)}"`,...Ir(e,t));let r=e.pose?.trace;if(r!==void 0&&e.stroke!==void 0){let i=y(ct(e.contours)+1);n.push(`stroke-dasharray="${i} ${i}"`,`stroke-dashoffset="${y((ct(e.contours)+1)*(1-r))}"`)}let o=e.pose?.fillOpacity;return o!==void 0&&o<1&&n.push(`fill-opacity="${y(o)}"`),e.rule!=="nonzero"&&n.push(`fill-rule="${e.rule}"`),e.cap!=="butt"&&n.push(`stroke-linecap="${e.cap}"`),e.join!=="miter"&&n.push(`stroke-linejoin="${e.join}"`),n.push(...ee(e,t.prefix)),`<path ${n.join(" ")}/>`}function Qi(e,t){if(e.lines.every(o=>o.spans.length===0))return"";let n=[];t.ids&&n.push(`id="${T(e.id)}"`),n.push('xml:space="preserve"'),e.opacity<1&&n.push(`opacity="${y(e.opacity)}"`),n.push(...ee(e,t.prefix));let r=[];for(let o of e.lines)for(let i of o.spans)i.text!==""&&r.push(es(i,t));return`<text ${n.join(" ")}>${r.join("")}</text>`}function es(e,t){let r=`<tspan ${[`x="${y(e.x)}"`,`y="${y(e.y)}"`,...ts(e.style,t)].join(" ")}>${ns(e.text)}</tspan>`;return e.style.link===void 0?r:`<a href="${T(e.style.link)}">${r}</a>`}function ts(e,t){let n=[`font-family="${T(e.family)}"`,`font-size="${y(e.size)}"`,`fill="${T(te(e.fill,t))}"`];e.weight!==400&&n.push(`font-weight="${y(e.weight)}"`),e.italic&&n.push('font-style="italic"'),e.letterSpacing!==0&&n.push(`letter-spacing="${y(e.letterSpacing)}"`);let r=[e.underline?"underline":"",e.strike?"line-through":""].filter(Boolean).join(" ");return r&&n.push(`text-decoration="${r}"`),n}function ns(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function T(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Jd(e,t={}){let{resolveAsset:n,measure:r,...o}=t;return vn($n(e,{...n?{resolveAsset:n}:{},...r?{measure:r}:{}}),o)}export{I as a,G as b,Y as c,q as d,Ee as e,Dn as f,le as g,Ln as h,rt as i,ot as j,ct as k,Qr as l,Rr as m,Dr as n,Lr as o,Cr as p,To as q,Wo as r,zo as s,nr as t,rr as u,Zo as v,Qo as w,ei as x,sr as y,bn as z,kt as A,vr as B,$n as C,vn as D,Bi as E,Ui as F,En as G,Xi as H,Nr as I,_r as J,Ar as K,Jd as L};
|