@getv.design/embed 0.1.2 → 0.1.4
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/chunks/chunk-5NSMF3ZC.js +8 -0
- package/dist/chunks/{chunk-GI6ZV6OJ.js → chunk-E3UBMQLG.js} +1 -1
- package/dist/chunks/chunk-QFKGWML4.js +2 -0
- package/dist/chunks/{chunk-VBG4ORCT.js → chunk-WT7EGVYI.js} +2 -2
- package/dist/chunks/fonts.js +2 -2
- package/dist/edit.js +142 -37
- package/dist/index.js +2 -2
- package/dist/static.js +2 -2
- package/dist/view.js +8 -7
- package/edit.css +110 -6
- package/package.json +1 -1
- package/view.css +5 -4
- package/dist/chunks/chunk-JWKZL5KP.js +0 -8
- package/dist/chunks/chunk-PCMXJXR4.js +0 -2
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! @getv.design/embed v0.1.
|
|
2
|
-
import{a as y}from"./chunks/chunk-
|
|
1
|
+
/*! @getv.design/embed v0.1.4. Free to use under the vDesign Embed Licence. © 2026 Sagar Saini. https://getv.design/docs/licence/ */
|
|
2
|
+
import{a as y}from"./chunks/chunk-QFKGWML4.js";import"./chunks/chunk-E3UBMQLG.js";var d=["view","edit","play"];async function l(a,i,e){let o=e?.mode;if(!d.includes(o))throw new TypeError(`mount: mode must be one of ${d.join(", ")}; got ${String(o)}.`);if(o==="edit"){let{edit:t}=await import("./edit.js");return t(a,i,e)}let{view:s}=await import("./view.js"),n=await s(a,i,e);if(o==="view")return n;let r;try{r=await n.play(e.page===void 0?{}:{page:e.page})}catch(t){throw n.destroy(),t}return{goTo:t=>r.goTo(t),destroy(){r.destroy(),n.destroy()}}}export{l as mount,y as version};
|
package/dist/static.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! @getv.design/embed v0.1.
|
|
2
|
-
import{a as g,c as h,e as b,f as v,g as f}from"./chunks/chunk-
|
|
1
|
+
/*! @getv.design/embed v0.1.4. Free to use under the vDesign Embed Licence. © 2026 Sagar Saini. https://getv.design/docs/licence/ */
|
|
2
|
+
import{a as g,c as h,e as b,f as v,g as f}from"./chunks/chunk-WT7EGVYI.js";import{a as P,b as l}from"./chunks/chunk-QFKGWML4.js";import{j as d,y as m}from"./chunks/chunk-5NSMF3ZC.js";import"./chunks/chunk-E3UBMQLG.js";function A(e){return g(e)}async function F(e,t={}){let o=t.fonts??"approximate";if(!S.includes(o))throw new TypeError(`renderSvg: fonts must be one of ${S.join(", ")}; got ${String(o)}.`);let n=o==="exact"?v(t.fontBase,w()):void 0,{document:c,blocks:x,problems:y}=await h(e),u=t.page===void 0?c:O(c,t.page),p=s=>{let r=x.get(s.hash);return r===void 0?void 0:d(s.type,r)},i=[...y],a;if(o==="exact")if(n===void 0)i.push(f([],"no fontBase was given and this build has no default"));else{let{exactSvg:s}=await import("./chunks/fonts.js"),r=await s(u,{base:n,resolveAsset:p});"svg"in r?a=r.svg:i.push(f(r.failures))}return a??=m(u,{ids:!1,resolveAsset:p}),t.onProblems?.(i),a}var S=["approximate","exact"];function w(){let e=import.meta.url,o=typeof globalThis.process?.getBuiltinModule=="function";return e.startsWith("file:")&&o?new URL("../fonts/",e).href:l}function O(e,t){let o=b(e,t);return{...e,root:{...e.root,children:e.root.children.map(n=>n===o?n:{...n,hidden:!0})}}}export{A as parse,F as renderSvg,P as version};
|
package/dist/view.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! @getv.design/embed v0.1.
|
|
2
|
-
import{b as
|
|
1
|
+
/*! @getv.design/embed v0.1.4. Free to use under the vDesign Embed Licence. © 2026 Sagar Saini. https://getv.design/docs/licence/ */
|
|
2
|
+
import{b as ut,c as ze,d as ce,e as Ee,f as pt,g as Le}from"./chunks/chunk-WT7EGVYI.js";import{a as qt,b as qe}from"./chunks/chunk-QFKGWML4.js";import{a as Xe,b as Je,c as Te,d as Fe,e as Qe,f as et,g as tt,h as nt,j as rt,k as it,m as Ie,n as _e,o as ot,p as Ne,s as st,t as at,u as ct,v as dt,w as ft,x as lt}from"./chunks/chunk-5NSMF3ZC.js";import"./chunks/chunk-E3UBMQLG.js";var Xt=.8,Jt=.2;function Ve(e,t){let i=e.createElement("canvas").getContext("2d"),n=ot(),u=new Map,s=new Map,m=new Set;function f(l){return`${l.italic?"italic ":""}${l.weight} ${l.size}px ${l.family}`}function g(){u.clear(),s.clear()}return{advance(l,p){if(!i)return n.advance(l,p);let M=f(p),S=`${M}\0${p.letterSpacing}\0${l}`,O=u.get(S);if(O!==void 0)return O;i.font=M;let w=i.measureText(l).width+p.letterSpacing*[...l].length;return u.set(S,w),w},metrics(l){if(!i)return n.metrics(l);let p=f(l),M=s.get(p);if(M)return M;i.font=p;let S=i.measureText("Hxg"),O=S.fontBoundingBoxAscent??l.size*Xt,w=S.fontBoundingBoxDescent??l.size*Jt,N={ascent:O,descent:w,lineGap:0};return s.set(p,N),N},load(l,p){let M=e.fonts;if(!M||typeof FontFace!="function")return!1;let S=!1;for(let O of Object.values(l.fonts))for(let w of Qt(O)){let N=`${O.family}\0${w.src}\0${w.weight??400}\0${w.style??"normal"}`;if(m.has(N))continue;m.add(N);let _=w.src.startsWith("data:")?void 0:p?.(w.src),x={weight:String(w.weight??400),style:w.style??"normal"},R=X=>{let z=new FontFace(O.family,typeof X=="string"?`url(${X})`:en(X),x);M.add(z),z.load().then(()=>{g(),t?.()},()=>{M.delete(z)})};_===void 0?R(w.src):(S=!0,_.then(R,()=>{}))}return S},invalidate:g,destroy(){g(),m.clear()}}}function Qt(e){return e.faces??[]}function en(e){return e instanceof Uint8Array?e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength):e}var Pe={x:0,y:0,zoom:1},ht=.02,mt=64;function Se(e){return Number.isFinite(e)?Math.min(Math.max(e,ht),mt):1}function Ce(e,t){return{x:(t.x-e.x)/e.zoom,y:(t.y-e.y)/e.zoom}}function Re(e,t){return{x:t.x*e.zoom+e.x,y:t.y*e.zoom+e.y}}function De(e,t,r){let i=Se(e.zoom*r),n=Ce(e,t);return{zoom:i,x:t.x-n.x*i,y:t.y-n.y*i}}function ke(e,t,r){return{...e,x:e.x+t,y:e.y+r}}function $e(e){return`translate(${e.x} ${e.y}) scale(${e.zoom})`}function de(e,t,r){let i={width:Math.max(1,t.width-r*2),height:Math.max(1,t.height-r*2)};if(e.width<=0||e.height<=0)return Pe;let n=Se(Math.min(i.width/e.width,i.height/e.height));return{zoom:n,x:(t.width-e.width*n)/2-(e.x??0)*n,y:(t.height-e.height*n)/2-(e.y??0)*n}}var J="http://www.w3.org/2000/svg",gt="vd-viewer-styles",yt=`
|
|
3
3
|
.vd-viewer {
|
|
4
4
|
position: relative;
|
|
5
5
|
overflow: hidden;
|
|
@@ -21,10 +21,11 @@ import{b as Qe,c as Ae,d as ee,e as ue,f as et,g as ye}from"./chunks/chunk-VBG4O
|
|
|
21
21
|
.vd-viewer__surface text {
|
|
22
22
|
white-space: pre;
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
/* No \`will-change\` on the camera group. It made the document its own
|
|
25
|
+
composited layer, and every camera step then rebuilt the compositor's layer
|
|
26
|
+
list from one entry per clipped or filtered item: 40 ms a step at 60 pages,
|
|
27
|
+
most of a pan. Without it a step repaints what is on screen instead, which is
|
|
28
|
+
cheap except under a large blur. */
|
|
28
29
|
.vd-viewer__page {
|
|
29
30
|
/* An embedder with a no-shadow brand sets --vd-page-shadow: none. */
|
|
30
31
|
filter: var(--vd-page-shadow, drop-shadow(0 6px 24px rgb(0 0 0 / 0.35)));
|
|
@@ -97,4 +98,4 @@ import{b as Qe,c as Ae,d as ee,e as ue,f as et,g as ye}from"./chunks/chunk-VBG4O
|
|
|
97
98
|
.vd-viewer--interacting .vd-viewer__page {
|
|
98
99
|
filter: none;
|
|
99
100
|
}
|
|
100
|
-
`;function ot(e){if(e.getElementById(rt))return;let t=e.createElement("style");t.id=rt,t.textContent=it,e.head.appendChild(t)}function at(e,t,r,i){return t?$t(e,t,r,i):Vt(e,r,i)}function Vt(e,t,r){let i=Oe(e,r);return{measurer:i,update:n=>{i.load(n,t)},afterPaint:()=>{},destroy:()=>i.destroy()}}var st=new WeakMap;function $t(e,t,r,i){let n,l,c,m=()=>{if(!n)throw new Error("canvasFonts: update() before measuring");return n};return{measurer:{advance:(y,f)=>m().measurer.advance(y,f),metrics:y=>m().measurer.metrics(y),itemize:y=>m().measurer.itemize(y)},update(y){n&&y.fonts===l||(c?.(),n?.dispose(),n=t.forDocument(y,r?{loader:r}:{}),l=y.fonts,c=n.onChange(i))},afterPaint(){let y=e.fonts;if(!n||!y||typeof FontFace!="function")return;let f=st.get(e);f||st.set(e,f=new Set);for(let p of n.usedFaces()){if(f.has(p.id))continue;f.add(p.id);let A=new FontFace(p.id,Ht(p.bytes),{weight:String(p.weight),style:p.style});y.add(A),A.load().catch(()=>y.delete(A))}},destroy(){c?.(),n?.dispose(),n=void 0}}}function Ht(e){return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}var Bt=.01,jt=.004,ct=40,Ut=16;function le(e,t){ot(e.ownerDocument);let r=t.document,i=a=>at(e.ownerDocument,a,t.loadFont,()=>{$(r)}),n=i(t.fonts),l={advance:(a,v)=>n.measurer.advance(a,v),metrics:a=>n.measurer.metrics(a),itemize:a=>n.measurer.itemize?.(a)??[a]};n.update(r);let c=me(r),m=()=>t.resolveAsset?{measure:l,resolveAsset:t.resolveAsset}:{measure:l},u=ke(r,c,m()),y=t.camera??we,f=t.interactive??!0,p=t.wheel??"always";e.classList.add("vd-viewer"),t.surface&&(e.style.background=t.surface);let A=e.ownerDocument.createElementNS(j,"svg");A.setAttribute("class","vd-viewer__surface"),A.setAttribute("width","100%"),A.setAttribute("height","100%");let S=e.ownerDocument.createElementNS(j,"g");S.setAttribute("class","vd-viewer__camera"),S.style.isolation="isolate",A.appendChild(S);let E=e.ownerDocument.createElementNS(j,"defs");S.appendChild(E);let x=e.ownerDocument.createElementNS(j,"rect");x.setAttribute("class","vd-viewer__page"),S.appendChild(x),e.appendChild(A);let C=new Map;function O(){S.setAttribute("transform",_e(y))}function _(){N();let a=u.background!==void 0;x.setAttribute("x",String(u.x)),x.setAttribute("y",String(u.y)),x.setAttribute("width",String(a?u.width:0)),x.setAttribute("height",String(a?u.height:0)),D(x,"fill",u.background??null);let v=new Set,M=x;for(let w of u.items){v.add(w.id);let L=C.get(w.id);(!L||L.tagName!==dt(w))&&(L?.remove(),L=e.ownerDocument.createElementNS(j,dt(w)),L.setAttribute("data-vd-id",w.id),C.set(w.id,L)),Kt(L,w),M.nextSibling!==L&&S.insertBefore(L,M.nextSibling),M=L}for(let[w,L]of C)v.has(w)||(L.remove(),C.delete(w));n.afterPaint(),t.onSceneChange?.(u,r)}function N(){E.replaceChildren();let a=u.items.filter(v=>v.shadows.length>0);if(u.gradients.length>0||a.length>0){let v=`<svg xmlns="${j}">${u.gradients.map(Ye).join("")}${a.map(w=>qe(w)).join("")}</svg>`,M=new DOMParser().parseFromString(v,"image/svg+xml");for(let w of[...M.documentElement.children])E.appendChild(e.ownerDocument.importNode(w,!0))}for(let v of u.clips){let M=e.ownerDocument.createElementNS(j,"clipPath");M.setAttribute("id",ft(v.id)),v.parent!==void 0&&M.setAttribute("clip-path",Pe(v.parent));let w=e.ownerDocument.createElementNS(j,"rect");w.setAttribute("x",String(v.x)),w.setAttribute("y",String(v.y)),w.setAttribute("width",String(v.w)),w.setAttribute("height",String(v.h)),M.appendChild(w),E.appendChild(M)}}function $(a){r=a,n.update(r),c=me(r),u=ke(r,c,m()),_()}function P(a){let v=e.getBoundingClientRect();return{x:a.clientX-v.left,y:a.clientY-v.top}}let F=0,I=0;function U(){e.classList.add("vd-viewer--interacting"),I&&clearTimeout(I),I=setTimeout(()=>{I=0,e.classList.remove("vd-viewer--interacting")},180)}function K(){F&&(cancelAnimationFrame(F),F=0),O(),t.onCameraChange?.(y)}function z(a){y=a,K()}function q(a){y=a,U(),!F&&(F=requestAnimationFrame(()=>{F=0,O(),t.onCameraChange?.(y)}))}let X=null,W=null,B=!1,te=a=>{if(p==="modifier"&&!a.ctrlKey&&!a.metaKey)return;a.preventDefault();let v=P(a),M=a.deltaMode===1?Ut:a.deltaMode===2?e.clientHeight||800:1,w=a.deltaX*M,L=a.deltaY*M;if(a.ctrlKey||a.metaKey){let s=a.ctrlKey?Bt:jt,d=Math.max(-ct,Math.min(ct,L));q(xe(y,v,Math.exp(-d*s)));return}if(a.shiftKey&&w===0){q(fe(y,-L,0));return}q(fe(y,-w,-L))},Z=a=>{(a.button===1||a.button===0&&B)&&(a.preventDefault(),X=a.pointerId,W=P(a),e.setPointerCapture(a.pointerId))},J=a=>{if(X!==a.pointerId||!W)return;let v=P(a);q(fe(y,v.x-W.x,v.y-W.y)),W=v},H=a=>{X===a.pointerId&&(X=null,W=null,e.hasPointerCapture(a.pointerId)&&e.releasePointerCapture(a.pointerId))},Q=a=>{a.code==="Space"&&(B=!0)},G=a=>{a.code==="Space"&&(B=!1)};f&&(e.addEventListener("wheel",te,{passive:!1}),e.addEventListener("pointerdown",Z),e.addEventListener("pointermove",J),e.addEventListener("pointerup",H),e.addEventListener("pointercancel",H),e.ownerDocument.addEventListener("keydown",Q),e.ownerDocument.addEventListener("keyup",G)),O(),_();let ne={element:e,surface:A,update:$,getDocument:()=>r,getScene:()=>u,getResolution:()=>c,getMeasurer:()=>l,setFonts(a){n.destroy(),n=i(a),$(r)},getCamera:()=>y,setCamera:z,zoomBy(a,v){let M=e.getBoundingClientRect(),w=v??{x:M.width/2,y:M.height/2};z(xe(y,w,a))},fitToContent(a=32){let v=e.getBoundingClientRect();z(oe({x:u.x,y:u.y,width:u.width,height:u.height},{width:v.width||u.width,height:v.height||u.height},a))},screenToDocument:a=>ve(y,a),documentToScreen:a=>Te(y,a),pointerPoint:P,hitTest(a,v){for(let M=u.items.length-1;M>=0;M--){let w=u.items[M];if(w&&tn(w,a,en/y.zoom)&&(!v||v(w.id)))return w.id}return null},linkAt(a,v){for(let M=u.items.length-1;M>=0;M--){let w=u.items[M];if(w?.kind!=="text"||v&&!v(w.id))continue;let L=w.rotation===0?a:Ee(a,{x:w.x+w.w/2,y:w.y+w.h/2},-w.rotation);for(let s of w.lines){if(L.y<s.y||L.y>s.y+s.h)continue;let d=s.spans.find(o=>L.x>=o.x&&L.x<=o.x+o.w);if(d)return d.style.link}}},itemOf:a=>u.items.find(v=>v.id===a),elementOf:a=>C.get(a),destroy(){f&&(e.removeEventListener("wheel",te),e.removeEventListener("pointerdown",Z),e.removeEventListener("pointermove",J),e.removeEventListener("pointerup",H),e.removeEventListener("pointercancel",H),e.ownerDocument.removeEventListener("keydown",Q),e.ownerDocument.removeEventListener("keyup",G)),F&&cancelAnimationFrame(F),I&&clearTimeout(I),F=0,I=0,n.destroy(),e.classList.remove("vd-viewer--interacting"),A.remove(),C.clear(),e.classList.remove("vd-viewer")}};return t.autoFit&&ne.fitToContent(),ne}var Wt="vd-clip-";function ft(e){return Wt+e}function Pe(e){return`url(#${ft(e)})`}function dt(e){return Je(e)?"g":Le(e)}function Le(e){switch(e.kind){case"ellipse":return"ellipse";case"frame":return"rect";case"image":return e.href===void 0?"rect":"image";case"rect":return"rect";case"text":return"text";case"vector":return"path"}}function Kt(e,t){if(e.tagName!=="g"){ut(e,t);return}D(e,"clip-path",t.clip===void 0?null:Pe(t.clip)),e.style.mixBlendMode=t.blend==="normal"?"":t.blend;let r=e.firstElementChild;(!r||r.tagName!==Le(t))&&(r?.remove(),r=e.ownerDocument.createElementNS(j,Le(t)),e.appendChild(r)),ut(r,{...t,clip:void 0,blend:"normal"})}function ut(e,t){switch(D(e,"clip-path",t.clip===void 0?null:Pe(t.clip)),D(e,"transform",t.rotation===0?null:Xe(t)),e.style.mixBlendMode=t.blend==="normal"?"":t.blend,e.style.filter=t.shadows.length>0?`url(#${Ze}${t.id})`:"",t.kind){case"ellipse":Jt(e,t);return;case"frame":Gt(e,t);return;case"image":Yt(e,t);return;case"rect":Xt(e,t);return;case"text":qt(e,t);return;case"vector":Qt(e,t);return}}function Gt(e,t){e.setAttribute("class","vd-viewer__page"),e.setAttribute("x",String(t.x)),e.setAttribute("y",String(t.y)),e.setAttribute("width",String(t.w)),e.setAttribute("height",String(t.h)),D(e,"fill",t.background??null)}function Yt(e,t){if(e.setAttribute("x",String(t.x)),e.setAttribute("y",String(t.y)),e.setAttribute("width",String(t.w)),e.setAttribute("height",String(t.h)),D(e,"opacity",t.opacity<1?String(t.opacity):null),t.href===void 0){e.setAttribute("class","vd-viewer__missing"),D(e,"rx",t.radius>0?String(t.radius):null);return}e.setAttribute("href",t.href),e.setAttribute("preserveAspectRatio",Zt[t.fit])}var Zt={cover:"xMidYMid slice",contain:"xMidYMid meet",fill:"none"};function qt(e,t){D(e,"opacity",t.opacity<1?String(t.opacity):null),e.setAttribute("xml:space","preserve");let r=t.lines.flatMap(n=>n.spans).filter(n=>n.text!==""),i=e.ownerDocument;for(;e.childNodes.length>r.length;)e.lastChild?.remove();for(;e.childNodes.length<r.length;)e.appendChild(i.createElementNS(j,"tspan"));r.forEach((n,l)=>{let c=e.childNodes[l];c.textContent=n.text,c.setAttribute("x",String(n.x)),c.setAttribute("y",String(n.y)),c.setAttribute("font-family",n.style.family),c.setAttribute("font-size",String(n.style.size)),c.setAttribute("fill",n.style.fill),D(c,"font-weight",n.style.weight===400?null:String(n.style.weight)),D(c,"font-style",n.style.italic?"italic":null),D(c,"letter-spacing",n.style.letterSpacing===0?null:String(n.style.letterSpacing)),D(c,"data-vd-link",n.style.link??null);let m=[n.style.underline?"underline":"",n.style.strike?"line-through":""].filter(Boolean).join(" ");D(c,"text-decoration",m===""?null:m)})}function Xt(e,t){e.removeAttribute("class"),e.setAttribute("x",String(t.x)),e.setAttribute("y",String(t.y)),e.setAttribute("width",String(t.w)),e.setAttribute("height",String(t.h)),e.setAttribute("fill",t.fill),D(e,"rx",t.radius>0?String(t.radius):null),D(e,"stroke",t.stroke??null),D(e,"stroke-width",t.stroke&&t.strokeWidth>0?String(t.strokeWidth):null),D(e,"opacity",t.opacity<1?String(t.opacity):null)}function lt(e,t){e.setAttribute("fill",t.fill),D(e,"stroke",t.stroke??null),D(e,"stroke-width",t.stroke&&t.strokeWidth>0?String(t.strokeWidth):null),D(e,"opacity",t.opacity<1?String(t.opacity):null)}function Jt(e,t){e.setAttribute("cx",String(t.x+t.w/2)),e.setAttribute("cy",String(t.y+t.h/2)),e.setAttribute("rx",String(t.w/2)),e.setAttribute("ry",String(t.h/2)),lt(e,t)}function Qt(e,t){e.setAttribute("d",t.d),lt(e,t),D(e,"fill-rule",t.rule==="nonzero"?null:t.rule),D(e,"stroke-linecap",t.cap==="butt"?null:t.cap),D(e,"stroke-linejoin",t.join==="miter"?null:t.join)}function D(e,t,r){r===null?e.removeAttribute(t):e.setAttribute(t,r)}var en=4;function tn(e,t,r){let i=e.rotation===0?t:Ee(t,{x:e.x+e.w/2,y:e.y+e.h/2},-e.rotation),n=i.x>=e.x&&i.x<=e.x+e.w&&i.y>=e.y&&i.y<=e.y+e.h;if(e.kind==="ellipse"){let l=e.stroke!==void 0?e.strokeWidth/2:0,c=e.w/2+l,m=e.h/2+l;if(c<=0||m<=0)return!1;let u=(i.x-(e.x+e.w/2))/c,y=(i.y-(e.y+e.h/2))/m;return u*u+y*y<=1}if(e.kind==="vector"){let l=e.stroke!==void 0&&e.strokeWidth>0;return Ue(e.contours,i,{fill:e.fill!=="none",rule:e.rule,reach:(l?e.strokeWidth/2:0)+r})}return n}function ae(e,t){let r=new Map;for(let n of t.items)n.kind==="frame"&&n.w>0&&n.h>0&&r.set(n.id,{id:n.id,x:n.x,y:n.y,w:n.w,h:n.h});let i=e.root.children.flatMap(n=>{let l=n.type==="frame"?r.get(n.id):void 0;return l&&n.type==="frame"?[{...l,skip:n.skip===!0}]:[]});return i.length===0?[{id:null,x:t.x,y:t.y,w:t.width,h:t.height,skip:!1}]:i.every(n=>n.skip)?i.map(n=>({...n,skip:!1})):i}function pt(e,t){return e.root.children.find(i=>i.type==="frame"&&$e(i,t)!==void 0)?.id}function ht(e,t){let r=t===void 0?-1:e.findIndex(i=>i.id===t);return r!==-1?r:Math.max(0,e.findIndex(i=>!i.skip))}function ce(e,t,r){for(let i=t+r;i>=0&&i<e.length;i+=r)if(!e[i]?.skip)return i;return t}function gt(e){return e.filter(t=>!t.skip).length}function Ce(e,t){return e[t]?.skip!==!1?null:e.slice(0,t+1).filter(r=>!r.skip).length}function mt(e,t){if(!/^\d+$/.test(e))return null;let r=Number(e),i=t.findIndex((n,l)=>Ce(t,l)===r);return i===-1?null:i}function yt(e,t,r){let i=pt(e,r),n=t.findIndex(l=>l.id!==null&&l.id===i);return n===-1?null:n}var nn="cubic-bezier(0.2, 0, 0, 1)",rn="cubic-bezier(0.4, 0, 1, 1)",wt="cubic-bezier(0.4, 0, 0.2, 1)";function vt(e,t,r,i,n){let l={opacity:r},c=on(e,t,i,n);if(e==="cut")return{keyframes:t==="enter"?[{visibility:"hidden"},{visibility:"hidden"}]:[{visibility:"visible"},{visibility:"visible"}],easing:"linear"};if(e==="pop"){let m=`${n.x}px ${n.y}px`;l.scale="1",l.transformOrigin=m}else(e==="rise"||e==="drop")&&(l.translate="0 0");return t==="enter"?{keyframes:[c,l],easing:nn}:{keyframes:[l,c],easing:rn}}function on(e,t,r,i){switch(e){case"rise":return{opacity:0,translate:`0 ${t==="enter"?r:-r}px`};case"drop":return{opacity:0,translate:`0 ${t==="enter"?-r:r}px`};case"pop":return{opacity:0,scale:String(.85),transformOrigin:`${i.x}px ${i.y}px`};case"fade":case"cut":return{opacity:0}}}function xt(e,t){let r=t==="forward"?"-100%":"100%",i=t==="forward"?"100%":"-100%";switch(e){case"cut":return null;case"fade":return{still:[{opacity:1},{opacity:0}],live:null,stillOnTop:!0};case"push":return{still:[{translate:"0 0"},{translate:`${r} 0`}],live:[{translate:`${i} 0`},{translate:"0 0"}],stillOnTop:!1};case"slide":return t==="forward"?{still:null,live:[{translate:"100% 0"},{translate:"0 0"}],stillOnTop:!1}:{still:[{translate:"0 0"},{translate:"100% 0"}],live:null,stillOnTop:!0}}}var sn={enter:"cut",duration:0,steps:[[]],clicks:new Map};function De(e){let t=new Map,r=new Map,i=new Map;Ve(e.root,(m,u)=>{u&&(r.set(m.id,u.id),i.set(u.id,[...i.get(u.id)??[],m.id]))});let n=je(e),l=Be(e);for(let[m,u]of Object.entries(e.motion??{})){if(!l.has(m))continue;let y=[[]],f=new Map;for(let p of u.lines){if(p.id===m||n.get(p.id)!==m)continue;let A=p.go===void 0?void 0:He(p.go);A&&f.set(p.id,A);let S=p.enter!==void 0?"enter":p.exit!==void 0?"exit":null,E=p.enter??p.exit;S===null||E===void 0||(p.step&&y.push([]),y.at(-1).push({id:p.id,kind:S,effect:E,duration:E==="cut"?0:p.duration??Se,delay:p.delay??0,together:p.together===!0}))}t.set(m,{enter:u.enter??"cut",duration:u.duration??Se,steps:y,clicks:f})}let c=m=>[m,...(i.get(m)??[]).flatMap(u=>c(u))];return{pages:t,parents:r,within:c}}function bt(e,t){let r=t?.id;return(r?e.pages.get(r):void 0)??sn}function Fe(e){let t=0,r=0;return e.map((i,n)=>(t=(n===0?0:i.together?t:r)+i.delay,r=t+i.duration,{build:i,at:t}))}function St(e){return Math.max(0,...Fe(e).map(({build:t,at:r})=>r+t.duration))}function se(e,t){let r=new Set,i=new Set;for(let n of e.steps.flat())i.has(n.id)||(i.add(n.id),n.kind==="enter"&&r.add(n.id));for(let n of e.steps.slice(0,t).flat())n.kind==="enter"?r.delete(n.id):r.add(n.id);return r}function Et(e,t,r){for(let i=r;i!==void 0;i=e.parents.get(i)){let n=t.clicks.get(i);if(n)return{id:i,target:n}}}function kt(e,t,r){let i=[...e];for(;i.length>0;){let n=i.pop(),l=t.findIndex(c=>c.id!==null&&c.id===n);if(l!==-1&&l!==r)return{index:l,history:i}}return null}var cn=1500,dn=2e3,un=50;function Ie(e,t){let r=e.ownerDocument;e.classList.add("vd-player"),e.tabIndex=-1;let i=new Set,n=new Set,l=!1,c=le(e,{document:t.document,interactive:!1,surface:"#000",...t.fonts?{fonts:t.fonts}:{},...t.loadFont?{loadFont:t.loadFont}:{},...t.resolveAsset?{resolveAsset:t.resolveAsset}:{},onSceneChange:()=>{l&&z()}}),m=r.createElementNS(j,"path");m.setAttribute("class","vd-player__mask"),m.setAttribute("fill","#000"),m.setAttribute("fill-rule","evenodd"),c.surface.appendChild(m);let u=r.createElement("div");u.className="vd-player__counter",u.setAttribute("aria-live","polite"),e.appendChild(u);let y=De(t.document),f=ae(t.document,c.getScene()),p=ht(f,t.start),A=[],S=0,E=[],x,C=0,O="",_,N,$=r.defaultView,P=()=>typeof c.surface.animate=="function"&&!($?.matchMedia?.("(prefers-reduced-motion: reduce)").matches??!1),F=()=>bt(y,f[p]);function I(){let s=e.getBoundingClientRect(),d=f[p];return{width:s.width||d?.w||1,height:s.height||d?.h||1}}function U(){let s=f[p];if(!s)return;let d=I(),o=oe({x:s.x,y:s.y,width:s.w,height:s.h},d,0);c.setCamera(o);let h=s.x*o.zoom+o.x,g=s.y*o.zoom+o.y,b=s.w*o.zoom,T=s.h*o.zoom;m.setAttribute("d",`M0 0H${d.width}V${d.height}H0ZM${h} ${g}h${b}v${T}h${-b}Z`),m.dataset.slide=s.id??""}function K(){let s=Ce(f,p),d=gt(f);u.textContent=s===null?"Skipped":`${s} / ${d}`,u.classList.add("vd-player__counter--shown"),_&&clearTimeout(_),_=setTimeout(()=>u.classList.remove("vd-player__counter--shown"),cn),t.onChange?.(s,d)}function z(){let s=new Set;for(let d of i)for(let o of y.within(d))s.add(o);n=s;for(let d of c.surface.querySelectorAll("[data-vd-hidden]")){let o=d.getAttribute("data-vd-id");(o===null||!s.has(o))&&d.removeAttribute("data-vd-hidden")}for(let d of s)c.elementOf(d)?.setAttribute("data-vd-hidden","")}function q(s){return y.within(s).flatMap(d=>{let o=c.elementOf(d);return o?[o]:[]})}function X(s){let d=1/0,o=1/0,h=-1/0,g=-1/0;for(let b of y.within(s)){let T=c.itemOf(b);T&&(d=Math.min(d,T.x),o=Math.min(o,T.y),h=Math.max(h,T.x+T.w),g=Math.max(g,T.y+T.h))}return Number.isFinite(d)?{x:(d+h)/2,y:(o+g)/2}:{x:0,y:0}}function W(){if(!(E.length===0&&!x)){C+=1,S===0&&(S=1),i=se(F(),S),z();for(let s of E)s.cancel();E=[],x?.remove(),x=void 0}}function B(){return E.length===0&&!x?!1:(W(),!0)}function te(s,d){return new Promise(o=>{let h=!1,g=()=>{h||(h=!0,o())};Promise.all(s.map(b=>b.finished)).then(g,()=>{h=!0}),setTimeout(()=>{if(!h){for(let b of s)(b.playState==="running"||b.playState==="paused")&&b.finish();g()}},d+un)})}function Z(s,d,o){if(s===p||!f[s])return;let h=F();p=s;let g=F(),b=o==="forward"?g:h,T=P()?xt(b.enter,o):null;if(T&&(x=c.surface.cloneNode(!0),x.classList.add("vd-player__still"),x.setAttribute("aria-hidden","true"),T.stillOnTop?c.surface.after(x):c.surface.before(x)),U(),S=d?0:g.steps.length,i=se(g,S),z(),K(),!T||!x){d&&J();return}let R={duration:b.duration,easing:wt},k=[];T.still&&k.push(x.animate(T.still,{...R,fill:"forwards"})),T.live&&k.push(c.surface.animate(T.live,R)),E.push(...k);let re=C;te(k,b.duration).then(()=>{if(re===C){E=E.filter(ie=>!k.includes(ie));for(let ie of k)ie.cancel();x?.remove(),x=void 0,d&&J()}})}function J(){let s=F(),d=s.steps[S];if(d===void 0)return;S+=1;let o=se(s,S);if(d.length===0)return;if(!P()){i=o,z();return}let h=new Set(d.filter(k=>k.kind==="enter").map(k=>k.id));i=new Set([...se(s,S-1)].filter(k=>!h.has(k))),z();let g=f[p],b=.04*Math.min(g?.w??0,g?.h??0),T=C,R=[];for(let{build:k,at:re}of Fe(d)){let ie=X(k.id),Y=[];for(let V of q(k.id)){let de=Number(V.getAttribute("opacity")??1),{keyframes:be,easing:he}=vt(k.effect,k.kind,Number.isFinite(de)?de:1,b,ie);Y.push(V.animate(be,{duration:k.duration,delay:re,easing:he,fill:k.kind==="enter"?"backwards":"forwards"}))}R.push(...Y),k.kind==="exit"&&Y.length>0&&te(Y,re+k.duration).then(()=>{if(T===C){i.add(k.id),z();for(let V of Y)V.cancel()}})}E.push(...R),te(R,St(d)).then(()=>{if(T===C){E=E.filter(k=>!R.includes(k)),i=o,z();for(let k of R)k.cancel()}})}function H(s){let d=Math.min(Math.max(0,s),f.length-1);if(d===p)return;let o=f[p]?.id;o&&A.push(o),Z(d,!0,"forward")}function Q(){if(!B()){if(S<F().steps.length){J();return}H(ce(f,p,1))}}function G(){if(B())return;let s=kt(A,f,p);if(s){A=s.history,Z(s.index,!1,"back");return}Z(ce(f,p,-1),!1,"back")}function ne(s){switch(s.kind){case"url":t.onLink?.(s.url);return;case"back":G();return;case"next":H(ce(f,p,1));return;case"frame":{let d=yt(c.getDocument(),f,s.id);d===null?Q():H(d)}}}function a(s){let d=f[p];if(!d||s.x<d.x||s.y<d.y||s.x>d.x+d.w||s.y>d.y+d.h)return;let o=T=>!n.has(T),h=c.hitTest(s,o),g=h===null?void 0:Et(y,F(),h);if(g)return g.target;let b=c.linkAt(s,o);return b===void 0?void 0:ge(b)}let v=s=>{if(s.stopPropagation(),s.metaKey||s.ctrlKey||s.altKey)return;let d=s.key;if(/^\d$/.test(d))O+=d;else if(d==="Enter"&&O!==""){let o=mt(O,f);O="",!B()&&o!==null&&H(o)}else if(d==="Escape")O!==""?O="":t.onExit?.();else if(["ArrowRight","ArrowDown","PageDown"," ","Enter"].includes(d))O="",Q();else if(["ArrowLeft","ArrowUp","PageUp","Backspace"].includes(d))O="",G();else if(d==="Home")B()||H(ce(f,-1,1));else if(d==="End")B()||H(ce(f,f.length,-1));else return;s.preventDefault()},M=s=>{if(B())return;let d=a(c.screenToDocument(c.pointerPoint(s)));d?ne(d):Q()},w=s=>{if(e.classList.remove("vd-player--idle"),N&&clearTimeout(N),N=setTimeout(()=>e.classList.add("vd-player--idle"),dn),!s)return;let d=c.screenToDocument(c.pointerPoint(s));e.classList.toggle("vd-player--link",a(d)!==void 0)},L=$&&"ResizeObserver"in $?new $.ResizeObserver(()=>U()):void 0;return L?.observe(e),e.addEventListener("keydown",v),e.addEventListener("click",M),e.addEventListener("pointermove",w),l=!0,U(),i=se(F(),0),z(),K(),w(),e.focus({preventScroll:!0}),J(),{viewer:c,index:()=>p,count:()=>f.length,next:Q,back:G,go(s){W(),H(s)},update(s){if(s===c.getDocument())return;W();let d=f[p]?.id;c.update(s),y=De(s),f=ae(s,c.getScene());let o=f.findIndex(h=>h.id===d);p=o===-1?Math.min(p,f.length-1):o,U(),S=F().steps.length,i=se(F(),S),z()},refit:U,destroy(){C+=1;for(let s of E)s.cancel();E=[],x?.remove(),L?.disconnect(),e.removeEventListener("keydown",v),e.removeEventListener("click",M),e.removeEventListener("pointermove",w),_&&clearTimeout(_),N&&clearTimeout(N),m.remove(),u.remove(),c.destroy(),e.classList.remove("vd-player","vd-player--idle","vd-player--link"),e.removeAttribute("tabindex")}}}function At(e){let t=e,r=new Map,i=typeof URL.createObjectURL=="function"&&typeof URL.revokeObjectURL=="function";return{resolve(n){let l=r.get(n.hash);if(l!==void 0)return l;let c=t.get(n.hash);if(c===void 0)return;if(!i)return We(n.type,c);let m;try{m=Ke(c)}catch{return}let u=URL.createObjectURL(new Blob([m],{type:n.type}));return r.set(n.hash,u),u},replace(n){t=n;for(let[l,c]of r)n.has(l)||(URL.revokeObjectURL(c),r.delete(l))},destroy(){for(let n of r.values())URL.revokeObjectURL(n);r.clear(),t=new Map}}}var Ne=["page","content","none"],Ot=24;function pe(e){let t=e.getBoundingClientRect();return{width:t.width,height:t.height}}function Mt(e,t){let r=t===void 0?void 0:e.itemOf(t);if(!(!r||r.w<=0||r.h<=0))return{x:r.x,y:r.y,width:r.w,height:r.h}}function Tt(e,t,r,i){if(r==="none")return;let n=r==="page"?Mt(e,i):void 0;if(!n){e.fitToContent(Ot);return}let l=pe(t);e.setCamera(oe(n,{width:l.width||n.width,height:l.height||n.height},Ot))}function _t(e,t,r){let i=Mt(e,r);if(!i)return;let n=e.getCamera(),l=pe(t),c=l.width||i.width*n.zoom,m=l.height||i.height*n.zoom;e.setCamera({zoom:n.zoom,x:c/2-(i.x+i.width/2)*n.zoom,y:m/2-(i.y+i.height/2)*n.zoom})}var ze=Symbol.for("vdesign.embed.handover");function Lt(e){return e[ze]}var Pt=["exact","browser"],Ct=["ready","problems","page","fonts"];async function fn(e,t){try{let{exactFontsAt:r}=await import("./chunks/fonts.js"),i=r(e);return(await i.ensure(t)).length===0?i:void 0}catch{return}}async function ur(e,t,r={}){let i=r.fit??"page";if(!Ne.includes(i))throw new TypeError(`view: fit must be one of ${Ne.join(", ")}; got ${String(i)}.`);let n=r.fonts??"exact";if(!Pt.includes(n))throw new TypeError(`view: fonts must be one of ${Pt.join(", ")}; got ${String(n)}.`);let l=n==="exact"?et(r.fontBase,Re,e.ownerDocument.baseURI):void 0,c=Lt(r),m=await Ae(t),u=c?.page!==void 0&&ee(m.document).some(o=>o.id===c.page)?c.page:r.page===void 0?ee(m.document)[0]?.id:ue(m.document,r.page).id,y=c?.exact&&l?await fn(l,m.document):void 0,f=e.ownerDocument,p=f.defaultView,A=At(m.blocks),S=m.blocks,E=[...m.problems],x,C=()=>x?[...E,x]:[...E],O=f.createElement("div");O.className="vd-embed",O.style.width="100%",O.style.height="100%",e.appendChild(O);let _=le(O,{document:m.document,interactive:r.interactive??!0,wheel:"modifier",resolveAsset:o=>A.resolve(o),...r.surface?{surface:r.surface}:{},...c?{camera:c.camera}:{},...y?{fonts:y.library}:{}}),N={ready:new Set,problems:new Set,page:new Set,fonts:new Set},$=!1,P=!1,F=0,I,U,K=y,z=n==="browser"?"browser":void 0,q;function X(){$=!0;for(let o of N.ready)o()}function W(){for(let o of N.problems)o(C())}function B(o){z=o;for(let h of N.fonts)h(o)}function te(){return q??=(async()=>{if(l)try{let{exactFontsAt:o}=await import("./chunks/fonts.js");return o(l)}catch{return}})(),q}function Z(o){K=void 0,_.setFonts(void 0),I?.fonts(void 0),x=o,W(),B("browser")}async function J(){let o=await te();if(!P){if(!o){Z(ye([],l?"the fonts chunk would not load":"no fontBase was given and this build has no default"));return}for(;;){let h=_.getDocument(),g=await o.ensure(h);if(P)return;if(g.length>0){Z(ye(g));return}if(_.getDocument()===h)break}K=o,_.setFonts(o.library),I?.fonts(o),B("exact")}}function H(){let o=Q(u);if(o)for(let h of N.page)h(o)}function Q(o){let h=ee(_.getDocument()).find(g=>g.id===o);if(h)return h.name===void 0?{id:h.id}:{id:h.id,name:h.name}}let G=()=>Tt(_,O,i,u),ne=()=>_t(_,O,u);function a(o){if(P)return;let h=ue(_.getDocument(),o).id,g=h!==u;u=h,i==="page"?G():ne(),g&&H()}function v(o){r.onLink?r.onLink(o):p?.open(o,"_blank","noopener,noreferrer")}let M=o=>{if(o.button!==0||I)return;let h=_.linkAt(_.screenToDocument(_.pointerPoint(o)));if(h===void 0)return;let g=ge(h);if(g){if(o.preventDefault(),g.kind==="frame"){ee(_.getDocument()).some(b=>b.id===g.id)&&a(g.id);return}v(g.url)}};O.addEventListener("click",M);let w=pe(O),L=p&&"ResizeObserver"in p?new p.ResizeObserver(()=>{let o=pe(O);o.width===w.width&&o.height===w.height||(w=o,G())}):void 0;L?.observe(O),c||(i==="none"&&u!==void 0&&r.page!==void 0?ne():G()),X(),y?B("exact"):n==="exact"&&J();let s={async load(o){if(P)throw new Error("view: this view was destroyed.");let h=++F,g=await Ae(o),b=K,T=b?await b.ensure(g.document):[];if(U&&await U||P||h!==F)return;T.length>0&&K===b&&Z(ye(T)),A.replace(g.blocks),S=g.blocks,_.update(g.document),E=[...g.problems],I?.update(g.document),ee(g.document).some(k=>k.id===u)||(u=ee(g.document)[0]?.id,i==="page"?G():ne(),H()),W(),X()},pages:()=>ee(_.getDocument()).map(o=>o.name===void 0?{id:o.id}:{id:o.id,name:o.name}),goTo:a,fit:()=>{P||G()},play(o={}){if(P)return Promise.reject(new Error("view: this view was destroyed."));try{return I?.stop(),Promise.resolve(d(_.getDocument(),o.page))}catch(h){return Promise.reject(h instanceof Error?h:new Error(String(h)))}},async edit(o={}){if(P)throw new Error("view: this view was destroyed.");if(U)throw new Error("view: edit() is already opening an editor.");let h;U=new Promise(b=>h=b);let g=!1;try{let{edit:b}=await import("./edit.js");if(P)throw new Error("view: this view was destroyed.");let T={camera:_.getCamera(),page:u,exact:K!==void 0},R=Qe(_.getDocument(),S,E),k=await b(e,R,{...r,...o,[ze]:T});if(P)throw k.destroy(),new Error("view: this view was destroyed.");return g=!0,s.destroy(),k}finally{U=void 0,h(g)}},on(o,h){if(!Ct.includes(o))throw new TypeError(`view: on() takes one of ${Ct.join(", ")}; got ${String(o)}.`);let g=N[o];if(g.add(h),o==="ready"&&$&&queueMicrotask(()=>{g.has(h)&&h()}),o==="problems"&&queueMicrotask(()=>{g.has(h)&&h(C())}),o==="fonts"&&z!==void 0){let b=z;queueMicrotask(()=>{g.has(h)&&h(b)})}return()=>{g.delete(h)}},destroy(){if(!P){P=!0,I?.stop(),O.removeEventListener("click",M),L?.disconnect(),_.destroy(),A.destroy(),O.remove();for(let o of Object.values(N))o.clear()}}};function d(o,h){let g=h===void 0?u:ue(o,h).id,b=f.createElement("div");b.className="vd-embed__play",b.style.position="absolute",b.style.inset="0";let T=V=>V.stopPropagation();b.addEventListener("wheel",T);let R=f.activeElement;O.appendChild(b);let k=!1,re=()=>{if(k)return;k=!0,I===ie&&(I=void 0),Y.destroy(),b.removeEventListener("wheel",T);let V=b.contains(f.activeElement);b.remove(),V&&R&&"focus"in R&&typeof R.focus=="function"&&R.focus({preventScroll:!0})},ie={stop:re,update:V=>Y.update(V),fonts:V=>Y.viewer.setFonts(V?.library)},Y=Ie(b,{document:o,resolveAsset:V=>A.resolve(V),...K?{fonts:K.library}:{},...g===void 0?{}:{start:g},onExit:re,onLink:v});return I=ie,{goTo(V){if(k)return;let de=Y.viewer.getDocument(),be=ue(de,V).id,he=ae(de,Y.viewer.getScene()).findIndex(Dt=>Dt.id===be);he!==-1&&Y.go(he)},destroy:re}}return s}export{Ft as version,ur as view};
|
|
101
|
+
`;function wt(e){if(e.getElementById(gt))return;let t=e.createElement("style");t.id=gt,t.textContent=yt,e.head.appendChild(t)}function vt(e,t,r,i){return t?nn(e,t,r,i):tn(e,r,i)}function tn(e,t,r){let i=Ve(e,r);return{measurer:i,update:n=>{i.load(n,t)},afterPaint:()=>{},destroy:()=>i.destroy()}}var xt=new WeakMap;function nn(e,t,r,i){let n,u,s,m=()=>{if(!n)throw new Error("canvasFonts: update() before measuring");return n};return{measurer:{advance:(g,l)=>m().measurer.advance(g,l),metrics:g=>m().measurer.metrics(g),itemize:g=>m().measurer.itemize(g)},update(g){n&&g.fonts===u||(s?.(),n?.dispose(),n=t.forDocument(g,r?{loader:r}:{}),u=g.fonts,s=n.onChange(i))},afterPaint(){let g=e.fonts;if(!n||!g||typeof FontFace!="function")return;let l=xt.get(e);l||xt.set(e,l=new Set);for(let p of n.usedFaces()){if(l.has(p.id))continue;l.add(p.id);let M=new FontFace(p.id,rn(p.bytes),{weight:String(p.weight),style:p.style});g.add(M),M.load().catch(()=>g.delete(M))}},destroy(){s?.(),n?.dispose(),n=void 0}}}function rn(e){return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}var on=.01,sn=.004,bt=40,an=16;function Ae(e,t){wt(e.ownerDocument);let r=t.document,i=a=>vt(e.ownerDocument,a,t.loadFont,()=>{z(r)}),n=i(t.fonts),u={advance:(a,v)=>n.measurer.advance(a,v),metrics:a=>n.measurer.metrics(a),itemize:a=>n.measurer.itemize?.(a)??[a]};n.update(r);let s=_e(r),m=()=>t.resolveAsset?{measure:u,resolveAsset:t.resolveAsset}:{measure:u},f=Ne(r,s,m()),g=t.camera??Pe,l=t.interactive??!0,p=t.wheel??"always";e.classList.add("vd-viewer"),t.surface&&(e.style.background=t.surface);let M=e.ownerDocument.createElementNS(J,"svg");M.setAttribute("class","vd-viewer__surface"),M.setAttribute("width","100%"),M.setAttribute("height","100%");let S=e.ownerDocument.createElementNS(J,"g");S.setAttribute("class","vd-viewer__camera"),S.style.isolation="isolate",M.appendChild(S);let O=e.ownerDocument.createElementNS(J,"defs");S.appendChild(O);let w=e.ownerDocument.createElementNS(J,"rect");w.setAttribute("class","vd-viewer__page"),S.appendChild(w),e.appendChild(M);let N=new Map;function _(){S.setAttribute("transform",$e(g))}function x(){X();let a=f.background!==void 0;A(w,"x",String(f.x)),A(w,"y",String(f.y)),A(w,"width",String(a?f.width:0)),A(w,"height",String(a?f.height:0)),I(w,"fill",f.background??null);let v=new Set,L=w;for(let E of f.items){v.add(E.id);let b=N.get(E.id);(!b||b.tagName!==Et(E))&&(b?.remove(),b=e.ownerDocument.createElementNS(J,Et(E)),b.setAttribute("data-vd-id",E.id),N.set(E.id,b)),fn(b,E),L.nextSibling!==b&&S.insertBefore(b,L.nextSibling),L=b}for(let[E,b]of N)v.has(E)||(b.remove(),N.delete(E));n.afterPaint(),t.onSceneChange?.(f,r)}let R=new Map;function X(){let a=[...f.gradients.map(at),...f.items.filter(b=>b.shadows.length>0).map(b=>dt(b)),...f.clips.map(st)],v=new Set(a);for(let[b,H]of R)v.has(b)||(H.remove(),R.delete(b));let L=a.filter(b=>!R.has(b));if(L.length===0)return;[...new DOMParser().parseFromString(`<svg xmlns="${J}">${L.join("")}</svg>`,"image/svg+xml").documentElement.children].forEach((b,H)=>{let d=e.ownerDocument.importNode(b,!0);O.appendChild(d),R.set(L[H],d)})}function z(a){r=a,n.update(r),s=_e(r),f=Ne(r,s,m()),x()}function G(a){let v=e.getBoundingClientRect();return{x:a.clientX-v.left,y:a.clientY-v.top}}let C=0,j=0;function Y(){e.classList.add("vd-viewer--interacting"),j&&clearTimeout(j),j=setTimeout(()=>{j=0,e.classList.remove("vd-viewer--interacting")},180)}function Z(){C&&(cancelAnimationFrame(C),C=0),_(),t.onCameraChange?.(g)}function te(a){g=a,Z()}function $(a){g=a,Y(),!C&&(C=requestAnimationFrame(()=>{C=0,_(),t.onCameraChange?.(g)}))}let Q=null,B=null,fe=!1,K=a=>{if(p==="modifier"&&!a.ctrlKey&&!a.metaKey)return;a.preventDefault();let v=G(a),L=a.deltaMode===1?an:a.deltaMode===2?e.clientHeight||800:1,E=a.deltaX*L,b=a.deltaY*L;if(a.ctrlKey||a.metaKey){let H=a.ctrlKey?on:sn,d=Math.max(-bt,Math.min(bt,b));$(De(g,v,Math.exp(-d*H)));return}if(a.shiftKey&&E===0){$(ke(g,-b,0));return}$(ke(g,-E,-b))},ge=a=>{(a.button===1||a.button===0&&fe)&&(a.preventDefault(),Q=a.pointerId,B=G(a),e.setPointerCapture(a.pointerId))},pe=a=>{if(Q!==a.pointerId||!B)return;let v=G(a);$(ke(g,v.x-B.x,v.y-B.y)),B=v},ne=a=>{Q===a.pointerId&&(Q=null,B=null,e.hasPointerCapture(a.pointerId)&&e.releasePointerCapture(a.pointerId))},W=a=>{a.code==="Space"&&(fe=!0)},re=a=>{a.code==="Space"&&(fe=!1)};l&&(e.addEventListener("wheel",K,{passive:!1}),e.addEventListener("pointerdown",ge),e.addEventListener("pointermove",pe),e.addEventListener("pointerup",ne),e.addEventListener("pointercancel",ne),e.ownerDocument.addEventListener("keydown",W),e.ownerDocument.addEventListener("keyup",re)),_(),x();let se={element:e,surface:M,update:z,getDocument:()=>r,getScene:()=>f,getResolution:()=>s,getMeasurer:()=>u,setFonts(a){n.destroy(),n=i(a),z(r)},getCamera:()=>g,setCamera:te,zoomBy(a,v){let L=e.getBoundingClientRect(),E=v??{x:L.width/2,y:L.height/2};te(De(g,E,a))},fitToContent(a=32){let v=e.getBoundingClientRect();te(de({x:f.x,y:f.y,width:f.width,height:f.height},{width:v.width||f.width,height:v.height||f.height},a))},screenToDocument:a=>Ce(g,a),documentToScreen:a=>Re(g,a),pointerPoint:G,hitTest(a,v){for(let L=f.items.length-1;L>=0;L--){let E=f.items[L];if(E&&xn(E,a,wn/g.zoom)&&(!v||v(E.id)))return E.id}return null},linkAt(a,v){for(let L=f.items.length-1;L>=0;L--){let E=f.items[L];if(E?.kind!=="text"||v&&!v(E.id))continue;let b=E.rotation===0?a:Ie(a,{x:E.x+E.w/2,y:E.y+E.h/2},-E.rotation);for(let H of E.lines){if(b.y<H.y||b.y>H.y+H.h)continue;let d=H.spans.find(y=>b.x>=y.x&&b.x<=y.x+y.w);if(d)return d.style.link}}},itemOf:a=>f.items.find(v=>v.id===a),elementOf:a=>N.get(a),destroy(){l&&(e.removeEventListener("wheel",K),e.removeEventListener("pointerdown",ge),e.removeEventListener("pointermove",pe),e.removeEventListener("pointerup",ne),e.removeEventListener("pointercancel",ne),e.ownerDocument.removeEventListener("keydown",W),e.ownerDocument.removeEventListener("keyup",re)),C&&cancelAnimationFrame(C),j&&clearTimeout(j),C=0,j=0,n.destroy(),e.classList.remove("vd-viewer--interacting"),M.remove(),N.clear(),e.classList.remove("vd-viewer")}};return t.autoFit&&se.fitToContent(),se}var cn="vd-clip-";function dn(e){return cn+e}function kt(e){return`url(#${dn(e)})`}function Et(e){return lt(e)?"g":Be(e)}function Be(e){switch(e.kind){case"ellipse":return"ellipse";case"frame":return"rect";case"image":return e.href===void 0?"rect":"image";case"rect":return"rect";case"text":return"text";case"vector":return"path"}}function fn(e,t){if(e.tagName!=="g"){St(e,t);return}I(e,"clip-path",t.clip===void 0?null:kt(t.clip)),e.style.mixBlendMode=t.blend==="normal"?"":t.blend;let r=e.firstElementChild;(!r||r.tagName!==Be(t))&&(r?.remove(),r=e.ownerDocument.createElementNS(J,Be(t)),e.appendChild(r)),St(r,{...t,clip:void 0,blend:"normal"})}function St(e,t){switch(I(e,"clip-path",t.clip===void 0?null:kt(t.clip)),I(e,"transform",t.rotation===0?null:ft(t)),e.style.mixBlendMode=t.blend==="normal"?"":t.blend,e.style.filter=t.shadows.length>0?`url(#${ct}${t.id})`:"",t.kind){case"ellipse":gn(e,t);return;case"frame":ln(e,t);return;case"image":un(e,t);return;case"rect":mn(e,t);return;case"text":hn(e,t);return;case"vector":yn(e,t);return}}function ln(e,t){A(e,"class","vd-viewer__page"),A(e,"x",String(t.x)),A(e,"y",String(t.y)),A(e,"width",String(t.w)),A(e,"height",String(t.h)),I(e,"fill",t.background??null)}function un(e,t){if(A(e,"x",String(t.x)),A(e,"y",String(t.y)),A(e,"width",String(t.w)),A(e,"height",String(t.h)),I(e,"opacity",t.opacity<1?String(t.opacity):null),t.href===void 0){A(e,"class","vd-viewer__missing"),I(e,"rx",t.radius>0?String(t.radius):null);return}A(e,"href",t.href),A(e,"preserveAspectRatio",pn[t.fit])}var pn={cover:"xMidYMid slice",contain:"xMidYMid meet",fill:"none"};function hn(e,t){I(e,"opacity",t.opacity<1?String(t.opacity):null),A(e,"xml:space","preserve");let r=t.lines.flatMap(n=>n.spans).filter(n=>n.text!==""),i=e.ownerDocument;for(;e.childNodes.length>r.length;)e.lastChild?.remove();for(;e.childNodes.length<r.length;)e.appendChild(i.createElementNS(J,"tspan"));r.forEach((n,u)=>{let s=e.childNodes[u];s.textContent!==n.text&&(s.textContent=n.text),A(s,"x",String(n.x)),A(s,"y",String(n.y)),A(s,"font-family",n.style.family),A(s,"font-size",String(n.style.size)),A(s,"fill",n.style.fill),I(s,"font-weight",n.style.weight===400?null:String(n.style.weight)),I(s,"font-style",n.style.italic?"italic":null),I(s,"letter-spacing",n.style.letterSpacing===0?null:String(n.style.letterSpacing)),I(s,"data-vd-link",n.style.link??null);let m=[n.style.underline?"underline":"",n.style.strike?"line-through":""].filter(Boolean).join(" ");I(s,"text-decoration",m===""?null:m)})}function mn(e,t){I(e,"class",null),A(e,"x",String(t.x)),A(e,"y",String(t.y)),A(e,"width",String(t.w)),A(e,"height",String(t.h)),A(e,"fill",t.fill),I(e,"rx",t.radius>0?String(t.radius):null),I(e,"stroke",t.stroke??null),I(e,"stroke-width",t.stroke&&t.strokeWidth>0?String(t.strokeWidth):null),I(e,"opacity",t.opacity<1?String(t.opacity):null)}function At(e,t){A(e,"fill",t.fill),I(e,"stroke",t.stroke??null),I(e,"stroke-width",t.stroke&&t.strokeWidth>0?String(t.strokeWidth):null),I(e,"opacity",t.opacity<1?String(t.opacity):null)}function gn(e,t){A(e,"cx",String(t.x+t.w/2)),A(e,"cy",String(t.y+t.h/2)),A(e,"rx",String(t.w/2)),A(e,"ry",String(t.h/2)),At(e,t)}function yn(e,t){A(e,"d",t.d),At(e,t),I(e,"fill-rule",t.rule==="nonzero"?null:t.rule),I(e,"stroke-linecap",t.cap==="butt"?null:t.cap),I(e,"stroke-linejoin",t.join==="miter"?null:t.join)}function A(e,t,r){e.getAttribute(t)!==r&&e.setAttribute(t,r)}function I(e,t,r){r===null?e.hasAttribute(t)&&e.removeAttribute(t):A(e,t,r)}var wn=4;function xn(e,t,r){let i=e.rotation===0?t:Ie(t,{x:e.x+e.w/2,y:e.y+e.h/2},-e.rotation),n=i.x>=e.x&&i.x<=e.x+e.w&&i.y>=e.y&&i.y<=e.y+e.h;if(e.kind==="ellipse"){let u=e.stroke!==void 0?e.strokeWidth/2:0,s=e.w/2+u,m=e.h/2+u;if(s<=0||m<=0)return!1;let f=(i.x-(e.x+e.w/2))/s,g=(i.y-(e.y+e.h/2))/m;return f*f+g*g<=1}if(e.kind==="vector"){let u=e.stroke!==void 0&&e.strokeWidth>0;return nt(e.contours,i,{fill:e.fill!=="none",rule:e.rule,reach:(u?e.strokeWidth/2:0)+r})}return n}function xe(e,t){let r=new Map;for(let n of t.items)n.kind==="frame"&&n.w>0&&n.h>0&&r.set(n.id,{id:n.id,x:n.x,y:n.y,w:n.w,h:n.h});let i=e.root.children.flatMap(n=>{let u=n.type==="frame"?r.get(n.id):void 0;return u&&n.type==="frame"?[{...u,skip:n.skip===!0}]:[]});return i.length===0?[{id:null,x:t.x,y:t.y,w:t.width,h:t.height,skip:!1}]:i.every(n=>n.skip)?i.map(n=>({...n,skip:!1})):i}function Mt(e,t){return e.root.children.find(i=>i.type==="frame"&&Je(i,t)!==void 0)?.id}function Ot(e,t){let r=t===void 0?-1:e.findIndex(i=>i.id===t);return r!==-1?r:Math.max(0,e.findIndex(i=>!i.skip))}function ve(e,t,r){for(let i=t+r;i>=0&&i<e.length;i+=r)if(!e[i]?.skip)return i;return t}function Tt(e){return e.filter(t=>!t.skip).length}function He(e,t){return e[t]?.skip!==!1?null:e.slice(0,t+1).filter(r=>!r.skip).length}function _t(e,t){if(!/^\d+$/.test(e))return null;let r=Number(e),i=t.findIndex((n,u)=>He(t,u)===r);return i===-1?null:i}function Lt(e,t,r){let i=Mt(e,r),n=t.findIndex(u=>u.id!==null&&u.id===i);return n===-1?null:n}var vn="cubic-bezier(0.2, 0, 0, 1)",bn="cubic-bezier(0.4, 0, 1, 1)",Pt="cubic-bezier(0.4, 0, 0.2, 1)";function Ct(e,t,r,i,n){let u={opacity:r},s=En(e,t,i,n);if(e==="cut")return{keyframes:t==="enter"?[{visibility:"hidden"},{visibility:"hidden"}]:[{visibility:"visible"},{visibility:"visible"}],easing:"linear"};if(e==="pop"){let m=`${n.x}px ${n.y}px`;u.scale="1",u.transformOrigin=m}else(e==="rise"||e==="drop")&&(u.translate="0 0");return t==="enter"?{keyframes:[s,u],easing:vn}:{keyframes:[u,s],easing:bn}}function En(e,t,r,i){switch(e){case"rise":return{opacity:0,translate:`0 ${t==="enter"?r:-r}px`};case"drop":return{opacity:0,translate:`0 ${t==="enter"?-r:r}px`};case"pop":return{opacity:0,scale:String(.85),transformOrigin:`${i.x}px ${i.y}px`};case"fade":case"cut":return{opacity:0}}}function Dt(e,t){let r=t==="forward"?"-100%":"100%",i=t==="forward"?"100%":"-100%";switch(e){case"cut":return null;case"fade":return{still:[{opacity:1},{opacity:0}],live:null,stillOnTop:!0};case"push":return{still:[{translate:"0 0"},{translate:`${r} 0`}],live:[{translate:`${i} 0`},{translate:"0 0"}],stillOnTop:!1};case"slide":return t==="forward"?{still:null,live:[{translate:"100% 0"},{translate:"0 0"}],stillOnTop:!1}:{still:[{translate:"0 0"},{translate:"100% 0"}],live:null,stillOnTop:!0}}}var Sn={enter:"cut",duration:0,steps:[[]],clicks:new Map,scroll:!1};function je(e){let t=new Map,r=new Map,i=new Map;Xe(e.root,(m,f)=>{f&&(r.set(m.id,f.id),i.set(f.id,[...i.get(f.id)??[],m.id]))});let n=tt(e),u=et(e);for(let[m,f]of Object.entries(e.motion??{})){if(!u.has(m))continue;let g=[[]],l=new Map;for(let p of f.lines){if(p.id===m||n.get(p.id)!==m)continue;let M=p.go===void 0?void 0:Qe(p.go);M&&l.set(p.id,M);let S=p.enter!==void 0?"enter":p.exit!==void 0?"exit":null,O=p.enter??p.exit;S===null||O===void 0||(p.step&&g.push([]),g.at(-1).push({id:p.id,kind:S,effect:O,duration:O==="cut"?0:p.duration??Fe,delay:p.delay??0,together:p.together===!0}))}t.set(m,{enter:f.enter??"cut",duration:f.duration??Fe,steps:g,clicks:l,scroll:f.scroll===!0})}let s=m=>[m,...(i.get(m)??[]).flatMap(f=>s(f))];return{pages:t,parents:r,within:s}}function Ft(e,t){let r=t?.id;return(r?e.pages.get(r):void 0)??Sn}function Ue(e){let t=0,r=0;return e.map((i,n)=>(t=(n===0?0:i.together?t:r)+i.delay,r=t+i.duration,{build:i,at:t}))}function It(e){return Math.max(0,...Ue(e).map(({build:t,at:r})=>r+t.duration))}function me(e,t){let r=new Set,i=new Set;for(let n of e.steps.flat())i.has(n.id)||(i.add(n.id),n.kind==="enter"&&r.add(n.id));for(let n of e.steps.slice(0,t).flat())n.kind==="enter"?r.delete(n.id):r.add(n.id);return r}function Nt(e,t,r){for(let i=r;i!==void 0;i=e.parents.get(i)){let n=t.clicks.get(i);if(n)return{id:i,target:n}}}function zt(e,t,r){let i=[...e];for(;i.length>0;){let n=i.pop(),u=t.findIndex(s=>s.id!==null&&s.id===n);if(u!==-1&&u!==r)return{index:u,history:i}}return null}function Vt(e,t,r){let i=Se(t.width/Math.max(1,e.w));if(e.h*i<=t.height)return{camera:de({x:e.x,y:e.y,width:e.w,height:e.h},t,0),top:0,max:0};let n=e.h-t.height/i,u=Math.min(Math.max(0,r),n),s=(t.width-e.w*i)/2-e.x*i;return{camera:{zoom:i,x:s,y:0-(e.y+u)*i},top:u,max:n}}var Me=.9,Ke=.1;function Rt(e,t){return e.deltaMode===1?e.deltaY*16:e.deltaMode===2?e.deltaY*t.height:e.deltaY}var An=1500,Mn=2e3,On=200,Tn=50;function We(e,t){let r=e.ownerDocument;e.classList.add("vd-player"),e.tabIndex=-1;let i=new Set,n=new Set,u=!1,s=Ae(e,{document:t.document,interactive:!1,surface:"#000",...t.fonts?{fonts:t.fonts}:{},...t.loadFont?{loadFont:t.loadFont}:{},...t.resolveAsset?{resolveAsset:t.resolveAsset}:{},onSceneChange:()=>{u&&K()}}),m=r.createElementNS(J,"path");m.setAttribute("class","vd-player__mask"),m.setAttribute("fill","#000"),m.setAttribute("fill-rule","evenodd"),s.surface.appendChild(m);let f=r.createElement("div");f.className="vd-player__counter",f.setAttribute("aria-live","polite"),e.appendChild(f);let g=je(t.document),l=xe(t.document,s.getScene()),p=Ot(l,t.start),M=[],S=0,O=[],w,N=0,_="",x=0,R=0,X=1,z=new Map,G,C=0,j,Y,Z=r.defaultView,te=()=>typeof s.surface.animate=="function"&&!(Z?.matchMedia?.("(prefers-reduced-motion: reduce)").matches??!1),$=()=>Ft(g,l[p]);function Q(){let o=e.getBoundingClientRect(),c=l[p];return{width:o.width||c?.w||1,height:o.height||c?.h||1}}function B(){let o=l[p];if(!o)return;let c=Q(),h=de({x:o.x,y:o.y,width:o.w,height:o.h},c,0);if(R=0,$().scroll){let q=Vt(o,c,x);h=q.camera,x=q.top,R=q.max}X=h.zoom,s.setCamera(h);let T=o.x*h.zoom+h.x,D=o.y*h.zoom+h.y,F=o.w*h.zoom,U=o.h*h.zoom;m.setAttribute("d",`M0 0H${c.width}V${c.height}H0ZM${T} ${D}h${F}v${U}h${-F}Z`),m.dataset.slide=o.id??""}function fe(){let o=He(l,p),c=Tt(l);f.textContent=o===null?"Skipped":`${o} / ${c}`,f.classList.add("vd-player__counter--shown"),j&&clearTimeout(j),j=setTimeout(()=>f.classList.remove("vd-player__counter--shown"),An),t.onChange?.(o,c)}function K(){let o=new Set;for(let c of i)for(let h of g.within(c))o.add(h);n=o;for(let c of s.surface.querySelectorAll("[data-vd-hidden]")){let h=c.getAttribute("data-vd-id");(h===null||!o.has(h))&&c.removeAttribute("data-vd-hidden")}for(let c of o)s.elementOf(c)?.setAttribute("data-vd-hidden","")}function ge(o){return g.within(o).flatMap(c=>{let h=s.elementOf(c);return h?[h]:[]})}function pe(o){let c=1/0,h=1/0,T=-1/0,D=-1/0;for(let F of g.within(o)){let U=s.itemOf(F);U&&(c=Math.min(c,U.x),h=Math.min(h,U.y),T=Math.max(T,U.x+U.w),D=Math.max(D,U.y+U.h))}return Number.isFinite(c)?{x:(c+T)/2,y:(h+D)/2}:{x:0,y:0}}function ne(){if(!(O.length===0&&!w)){N+=1,S===0&&(S=1),i=me($(),S),K();for(let o of O)o.cancel();O=[],w?.remove(),w=void 0}}function W(){return O.length===0&&!w?!1:(ne(),!0)}function re(o,c){return new Promise(h=>{let T=!1,D=()=>{T||(T=!0,h())};Promise.all(o.map(F=>F.finished)).then(D,()=>{T=!0}),setTimeout(()=>{if(!T){for(let F of o)(F.playState==="running"||F.playState==="paused")&&F.finish();D()}},c+Tn)})}function se(o,c,h){if(o===p||!l[o])return;let T=$(),D=l[p]?.id;D&&z.set(D,G===void 0?x:C),v(),p=o;let F=$(),U=l[o]?.id;x=c||!U?0:z.get(U)??0;let q=h==="forward"?F:T,P=te()?Dt(q.enter,h):null;if(P&&(w=s.surface.cloneNode(!0),w.classList.add("vd-player__still"),w.setAttribute("aria-hidden","true"),P.stillOnTop?s.surface.after(w):s.surface.before(w)),B(),S=c?0:F.steps.length,i=me(F,S),K(),fe(),!P||!w){c&&a();return}let be={duration:q.duration,easing:Pt},le=[];P.still&&le.push(w.animate(P.still,{...be,fill:"forwards"})),P.live&&le.push(s.surface.animate(P.live,be)),O.push(...le);let he=N;re(le,q.duration).then(()=>{if(he===N){O=O.filter(ue=>!le.includes(ue));for(let ue of le)ue.cancel();w?.remove(),w=void 0,c&&a()}})}function a(){let o=$(),c=o.steps[S];if(c===void 0)return;S+=1;let h=me(o,S);if(c.length===0)return;if(!te()){i=h,K();return}let T=new Set(c.filter(P=>P.kind==="enter").map(P=>P.id));i=new Set([...me(o,S-1)].filter(P=>!T.has(P))),K();let D=l[p],F=.04*Math.min(D?.w??0,D?.h??0),U=N,q=[];for(let{build:P,at:be}of Ue(c)){let le=pe(P.id),he=[];for(let ue of ge(P.id)){let Ze=Number(ue.getAttribute("opacity")??1),{keyframes:Yt,easing:Zt}=Ct(P.effect,P.kind,Number.isFinite(Ze)?Ze:1,F,le);he.push(ue.animate(Yt,{duration:P.duration,delay:be,easing:Zt,fill:P.kind==="enter"?"backwards":"forwards"}))}q.push(...he),P.kind==="exit"&&he.length>0&&re(he,be+P.duration).then(()=>{if(U===N){i.add(P.id),K();for(let ue of he)ue.cancel()}})}O.push(...q),re(q,It(c)).then(()=>{if(U===N){O=O.filter(P=>!q.includes(P)),i=h,K();for(let P of q)P.cancel()}})}function v(){G!==void 0&&Z?.cancelAnimationFrame(G),G=void 0}function L(o){if(v(),C=Math.min(Math.max(0,o),R),!te()||!Z?.requestAnimationFrame){x=C,B();return}let c=x,h,T=D=>{h??=D;let F=Math.min(1,(D-h)/On);x=c+(C-c)*(1-(1-F)**3),B(),G=F<1?Z.requestAnimationFrame(T):void 0};G=Z.requestAnimationFrame(T)}function E(o,c){if(W())return;let h=G===void 0?x:C;if(!(o>0?x>=R-.5:x<=.5)){L(h+o*Q().height/X);return}c||(o>0?d():y())}function b(o){if(!(!$().scroll||R<=0))switch(o.key){case" ":return o.shiftKey?-Me:Me;case"PageDown":return Me;case"PageUp":return-Me;case"ArrowDown":return Ke;case"ArrowUp":return-Ke;default:return}}function H(o){let c=Math.min(Math.max(0,o),l.length-1);if(c===p)return;let h=l[p]?.id;h&&M.push(h),se(c,!0,"forward")}function d(){if(!W()){if(S<$().steps.length){a();return}H(ve(l,p,1))}}function y(){if(W())return;let o=zt(M,l,p);if(o){M=o.history,se(o.index,!1,"back");return}se(ve(l,p,-1),!1,"back")}function k(o){switch(o.kind){case"url":t.onLink?.(o.url);return;case"back":y();return;case"next":H(ve(l,p,1));return;case"frame":{let c=Lt(s.getDocument(),l,o.id);c===null?d():V(c,o.id)}}}function V(o,c){let h=o===p;h||H(o);let T=l[p];if(!T||!$().scroll)return;let D=T.id===c?void 0:s.itemOf(c),F=D?D.y-T.y:0;h?L(F):(x=F,B())}function ie(o){let c=l[p];if(!c||o.x<c.x||o.y<c.y||o.x>c.x+c.w||o.y>c.y+c.h)return;let h=U=>!n.has(U),T=s.hitTest(o,h),D=T===null?void 0:Nt(g,$(),T);if(D)return D.target;let F=s.linkAt(o,h);return F===void 0?void 0:Te(F)}let oe=o=>{if(o.stopPropagation(),o.metaKey||o.ctrlKey||o.altKey)return;let c=o.key,h=b(o);if(h!==void 0){_="",E(h,o.repeat),o.preventDefault();return}if(/^\d$/.test(c))_+=c;else if(c==="Enter"&&_!==""){let T=_t(_,l);_="",!W()&&T!==null&&H(T)}else if(c==="Escape")_!==""?_="":t.onExit?.();else if(["ArrowRight","ArrowDown","PageDown"," ","Enter"].includes(c))_="",d();else if(["ArrowLeft","ArrowUp","PageUp","Backspace"].includes(c))_="",y();else if(c==="Home")W()||H(ve(l,-1,1));else if(c==="End")W()||H(ve(l,l.length,-1));else return;o.preventDefault()},ee=o=>{if(W())return;let c=ie(s.screenToDocument(s.pointerPoint(o)));c?k(c):d()},ye=o=>{!$().scroll||R<=0||(o.preventDefault(),!(w||o.ctrlKey||o.metaKey)&&(v(),x=Math.min(Math.max(0,x+Rt(o,Q())/X),R),B()))},we=o=>{if(e.classList.remove("vd-player--idle"),Y&&clearTimeout(Y),Y=setTimeout(()=>e.classList.add("vd-player--idle"),Mn),!o)return;let c=s.screenToDocument(s.pointerPoint(o));e.classList.toggle("vd-player--link",ie(c)!==void 0)},ae=Z&&"ResizeObserver"in Z?new Z.ResizeObserver(()=>B()):void 0;return ae?.observe(e),e.addEventListener("keydown",oe),e.addEventListener("click",ee),e.addEventListener("pointermove",we),e.addEventListener("wheel",ye,{passive:!1}),u=!0,B(),i=me($(),0),K(),fe(),we(),e.focus({preventScroll:!0}),a(),{viewer:s,index:()=>p,count:()=>l.length,next:d,back:y,go(o){ne(),H(o)},update(o){if(o===s.getDocument())return;ne();let c=l[p]?.id;s.update(o),g=je(o),l=xe(o,s.getScene());let h=l.findIndex(T=>T.id===c);p=h===-1?Math.min(p,l.length-1):h,h===-1&&(v(),x=0),B(),S=$().steps.length,i=me($(),S),K()},refit:B,destroy(){N+=1,v();for(let o of O)o.cancel();O=[],w?.remove(),ae?.disconnect(),e.removeEventListener("wheel",ye),e.removeEventListener("keydown",oe),e.removeEventListener("click",ee),e.removeEventListener("pointermove",we),j&&clearTimeout(j),Y&&clearTimeout(Y),m.remove(),f.remove(),s.destroy(),e.classList.remove("vd-player","vd-player--idle","vd-player--link"),e.removeAttribute("tabindex")}}}function $t(e){let t=e,r=new Map,i=typeof URL.createObjectURL=="function"&&typeof URL.revokeObjectURL=="function";return{resolve(n){let u=r.get(n.hash);if(u!==void 0)return u;let s=t.get(n.hash);if(s===void 0)return;if(!i)return rt(n.type,s);let m;try{m=it(s)}catch{return}let f=URL.createObjectURL(new Blob([m],{type:n.type}));return r.set(n.hash,f),f},replace(n){t=n;for(let[u,s]of r)n.has(u)||(URL.revokeObjectURL(s),r.delete(u))},destroy(){for(let n of r.values())URL.revokeObjectURL(n);r.clear(),t=new Map}}}var Ge=["page","content","none"],Bt=24;function Oe(e){let t=e.getBoundingClientRect();return{width:t.width,height:t.height}}function Ht(e,t){let r=t===void 0?void 0:e.itemOf(t);if(!(!r||r.w<=0||r.h<=0))return{x:r.x,y:r.y,width:r.w,height:r.h}}function jt(e,t,r,i){if(r==="none")return;let n=r==="page"?Ht(e,i):void 0;if(!n){e.fitToContent(Bt);return}let u=Oe(t);e.setCamera(de(n,{width:u.width||n.width,height:u.height||n.height},Bt))}function Ut(e,t,r){let i=Ht(e,r);if(!i)return;let n=e.getCamera(),u=Oe(t),s=u.width||i.width*n.zoom,m=u.height||i.height*n.zoom;e.setCamera({zoom:n.zoom,x:s/2-(i.x+i.width/2)*n.zoom,y:m/2-(i.y+i.height/2)*n.zoom})}var Ye=Symbol.for("vdesign.embed.handover");function Kt(e){return e[Ye]}var Wt=["exact","browser"],Gt=["ready","problems","page","fonts"];async function _n(e,t){try{let{exactFontsAt:r}=await import("./chunks/fonts.js"),i=r(e);return(await i.ensure(t)).length===0?i:void 0}catch{return}}async function Pr(e,t,r={}){let i=r.fit??"page";if(!Ge.includes(i))throw new TypeError(`view: fit must be one of ${Ge.join(", ")}; got ${String(i)}.`);let n=r.fonts??"exact";if(!Wt.includes(n))throw new TypeError(`view: fonts must be one of ${Wt.join(", ")}; got ${String(n)}.`);let u=n==="exact"?pt(r.fontBase,qe,e.ownerDocument.baseURI):void 0,s=Kt(r),m=await ze(t),f=s?.page!==void 0&&ce(m.document).some(d=>d.id===s.page)?s.page:r.page===void 0?ce(m.document)[0]?.id:Ee(m.document,r.page).id,g=s?.exact&&u?await _n(u,m.document):void 0,l=e.ownerDocument,p=l.defaultView,M=$t(m.blocks),S=m.blocks,O=[...m.problems],w,N=()=>w?[...O,w]:[...O],_=l.createElement("div");_.className="vd-embed",_.style.width="100%",_.style.height="100%",e.appendChild(_);let x=Ae(_,{document:m.document,interactive:r.interactive??!0,wheel:"modifier",resolveAsset:d=>M.resolve(d),...r.surface?{surface:r.surface}:{},...s?{camera:s.camera}:{},...g?{fonts:g.library}:{}}),R={ready:new Set,problems:new Set,page:new Set,fonts:new Set},X=!1,z=!1,G=0,C,j,Y=g,Z=n==="browser"?"browser":void 0,te;function $(){X=!0;for(let d of R.ready)d()}function Q(){for(let d of R.problems)d(N())}function B(d){Z=d;for(let y of R.fonts)y(d)}function fe(){return te??=(async()=>{if(u)try{let{exactFontsAt:d}=await import("./chunks/fonts.js");return d(u)}catch{return}})(),te}function K(d){Y=void 0,x.setFonts(void 0),C?.fonts(void 0),w=d,Q(),B("browser")}async function ge(){let d=await fe();if(!z){if(!d){K(Le([],u?"the fonts chunk would not load":"no fontBase was given and this build has no default"));return}for(;;){let y=x.getDocument(),k=await d.ensure(y);if(z)return;if(k.length>0){K(Le(k));return}if(x.getDocument()===y)break}Y=d,x.setFonts(d.library),C?.fonts(d),B("exact")}}function pe(){let d=ne(f);if(d)for(let y of R.page)y(d)}function ne(d){let y=ce(x.getDocument()).find(k=>k.id===d);if(y)return y.name===void 0?{id:y.id}:{id:y.id,name:y.name}}let W=()=>jt(x,_,i,f),re=()=>Ut(x,_,f);function se(d){if(z)return;let y=Ee(x.getDocument(),d).id,k=y!==f;f=y,i==="page"?W():re(),k&&pe()}function a(d){r.onLink?r.onLink(d):p?.open(d,"_blank","noopener,noreferrer")}let v=d=>{if(d.button!==0||C)return;let y=x.linkAt(x.screenToDocument(x.pointerPoint(d)));if(y===void 0)return;let k=Te(y);if(k){if(d.preventDefault(),k.kind==="frame"){ce(x.getDocument()).some(V=>V.id===k.id)&&se(k.id);return}a(k.url)}};_.addEventListener("click",v);let L=Oe(_),E=p&&"ResizeObserver"in p?new p.ResizeObserver(()=>{let d=Oe(_);d.width===L.width&&d.height===L.height||(L=d,W())}):void 0;E?.observe(_),s||(i==="none"&&f!==void 0&&r.page!==void 0?re():W()),$(),g?B("exact"):n==="exact"&&ge();let b={async load(d){if(z)throw new Error("view: this view was destroyed.");let y=++G,k=await ze(d),V=Y,ie=V?await V.ensure(k.document):[];if(j&&await j||z||y!==G)return;ie.length>0&&Y===V&&K(Le(ie)),M.replace(k.blocks),S=k.blocks,x.update(k.document),O=[...k.problems],C?.update(k.document),ce(k.document).some(ee=>ee.id===f)||(f=ce(k.document)[0]?.id,i==="page"?W():re(),pe()),Q(),$()},pages:()=>ce(x.getDocument()).map(d=>d.name===void 0?{id:d.id}:{id:d.id,name:d.name}),goTo:se,fit:()=>{z||W()},play(d={}){if(z)return Promise.reject(new Error("view: this view was destroyed."));try{return C?.stop(),Promise.resolve(H(x.getDocument(),d.page))}catch(y){return Promise.reject(y instanceof Error?y:new Error(String(y)))}},async edit(d={}){if(z)throw new Error("view: this view was destroyed.");if(j)throw new Error("view: edit() is already opening an editor.");let y;j=new Promise(V=>y=V);let k=!1;try{let{edit:V}=await import("./edit.js");if(z)throw new Error("view: this view was destroyed.");let ie={camera:x.getCamera(),page:f,exact:Y!==void 0},oe=ut(x.getDocument(),S,O),ee=await V(e,oe,{...r,...d,[Ye]:ie});if(z)throw ee.destroy(),new Error("view: this view was destroyed.");return k=!0,b.destroy(),ee}finally{j=void 0,y(k)}},on(d,y){if(!Gt.includes(d))throw new TypeError(`view: on() takes one of ${Gt.join(", ")}; got ${String(d)}.`);let k=R[d];if(k.add(y),d==="ready"&&X&&queueMicrotask(()=>{k.has(y)&&y()}),d==="problems"&&queueMicrotask(()=>{k.has(y)&&y(N())}),d==="fonts"&&Z!==void 0){let V=Z;queueMicrotask(()=>{k.has(y)&&y(V)})}return()=>{k.delete(y)}},destroy(){if(!z){z=!0,C?.stop(),_.removeEventListener("click",v),E?.disconnect(),x.destroy(),M.destroy(),_.remove();for(let d of Object.values(R))d.clear()}}};function H(d,y){let k=y===void 0?f:Ee(d,y).id,V=l.createElement("div");V.className="vd-embed__play",V.style.position="absolute",V.style.inset="0";let ie=o=>o.stopPropagation();V.addEventListener("wheel",ie);let oe=l.activeElement;_.appendChild(V);let ee=!1,ye=()=>{if(ee)return;ee=!0,C===we&&(C=void 0),ae.destroy(),V.removeEventListener("wheel",ie);let o=V.contains(l.activeElement);V.remove(),o&&oe&&"focus"in oe&&typeof oe.focus=="function"&&oe.focus({preventScroll:!0})},we={stop:ye,update:o=>ae.update(o),fonts:o=>ae.viewer.setFonts(o?.library)},ae=We(V,{document:d,resolveAsset:o=>M.resolve(o),...Y?{fonts:Y.library}:{},...k===void 0?{}:{start:k},onExit:ye,onLink:a});return C=we,{goTo(o){if(ee)return;let c=ae.viewer.getDocument(),h=Ee(c,o).id,T=xe(c,ae.viewer.getScene()).findIndex(D=>D.id===h);T!==-1&&ae.go(T)},destroy:ye}}return b}export{qt as version,Pr as view};
|
package/edit.css
CHANGED
|
@@ -626,6 +626,8 @@
|
|
|
626
626
|
*/
|
|
627
627
|
.vd-strip {
|
|
628
628
|
box-sizing: border-box;
|
|
629
|
+
/* The drop line and the context menu are placed against it. */
|
|
630
|
+
position: relative;
|
|
629
631
|
display: flex;
|
|
630
632
|
flex: 0 0 104px;
|
|
631
633
|
height: 104px;
|
|
@@ -652,21 +654,121 @@
|
|
|
652
654
|
}
|
|
653
655
|
|
|
654
656
|
.vd-strip__list[hidden],
|
|
655
|
-
.vd-
|
|
657
|
+
.vd-strip__blank[hidden],
|
|
658
|
+
.vd-strip__drop[hidden] {
|
|
656
659
|
display: none;
|
|
657
660
|
}
|
|
658
661
|
|
|
659
|
-
.
|
|
662
|
+
/* No frames: what the strip is for, and the way to start one. */
|
|
663
|
+
.vd-strip__blank {
|
|
664
|
+
display: flex;
|
|
660
665
|
flex: 1 1 auto;
|
|
661
|
-
align-
|
|
662
|
-
|
|
666
|
+
align-items: center;
|
|
667
|
+
justify-content: center;
|
|
668
|
+
gap: 12px;
|
|
669
|
+
min-width: 0;
|
|
663
670
|
padding: 0 16px;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
.vd-strip__empty {
|
|
674
|
+
min-width: 0;
|
|
675
|
+
margin: 0;
|
|
664
676
|
font-size: 12px;
|
|
665
677
|
line-height: 1.5;
|
|
666
|
-
text-align: center;
|
|
667
678
|
color: var(--vd-muted, rgb(0 0 0 / 0.55));
|
|
668
679
|
}
|
|
669
680
|
|
|
681
|
+
.vd-strip__add {
|
|
682
|
+
flex: 0 0 auto;
|
|
683
|
+
height: 28px;
|
|
684
|
+
padding: 0 12px;
|
|
685
|
+
border: 1px solid var(--vd-rule, rgb(0 0 0 / 0.12));
|
|
686
|
+
border-radius: 6px;
|
|
687
|
+
background: none;
|
|
688
|
+
color: var(--vd-ink, #1a1a1f);
|
|
689
|
+
font: inherit;
|
|
690
|
+
font-size: 12px;
|
|
691
|
+
cursor: default;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
.vd-strip__add:hover {
|
|
695
|
+
background: var(--vd-row-hover, rgb(0 0 0 / 0.06));
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
.vd-strip__add:focus-visible {
|
|
699
|
+
outline: 2px solid var(--vd-focus, var(--vd-accent, #3b82f6));
|
|
700
|
+
outline-offset: 2px;
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
/* Where a dragged tile lands: a line in the gap, the tile's height, level
|
|
704
|
+
with the pictures (the list's 11 px top padding). */
|
|
705
|
+
.vd-strip__drop {
|
|
706
|
+
position: absolute;
|
|
707
|
+
top: 11px;
|
|
708
|
+
width: 2px;
|
|
709
|
+
height: 64px;
|
|
710
|
+
border-radius: 1px;
|
|
711
|
+
background: var(--vd-chosen, var(--vd-accent, #3b82f6));
|
|
712
|
+
pointer-events: none;
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
/* The tiles being dragged stay in place, faded, until the drop moves them. */
|
|
716
|
+
.vd-strip__tile[data-dragging='true'] {
|
|
717
|
+
opacity: 0.35;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
.vd-strip--dragging,
|
|
721
|
+
.vd-strip--dragging * {
|
|
722
|
+
cursor: grabbing;
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
/* The picture under the pointer while dragging, with a count for several. */
|
|
726
|
+
.vd-strip__ghost {
|
|
727
|
+
position: fixed;
|
|
728
|
+
top: 0;
|
|
729
|
+
left: 0;
|
|
730
|
+
z-index: 10;
|
|
731
|
+
pointer-events: none;
|
|
732
|
+
opacity: 0.9;
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
.vd-strip__ghost .vd-strip__thumb {
|
|
736
|
+
outline: 2px solid var(--vd-chosen, var(--vd-accent, #3b82f6));
|
|
737
|
+
outline-offset: 1px;
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
.vd-strip__count {
|
|
741
|
+
position: absolute;
|
|
742
|
+
top: -8px;
|
|
743
|
+
right: -8px;
|
|
744
|
+
min-width: 18px;
|
|
745
|
+
height: 18px;
|
|
746
|
+
padding: 0 5px;
|
|
747
|
+
box-sizing: border-box;
|
|
748
|
+
border-radius: 9px;
|
|
749
|
+
background: var(--vd-chosen, var(--vd-accent, #3b82f6));
|
|
750
|
+
color: var(--vd-on-chosen, #ffffff);
|
|
751
|
+
font-family: var(--vd-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
|
|
752
|
+
font-size: 11px;
|
|
753
|
+
line-height: 18px;
|
|
754
|
+
text-align: center;
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
/* Read by a screen reader, never seen. */
|
|
758
|
+
.vd-strip__status {
|
|
759
|
+
position: absolute;
|
|
760
|
+
width: 1px;
|
|
761
|
+
height: 1px;
|
|
762
|
+
overflow: hidden;
|
|
763
|
+
clip-path: inset(50%);
|
|
764
|
+
white-space: nowrap;
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
/* The menu opens up over the canvas, so it sits above the canvas's chrome. */
|
|
768
|
+
.vd-strip > .vd-menu {
|
|
769
|
+
z-index: 10;
|
|
770
|
+
}
|
|
771
|
+
|
|
670
772
|
.vd-strip__tile {
|
|
671
773
|
display: flex;
|
|
672
774
|
flex: 0 0 auto;
|
|
@@ -689,7 +791,9 @@
|
|
|
689
791
|
box-sizing: border-box;
|
|
690
792
|
overflow: hidden;
|
|
691
793
|
border-radius: 4px;
|
|
692
|
-
|
|
794
|
+
/* Its own variable, not the strip's rule: a dark slide on a dark strip
|
|
795
|
+
needs a stronger edge than a panel's hairline to be told apart. */
|
|
796
|
+
outline: 1px solid var(--vd-thumb-rule, var(--vd-rule, rgb(0 0 0 / 0.12)));
|
|
693
797
|
outline-offset: -1px;
|
|
694
798
|
background: var(--vd-thumb-bg, #f2f2f2);
|
|
695
799
|
}
|
package/package.json
CHANGED
package/view.css
CHANGED
|
@@ -20,10 +20,11 @@
|
|
|
20
20
|
.vd-viewer__surface text {
|
|
21
21
|
white-space: pre;
|
|
22
22
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
/* No `will-change` on the camera group. It made the document its own
|
|
24
|
+
composited layer, and every camera step then rebuilt the compositor's layer
|
|
25
|
+
list from one entry per clipped or filtered item: 40 ms a step at 60 pages,
|
|
26
|
+
most of a pan. Without it a step repaints what is on screen instead, which is
|
|
27
|
+
cheap except under a large blur. */
|
|
27
28
|
.vd-viewer__page {
|
|
28
29
|
/* An embedder with a no-shadow brand sets --vd-page-shadow: none. */
|
|
29
30
|
filter: var(--vd-page-shadow, drop-shadow(0 6px 24px rgb(0 0 0 / 0.35)));
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/*! @getv.design/embed v0.1.2. Free to use under the vDesign Embed Licence. © 2026 Sagar Saini. https://getv.design/docs/licence/ */
|
|
2
|
-
function D(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 J="--- payload base64 ---",Pn="sha256-";function Ut(e){let t=Dn(e);return t===-1?{head:e,payload:""}:{head:e.slice(0,t),payload:e.slice(t+J.length)}}function Rn(e){let{head:t,payload:n}=Ut(e);return{head:t,blocks:Wt(n)}}function Wt(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(Pn)&&t.set(o,n.slice(r+1).trim())}return t}function Ln(e,t){return`data:${e};base64,${t}`}function Vn(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 Dn(e){if(e.startsWith(J))return 0;let t=e.indexOf(`
|
|
4
|
-
${J}`);return t===-1?-1:t+1}function ee(e){return{expr:e}}function P(e){return typeof e=="object"&&e!==null&&typeof e.expr=="string"}var me=["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],te=["left","center","right","justify"],ne=["top","middle","bottom"],re=["cover","contain","fill"],ge=["nonzero","evenodd"],xe=["butt","round","square"],$e=["miter","round","bevel"],Bt=["canvas","frame","group"];function we(e){return Bt.includes(e)}function _(e){return we(e.type)}function oe(e){return e.type==="group"}var zt={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 ke(e){return zt[e.type]}function T(e,t,n){if(t(e,n)!==!1&&_(e))for(let r of e.children)T(r,t,e)}function Ye(e,t){let n;return T(e,r=>{if(n)return!1;r.id===t&&(n=r)}),n}var ie=["design"],X="design";var ve=[1,2,3,4],F="doc";function se(e){return{type:"canvas",...e}}function be(e={}){return{version:4,kind:e.kind??X,...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},root:e.root??se({id:F,children:[]})}}var Ee=["cut","fade","push","slide"],Se=["cut","fade","rise","drop","pop"],Fn=400,ue=1e4;function Y(e){let t=e.trim();return t==="back"?{kind:"back"}:t==="next"?{kind:"next"}:D(t)}function ae(e){return e===void 0||e.enter===void 0&&e.duration===void 0&&e.lines.length===0}function Oe(e){return e.enter!==void 0||e.exit!==void 0||e.go!==void 0}function Me(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 He(e){return new Set(e.root.children.filter(t=>t.type==="frame").map(t=>t.id))}function Ke(e){let t=new Map;for(let n of e.root.children)n.type==="frame"&&T(n,r=>{t.set(r.id,n.id)});return t}function jn(e){let t=new Set;return T(e,n=>{t.add(n.id)}),t}function ce(e,t){let n=e.motion;if(!n)return[];let r=[],o=He(e),i=Ke(e),s=jn(e.root),a=(u,c)=>{let f=t?.(u,c);return f===void 0?"":`Line ${f}: `};for(let u of Me(e)){let c=n[u];if(c){if(!o.has(u)){r.push({severity:"warning",code:"motion-not-a-page",message:`${a(u)}motion ${u}: ${u} is not a page (a top-level frame), so none of it plays`,nodeId:u});continue}for(let f of c.lines){let d=a(u,f.id);s.has(f.id)?i.get(f.id)!==u&&r.push({severity:"warning",code:"motion-wrong-page",message:`${d}motion ${u}: ${f.id} is not on ${u}, so Play skips it`,nodeId:f.id}):r.push({severity:"warning",code:"unknown-reference",message:`${d}motion ${u}: no node ${f.id}`,nodeId:f.id});let l=f.go===void 0?void 0:Y(f.go);l?.kind==="frame"&&!Cn(e,l.id)&&r.push({severity:"warning",code:"unknown-reference",message:`${d}motion ${u}: go=#${l.id} names no frame`,nodeId:f.id})}}}return r}function Cn(e,t){let n=!1;return T(e.root,r=>{if(n)return!1;r.id===t&&(n=r.type==="frame")}),n}function h(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 Un={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0};function qe(e){let t=[],n,r=0,o=0,i=0,s=0,a,u,c=Bn(e),f=()=>(n||(n={anchors:[{x:r,y:o}],closed:!1},t.push(n)),n.anchors[n.anchors.length-1]),d=(p,$)=>{f(),n?.anchors.push({x:p,y:$}),r=p,o=$},l=(p,$,k,g)=>{f().out=p,n?.anchors.push({x:k,y:g,in:$}),r=k,o=g},y="",b=!0;for(;c.more();){let p=c.command();if(p!==void 0)y=p,b=!0;else if(y===""||y.toUpperCase()==="Z")return{contours:Te(t),error:`Expected a command at ${c.at()}`};let $=y.toUpperCase(),k=y!==$,g=Un[$];if(g===void 0)return{contours:Te(t),error:`Unknown command ${y}`};if($==="Z"){n&&(n.closed=!0),n=void 0,r=i,o=s,a=void 0,u=void 0,y="";continue}let N=$==="A"?c.arc():c.numbers(g);if(N===void 0)return{contours:Te(t),error:`${y} expects ${g} numbers at ${c.at()}`};let m=k?r:0,w=k?o:0,x=v=>N[v];switch($){case"M":b&&(n={anchors:[{x:m+x(0),y:w+x(1)}],closed:!1},t.push(n),r=i=m+x(0),o=s=w+x(1),y=k?"l":"L"),a=u=void 0;break;case"L":d(m+x(0),w+x(1)),a=u=void 0;break;case"H":d(m+x(0),o),a=u=void 0;break;case"V":d(r,w+x(0)),a=u=void 0;break;case"C":{let v={x:m+x(2),y:w+x(3)};l({x:m+x(0),y:w+x(1)},v,m+x(4),w+x(5)),a=v,u=void 0;break}case"S":{let v=a?{x:2*r-a.x,y:2*o-a.y}:{x:r,y:o},S={x:m+x(0),y:w+x(1)};l(v,S,m+x(2),w+x(3)),a=S,u=void 0;break}case"Q":case"T":{let v=$==="Q"?{x:m+x(0),y:w+x(1)}:u?{x:2*r-u.x,y:2*o-u.y}:{x:r,y:o},S=$==="Q"?m+x(2):m+x(0),L=$==="Q"?w+x(3):w+x(1),U={x:r+2/3*(v.x-r),y:o+2/3*(v.y-o)},W={x:S+2/3*(v.x-S),y:L+2/3*(v.y-L)};l(U,W,S,L),u=v,a=void 0;break}case"A":{let v=m+x(5),S=w+x(6);for(let[L,U,W]of zn(r,o,x(0),x(1),x(2),x(3)!==0,x(4)!==0,v,S))l(L,U,W.x,W.y);(r!==v||o!==S)&&d(v,S),a=u=void 0;break}}b=!1}return{contours:Te(t)}}function Te(e){return e.map(t=>{let n=[...t.anchors];if(t.closed&&n.length>1){let r=n[0],o=n[n.length-1];fe(r,o)&&(n.pop(),n[0]={...r,...o.in?{in:o.in}:{}})}return{anchors:n.map(Wn),closed:t.closed}})}function Wn(e){let t={x:e.x,y:e.y};return e.in&&!fe(e.in,e)&&(t.in=e.in),e.out&&!fe(e.out,e)&&(t.out=e.out),t}function fe(e,t,n=1e-6){return Math.abs(e.x-t.x)<n&&Math.abs(e.y-t.y)<n}function Bn(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 a=0;a<i;a+=1){let u=r();if(u===void 0)return;s.push(u)}return s},arc(){let i=this.numbers(3),s=o(),a=o(),u=this.numbers(2);if(!(!i||s===void 0||a===void 0||!u))return[...i,s,a,...u]},at(){return t}}}function zn(e,t,n,r,o,i,s,a,u){let c=Math.abs(n),f=Math.abs(r);if(c===0||f===0||e===a&&t===u)return[];let d=o*Math.PI/180,l=Math.cos(d),y=Math.sin(d),b=(e-a)/2,p=(t-u)/2,$=l*b+y*p,k=-y*b+l*p,g=$*$/(c*c)+k*k/(f*f);g>1&&(c*=Math.sqrt(g),f*=Math.sqrt(g));let N=c*c*f*f-c*c*k*k-f*f*$*$,m=c*c*k*k+f*f*$*$,w=(i===s?-1:1)*Math.sqrt(Math.max(0,N/m)),x=w*c*k/f,v=-w*f*$/c,S=l*x-y*v+(e+a)/2,L=y*x+l*v+(t+u)/2,U=(O,V,z,G)=>{let Z=O*z+V*G,ye=Math.hypot(O,V)*Math.hypot(z,G),Q=Math.acos(Math.min(1,Math.max(-1,Z/ye)));return O*G-V*z<0?-Q:Q},W=U(1,0,($-x)/c,(k-v)/f),B=U(($-x)/c,(k-v)/f,(-$-x)/c,(-k-v)/f);!s&&B>0&&(B-=2*Math.PI),s&&B<0&&(B+=2*Math.PI);let Je=Math.max(1,Math.ceil(Math.abs(B)/(Math.PI/2)-1e-9)),Xe=B/Je,he=4/3*Math.tan(Xe/4),Ft=O=>({x:S+c*Math.cos(O)*l-f*Math.sin(O)*y,y:L+c*Math.cos(O)*y+f*Math.sin(O)*l}),jt=O=>({x:-c*Math.sin(O)*l-f*Math.cos(O)*y,y:-c*Math.sin(O)*y+f*Math.cos(O)*l}),Ct=[];for(let O=0;O<Je;O+=1){let V=W+O*Xe,z=V+Xe,G=Ft(V),Z=O===Je-1?{x:a,y:u}:Ft(z),ye=jt(V),Q=jt(z);Ct.push([{x:G.x+he*ye.x,y:G.y+he*ye.y},{x:Z.x-he*Q.x,y:Z.y-he*Q.y},Z])}return Ct}function Ze(e){let t=[],n=r=>`${h(r.x)} ${h(r.y)}`;for(let r of e){let{anchors:o}=r,i=o[0];if(!i)continue;t.push(`M${n(i)}`);let s=Ne(r);for(let a=0;a<s;a+=1){let u=o[a],c=o[(a+1)%o.length],f=r.closed&&a===o.length-1;!u.out&&!c.in?f||t.push(`L${n(c)}`):t.push(`C${n(u.out??u)} ${n(c.in??c)} ${n(c)}`)}r.closed&&t.push("Z")}return t.join(" ")}function Ne(e){let t=e.anchors.length;return t<2?0:e.closed?t:t-1}function Qe(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 et(e,t){let[n,r,o,i]=e,s=1-t,a=s*s*s,u=3*s*s*t,c=3*s*t*t,f=t*t*t;return{x:a*n.x+u*r.x+c*o.x+f*i.x,y:a*n.y+u*r.y+c*o.y+f*i.y}}function tt(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 nt(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 u of s.anchors)i(u);let a=Ne(s);for(let u=0;u<a;u+=1){let c=Qe(s,u);for(let f of Gn(c))i(et(c,f))}}if(t!==1/0)return{x:t,y:n,w:r-t,h:o-n}}function Gn(e){let[t,n,r,o]=e,i=[];for(let s of["x","y"]){let a=-t[s]+3*n[s]-3*r[s]+o[s],u=2*(t[s]-2*n[s]+r[s]),c=n[s]-t[s];if(Math.abs(a)<1e-12){Math.abs(u)>1e-12&&i.push(-c/u);continue}let f=u*u-4*a*c;if(f<0)continue;let d=Math.sqrt(f);i.push((-u+d)/(2*a),(-u-d)/(2*a))}return i.filter(s=>s>0&&s<1)}function Ie(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 rt(e,t,n){return Ie(e)??{x:0,y:0,w:t,h:n}}function ot(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 Gt(e,t=.5){let[n,r,o,i]=e;if(fe(n,r)&&fe(o,i))return[n,i];let a=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),u=Math.min(256,Math.max(4,Math.ceil(Math.sqrt(a/t)))),c=[];for(let f=0;f<=u;f+=1)c.push(et(e,f/u));return c}function Jn(e,t,n){let r=0,o=0;for(let i of e){let s=Xn(i);if(s.length!==0){if(n.reach>0){let a=i.closed?s.length:s.length-1;for(let u=0;u<a;u+=1){let c=s[u],f=s[(u+1)%s.length];if(Yn(t,c,f)<=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 a=0;a<s.length;a+=1){let u=s[a],c=s[(a+1)%s.length];u.y<=t.y!=c.y<=t.y&&u.x+(t.y-u.y)/(c.y-u.y)*(c.x-u.x)>t.x&&(o+=1,r+=c.y>u.y?1:-1)}}}return n.fill?n.rule==="evenodd"?o%2===1:r!==0:!1}function Xn(e){let t=e.anchors[0];if(!t)return[];let n=[{x:t.x,y:t.y}],r=Ne(e);for(let o=0;o<r;o+=1)n.push(...Gt(Qe(e,o)).slice(1));return e.closed&&n.length>1&&n.pop(),n}function Yn(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 Ae={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"]]},_e=[["font","string"],["size","number"],["weight","number"],["italic","boolean"],["underline","boolean"],["strike","boolean"],["fill","string"],["letterSpacing","number"],["link","string"]];var it=[["enter","pageEffect"],["duration","number"]],Pe=[["enter","nodeEffect"],["exit","nodeEffect"],["duration","number"],["delay","number"],["step","boolean"],["together","boolean"],["go","string"]],Yt=Object.keys(Ae);function Re(e){return Yt.includes(e)}function st(e,t){return Ae[e].find(([n])=>n===t)?.[1]}function I(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=K(e);return r===void 0?{error:`Malformed quoted string ${e}`}:Jt(r,t,e)}if(tr(e)){if(!Zn(t))return{error:Qn(e,t)};let r=Kt(e).trim();return r===""?{error:"Empty expression"}:{value:ee(r)}}return t==="numberValue"&&Ht.test(e)?{value:ee(e)}:Jt(e,t,e)}var Ht=/^-?\d+(?:\.\d+)?%$/;function Zn(e){return e==="numberValue"||e==="stringValue"}function Qn(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 er(e,t){let n=/^(-?\d+(?:\.\d+)?)([A-Za-z]+)$/.exec(e);return n?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"?Ht.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 Jt(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}${er(e,t)}`}}case"align":return te.includes(e)?{value:e}:{error:`Expected one of ${te.join(", ")}, got ${n}`};case"valign":return ne.includes(e)?{value:e}:{error:`Expected one of ${ne.join(", ")}, got ${n}`};case"fontStyle":return e==="normal"||e==="italic"?{value:e}:{error:`Expected normal or italic, got ${n}`};case"imageFit":return re.includes(e)?{value:e}:{error:`Expected one of ${re.join(", ")}, got ${n}`};case"fillRule":return H(ge,e,n);case"lineCap":return H(xe,e,n);case"lineJoin":return H($e,e,n);case"blendMode":return H(me,e,n);case"pageEffect":return H(Ee,e,n);case"nodeEffect":return H(Se,e,n);default:return{value:e}}}function H(e,t,n){return e.includes(t)?{value:t}:{error:`Expected one of ${e.join(", ")}, got ${n}`}}function tr(e){return/^[$@(]/.test(e)}function K(e){try{let t=JSON.parse(e);return typeof t=="string"?t:void 0}catch{return}}function Kt(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 qt(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:A(n);if(r?.value===void 0||!Xt(e[t]??""))return;let o=t;for(;o<e.length&&Xt(e[o]??"");)o+=1;let i=[Kt(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 Xt(e){return!e.includes("=")&&/^(?:[-+*/]|-?\d+(?:\.\d+)?%?|[$@][\w.]*|[A-Za-z_]\w*(?:\.\w+)+|\(.*|.*\))$/.test(e)}function A(e){let t=e.indexOf("=");return t===-1?{key:e,value:void 0}:{key:e.slice(0,t),value:e.slice(t+1)}}var or=new Set(["exit","delay","step","together","go"]);function at(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 o of e.words.slice(2)){let{key:i,value:s}=A(o),a=it.find(([c])=>c===i)?.[1];if(a===void 0){let c=or.has(i)?` \u2014 ${i} goes on a node's line, under the header`:"";t(e.number,"invalid-motion",`motion ${n} has no "${i}"${c}`,n);continue}let u=I(s??"",a);"error"in u?t(e.number,"invalid-motion",`${i}: ${u.error}`,n):i==="duration"&&!Zt(u.value)?t(e.number,"invalid-motion",Qt(i,s),n):r[i]=u.value}return{page:n,number:e.number,head:r,lines:[],where:new Map,taken:new Map}}function ct(e,t,n){let r=t.words[0];if(t.indent!==1){n(t.number,"invalid-motion","A motion line sits one level under its page");return}if(r.includes("=")){n(t.number,"invalid-motion",`Expected a node id first, got ${r}`);return}if(r===e.page){n(t.number,"invalid-motion",`${r} is the page: its transition goes on the header (motion ${r} enter=fade)`,r);return}let o={id:r},i=!0;for(let a of t.words.slice(1)){let{key:u,value:c}=A(a),f=Pe.find(([l])=>l===u)?.[1];if(f===void 0){n(t.number,"invalid-motion",`A motion line has no "${u}"`,r),i=!1;continue}let d=I(c??"",f);"error"in d?(n(t.number,"invalid-motion",`${u}: ${d.error}`,r),i=!1):(u==="duration"||u==="delay")&&!Zt(d.value)?(n(t.number,"invalid-motion",Qt(u,c),r),i=!1):u==="go"&&Y(d.value)===void 0?(n(t.number,"invalid-motion",`go: expected #<page>, back, next, or an https: or mailto: link, got ${c??""}`,r),i=!1):d.value!==!1&&(o[u]=d.value)}if(o.enter!==void 0&&o.exit!==void 0&&(n(t.number,"invalid-motion",`${r} either enters or exits on one line \u2014 write a second line for the other`,r),i=!1),o.step===!0&&o.together===!0&&(n(t.number,"invalid-motion",`${r} waits for a step or starts together with the line above, not both`,r),i=!1),!i)return;let s=ir(o);if(!Oe(s)){n(t.number,"invalid-motion",`${r} says nothing: give it enter=, exit= or go=`,r);return}for(let a of["enter","exit","go"]){if(s[a]===void 0)continue;let u=e.taken.get(`${r} ${a}`);if(u!==void 0){let c=a==="go"?"has a go=":a==="enter"?"enters":"exits";n(t.number,"invalid-motion",`${r} already ${c} on line ${u}`,r);return}}for(let a of["enter","exit","go"])s[a]!==void 0&&e.taken.set(`${r} ${a}`,t.number);e.where.has(r)||e.where.set(r,t.number),e.lines.push(s)}function ft(e){let t={...e.head.enter===void 0?{}:{enter:e.head.enter},...e.head.duration===void 0?{}:{duration:e.head.duration},lines:e.lines};return ae(t)?void 0:t}function ir(e){let t={id:e.id};for(let[n]of Pe)e[n]!==void 0&&(t[n]=e[n]);return t}function Zt(e){return typeof e=="number"&&e>=0&&e<=ue}function Qt(e,t){return`${e}: expected 0 to ${ue} milliseconds, got ${t??""}`}function dt(e){return(t,n,r,o)=>{e.push({severity:"error",code:n,message:`Line ${t}: ${r}`,...o===void 0?{}:{nodeId:o}})}}function lt(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===J)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:qt(i)})}return t}function pt(e){let t=[],n=[],r=o=>{for(;t.length>0&&t[t.length-1].indent>=o;)ar(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 f=fr(o,e);return f!==void 0&&c.runs.push(f),!0}if(!Re(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 a=ur(i,s,o.words.slice(2),o,e),u=t[t.length-1];return u?u.children.push(a.record):n.push(a.record),t.push(a),!0},finish(){return r(0),n}}}function ur(e,t,n,r,o){let i={type:e,id:t},s=[];for(let a=0;a<n.length;a+=1){let{key:u,value:c}=A(n[a]),f=st(e,u);if(f===void 0){let l=ut(n,a,n[a-1]);l?(o(r.number,"invalid-value",l.message,t),a=l.end-1):o(r.number,"invalid-value",`${e} has no property "${u}"`,t);continue}let d=I(c??"",f);"error"in d?o(r.number,"invalid-value",`${u}: ${d.error}`,t):i[u]=d.value}return we(e)&&(i.children=s),e==="text"&&(i.content=""),{indent:r.indent,type:e,record:i,children:s,runs:[]}}function ar(e){e.type==="text"&&(e.record.content=cr(e.runs))}function cr(e){if(e.length===0)return"";let t=e[0];return e.length===1&&typeof t=="string"?t:[...e]}function fr(e,t){let n=K(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}=A(o),a=_e.find(([c])=>c===i);if(!a){t(e.number,"invalid-run",`A run has no mark "${i}"`);continue}let u=I(s??"",a[1]);"error"in u?t(e.number,"invalid-run",`${i}: ${u.error}`):r[i]=u.value}return r}function dr(e){let t=[],n=dt(t),r=X,o,i=!1,s={},a={},u={},c=pt(n),f,d={},l=new Map,y,b=!1,p=()=>{if(!y)return;let m=y;y=void 0;let w=l.get(m.page);if(w!==void 0){n(m.number,"invalid-motion",`motion ${m.page} is written twice \u2014 put its lines in the block on line ${w}`,m.page);return}l.set(m.page,m.number);for(let[v,S]of m.where)l.set(`${m.page} ${v}`,S);let x=ft(m);x&&(d[m.page]=x)};for(let m of lt(e)){let w=m.words[0];if(y&&m.indent>0){ct(y,m,n);continue}if(!(b&&m.indent>0)){if(b=!1,p(),w==="motion"&&m.indent===0){f=void 0,y=at(m,n),b=y===void 0;continue}if(w==="version"){i=!0,pr(m,t);continue}if(w==="kind"&&m.indent===0){r=hr(m,t);continue}if(w==="title"&&m.indent===0){o=tn(m,n);continue}if(w.startsWith("$")){f=void 0,yr(m,s,n);continue}if(w==="asset"&&m.indent===0){f=void 0,mr(m,u,n);continue}if(w==="font"&&m.indent===0){f=xr(m,a,n);continue}if((w==="fallback"||w==="face")&&f){$r(w,m,f,n);continue}f=void 0,!c.push(m)&&n(m.number,"unknown-node-type",`Unknown statement "${w}"`)}}p();let $=lr(c.finish(),t),k=Object.keys(d).length===0?{}:{motion:d},g=(m,w)=>l.get(w===void 0?m:`${m} ${w}`);if(!$){i||t.push({severity:"error",code:"invalid-document",message:"No nodes found"});let m=se({id:F,children:[]}),w=be({kind:r,...o===void 0?{}:{title:o},tokens:s,fonts:a,assets:u,...k,root:m});return t.push(...ce(w,g)),{document:w,problems:t}}let N={version:4,kind:r,...o===void 0?{}:{title:o},tokens:s,fonts:a,assets:u,...k,root:$};return t.push(...ce(N,g)),{document:N,problems:t}}function lr(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:F,children:[...e]}}}function pr(e,t){ve.includes(Number(e.words[1]))||t.push({severity:"warning",code:"version-mismatch",message:`Line ${e.number}: expected version ${4} or older, got ${e.words[1]??"nothing"}`})}function hr(e,t){let n=e.words[1];return n!==void 0&&ie.includes(n)?n:(t.push({severity:"error",code:"unknown-kind",message:`Line ${e.number}: unknown kind "${n??"nothing"}" \u2014 this build reads ${ie.join(", ")}`}),X)}function tn(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('"')?K(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 yr(e,t,n){let{name:r,value:o}=ht(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=I(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]=nn(i.value,o)}function nn(e,t){let n=Number(e);return t.startsWith('"')||!Number.isFinite(n)||e.trim()===""?e:n}function ht(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}=A(t);return o!==void 0?{name:n(r),value:o}:{name:n(t)}}function mr(e,t,n){let r=e.words.slice(1),o=r[0],i=r[1]==="=",s=o===void 0?void 0:A(o),a=s?.key,u=i?r[2]:s?.value,c=r.slice(i?3:1);if(a===void 0||a===""||u===void 0){n(e.number,"invalid-asset","Expected asset <name> = <type> hash=\u2026 bytes=\u2026");return}let f={};for(let y of c){let{key:b,value:p}=A(y);if(p===void 0){n(e.number,"invalid-asset",`Asset "${a}" has a stray word "${y}"`);continue}f[b]=gr(p)}let d=f.hash,l=Number(f.bytes);if(d===void 0||!Number.isFinite(l)){n(e.number,"invalid-asset",`Asset "${a}" needs a hash and a bytes count`);return}t[a]={type:u,hash:d,bytes:l,...f.credit===void 0?{}:{credit:f.credit},...f.source===void 0?{}:{source:f.source},...f.license===void 0?{}:{license:f.license}}}function gr(e){return e.startsWith('"')?K(e)??e:e}function xr(e,t,n){let{name:r,value:o}=ht(e.words.slice(1));if(r===void 0||o===void 0){n(e.number,"invalid-font","Expected font <name> = <family>");return}let i=I(o,"string"),s={family:"error"in i?o:i.value};return t[r]=s,{family:s,faces:[]}}function $r(e,t,n,r){if(e==="fallback"){let a=I(t.words.slice(1).join(" "),"string");"error"in a?r(t.number,"invalid-font",`fallback: ${a.error}`):n.family.fallback=a.value;return}let o=t.words[1];if(o===void 0){r(t.number,"invalid-font-face","A face needs a src");return}let i=I(o,"string"),s={src:"error"in i?o:i.value};for(let a of t.words.slice(2)){let{key:u,value:c}=A(a);if(u!=="weight"&&u!=="style"){r(t.number,"invalid-font-face",`A face has no property "${u}"`);continue}let f=I(c??"",u==="weight"?"number":"fontStyle");"error"in f?r(t.number,"invalid-font-face",`${u}: ${f.error}`):s[u]=f.value}n.faces.push(s),n.family.faces=n.faces}function Ve(e){return/^\s*(linear|radial|conic|repeating-[a-z]+)-gradient\s*\(/i.test(e)}function yt(e){let t=e.trim(),n=/^([a-z-]+)-gradient\s*\(([\s\S]*)\)$/i.exec(t);if(!n)return Ve(t)?{error:'A gradient needs its closing ")"'}:{kind:"solid",colour:t};let r=n[1].toLowerCase(),o=Er(n[2]).map(i=>i.trim());if(o.some(i=>i===""))return{error:"A gradient has an empty argument"};if(r==="linear"){let i=Or(o[0]),s=on(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=Tr(o[0]);if(i&&"error"in i)return i;let s=on(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 mt(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],a=t[i];for(let u=r;u<i;u+=1)t[u]=s+(a-s)*(u-o)/(i-o);r=i}return e.map((r,o)=>({colour:r.colour,at:t[o]}))}function Er(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 Sr={top:[0,-1],bottom:[0,1],left:[-1,0],right:[1,0]};function Or(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=Sr[i.toLowerCase()];if(!s)return;r+=s[0],o+=s[1]}return(Math.atan2(r,-o)*180/Math.PI+360)%360}var Mr={left:0,top:0,center:.5,right:1,bottom:1};function Tr(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=rn(t[2]),o=t[3]===void 0?.5:rn(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 rn(e){let t=Mr[e.toLowerCase()];if(t!==void 0)return t;let n=/^(-?\d*\.?\d+)%$/.exec(e);return n?Number(n[1])/100:void 0}function on(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&&Nr(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 Nr(e){let t=0;for(let n of e)if(n==="("&&(t+=1),n===")"&&(t-=1),t<0)return!1;return t===0}function gt(e){let t=e.trim();if(t===""||t==="none")return{shadows:[]};let n=[];for(let r of Ir(t)){let o=Ar(r.trim());if(o.includes("inset"))return{error:"Inner shadows (inset) are not supported yet"};let i=[],s=[];for(let d of o){let l=/^(-?\d*\.?\d+)(px)?$/.exec(d);l&&s.length===0?i.push(Number(l[1])):s.push(d)}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[a=0,u=0,c=0,f=0]=i;if(c<0)return{error:"A shadow cannot have a negative blur"};n.push({x:a,y:u,blur:c,spread:f,colour:s[0]})}return{shadows:n}}function Ir(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 Ar(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 De(e){return{x:e.x+e.w/2,y:e.y+e.h/2}}function sn(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,a=e.y-t.y;return{x:t.x+s*o-a*i,y:t.y+s*i+a*o}}function xt(e,t,n=De(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(u=>sn(u,n,t)),o=r.map(u=>u.x),i=r.map(u=>u.y),s=Math.min(...o),a=Math.min(...i);return{x:s,y:a,w:Math.max(...o)-s,h:Math.max(...i)-a}}var an="system-ui, -apple-system, Segoe UI, Roboto, sans-serif",cn=16,fn=400,dn=1.2,Fe="#0F172A";function wt(){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 $t(e,t){if(e===void 0)return an;let n=t[e];return n?n.fallback?`${un(n.family)}, ${n.fallback}`:un(n.family):e}function un(e){return/^[A-Za-z][A-Za-z0-9 -]*$/.test(e)?e:JSON.stringify(e)}function ln(e,t,n,r){let o={family:$t(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 a of i){if(typeof a=="string"){a.length>0&&s.push({text:a,style:o});continue}let u=a;u.text.length!==0&&s.push({text:u.text,style:{family:u.font===void 0?o.family:$t(u.font,n),size:u.size??o.size,weight:u.weight??o.weight,italic:u.italic??o.italic,underline:u.underline??!1,strike:u.strike??!1,fill:u.fill===void 0?o.fill:r(u.fill),letterSpacing:u.letterSpacing??o.letterSpacing,...u.link!==void 0&&D(u.link)?{link:u.link}:{}}})}return s}function _r(e,t){let n=[];for(let r of e)for(let o of r.text.split(/(\n)/))if(o!==""){if(o===`
|
|
6
|
-
`){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 Pr(e,t,n){let r=[...e.text],o=[],i="";for(let s of r){let a=i+s;if(i!==""&&n.advance(a,e.style)>t){o.push({text:i,style:e.style,w:n.advance(i,e.style),hardBreak:!1}),i=s;continue}i=a}return i!==""&&o.push({text:i,style:e.style,w:n.advance(i,e.style),hardBreak:e.hardBreak}),o.length>0?o:[e]}function pn(e,t){let{width:n,measure:r}=t,o=_r(r.itemize?e.flatMap(c=>r.itemize?.(c)??[c]):e,r);if(o.length===0){let c=e[0]?.style,f=c?t.lineHeight*c.size:0;return{lines:c?[Rr(c,t.lineHeight)]:[],width:0,height:f}}let i=[],s=[],a=0,u=()=>{i.push(s),s=[],a=0};for(let c of o){let f=s.length===0&&c.w>n&&n>0?Pr(c,n,r):[c];for(let d of f){let l=d.text.trimEnd(),y=l===d.text?d.w:r.advance(l,d.style);s.length>0&&a+y>n&&u(),s.push(d),a+=d.w,d.hardBreak&&u()}}return s.length>0&&i.push(s),Lr(i,t)}function Rr(e,t){let n=t*e.size;return{y:0,h:n,baseline:n*.8,w:0,spans:[]}}function Lr(e,t){let n=[],r=0,o=0;return e.forEach((i,s)=>{let a=i.map(v=>v.style.size),u=Math.max(...a,0),c=t.lineHeight*u,f=i.map(v=>t.measure.metrics(v.style)),d=Math.max(...f.map(v=>v.ascent),0),l=Math.max(...f.map(v=>v.descent),0),y=r+(c-(d+l))/2+d,b=Vr(i,t.measure),p=b.reduce((v,S)=>v+S.w,0);o=Math.max(o,p);let $=s===e.length-1||(i[i.length-1]?.hardBreak??!1),k=t.align==="justify"&&!$&&b.length>1,g=Math.max(0,t.width-p),N=t.align==="center"?g/2:t.align==="right"?g:0,m=k?g/(b.length-1):0,w=[],x=N;b.forEach((v,S)=>{w.push({text:v.text,style:v.style,x,w:v.w}),x+=v.w+(S<b.length-1?m:0)}),n.push({y:r,h:c,baseline:y,w:p,spans:Dr(w,k)}),r+=c}),{lines:n,width:o,height:r}}function Vr(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 Dr(e,t){if(t)return[...e];let n=[];for(let r of e){let o=n[n.length-1];if(o&&hn(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 hn(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 kt(e,t,n,r,o,i){let s={size:t.size??cn,weight:t.weight??fn,lineHeight:t.lineHeight??dn,letterSpacing:t.letterSpacing??0,italic:e.italic??!1,font:typeof e.font=="string"?e.font:void 0,fill:typeof e.fill=="string"?e.fill:Fe};return pn(ln(e.content,s,r,o),{width:n,align:e.align??"left",lineHeight:s.lineHeight,measure:i})}function vt(e,t,n){let r=t-n;return e.valign==="middle"?r/2:e.valign==="bottom"?r:0}var yn=["x","y","w","h","left","right","top","bottom","cx","cy"];function de(e){return yn.includes(e)}var mn=["parent","prev","next","self","root"];function bt(e){return mn.includes(e)}var M=class extends Error{position;constructor(t,n){super(t),this.position=n,this.name="ExprSyntaxError"}},gn=/[A-Za-z_]/,Et=/[A-Za-z0-9_]/;function St(e){let t=[],n=0,r=()=>{if(!gn.test(e[n]??""))throw new M(`Expected a name at position ${n}`,n);let s=n;for(;n<e.length&&Et.test(e[n]??"");)n++;return e.slice(s,n)},o=()=>{if(!Et.test(e[n]??""))throw new M(`Expected a name at position ${n}`,n);let s=n;for(;n<e.length&&Et.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 a=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 u=e.slice(a,n),c=Number(u);if(!Number.isFinite(c))throw new M(`Bad number "${u}"`,a);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(gn.test(s)){t.push({type:"word",path:i()});continue}if("+-*/()".includes(s)){n++,t.push({type:"op",value:s});continue}throw new M(`Unexpected character "${s}" at position ${n}`,n)}return t.push({type:"eof"}),t}var Fr={"+":1,"-":1,"*":2,"/":2};function je(e){try{let t=St(e),n=new Ot(t),r=n.parseBinary(0);return n.expectEof(),{ok:!0,ast:r}}catch(t){if(t instanceof M)return{ok:!1,message:t.message};throw t}}var Ot=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 M("Unexpected trailing input",this.index)}parseBinary(t){let n=this.parseUnary();for(;;){let r=this.peek();if(r.type!=="op"||!jr(r.value))break;let o=Fr[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 M(`@${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||!bt(n))throw new M(`Unknown name "${t.path.join(".")}". Use $token for a token or @id.edge for a node.`,this.index);if(r===void 0||!de(r)||o.length>0)throw new M(`${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 M("Missing closing parenthesis",this.index);return n}throw new M(`Unexpected "${t.value}"`,this.index)}case"eof":throw new M("Unexpected end of expression",this.index)}}};function jr(e){return e==="+"||e==="-"||e==="*"||e==="/"}function R(e,t){return`${e} ${t}`}function Mt(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 Tt(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 Nt(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 It(e,t,n){let r=d=>{let l=[];for(let y=n.parentOf.get(d);y!==void 0;y=n.parentOf.get(y))l.push(y);return l},o=r(e),i=r(t),s=new Set(i),a=o.find(d=>s.has(d)),u=d=>a===void 0?d:d.slice(0,d.indexOf(a)),c=new Map([[e,1]]),f=(d,l)=>{let y=(c.get(d)??0)+l;y===0?c.delete(d):c.set(d,y)};for(let d of u(o))f(d,1);for(let d of u(i))f(d,-1);return c}function At(e){switch(e){case"right":case"bottom":return 1;case"cx":case"cy":return .5;default:return 0}}function Ce(e){if(e==="x"||e==="w")return"w";if(e==="y"||e==="h")return"h"}function _t(e){let t=new Map,n=new Map,r=new Map,o=new Map,i=[];T(e.root,(f,d)=>{t.has(f.id)||t.set(f.id,f),i.push(f),d&&n.set(f.id,d.id),_(f)&&f.children.forEach((l,y)=>{let b=f.children[y-1],p=f.children[y+1];b&&r.set(l.id,b.id),p&&o.set(l.id,p.id)})});let s=new Map;for(let f of i){let d=n.get(f.id);for(;d!==void 0;){let l=t.get(d);if(!l||!oe(l))break;d=n.get(d)}d!==void 0&&s.set(f.id,d)}let a=new Map,u=new Map,c=f=>{if(_(f)){if(!oe(f)){let d=xn(f);d.forEach((l,y)=>{let b=d[y-1],p=d[y+1];b&&a.set(l.id,b.id),p&&u.set(l.id,p.id)})}for(let d of f.children)c(d)}};return c(e.root),{rootId:e.root.id,byId:t,parentOf:n,prevOf:r,nextOf:o,layoutParentOf:s,layoutPrevOf:a,layoutNextOf:u,order:i}}function xn(e){let t=[];for(let n of e.children)_(n)&&oe(n)?t.push(...xn(n)):t.push(n);return t}function Ue(e,t,n){if(e.kind==="relRef"){let i=Cr(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 de(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 Cr(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 Pt(e){let t=[],n=_t(e),r=Ur(n),o=new Set;Wr(r,t),Br(r,e,n,o,t);let i=zr(r);Gr(r,i,t);let s=Jr(r,i,e,n,o,t);return{nodes:Yr(e.root,s,r,t),problems:t}}function Ur(e){let t=new Map;for(let n of e.order){let r=n;for(let o of ke(n)){let i=r[o];i!==void 0&&t.set(R(n.id,o),{nodeId:n.id,prop:o,value:i,deps:[]})}}return t}function Wr(e,t){for(let n of e.values()){if(!P(n.value))continue;let r=je(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 Br(e,t,n,r,o){for(let i of e.values()){if(!i.ast)continue;let s=new Set,a=u=>{switch(u.kind){case"number":return;case"token":{let c=t.tokens[u.name];typeof c!="number"&&o.push({severity:"error",code:c===void 0?"unknown-token":"token-not-a-number",message:c===void 0?`Unknown token $${u.name}`:`Token $${u.name} is not a number`,nodeId:i.nodeId,prop:i.prop});return}case"percent":{let c=Ce(i.prop);if(!c)return;let f=n.layoutParentOf.get(i.nodeId),d=f===void 0?void 0:R(f,c);if(d===void 0||!e.has(d)){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(d);return}case"nodeRef":case"relRef":{let c=Ue(u,i.nodeId,n);if(!c.ok){r.add(u),o.push({severity:"error",code:"unknown-reference",message:c.message,nodeId:i.nodeId,prop:i.prop});return}let f=l=>{e.has(l)&&s.add(l)},d=Nt(c.edge);if(!d){for(let l of Mt(c.edge))f(R(c.nodeId,l));return}for(let l of It(c.nodeId,i.nodeId,n).keys())f(R(l,d));At(c.edge)!==0&&f(R(c.nodeId,d==="x"?"w":"h"));return}case"unary":a(u.operand);return;case"binary":a(u.left),a(u.right);return}};a(i.ast),i.deps=[...s]}}function zr(e){let t=new Map,n=new Map;for(let[i,s]of e){t.set(i,s.deps.length);for(let a of s.deps){let u=n.get(a);u?u.push(i):n.set(a,[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 a of n.get(s)??[]){let u=(t.get(a)??0)-1;t.set(a,u),u===0&&r.push(a)}}return o}function Gr(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 Jr(e,t,n,r,o,i){let s=new Map,a=(u,c)=>s.get(R(u,c))??0;for(let u of t){let c=e.get(u);if(c){if(!P(c.value)){s.set(u,c.value);continue}if(!c.ast){s.set(u,0);continue}s.set(u,$n(c.ast,c,n,r,o,i,a))}}return s}function $n(e,t,n,r,o,i,s){let a=u=>$n(u,t,n,r,o,i,s);switch(e.kind){case"number":return e.value;case"token":{let u=n.tokens[e.name];return typeof u=="number"?u:0}case"percent":{let u=Ce(t.prop);if(!u)return e.value/100;let c=r.layoutParentOf.get(t.nodeId);return c===void 0?0:e.value/100*s(c,u)}case"nodeRef":case"relRef":{if(o.has(e))return 0;let u=Ue(e,t.nodeId,r);if(!u.ok)return 0;let c=Nt(u.edge);if(!c)return Tt(u.edge,s(u.nodeId,"x"),s(u.nodeId,"y"),s(u.nodeId,"w"),s(u.nodeId,"h"));let f=At(u.edge)*s(u.nodeId,c==="x"?"w":"h");for(let[d,l]of It(u.nodeId,t.nodeId,r))f+=l*s(d,c);return f}case"unary":{let u=a(e.operand);return e.op==="-"?-u:u}case"binary":{let u=a(e.left),c=a(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 f=Xr(e.op,u,c);return Number.isFinite(f)?f:(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 Xr(e,t,n){switch(e){case"+":return t+n;case"-":return t-n;case"*":return t*n;case"/":return t/n}}function Yr(e,t,n,r){let o=new Map,i=(a,u)=>t.get(R(a,u))??0,s=(a,u,c)=>{let f=i(a.id,"x"),d=i(a.id,"y"),l=i(a.id,"w"),y=i(a.id,"h"),b={};for(let k of ke(a)){let g=R(a.id,k);n.has(g)&&(b[k]=t.get(g)??0)}(l<0||y<0)&&r.push({severity:"warning",code:"negative-size",message:`${a.id} resolved to a negative size`,nodeId:a.id});let p=u+f,$=c+d;if(o.set(a.id,{id:a.id,type:a.type,x:f,y:d,w:l,h:y,left:f,top:d,right:f+l,bottom:d+y,cx:f+l/2,cy:d+y/2,absX:p,absY:$,values:b}),_(a))for(let k of a.children)s(k,p,$)};return s(e,0,0),o}function Rt(e){switch(e.kind){case"text":{let t=Math.max(e.w,...e.lines.map(r=>r.w)),n=Math.max(e.y+e.h,...e.lines.map(r=>r.y+r.h));return{x:e.x,y:e.y,w:t,h:n-e.y}}case"vector":{let t=nt(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 ze(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 a=s.spread+s.blur;n=Math.min(n,e.x+s.x-a),r=Math.min(r,e.y+s.y-a),o=Math.max(o,e.x+e.w+s.x+a),i=Math.max(i,e.y+e.h+s.y+a)}return{x:n,y:r,w:o-n,h:i-r}}var vn="vd-paint-";var Be="#CBD5E1",bn="#FFFFFF";function En(e,t,n={}){let r=[...t.problems],o=[],i=[],s=n.measure??wt(),a=no(e.tokens,r),u=a.paint,c=new Map;T(e.root,(p,$)=>{if("hidden"in p&&p.hidden===!0)return!1;let k=$?c.get($.id):void 0,g=t.nodes.get(p.id);if(!g){c.set(p.id,k);return}if(p.type==="frame"){p.skip===!0&&$!==e.root&&r.push({severity:"warning",code:"skip-not-a-page",message:`${p.id}: skip only applies to a page, a frame at the top level`,nodeId:p.id,prop:"skip"});let m={x:g.absX,y:g.absY,w:Math.max(0,g.w),h:Math.max(0,g.h)};c.set(p.id,p.clip===!0?p.id:k),p.clip===!0&&i.push({id:p.id,...m,parent:k}),o.push({kind:"frame",id:p.id,...m,background:u(p.background,p.id,"background",m),clip:k,blend:p.blend??"normal",shadows:q(p.shadow,p.id,e.tokens,r),rotation:0});return}if(c.set(p.id,k),p.type==="text"){o.push(Kr(p,g,e,s,r,k,u));return}if(p.type==="image"){o.push({kind:"image",id:p.id,x:g.absX,y:g.absY,w:Math.max(0,g.w),h:Math.max(0,g.h),href:io(p,e,n.resolveAsset,r),fit:p.fit??"fill",radius:Math.max(0,g.values.radius??0),opacity:pe(g.values.opacity??1),clip:k,blend:p.blend??"normal",shadows:q(p.shadow,p.id,e.tokens,r),rotation:g.values.rotation??0});return}if(p.type==="ellipse"){let m=kn(g);o.push({kind:"ellipse",id:p.id,...m,fill:u(p.fill,p.id,"fill",m)??Be,stroke:u(p.stroke,p.id,"stroke",m),strokeWidth:g.values.strokeWidth??0,opacity:pe(g.values.opacity??1),clip:k,blend:p.blend??"normal",shadows:q(p.shadow,p.id,e.tokens,r),rotation:g.values.rotation??0});return}if(p.type==="vector"){o.push(to(p,g,r,k,u,q(p.shadow,p.id,e.tokens,r)));return}if(p.type!=="rect")return;let N=kn(g);o.push({kind:"rect",id:p.id,...N,fill:u(p.fill,p.id,"fill",N)??Be,stroke:u(p.stroke,p.id,"stroke",N),strokeWidth:g.values.strokeWidth??0,radius:Math.max(0,g.values.radius??0),opacity:pe(g.values.opacity??1),clip:k,blend:p.blend??"normal",shadows:q(p.shadow,p.id,e.tokens,r),rotation:g.values.rotation??0})});let f=t.nodes.get(e.root.id),d=e.root.w!==void 0&&e.root.h!==void 0,l=d?{x:0,y:0,width:Math.max(0,f?.w??0),height:Math.max(0,f?.h??0)}:Hr(o,i),y={x:l.x,y:l.y,w:l.width,h:l.height},b=u(e.root.background,e.root.id,"background",y);return{...l,background:d?b??bn:b,items:o,clips:i,gradients:a.gradients,problems:r}}function Hr(e,t){let n=new Map;for(let a of t){let u=a.parent===void 0?void 0:n.get(a.parent);n.set(a.id,u?wn(a,u):a)}let r=1/0,o=1/0,i=-1/0,s=-1/0;for(let a of e){let u=a.kind==="text"?Math.max(a.h,a.height):a.h,c=a.clip===void 0?void 0:n.get(a.clip),f=xt(ze({x:a.x,y:a.y,w:a.w,h:u},a.shadows),a.rotation,De(a)),d=c?wn(f,c):f;d.w<=0||d.h<=0||(r=Math.min(r,d.x),o=Math.min(o,d.y),i=Math.max(i,d.x+d.w),s=Math.max(s,d.y+d.h))}return Number.isFinite(r)?{x:r,y:o,width:i-r,height:s-o}:{x:0,y:0,width:0,height:0}}function wn(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 Lt(e,t={}){return En(e,Pt(e),t)}function Kr(e,t,n,r,o,i,s){let a=Math.max(0,t.w),u=Math.max(0,t.h),c={x:t.absX,y:t.absY,w:a,h:u},f=kt(e,t.values,a,n.fonts,l=>s(l,e.id,"fill",c)??Fe,r);f.height>u+.5&&o.push({severity:"warning",code:"text-overflow",message:`${e.id} needs ${Math.ceil(f.height)}px but its height is ${Math.round(u)}px`,nodeId:e.id,prop:"h"}),qr(e,n,o);let d=t.absY+vt(e,u,f.height);return{kind:"text",id:e.id,x:t.absX,y:t.absY,w:a,h:u,clip:i,blend:e.blend??"normal",shadows:q(e.shadow,e.id,n.tokens,o),rotation:t.values.rotation??0,opacity:pe(t.values.opacity??1),height:f.height,lines:f.lines.map(l=>({y:d+l.y,h:l.h,baseline:d+l.baseline,w:l.w,spans:l.spans.map(y=>({text:y.text,x:t.absX+y.x,y:d+l.baseline,w:y.w,style:y.style}))}))}}function qr(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=D(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"&&!Zr(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 Zr(e,t){let n=!1;return T(e.root,r=>{if(n)return!1;r.id===t&&r.type==="frame"&&(n=!0)}),n}var le=new Map,Qr=512;function eo(e){let t=le.get(e);if(t)return t;let n=qe(e);return le.size>=Qr&&le.delete(le.keys().next().value),le.set(e,n),n}function to(e,t,n,r,o,i){let s=Math.max(0,t.w),a=Math.max(0,t.h),u={x:t.absX,y:t.absY,w:s,h:a},{contours:c,error:f}=eo(e.d);f!==void 0&&n.push({severity:"error",code:"bad-path",message:`${e.id}: ${f}`,nodeId:e.id,prop:"d"}),e.view!==void 0&&Ie(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 d=tt(c,ot(rt(e.view,s,a),u));return{kind:"vector",id:e.id,...u,d:Ze(d),contours:d,fill:o(e.fill,e.id,"fill",u)??Be,stroke:o(e.stroke,e.id,"stroke",u),strokeWidth:t.values.strokeWidth??0,opacity:pe(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 Sn(e,t,n,r,o){if(e===void 0)return;if(P(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 kn(e){return{x:e.absX,y:e.absY,w:Math.max(0,e.w),h:Math.max(0,e.h)}}function no(e,t){let n=[],r=new Map;return{paint:(i,s,a,u)=>{let c=Sn(i,e,s,a,t);if(c===void 0)return;let f=yt(c);if("error"in f){t.push({severity:"error",code:"invalid-paint",message:`${s}: ${f.error}`,nodeId:s,prop:a});return}if(f.kind==="solid")return c;let d=`${s}\0${a}\0${c}`,l=r.get(d);if(l!==void 0)return`url(#${l})`;let y=[...r.keys()].filter($=>$.startsWith(`${s}\0${a}\0`)).length,b=`${vn}${s}-${a}${y===0?"":`-${y+1}`}`;r.set(d,b);let p=mt(f.stops).map($=>({offset:$.at,colour:On($.colour,e,s,a,t)}));return n.push(oo(f,b,u,ro(p))),`url(#${b})`},gradients:n}}function q(e,t,n,r){let o=Sn(e,n,t,"shadow",r);if(o===void 0)return[];let i=gt(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:On(s.colour,n,t,"shadow",r)}))}function ro(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 On(e,t,n,r,o){let i=t[e];return i===void 0?e:typeof i=="string"&&!Ve(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 oo(e,t,n,r){if(e.kind==="linear"){let c=e.angle*Math.PI/180,f=Math.sin(c),d=-Math.cos(c),l=(Math.abs(n.w*f)+Math.abs(n.h*d))/2,y=n.x+n.w/2,b=n.y+n.h/2;return{id:t,kind:"linear",x1:We(y-f*l),y1:We(b-d*l),x2:We(y+f*l),y2:We(b+d*l),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 a=s.x/s.y,u=Math.hypot(s.x/a,s.y);return{id:t,kind:"radial",cx:o,cy:i,rx:u*a,ry:u,stops:r}}function We(e){return Math.round(e*1e6)/1e6}function pe(e){return Math.min(Math.max(e,0),1)}function io(e,t,n,r){let o=P(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 Ge="vd-clip-";function Vt(e,t={}){let n=t.indent??" ",r={ids:t.ids??!0,prefix:t.idPrefix??""},o=h(e.width),i=h(e.height),s=`${h(e.x)} ${h(e.y)} ${o} ${i}`,a=[`<svg xmlns="http://www.w3.org/2000/svg" width="${o}" height="${i}" viewBox="${s}">`],u=e.items.filter(c=>c.shadows.length>0);if(e.clips.length>0||e.gradients.length>0||u.length>0){a.push(`${n}<defs>`);for(let c of e.clips)a.push(n+n+so(c,r.prefix));for(let c of e.gradients)a.push(n+n+Tn(c,r.prefix));for(let c of u)a.push(n+n+Nn(c,t.shadowsOnly,r.prefix));a.push(`${n}</defs>`)}e.background!==void 0&&a.push(`${n}<rect x="${h(e.x)}" y="${h(e.y)}" width="${o}" height="${i}" fill="${E(C(e.background,r))}"/>`);for(let c of e.items){let f=lo(c,r);f!==""&&a.push(n+f)}return a.push("</svg>"),`${a.join(`
|
|
7
|
-
`)}
|
|
8
|
-
`}function so(e,t){let n=e.parent===void 0?"":` clip-path="url(#${E(t+Ge+e.parent)})"`;return`<clipPath id="${E(t+Ge+e.id)}"${n}><rect x="${h(e.x)}" y="${h(e.y)}" width="${h(e.w)}" height="${h(e.h)}"/></clipPath>`}function uo(e){return Tn(e,"")}function Tn(e,t){let n=e.stops.map(o=>`<stop offset="${h(o.offset)}" stop-color="${E(o.colour)}"${o.opacity===void 0?"":` stop-opacity="${h(o.opacity)}"`}/>`).join(""),r=E(t+e.id);return e.kind==="linear"?`<linearGradient id="${r}" gradientUnits="userSpaceOnUse" x1="${h(e.x1)}" y1="${h(e.y1)}" x2="${h(e.x2)}" y2="${h(e.y2)}">${n}</linearGradient>`:`<radialGradient id="${r}" gradientUnits="userSpaceOnUse" cx="0" cy="0" r="1" gradientTransform="matrix(${h(e.rx)} 0 0 ${h(e.ry)} ${h(e.cx)} ${h(e.cy)})">${n}</radialGradient>`}var ao={cover:"xMidYMid slice",contain:"xMidYMid meet",fill:"none"},co="#94A3B8";function j(e,t){let n=e.clip===void 0?[]:[`clip-path="url(#${E(t+Ge+e.clip)})"`];return e.rotation!==0&&n.push(`transform="${In(e)}"`),e.shadows.length>0&&n.push(`filter="url(#${E(t+Dt+e.id)})"`),e.blend!=="normal"&&n.push(`style="mix-blend-mode:${e.blend}"`),n}var Dt="vd-shadow-";function fo(e,t=!1){return Nn(e,t,"")}function Nn(e,t,n){let r=ze(Rt(e),e.shadows),o=2,i=[];e.shadows.forEach((a,u)=>{let c=`s${u}`,f="SourceAlpha";a.spread!==0&&(i.push(`<feMorphology in="${f}" operator="${a.spread>0?"dilate":"erode"}" radius="${h(Math.abs(a.spread))}" result="${c}m"/>`),f=`${c}m`),a.blur>0&&(i.push(`<feGaussianBlur in="${f}" stdDeviation="${h(a.blur/2)}" result="${c}b"/>`),f=`${c}b`),i.push(`<feOffset in="${f}" dx="${h(a.x)}" dy="${h(a.y)}" result="${c}o"/>`,`<feFlood flood-color="${E(a.colour)}" result="${c}c"/>`,`<feComposite in="${c}c" in2="${c}o" operator="in" result="${c}"/>`)});let s=e.shadows.map((a,u)=>`<feMergeNode in="s${e.shadows.length-1-u}"/>`).join("");return`<filter id="${E(n+Dt+e.id)}" filterUnits="userSpaceOnUse" x="${h(r.x-o)}" y="${h(r.y-o)}" width="${h(r.w+o*2)}" height="${h(r.h+o*2)}" color-interpolation-filters="sRGB">`+i.join("")+`<feMerge>${s}${t?"":'<feMergeNode in="SourceGraphic"/>'}</feMerge></filter>`}function In(e){return`rotate(${h(e.rotation)} ${h(e.x+e.w/2)} ${h(e.y+e.h/2)})`}function An(e){return e.rotation!==0&&e.clip!==void 0}function lo(e,t){if(An(e)){let n=[`clip-path="url(#${E(t.prefix+Ge+e.clip)})"`];e.blend!=="normal"&&n.push(`style="mix-blend-mode:${e.blend}"`);let r=Mn({...e,clip:void 0,blend:"normal"},t);return r===""?"":`<g ${n.join(" ")}>${r}</g>`}return Mn(e,t)}function Mn(e,t){switch(e.kind){case"ellipse":return mo(e,t);case"frame":return po(e,t);case"image":return ho(e,t);case"rect":return yo(e,t);case"text":return xo(e,t);case"vector":return go(e,t)}}function C(e,t){return t.prefix!==""&&e.startsWith("url(#")?`url(#${t.prefix}${e.slice(5)}`:e}function po(e,t){let n=[];return t.ids&&n.push(`id="${E(e.id)}"`),n.push(`x="${h(e.x)}"`,`y="${h(e.y)}"`,`width="${h(e.w)}"`,`height="${h(e.h)}"`,`fill="${e.background===void 0?"none":E(C(e.background,t))}"`,...j(e,t.prefix)),`<rect ${n.join(" ")}/>`}function ho(e,t){let n=[];return t.ids&&n.push(`id="${E(e.id)}"`),n.push(`x="${h(e.x)}"`,`y="${h(e.y)}"`,`width="${h(e.w)}"`,`height="${h(e.h)}"`),e.href===void 0?(e.radius>0&&n.push(`rx="${h(e.radius)}"`),n.push('fill="none"',`stroke="${E(co)}"`,'stroke-width="1"','stroke-dasharray="4 4"',...j(e,t.prefix)),`<rect ${n.join(" ")}/>`):(n.push(`href="${E(e.href)}"`,`preserveAspectRatio="${ao[e.fit]}"`),e.opacity<1&&n.push(`opacity="${h(e.opacity)}"`),n.push(...j(e,t.prefix)),`<image ${n.join(" ")}/>`)}function yo(e,t){let n=[];return t.ids&&n.push(`id="${E(e.id)}"`),n.push(`x="${h(e.x)}"`,`y="${h(e.y)}"`,`width="${h(e.w)}"`,`height="${h(e.h)}"`),e.radius>0&&n.push(`rx="${h(e.radius)}"`),n.push(`fill="${E(C(e.fill,t))}"`),e.stroke!==void 0&&e.strokeWidth>0&&n.push(`stroke="${E(C(e.stroke,t))}"`,`stroke-width="${h(e.strokeWidth)}"`),e.opacity<1&&n.push(`opacity="${h(e.opacity)}"`),n.push(...j(e,t.prefix)),`<rect ${n.join(" ")}/>`}function _n(e,t){let n=[`fill="${E(C(e.fill,t))}"`];return e.stroke!==void 0&&e.strokeWidth>0&&n.push(`stroke="${E(C(e.stroke,t))}"`,`stroke-width="${h(e.strokeWidth)}"`),e.opacity<1&&n.push(`opacity="${h(e.opacity)}"`),n}function mo(e,t){let n=[];return t.ids&&n.push(`id="${E(e.id)}"`),n.push(`cx="${h(e.x+e.w/2)}"`,`cy="${h(e.y+e.h/2)}"`,`rx="${h(e.w/2)}"`,`ry="${h(e.h/2)}"`,..._n(e,t),...j(e,t.prefix)),`<ellipse ${n.join(" ")}/>`}function go(e,t){if(e.d==="")return"";let n=[];return t.ids&&n.push(`id="${E(e.id)}"`),n.push(`d="${E(e.d)}"`,..._n(e,t)),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(...j(e,t.prefix)),`<path ${n.join(" ")}/>`}function xo(e,t){if(e.lines.every(o=>o.spans.length===0))return"";let n=[];t.ids&&n.push(`id="${E(e.id)}"`),n.push('xml:space="preserve"'),e.opacity<1&&n.push(`opacity="${h(e.opacity)}"`),n.push(...j(e,t.prefix));let r=[];for(let o of e.lines)for(let i of o.spans)i.text!==""&&r.push($o(i,t));return`<text ${n.join(" ")}>${r.join("")}</text>`}function $o(e,t){let r=`<tspan ${[`x="${h(e.x)}"`,`y="${h(e.y)}"`,...wo(e.style,t)].join(" ")}>${ko(e.text)}</tspan>`;return e.style.link===void 0?r:`<a href="${E(e.style.link)}">${r}</a>`}function wo(e,t){let n=[`font-family="${E(e.family)}"`,`font-size="${h(e.size)}"`,`fill="${E(C(e.fill,t))}"`];e.weight!==400&&n.push(`font-weight="${h(e.weight)}"`),e.italic&&n.push('font-style="italic"'),e.letterSpacing!==0&&n.push(`letter-spacing="${h(e.letterSpacing)}"`);let r=[e.underline?"underline":"",e.strike?"line-through":""].filter(Boolean).join(" ");return r&&n.push(`text-decoration="${r}"`),n}function ko(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function E(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Ku(e,t={}){let{resolveAsset:n,measure:r,...o}=t;return Vt(Lt(e,{...n?{resolveAsset:n}:{},...r?{measure:r}:{}}),o)}export{T as a,Ye as b,D as c,Fn as d,Y as e,He as f,Ke as g,Jn as h,Rn as i,Ln as j,Vn as k,dr as l,sn as m,Pt as n,wt as o,En as p,Lt as q,Vt as r,uo as s,Dt as t,fo as u,In as v,An as w,Ku as x};
|